Skip to content

Commit

Permalink
feat: add genesis and system contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
forcodedancing committed Apr 26, 2024
1 parent 54f75cd commit ad47ddb
Show file tree
Hide file tree
Showing 107 changed files with 1,562 additions and 165 deletions.
1,035 changes: 909 additions & 126 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -355,3 +355,10 @@ proptest-derive = "0.4"
serial_test = "3"
similar-asserts = "1.5.0"
test-fuzz = "5"


[patch.crates-io]
revm = { git = "https://github.com/bnb-chain/revm.git", rev = "76d842a", features = ["std", "secp256k1"], default-features = false }
revm-primitives = { git = "https://github.com/bnb-chain/revm.git", rev = "76d842a", features = ["std"], default-features = false }
alloy-chains = { git = "https://github.com/bnb-chain/alloy-chains-rs.git", branch = "feat/v0.1.15-opbnb", feature = ["serde", "rlp", "arbitrary"] }
alloy-genesis = { git = "https://github.com/forcodedancing/alloy", branch = "feat/parlia-config" }
1 change: 1 addition & 0 deletions crates/ethereum-forks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ default = ["serde"]
serde = ["dep:serde"]
arbitrary = ["dep:arbitrary", "dep:proptest", "dep:proptest-derive"]
optimism = []
bsc = []
70 changes: 59 additions & 11 deletions crates/ethereum-forks/src/hardfork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,54 @@ pub enum Hardfork {
#[cfg(feature = "optimism")]
Ecotone,
// ArbOS20Atlas,

/// BSC Ramanujan hardfork
Ramanujan,

/// BSC Niels hardfork
Niels,

/// BSC MirrorSync hardfork
MirrorSync,

/// BSC Bruno hardfork
Bruno,

/// BSC Euler hardfork
Euler,

/// BSC Nano hardfork
Nano,

/// BSC Moran hardfork
Moran,

/// BSC Gibbs hardfork
Gibbs,

/// BSC Planck hardfork
Planck,

/// BSC Luban hardfork
Luban,

/// BSC Plato hardfork
Plato,

/// BSC Hertz hardfork
Hertz,

/// BSC Hertzfix hardfork
Hertzfix,

/// BSC Kepler hardfork
Kepler,

/// BSC Feynman hardfork
Feynman,

/// BSC FeynmanFix hardfork
FeynmanFix,
}

impl Hardfork {
Expand All @@ -94,22 +142,22 @@ impl Hardfork {
/// Retrieves the activation block for the specified hardfork on the given chain.
pub fn activation_block(&self, chain: Chain) -> Option<u64> {
if chain == Chain::mainnet() {
return self.mainnet_activation_block()
return self.mainnet_activation_block();
}
if chain == Chain::sepolia() {
return self.sepolia_activation_block()
return self.sepolia_activation_block();
}
if chain == Chain::holesky() {
return self.holesky_activation_block()
return self.holesky_activation_block();
}

#[cfg(feature = "optimism")]
{
if chain == Chain::base_sepolia() {
return self.base_sepolia_activation_block()
return self.base_sepolia_activation_block();
}
if chain == Chain::base_mainnet() {
return self.base_mainnet_activation_block()
return self.base_mainnet_activation_block();
}
}

Expand Down Expand Up @@ -307,21 +355,21 @@ impl Hardfork {
/// Retrieves the activation timestamp for the specified hardfork on the given chain.
pub fn activation_timestamp(&self, chain: Chain) -> Option<u64> {
if chain == Chain::mainnet() {
return self.mainnet_activation_timestamp()
return self.mainnet_activation_timestamp();
}
if chain == Chain::sepolia() {
return self.sepolia_activation_timestamp()
return self.sepolia_activation_timestamp();
}
if chain == Chain::holesky() {
return self.holesky_activation_timestamp()
return self.holesky_activation_timestamp();
}
#[cfg(feature = "optimism")]
{
if chain == Chain::base_sepolia() {
return self.base_sepolia_activation_timestamp()
return self.base_sepolia_activation_timestamp();
}
if chain == Chain::base_mainnet() {
return self.base_mainnet_activation_timestamp()
return self.base_mainnet_activation_timestamp();
}
}

Expand Down Expand Up @@ -655,7 +703,7 @@ mod tests {
let pos_hardforks = [Hardfork::Paris, Hardfork::Shanghai, Hardfork::Cancun];

#[cfg(feature = "optimism")]
let op_hardforks =
let op_hardforks =
[Hardfork::Bedrock, Hardfork::Regolith, Hardfork::Canyon, Hardfork::Ecotone];

for hardfork in pow_hardforks.iter() {
Expand Down
7 changes: 6 additions & 1 deletion crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ proptest = { workspace = true, optional = true }
proptest-derive = { workspace = true, optional = true }
strum = { workspace = true, features = ["derive"] }

include_dir = "0.7.3"
log = "0.4.21"
lazy_static = "1.4.0"

[dev-dependencies]
arbitrary = { workspace = true, features = ["derive"] }
assert_matches.workspace = true
Expand Down Expand Up @@ -90,7 +94,7 @@ pprof = { workspace = true, features = ["flamegraph", "frame-pointer", "criterio
secp256k1.workspace = true

[features]
default = ["c-kzg", "zstd-codec"]
default = ["c-kzg", "zstd-codec", "secp256k1/rand"]
asm-keccak = ["alloy-primitives/asm-keccak"]
arbitrary = [
"revm-primitives/arbitrary",
Expand All @@ -116,6 +120,7 @@ optimism = [
"revm/optimism",
]
test-utils = ["dep:plain_hasher", "dep:hash-db"]
bsc = ["revm-primitives/bsc", "revm/bsc"]

[[bench]]
name = "recover_ecdsa_crit"
Expand Down
82 changes: 82 additions & 0 deletions crates/primitives/res/genesis/bsc_mainnet.json

Large diffs are not rendered by default.

80 changes: 80 additions & 0 deletions crates/primitives/res/genesis/bsc_testnet.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions crates/primitives/src/chain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ pub use spec::{
#[cfg(feature = "optimism")]
pub use spec::{BASE_MAINNET, BASE_SEPOLIA, OP_SEPOLIA};

#[cfg(feature = "bsc")]
pub use spec::{BSC_MAINNET, BSC_TESTNET};

// The chain spec module.
mod spec;
// The chain info module.
Expand Down
Loading

0 comments on commit ad47ddb

Please sign in to comment.