-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
fix: Use OptimismBeaconConsensus in the OptimismNode #8487
Conversation
09e4576
to
a8ad8eb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, I wanted to do this for a while now,
need to check if we can make this work without features
c7df02d
to
06e26fd
Compare
#[cfg(feature = "optimism")] | ||
if ctx.chain_spec().is_optimism() { | ||
Arc::new(OptimismBeaconConsensus::new(ctx.chain_spec())) | ||
} else { | ||
Arc::new(EthBeaconConsensus::new(ctx.chain_spec())) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could this be part of node components so that each node builder implementer defines its own consensus interface implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, I believe it should be, yes, because it's stateful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, I'll push up another change soon with Consensus added as a new Component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ended up becoming a much larger change, but hopefully this is directionally aligned with your intent
06e26fd
to
86efc50
Compare
4aabc65
to
9b23f6d
Compare
#[cfg(feature = "optimism")] | ||
if ctx.chain_spec().is_optimism() { | ||
Arc::new(OptimismBeaconConsensus::new(ctx.chain_spec())) | ||
} else { | ||
Arc::new(EthBeaconConsensus::new(ctx.chain_spec())) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ended up becoming a much larger change, but hopefully this is directionally aligned with your intent
9b23f6d
to
1de97a6
Compare
447a370
to
7ddfc8c
Compare
f24a3af
to
d665768
Compare
d665768
to
ce4fff7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah now I get this,
this basically promotes the Consensus impl to a component.
imo this is reasonable and we should do this.
but we should keep using Arc<dyn>
separately, if you have any feedback re builder api/complexity, please let me know
/// The state of the tree | ||
/// | ||
/// Tracks all the chains, the block indices, and the block buffer. | ||
state: TreeState, | ||
/// External components (the database, consensus engine etc.) | ||
externals: TreeExternals<DB, E>, | ||
externals: TreeExternals<DB, C, E>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the Consensus type is super invasive and would introduce generics everywhere, I'd like to keep using Arc<dyn Consensus>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough - I wasn't sure whether the use of dyn
was actually preferred or only used as a placeholder for a future generic. Agreed that this additional type parameter increases the developer overhead anywhere that this struct is utilized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
developer overhead anywhere that this struct is utilized.
yeah we initial had this as a generic but pivoted to dyn because trait is object safe and the functions aren't called frequently.
we could likely use dyn for a few more generics but some aren't object safe, although we could likely make them, like Database
5609b54
to
c1125f6
Compare
c1125f6
to
a2b2422
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is great, tysm.
one nit re features
eventually, we will push the engine impls there as well.
crates/node/builder/Cargo.toml
Outdated
[features] | ||
optimism = [ | ||
"reth-primitives/optimism", | ||
"reth-rpc/optimism", | ||
"reth-provider/optimism", | ||
"reth-beacon-consensus/optimism", | ||
"reth-blockchain-tree/optimism", | ||
"reth-node-core/optimism", | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is required?
we want to keep this crate feature free and instead push all things down to the node
crates like you did with consensus
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch - this was left over from my original implementation
Ok(OptimismBeaconConsensus::new(ctx.chain_spec())) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great,
we can now remove all the optimism features from eth beacon consensus in a followup: #8739
27a9196
to
5513a07
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, tysm!
Consensus
as a new Node Component, with default implementations for theEthereumNode
andOptimismNode
.EthereumConsensusBuilder
builds eitherEthBeaconConsensus
orAutoSealConsensus
depending on whether or not dev mode is enabled