Skip to content

chore(l1,l2): ordered genesis files #2713

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

Merged
merged 31 commits into from
May 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4e0c17f
chore: sort genesis files
fkrause98 May 8, 2025
7ad873d
feat: orderly write json to file
fkrause98 May 8, 2025
b243eba
lint: fix
fkrause98 May 8, 2025
6f03475
Revert "chore: sort genesis files"
fkrause98 May 9, 2025
c810910
chore: sort jsons
fkrause98 May 9, 2025
1b9e0db
feat: functionality to sort genesis files
fkrause98 May 9, 2025
278b474
docs: update comment
fkrause98 May 9, 2025
722ce5f
feat: add genesis sorter file
fkrause98 May 12, 2025
062d66c
chore: ordere some more files
fkrause98 May 12, 2025
8222f59
feat: also order config keys
fkrause98 May 12, 2025
96678fc
chore: update config in genesis files
fkrause98 May 12, 2025
1bbeaa4
Merge branch 'main' into ordered_genesis_files
fkrause98 May 12, 2025
167c1e2
chore: sort genesis files
fkrause98 May 12, 2025
14cc4dc
chore: move genesis.rs to a tools crate
fkrause98 May 14, 2025
b78ee94
chore: remove old genesis sorter
fkrause98 May 14, 2025
934ce29
lint: remove extra new line
fkrause98 May 14, 2025
aa4bf76
fix: remove declared genesis module
fkrause98 May 14, 2025
16f9a77
refactor: move tools
fkrause98 May 15, 2025
f1d2d9f
refactor: move tools
fkrause98 May 15, 2025
72adaa3
Merge branch 'main' into ordered_genesis_files
fkrause98 May 15, 2025
11c33e5
lint: sort genesis files
fkrause98 May 15, 2025
47d9fc3
lint: fix warnings
fkrause98 May 15, 2025
176a991
lint: clippy
fkrause98 May 15, 2025
3a064b5
tools: move write_genesis_as_json to tools
fkrause98 May 15, 2025
e82c028
feat: serde_json preserve_order
fkrause98 May 15, 2025
eadc3f9
go back to default serde_json in ethrex_common
fkrause98 May 15, 2025
5c624cd
chore: fix null values
fkrause98 May 15, 2025
325d4ee
lint: clippy
fkrause98 May 15, 2025
b1c386a
Merge branch 'main' into ordered_genesis_files
fkrause98 May 15, 2025
174613f
fix: add tools copy to dockerfile
fkrause98 May 15, 2025
74bae84
Merge branch 'main' into ordered_genesis_files
fkrause98 May 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ members = [
"crates/storage",
"crates/vm",
"crates/vm/levm",
"crates/vm/levm/bench/revm_comparison",
"crates/vm/levm/bench/revm_comparison"
]
resolver = "2"

Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ WORKDIR /ethrex

FROM chef AS planner
COPY crates ./crates
COPY tools ./tools
COPY cmd ./cmd
COPY Cargo.* .
# Determine the crates that need to be built from dependencies
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,6 @@ rm-test-db: ## 🛑 Removes the DB used by the ethrex client used for testing

test_data/ERC20/ERC20.bin: ## 🔨 Build the ERC20 contract for the load test
solc ./test_data/ERC20.sol -o $@

sort-genesis-files:
cd ./tools && cargo run
1 change: 1 addition & 0 deletions crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ rayon = "1.5"
[dev-dependencies]
hex-literal.workspace = true


[features]
default = []
c-kzg = ["dep:c-kzg"]
Expand Down
3 changes: 1 addition & 2 deletions crates/common/types/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ impl ChainConfig {
}

#[allow(unused)]
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct GenesisAccount {
#[serde(default, with = "crate::serde_utils::bytes")]
pub code: Bytes,
Expand Down Expand Up @@ -372,7 +372,6 @@ impl Genesis {
Trie::compute_hash_from_unsorted_iter(iter)
}
}

#[cfg(test)]
mod tests {
use std::str::FromStr;
Expand Down
1 change: 1 addition & 0 deletions crates/l2/contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ ethrex-l2 = { path = "../../l2" }
ethrex-sdk = { path = "../../l2/sdk" }
ethrex-common = { path = "../../common" }
ethrex-rpc = { path = "../../networking/rpc" }
tools = { path = "../../../tools" }

[[bin]]
name = "ethrex_l2_l1_deployer"
Expand Down
10 changes: 4 additions & 6 deletions crates/l2/contracts/bin/system_contracts_updater/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::collections::HashMap;

use bytes::Bytes;
use clap::Parser;
use cli::SystemContractsUpdaterOptions;
Expand All @@ -8,7 +6,8 @@ use ethrex_common::types::GenesisAccount;
use ethrex_common::U256;
use ethrex_l2::utils::test_data_io::read_genesis_file;
use ethrex_l2_sdk::{compile_contract, COMMON_BRIDGE_L2_ADDRESS};

use std::{collections::HashMap, io::ErrorKind, path::Path};
use tools::genesis::write_genesis_as_json;
mod cli;
mod error;

Expand All @@ -34,9 +33,8 @@ fn update_genesis_file(l2_genesis_path: &str) -> Result<(), SystemContractsUpdat
},
);

let modified_genesis = serde_json::to_string(&genesis)?;

std::fs::write(l2_genesis_path, modified_genesis)?;
write_genesis_as_json(genesis, Path::new(l2_genesis_path))
.map_err(|err_msg| std::io::Error::new(ErrorKind::Other, err_msg))?;

println!("Updated L2 genesis file.");

Expand Down
239 changes: 153 additions & 86 deletions test_data/genesis-execution-api.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"config": {
"ethash": {},
"chainId": 3503995874084926,
"homesteadBlock": 0,
"daoForkSupport": false,
"eip150Block": 0,
"eip155Block": 0,
"eip158Block": 0,
Expand All @@ -15,11 +15,12 @@
"londonBlock": 0,
"arrowGlacierBlock": 0,
"grayGlacierBlock": 0,
"mergeNetsplitBlock": 0,
"terminalTotalDifficulty": 131072,
"terminalTotalDifficultyPassed": false,
"shanghaiTime": 0,
"cancunTime": 0,
"pragueTime": 0,
"depositContractAddress": "0x00000000219ab540356cbb839cbe05303d7705fa",
"blobSchedule": {
"cancun": {
"target": 3,
Expand All @@ -32,110 +33,176 @@
"baseFeeUpdateFraction": 5007716
}
},
"depositContractAddress": "0x00000000219ab540356cBB839Cbe05303d7705Fa"
"mergeNetsplitBlock": 0
},
"nonce": "0x0",
"timestamp": "0x0",
"timestamp": "0",
"extraData": "0x68697665636861696e",
"gasLimit": "0x23f3e20",
"difficulty": "0x20000",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
"00000961ef480eb55e80d19ad83579a64c007002": {
"0x00000961ef480eb55e80d19ad83579a64c007002": {
"code": "0x3373fffffffffffffffffffffffffffffffffffffffe1460cb5760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff146101f457600182026001905f5b5f82111560685781019083028483029004916001019190604d565b909390049250505036603814608857366101f457346101f4575f5260205ff35b34106101f457600154600101600155600354806003026004013381556001015f35815560010160203590553360601b5f5260385f601437604c5fa0600101600355005b6003546002548082038060101160df575060105b5f5b8181146101835782810160030260040181604c02815460601b8152601401816001015481526020019060020154807fffffffffffffffffffffffffffffffff00000000000000000000000000000000168252906010019060401c908160381c81600701538160301c81600601538160281c81600501538160201c81600401538160181c81600301538160101c81600201538160081c81600101535360010160e1565b910180921461019557906002556101a0565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14156101cd57505f5b6001546002828201116101e25750505f6101e8565b01600290035b5f555f600155604c025ff35b5f5ffd",
"balance": "0x1"
"storage": {},
"balance": "0x1",
"nonce": "0x0"
},
"0000bbddc7ce488642fb579f8b00f3a590007251": {
"0x0000bbddc7ce488642fb579f8b00f3a590007251": {
"code": "0x3373fffffffffffffffffffffffffffffffffffffffe1460d35760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1461019a57600182026001905f5b5f82111560685781019083028483029004916001019190604d565b9093900492505050366060146088573661019a573461019a575f5260205ff35b341061019a57600154600101600155600354806004026004013381556001015f358155600101602035815560010160403590553360601b5f5260605f60143760745fa0600101600355005b6003546002548082038060021160e7575060025b5f5b8181146101295782810160040260040181607402815460601b815260140181600101548152602001816002015481526020019060030154905260010160e9565b910180921461013b5790600255610146565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff141561017357505f5b6001546001828201116101885750505f61018e565b01600190035b5f555f6001556074025ff35b5f5ffd",
"balance": "0x1"
"storage": {},
"balance": "0x1",
"nonce": "0x0"
},
"0000f90827f1c53a10cb7a02335b175320002935": {
"0x0000f90827f1c53a10cb7a02335b175320002935": {
"code": "0x3373fffffffffffffffffffffffffffffffffffffffe14604657602036036042575f35600143038111604257611fff81430311604257611fff9006545f5260205ff35b5f5ffd5b5f35611fff60014303065500",
"balance": "0x1"
"storage": {},
"balance": "0x1",
"nonce": "0x0"
},
"000f3df6d732807ef1319fb7b8bb8522d0beac02": {
"0x000f3df6d732807ef1319fb7b8bb8522d0beac02": {
"code": "0x3373fffffffffffffffffffffffffffffffffffffffe14604d57602036146024575f5ffd5b5f35801560495762001fff810690815414603c575f5ffd5b62001fff01545f5260205ff35b5f5ffd5b62001fff42064281555f359062001fff015500",
"balance": "0x2a"
},
"0c2c51a0990aee1d73c1228de158688341557508": {
"balance": "0xc097ce7bc90715b34b9f1000000000"
},
"14e46043e63d0e3cdcf2530519f4cfaf35058cb2": {
"balance": "0xc097ce7bc90715b34b9f1000000000"
},
"16c57edf7fa9d9525378b0b81bf8a3ced0620c1c": {
"balance": "0xc097ce7bc90715b34b9f1000000000"
},
"1f4924b14f34e24159387c0a4cdbaa32f3ddb0cf": {
"balance": "0xc097ce7bc90715b34b9f1000000000"
},
"1f5bde34b4afc686f136c7a3cb6ec376f7357759": {
"balance": "0xc097ce7bc90715b34b9f1000000000"
},
"2d389075be5be9f2246ad654ce152cf05990b209": {
"balance": "0xc097ce7bc90715b34b9f1000000000"
},
"3ae75c08b4c907eb63a8960c45b86e1e9ab6123c": {
"balance": "0xc097ce7bc90715b34b9f1000000000"
},
"4340ee1b812acb40a1eb561c019c327b243b92df": {
"balance": "0xc097ce7bc90715b34b9f1000000000"
},
"4a0f1452281bcec5bd90c3dce6162a5995bfe9df": {
"balance": "0xc097ce7bc90715b34b9f1000000000"
},
"4dde844b71bcdf95512fb4dc94e84fb67b512ed8": {
"balance": "0xc097ce7bc90715b34b9f1000000000"
},
"5f552da00dfb4d3749d9e62dcee3c918855a86a0": {
"balance": "0xc097ce7bc90715b34b9f1000000000"
},
"654aa64f5fbefb84c270ec74211b81ca8c44a72e": {
"balance": "0xc097ce7bc90715b34b9f1000000000"
},
"717f8aa2b982bee0e29f573d31df288663e1ce16": {
"balance": "0xc097ce7bc90715b34b9f1000000000"
},
"7435ed30a8b4aeb0877cef0c6e8cffe834eb865f": {
"balance": "0xc097ce7bc90715b34b9f1000000000"
},
"7dcd17433742f4c0ca53122ab541d0ba67fc27df": {
"storage": {},
"balance": "0x2a",
"nonce": "0x0"
},
"0x0c2c51a0990aee1d73c1228de158688341557508": {
"code": "0x",
"storage": {},
"balance": "0xc097ce7bc90715b34b9f1000000000",
"nonce": "0x0"
},
"0x14e46043e63d0e3cdcf2530519f4cfaf35058cb2": {
"code": "0x",
"storage": {},
"balance": "0xc097ce7bc90715b34b9f1000000000",
"nonce": "0x0"
},
"0x16c57edf7fa9d9525378b0b81bf8a3ced0620c1c": {
"code": "0x",
"storage": {},
"balance": "0xc097ce7bc90715b34b9f1000000000",
"nonce": "0x0"
},
"0x1f4924b14f34e24159387c0a4cdbaa32f3ddb0cf": {
"code": "0x",
"storage": {},
"balance": "0xc097ce7bc90715b34b9f1000000000",
"nonce": "0x0"
},
"0x1f5bde34b4afc686f136c7a3cb6ec376f7357759": {
"code": "0x",
"storage": {},
"balance": "0xc097ce7bc90715b34b9f1000000000",
"nonce": "0x0"
},
"0x2d389075be5be9f2246ad654ce152cf05990b209": {
"code": "0x",
"storage": {},
"balance": "0xc097ce7bc90715b34b9f1000000000",
"nonce": "0x0"
},
"0x3ae75c08b4c907eb63a8960c45b86e1e9ab6123c": {
"code": "0x",
"storage": {},
"balance": "0xc097ce7bc90715b34b9f1000000000",
"nonce": "0x0"
},
"0x4340ee1b812acb40a1eb561c019c327b243b92df": {
"code": "0x",
"storage": {},
"balance": "0xc097ce7bc90715b34b9f1000000000",
"nonce": "0x0"
},
"0x4a0f1452281bcec5bd90c3dce6162a5995bfe9df": {
"code": "0x",
"storage": {},
"balance": "0xc097ce7bc90715b34b9f1000000000",
"nonce": "0x0"
},
"0x4dde844b71bcdf95512fb4dc94e84fb67b512ed8": {
"code": "0x",
"storage": {},
"balance": "0xc097ce7bc90715b34b9f1000000000",
"nonce": "0x0"
},
"0x5f552da00dfb4d3749d9e62dcee3c918855a86a0": {
"code": "0x",
"storage": {},
"balance": "0xc097ce7bc90715b34b9f1000000000",
"nonce": "0x0"
},
"0x654aa64f5fbefb84c270ec74211b81ca8c44a72e": {
"code": "0x",
"storage": {},
"balance": "0xc097ce7bc90715b34b9f1000000000",
"nonce": "0x0"
},
"0x717f8aa2b982bee0e29f573d31df288663e1ce16": {
"code": "0x",
"storage": {},
"balance": "0xc097ce7bc90715b34b9f1000000000",
"nonce": "0x0"
},
"0x7435ed30a8b4aeb0877cef0c6e8cffe834eb865f": {
"code": "0x",
"storage": {},
"balance": "0xc097ce7bc90715b34b9f1000000000",
"nonce": "0x0"
},
"0x7dcd17433742f4c0ca53122ab541d0ba67fc27df": {
"code": "0x3680600080376000206000548082558060010160005560005263656d697460206000a2",
"balance": "0x0"
},
"83c7e323d189f18725ac510004fdc2941f8c4a78": {
"balance": "0xc097ce7bc90715b34b9f1000000000"
},
"84e75c28348fb86acea1a93a39426d7d60f4cc46": {
"balance": "0xc097ce7bc90715b34b9f1000000000"
},
"8bebc8ba651aee624937e7d897853ac30c95a067": {
"storage": {},
"balance": "0x0",
"nonce": "0x0"
},
"0x83c7e323d189f18725ac510004fdc2941f8c4a78": {
"code": "0x",
"storage": {},
"balance": "0xc097ce7bc90715b34b9f1000000000",
"nonce": "0x0"
},
"0x84e75c28348fb86acea1a93a39426d7d60f4cc46": {
"code": "0x",
"storage": {},
"balance": "0xc097ce7bc90715b34b9f1000000000",
"nonce": "0x0"
},
"0x8bebc8ba651aee624937e7d897853ac30c95a067": {
"code": "0x",
"storage": {
"0x0000000000000000000000000000000000000000000000000000000000000001": "0x0000000000000000000000000000000000000000000000000000000000000001",
"0x0000000000000000000000000000000000000000000000000000000000000002": "0x0000000000000000000000000000000000000000000000000000000000000002",
"0x0000000000000000000000000000000000000000000000000000000000000003": "0x0000000000000000000000000000000000000000000000000000000000000003"
"0x1": "0x1",
"0x2": "0x2",
"0x3": "0x3"
},
"balance": "0x1",
"nonce": "0x1"
},
"c7b99a164efd027a93f147376cc7da7c67c6bbe0": {
"balance": "0xc097ce7bc90715b34b9f1000000000"
},
"d803681e487e6ac18053afc5a6cd813c86ec3e4d": {
"balance": "0xc097ce7bc90715b34b9f1000000000"
},
"e7d13f7aa2a838d24c59b40186a0aca1e21cffcc": {
"balance": "0xc097ce7bc90715b34b9f1000000000"
},
"eda8645ba6948855e3b3cd596bbb07596d59c603": {
"balance": "0xc097ce7bc90715b34b9f1000000000"
"0xc7b99a164efd027a93f147376cc7da7c67c6bbe0": {
"code": "0x",
"storage": {},
"balance": "0xc097ce7bc90715b34b9f1000000000",
"nonce": "0x0"
},
"0xd803681e487e6ac18053afc5a6cd813c86ec3e4d": {
"code": "0x",
"storage": {},
"balance": "0xc097ce7bc90715b34b9f1000000000",
"nonce": "0x0"
},
"0xe7d13f7aa2a838d24c59b40186a0aca1e21cffcc": {
"code": "0x",
"storage": {},
"balance": "0xc097ce7bc90715b34b9f1000000000",
"nonce": "0x0"
},
"0xeda8645ba6948855e3b3cd596bbb07596d59c603": {
"code": "0x",
"storage": {},
"balance": "0xc097ce7bc90715b34b9f1000000000",
"nonce": "0x0"
}
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"baseFeePerGas": "0x3b9aca00",
"excessBlobGas": null,
"blobGasUsed": null
}
"baseFeePerGas": "0x3b9aca00"
}
Loading