Skip to content
Closed
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

125 changes: 111 additions & 14 deletions block_producer/src/block_producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use operation_pools::{
};
use prometheus_metrics::Metrics;
use pubkey_cache::PubkeyCache;
use ssz::{BitList, BitVector, ContiguousList, Hc, SszHash};
use ssz::{BitList, BitVector, ContiguousList, Hc, ProgressiveList, SszHash};
use std_ext::ArcExt as _;
use tap::Pipe as _;
use tokio::task::JoinHandle;
Expand Down Expand Up @@ -81,10 +81,11 @@ use types::{
gloas::{
consts::BUILDER_INDEX_SELF_BUILD,
containers::{
BeaconBlock as GloasBeaconBlock, BeaconBlockBody as GloasBeaconBlockBody,
ExecutionPayload as GloasExecutionPayload, ExecutionPayloadBid,
ExecutionPayloadEnvelope, ExecutionRequests as GloasExecutionRequests,
PayloadAttestation, SignedExecutionPayloadBid,
AttesterSlashing as GloasAttesterSlashing, BeaconBlock as GloasBeaconBlock,
BeaconBlockBody as GloasBeaconBlockBody, ExecutionPayload as GloasExecutionPayload,
ExecutionPayloadBid, ExecutionPayloadEnvelope,
ExecutionRequests as GloasExecutionRequests, PayloadAttestation,
SignedExecutionPayloadBid,
},
},
nonstandard::{BlockRewards, Phase, WEI_IN_GWEI, WithBlobsAndMev},
Expand Down Expand Up @@ -275,6 +276,21 @@ impl<P: Preset, W: Wait> BlockProducer<P, W> {
predicates::is_slashable_validator(attester, current_epoch)
})
}
AttesterSlashing::Gloas(attester_slashing) => {
accessors::slashable_indices(attester_slashing).any(|attester_index| {
let attester = match finalized_state.validators().get(attester_index) {
Ok(attester) => attester,
Err(error) => {
log_with_feature(format_args!(
"attester slashing is too recent to discard: {error}"
));
return true;
}
};

predicates::is_slashable_validator(attester, current_epoch)
})
}
});

self.producer_context
Expand Down Expand Up @@ -343,6 +359,9 @@ impl<P: Preset, W: Wait> BlockProducer<P, W> {
AttesterSlashing::Electra(attester_slashing) => {
accessors::slashable_indices(attester_slashing).collect::<HashSet<_>>()
}
AttesterSlashing::Gloas(attester_slashing) => {
accessors::slashable_indices(attester_slashing).collect::<HashSet<_>>()
}
})
.collect::<HashSet<_>>();

Expand All @@ -355,6 +374,10 @@ impl<P: Preset, W: Wait> BlockProducer<P, W> {
accessors::slashable_indices(attester_slashing)
.all(|index| seen_indices.contains(&index))
}
AttesterSlashing::Gloas(ref attester_slashing) => {
accessors::slashable_indices(attester_slashing)
.all(|index| seen_indices.contains(&index))
}
};

if all_seen {
Expand Down Expand Up @@ -385,6 +408,12 @@ impl<P: Preset, W: Wait> BlockProducer<P, W> {
attester_slashing,
)
}
AttesterSlashing::Gloas(ref attester_slashing) => unphased::validate_attester_slashing(
&self.producer_context.chain_config,
&self.producer_context.pubkey_cache,
&state,
attester_slashing,
),
};

let outcome = match result {
Expand Down Expand Up @@ -1009,9 +1038,9 @@ impl<P: Preset, W: Wait> BlockBuildContext<P, W> {
let payload_attestations = if parent_block.value().to_header().message.slot
== misc::previous_slot(slot)
{
self.prepare_payload_attestations().await?
self.prepare_payload_attestations().await?.into()
} else {
ContiguousList::default()
ProgressiveList::default()
};

let parent_execution_requests = if snapshot.should_build_on_full() {
Expand All @@ -1037,13 +1066,13 @@ impl<P: Preset, W: Wait> BlockBuildContext<P, W> {
randao_reveal,
eth1_data,
graffiti,
proposer_slashings,
attester_slashings: self.prepare_attester_slashings_electra().await,
attestations,
deposits,
voluntary_exits,
proposer_slashings: proposer_slashings.into(),
attester_slashings: self.prepare_attester_slashings_gloas().await,
attestations: attestations.map(Into::into).into(),
deposits: deposits.into(),
voluntary_exits: voluntary_exits.into(),
sync_aggregate,
bls_to_execution_changes,
bls_to_execution_changes: bls_to_execution_changes.into(),
signed_execution_payload_bid: SignedExecutionPayloadBid::default(),
payload_attestations,
parent_execution_requests,
Expand Down Expand Up @@ -1404,6 +1433,12 @@ impl<P: Preset, W: Wait> BlockBuildContext<P, W> {
attester_slashing,
)
}
AttesterSlashing::Gloas(attester_slashing) => unphased::validate_attester_slashing(
&self.producer_context.chain_config,
&self.producer_context.pubkey_cache,
&self.beacon_state,
attester_slashing,
),
}
.is_ok()
});
Expand Down Expand Up @@ -1454,6 +1489,12 @@ impl<P: Preset, W: Wait> BlockBuildContext<P, W> {
attester_slashing,
)
}
AttesterSlashing::Gloas(attester_slashing) => unphased::validate_attester_slashing(
&self.producer_context.chain_config,
&self.producer_context.pubkey_cache,
&self.beacon_state,
attester_slashing,
),
}
.is_ok()
});
Expand All @@ -1475,6 +1516,62 @@ impl<P: Preset, W: Wait> BlockBuildContext<P, W> {
slashings
}

