mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 00:42:42 +00:00
Merge branch 'unstable' into dvt
This commit is contained in:
@@ -7,44 +7,44 @@ MIN_ACTIVATION_BALANCE: 32000000000
|
||||
# 2**11 * 10**9 (= 2,048,000,000,000) Gwei
|
||||
MAX_EFFECTIVE_BALANCE_ELECTRA: 2048000000000
|
||||
|
||||
# State list lengths
|
||||
# Rewards and penalties
|
||||
# ---------------------------------------------------------------
|
||||
# `uint64(2**27)` (= 134,217,728)
|
||||
PENDING_DEPOSITS_LIMIT: 134217728
|
||||
# `uint64(2**27)` (= 134,217,728)
|
||||
PENDING_PARTIAL_WITHDRAWALS_LIMIT: 134217728
|
||||
# `uint64(2**18)` (= 262,144)
|
||||
PENDING_CONSOLIDATIONS_LIMIT: 262144
|
||||
|
||||
# Reward and penalty quotients
|
||||
# ---------------------------------------------------------------
|
||||
# `uint64(2**12)` (= 4,096)
|
||||
# 2**12 (= 4,096)
|
||||
MIN_SLASHING_PENALTY_QUOTIENT_ELECTRA: 4096
|
||||
# `uint64(2**12)` (= 4,096)
|
||||
# 2**12 (= 4,096)
|
||||
WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA: 4096
|
||||
|
||||
# # Max operations per block
|
||||
# State list lengths
|
||||
# ---------------------------------------------------------------
|
||||
# `uint64(2**0)` (= 1)
|
||||
# 2**27 (= 134,217,728) pending deposits
|
||||
PENDING_DEPOSITS_LIMIT: 134217728
|
||||
# 2**27 (= 134,217,728) pending partial withdrawals
|
||||
PENDING_PARTIAL_WITHDRAWALS_LIMIT: 134217728
|
||||
# 2**18 (= 262,144) pending consolidations
|
||||
PENDING_CONSOLIDATIONS_LIMIT: 262144
|
||||
|
||||
# Max operations per block
|
||||
# ---------------------------------------------------------------
|
||||
# 2**0 (= 1) attester slashings
|
||||
MAX_ATTESTER_SLASHINGS_ELECTRA: 1
|
||||
# `uint64(2**3)` (= 8)
|
||||
# 2**3 (= 8) attestations
|
||||
MAX_ATTESTATIONS_ELECTRA: 8
|
||||
# `uint64(2**1)` (= 2)
|
||||
MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: 2
|
||||
|
||||
# Execution
|
||||
# ---------------------------------------------------------------
|
||||
# 2**13 (= 8192) deposit requests
|
||||
# 2**13 (= 8,192) deposit requests
|
||||
MAX_DEPOSIT_REQUESTS_PER_PAYLOAD: 8192
|
||||
# 2**4 (= 16) withdrawal requests
|
||||
MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD: 16
|
||||
# 2**1 (= 2) consolidation requests
|
||||
MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: 2
|
||||
|
||||
# Withdrawals processing
|
||||
# ---------------------------------------------------------------
|
||||
# 2**3 ( = 8) pending withdrawals
|
||||
# 2**3 (= 8) pending withdrawals
|
||||
MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP: 8
|
||||
|
||||
# Pending deposits processing
|
||||
# ---------------------------------------------------------------
|
||||
# 2**4 ( = 4) pending deposits
|
||||
# 2**4 (= 16) pending deposits
|
||||
MAX_PENDING_DEPOSITS_PER_EPOCH: 16
|
||||
|
||||
@@ -7,44 +7,44 @@ MIN_ACTIVATION_BALANCE: 32000000000
|
||||
# 2**11 * 10**9 (= 2,048,000,000,000) Gwei
|
||||
MAX_EFFECTIVE_BALANCE_ELECTRA: 2048000000000
|
||||
|
||||
# State list lengths
|
||||
# Rewards and penalties
|
||||
# ---------------------------------------------------------------
|
||||
# `uint64(2**27)` (= 134,217,728)
|
||||
PENDING_DEPOSITS_LIMIT: 134217728
|
||||
# [customized] `uint64(2**6)` (= 64)
|
||||
PENDING_PARTIAL_WITHDRAWALS_LIMIT: 64
|
||||
# [customized] `uint64(2**6)` (= 64)
|
||||
PENDING_CONSOLIDATIONS_LIMIT: 64
|
||||
|
||||
# Reward and penalty quotients
|
||||
# ---------------------------------------------------------------
|
||||
# `uint64(2**12)` (= 4,096)
|
||||
# 2**12 (= 4,096)
|
||||
MIN_SLASHING_PENALTY_QUOTIENT_ELECTRA: 4096
|
||||
# `uint64(2**12)` (= 4,096)
|
||||
# 2**12 (= 4,096)
|
||||
WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA: 4096
|
||||
|
||||
# # Max operations per block
|
||||
# State list lengths
|
||||
# ---------------------------------------------------------------
|
||||
# `uint64(2**0)` (= 1)
|
||||
# 2**27 (= 134,217,728) pending deposits
|
||||
PENDING_DEPOSITS_LIMIT: 134217728
|
||||
# [customized] 2**6 (= 64) pending partial withdrawals
|
||||
PENDING_PARTIAL_WITHDRAWALS_LIMIT: 64
|
||||
# [customized] 2**6 (= 64) pending consolidations
|
||||
PENDING_CONSOLIDATIONS_LIMIT: 64
|
||||
|
||||
# Max operations per block
|
||||
# ---------------------------------------------------------------
|
||||
# 2**0 (= 1) attester slashings
|
||||
MAX_ATTESTER_SLASHINGS_ELECTRA: 1
|
||||
# `uint64(2**3)` (= 8)
|
||||
# 2**3 (= 8) attestations
|
||||
MAX_ATTESTATIONS_ELECTRA: 8
|
||||
# `uint64(2**1)` (= 2)
|
||||
MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: 2
|
||||
|
||||
# Execution
|
||||
# ---------------------------------------------------------------
|
||||
# [customized]
|
||||
# [customized] 2**2 (= 4) deposit requests
|
||||
MAX_DEPOSIT_REQUESTS_PER_PAYLOAD: 4
|
||||
# [customized] 2**1 (= 2) withdrawal requests
|
||||
MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD: 2
|
||||
# 2**1 (= 2) consolidation requests
|
||||
MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: 2
|
||||
|
||||
# Withdrawals processing
|
||||
# ---------------------------------------------------------------
|
||||
# 2**1 ( = 2) pending withdrawals
|
||||
# 2**1 (= 2) pending withdrawals
|
||||
MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP: 2
|
||||
|
||||
# Pending deposits processing
|
||||
# ---------------------------------------------------------------
|
||||
# 2**4 ( = 4) pending deposits
|
||||
# 2**4 (= 16) pending deposits
|
||||
MAX_PENDING_DEPOSITS_PER_EPOCH: 16
|
||||
|
||||
@@ -5,6 +5,7 @@ use derivative::Derivative;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use ssz_types::BitVector;
|
||||
use std::collections::HashSet;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use superstruct::superstruct;
|
||||
use test_random_derive::TestRandom;
|
||||
@@ -210,6 +211,13 @@ impl<E: EthSpec> Attestation<E> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_committee_indices_map(&self) -> HashSet<u64> {
|
||||
match self {
|
||||
Attestation::Base(att) => HashSet::from([att.data.index]),
|
||||
Attestation::Electra(att) => att.get_committee_indices().into_iter().collect(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_aggregation_bits_zero(&self) -> bool {
|
||||
match self {
|
||||
Attestation::Base(att) => att.aggregation_bits.is_zero(),
|
||||
@@ -293,7 +301,11 @@ impl<E: EthSpec> AttestationRef<'_, E> {
|
||||
|
||||
impl<E: EthSpec> AttestationElectra<E> {
|
||||
pub fn committee_index(&self) -> Option<u64> {
|
||||
self.get_committee_indices().first().cloned()
|
||||
self.committee_bits
|
||||
.iter()
|
||||
.enumerate()
|
||||
.find(|&(_, bit)| bit)
|
||||
.map(|(index, _)| index as u64)
|
||||
}
|
||||
|
||||
pub fn get_aggregation_bits(&self) -> Vec<u64> {
|
||||
|
||||
@@ -210,10 +210,9 @@ pub struct ChainSpec {
|
||||
pub boot_nodes: Vec<String>,
|
||||
pub network_id: u8,
|
||||
pub target_aggregators_per_committee: u64,
|
||||
pub gossip_max_size: u64,
|
||||
pub max_payload_size: u64,
|
||||
max_request_blocks: u64,
|
||||
pub min_epochs_for_block_requests: u64,
|
||||
pub max_chunk_size: u64,
|
||||
pub ttfb_timeout: u64,
|
||||
pub resp_timeout: u64,
|
||||
pub attestation_propagation_slot_range: u64,
|
||||
@@ -241,6 +240,11 @@ pub struct ChainSpec {
|
||||
blob_sidecar_subnet_count_electra: u64,
|
||||
max_request_blob_sidecars_electra: u64,
|
||||
|
||||
/*
|
||||
* Networking Fulu
|
||||
*/
|
||||
max_blobs_per_block_fulu: u64,
|
||||
|
||||
/*
|
||||
* Networking Derived
|
||||
*
|
||||
@@ -656,7 +660,9 @@ impl ChainSpec {
|
||||
|
||||
/// Return the value of `MAX_BLOBS_PER_BLOCK` appropriate for `fork`.
|
||||
pub fn max_blobs_per_block_by_fork(&self, fork_name: ForkName) -> u64 {
|
||||
if fork_name.electra_enabled() {
|
||||
if fork_name.fulu_enabled() {
|
||||
self.max_blobs_per_block_fulu
|
||||
} else if fork_name.electra_enabled() {
|
||||
self.max_blobs_per_block_electra
|
||||
} else {
|
||||
self.max_blobs_per_block
|
||||
@@ -716,6 +722,35 @@ impl ChainSpec {
|
||||
(0..self.data_column_sidecar_subnet_count).map(DataColumnSubnetId::new)
|
||||
}
|
||||
|
||||
/// Worst-case compressed length for a given payload of size n when using snappy.
|
||||
///
|
||||
/// https://github.com/google/snappy/blob/32ded457c0b1fe78ceb8397632c416568d6714a0/snappy.cc#L218C1-L218C47
|
||||
/// https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/p2p-interface.md#max_compressed_len
|
||||
fn max_compressed_len_snappy(n: usize) -> Option<usize> {
|
||||
32_usize.checked_add(n)?.checked_add(n / 6)
|
||||
}
|
||||
|
||||
/// Max compressed length of a message that we receive over gossip.
|
||||
pub fn max_compressed_len(&self) -> usize {
|
||||
Self::max_compressed_len_snappy(self.max_payload_size as usize)
|
||||
.expect("should not overflow")
|
||||
}
|
||||
|
||||
/// Max allowed size of a raw, compressed message received over the network.
|
||||
///
|
||||
/// https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/p2p-interface.md#max_compressed_len
|
||||
pub fn max_message_size(&self) -> usize {
|
||||
std::cmp::max(
|
||||
// 1024 to account for framing + encoding overhead
|
||||
Self::max_compressed_len_snappy(self.max_payload_size as usize)
|
||||
.expect("should not overflow")
|
||||
.safe_add(1024)
|
||||
.expect("should not overflow"),
|
||||
//1MB
|
||||
1024 * 1024,
|
||||
)
|
||||
}
|
||||
|
||||
/// Returns a `ChainSpec` compatible with the Ethereum Foundation specification.
|
||||
pub fn mainnet() -> Self {
|
||||
Self {
|
||||
@@ -883,7 +918,7 @@ impl ChainSpec {
|
||||
* Electra hard fork params
|
||||
*/
|
||||
electra_fork_version: [0x05, 00, 00, 00],
|
||||
electra_fork_epoch: None,
|
||||
electra_fork_epoch: Some(Epoch::new(364032)),
|
||||
unset_deposit_requests_start_index: u64::MAX,
|
||||
full_exit_request_amount: 0,
|
||||
min_activation_balance: option_wrapper(|| {
|
||||
@@ -930,9 +965,8 @@ impl ChainSpec {
|
||||
subnets_per_node: 2,
|
||||
maximum_gossip_clock_disparity_millis: default_maximum_gossip_clock_disparity_millis(),
|
||||
target_aggregators_per_committee: 16,
|
||||
gossip_max_size: default_gossip_max_size(),
|
||||
max_payload_size: default_max_payload_size(),
|
||||
min_epochs_for_block_requests: default_min_epochs_for_block_requests(),
|
||||
max_chunk_size: default_max_chunk_size(),
|
||||
ttfb_timeout: default_ttfb_timeout(),
|
||||
resp_timeout: default_resp_timeout(),
|
||||
message_domain_invalid_snappy: default_message_domain_invalid_snappy(),
|
||||
@@ -965,6 +999,11 @@ impl ChainSpec {
|
||||
blob_sidecar_subnet_count_electra: default_blob_sidecar_subnet_count_electra(),
|
||||
max_request_blob_sidecars_electra: default_max_request_blob_sidecars_electra(),
|
||||
|
||||
/*
|
||||
* Networking Fulu specific
|
||||
*/
|
||||
max_blobs_per_block_fulu: default_max_blobs_per_block_fulu(),
|
||||
|
||||
/*
|
||||
* Application specific
|
||||
*/
|
||||
@@ -1213,7 +1252,7 @@ impl ChainSpec {
|
||||
* Electra hard fork params
|
||||
*/
|
||||
electra_fork_version: [0x05, 0x00, 0x00, 0x64],
|
||||
electra_fork_epoch: None,
|
||||
electra_fork_epoch: Some(Epoch::new(1337856)),
|
||||
unset_deposit_requests_start_index: u64::MAX,
|
||||
full_exit_request_amount: 0,
|
||||
min_activation_balance: option_wrapper(|| {
|
||||
@@ -1235,7 +1274,7 @@ impl ChainSpec {
|
||||
})
|
||||
.expect("calculation does not overflow"),
|
||||
max_per_epoch_activation_exit_churn_limit: option_wrapper(|| {
|
||||
u64::checked_pow(2, 8)?.checked_mul(u64::checked_pow(10, 9)?)
|
||||
u64::checked_pow(2, 6)?.checked_mul(u64::checked_pow(10, 9)?)
|
||||
})
|
||||
.expect("calculation does not overflow"),
|
||||
|
||||
@@ -1260,9 +1299,8 @@ impl ChainSpec {
|
||||
subnets_per_node: 4, // Make this larger than usual to avoid network damage
|
||||
maximum_gossip_clock_disparity_millis: default_maximum_gossip_clock_disparity_millis(),
|
||||
target_aggregators_per_committee: 16,
|
||||
gossip_max_size: default_gossip_max_size(),
|
||||
max_payload_size: default_max_payload_size(),
|
||||
min_epochs_for_block_requests: 33024,
|
||||
max_chunk_size: default_max_chunk_size(),
|
||||
ttfb_timeout: default_ttfb_timeout(),
|
||||
resp_timeout: default_resp_timeout(),
|
||||
message_domain_invalid_snappy: default_message_domain_invalid_snappy(),
|
||||
@@ -1278,7 +1316,7 @@ impl ChainSpec {
|
||||
max_request_data_column_sidecars: default_max_request_data_column_sidecars(),
|
||||
min_epochs_for_blob_sidecars_requests: 16384,
|
||||
blob_sidecar_subnet_count: default_blob_sidecar_subnet_count(),
|
||||
max_blobs_per_block: default_max_blobs_per_block(),
|
||||
max_blobs_per_block: 2,
|
||||
|
||||
/*
|
||||
* Derived Deneb Specific
|
||||
@@ -1291,9 +1329,14 @@ impl ChainSpec {
|
||||
/*
|
||||
* Networking Electra specific
|
||||
*/
|
||||
max_blobs_per_block_electra: default_max_blobs_per_block_electra(),
|
||||
blob_sidecar_subnet_count_electra: default_blob_sidecar_subnet_count_electra(),
|
||||
max_request_blob_sidecars_electra: default_max_request_blob_sidecars_electra(),
|
||||
max_blobs_per_block_electra: 2,
|
||||
blob_sidecar_subnet_count_electra: 2,
|
||||
max_request_blob_sidecars_electra: 256,
|
||||
|
||||
/*
|
||||
* Networking Fulu specific
|
||||
*/
|
||||
max_blobs_per_block_fulu: default_max_blobs_per_block_fulu(),
|
||||
|
||||
/*
|
||||
* Application specific
|
||||
@@ -1434,18 +1477,15 @@ pub struct Config {
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
gas_limit_adjustment_factor: u64,
|
||||
|
||||
#[serde(default = "default_gossip_max_size")]
|
||||
#[serde(default = "default_max_payload_size")]
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
gossip_max_size: u64,
|
||||
max_payload_size: u64,
|
||||
#[serde(default = "default_max_request_blocks")]
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
max_request_blocks: u64,
|
||||
#[serde(default = "default_min_epochs_for_block_requests")]
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
min_epochs_for_block_requests: u64,
|
||||
#[serde(default = "default_max_chunk_size")]
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
max_chunk_size: u64,
|
||||
#[serde(default = "default_ttfb_timeout")]
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
ttfb_timeout: u64,
|
||||
@@ -1517,6 +1557,9 @@ pub struct Config {
|
||||
#[serde(default = "default_custody_requirement")]
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
custody_requirement: u64,
|
||||
#[serde(default = "default_max_blobs_per_block_fulu")]
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
max_blobs_per_block_fulu: u64,
|
||||
}
|
||||
|
||||
fn default_bellatrix_fork_version() -> [u8; 4] {
|
||||
@@ -1580,7 +1623,7 @@ const fn default_gas_limit_adjustment_factor() -> u64 {
|
||||
1024
|
||||
}
|
||||
|
||||
const fn default_gossip_max_size() -> u64 {
|
||||
const fn default_max_payload_size() -> u64 {
|
||||
10485760
|
||||
}
|
||||
|
||||
@@ -1588,10 +1631,6 @@ const fn default_min_epochs_for_block_requests() -> u64 {
|
||||
33024
|
||||
}
|
||||
|
||||
const fn default_max_chunk_size() -> u64 {
|
||||
10485760
|
||||
}
|
||||
|
||||
const fn default_ttfb_timeout() -> u64 {
|
||||
5
|
||||
}
|
||||
@@ -1658,6 +1697,10 @@ const fn default_max_blobs_per_block_electra() -> u64 {
|
||||
9
|
||||
}
|
||||
|
||||
const fn default_max_blobs_per_block_fulu() -> u64 {
|
||||
12
|
||||
}
|
||||
|
||||
const fn default_attestation_propagation_slot_range() -> u64 {
|
||||
32
|
||||
}
|
||||
@@ -1857,10 +1900,9 @@ impl Config {
|
||||
|
||||
gas_limit_adjustment_factor: spec.gas_limit_adjustment_factor,
|
||||
|
||||
gossip_max_size: spec.gossip_max_size,
|
||||
max_payload_size: spec.max_payload_size,
|
||||
max_request_blocks: spec.max_request_blocks,
|
||||
min_epochs_for_block_requests: spec.min_epochs_for_block_requests,
|
||||
max_chunk_size: spec.max_chunk_size,
|
||||
ttfb_timeout: spec.ttfb_timeout,
|
||||
resp_timeout: spec.resp_timeout,
|
||||
attestation_propagation_slot_range: spec.attestation_propagation_slot_range,
|
||||
@@ -1886,6 +1928,7 @@ impl Config {
|
||||
data_column_sidecar_subnet_count: spec.data_column_sidecar_subnet_count,
|
||||
samples_per_slot: spec.samples_per_slot,
|
||||
custody_requirement: spec.custody_requirement,
|
||||
max_blobs_per_block_fulu: spec.max_blobs_per_block_fulu,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1938,9 +1981,8 @@ impl Config {
|
||||
deposit_network_id,
|
||||
deposit_contract_address,
|
||||
gas_limit_adjustment_factor,
|
||||
gossip_max_size,
|
||||
max_payload_size,
|
||||
min_epochs_for_block_requests,
|
||||
max_chunk_size,
|
||||
ttfb_timeout,
|
||||
resp_timeout,
|
||||
message_domain_invalid_snappy,
|
||||
@@ -1965,6 +2007,7 @@ impl Config {
|
||||
data_column_sidecar_subnet_count,
|
||||
samples_per_slot,
|
||||
custody_requirement,
|
||||
max_blobs_per_block_fulu,
|
||||
} = self;
|
||||
|
||||
if preset_base != E::spec_name().to_string().as_str() {
|
||||
@@ -2009,9 +2052,8 @@ impl Config {
|
||||
terminal_total_difficulty,
|
||||
terminal_block_hash,
|
||||
terminal_block_hash_activation_epoch,
|
||||
gossip_max_size,
|
||||
max_payload_size,
|
||||
min_epochs_for_block_requests,
|
||||
max_chunk_size,
|
||||
ttfb_timeout,
|
||||
resp_timeout,
|
||||
message_domain_invalid_snappy,
|
||||
@@ -2048,6 +2090,7 @@ impl Config {
|
||||
data_column_sidecar_subnet_count,
|
||||
samples_per_slot,
|
||||
custody_requirement,
|
||||
max_blobs_per_block_fulu,
|
||||
|
||||
..chain_spec.clone()
|
||||
})
|
||||
@@ -2311,9 +2354,8 @@ mod yaml_tests {
|
||||
check_default!(terminal_block_hash);
|
||||
check_default!(terminal_block_hash_activation_epoch);
|
||||
check_default!(bellatrix_fork_version);
|
||||
check_default!(gossip_max_size);
|
||||
check_default!(max_payload_size);
|
||||
check_default!(min_epochs_for_block_requests);
|
||||
check_default!(max_chunk_size);
|
||||
check_default!(ttfb_timeout);
|
||||
check_default!(resp_timeout);
|
||||
check_default!(message_domain_invalid_snappy);
|
||||
@@ -2339,4 +2381,17 @@ mod yaml_tests {
|
||||
[0, 0, 0, 1]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_max_network_limits_overflow() {
|
||||
let mut spec = MainnetEthSpec::default_spec();
|
||||
// Should not overflow
|
||||
let _ = spec.max_message_size();
|
||||
let _ = spec.max_compressed_len();
|
||||
|
||||
spec.max_payload_size *= 10;
|
||||
// Should not overflow even with a 10x increase in max
|
||||
let _ = spec.max_message_size();
|
||||
let _ = spec.max_compressed_len();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::beacon_block_body::{KzgCommitments, BLOB_KZG_COMMITMENTS_INDEX};
|
||||
use crate::test_utils::TestRandom;
|
||||
use crate::BeaconStateError;
|
||||
use crate::{BeaconBlockHeader, Epoch, EthSpec, Hash256, KzgProofs, SignedBeaconBlockHeader, Slot};
|
||||
use crate::{BeaconBlockHeader, Epoch, EthSpec, Hash256, SignedBeaconBlockHeader, Slot};
|
||||
use bls::Signature;
|
||||
use derivative::Derivative;
|
||||
use kzg::Error as KzgError;
|
||||
@@ -56,7 +56,7 @@ pub struct DataColumnSidecar<E: EthSpec> {
|
||||
pub column: DataColumn<E>,
|
||||
/// All the KZG commitments and proofs associated with the block, used for verifying sample cells.
|
||||
pub kzg_commitments: KzgCommitments<E>,
|
||||
pub kzg_proofs: KzgProofs<E>,
|
||||
pub kzg_proofs: VariableList<KzgProof, E::MaxBlobCommitmentsPerBlock>,
|
||||
pub signed_block_header: SignedBeaconBlockHeader,
|
||||
/// An inclusion proof, proving the inclusion of `blob_kzg_commitments` in `BeaconBlockBody`.
|
||||
pub kzg_commitments_inclusion_proof: FixedVector<Hash256, E::KzgCommitmentsInclusionProofDepth>,
|
||||
|
||||
@@ -4,8 +4,8 @@ use safe_arith::SafeArith;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use ssz_types::typenum::{
|
||||
bit::B0, UInt, U0, U1, U10, U1024, U1048576, U1073741824, U1099511627776, U128, U131072,
|
||||
U134217728, U16, U16777216, U17, U2, U2048, U256, U262144, U32, U4, U4096, U512, U625, U64,
|
||||
U65536, U8, U8192,
|
||||
U134217728, U16, U16777216, U17, U2, U2048, U256, U262144, U32, U33554432, U4, U4096, U512,
|
||||
U625, U64, U65536, U8, U8192,
|
||||
};
|
||||
use std::fmt::{self, Debug};
|
||||
use std::str::FromStr;
|
||||
@@ -146,6 +146,11 @@ pub trait EthSpec:
|
||||
/// Must be set to `BytesPerFieldElement * FieldElementsPerCell`.
|
||||
type BytesPerCell: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
||||
|
||||
/// The maximum number of cell commitments per block
|
||||
///
|
||||
/// FieldElementsPerExtBlob * MaxBlobCommitmentsPerBlock
|
||||
type MaxCellsPerBlock: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
||||
|
||||
/*
|
||||
* New in Electra
|
||||
*/
|
||||
@@ -421,6 +426,7 @@ impl EthSpec for MainnetEthSpec {
|
||||
type FieldElementsPerExtBlob = U8192;
|
||||
type BytesPerBlob = U131072;
|
||||
type BytesPerCell = U2048;
|
||||
type MaxCellsPerBlock = U33554432;
|
||||
type KzgCommitmentInclusionProofDepth = U17;
|
||||
type KzgCommitmentsInclusionProofDepth = U4; // inclusion of the whole list of commitments
|
||||
type SyncSubcommitteeSize = U128; // 512 committee size / 4 sync committee subnet count
|
||||
@@ -474,6 +480,7 @@ impl EthSpec for MinimalEthSpec {
|
||||
type MaxWithdrawalRequestsPerPayload = U2;
|
||||
type FieldElementsPerCell = U64;
|
||||
type FieldElementsPerExtBlob = U8192;
|
||||
type MaxCellsPerBlock = U33554432;
|
||||
type BytesPerCell = U2048;
|
||||
type KzgCommitmentsInclusionProofDepth = U4;
|
||||
|
||||
@@ -566,6 +573,7 @@ impl EthSpec for GnosisEthSpec {
|
||||
type MaxPendingDepositsPerEpoch = U16;
|
||||
type FieldElementsPerCell = U64;
|
||||
type FieldElementsPerExtBlob = U8192;
|
||||
type MaxCellsPerBlock = U33554432;
|
||||
type BytesPerCell = U2048;
|
||||
type KzgCommitmentsInclusionProofDepth = U4;
|
||||
|
||||
|
||||
@@ -272,7 +272,14 @@ pub type Address = fixed_bytes::Address;
|
||||
pub type ForkVersion = [u8; 4];
|
||||
pub type BLSFieldElement = Uint256;
|
||||
pub type Blob<E> = FixedVector<u8, <E as EthSpec>::BytesPerBlob>;
|
||||
pub type KzgProofs<E> = VariableList<KzgProof, <E as EthSpec>::MaxBlobCommitmentsPerBlock>;
|
||||
// Note on List limit:
|
||||
// - Deneb to Electra: `MaxBlobCommitmentsPerBlock`
|
||||
// - Fulu: `MaxCellsPerBlock`
|
||||
// We choose to use a single type (with the larger value from Fulu as `N`) instead of having to
|
||||
// introduce a new type for Fulu. This is to avoid messy conversions and having to add extra types
|
||||
// with no gains - as `N` does not impact serialisation at all, and only affects merkleization,
|
||||
// which we don't current do on `KzgProofs` anyway.
|
||||
pub type KzgProofs<E> = VariableList<KzgProof, <E as EthSpec>::MaxCellsPerBlock>;
|
||||
pub type VersionedHash = Hash256;
|
||||
pub type Hash64 = alloy_primitives::B64;
|
||||
|
||||
|
||||
@@ -227,28 +227,36 @@ pub struct ElectraPreset {
|
||||
pub min_activation_balance: u64,
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
pub max_effective_balance_electra: u64,
|
||||
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
pub min_slashing_penalty_quotient_electra: u64,
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
pub whistleblower_reward_quotient_electra: u64,
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
pub max_pending_partials_per_withdrawals_sweep: u64,
|
||||
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
pub pending_deposits_limit: u64,
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
pub pending_partial_withdrawals_limit: u64,
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
pub pending_consolidations_limit: u64,
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
pub max_consolidation_requests_per_payload: u64,
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
pub max_deposit_requests_per_payload: u64,
|
||||
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
pub max_attester_slashings_electra: u64,
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
pub max_attestations_electra: u64,
|
||||
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
pub max_deposit_requests_per_payload: u64,
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
pub max_withdrawal_requests_per_payload: u64,
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
pub max_consolidation_requests_per_payload: u64,
|
||||
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
pub max_pending_partials_per_withdrawals_sweep: u64,
|
||||
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
pub max_pending_deposits_per_epoch: u64,
|
||||
}
|
||||
|
||||
impl ElectraPreset {
|
||||
@@ -256,19 +264,26 @@ impl ElectraPreset {
|
||||
Self {
|
||||
min_activation_balance: spec.min_activation_balance,
|
||||
max_effective_balance_electra: spec.max_effective_balance_electra,
|
||||
|
||||
min_slashing_penalty_quotient_electra: spec.min_slashing_penalty_quotient_electra,
|
||||
whistleblower_reward_quotient_electra: spec.whistleblower_reward_quotient_electra,
|
||||
max_pending_partials_per_withdrawals_sweep: spec
|
||||
.max_pending_partials_per_withdrawals_sweep,
|
||||
|
||||
pending_deposits_limit: E::pending_deposits_limit() as u64,
|
||||
pending_partial_withdrawals_limit: E::pending_partial_withdrawals_limit() as u64,
|
||||
pending_consolidations_limit: E::pending_consolidations_limit() as u64,
|
||||
max_consolidation_requests_per_payload: E::max_consolidation_requests_per_payload()
|
||||
as u64,
|
||||
max_deposit_requests_per_payload: E::max_deposit_requests_per_payload() as u64,
|
||||
|
||||
max_attester_slashings_electra: E::max_attester_slashings_electra() as u64,
|
||||
max_attestations_electra: E::max_attestations_electra() as u64,
|
||||
|
||||
max_deposit_requests_per_payload: E::max_deposit_requests_per_payload() as u64,
|
||||
max_withdrawal_requests_per_payload: E::max_withdrawal_requests_per_payload() as u64,
|
||||
max_consolidation_requests_per_payload: E::max_consolidation_requests_per_payload()
|
||||
as u64,
|
||||
|
||||
max_pending_partials_per_withdrawals_sweep: spec
|
||||
.max_pending_partials_per_withdrawals_sweep,
|
||||
|
||||
max_pending_deposits_per_epoch: E::max_pending_deposits_per_epoch() as u64,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ impl<E: EthSpec> SyncCommitteeContribution<E> {
|
||||
///
|
||||
/// - `message`: A single `SyncCommitteeMessage`.
|
||||
/// - `subcommittee_index`: The subcommittee this contribution pertains to out of the broader
|
||||
/// sync committee. This can be determined from the `SyncSubnetId` of the gossip subnet
|
||||
/// this message was seen on.
|
||||
/// sync committee. This can be determined from the `SyncSubnetId` of the gossip subnet
|
||||
/// this message was seen on.
|
||||
/// - `validator_sync_committee_index`: The index of the validator **within** the subcommittee.
|
||||
pub fn from_message(
|
||||
message: &SyncCommitteeMessage,
|
||||
|
||||
@@ -3,7 +3,7 @@ use smallvec::smallvec;
|
||||
|
||||
impl<N: Unsigned + Clone> TestRandom for BitList<N> {
|
||||
fn random_for_test(rng: &mut impl RngCore) -> Self {
|
||||
let initial_len = std::cmp::max(1, (N::to_usize() + 7) / 8);
|
||||
let initial_len = std::cmp::max(1, N::to_usize().div_ceil(8));
|
||||
let mut raw_bytes = smallvec![0; initial_len];
|
||||
rng.fill_bytes(&mut raw_bytes);
|
||||
|
||||
@@ -24,7 +24,7 @@ impl<N: Unsigned + Clone> TestRandom for BitList<N> {
|
||||
|
||||
impl<N: Unsigned + Clone> TestRandom for BitVector<N> {
|
||||
fn random_for_test(rng: &mut impl RngCore) -> Self {
|
||||
let mut raw_bytes = smallvec![0; std::cmp::max(1, (N::to_usize() + 7) / 8)];
|
||||
let mut raw_bytes = smallvec![0; std::cmp::max(1, N::to_usize().div_ceil(8))];
|
||||
rng.fill_bytes(&mut raw_bytes);
|
||||
// If N isn't divisible by 8
|
||||
// zero out bits greater than N
|
||||
|
||||
@@ -249,7 +249,6 @@ impl Validator {
|
||||
}
|
||||
}
|
||||
|
||||
/// TODO(electra): refactor these functions and make it simpler.. this is a mess
|
||||
/// Returns `true` if the validator is partially withdrawable.
|
||||
fn is_partially_withdrawable_validator_capella(&self, balance: u64, spec: &ChainSpec) -> bool {
|
||||
self.has_eth1_withdrawal_credential(spec)
|
||||
|
||||
Reference in New Issue
Block a user