Skip to content

Commit da98ffe

Browse files
committed
Add new fields to BeaconState to match v1.7.0-alpha.1.
1 parent 4ffb11e commit da98ffe

File tree

9 files changed

+94
-19
lines changed

9 files changed

+94
-19
lines changed

consensus/state_processing/src/envelope_processing.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,6 @@ pub fn envelope_processing<E: EthSpec>(
162162
});
163163
};
164164

165-
// Verify the withdrawals root
166-
envelope_verify!(
167-
payload.withdrawals.tree_hash_root() == *state.latest_withdrawals_root()?,
168-
EnvelopeProcessingError::WithdrawalsRootMismatch {
169-
state: *state.latest_withdrawals_root()?,
170-
envelope: payload.withdrawals.tree_hash_root(),
171-
}
172-
);
173-
174165
// Verify the gas limit
175166
envelope_verify!(
176167
payload.gas_limit == committed_bid.gas_limit,

consensus/state_processing/src/per_block_processing/process_withdrawals.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ pub mod gloas {
130130
let (expected_withdrawals, builder_withdrawals_count, partial_withdrawals_count) =
131131
get_expected_withdrawals(state, spec)?;
132132

133-
*state.latest_withdrawals_root_mut()? = expected_withdrawals.tree_hash_root();
134-
135133
for withdrawal in expected_withdrawals.iter() {
136134
decrease_balance(
137135
state,

consensus/state_processing/src/upgrade/gloas.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use bls::Hash256;
21
use milhouse::{List, Vector};
32
use ssz_types::BitVector;
43
use std::mem;
@@ -88,15 +87,18 @@ pub fn upgrade_state_to_gloas<E: EthSpec>(
8887
pending_deposits: pre.pending_deposits.clone(),
8988
pending_partial_withdrawals: pre.pending_partial_withdrawals.clone(),
9089
pending_consolidations: pre.pending_consolidations.clone(),
90+
proposer_lookahead: mem::take(&mut pre.proposer_lookahead),
9191
// Gloas
92+
builders: List::default(),
93+
next_withdrawal_builder_index: 0,
9294
execution_payload_availability: BitVector::default(), // All bits set to false initially
9395
builder_pending_payments: Vector::new(vec![
9496
BuilderPendingPayment::default();
9597
E::builder_pending_payments_limit()
9698
])?,
9799
builder_pending_withdrawals: List::default(), // Empty list initially,
98100
latest_block_hash: pre.latest_execution_payload_header.block_hash,
99-
latest_withdrawals_root: Hash256::default(),
101+
payload_expected_withdrawals: List::default(),
100102
// Caches
101103
total_active_balance: pre.total_active_balance,
102104
progressive_balances_cache: mem::take(&mut pre.progressive_balances_cache),
@@ -105,7 +107,6 @@ pub fn upgrade_state_to_gloas<E: EthSpec>(
105107
exit_cache: mem::take(&mut pre.exit_cache),
106108
slashings_cache: mem::take(&mut pre.slashings_cache),
107109
epoch_cache: mem::take(&mut pre.epoch_cache),
108-
proposer_lookahead: mem::take(&mut pre.proposer_lookahead),
109110
});
110111
Ok(post)
111112
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,23 @@
11
# Mainnet preset - Gloas
2+
3+
# Misc
4+
# ---------------------------------------------------------------
5+
# 2**9 (= 512) validators
6+
PTC_SIZE: 512
7+
8+
# Max operations per block
9+
# ---------------------------------------------------------------
10+
# 2**2 (= 4) attestations
11+
MAX_PAYLOAD_ATTESTATIONS: 4
12+
13+
# State list lengths
14+
# ---------------------------------------------------------------
15+
# 2**40 (= 1,099,511,627,776) builder spots
16+
BUILDER_REGISTRY_LIMIT: 1099511627776
17+
# 2**20 (= 1,048,576) builder pending withdrawals
18+
BUILDER_PENDING_WITHDRAWALS_LIMIT: 1048576
19+
20+
# Withdrawals processing
21+
# ---------------------------------------------------------------
22+
# 2**14 (= 16,384) builders
23+
MAX_BUILDERS_PER_WITHDRAWALS_SWEEP: 16384
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,23 @@
11
# Minimal preset - Gloas
2+
3+
# Misc
4+
# ---------------------------------------------------------------
5+
# [customized] 2**1 (= 2) validators
6+
PTC_SIZE: 2
7+
8+
# Max operations per block
9+
# ---------------------------------------------------------------
10+
# 2**2 (= 4) attestations
11+
MAX_PAYLOAD_ATTESTATIONS: 4
12+
13+
# State list lengths
14+
# ---------------------------------------------------------------
15+
# 2**40 (= 1,099,511,627,776) builder spots
16+
BUILDER_REGISTRY_LIMIT: 1099511627776
17+
# 2**20 (= 1,048,576) builder pending withdrawals
18+
BUILDER_PENDING_WITHDRAWALS_LIMIT: 1048576
19+
20+
# Withdrawals processing
21+
# ---------------------------------------------------------------
22+
# [customized] 2**4 (= 16) builders
23+
MAX_BUILDERS_PER_WITHDRAWALS_SWEEP: 16
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
use crate::test_utils::TestRandom;
2+
use crate::{Address, Epoch};
3+
use bls::PublicKeyBytes;
4+
use serde::{Deserialize, Serialize};
5+
use ssz_derive::{Decode, Encode};
6+
use test_random_derive::TestRandom;
7+
use tree_hash_derive::TreeHash;
8+
9+
pub type BuilderIndex = u64;
10+
11+
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
12+
#[derive(
13+
Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Encode, Decode, TestRandom, TreeHash,
14+
)]
15+
pub struct Builder {
16+
pub pubkey: PublicKeyBytes,
17+
pub version: u8,
18+
pub execution_address: Address,
19+
pub balance: u64,
20+
pub deposit_epoch: Epoch,
21+
pub withdrawable_epoch: Epoch,
22+
}

consensus/types/src/builder/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
mod builder;
12
mod builder_bid;
23
mod builder_pending_payment;
34
mod builder_pending_withdrawal;
45

6+
pub use builder::{Builder, BuilderIndex};
57
pub use builder_bid::{
68
BuilderBid, BuilderBidBellatrix, BuilderBidCapella, BuilderBidDeneb, BuilderBidElectra,
79
BuilderBidFulu, SignedBuilderBid,

consensus/types/src/core/eth_spec.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ pub trait EthSpec: 'static + Default + Sync + Send + Clone + Debug + PartialEq +
122122
type CellsPerExtBlob: Unsigned + Clone + Sync + Send + Debug + PartialEq;
123123
type NumberOfColumns: Unsigned + Clone + Sync + Send + Debug + PartialEq;
124124
type ProposerLookaheadSlots: Unsigned + Clone + Sync + Send + Debug + PartialEq;
125+
/*
126+
* New in Gloas
127+
*/
128+
type BuilderRegistryLimit: Unsigned + Clone + Sync + Send + Debug + PartialEq;
125129
/*
126130
* Derived values (set these CAREFULLY)
127131
*/
@@ -484,6 +488,7 @@ impl EthSpec for MainnetEthSpec {
484488
type CellsPerExtBlob = U128;
485489
type NumberOfColumns = U128;
486490
type ProposerLookaheadSlots = U64; // Derived from (MIN_SEED_LOOKAHEAD + 1) * SLOTS_PER_EPOCH
491+
type BuilderRegistryLimit = U1099511627776;
487492
type SyncSubcommitteeSize = U128; // 512 committee size / 4 sync committee subnet count
488493
type MaxPendingAttestations = U4096; // 128 max attestations * 32 slots per epoch
489494
type SlotsPerEth1VotingPeriod = U2048; // 64 epochs * 32 slots per epoch
@@ -574,7 +579,8 @@ impl EthSpec for MinimalEthSpec {
574579
MaxDepositRequestsPerPayload,
575580
MaxWithdrawalRequestsPerPayload,
576581
PTCSize,
577-
MaxPayloadAttestations
582+
MaxPayloadAttestations,
583+
BuilderRegistryLimit
578584
});
579585

580586
fn default_spec() -> ChainSpec {
@@ -647,6 +653,7 @@ impl EthSpec for GnosisEthSpec {
647653
type CellsPerExtBlob = U128;
648654
type NumberOfColumns = U128;
649655
type ProposerLookaheadSlots = U32; // Derived from (MIN_SEED_LOOKAHEAD + 1) * SLOTS_PER_EPOCH
656+
type BuilderRegistryLimit = U1099511627776;
650657
type PTCSize = U512;
651658
type MaxPayloadAttestations = U2;
652659

consensus/types/src/state/beacon_state.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ use tree_hash_derive::TreeHash;
2323
use typenum::Unsigned;
2424

2525
use crate::{
26-
BuilderPendingPayment, BuilderPendingWithdrawal, ExecutionBlockHash, ExecutionPayloadBid,
26+
Builder, BuilderIndex, BuilderPendingPayment, BuilderPendingWithdrawal, ExecutionBlockHash,
27+
ExecutionPayloadBid, Withdrawal,
2728
attestation::{
2829
AttestationData, AttestationDuty, BeaconCommittee, Checkpoint, CommitteeIndex, PTC,
2930
ParticipationFlags, PendingAttestation,
@@ -608,8 +609,17 @@ where
608609
#[superstruct(only(Fulu, Gloas))]
609610
#[serde(with = "ssz_types::serde_utils::quoted_u64_fixed_vec")]
610611
pub proposer_lookahead: Vector<u64, E::ProposerLookaheadSlots>,
611-
612612
// Gloas
613+
#[compare_fields(as_iter)]
614+
#[test_random(default)]
615+
#[superstruct(only(Gloas))]
616+
pub builders: List<Builder, E::BuilderRegistryLimit>,
617+
618+
#[metastruct(exclude_from(tree_lists))]
619+
#[serde(with = "serde_utils::quoted_u64")]
620+
#[superstruct(only(Gloas), partial_getter(copy))]
621+
pub next_withdrawal_builder_index: BuilderIndex,
622+
613623
#[test_random(default)]
614624
#[superstruct(only(Gloas))]
615625
#[metastruct(exclude_from(tree_lists))]
@@ -631,10 +641,10 @@ where
631641
#[metastruct(exclude_from(tree_lists))]
632642
pub latest_block_hash: ExecutionBlockHash,
633643

644+
#[compare_fields(as_iter)]
634645
#[test_random(default)]
635646
#[superstruct(only(Gloas))]
636-
#[metastruct(exclude_from(tree_lists))]
637-
pub latest_withdrawals_root: Hash256,
647+
pub payload_expected_withdrawals: List<Withdrawal, E::MaxWithdrawalsPerPayload>,
638648

639649
// Caching (not in the spec)
640650
#[serde(skip_serializing, skip_deserializing)]

0 commit comments

Comments
 (0)