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 new crate op-beacon-core #7848

Merged
merged 7 commits into from
Apr 26, 2024
Merged

Conversation

rupam-04
Copy link
Contributor

Addresses #7648 and based on PR #7830 which I closed due to some conflicts

@rupam-04 rupam-04 requested a review from gakonst as a code owner April 24, 2024 18:44
@onbjerg onbjerg added C-debt A clean up/refactor of existing code A-op-reth Related to Optimism and op-reth labels Apr 24, 2024
@rupam-04
Copy link
Contributor Author

@mattsse I think I have covered all the changes you requested in PR #7830

Copy link
Collaborator

@mattsse mattsse left a 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

Comment on lines 61 to 62
#[cfg(feature = "optimism")]
{
Copy link
Collaborator

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() {
Copy link
Collaborator

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> {
Copy link
Collaborator

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() {
Copy link
Collaborator

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 }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Self { chain_spec }
assert!(chain_spec.is_optimism(), "optimism consensus only valid for optimism chains")
Self { chain_spec }

@rupam-04
Copy link
Contributor Author

@mattsse there seems to be a few conflicts again

@rupam-04
Copy link
Contributor Author

@mattsse Would changing this PR to a draft PR be better?

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

final nits

Comment on lines 31 to 33
if !chain_spec.is_optimism() {
panic!("Given chain spec is not optimism")
}
Copy link
Collaborator

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

Comment on lines 20 to 24
/// 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> {
Copy link
Collaborator

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

@rupam-04
Copy link
Contributor Author

Any updates on this? @mattsse

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

ty

@mattsse mattsse added this pull request to the merge queue Apr 26, 2024
Merged via the queue into paradigmxyz:main with commit d833f1a Apr 26, 2024
29 checks passed
@rupam-04 rupam-04 deleted the issue-7648 branch April 26, 2024 13:57
mw2000 pushed a commit to mw2000/reth that referenced this pull request Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-op-reth Related to Optimism and op-reth C-debt A clean up/refactor of existing code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants