Skip to content

net: resolve seed names by host name, add as CLI opt - #134

Open
torkelrogstad wants to merge 3 commits into
masterfrom
2026-08-13-seeds
Open

net: resolve seed names by host name, add as CLI opt#134
torkelrogstad wants to merge 3 commits into
masterfrom
2026-08-13-seeds

Conversation

@torkelrogstad

Copy link
Copy Markdown
Contributor

Take in seed nodes as host names in addition to raw IP addresses. This
makes it easier to reconfigure seeds without having to release new
Thunder versions. Re-resolve on startup. Expose passing custom seed
nodes via CLI.

Comment thread lib/net/mod.rs Outdated
Comment thread lib/node/mod.rs Outdated
Comment thread lib/net/mod.rs Outdated
Comment thread lib/net/mod.rs Outdated
Comment thread lib/net/peer/task.rs Outdated
Comment thread lib/net/peer/mod.rs Outdated
Comment thread lib/net/peer/mod.rs Outdated
Avoids trying to connect to invalid peers in a never ending loop
Take in seed nodes as host names in addition to raw IP addresses. This
makes it easier to reconfigure seeds without having to release new
Thunder versions. Re-resolve on startup. Expose passing custom seed
nodes via CLI.
Comment thread lib/net/peer/task.rs
// The mailbox stream sets `received_msg_successfully` once a
// message bearing our magic bytes has been received; forward
// that edge to the net task once, so it can persist the peer.
if !sent_validated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this bool still here? Clearly not needed since you have self.received_msg_successfully

Comment thread lib/net/error.rs
)]
pub struct ParsePeerAddress {
input: String,
reason: &'static str,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is sloppy, please use an enum for all of the possible failure cases

Comment thread lib/net/mod.rs
};
const DEFAULT_SEED_NODE_PORT: u16 = 4000 + THIS_SIDECHAIN as u16;

const SIGNET_SEED_NODES: &[(&str, u16)] = &[

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change the name? These are addresses, not nodes.
Also, this should be &[PeerAddress].

Comment thread lib/net/mod.rs
);
&[SIGNET_MINING_SERVER, BIP300_XYZ]
};
const DEFAULT_SEED_NODE_PORT: u16 = 4000 + THIS_SIDECHAIN as u16;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DEFAULT_PORT would be a better name

Comment thread lib/net/mod.rs
#[derive(
Clone, Debug, Eq, Hash, PartialEq, serde::Deserialize, serde::Serialize,
)]
pub struct PeerAddress {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be in types/net.rs instead. This would also make it usable in thunder_app_rpc_api.

Comment thread lib/net/mod.rs
}
}

/// Known peers and seed nodes are not dialed here: the net task reads

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They were not dialed before this PR! Now the known_peers DB is not initialized, either.

Comment thread lib/net/mod.rs

tracing::trace!(%addr, "wrote peer to database");
// Not written to `known_peers` here: the handshake proves nothing about
// which network the peer is on. Recorded once it emits `Validated`.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is unnecessary, and could be worded better, ie. "Written to known_peers once we receive a message from the peer that starts with the magic network bytes."

Comment thread lib/node/net_task.rs
// attempting to reorg to the new tip, on the corresponding oneshot
// receiver.
NewTipReady(Tip, Option<SocketAddr>, Option<oneshot::Sender<bool>>),
// Dial an initial peer, trying its resolved socket addresses

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the net task should handle this. Each peer connection task should handle dialing.

Comment thread lib/node/net_task.rs
.get(&addr)
.cloned()
.unwrap_or_else(|| PeerAddress::from(addr));
// The peer is connected, so its other resolved

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is actually fine to dial fallback addresses if a peer disconnects, and it is no longer possible to connect to the first validated address

Comment thread app/cli.rs
/// more than once, and is dialed in addition to the network's built-in seed
/// nodes.
#[arg(long = "seed-node")]
seed_nodes: Vec<thunder::net::PeerAddress>,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename this to add-peer, mirroring bitcoind's -addnode startup option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants