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

chore: Read Superchain genesis config from compressed files #14562

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

cakevm
Copy link
Contributor

@cakevm cakevm commented Feb 18, 2025

Add functions to read Genesis JSON from a zip file, allowing large JSON files to be removed from the repository.

Requires to work: alloy-rs/alloy#2073 to read the ChainConfig from the toml files

Added BSL-1.0 license. See here for compatibility to MIT/Apache 2.0

@mattsse: Seeking for advice how to get rid of std:io

@mattsse mattsse self-assigned this Feb 18, 2025
@mattsse mattsse added the A-op-reth Related to Optimism and op-reth label Feb 18, 2025
@mattsse mattsse added this to the release 1.2.1 milestone Feb 18, 2025
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.

@clabby @refcell

is there a use case for these static chainspecs in kona?

I guess it would depend how we proceed with #14571

we likely need to separate parts of the chainspec logic, like hardfork activations and maybe fee params not necessarily genesis

so we could feature gate these to std for now probably

@cakevm cakevm requested a review from joshieDo as a code owner February 19, 2025 12:21
@cakevm cakevm force-pushed the superchain-config branch 5 times, most recently from c7cb9d5 to ba5a4e2 Compare February 19, 2025 12:54
@clabby
Copy link
Collaborator

clabby commented Feb 19, 2025

@clabby @refcell

is there a use case for these static chainspecs in kona?

I guess it would depend how we proceed with #14571

we likely need to separate parts of the chainspec logic, like hardfork activations and maybe fee params not necessarily genesis

so we could feature gate these to std for now probably

Yeah, we could use them :D

fwiw, @refcell already has some rust bindings set up for the superchain-registry here. We use these bindings to pull in our RollupConfigs (think CL ChainSpec) from the upstream source of truth. It'd be awesome for us to saturate these ChainSpecs from that information. The genesis files over there are also all compressed w/ zstd.

@cakevm cakevm changed the title [DRAFT] chore: Read Superchain config from compressed zip [DRAFT] chore: Read Superchain genesis config from compressed file Feb 20, 2025
@cakevm cakevm changed the title [DRAFT] chore: Read Superchain genesis config from compressed file chore: Read Superchain genesis config from compressed files Feb 20, 2025
@cakevm
Copy link
Contributor Author

cakevm commented Feb 20, 2025

@mattsse This PR is ready for review. no-std is finally working. Here some remarks:

  • This PR is a step forward in reading config and genesis from the Superchain registry files. I only did it for base for now, as I’d like to keep this PR lean and make it more generic in another PR.
  • I could not find a reasonable way to handle ZIP, TOML, and ZSTD in no-std. For that reason, the config files are preprocessed and converted to JSON, and the compression method is changed.
  • I added the superchain_registry module with the intention of potentially extracting it to Alloy later for others to use. This helps limit the exposed methods and assess what we actually need.
  • I kept the "config:null" workaround until I get feedback from: Wish for clarification if "config" field in genesis files can be used ethereum-optimism/superchain-registry#901
  • I remove the op chain specific json files from the other chainspec. I could not see any usage
  • All genesis files are now in total 7,5MB. Compression methods like brotli gave better results. But I settled for more convenient to use miniz_oxide. This is something that could be improved in the future.

@cakevm
Copy link
Contributor Author

cakevm commented Feb 22, 2025

Small update: Now setting fields (e.g., eip150_block: Some(0),) like op-geth instead of defaulting to None. I feel this makes comparisons easier. I skipped it before because I could not see the requirement.

If you serialize and compare genesis used in BASE_MAINNET and BASE_SEPOLIA, you will see new fields introduced by this PR. The rest is the same:

base-mainnet:

14442a14443,14444
>     "cancunTime": 1710374401,
>     "canyonTime": 1704992401,
14445a14448,14449
>     "deltaTime": 1708560000,
>     "ecotoneTime": 1710374401,
14448a14453,14454
>     "fjordTime": 1720627201,
>     "graniteTime": 1726070401,
14449a14456
>     "holoceneTime": 1736445601,
14456a14464
>       "eip1559DenominatorCanyon": 250,
14460a14469
>     "shanghaiTime": 1704992401,

base-sepolia:

15224a15225,15226
>     "cancunTime": 1708534800,
>     "canyonTime": 1699981200,
15227a15230,15231
>     "deltaTime": 1703203200,
>     "ecotoneTime": 1708534800,
15230a15235,15236
>     "fjordTime": 1716998400,
>     "graniteTime": 1723478400,
15231a15238
>     "holoceneTime": 1732633200,
15238a15246
>       "eip1559DenominatorCanyon": 250,
15242a15251
>     "shanghaiTime": 1699981200,

How to get this result: Checkout main, and this PR and serialize the genesis value. Then compare the results with:
diff <(jq --sort-keys . base_before.json) <(jq --sort-keys . base_after.json)

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants