@@ -33,7 +33,7 @@ pub static MAINNET: Lazy<Arc<ChainSpec>> = Lazy::new(|| {
3333 15537394 ,
3434 U256 :: from ( 58_750_003_716_598_352_816_469u128 ) ,
3535 ) ) ,
36- fork_timestamps : ForkTimestamps :: default ( ) . shanghai ( 1681338455 ) ,
36+ fork_timestamps : ForkTimestamps :: default ( ) . shanghai ( 1681338455 ) . cancun ( 1710338135 ) ,
3737 hardforks : BTreeMap :: from ( [
3838 ( Hardfork :: Frontier , ForkCondition :: Block ( 0 ) ) ,
3939 ( Hardfork :: Homestead , ForkCondition :: Block ( 1150000 ) ) ,
@@ -57,6 +57,7 @@ pub static MAINNET: Lazy<Arc<ChainSpec>> = Lazy::new(|| {
5757 } ,
5858 ) ,
5959 ( Hardfork :: Shanghai , ForkCondition :: Timestamp ( 1681338455 ) ) ,
60+ ( Hardfork :: Cancun , ForkCondition :: Timestamp ( 1710338135 ) ) ,
6061 ] ) ,
6162 // https://etherscan.io/tx/0xe75fb554e433e03763a1560646ee22dcb74e5274b34c5ad644e7c0f619a7e1d0
6263 deposit_contract : Some ( DepositContract :: new (
@@ -82,7 +83,7 @@ pub static GOERLI: Lazy<Arc<ChainSpec>> = Lazy::new(|| {
8283 ) ) ,
8384 // <https://goerli.etherscan.io/block/7382818>
8485 paris_block_and_final_difficulty : Some ( ( 7382818 , U256 :: from ( 10_790_000 ) ) ) ,
85- fork_timestamps : ForkTimestamps :: default ( ) . shanghai ( 1678832736 ) ,
86+ fork_timestamps : ForkTimestamps :: default ( ) . shanghai ( 1678832736 ) . cancun ( 1705473120 ) ,
8687 hardforks : BTreeMap :: from ( [
8788 ( Hardfork :: Frontier , ForkCondition :: Block ( 0 ) ) ,
8889 ( Hardfork :: Homestead , ForkCondition :: Block ( 0 ) ) ,
@@ -126,7 +127,7 @@ pub static SEPOLIA: Lazy<Arc<ChainSpec>> = Lazy::new(|| {
126127 ) ) ,
127128 // <https://sepolia.etherscan.io/block/1450409>
128129 paris_block_and_final_difficulty : Some ( ( 1450409 , U256 :: from ( 17_000_018_015_853_232u128 ) ) ) ,
129- fork_timestamps : ForkTimestamps :: default ( ) . shanghai ( 1677557088 ) ,
130+ fork_timestamps : ForkTimestamps :: default ( ) . shanghai ( 1677557088 ) . cancun ( 1706655072 ) ,
130131 hardforks : BTreeMap :: from ( [
131132 ( Hardfork :: Frontier , ForkCondition :: Block ( 0 ) ) ,
132133 ( Hardfork :: Homestead , ForkCondition :: Block ( 0 ) ) ,
@@ -173,7 +174,7 @@ pub static HOLESKY: Lazy<Arc<ChainSpec>> = Lazy::new(|| {
173174 "b5f7f912443c940f21fd611f12828d75b534364ed9e95ca4e307729a4661bde4"
174175 ) ) ,
175176 paris_block_and_final_difficulty : Some ( ( 0 , U256 :: from ( 1 ) ) ) ,
176- fork_timestamps : ForkTimestamps :: default ( ) . shanghai ( 1696000704 ) ,
177+ fork_timestamps : ForkTimestamps :: default ( ) . shanghai ( 1696000704 ) . cancun ( 1707305664 ) ,
177178 hardforks : BTreeMap :: from ( [
178179 ( Hardfork :: Frontier , ForkCondition :: Block ( 0 ) ) ,
179180 ( Hardfork :: Homestead , ForkCondition :: Block ( 0 ) ) ,
@@ -1208,6 +1209,12 @@ impl ChainSpecBuilder {
12081209 self
12091210 }
12101211
1212+ /// Remove the given fork from the spec.
1213+ pub fn without_fork ( mut self , fork : Hardfork ) -> Self {
1214+ self . hardforks . remove ( & fork) ;
1215+ self
1216+ }
1217+
12111218 /// Enable the Paris hardfork at the given TTD.
12121219 ///
12131220 /// Does not set the merge netsplit block.
@@ -1722,6 +1729,7 @@ Merge hard forks:
17221729
17231730Post-merge hard forks (timestamp based):
17241731- Shanghai @1681338455
1732+ - Cancun @1710338135
17251733"
17261734 ) ;
17271735 }
@@ -1775,8 +1783,8 @@ Post-merge hard forks (timestamp based):
17751783 assert ! ( spec. fork_timestamps. shanghai. is_some( ) ) ;
17761784 }
17771785
1778- // currently there is only 1 timestamp fork known for mainnet: shanghai
1779- ensure_timestamp_fork_conditions ( & MAINNET , 1 ) ;
1786+ // currently there are 2 timestamp forks known for mainnet: shanghai, cancun
1787+ ensure_timestamp_fork_conditions ( & MAINNET , 2 ) ;
17801788
17811789 // currently there are 2 timestamp forks known for sepolia: shanghai, cancun
17821790 ensure_timestamp_fork_conditions ( & SEPOLIA , 2 ) ;
@@ -1998,7 +2006,11 @@ Post-merge hard forks (timestamp based):
19982006 Hardfork :: GrayGlacier ,
19992007 ForkId { hash : ForkHash ( [ 0xf0 , 0xaf , 0xd0 , 0xe3 ] ) , next : 1681338455 } ,
20002008 ) ,
2001- ( Hardfork :: Shanghai , ForkId { hash : ForkHash ( [ 0xdc , 0xe9 , 0x6c , 0x2d ] ) , next : 0 } ) ,
2009+ (
2010+ Hardfork :: Shanghai ,
2011+ ForkId { hash : ForkHash ( [ 0xdc , 0xe9 , 0x6c , 0x2d ] ) , next : 1710338135 } ,
2012+ ) ,
2013+ ( Hardfork :: Cancun , ForkId { hash : ForkHash ( [ 0x9f , 0x3d , 0x22 , 0x54 ] ) , next : 0 } ) ,
20022014 ] ,
20032015 ) ;
20042016 }
@@ -2175,12 +2187,17 @@ Post-merge hard forks (timestamp based):
21752187 // First Shanghai block
21762188 (
21772189 Head { number : 20000000 , timestamp : 1681338455 , ..Default :: default ( ) } ,
2178- ForkId { hash : ForkHash ( [ 0xdc , 0xe9 , 0x6c , 0x2d ] ) , next : 0 } ,
2190+ ForkId { hash : ForkHash ( [ 0xdc , 0xe9 , 0x6c , 0x2d ] ) , next : 1710338135 } ,
21792191 ) ,
2180- // Future Shanghai block
2192+ // First Cancun block
2193+ (
2194+ Head { number : 20000001 , timestamp : 1710338135 , ..Default :: default ( ) } ,
2195+ ForkId { hash : ForkHash ( [ 0x9f , 0x3d , 0x22 , 0x54 ] ) , next : 0 } ,
2196+ ) ,
2197+ // Future Cancun block
21812198 (
2182- Head { number : 20000000 , timestamp : 2000000000 , ..Default :: default ( ) } ,
2183- ForkId { hash : ForkHash ( [ 0xdc , 0xe9 , 0x6c , 0x2d ] ) , next : 0 } ,
2199+ Head { number : 20000002 , timestamp : 2000000000 , ..Default :: default ( ) } ,
2200+ ForkId { hash : ForkHash ( [ 0x9f , 0x3d , 0x22 , 0x54 ] ) , next : 0 } ,
21842201 ) ,
21852202 ] ,
21862203 ) ;
@@ -2417,11 +2434,9 @@ Post-merge hard forks (timestamp based):
24172434 /// This is based off of the test vectors here: https://github.com/ethereum/go-ethereum/blob/5c8cc10d1e05c23ff1108022f4150749e73c0ca1/core/forkid/forkid_test.go#L155-L188
24182435 #[ test]
24192436 fn timestamped_forks ( ) {
2420- let mainnet_with_shanghai = ChainSpecBuilder :: mainnet ( )
2421- . with_fork ( Hardfork :: Shanghai , ForkCondition :: Timestamp ( 1668000000 ) )
2422- . build ( ) ;
2437+ let mainnet_with_timestamps = ChainSpecBuilder :: mainnet ( ) . build ( ) ;
24232438 test_fork_ids (
2424- & mainnet_with_shanghai ,
2439+ & mainnet_with_timestamps ,
24252440 & [
24262441 (
24272442 Head { number : 0 , timestamp : 0 , ..Default :: default ( ) } ,
@@ -2521,20 +2536,28 @@ Post-merge hard forks (timestamp based):
25212536 ) , // Last Arrow Glacier block
25222537 (
25232538 Head { number : 15050000 , timestamp : 0 , ..Default :: default ( ) } ,
2524- ForkId { hash : ForkHash ( [ 0xf0 , 0xaf , 0xd0 , 0xe3 ] ) , next : 1668000000 } ,
2539+ ForkId { hash : ForkHash ( [ 0xf0 , 0xaf , 0xd0 , 0xe3 ] ) , next : 1681338455 } ,
25252540 ) , // First Gray Glacier block
25262541 (
25272542 Head { number : 19999999 , timestamp : 1667999999 , ..Default :: default ( ) } ,
2528- ForkId { hash : ForkHash ( [ 0xf0 , 0xaf , 0xd0 , 0xe3 ] ) , next : 1668000000 } ,
2543+ ForkId { hash : ForkHash ( [ 0xf0 , 0xaf , 0xd0 , 0xe3 ] ) , next : 1681338455 } ,
25292544 ) , // Last Gray Glacier block
25302545 (
2531- Head { number : 20000000 , timestamp : 1668000000 , ..Default :: default ( ) } ,
2532- ForkId { hash : ForkHash ( [ 0x71 , 0x14 , 0x76 , 0x44 ] ) , next : 0 } ,
2533- ) , // First Shanghai block
2546+ Head { number : 20000000 , timestamp : 1681338455 , ..Default :: default ( ) } ,
2547+ ForkId { hash : ForkHash ( [ 0xdc , 0xe9 , 0x6c , 0x2d ] ) , next : 1710338135 } ,
2548+ ) , // Last Shanghai block
2549+ (
2550+ Head { number : 20000001 , timestamp : 1710338134 , ..Default :: default ( ) } ,
2551+ ForkId { hash : ForkHash ( [ 0xdc , 0xe9 , 0x6c , 0x2d ] ) , next : 1710338135 } ,
2552+ ) , // First Cancun block
2553+ (
2554+ Head { number : 20000002 , timestamp : 1710338135 , ..Default :: default ( ) } ,
2555+ ForkId { hash : ForkHash ( [ 0x9f , 0x3d , 0x22 , 0x54 ] ) , next : 0 } ,
2556+ ) , // Future Cancun block
25342557 (
2535- Head { number : 20000000 , timestamp : 2668000000 , ..Default :: default ( ) } ,
2536- ForkId { hash : ForkHash ( [ 0x71 , 0x14 , 0x76 , 0x44 ] ) , next : 0 } ,
2537- ) , // Future Shanghai block
2558+ Head { number : 20000003 , timestamp : 2000000000 , ..Default :: default ( ) } ,
2559+ ForkId { hash : ForkHash ( [ 0x9f , 0x3d , 0x22 , 0x54 ] ) , next : 0 } ,
2560+ ) ,
25382561 ] ,
25392562 ) ;
25402563 }
@@ -2635,6 +2658,7 @@ Post-merge hard forks (timestamp based):
26352658 "arrowGlacierBlock": 0,
26362659 "grayGlacierBlock": 0,
26372660 "shanghaiTime": 0,
2661+ "cancunTime": 1,
26382662 "terminalTotalDifficulty": 0,
26392663 "terminalTotalDifficultyPassed": true,
26402664 "ethash": {}
@@ -2730,6 +2754,12 @@ Post-merge hard forks (timestamp based):
27302754 & ForkCondition :: Timestamp ( 0 )
27312755 ) ;
27322756
2757+ // including time based hardforks
2758+ assert_eq ! (
2759+ chainspec. hardforks. get( & Hardfork :: Cancun ) . unwrap( ) ,
2760+ & ForkCondition :: Timestamp ( 1 )
2761+ ) ;
2762+
27332763 // alloc key -> expected rlp mapping
27342764 let key_rlp = vec ! [
27352765 ( hex!( "658bdf435d810c91414ec09147daa6db62406379" ) , & hex!( "f84d8089487a9a304539440000a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" ) [ ..] ) ,
0 commit comments