diff --git a/eth2_libp2p b/eth2_libp2p index 51900734..60cf6aa2 160000 --- a/eth2_libp2p +++ b/eth2_libp2p @@ -1 +1 @@ -Subproject commit 51900734c85b7e5d838d3a171f5b1983e7ef9a8b +Subproject commit 60cf6aa296890b5e8d4a5dbf38fc9f4d3e5bed71 diff --git a/fork_choice_control/src/helpers.rs b/fork_choice_control/src/helpers.rs index eaa9c82a..d7ce9f8f 100644 --- a/fork_choice_control/src/helpers.rs +++ b/fork_choice_control/src/helpers.rs @@ -255,7 +255,7 @@ impl Context

{ } pub fn on_blob_sidecar(&mut self, blob_sidecar: BlobSidecar

) -> Option> { - let subnet_id = misc::compute_subnet_for_blob_sidecar(self.config(), blob_sidecar.index); + let subnet_id = misc::compute_subnet_for_blob_sidecar(self.config(), &blob_sidecar); self.controller().on_gossip_blob_sidecar( Arc::new(blob_sidecar), diff --git a/fork_choice_store/src/store.rs b/fork_choice_store/src/store.rs index f6982510..ef147471 100644 --- a/fork_choice_store/src/store.rs +++ b/fork_choice_store/src/store.rs @@ -1700,7 +1700,7 @@ impl Store

{ // [REJECT] The sidecar's index is consistent with MAX_BLOBS_PER_BLOCK -- i.e. blob_sidecar.index < MAX_BLOBS_PER_BLOCK. let max_blobs_per_block = - if self.chain_config().phase_at_slot::

(block_header.slot) == Phase::Electra { + if self.chain_config().phase_at_slot::

(block_header.slot) >= Phase::Electra { P::MaxBlobsPerBlockElectra::U64 } else { P::MaxBlobsPerBlock::U64 @@ -1713,8 +1713,7 @@ impl Store

{ // [REJECT] The sidecar is for the correct subnet -- i.e. compute_subnet_for_blob_sidecar(blob_sidecar.index) == subnet_id. if let Some(actual) = origin.subnet_id() { - let expected = - misc::compute_subnet_for_blob_sidecar(&self.chain_config, blob_sidecar.index); + let expected = misc::compute_subnet_for_blob_sidecar(&self.chain_config, &blob_sidecar); ensure!( actual == expected, diff --git a/helper_functions/src/misc.rs b/helper_functions/src/misc.rs index 233b1b0d..e512514b 100644 --- a/helper_functions/src/misc.rs +++ b/helper_functions/src/misc.rs @@ -23,6 +23,7 @@ use types::{ Blob, BlobCommitmentInclusionProof, BlobIndex, KzgCommitment, KzgProof, VersionedHash, }, }, + nonstandard::Phase, phase0::{ consts::{ AttestationSubnetCount, BLS_WITHDRAWAL_PREFIX, ETH1_ADDRESS_WITHDRAWAL_PREFIX, @@ -279,8 +280,15 @@ pub fn compute_subnet_for_attestation( /// [`compute_subnet_for_blob_sidecar`](https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/validator.md#sidecar) #[must_use] -pub fn compute_subnet_for_blob_sidecar(config: &Config, blob_index: BlobIndex) -> SubnetId { - blob_index % config.blob_sidecar_subnet_count +pub fn compute_subnet_for_blob_sidecar( + config: &Config, + blob_sidecar: &BlobSidecar

, +) -> SubnetId { + if config.phase_at_slot::

(blob_sidecar.signed_block_header.message.slot) >= Phase::Electra { + blob_sidecar.index % config.blob_sidecar_subnet_count_electra + } else { + blob_sidecar.index % config.blob_sidecar_subnet_count + } } /// diff --git a/p2p/src/network.rs b/p2p/src/network.rs index 45432593..8a268c8c 100644 --- a/p2p/src/network.rs +++ b/p2p/src/network.rs @@ -547,10 +547,8 @@ impl Network

{ } fn publish_blob_sidecar(&self, blob_sidecar: Arc>) { - let subnet_id = misc::compute_subnet_for_blob_sidecar( - self.controller.chain_config(), - blob_sidecar.index, - ); + let subnet_id = + misc::compute_subnet_for_blob_sidecar(self.controller.chain_config(), &blob_sidecar); let blob_identifier: BlobIdentifier = blob_sidecar.as_ref().into();