async fn prepare_attester_slashings_gloas(
&self,
) -> ProgressiveList<GloasAttesterSlashing<P>, P::MaxAttesterSlashingsElectra> {
let _timer = self
.producer_context
.metrics
.as_ref()
.map(|metrics| metrics.prepare_attester_slashings_times.start_timer());

let mut slashings = self.producer_context.attester_slashings.lock().await;

let split_index = itertools::partition(slashings.iter_mut(), |slashing| {
match slashing {
AttesterSlashing::Phase0(attester_slashing) => {
unphased::validate_attester_slashing(
&self.producer_context.chain_config,
&self.producer_context.pubkey_cache,
&self.beacon_state,
attester_slashing,
)
}
AttesterSlashing::Electra(attester_slashing) => {
unphased::validate_attester_slashing(
&self.producer_context.chain_config,
&self.producer_context.pubkey_cache,
&self.beacon_state,
attester_slashing,
)
}
AttesterSlashing::Gloas(attester_slashing) => unphased::validate_attester_slashing(
&self.producer_context.chain_config,
&self.producer_context.pubkey_cache,
&self.beacon_state,
attester_slashing,
),
}
.is_ok()
});

let slashings = ProgressiveList::try_from_iter(
slashings
.drain(0..split_index.min(P::MaxAttesterSlashingsElectra::USIZE))
.filter_map(AttesterSlashing::post_gloas),
)
.expect(
"the call to Vec::drain above limits the \
iterator to P::MaxAttesterSlashingsElectra::USIZE elements",
);

log_with_feature(format_args!(
"attester slashings for proposal: {slashings:?}"
));

slashings
}

async fn prepare_attestations(&self) -> Result<Vec<PoolAttestation<P>>> {
self.producer_context
.attestation_agg_pool
Expand Down Expand Up @@ -1716,7 +1813,7 @@ impl<P: Preset, W: Wait> BlockBuildContext<P, W> {
slot: state.slot(),
value: 0,
execution_payment: 0,
blob_kzg_commitments: blob_kzg_commitments_opt.unwrap_or_default(),
blob_kzg_commitments: blob_kzg_commitments_opt.unwrap_or_default().into(),
execution_requests_root,
};

Expand Down
14 changes: 7 additions & 7 deletions eip_7594/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use kzg_utils::{
use num_traits::One as _;
use prometheus_metrics::Metrics;
use sha2::{Digest as _, Sha256};
use ssz::{ContiguousList, ContiguousVector, H256, SszHash as _, Uint256};
use ssz::{ContiguousList, ContiguousVector, H256, ProgressiveList, SszHash as _, Uint256};
use tracing::instrument;
use try_from_iterator::TryFromIterator as _;
use typenum::Unsigned as _;
Expand Down Expand Up @@ -154,7 +154,7 @@ pub fn verify_data_column_sidecar<P: Preset>(
}

// A sidecar for zero blobs is invalid
if data_column_sidecar.column().is_empty() {
if data_column_sidecar.column().len_usize() == 0 {
return false;
}

Expand All @@ -168,8 +168,8 @@ pub fn verify_data_column_sidecar<P: Preset>(
}

// The column length must be equal to the number of commitments/proofs
if data_column_sidecar.column().len() != kzg_commitments.len()
|| data_column_sidecar.column().len() != data_column_sidecar.kzg_proofs().len()
if data_column_sidecar.column().len_usize() != kzg_commitments.len()
|| data_column_sidecar.column().len_usize() != data_column_sidecar.kzg_proofs().len_usize()
{
return false;
}
Expand Down Expand Up @@ -198,7 +198,7 @@ pub fn verify_kzg_proofs<P: Preset>(
});

let cell_indices: Vec<u64> =
vec![data_column_sidecar.index(); data_column_sidecar.column().len()];
vec![data_column_sidecar.index(); data_column_sidecar.column().len_usize()];

// KZG commitments, proofs, and column length is already enforced by `verify_data_column_sidecar`
// which check prior to `verify_kzg_proofs`, so no additional check is needed.
Expand Down Expand Up @@ -325,11 +325,11 @@ fn get_data_column_sidecars_post_gloas<P: Preset>(

let mut sidecars = vec![];
for column_index in 0..P::NumberOfColumns::USIZE {
let column = ContiguousList::try_from_iter(
let column = ProgressiveList::try_from_iter(
(0..blob_count)
.map(|row_index| cells_and_kzg_proofs[row_index].0[column_index].clone()),
)?;
let kzg_proofs = ContiguousList::try_from_iter(
let kzg_proofs = ProgressiveList::try_from_iter(
(0..blob_count).map(|row_index| cells_and_kzg_proofs[row_index].1[column_index]),
)?;

Expand Down
2 changes: 1 addition & 1 deletion eth1_api/src/eth1_api/http_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ impl Eth1Api {
}),
) => {
let payload_v4 = ExecutionPayloadV4::from(payload);
let raw_execution_requests = RawExecutionRequests::from(execution_requests);
let raw_execution_requests = RawExecutionRequests::try_from(execution_requests)?;

let params = vec![
serde_json::to_value(payload_v4)?,
Expand Down
2 changes: 1 addition & 1 deletion eth1_api/src/execution_blob_fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ impl<P: Preset, W: Wait> ExecutionBlobFetcher<P, W> {
metrics.engine_get_blobs_v2_requests_count.inc();
}

let expected_blobs_count = kzg_commitments.len();
let expected_blobs_count = kzg_commitments.len_usize();
let versioned_hashes = kzg_commitments
.iter()
.copied()
Expand Down
2 changes: 1 addition & 1 deletion eth2_libp2p
Submodule eth2_libp2p updated 1 files
+16 −10 src/rpc/protocol.rs
Loading
Loading