fix compilation errors, rename capella -> shanghai, cleanup some rebase issues

This commit is contained in:
realbigsean
2022-04-05 16:55:42 -04:00
parent 809b52715e
commit fe6fc55449
38 changed files with 218 additions and 311 deletions

View File

@@ -21,6 +21,9 @@ const GOSSIP_MAX_SIZE: usize = 1_048_576; // 1M
/// The maximum transmit size of gossip messages in bytes post-merge.
const GOSSIP_MAX_SIZE_POST_MERGE: usize = 10 * 1_048_576; // 10M
const MAX_REQUEST_BLOBS_SIDECARS: usize = 128;
const MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUESTS: usize = 128;
/// The cache time is set to accommodate the circulation time of an attestation.
///
/// The p2p spec declares that we accept attestations within the following range:
@@ -297,7 +300,7 @@ pub fn gossipsub_config(network_load: u8, fork_context: Arc<ForkContext>) -> Gos
// according to: https://github.com/ethereum/consensus-specs/blob/dev/specs/merge/p2p-interface.md#the-gossip-domain-gossipsub
// the derivation of the message-id remains the same in the merge
//TODO(sean): figure this out
ForkName::Altair | ForkName::Merge | ForkName::Shanghai => {
ForkName::Altair | ForkName::Merge | ForkName::Capella => {
let topic_len_bytes = topic_bytes.len().to_le_bytes();
let mut vec = Vec::with_capacity(
prefix.len() + topic_len_bytes.len() + topic_bytes.len() + message.data.len(),

View File

@@ -16,8 +16,8 @@ use std::marker::PhantomData;
use std::sync::Arc;
use tokio_util::codec::{Decoder, Encoder};
use types::{
BlobWrapper, EthSpec, ForkContext, ForkName, SignedBeaconBlock, SignedBeaconBlockAltair,
SignedBeaconBlockBase, SignedBeaconBlockMerge, SignedBeaconBlockShanghai,
BlobsSidecar, EthSpec, ForkContext, ForkName, SignedBeaconBlock, SignedBeaconBlockAltair,
SignedBeaconBlockBase, SignedBeaconBlockCapella, SignedBeaconBlockMerge,
};
use unsigned_varint::codec::Uvi;
@@ -409,8 +409,8 @@ fn context_bytes<T: EthSpec>(
return match **ref_box_block {
// NOTE: If you are adding another fork type here, be sure to modify the
// `fork_context.to_context_bytes()` function to support it as well!
SignedBeaconBlock::Shanghai { .. } => {
fork_context.to_context_bytes(ForkName::Shanghai)
SignedBeaconBlock::Capella { .. } => {
fork_context.to_context_bytes(ForkName::Capella)
}
SignedBeaconBlock::Merge { .. } => {
// Merge context being `None` implies that "merge never happened".
@@ -547,7 +547,7 @@ fn handle_v1_response<T: EthSpec>(
SignedBeaconBlock::Base(SignedBeaconBlockBase::from_ssz_bytes(decoded_buffer)?),
)))),
Protocol::TxBlobsByRange => Ok(Some(RPCResponse::TxBlobsByRange(Arc::new(
BlobWrapper::from_ssz_bytes(decoded_buffer)?),
BlobsSidecar::from_ssz_bytes(decoded_buffer)?),
))),
Protocol::BlocksByRoot => Ok(Some(RPCResponse::BlocksByRoot(Arc::new(
SignedBeaconBlock::Base(SignedBeaconBlockBase::from_ssz_bytes(decoded_buffer)?),
@@ -600,14 +600,14 @@ fn handle_v2_response<T: EthSpec>(
decoded_buffer,
)?),
)))),
ForkName::Shanghai => Ok(Some(RPCResponse::BlocksByRange(Box::new(
SignedBeaconBlock::Shanghai(SignedBeaconBlockShanghai::from_ssz_bytes(
ForkName::Capella => Ok(Some(RPCResponse::BlocksByRange(Box::new(
SignedBeaconBlock::Capella(SignedBeaconBlockCapella::from_ssz_bytes(
decoded_buffer,
)?),
)))),
},
Protocol::TxBlobsByRange => Ok(Some(RPCResponse::TxBlobsByRange(Box::new(
BlobWrapper::from_ssz_bytes(decoded_buffer)?,
BlobsSidecar::from_ssz_bytes(decoded_buffer)?,
)))),
Protocol::BlocksByRoot => match fork_name {
ForkName::Altair => Ok(Some(RPCResponse::BlocksByRoot(Arc::new(
@@ -623,8 +623,8 @@ fn handle_v2_response<T: EthSpec>(
decoded_buffer,
)?),
)))),
ForkName::Shanghai => Ok(Some(RPCResponse::BlocksByRoot(Box::new(
SignedBeaconBlock::Shanghai(SignedBeaconBlockShanghai::from_ssz_bytes(
ForkName::Capella => Ok(Some(RPCResponse::BlocksByRoot(Box::new(
SignedBeaconBlock::Capella(SignedBeaconBlockCapella::from_ssz_bytes(
decoded_buffer,
)?),
)))),

View File

@@ -12,7 +12,7 @@ use std::ops::Deref;
use std::sync::Arc;
use strum::IntoStaticStr;
use superstruct::superstruct;
use types::{BlobWrapper, Epoch, EthSpec, Hash256, SignedBeaconBlock, Slot};
use types::{BlobsSidecar, Epoch, EthSpec, Hash256, SignedBeaconBlock, Slot};
/// Maximum number of blocks in a single request.
pub type MaxRequestBlocks = U1024;
@@ -246,7 +246,7 @@ pub enum RPCResponse<T: EthSpec> {
/// batch.
BlocksByRange(Arc<SignedBeaconBlock<T>>),
TxBlobsByRange(Box<BlobWrapper<T>>),
TxBlobsByRange(Box<BlobsSidecar<T>>),
/// A response to a get BLOCKS_BY_ROOT request.
BlocksByRoot(Arc<SignedBeaconBlock<T>>),

View File

@@ -21,7 +21,7 @@ use tokio_util::{
compat::{Compat, FuturesAsyncReadCompatExt},
};
use types::{
BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockMerge, BlobWrapper, EthSpec,
BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockMerge, BlobsSidecar, EthSpec,
ForkContext, ForkName, Hash256, MainnetEthSpec, Signature, SignedBeaconBlock,
};
@@ -71,11 +71,11 @@ lazy_static! {
+ types::ExecutionPayload::<MainnetEthSpec>::max_execution_payload_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 BLOB_MIN: usize = BlobWrapper::<MainnetEthSpec>::empty()
pub static ref BLOB_MIN: usize = BlobsSidecar::<MainnetEthSpec>::empty()
.as_ssz_bytes()
.len();
pub static ref BLOB_MAX: usize = BlobWrapper::<MainnetEthSpec>::max_size();
pub static ref BLOB_MAX: usize = BlobsSidecar::<MainnetEthSpec>::max_size();
pub static ref BLOCKS_BY_ROOT_REQUEST_MIN: usize =
VariableList::<Hash256, MaxRequestBlocks>::from(Vec::<Hash256>::new())
@@ -120,7 +120,8 @@ const REQUEST_TIMEOUT: u64 = 15;
pub fn max_rpc_size(fork_context: &ForkContext) -> usize {
match fork_context.current_fork() {
ForkName::Merge => MAX_RPC_SIZE_POST_MERGE,
ForkName::Altair | ForkName::Base => MAX_RPC_SIZE,
//FIXME(sean) check this
ForkName::Altair | ForkName::Base | ForkName::Capella => MAX_RPC_SIZE,
}
}

View File

@@ -41,7 +41,7 @@ use std::sync::Arc;
use std::task::{Context, Poll};
use types::{
consts::altair::SYNC_COMMITTEE_SUBNET_COUNT, EnrForkId, EthSpec, ForkContext, Slot, SubnetId,
BlobWrapper, SignedBeaconBlock, SyncSubnetId
BlobsSidecar, SignedBeaconBlock, SyncSubnetId
};
use crate::rpc::methods::TxBlobsByRangeRequest;
use utils::{build_transport, strip_peer_id, MAX_CONNECTIONS_PER_PEER};

View File

@@ -9,9 +9,9 @@ use std::boxed::Box;
use std::io::{Error, ErrorKind};
use std::sync::Arc;
use types::{
Attestation, AttesterSlashing, BlobWrapper, EthSpec, ForkContext, ForkName, ProposerSlashing,
Attestation, AttesterSlashing, BlobsSidecar, EthSpec, ForkContext, ForkName, ProposerSlashing,
SignedAggregateAndProof, SignedBeaconBlock, SignedBeaconBlockAltair, SignedBeaconBlockBase,
SignedBeaconBlockMerge, SignedBeaconBlockShanghai, SignedContributionAndProof,
SignedBeaconBlockCapella, SignedBeaconBlockMerge, SignedContributionAndProof,
SignedVoluntaryExit, SubnetId, SyncCommitteeMessage, SyncSubnetId,
};
@@ -168,8 +168,8 @@ impl<T: EthSpec> PubsubMessage<T> {
SignedBeaconBlockMerge::from_ssz_bytes(data)
.map_err(|e| format!("{:?}", e))?,
),
Some(ForkName::Shanghai) => SignedBeaconBlock::<T>::Shanghai(
SignedBeaconBlockShanghai::from_ssz_bytes(data)
Some(ForkName::Capella) => SignedBeaconBlock::<T>::Capella(
SignedBeaconBlockCapella::from_ssz_bytes(data)
.map_err(|e| format!("{:?}", e))?,
),
None => {
@@ -184,7 +184,7 @@ impl<T: EthSpec> PubsubMessage<T> {
GossipKind::Blob => {
//FIXME(sean) verify against fork context
let blob =
BlobWrapper::from_ssz_bytes(data).map_err(|e| format!("{:?}", e))?;
BlobsSidecar::from_ssz_bytes(data).map_err(|e| format!("{:?}", e))?;
Ok(PubsubMessage::Blob(Box::new(blob)))
}
GossipKind::VoluntaryExit => {