Skip to content

Commit

Permalink
Update eth2_libp2p
Browse files Browse the repository at this point in the history
- This updates both `libp2p` and `discv5`
- Remove duplicated `BlobSidecarSubnetCount` type
  • Loading branch information
Tumas committed Nov 6, 2024
1 parent 931fad7 commit 17ad54d
Show file tree
Hide file tree
Showing 11 changed files with 301 additions and 276 deletions.
316 changes: 103 additions & 213 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ private_intra_doc_links = 'allow'

[workspace.dependencies]
aes = { version = '0.8', features = ['zeroize'] }
alloy-rlp = '0.3.9'
anyhow = { version = '1', features = ['backtrace'] }
arc-swap = '1'
assert-json-diff = '2'
Expand Down Expand Up @@ -309,7 +310,7 @@ delay_map = '0.4'
derivative = '2'
derive_more = { version = '1', features = ["full"] }
dirs = '5'
discv5 = { version = '0.4', features = ['libp2p'] }
discv5 = { version = '0.7', features = ['libp2p'] }
drain_filter_polyfill = '0.1'
duplicate = '1'
easy-ext = '1'
Expand All @@ -332,6 +333,7 @@ git-version = '0.3'
glob = '0.3'
good_lp = { version = '1', default-features = false, features = ['highs'] }
hash_hasher = '2'
hashlink = '0.9'
hex = { version = '0.4', features = ['serde'] }
hex-literal = '0.4'
hex_fmt = '0.3'
Expand All @@ -355,8 +357,8 @@ jwt-simple = { version = '0.12', default-features = false, features = ['pure-rus
kzg = { git = 'https://github.com/grandinetech/rust-kzg.git', branch = 'integration-raw' }
lazy_static = '1'
libmdbx = { git = 'https://github.com/paradigmxyz/reth.git', package = 'reth-libmdbx', rev = 'c228fe15808c3acbf18dc3af1a03ef5cbdcda07a' }
libp2p = { version = '0.53', default-features = false, features = ['metrics', 'dns', 'ecdsa', 'identify', 'macros', 'noise', 'plaintext', 'secp256k1', 'serde', 'tcp', 'tokio', 'yamux', 'quic', 'upnp'] }
libp2p-mplex = '0.41'
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'
log = '0.4'
lru = '0.12'
mediatype = '0.19'
Expand Down
2 changes: 1 addition & 1 deletion fork_choice_control/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,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(blob_sidecar.index);
let subnet_id = misc::compute_subnet_for_blob_sidecar(self.config(), blob_sidecar.index);

self.controller().on_gossip_blob_sidecar(
Arc::new(blob_sidecar),
Expand Down
3 changes: 2 additions & 1 deletion fork_choice_store/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1706,7 +1706,8 @@ impl<P: Preset> Store<P> {

// [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(blob_sidecar.index);
let expected =
misc::compute_subnet_for_blob_sidecar(&self.chain_config, blob_sidecar.index);

ensure!(
actual == expected,
Expand Down
6 changes: 3 additions & 3 deletions helper_functions/src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use types::{
combined::{Attestation, SignedBeaconBlock},
config::Config,
deneb::{
consts::{BlobCommitmentTreeDepth, BlobSidecarSubnetCount, VERSIONED_HASH_VERSION_KZG},
consts::{BlobCommitmentTreeDepth, VERSIONED_HASH_VERSION_KZG},
containers::BlobSidecar,
primitives::{
Blob, BlobCommitmentInclusionProof, BlobIndex, KzgCommitment, KzgProof, VersionedHash,
Expand Down Expand Up @@ -204,8 +204,8 @@ pub fn compute_subnet_for_attestation<P: Preset>(

/// [`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(blob_index: BlobIndex) -> SubnetId {
blob_index.mod_typenum::<BlobSidecarSubnetCount>()
pub const fn compute_subnet_for_blob_sidecar(config: &Config, blob_index: BlobIndex) -> SubnetId {
blob_index % config.blob_sidecar_subnet_count
}

/// <https://github.com/ethereum/consensus-specs/blob/v1.1.0/specs/altair/validator.md#broadcast-sync-committee-message>
Expand Down
8 changes: 4 additions & 4 deletions p2p/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use std::{collections::BTreeMap, sync::Arc};
use anyhow::Result;
use bls::PublicKeyBytes;
use eth2_libp2p::{
rpc::{GoodbyeReason, StatusMessage},
rpc::{GoodbyeReason, RequestId as IncomingRequestId, RequestType, StatusMessage},
types::{EnrForkId, GossipKind},
GossipId, GossipTopic, MessageAcceptance, NetworkEvent, PeerAction, PeerId, PeerRequestId,
PubsubMessage, ReportSource, Request, Response, Subnet, SubnetDiscovery,
PubsubMessage, ReportSource, Response, Subnet, SubnetDiscovery,
};
use futures::channel::{mpsc::UnboundedSender, oneshot::Sender};
use log::debug;
Expand Down Expand Up @@ -195,8 +195,8 @@ pub enum ServiceInboundMessage<P: Preset> {
Publish(PubsubMessage<P>),
ReportPeer(PeerId, PeerAction, ReportSource, &'static str),
ReportMessageValidationResult(GossipId, MessageAcceptance),
SendRequest(PeerId, RequestId, Request),
SendResponse(PeerId, PeerRequestId, Box<Response<P>>),
SendRequest(PeerId, RequestId, RequestType<P>),
SendResponse(PeerId, PeerRequestId, IncomingRequestId, Box<Response<P>>),
Subscribe(GossipTopic),
SubscribeKind(GossipKind),
SubscribeNewForkTopics(Phase, ForkDigest),
Expand Down
Loading

0 comments on commit 17ad54d

Please sign in to comment.