Merge remote-tracking branch 'upstream/unstable' into electra_attestation_changes

This commit is contained in:
Mark Mackey
2024-05-02 18:22:34 -05:00
156 changed files with 3625 additions and 4082 deletions

View File

@@ -438,7 +438,7 @@ pub fn gossipsub_config(
let topic_bytes = message.topic.as_str().as_bytes();
match fork_context.current_fork() {
ForkName::Altair
| ForkName::Merge
| ForkName::Bellatrix
| ForkName::Capella
| ForkName::Deneb
| ForkName::Electra => {
@@ -461,7 +461,7 @@ pub fn gossipsub_config(
}
}
let message_domain_valid_snappy = gossipsub_config_params.message_domain_valid_snappy;
let is_merge_enabled = fork_context.fork_exists(ForkName::Merge);
let is_bellatrix_enabled = fork_context.fork_exists(ForkName::Bellatrix);
let gossip_message_id = move |message: &gossipsub::Message| {
gossipsub::MessageId::from(
&Sha256::digest(
@@ -481,7 +481,7 @@ pub fn gossipsub_config(
gossipsub::ConfigBuilder::default()
.max_transmit_size(gossip_max_size(
is_merge_enabled,
is_bellatrix_enabled,
gossipsub_config_params.gossip_max_size,
))
.heartbeat_interval(load.heartbeat_interval)

View File

@@ -398,16 +398,32 @@ impl<E: EthSpec> Discovery<E> {
/// automatically update the external address.
///
/// If the external address needs to be modified, use `update_enr_udp_socket.
pub fn update_enr_tcp_port(&mut self, port: u16) -> Result<(), String> {
///
/// This returns Ok(true) if the ENR was updated, otherwise Ok(false) if nothing was done.
pub fn update_enr_tcp_port(&mut self, port: u16, v6: bool) -> Result<bool, String> {
let enr_field = if v6 {
if self.discv5.external_enr().read().tcp6() == Some(port) {
// The field is already set to the same value, nothing to do
return Ok(false);
}
"tcp6"
} else {
if self.discv5.external_enr().read().tcp4() == Some(port) {
// The field is already set to the same value, nothing to do
return Ok(false);
}
"tcp"
};
self.discv5
.enr_insert("tcp", &port)
.enr_insert(enr_field, &port)
.map_err(|e| format!("{:?}", e))?;
// replace the global version
*self.network_globals.local_enr.write() = self.discv5.local_enr();
// persist modified enr to disk
enr::save_enr_to_disk(Path::new(&self.enr_dir), &self.local_enr(), &self.log);
Ok(())
Ok(true)
}
// TODO: Group these functions here once the ENR is shared across discv5 and lighthouse and
@@ -415,16 +431,35 @@ impl<E: EthSpec> Discovery<E> {
// This currently doesn't support ipv6. All of these functions should be removed and
// addressed properly in the following issue.
// https://github.com/sigp/lighthouse/issues/4706
pub fn update_enr_quic_port(&mut self, port: u16) -> Result<(), String> {
pub fn update_enr_quic_port(&mut self, port: u16, v6: bool) -> Result<bool, String> {
let enr_field = if v6 {
if self.discv5.external_enr().read().quic6() == Some(port) {
// The field is already set to the same value, nothing to do
return Ok(false);
}
"quic6"
} else {
if self.discv5.external_enr().read().quic4() == Some(port) {
// The field is already set to the same value, nothing to do
return Ok(false);
}
"quic"
};
let current_field = self.discv5.external_enr().read().quic4();
if current_field == Some(port) {
// The current field is already set, no need to update.
return Ok(false);
}
self.discv5
.enr_insert("quic", &port)
.enr_insert(enr_field, &port)
.map_err(|e| format!("{:?}", e))?;
// replace the global version
*self.network_globals.local_enr.write() = self.discv5.local_enr();
// persist modified enr to disk
enr::save_enr_to_disk(Path::new(&self.enr_dir), &self.local_enr(), &self.log);
Ok(())
Ok(true)
}
/// Updates the local ENR UDP socket.
@@ -1057,7 +1092,7 @@ impl<E: EthSpec> NetworkBehaviour for Discovery<E> {
return;
}
self.update_enr_tcp_port(port)
self.update_enr_tcp_port(port, false)
}
(Some(Protocol::Udp(port)), Some(Protocol::QuicV1)) => {
if !self.update_ports.quic4 {
@@ -1065,7 +1100,7 @@ impl<E: EthSpec> NetworkBehaviour for Discovery<E> {
return;
}
self.update_enr_quic_port(port)
self.update_enr_quic_port(port, false)
}
_ => {
debug!(self.log, "Encountered unacceptable multiaddr for listening (unsupported transport)"; "addr" => ?addr);
@@ -1079,7 +1114,7 @@ impl<E: EthSpec> NetworkBehaviour for Discovery<E> {
return;
}
self.update_enr_tcp_port(port)
self.update_enr_tcp_port(port, true)
}
(Some(Protocol::Udp(port)), Some(Protocol::QuicV1)) => {
if !self.update_ports.quic6 {
@@ -1087,7 +1122,7 @@ impl<E: EthSpec> NetworkBehaviour for Discovery<E> {
return;
}
self.update_enr_quic_port(port)
self.update_enr_quic_port(port, true)
}
_ => {
debug!(self.log, "Encountered unacceptable multiaddr for listening (unsupported transport)"; "addr" => ?addr);
@@ -1103,9 +1138,10 @@ impl<E: EthSpec> NetworkBehaviour for Discovery<E> {
let local_enr: Enr = self.discv5.local_enr();
match attempt_enr_update {
Ok(_) => {
Ok(true) => {
info!(self.log, "Updated local ENR"; "enr" => local_enr.to_base64(), "seq" => local_enr.seq(), "id"=> %local_enr.node_id(), "ip4" => ?local_enr.ip4(), "udp4"=> ?local_enr.udp4(), "tcp4" => ?local_enr.tcp4(), "tcp6" => ?local_enr.tcp6(), "udp6" => ?local_enr.udp6())
}
Ok(false) => {} // Nothing to do, ENR already configured
Err(e) => warn!(self.log, "Failed to update ENR"; "error" => ?e),
}
}

View File

@@ -184,13 +184,13 @@ mod tests {
fn fork_context(fork_name: ForkName) -> ForkContext {
let mut chain_spec = Spec::default_spec();
let altair_fork_epoch = Epoch::new(1);
let merge_fork_epoch = Epoch::new(2);
let bellatrix_fork_epoch = Epoch::new(2);
let capella_fork_epoch = Epoch::new(3);
let deneb_fork_epoch = Epoch::new(4);
let electra_fork_epoch = Epoch::new(5);
chain_spec.altair_fork_epoch = Some(altair_fork_epoch);
chain_spec.bellatrix_fork_epoch = Some(merge_fork_epoch);
chain_spec.bellatrix_fork_epoch = Some(bellatrix_fork_epoch);
chain_spec.capella_fork_epoch = Some(capella_fork_epoch);
chain_spec.deneb_fork_epoch = Some(deneb_fork_epoch);
chain_spec.electra_fork_epoch = Some(electra_fork_epoch);
@@ -198,7 +198,7 @@ mod tests {
let current_slot = match fork_name {
ForkName::Base => Slot::new(0),
ForkName::Altair => altair_fork_epoch.start_slot(Spec::slots_per_epoch()),
ForkName::Merge => merge_fork_epoch.start_slot(Spec::slots_per_epoch()),
ForkName::Bellatrix => bellatrix_fork_epoch.start_slot(Spec::slots_per_epoch()),
ForkName::Capella => capella_fork_epoch.start_slot(Spec::slots_per_epoch()),
ForkName::Deneb => deneb_fork_epoch.start_slot(Spec::slots_per_epoch()),
ForkName::Electra => electra_fork_epoch.start_slot(Spec::slots_per_epoch()),

View File

@@ -18,8 +18,8 @@ use tokio_util::codec::{Decoder, Encoder};
use types::{
BlobSidecar, ChainSpec, EthSpec, ForkContext, ForkName, Hash256, LightClientBootstrap,
LightClientFinalityUpdate, LightClientOptimisticUpdate, RuntimeVariableList, SignedBeaconBlock,
SignedBeaconBlockAltair, SignedBeaconBlockBase, SignedBeaconBlockCapella,
SignedBeaconBlockDeneb, SignedBeaconBlockElectra, SignedBeaconBlockMerge,
SignedBeaconBlockAltair, SignedBeaconBlockBase, SignedBeaconBlockBellatrix,
SignedBeaconBlockCapella, SignedBeaconBlockDeneb, SignedBeaconBlockElectra,
};
use unsigned_varint::codec::Uvi;
@@ -403,8 +403,8 @@ fn context_bytes<E: EthSpec>(
SignedBeaconBlock::Capella { .. } => {
fork_context.to_context_bytes(ForkName::Capella)
}
SignedBeaconBlock::Merge { .. } => {
fork_context.to_context_bytes(ForkName::Merge)
SignedBeaconBlock::Bellatrix { .. } => {
fork_context.to_context_bytes(ForkName::Bellatrix)
}
SignedBeaconBlock::Altair { .. } => {
fork_context.to_context_bytes(ForkName::Altair)
@@ -658,8 +658,10 @@ fn handle_rpc_response<E: EthSpec>(
Some(ForkName::Base) => Ok(Some(RPCResponse::BlocksByRange(Arc::new(
SignedBeaconBlock::Base(SignedBeaconBlockBase::from_ssz_bytes(decoded_buffer)?),
)))),
Some(ForkName::Merge) => Ok(Some(RPCResponse::BlocksByRange(Arc::new(
SignedBeaconBlock::Merge(SignedBeaconBlockMerge::from_ssz_bytes(decoded_buffer)?),
Some(ForkName::Bellatrix) => Ok(Some(RPCResponse::BlocksByRange(Arc::new(
SignedBeaconBlock::Bellatrix(SignedBeaconBlockBellatrix::from_ssz_bytes(
decoded_buffer,
)?),
)))),
Some(ForkName::Capella) => Ok(Some(RPCResponse::BlocksByRange(Arc::new(
SignedBeaconBlock::Capella(SignedBeaconBlockCapella::from_ssz_bytes(
@@ -689,8 +691,10 @@ fn handle_rpc_response<E: EthSpec>(
Some(ForkName::Base) => Ok(Some(RPCResponse::BlocksByRoot(Arc::new(
SignedBeaconBlock::Base(SignedBeaconBlockBase::from_ssz_bytes(decoded_buffer)?),
)))),
Some(ForkName::Merge) => Ok(Some(RPCResponse::BlocksByRoot(Arc::new(
SignedBeaconBlock::Merge(SignedBeaconBlockMerge::from_ssz_bytes(decoded_buffer)?),
Some(ForkName::Bellatrix) => Ok(Some(RPCResponse::BlocksByRoot(Arc::new(
SignedBeaconBlock::Bellatrix(SignedBeaconBlockBellatrix::from_ssz_bytes(
decoded_buffer,
)?),
)))),
Some(ForkName::Capella) => Ok(Some(RPCResponse::BlocksByRoot(Arc::new(
SignedBeaconBlock::Capella(SignedBeaconBlockCapella::from_ssz_bytes(
@@ -743,7 +747,7 @@ mod tests {
use crate::types::{EnrAttestationBitfield, EnrSyncCommitteeBitfield};
use types::{
blob_sidecar::BlobIdentifier, BeaconBlock, BeaconBlockAltair, BeaconBlockBase,
BeaconBlockMerge, EmptyBlock, Epoch, FullPayload, Signature, Slot,
BeaconBlockBellatrix, EmptyBlock, Epoch, FullPayload, Signature, Slot,
};
type Spec = types::MainnetEthSpec;
@@ -751,13 +755,13 @@ mod tests {
fn fork_context(fork_name: ForkName) -> ForkContext {
let mut chain_spec = Spec::default_spec();
let altair_fork_epoch = Epoch::new(1);
let merge_fork_epoch = Epoch::new(2);
let bellatrix_fork_epoch = Epoch::new(2);
let capella_fork_epoch = Epoch::new(3);
let deneb_fork_epoch = Epoch::new(4);
let electra_fork_epoch = Epoch::new(5);
chain_spec.altair_fork_epoch = Some(altair_fork_epoch);
chain_spec.bellatrix_fork_epoch = Some(merge_fork_epoch);
chain_spec.bellatrix_fork_epoch = Some(bellatrix_fork_epoch);
chain_spec.capella_fork_epoch = Some(capella_fork_epoch);
chain_spec.deneb_fork_epoch = Some(deneb_fork_epoch);
chain_spec.electra_fork_epoch = Some(electra_fork_epoch);
@@ -765,7 +769,7 @@ mod tests {
let current_slot = match fork_name {
ForkName::Base => Slot::new(0),
ForkName::Altair => altair_fork_epoch.start_slot(Spec::slots_per_epoch()),
ForkName::Merge => merge_fork_epoch.start_slot(Spec::slots_per_epoch()),
ForkName::Bellatrix => bellatrix_fork_epoch.start_slot(Spec::slots_per_epoch()),
ForkName::Capella => capella_fork_epoch.start_slot(Spec::slots_per_epoch()),
ForkName::Deneb => deneb_fork_epoch.start_slot(Spec::slots_per_epoch()),
ForkName::Electra => electra_fork_epoch.start_slot(Spec::slots_per_epoch()),
@@ -790,32 +794,38 @@ mod tests {
Arc::new(BlobSidecar::empty())
}
/// Merge block with length < max_rpc_size.
fn merge_block_small(fork_context: &ForkContext, spec: &ChainSpec) -> SignedBeaconBlock<Spec> {
let mut block: BeaconBlockMerge<_, FullPayload<Spec>> =
BeaconBlockMerge::empty(&Spec::default_spec());
/// Bellatrix block with length < max_rpc_size.
fn bellatrix_block_small(
fork_context: &ForkContext,
spec: &ChainSpec,
) -> SignedBeaconBlock<Spec> {
let mut block: BeaconBlockBellatrix<_, FullPayload<Spec>> =
BeaconBlockBellatrix::empty(&Spec::default_spec());
let tx = VariableList::from(vec![0; 1024]);
let txs = VariableList::from(std::iter::repeat(tx).take(5000).collect::<Vec<_>>());
block.body.execution_payload.execution_payload.transactions = txs;
let block = BeaconBlock::Merge(block);
let block = BeaconBlock::Bellatrix(block);
assert!(block.ssz_bytes_len() <= max_rpc_size(fork_context, spec.max_chunk_size as usize));
SignedBeaconBlock::from_block(block, Signature::empty())
}
/// Merge block with length > MAX_RPC_SIZE.
/// The max limit for a merge block is in the order of ~16GiB which wouldn't fit in memory.
/// Hence, we generate a merge block just greater than `MAX_RPC_SIZE` to test rejection on the rpc layer.
fn merge_block_large(fork_context: &ForkContext, spec: &ChainSpec) -> SignedBeaconBlock<Spec> {
let mut block: BeaconBlockMerge<_, FullPayload<Spec>> =
BeaconBlockMerge::empty(&Spec::default_spec());
/// Bellatrix block with length > MAX_RPC_SIZE.
/// The max limit for a Bellatrix block is in the order of ~16GiB which wouldn't fit in memory.
/// Hence, we generate a Bellatrix block just greater than `MAX_RPC_SIZE` to test rejection on the rpc layer.
fn bellatrix_block_large(
fork_context: &ForkContext,
spec: &ChainSpec,
) -> SignedBeaconBlock<Spec> {
let mut block: BeaconBlockBellatrix<_, FullPayload<Spec>> =
BeaconBlockBellatrix::empty(&Spec::default_spec());
let tx = VariableList::from(vec![0; 1024]);
let txs = VariableList::from(std::iter::repeat(tx).take(100000).collect::<Vec<_>>());
block.body.execution_payload.execution_payload.transactions = txs;
let block = BeaconBlock::Merge(block);
let block = BeaconBlock::Bellatrix(block);
assert!(block.ssz_bytes_len() > max_rpc_size(fork_context, spec.max_chunk_size as usize));
SignedBeaconBlock::from_block(block, Signature::empty())
}
@@ -1172,25 +1182,27 @@ mod tests {
Ok(Some(RPCResponse::BlocksByRange(Arc::new(altair_block()))))
);
let merge_block_small = merge_block_small(&fork_context(ForkName::Merge), &chain_spec);
let merge_block_large = merge_block_large(&fork_context(ForkName::Merge), &chain_spec);
let bellatrix_block_small =
bellatrix_block_small(&fork_context(ForkName::Bellatrix), &chain_spec);
let bellatrix_block_large =
bellatrix_block_large(&fork_context(ForkName::Bellatrix), &chain_spec);
assert_eq!(
encode_then_decode_response(
SupportedProtocol::BlocksByRangeV2,
RPCCodedResponse::Success(RPCResponse::BlocksByRange(Arc::new(
merge_block_small.clone()
bellatrix_block_small.clone()
))),
ForkName::Merge,
ForkName::Bellatrix,
&chain_spec,
),
Ok(Some(RPCResponse::BlocksByRange(Arc::new(
merge_block_small.clone()
bellatrix_block_small.clone()
))))
);
let mut encoded =
encode_without_length_checks(merge_block_large.as_ssz_bytes(), ForkName::Merge)
encode_without_length_checks(bellatrix_block_large.as_ssz_bytes(), ForkName::Bellatrix)
.unwrap();
assert!(
@@ -1198,7 +1210,7 @@ mod tests {
decode_response(
SupportedProtocol::BlocksByRangeV2,
&mut encoded,
ForkName::Merge,
ForkName::Bellatrix,
&chain_spec,
)
.unwrap_err(),
@@ -1248,16 +1260,18 @@ mod tests {
encode_then_decode_response(
SupportedProtocol::BlocksByRootV2,
RPCCodedResponse::Success(RPCResponse::BlocksByRoot(Arc::new(
merge_block_small.clone()
bellatrix_block_small.clone()
))),
ForkName::Merge,
ForkName::Bellatrix,
&chain_spec,
),
Ok(Some(RPCResponse::BlocksByRoot(Arc::new(merge_block_small))))
Ok(Some(RPCResponse::BlocksByRoot(Arc::new(
bellatrix_block_small
))))
);
let mut encoded =
encode_without_length_checks(merge_block_large.as_ssz_bytes(), ForkName::Merge)
encode_without_length_checks(bellatrix_block_large.as_ssz_bytes(), ForkName::Bellatrix)
.unwrap();
assert!(
@@ -1265,7 +1279,7 @@ mod tests {
decode_response(
SupportedProtocol::BlocksByRootV2,
&mut encoded,
ForkName::Merge,
ForkName::Bellatrix,
&chain_spec,
)
.unwrap_err(),

View File

@@ -17,8 +17,8 @@ use tokio_util::{
compat::{Compat, FuturesAsyncReadCompatExt},
};
use types::{
BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockCapella, BeaconBlockElectra,
BeaconBlockMerge, BlobSidecar, ChainSpec, EmptyBlock, EthSpec, ForkContext, ForkName,
BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockBellatrix, BeaconBlockCapella,
BeaconBlockElectra, BlobSidecar, ChainSpec, EmptyBlock, EthSpec, ForkContext, ForkName,
LightClientBootstrap, LightClientBootstrapAltair, LightClientFinalityUpdate,
LightClientFinalityUpdateAltair, LightClientOptimisticUpdate,
LightClientOptimisticUpdateAltair, MainnetEthSpec, Signature, SignedBeaconBlock,
@@ -53,8 +53,8 @@ lazy_static! {
.as_ssz_bytes()
.len();
pub static ref SIGNED_BEACON_BLOCK_MERGE_MIN: usize = SignedBeaconBlock::<MainnetEthSpec>::from_block(
BeaconBlock::Merge(BeaconBlockMerge::<MainnetEthSpec>::empty(&MainnetEthSpec::default_spec())),
pub static ref SIGNED_BEACON_BLOCK_BELLATRIX_MIN: usize = SignedBeaconBlock::<MainnetEthSpec>::from_block(
BeaconBlock::Bellatrix(BeaconBlockBellatrix::<MainnetEthSpec>::empty(&MainnetEthSpec::default_spec())),
Signature::empty(),
)
.as_ssz_bytes()
@@ -74,14 +74,14 @@ lazy_static! {
.as_ssz_bytes()
.len();
/// The `BeaconBlockMerge` block has an `ExecutionPayload` field which has a max size ~16 GiB for future proofing.
/// The `BeaconBlockBellatrix` block has an `ExecutionPayload` field which has a max size ~16 GiB for future proofing.
/// We calculate the value from its fields instead of constructing the block and checking the length.
/// Note: This is only the theoretical upper bound. We further bound the max size we receive over the network
/// with `max_chunk_size`.
pub static ref SIGNED_BEACON_BLOCK_MERGE_MAX: usize =
pub static ref SIGNED_BEACON_BLOCK_BELLATRIX_MAX: usize =
// Size of a full altair block
*SIGNED_BEACON_BLOCK_ALTAIR_MAX
+ types::ExecutionPayload::<MainnetEthSpec>::max_execution_payload_merge_size() // adding max size of execution payload (~16gb)
+ types::ExecutionPayload::<MainnetEthSpec>::max_execution_payload_bellatrix_size() // adding max size of execution payload (~16gb)
+ ssz::BYTES_PER_LENGTH_OFFSET; // Adding the additional ssz offset for the `ExecutionPayload` field
pub static ref SIGNED_BEACON_BLOCK_CAPELLA_MAX: usize = *SIGNED_BEACON_BLOCK_CAPELLA_MAX_WITHOUT_PAYLOAD
@@ -134,7 +134,7 @@ const REQUEST_TIMEOUT: u64 = 15;
pub fn max_rpc_size(fork_context: &ForkContext, max_chunk_size: usize) -> usize {
match fork_context.current_fork() {
ForkName::Altair | ForkName::Base => max_chunk_size / 10,
ForkName::Merge => max_chunk_size,
ForkName::Bellatrix => max_chunk_size,
ForkName::Capella => max_chunk_size,
ForkName::Deneb => max_chunk_size,
ForkName::Electra => max_chunk_size,
@@ -154,20 +154,20 @@ pub fn rpc_block_limits_by_fork(current_fork: ForkName) -> RpcLimits {
*SIGNED_BEACON_BLOCK_BASE_MIN, // Base block is smaller than altair blocks
*SIGNED_BEACON_BLOCK_ALTAIR_MAX, // Altair block is larger than base blocks
),
ForkName::Merge => RpcLimits::new(
*SIGNED_BEACON_BLOCK_BASE_MIN, // Base block is smaller than altair and merge blocks
*SIGNED_BEACON_BLOCK_MERGE_MAX, // Merge block is larger than base and altair blocks
ForkName::Bellatrix => RpcLimits::new(
*SIGNED_BEACON_BLOCK_BASE_MIN, // Base block is smaller than altair and bellatrix blocks
*SIGNED_BEACON_BLOCK_BELLATRIX_MAX, // Bellatrix block is larger than base and altair blocks
),
ForkName::Capella => RpcLimits::new(
*SIGNED_BEACON_BLOCK_BASE_MIN, // Base block is smaller than altair and merge blocks
*SIGNED_BEACON_BLOCK_BASE_MIN, // Base block is smaller than altair and bellatrix blocks
*SIGNED_BEACON_BLOCK_CAPELLA_MAX, // Capella block is larger than base, altair and merge blocks
),
ForkName::Deneb => RpcLimits::new(
*SIGNED_BEACON_BLOCK_BASE_MIN, // Base block is smaller than altair and merge blocks
*SIGNED_BEACON_BLOCK_BASE_MIN, // Base block is smaller than altair and bellatrix blocks
*SIGNED_BEACON_BLOCK_DENEB_MAX, // Deneb block is larger than all prior fork blocks
),
ForkName::Electra => RpcLimits::new(
*SIGNED_BEACON_BLOCK_BASE_MIN, // Base block is smaller than altair and merge blocks
*SIGNED_BEACON_BLOCK_BASE_MIN, // Base block is smaller than altair and bellatrix blocks
*SIGNED_BEACON_BLOCK_ELECTRA_MAX, // Electra block is larger than Deneb block
),
}
@@ -178,7 +178,9 @@ fn rpc_light_client_finality_update_limits_by_fork(current_fork: ForkName) -> Rp
match &current_fork {
ForkName::Base => RpcLimits::new(0, 0),
ForkName::Altair | ForkName::Merge => RpcLimits::new(altair_fixed_len, altair_fixed_len),
ForkName::Altair | ForkName::Bellatrix => {
RpcLimits::new(altair_fixed_len, altair_fixed_len)
}
ForkName::Capella => {
RpcLimits::new(altair_fixed_len, *LIGHT_CLIENT_FINALITY_UPDATE_CAPELLA_MAX)
}
@@ -196,7 +198,9 @@ fn rpc_light_client_optimistic_update_limits_by_fork(current_fork: ForkName) ->
match &current_fork {
ForkName::Base => RpcLimits::new(0, 0),
ForkName::Altair | ForkName::Merge => RpcLimits::new(altair_fixed_len, altair_fixed_len),
ForkName::Altair | ForkName::Bellatrix => {
RpcLimits::new(altair_fixed_len, altair_fixed_len)
}
ForkName::Capella => RpcLimits::new(
altair_fixed_len,
*LIGHT_CLIENT_OPTIMISTIC_UPDATE_CAPELLA_MAX,
@@ -216,7 +220,9 @@ fn rpc_light_client_bootstrap_limits_by_fork(current_fork: ForkName) -> RpcLimit
match &current_fork {
ForkName::Base => RpcLimits::new(0, 0),
ForkName::Altair | ForkName::Merge => RpcLimits::new(altair_fixed_len, altair_fixed_len),
ForkName::Altair | ForkName::Bellatrix => {
RpcLimits::new(altair_fixed_len, altair_fixed_len)
}
ForkName::Capella => RpcLimits::new(altair_fixed_len, *LIGHT_CLIENT_BOOTSTRAP_CAPELLA_MAX),
ForkName::Deneb => RpcLimits::new(altair_fixed_len, *LIGHT_CLIENT_BOOTSTRAP_DENEB_MAX),
ForkName::Electra => RpcLimits::new(altair_fixed_len, *LIGHT_CLIENT_BOOTSTRAP_ELECTRA_MAX),

View File

@@ -1681,12 +1681,16 @@ impl<AppReqId: ReqId, E: EthSpec> Network<AppReqId, E> {
libp2p::upnp::Event::NewExternalAddr(addr) => {
info!(self.log, "UPnP route established"; "addr" => %addr);
let mut iter = addr.iter();
// Skip Ip address.
iter.next();
let is_ip6 = {
let addr = iter.next();
matches!(addr, Some(MProtocol::Ip6(_)))
};
match iter.next() {
Some(multiaddr::Protocol::Udp(udp_port)) => match iter.next() {
Some(multiaddr::Protocol::QuicV1) => {
if let Err(e) = self.discovery_mut().update_enr_quic_port(udp_port) {
if let Err(e) =
self.discovery_mut().update_enr_quic_port(udp_port, is_ip6)
{
warn!(self.log, "Failed to update ENR"; "error" => e);
}
}
@@ -1695,7 +1699,7 @@ impl<AppReqId: ReqId, E: EthSpec> Network<AppReqId, E> {
}
},
Some(multiaddr::Protocol::Tcp(tcp_port)) => {
if let Err(e) = self.discovery_mut().update_enr_tcp_port(tcp_port) {
if let Err(e) = self.discovery_mut().update_enr_tcp_port(tcp_port, is_ip6) {
warn!(self.log, "Failed to update ENR"; "error" => e);
}
}

View File

@@ -10,8 +10,8 @@ use types::{
Attestation, AttesterSlashing, AttesterSlashingBase, AttesterSlashingElectra, BlobSidecar,
EthSpec, ForkContext, ForkName, LightClientFinalityUpdate, LightClientOptimisticUpdate,
ProposerSlashing, SignedAggregateAndProof, SignedBeaconBlock, SignedBeaconBlockAltair,
SignedBeaconBlockBase, SignedBeaconBlockCapella, SignedBeaconBlockDeneb,
SignedBeaconBlockElectra, SignedBeaconBlockMerge, SignedBlsToExecutionChange,
SignedBeaconBlockBase, SignedBeaconBlockBellatrix, SignedBeaconBlockCapella,
SignedBeaconBlockDeneb, SignedBeaconBlockElectra, SignedBlsToExecutionChange,
SignedContributionAndProof, SignedVoluntaryExit, SubnetId, SyncCommitteeMessage, SyncSubnetId,
};
@@ -179,8 +179,8 @@ impl<E: EthSpec> PubsubMessage<E> {
SignedBeaconBlockAltair::from_ssz_bytes(data)
.map_err(|e| format!("{:?}", e))?,
),
Some(ForkName::Merge) => SignedBeaconBlock::<E>::Merge(
SignedBeaconBlockMerge::from_ssz_bytes(data)
Some(ForkName::Bellatrix) => SignedBeaconBlock::<E>::Bellatrix(
SignedBeaconBlockBellatrix::from_ssz_bytes(data)
.map_err(|e| format!("{:?}", e))?,
),
Some(ForkName::Capella) => SignedBeaconBlock::<E>::Capella(
@@ -219,7 +219,7 @@ impl<E: EthSpec> PubsubMessage<E> {
Some(
ForkName::Base
| ForkName::Altair
| ForkName::Merge
| ForkName::Bellatrix
| ForkName::Capella,
)
| None => Err(format!(
@@ -244,7 +244,7 @@ impl<E: EthSpec> PubsubMessage<E> {
match fork_context.from_context_bytes(gossip_topic.fork_digest) {
Some(ForkName::Base)
| Some(ForkName::Altair)
| Some(ForkName::Merge)
| Some(ForkName::Bellatrix)
| Some(ForkName::Capella)
| Some(ForkName::Deneb) => AttesterSlashing::Base(
AttesterSlashingBase::from_ssz_bytes(data)

View File

@@ -47,7 +47,7 @@ pub fn fork_core_topics<E: EthSpec>(fork_name: &ForkName, spec: &ChainSpec) -> V
match fork_name {
ForkName::Base => BASE_CORE_TOPICS.to_vec(),
ForkName::Altair => ALTAIR_CORE_TOPICS.to_vec(),
ForkName::Merge => vec![],
ForkName::Bellatrix => vec![],
ForkName::Capella => CAPELLA_CORE_TOPICS.to_vec(),
ForkName::Deneb => {
// All of deneb blob topics are core topics