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: add sepolia #147

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions crates/common/src/pbs/types/beacon_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ mod tests {
},
"execution_payload_header": {
"parent_hash": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
"fee_recipient": "0xAbcF8e0d4e9587369b2301D0790347320302cc09",
"fee_recipient": "0xabcf8e0d4e9587369b2301d0790347320302cc09",
"state_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
"receipts_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
"logs_bloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
Expand All @@ -237,7 +237,7 @@ mod tests {
"message": {
"validator_index": "1",
"from_bls_pubkey": "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a",
"to_execution_address": "0xAbcF8e0d4e9587369b2301D0790347320302cc09"
"to_execution_address": "0xabcf8e0d4e9587369b2301d0790347320302cc09"
},
"signature": "0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2305b26a285fa2737f175668d0dff91cc1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505"
}
Expand Down Expand Up @@ -537,7 +537,7 @@ mod tests {
},
"execution_payload_header": {
"parent_hash": "0xa330251430b91a6fb5342f30a1f527dc76499c03a411464235951dbd51b94d9f",
"fee_recipient": "0xf97e180c050e5Ab072211Ad2C213Eb5AEE4DF134",
"fee_recipient": "0xf97e180c050e5ab072211ad2c213eb5aee4df134",
"state_root": "0x079f2cc22a29388fd4fc20f451cbaa3ff39845d68b2c368ff7be314617418e38",
"receipts_root": "0xed980a4cf6df8ba330c14ed9fe0597ec20515f44e5a9adfd2f7b72aa14890996",
"logs_bloom": "0x0000000400000008000008000040000000000000000000001000104880000200000004000000400000000204000020002000000000000000000000000022000800000004000000000002000c000000000000000000000100000000000000000000000000000000000000000000000040000000000040000001000014000000010002104000000000000000000000000000000000000000000000000000000080020000000000000000002400000000000001000000000002000200102000000040100002000000000000000000000000000000000000000800000000000000000010000000000000000000000000000000000400002000000000000000200000",
Expand Down Expand Up @@ -579,7 +579,7 @@ mod tests {
"execution_payload": {
"parent_hash":
"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
"fee_recipient": "0xAbcF8e0d4e9587369b2301D0790347320302cc09",
"fee_recipient": "0xabcf8e0d4e9587369b2301d0790347320302cc09",
"state_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
"receipts_root":
"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
Expand All @@ -603,7 +603,7 @@ mod tests {
{
"index": "1",
"validator_index": "1",
"address": "0xAbcF8e0d4e9587369b2301D0790347320302cc09",
"address": "0xabcf8e0d4e9587369b2301d0790347320302cc09",
"amount": "32000000000"
}
]
Expand Down
2 changes: 1 addition & 1 deletion crates/common/src/pbs/types/execution_payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ mod tests {
fn test_execution_payload_header() {
let data = r#"{
"parent_hash": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
"fee_recipient": "0xAbcF8e0d4e9587369b2301D0790347320302cc09",
"fee_recipient": "0xabcf8e0d4e9587369b2301d0790347320302cc09",
"state_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
"receipts_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
"logs_bloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
Expand Down
2 changes: 1 addition & 1 deletion crates/common/src/pbs/types/get_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ mod tests {
"message": {
"header": {
"parent_hash": "0x114d1897fefa402a01a653c21a7f1f1db049d1373a5e73a2d25d7a8045dc02a1",
"fee_recipient": "0x1268AD189526AC0b386faF06eFfC46779c340eE6",
"fee_recipient": "0x1268ad189526ac0b386faf06effc46779c340ee6",
"state_root": "0x53ffe6d7d4bbcc5ef71429ce82b3d7bbfffddaed89d53979bf4dca7af0dbe94c",
"receipts_root": "0x3d67a1bb141379c352c95126c4dd06a4fe086efdc00b6e919b050c84d79f4df2",
"logs_bloom": "0x05440404082f80182749948b189406732c7da48ce83013f11c02562c0d10cc714002025f21c1c64b21293e4c40c5b58e5404aed7922104002008019258ad7020097424e0b01d41eb474dc0cd26c0c9298c640692260452e27104ac808a050a0dc47187f40386108058b301007229b82f0d30bb082c72410043005e32a42c841841184260c0d744a4a9a190840048a4590011e00084ca62a8ce3a030d640350214fbedf09f041823266c491b128800802a200eb1048341000fa810323c4825804643b68ca2301c559881c0e944334c843016e0874010c81009100348a1900e0546014239b02e956940d1408c1824847516850d8de4a110495f3d9a4d8c00808a0",
Expand Down
4 changes: 4 additions & 0 deletions crates/common/src/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ mod tests {
compute_domain(Chain::Holesky, APPLICATION_BUILDER_DOMAIN),
Chain::Holesky.builder_domain()
);
assert_eq!(
compute_domain(Chain::Sepolia, APPLICATION_BUILDER_DOMAIN),
Chain::Sepolia.builder_domain()
);
assert_eq!(
compute_domain(Chain::Helder, APPLICATION_BUILDER_DOMAIN),
Chain::Helder.builder_domain()
Expand Down
68 changes: 56 additions & 12 deletions crates/common/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub struct Jwt(pub String);
pub enum Chain {
Mainnet,
Holesky,
Sepolia,
Helder,
Custom { genesis_time_secs: u64, slot_time_secs: u64, genesis_fork_version: [u8; 4] },
}
Expand All @@ -30,6 +31,7 @@ impl std::fmt::Debug for Chain {
match self {
Self::Mainnet => write!(f, "Mainnet"),
Self::Holesky => write!(f, "Holesky"),
Self::Sepolia => write!(f, "Sepolia"),
Self::Helder => write!(f, "Helder"),
Self::Custom { genesis_time_secs, slot_time_secs, genesis_fork_version } => f
.debug_struct("Custom")
Expand All @@ -46,6 +48,7 @@ impl Chain {
match self {
Chain::Mainnet => KnownChain::Mainnet.builder_domain(),
Chain::Holesky => KnownChain::Holesky.builder_domain(),
Chain::Sepolia => KnownChain::Sepolia.builder_domain(),
Chain::Helder => KnownChain::Helder.builder_domain(),
Chain::Custom { .. } => compute_domain(*self, APPLICATION_BUILDER_DOMAIN),
}
Expand All @@ -55,6 +58,7 @@ impl Chain {
match self {
Chain::Mainnet => KnownChain::Mainnet.genesis_fork_version(),
Chain::Holesky => KnownChain::Holesky.genesis_fork_version(),
Chain::Sepolia => KnownChain::Sepolia.genesis_fork_version(),
Chain::Helder => KnownChain::Helder.genesis_fork_version(),
Chain::Custom { genesis_fork_version, .. } => *genesis_fork_version,
}
Expand All @@ -64,6 +68,7 @@ impl Chain {
match self {
Chain::Mainnet => KnownChain::Mainnet.genesis_time_sec(),
Chain::Holesky => KnownChain::Holesky.genesis_time_sec(),
Chain::Sepolia => KnownChain::Sepolia.genesis_time_sec(),
Chain::Helder => KnownChain::Helder.genesis_time_sec(),
Chain::Custom { genesis_time_secs, .. } => *genesis_time_secs,
}
Expand All @@ -73,6 +78,7 @@ impl Chain {
match self {
Chain::Mainnet => KnownChain::Mainnet.slot_time_sec(),
Chain::Holesky => KnownChain::Holesky.slot_time_sec(),
Chain::Sepolia => KnownChain::Sepolia.slot_time_sec(),
Chain::Helder => KnownChain::Helder.slot_time_sec(),
Chain::Custom { slot_time_secs, .. } => *slot_time_secs,
}
Expand All @@ -85,6 +91,8 @@ pub enum KnownChain {
Mainnet,
#[serde(alias = "holesky")]
Holesky,
#[serde(alias = "sepolia")]
Sepolia,
#[serde(alias = "helder")]
Helder,
}
Expand All @@ -101,6 +109,10 @@ impl KnownChain {
0, 0, 0, 1, 91, 131, 162, 55, 89, 197, 96, 178, 208, 198, 69, 118, 225, 220, 252,
52, 234, 148, 196, 152, 143, 62, 13, 159, 119, 240, 83, 135,
],
KnownChain::Sepolia => [
0, 0, 0, 1, 211, 1, 7, 120, 205, 8, 238, 81, 75, 8, 254, 103, 182, 197, 3, 181, 16,
152, 122, 76, 228, 63, 66, 48, 109, 151, 198, 124,
],
KnownChain::Helder => [
0, 0, 0, 1, 148, 196, 26, 244, 132, 255, 247, 150, 73, 105, 224, 189, 217, 34, 248,
45, 255, 15, 75, 232, 122, 96, 208, 102, 76, 201, 209, 255,
Expand All @@ -110,23 +122,28 @@ impl KnownChain {

pub fn genesis_fork_version(&self) -> [u8; 4] {
match self {
KnownChain::Mainnet => [0u8; 4],
KnownChain::Holesky => [1, 1, 112, 0],
KnownChain::Helder => [16, 0, 0, 0],
KnownChain::Mainnet => hex!("00000000"),
KnownChain::Holesky => hex!("01017000"),
KnownChain::Sepolia => hex!("90000069"),
KnownChain::Helder => hex!("10000000"),
}
}

fn genesis_time_sec(&self) -> u64 {
match self {
KnownChain::Mainnet => 1606824023,
KnownChain::Holesky => 1695902400,
KnownChain::Sepolia => 1655733600,
KnownChain::Helder => 1718967660,
}
}

pub fn slot_time_sec(&self) -> u64 {
match self {
KnownChain::Mainnet | KnownChain::Holesky | KnownChain::Helder => 12,
KnownChain::Mainnet |
KnownChain::Holesky |
KnownChain::Sepolia |
KnownChain::Helder => 12,
}
}
}
Expand All @@ -136,6 +153,7 @@ impl From<KnownChain> for Chain {
match value {
KnownChain::Mainnet => Chain::Mainnet,
KnownChain::Holesky => Chain::Holesky,
KnownChain::Sepolia => Chain::Sepolia,
KnownChain::Helder => Chain::Helder,
}
}
Expand All @@ -157,6 +175,7 @@ impl Serialize for Chain {
let loader = match self {
Chain::Mainnet => ChainLoader::Known(KnownChain::Mainnet),
Chain::Holesky => ChainLoader::Known(KnownChain::Holesky),
Chain::Sepolia => ChainLoader::Known(KnownChain::Sepolia),
Chain::Helder => ChainLoader::Known(KnownChain::Helder),
Chain::Custom { genesis_time_secs, slot_time_secs, genesis_fork_version } => {
ChainLoader::Custom {
Expand Down Expand Up @@ -214,6 +233,10 @@ pub fn load_chain_from_file(path: PathBuf) -> eyre::Result<Chain> {
let genesis_fork_version: [u8; 4] = self.genesis_fork_version.as_ref().try_into()?;

Ok(Chain::Custom {
// note that this can be wrong, (e.g. it's wrong in mainnet). The correct
// value should come from /eth/v1/beacon/genesis
// more info here: https://kb.beaconcha.in/ethereum-staking/the-genesis-event
// FIXME
genesis_time_secs: self.min_genesis_time + self.genesis_delay,
slot_time_secs: self.seconds_per_slot,
genesis_fork_version,
Expand Down Expand Up @@ -289,13 +312,34 @@ mod tests {
}

#[test]
fn test_load_file_data_json() {
fn test_spec_mainnet_data_json() {
let a = env!("CARGO_MANIFEST_DIR");
let mut path = PathBuf::from(a);

path.pop();
path.pop();
path.push("tests/data/holesky_spec_data.json");
path.push("tests/data/mainnet_spec_data.json");

let s = format!("chain = {path:?}");

let decoded: MockConfig = toml::from_str(&s).unwrap();

// see fixme in load_chain_from_file
assert_eq!(decoded.chain.slot_time_sec(), KnownChain::Mainnet.slot_time_sec());
assert_eq!(
decoded.chain.genesis_fork_version(),
KnownChain::Mainnet.genesis_fork_version()
);
}

#[test]
fn test_spec_holesky_json() {
let a = env!("CARGO_MANIFEST_DIR");
let mut path = PathBuf::from(a);

path.pop();
path.pop();
path.push("tests/data/holesky_spec.json");

let s = format!("chain = {path:?}");

Expand All @@ -308,26 +352,26 @@ mod tests {
}

#[test]
fn test_load_file_json() {
fn test_spec_sepolia_data_json() {
let a = env!("CARGO_MANIFEST_DIR");
let mut path = PathBuf::from(a);

path.pop();
path.pop();
path.push("tests/data/holesky_spec.json");
path.push("tests/data/sepolia_spec_data.json");

let s = format!("chain = {path:?}");

let decoded: MockConfig = toml::from_str(&s).unwrap();
assert_eq!(decoded.chain, Chain::Custom {
genesis_time_secs: KnownChain::Holesky.genesis_time_sec(),
slot_time_secs: KnownChain::Holesky.slot_time_sec(),
genesis_fork_version: KnownChain::Holesky.genesis_fork_version()
genesis_time_secs: KnownChain::Sepolia.genesis_time_sec(),
slot_time_secs: KnownChain::Sepolia.slot_time_sec(),
genesis_fork_version: KnownChain::Sepolia.genesis_fork_version()
})
}

#[test]
fn test_load_file_yml() {
fn test_spec_helder_yml() {
let a = env!("CARGO_MANIFEST_DIR");
let mut path = PathBuf::from(a);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"data": {
"SLOTS_PER_EPOCH": "32",
"PRESET_BASE": "mainnet",
"TERMINAL_TOTAL_DIFFICULTY": "0",
"TERMINAL_TOTAL_DIFFICULTY": "58750000000000000000000",
"INACTIVITY_SCORE_BIAS": "4",
"PENDING_BALANCE_DEPOSITS_LIMIT": "134217728",
"MAX_ATTESTER_SLASHINGS": "2",
Expand All @@ -19,10 +19,11 @@
"RESP_TIMEOUT": "10",
"DOMAIN_VOLUNTARY_EXIT": "0x04000000",
"MAX_VALIDATORS_PER_COMMITTEE": "2048",
"MIN_GENESIS_TIME": "1695902100",
"ALTAIR_FORK_EPOCH": "0",
"MIN_GENESIS_TIME": "1606824000",
"ALTAIR_FORK_EPOCH": "74240",
"MAX_PER_EPOCH_ACTIVATION_EXIT_CHURN_LIMIT": "256000000000",
"HYSTERESIS_QUOTIENT": "4",
"ALTAIR_FORK_VERSION": "0x02017000",
"ALTAIR_FORK_VERSION": "0x01000000",
"MAX_BYTES_PER_TRANSACTION": "1073741824",
"MAX_CHUNK_SIZE": "10485760",
"TTFB_TIMEOUT": "5",
Expand All @@ -34,7 +35,7 @@
"MAX_ATTESTER_SLASHINGS_ELECTRA": "1",
"TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE": "16",
"MAX_DEPOSITS": "16",
"BELLATRIX_FORK_EPOCH": "0",
"BELLATRIX_FORK_EPOCH": "144896",
"MAX_REQUEST_BLOB_SIDECARS": "768",
"REORG_HEAD_WEIGHT_THRESHOLD": "20",
"TARGET_AGGREGATORS_PER_COMMITTEE": "16",
Expand All @@ -48,31 +49,33 @@
"EPOCHS_PER_SUBNET_SUBSCRIPTION": "256",
"MAX_ATTESTATIONS_ELECTRA": "8",
"ATTESTATION_SUBNET_COUNT": "64",
"GENESIS_DELAY": "300",
"GENESIS_DELAY": "604800",
"MAX_SEED_LOOKAHEAD": "4",
"ETH1_FOLLOW_DISTANCE": "2048",
"SECONDS_PER_SLOT": "12",
"REORG_PARENT_WEIGHT_THRESHOLD": "160",
"MIN_SYNC_COMMITTEE_PARTICIPANTS": "1",
"BELLATRIX_FORK_VERSION": "0x03017000",
"BELLATRIX_FORK_VERSION": "0x02000000",
"PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX": "3",
"EFFECTIVE_BALANCE_INCREMENT": "1000000000",
"MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA": "128000000000",
"FIELD_ELEMENTS_PER_BLOB": "4096",
"MIN_EPOCHS_TO_INACTIVITY_PENALTY": "4",
"BASE_REWARD_FACTOR": "64",
"MAX_EXTRA_DATA_BYTES": "32",
"CONFIG_NAME": "holesky",
"CONFIG_NAME": "mainnet",
"MAX_PROPOSER_SLASHINGS": "16",
"MAX_CONSOLIDATIONS": "1",
"INACTIVITY_SCORE_RECOVERY_RATE": "16",
"MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS": "4096",
"MAX_TRANSACTIONS_PER_PAYLOAD": "1048576",
"DEPOSIT_CONTRACT_ADDRESS": "0x4242424242424242424242424242424242424242",
"DEPOSIT_CONTRACT_ADDRESS": "0x00000000219ab540356cBB839Cbe05303d7705Fa",
"MIN_ATTESTATION_INCLUSION_DELAY": "1",
"SHUFFLE_ROUND_COUNT": "90",
"TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH": "18446744073709551615",
"MAX_EFFECTIVE_BALANCE": "32000000000",
"DOMAIN_BEACON_PROPOSER": "0x00000000",
"DENEB_FORK_EPOCH": "29696",
"DENEB_FORK_EPOCH": "269568",
"DOMAIN_SYNC_COMMITTEE": "0x07000000",
"PROPOSER_SCORE_BOOST": "40",
"DOMAIN_SELECTION_PROOF": "0x05000000",
Expand All @@ -93,13 +96,14 @@
"UPDATE_TIMEOUT": "8192",
"ELECTRA_FORK_EPOCH": "18446744073709551615",
"SYNC_COMMITTEE_BRANCH_LENGTH": "5",
"DEPOSIT_CHAIN_ID": "17000",
"DEPOSIT_CHAIN_ID": "1",
"MAX_BLOB_COMMITMENTS_PER_BLOCK": "4096",
"DOMAIN_RANDAO": "0x02000000",
"CAPELLA_FORK_VERSION": "0x04017000",
"CAPELLA_FORK_VERSION": "0x03000000",
"MAX_EFFECTIVE_BALANCE_ELECTRA": "2048000000000",
"MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR": "64",
"EPOCHS_PER_ETH1_VOTING_PERIOD": "64",
"MAX_DEPOSIT_RECEIPTS_PER_PAYLOAD": "8192",
"WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA": "4096",
"HISTORICAL_ROOTS_LIMIT": "16777216",
"ATTESTATION_PROPAGATION_SLOT_RANGE": "32",
Expand All @@ -115,22 +119,20 @@
"MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP": "8",
"EPOCHS_PER_SYNC_COMMITTEE_PERIOD": "256",
"BYTES_PER_LOGS_BLOOM": "256",
"MAX_DEPOSIT_REQUESTS_PER_PAYLOAD": "8192",
"MIN_GENESIS_ACTIVE_VALIDATOR_COUNT": "16384",
"MAX_ATTESTATIONS": "128",
"MIN_EPOCHS_FOR_BLOCK_REQUESTS": "33024",
"DENEB_FORK_VERSION": "0x05017000",
"ELECTRA_FORK_VERSION": "0x06017000",
"DENEB_FORK_VERSION": "0x04000000",
"ELECTRA_FORK_VERSION": "0x05000000",
"MAX_REQUEST_BLOCKS": "1024",
"GENESIS_FORK_VERSION": "0x01017000",
"GENESIS_FORK_VERSION": "0x00000000",
"KZG_COMMITMENT_INCLUSION_PROOF_DEPTH": "17",
"DEPOSIT_NETWORK_ID": "17000",
"MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD": "1",
"DEPOSIT_NETWORK_ID": "1",
"MAX_REQUEST_BLOCKS_DENEB": "128",
"BLOB_SIDECAR_SUBNET_COUNT": "6",
"SYNC_COMMITTEE_SUBNET_COUNT": "4",
"CAPELLA_FORK_EPOCH": "256",
"EJECTION_BALANCE": "28000000000",
"CAPELLA_FORK_EPOCH": "194048",
"EJECTION_BALANCE": "16000000000",
"ATTESTATION_SUBNET_EXTRA_BITS": "0",
"MAX_COMMITTEES_PER_SLOT": "64",
"SHARD_COMMITTEE_PERIOD": "256",
Expand Down
Loading