mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-29 17:18:08 -05:00
feat: use DepositContract on ChainSpec (#4041)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@@ -25,7 +25,10 @@ impl PruningArgs {
|
||||
parts: PruneModes {
|
||||
sender_recovery: Some(PruneMode::Distance(128)),
|
||||
transaction_lookup: None,
|
||||
receipts: chain_spec.deposit_contract_deployment_block.map(PruneMode::Before),
|
||||
receipts: chain_spec
|
||||
.deposit_contract
|
||||
.as_ref()
|
||||
.map(|contract| PruneMode::Before(contract.block)),
|
||||
account_history: Some(PruneMode::Distance(128)),
|
||||
storage_history: Some(PruneMode::Distance(128)),
|
||||
},
|
||||
|
||||
@@ -272,7 +272,7 @@ mod tests {
|
||||
fork_timestamps: ForkTimestamps::default(),
|
||||
genesis_hash: None,
|
||||
paris_block_and_final_difficulty: None,
|
||||
deposit_contract_deployment_block: None,
|
||||
deposit_contract: None,
|
||||
});
|
||||
|
||||
let db = create_test_rw_db();
|
||||
|
||||
@@ -3,8 +3,8 @@ use crate::{
|
||||
forkid::ForkFilterKey,
|
||||
header::Head,
|
||||
proofs::genesis_state_root,
|
||||
BlockNumber, Chain, ForkFilter, ForkHash, ForkId, Genesis, Hardfork, Header, SealedHeader,
|
||||
H256, U256,
|
||||
Address, BlockNumber, Chain, ForkFilter, ForkHash, ForkId, Genesis, Hardfork, Header,
|
||||
SealedHeader, H160, H256, U256,
|
||||
};
|
||||
use hex_literal::hex;
|
||||
use once_cell::sync::Lazy;
|
||||
@@ -55,7 +55,11 @@ pub static MAINNET: Lazy<Arc<ChainSpec>> = Lazy::new(|| {
|
||||
(Hardfork::Shanghai, ForkCondition::Timestamp(1681338455)),
|
||||
]),
|
||||
// https://etherscan.io/tx/0xe75fb554e433e03763a1560646ee22dcb74e5274b34c5ad644e7c0f619a7e1d0
|
||||
deposit_contract_deployment_block: Some(11052984),
|
||||
deposit_contract: Some(DepositContract::new(
|
||||
H160(hex!("00000000219ab540356cbb839cbe05303d7705fa")),
|
||||
11052984,
|
||||
H256(hex!("649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5")),
|
||||
)),
|
||||
}
|
||||
.into()
|
||||
});
|
||||
@@ -91,7 +95,11 @@ pub static GOERLI: Lazy<Arc<ChainSpec>> = Lazy::new(|| {
|
||||
(Hardfork::Shanghai, ForkCondition::Timestamp(1678832736)),
|
||||
]),
|
||||
// https://goerli.etherscan.io/tx/0xa3c07dc59bfdb1bfc2d50920fed2ef2c1c4e0a09fe2325dbc14e07702f965a78
|
||||
deposit_contract_deployment_block: Some(4367322),
|
||||
deposit_contract: Some(DepositContract::new(
|
||||
H160(hex!("ff50ed3d0ec03ac01d4c79aad74928bff48a7b2b")),
|
||||
4367322,
|
||||
H256(hex!("649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5")),
|
||||
)),
|
||||
}
|
||||
.into()
|
||||
});
|
||||
@@ -131,7 +139,11 @@ pub static SEPOLIA: Lazy<Arc<ChainSpec>> = Lazy::new(|| {
|
||||
(Hardfork::Shanghai, ForkCondition::Timestamp(1677557088)),
|
||||
]),
|
||||
// https://sepolia.etherscan.io/tx/0x025ecbf81a2f1220da6285d1701dc89fb5a956b62562ee922e1a9efd73eb4b14
|
||||
deposit_contract_deployment_block: Some(1273020),
|
||||
deposit_contract: Some(DepositContract::new(
|
||||
H160(hex!("7f02c3e3c98b133055b8b348b2ac625669ed295d")),
|
||||
1273020,
|
||||
H256(hex!("649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5")),
|
||||
)),
|
||||
}
|
||||
.into()
|
||||
});
|
||||
@@ -169,7 +181,7 @@ pub static DEV: Lazy<Arc<ChainSpec>> = Lazy::new(|| {
|
||||
),
|
||||
(Hardfork::Shanghai, ForkCondition::Timestamp(0)),
|
||||
]),
|
||||
deposit_contract_deployment_block: Some(0),
|
||||
deposit_contract: None, // TODO: do we even have?
|
||||
}
|
||||
.into()
|
||||
});
|
||||
@@ -209,9 +221,9 @@ pub struct ChainSpec {
|
||||
/// The active hard forks and their activation conditions
|
||||
pub hardforks: BTreeMap<Hardfork, ForkCondition>,
|
||||
|
||||
/// The block at which the deposit contract for PoS was deployed.
|
||||
/// The deposit contract deployed for PoS.
|
||||
#[serde(skip, default)]
|
||||
pub deposit_contract_deployment_block: Option<BlockNumber>,
|
||||
pub deposit_contract: Option<DepositContract>,
|
||||
}
|
||||
|
||||
impl ChainSpec {
|
||||
@@ -444,7 +456,7 @@ impl From<Genesis> for ChainSpec {
|
||||
fork_timestamps: ForkTimestamps::from_hardforks(&hardforks),
|
||||
hardforks,
|
||||
paris_block_and_final_difficulty: None,
|
||||
deposit_contract_deployment_block: None,
|
||||
deposit_contract: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -667,7 +679,7 @@ impl ChainSpecBuilder {
|
||||
fork_timestamps: ForkTimestamps::from_hardforks(&self.hardforks),
|
||||
hardforks: self.hardforks,
|
||||
paris_block_and_final_difficulty: None,
|
||||
deposit_contract_deployment_block: None,
|
||||
deposit_contract: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -960,6 +972,23 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// PoS deposit contract details.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct DepositContract {
|
||||
/// Deposit Contract Address
|
||||
pub address: Address,
|
||||
/// Deployment Block
|
||||
pub block: BlockNumber,
|
||||
/// `DepositEvent` event signature
|
||||
pub topic: H256,
|
||||
}
|
||||
|
||||
impl DepositContract {
|
||||
fn new(address: Address, block: BlockNumber, topic: H256) -> Self {
|
||||
DepositContract { address, block, topic }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{
|
||||
|
||||
@@ -164,7 +164,7 @@ mod tests {
|
||||
hardforks: BTreeMap::from([(Hardfork::Frontier, ForkCondition::Never)]),
|
||||
fork_timestamps: Default::default(),
|
||||
paris_block_and_final_difficulty: None,
|
||||
deposit_contract_deployment_block: None,
|
||||
deposit_contract: None,
|
||||
};
|
||||
|
||||
assert_eq!(Hardfork::Frontier.fork_id(&spec), None);
|
||||
@@ -179,7 +179,7 @@ mod tests {
|
||||
hardforks: BTreeMap::from([(Hardfork::Shanghai, ForkCondition::Never)]),
|
||||
fork_timestamps: Default::default(),
|
||||
paris_block_and_final_difficulty: None,
|
||||
deposit_contract_deployment_block: None,
|
||||
deposit_contract: None,
|
||||
};
|
||||
|
||||
assert_eq!(Hardfork::Shanghai.fork_filter(&spec), None);
|
||||
|
||||
@@ -592,7 +592,7 @@ mod tests {
|
||||
},
|
||||
};
|
||||
use reth_primitives::{
|
||||
Address, BlockNumber, PruneCheckpoint, PruneMode, PruneModes, PrunePart, H256, MAINNET,
|
||||
BlockNumber, PruneCheckpoint, PruneMode, PruneModes, PrunePart, H256, MAINNET,
|
||||
};
|
||||
use reth_provider::PruneCheckpointReader;
|
||||
use reth_stages::test_utils::TestTransaction;
|
||||
|
||||
Reference in New Issue
Block a user