Add new fields to BeaconState to match v1.7.0-alpha.1.

This commit is contained in:
Jimmy Chen
2026-01-19 16:45:39 +11:00
parent 4ffb11ed5c
commit da98ffec8d
9 changed files with 94 additions and 19 deletions

View File

@@ -162,15 +162,6 @@ pub fn envelope_processing<E: EthSpec>(
});
};
// Verify the withdrawals root
envelope_verify!(
payload.withdrawals.tree_hash_root() == *state.latest_withdrawals_root()?,
EnvelopeProcessingError::WithdrawalsRootMismatch {
state: *state.latest_withdrawals_root()?,
envelope: payload.withdrawals.tree_hash_root(),
}
);
// Verify the gas limit
envelope_verify!(
payload.gas_limit == committed_bid.gas_limit,

View File

@@ -130,8 +130,6 @@ pub mod gloas {
let (expected_withdrawals, builder_withdrawals_count, partial_withdrawals_count) =
get_expected_withdrawals(state, spec)?;
*state.latest_withdrawals_root_mut()? = expected_withdrawals.tree_hash_root();
for withdrawal in expected_withdrawals.iter() {
decrease_balance(
state,

View File

@@ -1,4 +1,3 @@
use bls::Hash256;
use milhouse::{List, Vector};
use ssz_types::BitVector;
use std::mem;
@@ -88,7 +87,10 @@ pub fn upgrade_state_to_gloas<E: EthSpec>(
pending_deposits: pre.pending_deposits.clone(),
pending_partial_withdrawals: pre.pending_partial_withdrawals.clone(),
pending_consolidations: pre.pending_consolidations.clone(),
proposer_lookahead: mem::take(&mut pre.proposer_lookahead),
// Gloas
builders: List::default(),
next_withdrawal_builder_index: 0,
execution_payload_availability: BitVector::default(), // All bits set to false initially
builder_pending_payments: Vector::new(vec![
BuilderPendingPayment::default();
@@ -96,7 +98,7 @@ pub fn upgrade_state_to_gloas<E: EthSpec>(
])?,
builder_pending_withdrawals: List::default(), // Empty list initially,
latest_block_hash: pre.latest_execution_payload_header.block_hash,
latest_withdrawals_root: Hash256::default(),
payload_expected_withdrawals: List::default(),
// Caches
total_active_balance: pre.total_active_balance,
progressive_balances_cache: mem::take(&mut pre.progressive_balances_cache),
@@ -105,7 +107,6 @@ pub fn upgrade_state_to_gloas<E: EthSpec>(
exit_cache: mem::take(&mut pre.exit_cache),
slashings_cache: mem::take(&mut pre.slashings_cache),
epoch_cache: mem::take(&mut pre.epoch_cache),
proposer_lookahead: mem::take(&mut pre.proposer_lookahead),
});
Ok(post)
}

View File

@@ -1 +1,23 @@
# Mainnet preset - Gloas
# Misc
# ---------------------------------------------------------------
# 2**9 (= 512) validators
PTC_SIZE: 512
# Max operations per block
# ---------------------------------------------------------------
# 2**2 (= 4) attestations
MAX_PAYLOAD_ATTESTATIONS: 4
# State list lengths
# ---------------------------------------------------------------
# 2**40 (= 1,099,511,627,776) builder spots
BUILDER_REGISTRY_LIMIT: 1099511627776
# 2**20 (= 1,048,576) builder pending withdrawals
BUILDER_PENDING_WITHDRAWALS_LIMIT: 1048576
# Withdrawals processing
# ---------------------------------------------------------------
# 2**14 (= 16,384) builders
MAX_BUILDERS_PER_WITHDRAWALS_SWEEP: 16384

View File

@@ -1 +1,23 @@
# Minimal preset - Gloas
# Misc
# ---------------------------------------------------------------
# [customized] 2**1 (= 2) validators
PTC_SIZE: 2
# Max operations per block
# ---------------------------------------------------------------
# 2**2 (= 4) attestations
MAX_PAYLOAD_ATTESTATIONS: 4
# State list lengths
# ---------------------------------------------------------------
# 2**40 (= 1,099,511,627,776) builder spots
BUILDER_REGISTRY_LIMIT: 1099511627776
# 2**20 (= 1,048,576) builder pending withdrawals
BUILDER_PENDING_WITHDRAWALS_LIMIT: 1048576
# Withdrawals processing
# ---------------------------------------------------------------
# [customized] 2**4 (= 16) builders
MAX_BUILDERS_PER_WITHDRAWALS_SWEEP: 16

View File

@@ -0,0 +1,22 @@
use crate::test_utils::TestRandom;
use crate::{Address, Epoch};
use bls::PublicKeyBytes;
use serde::{Deserialize, Serialize};
use ssz_derive::{Decode, Encode};
use test_random_derive::TestRandom;
use tree_hash_derive::TreeHash;
pub type BuilderIndex = u64;
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[derive(
Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Encode, Decode, TestRandom, TreeHash,
)]
pub struct Builder {
pub pubkey: PublicKeyBytes,
pub version: u8,
pub execution_address: Address,
pub balance: u64,
pub deposit_epoch: Epoch,
pub withdrawable_epoch: Epoch,
}

View File

@@ -1,7 +1,9 @@
mod builder;
mod builder_bid;
mod builder_pending_payment;
mod builder_pending_withdrawal;
pub use builder::{Builder, BuilderIndex};
pub use builder_bid::{
BuilderBid, BuilderBidBellatrix, BuilderBidCapella, BuilderBidDeneb, BuilderBidElectra,
BuilderBidFulu, SignedBuilderBid,

View File

@@ -122,6 +122,10 @@ pub trait EthSpec: 'static + Default + Sync + Send + Clone + Debug + PartialEq +
type CellsPerExtBlob: Unsigned + Clone + Sync + Send + Debug + PartialEq;
type NumberOfColumns: Unsigned + Clone + Sync + Send + Debug + PartialEq;
type ProposerLookaheadSlots: Unsigned + Clone + Sync + Send + Debug + PartialEq;
/*
* New in Gloas
*/
type BuilderRegistryLimit: Unsigned + Clone + Sync + Send + Debug + PartialEq;
/*
* Derived values (set these CAREFULLY)
*/
@@ -484,6 +488,7 @@ impl EthSpec for MainnetEthSpec {
type CellsPerExtBlob = U128;
type NumberOfColumns = U128;
type ProposerLookaheadSlots = U64; // Derived from (MIN_SEED_LOOKAHEAD + 1) * SLOTS_PER_EPOCH
type BuilderRegistryLimit = U1099511627776;
type SyncSubcommitteeSize = U128; // 512 committee size / 4 sync committee subnet count
type MaxPendingAttestations = U4096; // 128 max attestations * 32 slots per epoch
type SlotsPerEth1VotingPeriod = U2048; // 64 epochs * 32 slots per epoch
@@ -574,7 +579,8 @@ impl EthSpec for MinimalEthSpec {
MaxDepositRequestsPerPayload,
MaxWithdrawalRequestsPerPayload,
PTCSize,
MaxPayloadAttestations
MaxPayloadAttestations,
BuilderRegistryLimit
});
fn default_spec() -> ChainSpec {
@@ -647,6 +653,7 @@ impl EthSpec for GnosisEthSpec {
type CellsPerExtBlob = U128;
type NumberOfColumns = U128;
type ProposerLookaheadSlots = U32; // Derived from (MIN_SEED_LOOKAHEAD + 1) * SLOTS_PER_EPOCH
type BuilderRegistryLimit = U1099511627776;
type PTCSize = U512;
type MaxPayloadAttestations = U2;

View File

@@ -23,7 +23,8 @@ use tree_hash_derive::TreeHash;
use typenum::Unsigned;
use crate::{
BuilderPendingPayment, BuilderPendingWithdrawal, ExecutionBlockHash, ExecutionPayloadBid,
Builder, BuilderIndex, BuilderPendingPayment, BuilderPendingWithdrawal, ExecutionBlockHash,
ExecutionPayloadBid, Withdrawal,
attestation::{
AttestationData, AttestationDuty, BeaconCommittee, Checkpoint, CommitteeIndex, PTC,
ParticipationFlags, PendingAttestation,
@@ -608,8 +609,17 @@ where
#[superstruct(only(Fulu, Gloas))]
#[serde(with = "ssz_types::serde_utils::quoted_u64_fixed_vec")]
pub proposer_lookahead: Vector<u64, E::ProposerLookaheadSlots>,
// Gloas
#[compare_fields(as_iter)]
#[test_random(default)]
#[superstruct(only(Gloas))]
pub builders: List<Builder, E::BuilderRegistryLimit>,
#[metastruct(exclude_from(tree_lists))]
#[serde(with = "serde_utils::quoted_u64")]
#[superstruct(only(Gloas), partial_getter(copy))]
pub next_withdrawal_builder_index: BuilderIndex,
#[test_random(default)]
#[superstruct(only(Gloas))]
#[metastruct(exclude_from(tree_lists))]
@@ -631,10 +641,10 @@ where
#[metastruct(exclude_from(tree_lists))]
pub latest_block_hash: ExecutionBlockHash,
#[compare_fields(as_iter)]
#[test_random(default)]
#[superstruct(only(Gloas))]
#[metastruct(exclude_from(tree_lists))]
pub latest_withdrawals_root: Hash256,
pub payload_expected_withdrawals: List<Withdrawal, E::MaxWithdrawalsPerPayload>,
// Caching (not in the spec)
#[serde(skip_serializing, skip_deserializing)]