Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add OP cli flag to opt-in into discv4 discovery #9938

Merged
merged 3 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions book/run/optimism.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ The `optimism` feature flag in `op-reth` adds several new CLI flags to the `reth
1. `--rollup.sequencer-http <uri>` - The sequencer endpoint to connect to. Transactions sent to the `op-reth` EL are also forwarded to this sequencer endpoint for inclusion, as the sequencer is the entity that builds blocks on OP Stack chains.
1. `--rollup.disable-tx-pool-gossip` - Disables gossiping of transactions in the mempool to peers. This can be omitted for personal nodes, though providers should always opt to enable this flag.
1. `--rollup.enable-genesis-walkback` - Disables setting the forkchoice status to tip on startup, making the `op-node` walk back to genesis and verify the integrity of the chain before starting to sync. This can be omitted unless a corruption of local chainstate is suspected.
1. `--rollup.discovery.v4` - Enables the discovery v4 protocol for peer discovery.

First, ensure that your L1 archival node is running and synced to tip. Also make sure that the beacon node / consensus layer client is running and has http APIs enabled. Then, start `op-reth` with the `--rollup.sequencer-http` flag set to the `Base Mainnet` sequencer endpoint:
```sh
Expand Down
4 changes: 4 additions & 0 deletions crates/optimism/node/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ pub struct RollupArgs {
/// that this flag is not yet functional.
#[arg(long = "rollup.compute-pending-block")]
pub compute_pending_block: bool,

/// enables discovery v4 if provided
#[arg(long = "rollup.discovery.v4", default_value = "false")]
pub discovery_v4: bool,
}

#[cfg(test)]
Expand Down
16 changes: 11 additions & 5 deletions crates/optimism/node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,18 @@ impl OptimismNode {
where
Node: FullNodeTypes<Engine = OptimismEngineTypes>,
{
let RollupArgs { disable_txpool_gossip, compute_pending_block, .. } = args;
let RollupArgs { disable_txpool_gossip, compute_pending_block, discovery_v4, .. } = args;
ComponentsBuilder::default()
.node_types::<Node>()
.pool(OptimismPoolBuilder::default())
.payload(OptimismPayloadBuilder::new(
compute_pending_block,
OptimismEvmConfig::default(),
))
.network(OptimismNetworkBuilder { disable_txpool_gossip })
.network(OptimismNetworkBuilder {
disable_txpool_gossip,
disable_discovery_v4: !discovery_v4,
})
.executor(OptimismExecutorBuilder::default())
.consensus(OptimismConsensusBuilder::default())
}
Expand Down Expand Up @@ -274,6 +277,8 @@ where
pub struct OptimismNetworkBuilder {
/// Disable transaction pool gossip
pub disable_txpool_gossip: bool,
/// Disable discovery v4
pub disable_discovery_v4: bool,
}

impl<Node, Pool> NetworkBuilder<Node, Pool> for OptimismNetworkBuilder
Expand All @@ -286,16 +291,17 @@ where
ctx: &BuilderContext<Node>,
pool: Pool,
) -> eyre::Result<NetworkHandle> {
let Self { disable_txpool_gossip } = self;
let Self { disable_txpool_gossip, disable_discovery_v4 } = self;

let args = &ctx.config().network;

let network_builder = ctx
.network_config_builder()?
// apply discovery settings
.apply(|mut builder| {
let rlpx_socket = (args.addr, args.port).into();

if disable_discovery_v4 || args.discovery.disable_discovery {
builder = builder.disable_discv4_discovery();
}
if !args.discovery.disable_discovery {
builder = builder.discovery_v5(
args.discovery.discovery_v5_builder(
Expand Down
Loading