Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions beacon_node/beacon_chain/src/data_column_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,22 @@ mod test {
.build();
harness.advance_slot();

// Check block generator timestamp conversion sanity.
{
let exec_block_generator = harness.execution_block_generator();
assert_eq!(
exec_block_generator
.timestamp_to_slot_post_capella(exec_block_generator.osaka_time.unwrap()),
0
);
assert_eq!(
exec_block_generator.timestamp_to_slot_post_capella(
exec_block_generator.osaka_time.unwrap() + harness.spec.seconds_per_slot
),
1
);
}

let verify_fn = |column_sidecar: DataColumnSidecar<E>| {
GossipVerifiedDataColumn::<_>::new_for_block_publishing(
column_sidecar.into(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use types::{
Blob, ChainSpec, EthSpec, ExecutionBlockHash, ExecutionPayload, ExecutionPayloadBellatrix,
ExecutionPayloadCapella, ExecutionPayloadDeneb, ExecutionPayloadElectra, ExecutionPayloadFulu,
ExecutionPayloadGloas, ExecutionPayloadHeader, FixedBytesExtended, ForkName, Hash256,
KzgProofs, Transaction, Transactions, Uint256,
KzgProofs, Slot, Transaction, Transactions, Uint256,
};

use super::DEFAULT_TERMINAL_BLOCK;
Expand Down Expand Up @@ -265,6 +265,37 @@ impl<E: EthSpec> ExecutionBlockGenerator<E> {
ForkName::Bellatrix
}

/// Get the timestamp at which `fork` activates.
///
/// This function will panic if the `fork` is not enabled or is `<= ForkName::Bellatrix`.
pub fn get_fork_timestamp_post_capella(&self, fork: ForkName) -> u64 {
match fork {
ForkName::Gloas => self.amsterdam_time,
ForkName::Fulu => self.osaka_time,
ForkName::Electra => self.prague_time,
ForkName::Deneb => self.cancun_time,
ForkName::Capella => self.shanghai_time,
_ => panic!("only the Capella fork or later is supported"),
}
.unwrap_or_else(|| panic!("fork is {fork} but no corresponding timestamp is set"))
}

/// This is a slightly nasty method for converting timestamps to slots, but it will suffice
/// until we can plumb through a slot clock.
pub fn timestamp_to_slot_post_capella(&self, timestamp: u64) -> Slot {
let fork = self.get_fork_at_timestamp(timestamp);
let fork_epoch = self.spec.fork_epoch(fork).unwrap();
let fork_timestamp = self.get_fork_timestamp_post_capella(fork);

// Number of slots since fork.
let slot_offset = timestamp
.checked_sub(fork_timestamp)
.expect("timestamp should be >= fork timestamp")
/ self.spec.seconds_per_slot;

fork_epoch.start_slot(E::slots_per_epoch()) + Slot::new(slot_offset)
}

pub fn execution_block_by_number(&self, number: u64) -> Option<ExecutionBlock> {
self.block_by_number(number)
.map(|block| block.as_execution_block(self.terminal_total_difficulty))
Expand Down Expand Up @@ -734,9 +765,10 @@ impl<E: EthSpec> ExecutionBlockGenerator<E> {
if fork_name.deneb_enabled() {
// get random number between 0 and Max Blobs
let mut rng = self.rng.lock();
// TODO(EIP-7892): see FIXME below
// FIXME: this will break with BPO forks. This function needs to calculate the epoch based on block timestamp..
let max_blobs = self.spec.max_blobs_per_block_within_fork(fork_name) as usize;
let epoch = self
.timestamp_to_slot_post_capella(execution_payload.timestamp())
.epoch(E::slots_per_epoch());
let max_blobs = self.spec.max_blobs_per_block(epoch) as usize;
let num_blobs = rng.random_range(self.min_blobs_count..=max_blobs);
let (bundle, transactions) = generate_blobs(num_blobs, fork_name)?;
for tx in Vec::from(transactions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ PRESET_BASE: 'mainnet'
# Free-form short name of the network that this configuration applies to - known
# canonical network names include:
# * 'mainnet' - there can be only one
# * 'sepolia' - testnet
# * 'holesky' - testnet
# * 'hoodi' - testnet
# Must match the regex: [a-z0-9\-]
CONFIG_NAME: 'mainnet'

Expand Down Expand Up @@ -52,23 +54,37 @@ ELECTRA_FORK_VERSION: 0x05000000
ELECTRA_FORK_EPOCH: 364032 # May 7, 2025, 10:05:11am UTC
# Fulu
FULU_FORK_VERSION: 0x06000000
FULU_FORK_EPOCH: 18446744073709551615
FULU_FORK_EPOCH: 411392 # December 3, 2025, 09:49:11pm UTC
# Gloas
GLOAS_FORK_VERSION: 0x07000000
GLOAS_FORK_EPOCH: 18446744073709551615

# Time parameters
# ---------------------------------------------------------------
# 12 seconds
# 12 seconds (*deprecated*)
SECONDS_PER_SLOT: 12
# 12000 milliseconds
SLOT_DURATION_MS: 12000
# 14 (estimate from Eth1 mainnet)
SECONDS_PER_ETH1_BLOCK: 14
# 2**8 (= 256) epochs ~27 hours
# 2**8 (= 256) epochs
MIN_VALIDATOR_WITHDRAWABILITY_DELAY: 256
# 2**8 (= 256) epochs ~27 hours
# 2**8 (= 256) epochs
SHARD_COMMITTEE_PERIOD: 256
# 2**11 (= 2,048) Eth1 blocks ~8 hours
# 2**11 (= 2,048) Eth1 blocks
ETH1_FOLLOW_DISTANCE: 2048
# 1667 basis points, ~17% of SLOT_DURATION_MS
PROPOSER_REORG_CUTOFF_BPS: 1667
# 3333 basis points, ~33% of SLOT_DURATION_MS
ATTESTATION_DUE_BPS: 3333
# 6667 basis points, ~67% of SLOT_DURATION_MS
AGGREGATE_DUE_BPS: 6667

# Altair
# 3333 basis points, ~33% of SLOT_DURATION_MS
SYNC_MESSAGE_DUE_BPS: 3333
# 6667 basis points, ~67% of SLOT_DURATION_MS
CONTRIBUTION_DUE_BPS: 6667

# Validator cycle
# ---------------------------------------------------------------
Expand All @@ -78,13 +94,21 @@ INACTIVITY_SCORE_BIAS: 4
INACTIVITY_SCORE_RECOVERY_RATE: 16
# 2**4 * 10**9 (= 16,000,000,000) Gwei
EJECTION_BALANCE: 16000000000
# 2**2 (= 4)
# 2**2 (= 4) validators
MIN_PER_EPOCH_CHURN_LIMIT: 4
# 2**16 (= 65,536)
CHURN_LIMIT_QUOTIENT: 65536
# [New in Deneb:EIP7514] 2**3 (= 8)

# Deneb
# 2**3 (= 8) (*deprecated*)
MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT: 8

# Electra
# 2**7 * 10**9 (= 128,000,000,000) Gwei
MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA: 128000000000
# 2**8 * 10**9 (= 256,000,000,000) Gwei
MAX_PER_EPOCH_ACTIVATION_EXIT_CHURN_LIMIT: 256000000000

# Fork choice
# ---------------------------------------------------------------
# 40%
Expand All @@ -93,7 +117,7 @@ PROPOSER_SCORE_BOOST: 40
REORG_HEAD_WEIGHT_THRESHOLD: 20
# 160%
REORG_PARENT_WEIGHT_THRESHOLD: 160
# `2` epochs
# 2 epochs
REORG_MAX_EPOCHS_SINCE_FINALIZATION: 2

# Deposit contract
Expand All @@ -105,64 +129,79 @@ DEPOSIT_CONTRACT_ADDRESS: 0x00000000219ab540356cBB839Cbe05303d7705Fa

# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (= 10485760, 10 MiB)
# 10 * 2**20 (= 10,485,760) bytes, 10 MiB
MAX_PAYLOAD_SIZE: 10485760
# `2**10` (= 1024)
# 2**10 (= 1,024) blocks
MAX_REQUEST_BLOCKS: 1024
# `2**8` (= 256)
# 2**8 (= 256) epochs
EPOCHS_PER_SUBNET_SUBSCRIPTION: 256
# `MIN_VALIDATOR_WITHDRAWABILITY_DELAY + CHURN_LIMIT_QUOTIENT // 2` (= 33024, ~5 months)
# MIN_VALIDATOR_WITHDRAWABILITY_DELAY + CHURN_LIMIT_QUOTIENT // 2 (= 33,024) epochs
MIN_EPOCHS_FOR_BLOCK_REQUESTS: 33024
# 5s
TTFB_TIMEOUT: 5
# 10s
RESP_TIMEOUT: 10
# 2**5 (= 32) slots
ATTESTATION_PROPAGATION_SLOT_RANGE: 32
# 500ms
MAXIMUM_GOSSIP_CLOCK_DISPARITY: 500
MESSAGE_DOMAIN_INVALID_SNAPPY: 0x00000000
MESSAGE_DOMAIN_VALID_SNAPPY: 0x01000000
# 2 subnets per node
SUBNETS_PER_NODE: 2
# 2**8 (= 64)
# 2**6 (= 64) subnets
ATTESTATION_SUBNET_COUNT: 64
# 0 bits
ATTESTATION_SUBNET_EXTRA_BITS: 0
# ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS
# ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS (= 6 + 0) bits
ATTESTATION_SUBNET_PREFIX_BITS: 6
ATTESTATION_SUBNET_SHUFFLING_PREFIX_BITS: 3

# Deneb
# `2**7` (=128)
# 2**7 (= 128) blocks
MAX_REQUEST_BLOCKS_DENEB: 128
# MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK
MAX_REQUEST_BLOB_SIDECARS: 768
# `2**12` (= 4096 epochs, ~18 days)
# 2**12 (= 4,096) epochs
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: 4096
# `6`
# 6 subnets
BLOB_SIDECAR_SUBNET_COUNT: 6
# `uint64(6)`
# 6 blobs
MAX_BLOBS_PER_BLOCK: 6
# MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK (= 128 * 6) sidecars
MAX_REQUEST_BLOB_SIDECARS: 768

# Electra
# 2**7 * 10**9 (= 128,000,000,000)
MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA: 128000000000
# 2**8 * 10**9 (= 256,000,000,000)
MAX_PER_EPOCH_ACTIVATION_EXIT_CHURN_LIMIT: 256000000000
# `9`
# 9 subnets
BLOB_SIDECAR_SUBNET_COUNT_ELECTRA: 9
# `uint64(9)`
# 9 blobs
MAX_BLOBS_PER_BLOCK_ELECTRA: 9
# MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_ELECTRA
# MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_ELECTRA (= 128 * 9) sidecars
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: 1152

# Fulu
# 2**7 (= 128) groups
NUMBER_OF_CUSTODY_GROUPS: 128
# 2**7 (= 128) subnets
DATA_COLUMN_SIDECAR_SUBNET_COUNT: 128
# MAX_REQUEST_BLOCKS_DENEB * NUMBER_OF_COLUMNS (= 128 * 128) sidecars
MAX_REQUEST_DATA_COLUMN_SIDECARS: 16384
# 2**3 (= 8) samples
SAMPLES_PER_SLOT: 8
# 2**2 (= 4) sidecars
CUSTODY_REQUIREMENT: 4
# 2**3 (= 8) sidecars
VALIDATOR_CUSTODY_REQUIREMENT: 8
# 2**5 * 10**9 (= 32,000,000,000) Gwei
BALANCE_PER_ADDITIONAL_CUSTODY_GROUP: 32000000000
# 2**12 (= 4,096) epochs
MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS: 4096

# Gloas
# Blob Scheduling
# ---------------------------------------------------------------

BLOB_SCHEDULE:
- EPOCH: 412672 # December 9, 2025, 02:21:11pm UTC
MAX_BLOBS_PER_BLOCK: 15
- EPOCH: 419072 # January 7, 2026, 01:01:11am UTC
MAX_BLOBS_PER_BLOCK: 21

# Gloas
3 changes: 1 addition & 2 deletions consensus/types/presets/gnosis/electra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD: 16

# Withdrawals processing
# ---------------------------------------------------------------
# 2**3 ( = 8) pending withdrawals
MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP: 8
MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP: 6

# Pending deposits processing
# ---------------------------------------------------------------
Expand Down
34 changes: 30 additions & 4 deletions consensus/types/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,18 @@ pub struct ChainSpec {
*/
pub genesis_delay: u64,
pub seconds_per_slot: u64,
pub slot_duration_ms: u64,
pub min_attestation_inclusion_delay: u64,
pub min_seed_lookahead: Epoch,
pub max_seed_lookahead: Epoch,
pub min_epochs_to_inactivity_penalty: u64,
pub min_validator_withdrawability_delay: Epoch,
pub shard_committee_period: u64,
pub proposer_reorg_cutoff_bps: u64,
pub attestation_due_bps: u64,
pub aggregate_due_bps: u64,
pub sync_message_due_bps: u64,
pub contribution_due_bps: u64,

/*
* Reward and penalty quotients
Expand Down Expand Up @@ -964,12 +970,18 @@ impl ChainSpec {
*/
genesis_delay: 604800, // 7 days
seconds_per_slot: 12,
slot_duration_ms: 12000,
min_attestation_inclusion_delay: 1,
min_seed_lookahead: Epoch::new(1),
max_seed_lookahead: Epoch::new(4),
min_epochs_to_inactivity_penalty: 4,
min_validator_withdrawability_delay: Epoch::new(256),
shard_committee_period: 256,
proposer_reorg_cutoff_bps: 1667,
attestation_due_bps: 3333,
aggregate_due_bps: 6667,
sync_message_due_bps: 3333,
contribution_due_bps: 6667,

/*
* Reward and penalty quotients
Expand Down Expand Up @@ -1098,7 +1110,7 @@ impl ChainSpec {
* Fulu hard fork params
*/
fulu_fork_version: [0x06, 0x00, 0x00, 0x00],
fulu_fork_epoch: None,
fulu_fork_epoch: Some(Epoch::new(411392)),
custody_requirement: 4,
number_of_custody_groups: 128,
data_column_sidecar_subnet_count: 128,
Expand Down Expand Up @@ -1158,7 +1170,16 @@ impl ChainSpec {
/*
* Networking Fulu specific
*/
blob_schedule: BlobSchedule::default(),
blob_schedule: BlobSchedule::new(vec![
BlobParameters {
epoch: Epoch::new(412672),
max_blobs_per_block: 15,
},
BlobParameters {
epoch: Epoch::new(419072),
max_blobs_per_block: 21,
},
]),
min_epochs_for_data_column_sidecars_requests:
default_min_epochs_for_data_column_sidecars_requests(),
max_data_columns_by_root_request: default_data_columns_by_root_request(),
Expand Down Expand Up @@ -1310,12 +1331,18 @@ impl ChainSpec {
*/
genesis_delay: 6000, // 100 minutes
seconds_per_slot: 5,
slot_duration_ms: 5000,
min_attestation_inclusion_delay: 1,
min_seed_lookahead: Epoch::new(1),
max_seed_lookahead: Epoch::new(4),
min_epochs_to_inactivity_penalty: 4,
min_validator_withdrawability_delay: Epoch::new(256),
shard_committee_period: 256,
proposer_reorg_cutoff_bps: 1667,
attestation_due_bps: 3333,
aggregate_due_bps: 6667,
sync_message_due_bps: 3333,
contribution_due_bps: 6667,

/*
* Reward and penalty quotients
Expand Down Expand Up @@ -1429,8 +1456,7 @@ impl ChainSpec {
.expect("pow does not overflow"),
whistleblower_reward_quotient_electra: u64::checked_pow(2, 12)
.expect("pow does not overflow"),
max_pending_partials_per_withdrawals_sweep: u64::checked_pow(2, 3)
.expect("pow does not overflow"),
max_pending_partials_per_withdrawals_sweep: 6,
min_per_epoch_churn_limit_electra: option_wrapper(|| {
u64::checked_pow(2, 7)?.checked_mul(u64::checked_pow(10, 9)?)
})
Expand Down
Loading