Skip to content

Commit

Permalink
Upgrade consensus-spec-tests to v1.5.0-beta.2
Browse files Browse the repository at this point in the history
- Update`eth2_libp2p` & move blob count validations of received requests to `eth2_libp2p`
- Add `POST /eth/v2/beacon/pool/attestations` endpoint

Co-authored-by: Povilas Liubauskas <povilas@grandine.io>
  • Loading branch information
Tumas and povi committed Feb 12, 2025
1 parent ef2a76a commit 45d22e4
Show file tree
Hide file tree
Showing 32 changed files with 905 additions and 617 deletions.
663 changes: 429 additions & 234 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,8 @@ jwt-simple = { version = '0.12', default-features = false, features = ['pure-rus
kzg = { git = 'https://github.com/grandinetech/rust-kzg.git' }
lazy_static = '1'
libmdbx = { git = 'https://github.com/paradigmxyz/reth.git', package = 'reth-libmdbx', rev = 'c228fe15808c3acbf18dc3af1a03ef5cbdcda07a' }
libp2p = { version = '0.54', default-features = false, features = ['metrics', 'dns', 'ecdsa', 'identify', 'macros', 'noise', 'plaintext', 'secp256k1', 'serde', 'tcp', 'tokio', 'yamux', 'quic', 'upnp'] }
libp2p-mplex = '0.42'
libp2p = { version = '0.55', default-features = false, features = ['metrics', 'dns', 'ecdsa', 'identify', 'macros', 'noise', 'plaintext', 'secp256k1', 'serde', 'tcp', 'tokio', 'yamux', 'quic', 'upnp'] }
libp2p-mplex = '0.43'
log = '0.4'
lru = '0.12'
mediatype = '0.19'
Expand Down
19 changes: 14 additions & 5 deletions block_producer/src/block_producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,11 +456,20 @@ impl<P: Preset, W: Wait> BlockProducer<P, W> {
.controller
.preprocessed_state_at_current_slot()?;

let outcome = match unphased::validate_voluntary_exit(
&self.producer_context.chain_config,
&state,
exit,
) {
let result = match state.as_ref() {
BeaconState::Phase0(_)
| BeaconState::Altair(_)
| BeaconState::Bellatrix(_)
| BeaconState::Capella(_)
| BeaconState::Deneb(_) => {
unphased::validate_voluntary_exit(&self.producer_context.chain_config, &state, exit)
}
BeaconState::Electra(state) => {
electra::validate_voluntary_exit(&self.producer_context.chain_config, state, exit)
}
};

let outcome = match result {
Ok(()) => {
voluntary_exits.push(exit);
PoolAdditionOutcome::Accept
Expand Down
8 changes: 7 additions & 1 deletion block_producer/src/eth1_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,16 @@ pub trait Eth1Storage {
&self,
config: &Config,
metrics: Option<&Arc<Metrics>>,
state_at_slot: &impl BeaconState<P>,
state_at_slot: &CombinedBeaconState<P>,
) -> Result<Eth1Data> {
let _timer = metrics.map(|metrics| metrics.eth1_vote_times.start_timer());

if let Some(state) = state_at_slot.post_electra() {
if state.eth1_deposit_index() == state.deposit_requests_start_index() {
return Ok(state.eth1_data());
}
}

let eth1_data = state_at_slot.eth1_data();
let period_start = voting_period_start_time(config, state_at_slot);

Expand Down
2 changes: 1 addition & 1 deletion consensus-spec-tests
4 changes: 2 additions & 2 deletions eip_7594/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ mod tests {

#[duplicate_item(
glob function_name preset;
["consensus-spec-tests/tests/mainnet/fulu/networking/get_custody_columns/*/*"] [get_custody_groups_mainnet] [Mainnet];
["consensus-spec-tests/tests/minimal/fulu/networking/get_custody_columns/*/*"] [get_custody_groups_minimal] [Minimal];
["consensus-spec-tests/tests/mainnet/fulu/networking/get_custody_groups/*/*"] [get_custody_groups_mainnet] [Mainnet];
["consensus-spec-tests/tests/minimal/fulu/networking/get_custody_groups/*/*"] [get_custody_groups_minimal] [Minimal];
)]
#[test_resources(glob)]
fn function_name(case: Case) {
Expand Down
3 changes: 1 addition & 2 deletions fork_choice_control/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,7 @@ impl<P: Preset> Context<P> {
}

pub fn on_blob_sidecar(&mut self, blob_sidecar: BlobSidecar<P>) -> Option<P2pMessage<P>> {
let subnet_id = misc::compute_subnet_for_blob_sidecar(self.config(), &blob_sidecar)
.expect("cannot compute subnet_id for given blob_sidecar");
let subnet_id = misc::compute_subnet_for_blob_sidecar(self.config(), &blob_sidecar);

self.controller().on_gossip_blob_sidecar(
Arc::new(blob_sidecar),
Expand Down
3 changes: 2 additions & 1 deletion fork_choice_control/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ pub enum MutatorMessage<P: Preset, W> {
wait_group: W,
result: Result<BlobSidecarAction<P>>,
origin: BlobSidecarOrigin,
blob_identifier: BlobIdentifier,
block_seen: bool,
submission_time: Instant,
},
Expand Down Expand Up @@ -170,7 +171,7 @@ pub enum P2pMessage<P: Preset> {
Accept(GossipId),
Ignore(GossipId),
PublishBlobSidecar(Arc<BlobSidecar<P>>),
Reject(GossipId, MutatorRejectionReason),
Reject(Option<GossipId>, MutatorRejectionReason),
BlockNeeded(H256, Option<PeerId>),
BlobsNeeded(Vec<BlobIdentifier>, Slot, Option<PeerId>),
FinalizedCheckpoint(Checkpoint),
Expand Down
7 changes: 5 additions & 2 deletions fork_choice_control/src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use serde::Serialize;
use strum::IntoStaticStr;
use types::{
combined::{SignedAggregateAndProof, SignedBeaconBlock},
deneb::containers::BlobSidecar,
deneb::containers::{BlobIdentifier, BlobSidecar},
phase0::primitives::ValidatorIndex,
preset::Preset,
};
Expand Down Expand Up @@ -118,7 +118,10 @@ pub enum MutatorRejectionReason {
InvalidAggregateAndProof,
InvalidAttestation,
InvalidBlock,
InvalidBlobSidecar,
#[strum(serialize = "invalid_blob_sidecar")]
InvalidBlobSidecar {
blob_identifier: BlobIdentifier,
},
}

#[derive(Clone, Copy, Debug)]
Expand Down
26 changes: 15 additions & 11 deletions fork_choice_control/src/mutator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,16 @@ where
MutatorMessage::BlobSidecar {
wait_group,
result,
block_seen,
origin,
blob_identifier,
block_seen,
submission_time,
} => self.handle_blob_sidecar(
wait_group,
result,
block_seen,
origin,
blob_identifier,
block_seen,
submission_time,
),
MutatorMessage::CheckpointState {
Expand Down Expand Up @@ -645,7 +647,7 @@ where

let (gossip_id, sender) = origin.split();

if let Some(gossip_id) = gossip_id {
if gossip_id.is_some() {
P2pMessage::Reject(gossip_id, MutatorRejectionReason::InvalidBlock)
.send(&self.p2p_tx);
}
Expand Down Expand Up @@ -798,7 +800,7 @@ where

let (gossip_id, sender) = origin.split();

if let Some(gossip_id) = gossip_id {
if gossip_id.is_some() {
P2pMessage::Reject(gossip_id, MutatorRejectionReason::InvalidAggregateAndProof)
.send(&self.p2p_tx);
}
Expand Down Expand Up @@ -943,7 +945,7 @@ where
let attestation = error.attestation();
let (gossip_id, sender) = attestation.origin.split();

if let Some(gossip_id) = gossip_id {
if gossip_id.is_some() {
P2pMessage::Reject(gossip_id, MutatorRejectionReason::InvalidAttestation)
.send(&self.p2p_tx);
}
Expand Down Expand Up @@ -1065,8 +1067,9 @@ where
&mut self,
wait_group: W,
result: Result<BlobSidecarAction<P>>,
block_seen: bool,
origin: BlobSidecarOrigin,
blob_identifier: BlobIdentifier,
block_seen: bool,
submission_time: Instant,
) {
match result {
Expand Down Expand Up @@ -1149,10 +1152,11 @@ where

let (gossip_id, sender) = origin.split();

if let Some(gossip_id) = gossip_id {
P2pMessage::Reject(gossip_id, MutatorRejectionReason::InvalidBlobSidecar)
.send(&self.p2p_tx);
}
P2pMessage::Reject(
gossip_id,
MutatorRejectionReason::InvalidBlobSidecar { blob_identifier },
)
.send(&self.p2p_tx);

reply_to_http_api(sender, Err(error));
}
Expand Down Expand Up @@ -1454,7 +1458,7 @@ where
let unfinalized_states_in_memory = self.store.store_config().unfinalized_states_in_memory;
let head_slot = self.store.head().slot();

if misc::is_epoch_start::<P>(head_slot) {
if misc::is_epoch_start::<P>(block.message().slot()) {
info!("unloading old beacon states (head slot: {head_slot})");

self.store_mut()
Expand Down
Loading

0 comments on commit 45d22e4

Please sign in to comment.