-
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
feat: add new crate op-beacon-core #7848
Conversation
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 simplify a few things because this is now intended for OP only
#[cfg(feature = "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.
this crate is now specific to optimism,
we can remove all the cfgs here
// Goerli and early OP exception: | ||
// * If the network is goerli pre-merge, ignore the extradata check, since we do not | ||
// support clique. Same goes for OP blocks below Bedrock. | ||
if self.chain_spec.chain != Chain::goerli() && !self.chain_spec.is_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.
this can be removed because this is expected to be used for OP
/// | ||
/// From yellow paper: extraData: An arbitrary byte array containing data relevant to this block. | ||
/// This must be 32 bytes or fewer; formally Hx. | ||
fn validate_header_extradata(header: &Header) -> Result<(), ConsensusError> { |
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.
let's move this to consensus-common and reuse
} | ||
|
||
if is_post_merge { | ||
if !self.chain_spec.is_optimism() && !header.is_zero_difficulty() { |
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.
rm non op checks
impl OptimismBeaconConsensus { | ||
/// Create a new instance of [OptimismBeaconConsensus] | ||
pub fn new(chain_spec: Arc<ChainSpec>) -> Self { | ||
Self { 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.
Self { chain_spec } | |
assert!(chain_spec.is_optimism(), "optimism consensus only valid for optimism chains") | |
Self { chain_spec } |
@mattsse there seems to be a few conflicts again |
@mattsse Would changing this PR to a draft PR be better? |
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.
final nits
if !chain_spec.is_optimism() { | ||
panic!("Given chain spec is not 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.
this panic is redundant because unreachable due to the assert, we can remove this
crates/consensus/common/src/lib.rs
Outdated
/// Validates the header's extradata according to the beacon consensus rules. | ||
/// | ||
/// From yellow paper: extraData: An arbitrary byte array containing data relevant to this block. | ||
/// This must be 32 bytes or fewer; formally Hx. | ||
pub fn validate_header_extradata(header: &Header) -> Result<(), ConsensusError> { |
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.
let's move to mod validation
Any updates on this? @mattsse |
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.
ty
Co-authored-by: Matthias Seitz <[email protected]>
Addresses #7648 and based on PR #7830 which I closed due to some conflicts