mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-30 19:23:50 +00:00
Add mainnet merge values 🐼 (#3462)
## 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~~
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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<MainnetEthSpec> = BeaconState::Base(BeaconStateBase {
|
||||
let good_base_state: BeaconState<MainnetEthSpec> = 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
|
||||
);
|
||||
<BeaconState<MainnetEthSpec>>::from_ssz_bytes(&bad_base_block.as_ssz_bytes(), &spec)
|
||||
.expect_err("bad base block cannot be decoded");
|
||||
<BeaconState<MainnetEthSpec>>::from_ssz_bytes(&bad_base_state.as_ssz_bytes(), &spec)
|
||||
.expect_err("bad base state cannot be decoded");
|
||||
}
|
||||
|
||||
// BeaconStateAltair
|
||||
{
|
||||
let good_altair_block: BeaconState<MainnetEthSpec> =
|
||||
let good_altair_state: BeaconState<MainnetEthSpec> =
|
||||
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
|
||||
);
|
||||
<BeaconState<MainnetEthSpec>>::from_ssz_bytes(&bad_altair_block.as_ssz_bytes(), &spec)
|
||||
.expect_err("bad altair block cannot be decoded");
|
||||
<BeaconState<MainnetEthSpec>>::from_ssz_bytes(&bad_altair_state.as_ssz_bytes(), &spec)
|
||||
.expect_err("bad altair state cannot be decoded");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user