mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: Add OP cli flag to opt-in into discv4 discovery (#9938)
Co-authored-by: Dan Cline <6798349+Rjected@users.noreply.github.com>
This commit is contained in:
@ -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
|
||||
|
||||
@ -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)]
|
||||
|
||||
@ -59,7 +59,7 @@ 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())
|
||||
@ -67,7 +67,10 @@ impl OptimismNode {
|
||||
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())
|
||||
}
|
||||
@ -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
|
||||
@ -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(
|
||||
|
||||
Reference in New Issue
Block a user