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: allow syncing op-mainnet with only state and without importing blocks/receipts #10850

Merged
merged 26 commits into from
Sep 18, 2024

Conversation

joshieDo
Copy link
Collaborator

@joshieDo joshieDo commented Sep 11, 2024

Running optimism mainnet is an hard endeavour since on top of state (14G uncompressed / 4GB compressed), one needs to export (from op-geth) and import blocks (103G / 43G) and receipts (173G / 71G). The process of acquiring this historical data is also quite troublesome.

On top of that, these blocks cannot even be executed, so they are there only for historical/RPC purposes.

Proposing adding op-reth init-state --chain optimism --without-ovm world_trie.jsonl which just imports state and readies the chain for syncing.

It will generate a dummy chain (with no transactions) up the last OVM block header. It then, appends the real Bedrock block. Takes around 90seconds and 14G which come from inserting >100_000_000 empty headers.

@joshieDo joshieDo added C-enhancement New feature or request A-cli Related to the reth CLI A-op-reth Related to Optimism and op-reth labels Sep 11, 2024
@joshieDo joshieDo changed the title feat: allow syncing op-mainnet with only state and without importing blocks/receipts feat: allow syncing op-mainnet with only state and without importing blocks/receipts Sep 11, 2024
@emhane
Copy link
Member

emhane commented Sep 12, 2024

will be great for testing

joshieDo and others added 2 commits September 16, 2024 11:17
Co-authored-by: Alexey Shekhirin <a.shekhirin@gmail.com>
Co-authored-by: Alexey Shekhirin <a.shekhirin@gmail.com>
Copy link
Member

@emhane emhane left a comment

Choose a reason for hiding this comment

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

We need to edit rpc for this too, any queries made for blocks in the ovm range, need to return an error. Alternatively, we need to add docs explaining that rpc responses may return undefined behaviour. Needs to include an exhaustive list of the rpc endpoints that are effected, and how, so that no one bases their scraping on this. Maybe logging a warning "don't use rpc for scraping" if op mainnet is started with dummy blocks, is sufficient.

@joshieDo
Copy link
Collaborator Author

i feel like that's overblown. an empty response should suffice imo. this is happening for txs/receips, but need to add that for the block then, so it doesnt return an invalid block

scrapers that own the node are aware of the lack of ovm historical data
scrapers that use 3rd party nodes, should be informed by the 3rd party

@joshieDo joshieDo marked this pull request as ready for review September 17, 2024 20:31
Copy link
Member

@gakonst gakonst left a comment

Choose a reason for hiding this comment

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

Super supportive and something we should have done from the beginning

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.

a few more suggestions and nits

book/run/sync-op-mainnet.md Outdated Show resolved Hide resolved
Comment on lines 125 to 128
assert_eq!(
sf_provider.latest_writer(segment)?.user_header().block_end(),
Some(BEDROCK_HEADER.number - 1)
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should include a message because will panic

/// * Headers: It will push an empty block.
/// * Transactions: It will not push any tx, only increments the end block range.
/// * Receipts: It will not push any receipt, only increments the end block range.
fn append_dummy_chain(sf_provider: &StaticFileProvider) -> Result<(), eyre::Error> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we make this accept the target as argument, could be useful in the future

let receipts_writer = sf_provider.latest_writer(StaticFileSegment::Receipts)?;
let (tx, rx) = std::sync::mpsc::channel();

rayon::scope(|s| {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should be fine because this is the only thing we're running, even if this does a lot of IO.

still would prefer regular thread for this.

@joshieDo joshieDo added this pull request to the merge queue Sep 18, 2024
Merged via the queue into main with commit c2019e3 Sep 18, 2024
36 checks passed
@joshieDo joshieDo deleted the joshie/dummy-ovm branch September 18, 2024 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cli Related to the reth CLI A-op-reth Related to Optimism and op-reth C-enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants