From 059716a942ed165b9fe8bda1be0f7373b54dd5f8 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Wed, 17 Aug 2022 02:36:38 +0000 Subject: [PATCH] =?UTF-8?q?Add=20mainnet=20merge=20values=20=F0=9F=90=BC?= =?UTF-8?q?=20(#3462)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Issue Addressed NA ## Proposed Changes Adds **tentative** values for the merge TTD and Bellatrix as per https://github.com/ethereum/consensus-specs/pull/2969 ## Additional Info - ~~Blocked on https://github.com/ethereum/consensus-specs/pull/2969~~ --- .../mainnet/config.yaml | 6 +-- consensus/types/src/beacon_block.rs | 6 +-- consensus/types/src/beacon_state/tests.rs | 44 +++++++++---------- consensus/types/src/chain_spec.rs | 18 ++++---- testing/ef_tests/Makefile | 2 +- testing/ef_tests/check_all_files_accessed.py | 8 ++++ 6 files changed, 45 insertions(+), 39 deletions(-) diff --git a/common/eth2_network_config/built_in_network_configs/mainnet/config.yaml b/common/eth2_network_config/built_in_network_configs/mainnet/config.yaml index cc4e7dcab4f..6e87a708f82 100644 --- a/common/eth2_network_config/built_in_network_configs/mainnet/config.yaml +++ b/common/eth2_network_config/built_in_network_configs/mainnet/config.yaml @@ -6,8 +6,8 @@ PRESET_BASE: 'mainnet' # Transition # --------------------------------------------------------------- -# TBD, 2**256-2**10 is a placeholder -TERMINAL_TOTAL_DIFFICULTY: 115792089237316195423570985008687907853269984665640564039457584007913129638912 +# Estimated on Sept 15, 2022 +TERMINAL_TOTAL_DIFFICULTY: 58750000000000000000000 # By default, don't use these params TERMINAL_BLOCK_HASH: 0x0000000000000000000000000000000000000000000000000000000000000000 TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH: 18446744073709551615 @@ -35,7 +35,7 @@ ALTAIR_FORK_VERSION: 0x01000000 ALTAIR_FORK_EPOCH: 74240 # Merge BELLATRIX_FORK_VERSION: 0x02000000 -BELLATRIX_FORK_EPOCH: 18446744073709551615 +BELLATRIX_FORK_EPOCH: 144896 # Sept 6, 2022, 11:34:47am UTC # Sharding SHARDING_FORK_VERSION: 0x03000000 SHARDING_FORK_EPOCH: 18446744073709551615 diff --git a/consensus/types/src/beacon_block.rs b/consensus/types/src/beacon_block.rs index 2d7e68a5c4a..da8566dcb23 100644 --- a/consensus/types/src/beacon_block.rs +++ b/consensus/types/src/beacon_block.rs @@ -651,19 +651,17 @@ mod tests { #[test] fn decode_base_and_altair() { type E = MainnetEthSpec; + let spec = E::default_spec(); let rng = &mut XorShiftRng::from_seed([42; 16]); - let fork_epoch = Epoch::from_ssz_bytes(&[7, 6, 5, 4, 3, 2, 1, 0]).unwrap(); + let fork_epoch = spec.altair_fork_epoch.unwrap(); let base_epoch = fork_epoch.saturating_sub(1_u64); let base_slot = base_epoch.end_slot(E::slots_per_epoch()); let altair_epoch = fork_epoch; let altair_slot = altair_epoch.start_slot(E::slots_per_epoch()); - let mut spec = E::default_spec(); - spec.altair_fork_epoch = Some(fork_epoch); - // BeaconBlockBase { let good_base_block = BeaconBlock::Base(BeaconBlockBase { diff --git a/consensus/types/src/beacon_state/tests.rs b/consensus/types/src/beacon_state/tests.rs index d65d0a9e6ce..5898bfe214f 100644 --- a/consensus/types/src/beacon_state/tests.rs +++ b/consensus/types/src/beacon_state/tests.rs @@ -11,7 +11,7 @@ use beacon_chain::types::{ MinimalEthSpec, RelativeEpoch, Slot, }; use safe_arith::SafeArith; -use ssz::{Decode, Encode}; +use ssz::Encode; use state_processing::per_slot_processing; use std::ops::Mul; use swap_or_not_shuffle::compute_shuffled_index; @@ -438,62 +438,60 @@ mod get_outstanding_deposit_len { #[test] fn decode_base_and_altair() { type E = MainnetEthSpec; + let spec = E::default_spec(); let rng = &mut XorShiftRng::from_seed([42; 16]); - let fork_epoch = Epoch::from_ssz_bytes(&[7, 6, 5, 4, 3, 2, 1, 0]).unwrap(); + let fork_epoch = spec.altair_fork_epoch.unwrap(); let base_epoch = fork_epoch.saturating_sub(1_u64); let base_slot = base_epoch.end_slot(E::slots_per_epoch()); let altair_epoch = fork_epoch; let altair_slot = altair_epoch.start_slot(E::slots_per_epoch()); - let mut spec = E::default_spec(); - spec.altair_fork_epoch = Some(altair_epoch); - // BeaconStateBase { - let good_base_block: BeaconState = BeaconState::Base(BeaconStateBase { + let good_base_state: BeaconState = BeaconState::Base(BeaconStateBase { slot: base_slot, ..<_>::random_for_test(rng) }); - // It's invalid to have a base block with a slot higher than the fork slot. - let bad_base_block = { - let mut bad = good_base_block.clone(); + // It's invalid to have a base state with a slot higher than the fork slot. + let bad_base_state = { + let mut bad = good_base_state.clone(); *bad.slot_mut() = altair_slot; bad }; assert_eq!( - BeaconState::from_ssz_bytes(&good_base_block.as_ssz_bytes(), &spec) - .expect("good base block can be decoded"), - good_base_block + BeaconState::from_ssz_bytes(&good_base_state.as_ssz_bytes(), &spec) + .expect("good base state can be decoded"), + good_base_state ); - >::from_ssz_bytes(&bad_base_block.as_ssz_bytes(), &spec) - .expect_err("bad base block cannot be decoded"); + >::from_ssz_bytes(&bad_base_state.as_ssz_bytes(), &spec) + .expect_err("bad base state cannot be decoded"); } // BeaconStateAltair { - let good_altair_block: BeaconState = + let good_altair_state: BeaconState = BeaconState::Altair(BeaconStateAltair { slot: altair_slot, ..<_>::random_for_test(rng) }); - // It's invalid to have an Altair block with a slot lower than the fork slot. - let bad_altair_block = { - let mut bad = good_altair_block.clone(); + // It's invalid to have an Altair state with a slot lower than the fork slot. + let bad_altair_state = { + let mut bad = good_altair_state.clone(); *bad.slot_mut() = base_slot; bad }; assert_eq!( - BeaconState::from_ssz_bytes(&good_altair_block.as_ssz_bytes(), &spec) - .expect("good altair block can be decoded"), - good_altair_block + BeaconState::from_ssz_bytes(&good_altair_state.as_ssz_bytes(), &spec) + .expect("good altair state can be decoded"), + good_altair_state ); - >::from_ssz_bytes(&bad_altair_block.as_ssz_bytes(), &spec) - .expect_err("bad altair block cannot be decoded"); + >::from_ssz_bytes(&bad_altair_state.as_ssz_bytes(), &spec) + .expect_err("bad altair state cannot be decoded"); } } diff --git a/consensus/types/src/chain_spec.rs b/consensus/types/src/chain_spec.rs index 8d56ce2da94..b2ba24ac3ee 100644 --- a/consensus/types/src/chain_spec.rs +++ b/consensus/types/src/chain_spec.rs @@ -561,14 +561,9 @@ impl ChainSpec { .expect("pow does not overflow"), proportional_slashing_multiplier_bellatrix: 3, bellatrix_fork_version: [0x02, 0x00, 0x00, 0x00], - bellatrix_fork_epoch: None, - terminal_total_difficulty: Uint256::MAX - .checked_sub(Uint256::from(2u64.pow(10))) - .expect("subtraction does not overflow") - // Add 1 since the spec declares `2**256 - 2**10` and we use - // `Uint256::MAX` which is `2*256- 1`. - .checked_add(Uint256::one()) - .expect("addition does not overflow"), + bellatrix_fork_epoch: Some(Epoch::new(144896)), + terminal_total_difficulty: Uint256::from_dec_str("58750000000000000000000") + .expect("terminal_total_difficulty is a valid integer"), terminal_block_hash: ExecutionBlockHash::zero(), terminal_block_hash_activation_epoch: Epoch::new(u64::MAX), safe_slots_to_import_optimistically: 128u64, @@ -621,6 +616,13 @@ impl ChainSpec { // Merge bellatrix_fork_version: [0x02, 0x00, 0x00, 0x01], bellatrix_fork_epoch: None, + terminal_total_difficulty: Uint256::MAX + .checked_sub(Uint256::from(2u64.pow(10))) + .expect("subtraction does not overflow") + // Add 1 since the spec declares `2**256 - 2**10` and we use + // `Uint256::MAX` which is `2*256- 1`. + .checked_add(Uint256::one()) + .expect("addition does not overflow"), // Other network_id: 2, // lighthouse testnet network id deposit_chain_id: 5, diff --git a/testing/ef_tests/Makefile b/testing/ef_tests/Makefile index b237bfb7610..9127093310c 100644 --- a/testing/ef_tests/Makefile +++ b/testing/ef_tests/Makefile @@ -1,4 +1,4 @@ -TESTS_TAG := v1.2.0-rc.1 +TESTS_TAG := v1.2.0-rc.2 TESTS = general minimal mainnet TARBALLS = $(patsubst %,%-$(TESTS_TAG).tar.gz,$(TESTS)) diff --git a/testing/ef_tests/check_all_files_accessed.py b/testing/ef_tests/check_all_files_accessed.py index 87953a6141f..88567c688ee 100755 --- a/testing/ef_tests/check_all_files_accessed.py +++ b/testing/ef_tests/check_all_files_accessed.py @@ -25,12 +25,20 @@ # Intentionally omitted, as per https://github.com/sigp/lighthouse/issues/1835 "tests/.*/.*/ssz_static/Eth1Block/", "tests/.*/.*/ssz_static/PowBlock/", + # light_client + "tests/.*/.*/light_client", # LightClientStore "tests/.*/.*/ssz_static/LightClientStore", # LightClientUpdate "tests/.*/.*/ssz_static/LightClientUpdate", # LightClientSnapshot "tests/.*/.*/ssz_static/LightClientSnapshot", + # LightClientBootstrap + "tests/.*/.*/ssz_static/LightClientBootstrap", + # LightClientOptimistic + "tests/.*/.*/ssz_static/LightClientOptimistic", + # LightClientFinalityUpdate + "tests/.*/.*/ssz_static/LightClientFinalityUpdate", # Merkle-proof tests for light clients "tests/.*/.*/merkle/single_proof", # Capella tests are disabled for now.