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

Snap Sync: consensus: handle legacy pre-bedrock header verification #182

Merged
merged 3 commits into from
Jan 22, 2024

Conversation

protolambda
Copy link
Collaborator

Description

Handle legacy pre-bedrock block-headers in consensus validation, to support snap-syncing without prior data-dir.

Very experimental. See optimism monorepo PR for context.

Copy link
Contributor

@trianglesphere trianglesphere left a comment

Choose a reason for hiding this comment

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

PR is looking good. It needs a some lints to be fixed, but I'd like to get this in

consensus/beacon/consensus.go Outdated Show resolved Hide resolved
consensus/beacon/oplegacy.go Outdated Show resolved Hide resolved
consensus/beacon/consensus.go Show resolved Hide resolved
@trianglesphere trianglesphere marked this pull request as ready for review November 30, 2023 23:45
@sebastianst sebastianst self-assigned this Dec 13, 2023
@sebastianst sebastianst force-pushed the legacy-state-sync-support branch from 5a9ad64 to 07b934f Compare January 3, 2024 15:13
@sebastianst sebastianst changed the title consensus: handle legacy pre-bedrock header verification Snap Sync: consensus: handle legacy pre-bedrock header verification Jan 11, 2024
@sebastianst sebastianst force-pushed the legacy-state-sync-support branch from 07b934f to fb9c707 Compare January 11, 2024 19:20
Copy link
Member

@sebastianst sebastianst left a comment

Choose a reason for hiding this comment

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

We should run a test in our snap sync infra before merging.

consensus/beacon/consensus.go Show resolved Hide resolved
consensus/beacon/oplegacy.go Outdated Show resolved Hide resolved
Copy link
Contributor

@trianglesphere trianglesphere left a comment

Choose a reason for hiding this comment

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

LGTM. I've also successfully used this code to snap sync op-goerli.

@protolambda protolambda force-pushed the legacy-state-sync-support branch from 2713f2d to 3080d04 Compare January 20, 2024 00:45
@protolambda
Copy link
Collaborator Author

Rebased on latest optimism branch, to resolve some conflicts with the receipts tests/code. (basefee->baseFee was renamed).

Fixed the unit-test, but had to jump through some hoops to make it work:

  • historical blocks tests generates a chain
  • config of above sets Bedrock at block 5
  • chain import requires EVM processing
  • EVM fails for < bedrock blocks, since we enforce don't support blocks to be processed pre-bedrock with EVM

Solution:

  • generate with ethash faker as pre-bedrock consensus, like the upstream geth tests.
  • swap the consensus of the node that we create (which by default creates a beacon consensus, wrapping an op-legacy consensus, for an optimism-configured chain-config)
  • import the blocks
  • swap back the consensus to op-legacy.

Related fixes:

  • When loading receipts metadata, don't hydrate the L1-fee info with data if it's pre-bedrock. Don't just check if it's not a 1-tx block (as all pre-bedrock blocks are really on mainnet), since some tests have more txs than that.
  • When checking if TTD has been reached, and if it's an optimism config, then enforce the bedrock block as the strict transition. Don't fall back on any TTD or ethash logic if it's not been reached yet, as there shouldn't be any other way to reach "merge" on an op-stack chain.

cc @trianglesphere, I think this unblocks this PR. PTAL

@trianglesphere trianglesphere merged commit ec72ec6 into optimism Jan 22, 2024
10 checks passed
@trianglesphere trianglesphere deleted the legacy-state-sync-support branch January 22, 2024 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants