Skip to content
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/commit/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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,
}

Expand All @@ -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 }
Expand Down Expand Up @@ -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,
}

Expand All @@ -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 }
Expand Down
5 changes: 3 additions & 2 deletions crates/common/src/config/pbs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
Expand Down
20 changes: 11 additions & 9 deletions crates/common/src/types.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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),
}
}

Expand Down Expand Up @@ -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
Expand Down