diff --git a/crates/common/src/commit/response.rs b/crates/common/src/commit/response.rs index e1096828..5424a4bd 100644 --- a/crates/common/src/commit/response.rs +++ b/crates/common/src/commit/response.rs @@ -2,7 +2,7 @@ use std::{fmt, fmt::Display}; use alloy::{ hex, - primitives::{Address, B256}, + primitives::{Address, B256, U256}, rpc::types::beacon::BlsSignature, }; use serde::{Deserialize, Serialize}; @@ -15,7 +15,7 @@ pub struct BlsSignResponse { pub object_root: B256, pub module_signing_id: B256, pub nonce: u64, - pub chain_id: u64, + pub chain_id: U256, pub signature: BlsSignature, } @@ -25,7 +25,7 @@ impl BlsSignResponse { object_root: B256, module_signing_id: B256, nonce: u64, - chain_id: u64, + chain_id: U256, signature: BlsSignature, ) -> Self { Self { pubkey, object_root, module_signing_id, nonce, chain_id, signature } @@ -53,7 +53,7 @@ pub struct EcdsaSignResponse { pub object_root: B256, pub module_signing_id: B256, pub nonce: u64, - pub chain_id: u64, + pub chain_id: U256, pub signature: EcdsaSignature, } @@ -63,7 +63,7 @@ impl EcdsaSignResponse { object_root: B256, module_signing_id: B256, nonce: u64, - chain_id: u64, + chain_id: U256, signature: EcdsaSignature, ) -> Self { Self { address, object_root, module_signing_id, nonce, chain_id, signature } diff --git a/crates/common/src/config/pbs.rs b/crates/common/src/config/pbs.rs index d04b3394..e12493d4 100644 --- a/crates/common/src/config/pbs.rs +++ b/crates/common/src/config/pbs.rs @@ -169,12 +169,13 @@ impl PbsConfig { if !matches!(chain, Chain::Custom { .. }) { let provider = ProviderBuilder::new().on_http(rpc_url.clone()); let chain_id = provider.get_chain_id().await?; + let chain_id_big = U256::from(chain_id); ensure!( - chain_id == chain.id(), + chain_id_big == chain.id(), "Rpc url is for the wrong chain, expected: {} ({:?}) got {}", chain.id(), chain, - chain_id + chain_id_big ); } } diff --git a/crates/common/src/types.rs b/crates/common/src/types.rs index 6a19be48..d650f6be 100644 --- a/crates/common/src/types.rs +++ b/crates/common/src/types.rs @@ -1,6 +1,6 @@ use std::path::PathBuf; -use alloy::primitives::{aliases::B32, hex, Bytes, B256}; +use alloy::primitives::{aliases::B32, hex, Bytes, B256, U256}; use derive_more::{Deref, Display, From, Into}; use eyre::{bail, Context}; use serde::{Deserialize, Serialize}; @@ -72,7 +72,9 @@ impl std::fmt::Debug for Chain { } impl Chain { - pub fn id(&self) -> u64 { + // Chain IDs are 256-bit unsigned integers because they need to support + // Keccak256 hashes + pub fn id(&self) -> U256 { match self { Chain::Mainnet => KnownChain::Mainnet.id(), Chain::Holesky => KnownChain::Holesky.id(), @@ -146,13 +148,13 @@ pub enum KnownChain { // Constants impl KnownChain { - pub fn id(&self) -> u64 { + pub fn id(&self) -> U256 { match self { - KnownChain::Mainnet => 1, - KnownChain::Holesky => 17000, - KnownChain::Sepolia => 11155111, - KnownChain::Helder => 167000, - KnownChain::Hoodi => 560048, + KnownChain::Mainnet => U256::from(1), + KnownChain::Holesky => U256::from(17000), + KnownChain::Sepolia => U256::from(11155111), + KnownChain::Helder => U256::from(167000), + KnownChain::Hoodi => U256::from(560048), } } @@ -305,7 +307,7 @@ pub struct PropCommitSigningInfo { pub data: B256, pub module_signing_id: B256, pub nonce: u64, // As per https://eips.ethereum.org/EIPS/eip-2681 - pub chain_id: u64, + pub chain_id: U256, } /// Information about a signature request, including the module signing ID and