diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 1dba7330e..9f536254a 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -3620,17 +3620,17 @@ impl BeaconChain { .ok_or(BlockProductionError::MissingExecutionPayload)?, }, }), - BeaconState::Shanghai(_) => { + BeaconState::Capella(_) => { let sync_aggregate = get_sync_aggregate()?; let (execution_payload, blobs) = get_execution_payload_and_blobs(self, &state, proposer_index)?; //FIXME(sean) get blobs - BeaconBlock::Shanghai(BeaconBlockShanghai { + BeaconBlock::Capella(BeaconBlockCapella { slot, proposer_index, parent_root, state_root: Hash256::zero(), - body: BeaconBlockBodyShanghai { + body: BeaconBlockBodyCapella { randao_reveal, eth1_data, graffiti, diff --git a/beacon_node/beacon_chain/src/execution_payload.rs b/beacon_node/beacon_chain/src/execution_payload.rs index b0ea743b1..022cfc361 100644 --- a/beacon_node/beacon_chain/src/execution_payload.rs +++ b/beacon_node/beacon_chain/src/execution_payload.rs @@ -388,16 +388,19 @@ pub fn get_execution_payload< } /// Wraps the async `prepare_execution_payload` function as a blocking task. -pub fn prepare_execution_payload_and_blobs_blocking( +pub fn prepare_execution_payload_and_blobs_blocking< + T: BeaconChainTypes, + Payload: ExecPayload, +>( chain: &BeaconChain, state: &BeaconState, proposer_index: u64, ) -> Result< Option<( - ExecutionPayload, + Payload, VariableList< KZGCommitment, - <::EthSpec as EthSpec>::MaxObjectListSize, + <::EthSpec as EthSpec>::MaxBlobsPerBlock, >, )>, BlockProductionError, @@ -409,7 +412,7 @@ pub fn prepare_execution_payload_and_blobs_blocking( execution_layer .block_on_generic(|_| async { - prepare_execution_payload_and_blobs(chain, state, proposer_index).await + prepare_execution_payload_and_blobs::(chain, state, proposer_index).await }) .map_err(BlockProductionError::BlockingFailed)? } @@ -513,100 +516,22 @@ where Ok(execution_payload) } -pub async fn prepare_execution_payload_and_blobs( +pub async fn prepare_execution_payload_and_blobs< + T: BeaconChainTypes, + Payload: ExecPayload, +>( chain: &BeaconChain, state: &BeaconState, proposer_index: u64, ) -> Result< Option<( - ExecutionPayload, + Payload, VariableList< KZGCommitment, - <::EthSpec as EthSpec>::MaxObjectListSize, + <::EthSpec as EthSpec>::MaxBlobsPerBlock, >, )>, BlockProductionError, > { - let spec = &chain.spec; - let execution_layer = chain - .execution_layer - .as_ref() - .ok_or(BlockProductionError::ExecutionLayerMissing)?; - - let parent_hash = if !is_merge_transition_complete(state) { - let is_terminal_block_hash_set = spec.terminal_block_hash != Hash256::zero(); - let is_activation_epoch_reached = - state.current_epoch() >= spec.terminal_block_hash_activation_epoch; - - if is_terminal_block_hash_set && !is_activation_epoch_reached { - return Ok(None); - } - - let terminal_pow_block_hash = execution_layer - .get_terminal_pow_block_hash(spec) - .await - .map_err(BlockProductionError::TerminalPoWBlockLookupFailed)?; - - if let Some(terminal_pow_block_hash) = terminal_pow_block_hash { - terminal_pow_block_hash - } else { - return Ok(None); - } - } else { - state.latest_execution_payload_header()?.block_hash - }; - - let timestamp = compute_timestamp_at_slot(state, spec).map_err(BeaconStateError::from)?; - let random = *state.get_randao_mix(state.current_epoch())?; - let finalized_root = state.finalized_checkpoint().root; - - // The finalized block hash is not included in the specification, however we provide this - // parameter so that the execution layer can produce a payload id if one is not already known - // (e.g., due to a recent reorg). - let finalized_block_hash = - if let Some(block) = chain.fork_choice.read().get_block(&finalized_root) { - block.execution_status.block_hash() - } else { - chain - .store - .get_block(&finalized_root) - .map_err(BlockProductionError::FailedToReadFinalizedBlock)? - .ok_or(BlockProductionError::MissingFinalizedBlock(finalized_root))? - .message() - .body() - .execution_payload() - .ok() - .map(|ep| ep.block_hash) - }; - - // Note: the suggested_fee_recipient is stored in the `execution_layer`, it will add this parameter. - let execution_payload = execution_layer - .get_payload( - parent_hash, - timestamp, - random, - finalized_block_hash.unwrap_or_else(Hash256::zero), - proposer_index, - ) - .await - .map_err(BlockProductionError::GetPayloadFailed)?; - - //FIXME(sean) - for tx in execution_payload.blob_txns_iter() { - let versioned_hash = Hash256::zero(); - // get versioned hash - let blob = execution_layer - .get_blob::( - parent_hash, - timestamp, - random, - finalized_root, - proposer_index, - versioned_hash, - ) - .await - .map_err(BlockProductionError::GetPayloadFailed)?; - } - - Ok(Some((execution_payload, VariableList::empty()))) + todo!() } diff --git a/beacon_node/execution_layer/src/engine_api.rs b/beacon_node/execution_layer/src/engine_api.rs index c82acea63..361953beb 100644 --- a/beacon_node/execution_layer/src/engine_api.rs +++ b/beacon_node/execution_layer/src/engine_api.rs @@ -9,12 +9,9 @@ pub use types::{ Address, EthSpec, ExecutionBlockHash, ExecutionPayload, ExecutionPayloadHeader, FixedVector, Hash256, Uint256, VariableList, }; - -pub mod auth; -use crate::engines::ForkChoiceState; -pub use types::{Address, EthSpec, ExecutionPayload, Hash256, Uint256}; use types::{Blob, KZGCommitment}; +pub mod auth; pub mod http; pub mod json_structures; diff --git a/beacon_node/execution_layer/src/engine_api/http.rs b/beacon_node/execution_layer/src/engine_api/http.rs index 093dad5f1..92c207f79 100644 --- a/beacon_node/execution_layer/src/engine_api/http.rs +++ b/beacon_node/execution_layer/src/engine_api/http.rs @@ -667,10 +667,10 @@ impl HttpJsonRpc { Ok(response.into()) } - async fn get_blob_v1( + pub async fn get_blob_v1( &self, payload_id: PayloadId, - versioned_hash: Hash256, + versioned_hash: ExecutionBlockHash, ) -> Result { let params = json!([JsonPayloadIdRequest::from(payload_id), versioned_hash]); diff --git a/beacon_node/execution_layer/src/lib.rs b/beacon_node/execution_layer/src/lib.rs index fd6886c69..50ea35d76 100644 --- a/beacon_node/execution_layer/src/lib.rs +++ b/beacon_node/execution_layer/src/lib.rs @@ -897,60 +897,7 @@ impl ExecutionLayer { proposer_index: u64, versioned_hash: Hash256, ) -> Result { - let suggested_fee_recipient = self.get_suggested_fee_recipient(proposer_index).await; - - debug!( - self.log(), - "Issuing engine_getBlob"; - "suggested_fee_recipient" => ?suggested_fee_recipient, - "random" => ?random, - "timestamp" => timestamp, - "parent_hash" => ?parent_hash, - ); - self.engines() - .first_success(|engine| async move { - let payload_id = if let Some(id) = engine - .get_payload_id(parent_hash, timestamp, random, suggested_fee_recipient) - .await - { - // The payload id has been cached for this engine. - id - } else { - // The payload id has *not* been cached for this engine. Trigger an artificial - // fork choice update to retrieve a payload ID. - // - // TODO(merge): a better algorithm might try to favour a node that already had a - // cached payload id, since a payload that has had more time to produce is - // likely to be more profitable. - let fork_choice_state = ForkChoiceState { - head_block_hash: parent_hash, - safe_block_hash: parent_hash, - finalized_block_hash, - }; - let payload_attributes = PayloadAttributes { - timestamp, - random, - suggested_fee_recipient, - }; - - engine - .notify_forkchoice_updated( - fork_choice_state, - Some(payload_attributes), - self.log(), - ) - .await - .map(|response| response.payload_id)? - .ok_or(ApiError::PayloadIdUnavailable)? - }; - - engine - .api - .get_blob_v1::(payload_id, versioned_hash) - .await - }) - .await - .map_err(Error::EngineErrors) + todo!() } /// Maps to the `engine_newPayload` JSON-RPC call. diff --git a/beacon_node/lighthouse_network/src/config.rs b/beacon_node/lighthouse_network/src/config.rs index 05139e558..cf3381a94 100644 --- a/beacon_node/lighthouse_network/src/config.rs +++ b/beacon_node/lighthouse_network/src/config.rs @@ -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) -> 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(), diff --git a/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs b/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs index 7e5e11443..58bd9786e 100644 --- a/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs +++ b/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs @@ -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( 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( 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( 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( 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, )?), )))), diff --git a/beacon_node/lighthouse_network/src/rpc/methods.rs b/beacon_node/lighthouse_network/src/rpc/methods.rs index 8aa04866c..db0af5131 100644 --- a/beacon_node/lighthouse_network/src/rpc/methods.rs +++ b/beacon_node/lighthouse_network/src/rpc/methods.rs @@ -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 { /// batch. BlocksByRange(Arc>), - TxBlobsByRange(Box>), + TxBlobsByRange(Box>), /// A response to a get BLOCKS_BY_ROOT request. BlocksByRoot(Arc>), diff --git a/beacon_node/lighthouse_network/src/rpc/protocol.rs b/beacon_node/lighthouse_network/src/rpc/protocol.rs index f3e4a7c4a..d023b3622 100644 --- a/beacon_node/lighthouse_network/src/rpc/protocol.rs +++ b/beacon_node/lighthouse_network/src/rpc/protocol.rs @@ -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::::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::::empty() + pub static ref BLOB_MIN: usize = BlobsSidecar::::empty() .as_ssz_bytes() .len(); - pub static ref BLOB_MAX: usize = BlobWrapper::::max_size(); + pub static ref BLOB_MAX: usize = BlobsSidecar::::max_size(); pub static ref BLOCKS_BY_ROOT_REQUEST_MIN: usize = VariableList::::from(Vec::::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, } } diff --git a/beacon_node/lighthouse_network/src/service/mod.rs b/beacon_node/lighthouse_network/src/service/mod.rs index 73756ba9f..6289712bb 100644 --- a/beacon_node/lighthouse_network/src/service/mod.rs +++ b/beacon_node/lighthouse_network/src/service/mod.rs @@ -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}; diff --git a/beacon_node/lighthouse_network/src/types/pubsub.rs b/beacon_node/lighthouse_network/src/types/pubsub.rs index 72ab12891..780fa215f 100644 --- a/beacon_node/lighthouse_network/src/types/pubsub.rs +++ b/beacon_node/lighthouse_network/src/types/pubsub.rs @@ -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 PubsubMessage { SignedBeaconBlockMerge::from_ssz_bytes(data) .map_err(|e| format!("{:?}", e))?, ), - Some(ForkName::Shanghai) => SignedBeaconBlock::::Shanghai( - SignedBeaconBlockShanghai::from_ssz_bytes(data) + Some(ForkName::Capella) => SignedBeaconBlock::::Capella( + SignedBeaconBlockCapella::from_ssz_bytes(data) .map_err(|e| format!("{:?}", e))?, ), None => { @@ -184,7 +184,7 @@ impl PubsubMessage { 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 => { diff --git a/beacon_node/network/src/beacon_processor/mod.rs b/beacon_node/network/src/beacon_processor/mod.rs index 4e4452075..496142f9a 100644 --- a/beacon_node/network/src/beacon_processor/mod.rs +++ b/beacon_node/network/src/beacon_processor/mod.rs @@ -62,9 +62,9 @@ use std::{cmp, collections::HashSet}; use task_executor::TaskExecutor; use tokio::sync::{mpsc, oneshot}; use types::{ - Attestation, AttesterSlashing, BlobWrapper, Hash256, ProposerSlashing, SignedAggregateAndProof, - SignedBeaconBlock, SignedContributionAndProof, SignedVoluntaryExit, SubnetId, - SyncCommitteeMessage, SyncSubnetId, + Attestation, AttesterSlashing, BlobsSidecar, Hash256, ProposerSlashing, + SignedAggregateAndProof, SignedBeaconBlock, SignedContributionAndProof, SignedVoluntaryExit, + SubnetId, SyncCommitteeMessage, SyncSubnetId, }; use work_reprocessing_queue::{ spawn_reprocess_scheduler, QueuedAggregate, QueuedRpcBlock, QueuedUnaggregate, ReadyWork, @@ -412,7 +412,7 @@ impl WorkEvent { message_id: MessageId, peer_id: PeerId, peer_client: Client, - blob: Box>, + blob: Box>, seen_timestamp: Duration, ) -> Self { Self { @@ -721,7 +721,7 @@ pub enum Work { message_id: MessageId, peer_id: PeerId, peer_client: Client, - blob: Box>, + blob: Box>, seen_timestamp: Duration, }, DelayedImportBlock { diff --git a/beacon_node/network/src/beacon_processor/worker/gossip_methods.rs b/beacon_node/network/src/beacon_processor/worker/gossip_methods.rs index 36981ac9f..e78da09ca 100644 --- a/beacon_node/network/src/beacon_processor/worker/gossip_methods.rs +++ b/beacon_node/network/src/beacon_processor/worker/gossip_methods.rs @@ -18,7 +18,7 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH}; use store::hot_cold_store::HotColdDBError; use tokio::sync::mpsc; use types::{ - Attestation, AttesterSlashing, BlobWrapper, EthSpec, Hash256, IndexedAttestation, + Attestation, AttesterSlashing, BlobsSidecar, EthSpec, Hash256, IndexedAttestation, ProposerSlashing, SignedAggregateAndProof, SignedBeaconBlock, SignedContributionAndProof, SignedVoluntaryExit, Slot, SubnetId, SyncCommitteeMessage, SyncSubnetId, }; @@ -698,7 +698,7 @@ impl Worker { message_id: MessageId, peer_id: PeerId, peer_client: Client, - blob: BlobWrapper, + blob: BlobsSidecar, reprocess_tx: mpsc::Sender>, duplicate_cache: DuplicateCache, seen_duration: Duration, diff --git a/beacon_node/network/src/router/processor.rs b/beacon_node/network/src/router/processor.rs index 11ecdab28..3e9e004d0 100644 --- a/beacon_node/network/src/router/processor.rs +++ b/beacon_node/network/src/router/processor.rs @@ -18,8 +18,9 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH}; use store::SyncCommitteeMessage; use tokio::sync::mpsc; use types::{ - Attestation, AttesterSlashing, BlobWrapper, EthSpec, ProposerSlashing, SignedAggregateAndProof, - SignedBeaconBlock, SignedContributionAndProof, SignedVoluntaryExit, SubnetId, SyncSubnetId, + Attestation, AttesterSlashing, BlobsSidecar, EthSpec, ProposerSlashing, + SignedAggregateAndProof, SignedBeaconBlock, SignedContributionAndProof, SignedVoluntaryExit, + SubnetId, SyncSubnetId, }; /// Processes validated messages from the network. It relays necessary data to the syncing thread @@ -221,7 +222,7 @@ impl Processor { &mut self, peer_id: PeerId, request_id: RequestId, - blob_wrapper: Option>>, + blob_wrapper: Option>>, ) { trace!( self.log, @@ -299,7 +300,7 @@ impl Processor { message_id: MessageId, peer_id: PeerId, peer_client: Client, - blob: Box>, + blob: Box>, ) { self.send_beacon_processor_work(BeaconWorkEvent::gossip_tx_blob_block( message_id, diff --git a/beacon_node/network/src/sync/manager.rs b/beacon_node/network/src/sync/manager.rs index 6110bdf52..1451ffb07 100644 --- a/beacon_node/network/src/sync/manager.rs +++ b/beacon_node/network/src/sync/manager.rs @@ -53,7 +53,7 @@ use std::ops::Sub; use std::sync::Arc; use std::time::Duration; use tokio::sync::mpsc; -use types::{BlobWrapper, Epoch, EthSpec, Hash256, SignedBeaconBlock, Slot}; +use types::{BlobsSidecar, Epoch, EthSpec, Hash256, SignedBeaconBlock, Slot}; /// The number of slots ahead of us that is allowed before requesting a long-range (batch) Sync /// from a peer. If a peer is within this tolerance (forwards or backwards), it is treated as a @@ -88,14 +88,16 @@ pub enum SyncMessage { /// A block has been received from the RPC. RpcBlock { request_id: RequestId, + peer_id: PeerId, beacon_block: Option>>, + seen_timestamp: Duration, }, /// A [`TxBlobsByRangeResponse`] response has been received. TxBlobsByRangeResponse { peer_id: PeerId, request_id: RequestId, - blob_wrapper: Option>>, + blob_wrapper: Option>>, }, /// A [`BlocksByRoot`] response has been received. diff --git a/beacon_node/network/src/sync/range_sync/range.rs b/beacon_node/network/src/sync/range_sync/range.rs index d7a0d86cd..39696f2b6 100644 --- a/beacon_node/network/src/sync/range_sync/range.rs +++ b/beacon_node/network/src/sync/range_sync/range.rs @@ -55,7 +55,7 @@ use lru_cache::LRUTimeCache; use slog::{crit, debug, trace, warn}; use std::collections::HashMap; use std::sync::Arc; -use types::{BlobWrapper, Epoch, EthSpec, Hash256, SignedBeaconBlock, Slot}; +use types::{BlobsSidecar, Epoch, EthSpec, Hash256, SignedBeaconBlock, Slot}; /// For how long we store failed finalized chains to prevent retries. const FAILED_CHAINS_EXPIRY_SECONDS: u64 = 30; diff --git a/beacon_node/store/src/partial_beacon_state.rs b/beacon_node/store/src/partial_beacon_state.rs index 1e52e9856..66b517b77 100644 --- a/beacon_node/store/src/partial_beacon_state.rs +++ b/beacon_node/store/src/partial_beacon_state.rs @@ -14,7 +14,7 @@ use types::*; /// /// Utilises lazy-loading from separate storage for its vector fields. #[superstruct( - variants(Base, Altair, Merge, Shanghai), + variants(Base, Altair, Merge, Capella), variant_attributes(derive(Debug, PartialEq, Clone, Encode, Decode)) )] #[derive(Debug, PartialEq, Clone, Encode)] @@ -66,9 +66,9 @@ where pub current_epoch_attestations: VariableList, T::MaxPendingAttestations>, // Participation (Altair and later) - #[superstruct(only(Altair, Merge, Shanghai))] + #[superstruct(only(Altair, Merge, Capella))] pub previous_epoch_participation: VariableList, - #[superstruct(only(Altair, Merge, Shanghai))] + #[superstruct(only(Altair, Merge, Capella))] pub current_epoch_participation: VariableList, // Finality @@ -78,17 +78,17 @@ where pub finalized_checkpoint: Checkpoint, // Inactivity - #[superstruct(only(Altair, Merge, Shanghai))] + #[superstruct(only(Altair, Merge, Capella))] pub inactivity_scores: VariableList, // Light-client sync committees - #[superstruct(only(Altair, Merge, Shanghai))] + #[superstruct(only(Altair, Merge, Capella))] pub current_sync_committee: Arc>, - #[superstruct(only(Altair, Merge, Shanghai))] + #[superstruct(only(Altair, Merge, Capella))] pub next_sync_committee: Arc>, // Execution - #[superstruct(only(Merge, Shanghai))] + #[superstruct(only(Merge, Capella))] pub latest_execution_payload_header: ExecutionPayloadHeader, } @@ -178,11 +178,11 @@ impl PartialBeaconState { latest_execution_payload_header ] ), - BeaconState::Shanghai(s) => impl_from_state_forgetful!( + BeaconState::Capella(s) => impl_from_state_forgetful!( s, outer, - Shanghai, - PartialBeaconStateShanghai, + Capella, + PartialBeaconStateCapella, [ previous_epoch_participation, current_epoch_participation, @@ -379,10 +379,10 @@ impl TryInto> for PartialBeaconState { latest_execution_payload_header ] ), - PartialBeaconState::Shanghai(inner) => impl_try_into_beacon_state!( + PartialBeaconState::Capella(inner) => impl_try_into_beacon_state!( inner, - Shanghai, - BeaconStateShanghai, + Capella, + BeaconStateCapella, [ previous_epoch_participation, current_epoch_participation, diff --git a/consensus/state_processing/src/common/slash_validator.rs b/consensus/state_processing/src/common/slash_validator.rs index 23bd35bf6..6351fdcc3 100644 --- a/consensus/state_processing/src/common/slash_validator.rs +++ b/consensus/state_processing/src/common/slash_validator.rs @@ -45,7 +45,7 @@ pub fn slash_validator( validator_effective_balance.safe_div(spec.whistleblower_reward_quotient)?; let proposer_reward = match state { BeaconState::Base(_) => whistleblower_reward.safe_div(spec.proposer_reward_quotient)?, - BeaconState::Altair(_) | BeaconState::Merge(_) | BeaconState::Shanghai(_) => { + BeaconState::Altair(_) | BeaconState::Merge(_) | BeaconState::Capella(_) => { whistleblower_reward .safe_mul(PROPOSER_WEIGHT)? .safe_div(WEIGHT_DENOMINATOR)? diff --git a/consensus/state_processing/src/per_block_processing/process_operations.rs b/consensus/state_processing/src/per_block_processing/process_operations.rs index 10b0e5f9b..71b4ee535 100644 --- a/consensus/state_processing/src/per_block_processing/process_operations.rs +++ b/consensus/state_processing/src/per_block_processing/process_operations.rs @@ -232,7 +232,7 @@ pub fn process_attestations<'a, T: EthSpec, Payload: ExecPayload>( } BeaconBlockBodyRef::Altair(_) | BeaconBlockBodyRef::Merge(_) - | BeaconBlockBodyRef::Shanghai(_) => { + | BeaconBlockBodyRef::Capella(_) => { altair::process_attestations( state, block_body.attestations(), diff --git a/consensus/state_processing/src/per_epoch_processing.rs b/consensus/state_processing/src/per_epoch_processing.rs index 8074a32ed..fc93ab79b 100644 --- a/consensus/state_processing/src/per_epoch_processing.rs +++ b/consensus/state_processing/src/per_epoch_processing.rs @@ -37,7 +37,7 @@ pub fn process_epoch( match state { BeaconState::Base(_) => base::process_epoch(state, spec), - BeaconState::Altair(_) | BeaconState::Merge(_) | BeaconState::Shanghai(_) => { + BeaconState::Altair(_) | BeaconState::Merge(_) | BeaconState::Capella(_) => { altair::process_epoch(state, spec) } } diff --git a/consensus/types/src/beacon_block.rs b/consensus/types/src/beacon_block.rs index dee3292a8..199b7601d 100644 --- a/consensus/types/src/beacon_block.rs +++ b/consensus/types/src/beacon_block.rs @@ -1,6 +1,6 @@ use crate::beacon_block_body::{ - BeaconBlockBodyAltair, BeaconBlockBodyBase, BeaconBlockBodyMerge, BeaconBlockBodyRef, - BeaconBlockBodyRefMut, BeaconBlockBodyShanghai, + BeaconBlockBodyAltair, BeaconBlockBodyBase, BeaconBlockBodyCapella, BeaconBlockBodyMerge, + BeaconBlockBodyRef, BeaconBlockBodyRefMut, }; use crate::test_utils::TestRandom; use crate::*; @@ -17,7 +17,7 @@ use tree_hash_derive::TreeHash; /// A block of the `BeaconChain`. #[superstruct( - variants(Base, Altair, Merge, Shanghai), + variants(Base, Altair, Merge, Capella), variant_attributes( derive( Debug, @@ -64,8 +64,8 @@ pub struct BeaconBlock = FullPayload> { pub body: BeaconBlockBodyAltair, #[superstruct(only(Merge), partial_getter(rename = "body_merge"))] pub body: BeaconBlockBodyMerge, - #[superstruct(only(Shanghai), partial_getter(rename = "body_shanghai"))] - pub body: BeaconBlockBodyShanghai, + #[superstruct(only(Capella), partial_getter(rename = "body_capella"))] + pub body: BeaconBlockBodyCapella, } pub type BlindedBeaconBlock = BeaconBlock>; @@ -191,7 +191,7 @@ impl<'a, T: EthSpec, Payload: ExecPayload> BeaconBlockRef<'a, T, Payload> { BeaconBlockRef::Base { .. } => ForkName::Base, BeaconBlockRef::Altair { .. } => ForkName::Altair, BeaconBlockRef::Merge { .. } => ForkName::Merge, - BeaconBlockRef::Shanghai { .. } => ForkName::Shanghai, + BeaconBlockRef::Capella { .. } => ForkName::Capella, }; if fork_at_slot == object_fork { diff --git a/consensus/types/src/beacon_block_body.rs b/consensus/types/src/beacon_block_body.rs index 438d9535c..d48515440 100644 --- a/consensus/types/src/beacon_block_body.rs +++ b/consensus/types/src/beacon_block_body.rs @@ -13,7 +13,7 @@ use tree_hash_derive::TreeHash; /// /// This *superstruct* abstracts over the hard-fork. #[superstruct( - variants(Base, Altair, Merge, Shanghai), + variants(Base, Altair, Merge, Capella), variant_attributes( derive( Debug, @@ -47,16 +47,16 @@ pub struct BeaconBlockBody = FullPayload> pub attestations: VariableList, T::MaxAttestations>, pub deposits: VariableList, pub voluntary_exits: VariableList, - #[superstruct(only(Altair, Merge, Shanghai))] + #[superstruct(only(Altair, Merge, Capella))] pub sync_aggregate: SyncAggregate, // We flatten the execution payload so that serde can use the name of the inner type, // either `execution_payload` for full payloads, or `execution_payload_header` for blinded // payloads. - #[superstruct(only(Merge, Shanghai))] + #[superstruct(only(Merge, Capella))] #[serde(flatten)] pub execution_payload: Payload, - #[superstruct(only(Shanghai))] - pub blob_kzgs: VariableList, + #[superstruct(only(Capella))] + pub blob_kzgs: VariableList, #[superstruct(only(Base, Altair))] #[ssz(skip_serializing, skip_deserializing)] #[tree_hash(skip_hashing)] @@ -71,7 +71,7 @@ impl<'a, T: EthSpec> BeaconBlockBodyRef<'a, T> { BeaconBlockBodyRef::Base { .. } => ForkName::Base, BeaconBlockBodyRef::Altair { .. } => ForkName::Altair, BeaconBlockBodyRef::Merge { .. } => ForkName::Merge, - BeaconBlockBodyRef::Shanghai { .. } => ForkName::Shanghai, + BeaconBlockBodyRef::Capella { .. } => ForkName::Capella, } } } diff --git a/consensus/types/src/beacon_state.rs b/consensus/types/src/beacon_state.rs index eb4be019f..8a5cdda9b 100644 --- a/consensus/types/src/beacon_state.rs +++ b/consensus/types/src/beacon_state.rs @@ -172,7 +172,7 @@ impl From for Hash256 { /// The state of the `BeaconChain` at some slot. #[superstruct( - variants(Base, Altair, Merge, Shanghai), + variants(Base, Altair, Merge, Capella), variant_attributes( derive( Derivative, @@ -250,9 +250,9 @@ where pub current_epoch_attestations: VariableList, T::MaxPendingAttestations>, // Participation (Altair and later) - #[superstruct(only(Altair, Merge, Shanghai))] + #[superstruct(only(Altair, Merge, Capella))] pub previous_epoch_participation: VariableList, - #[superstruct(only(Altair, Merge, Shanghai))] + #[superstruct(only(Altair, Merge, Capella))] pub current_epoch_participation: VariableList, // Finality @@ -267,17 +267,17 @@ where // Inactivity #[serde(with = "ssz_types::serde_utils::quoted_u64_var_list")] - #[superstruct(only(Altair, Merge, Shanghai))] + #[superstruct(only(Altair, Merge, Capella))] pub inactivity_scores: VariableList, // Light-client sync committees - #[superstruct(only(Altair, Merge, Shanghai))] + #[superstruct(only(Altair, Merge, Capella))] pub current_sync_committee: Arc>, - #[superstruct(only(Altair, Merge, Shanghai))] + #[superstruct(only(Altair, Merge, Capella))] pub next_sync_committee: Arc>, // Execution - #[superstruct(only(Merge, Shanghai))] + #[superstruct(only(Merge, Capella))] pub latest_execution_payload_header: ExecutionPayloadHeader, // Caching (not in the spec) @@ -389,7 +389,7 @@ impl BeaconState { BeaconState::Base { .. } => ForkName::Base, BeaconState::Altair { .. } => ForkName::Altair, BeaconState::Merge { .. } => ForkName::Merge, - BeaconState::Shanghai { .. } => ForkName::Shanghai, + BeaconState::Capella { .. } => ForkName::Capella, }; if fork_at_slot == object_fork { @@ -1103,7 +1103,7 @@ impl BeaconState { BeaconState::Base(state) => (&mut state.validators, &mut state.balances), BeaconState::Altair(state) => (&mut state.validators, &mut state.balances), BeaconState::Merge(state) => (&mut state.validators, &mut state.balances), - BeaconState::Shanghai(state) => (&mut state.validators, &mut state.balances), + BeaconState::Capella(state) => (&mut state.validators, &mut state.balances), } } @@ -1300,14 +1300,14 @@ impl BeaconState { BeaconState::Base(_) => Err(BeaconStateError::IncorrectStateVariant), BeaconState::Altair(state) => Ok(&mut state.current_epoch_participation), BeaconState::Merge(state) => Ok(&mut state.current_epoch_participation), - BeaconState::Shanghai(state) => Ok(&mut state.current_epoch_participation), + BeaconState::Capella(state) => Ok(&mut state.current_epoch_participation), } } else if epoch == self.previous_epoch() { match self { BeaconState::Base(_) => Err(BeaconStateError::IncorrectStateVariant), BeaconState::Altair(state) => Ok(&mut state.previous_epoch_participation), BeaconState::Merge(state) => Ok(&mut state.previous_epoch_participation), - BeaconState::Shanghai(state) => Ok(&mut state.previous_epoch_participation), + BeaconState::Capella(state) => Ok(&mut state.previous_epoch_participation), } } else { Err(BeaconStateError::EpochOutOfBounds) @@ -1612,7 +1612,7 @@ impl BeaconState { BeaconState::Base(inner) => BeaconState::Base(inner.clone()), BeaconState::Altair(inner) => BeaconState::Altair(inner.clone()), BeaconState::Merge(inner) => BeaconState::Merge(inner.clone()), - BeaconState::Shanghai(inner) => BeaconState::Shanghai(inner.clone()), + BeaconState::Capella(inner) => BeaconState::Capella(inner.clone()), }; if config.committee_caches { *res.committee_caches_mut() = self.committee_caches().clone(); diff --git a/consensus/types/src/blob_wrapper.rs b/consensus/types/src/blobs_sidecar.rs similarity index 72% rename from consensus/types/src/blob_wrapper.rs rename to consensus/types/src/blobs_sidecar.rs index 7960403a7..e8644af15 100644 --- a/consensus/types/src/blob_wrapper.rs +++ b/consensus/types/src/blobs_sidecar.rs @@ -8,13 +8,13 @@ use tree_hash_derive::TreeHash; #[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(Debug, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, PartialEq, Default)] -pub struct BlobWrapper { +pub struct BlobsSidecar { pub beacon_block_root: Hash256, pub beacon_block_slot: Slot, - pub blobs: VariableList, E::MaxObjectListSize>, + pub blobs: VariableList, E::MaxBlobsPerBlock>, } -impl BlobWrapper { +impl BlobsSidecar { pub fn empty() -> Self { Self::default() } @@ -22,6 +22,6 @@ impl BlobWrapper { // Fixed part Self::empty().as_ssz_bytes().len() // Max size of variable length `blobs` field - + (E::max_object_list_size() * as Encode>::ssz_fixed_len()) + + (E::max_object_list_size() * as Encode>::ssz_fixed_len()) } } diff --git a/consensus/types/src/chain_spec.rs b/consensus/types/src/chain_spec.rs index 4f62022fb..9f25208b9 100644 --- a/consensus/types/src/chain_spec.rs +++ b/consensus/types/src/chain_spec.rs @@ -22,6 +22,8 @@ pub enum Domain { ContributionAndProof, SyncCommitteeSelectionProof, ApplicationMask(ApplicationDomain), + //FIXME(sean) add this domain + //BlobsSideCar, } /// Lighthouse's internal configuration struct. @@ -151,10 +153,10 @@ pub struct ChainSpec { pub safe_slots_to_import_optimistically: u64, /* - * Shanghai hard fork params + * Capella hard fork params */ - pub shanghai_fork_version: [u8; 4], - pub shanghai_fork_epoch: Option, + pub capella_fork_version: [u8; 4], + pub capella_fork_epoch: Option, /* * Networking @@ -236,8 +238,8 @@ impl ChainSpec { /// Returns the name of the fork which is active at `epoch`. pub fn fork_name_at_epoch(&self, epoch: Epoch) -> ForkName { - match self.shanghai_fork_epoch { - Some(fork_epoch) if epoch >= fork_epoch => ForkName::Shanghai, + match self.capella_fork_epoch { + Some(fork_epoch) if epoch >= fork_epoch => ForkName::Capella, _ => match self.bellatrix_fork_epoch { Some(fork_epoch) if epoch >= fork_epoch => ForkName::Merge, _ => match self.altair_fork_epoch { @@ -254,7 +256,7 @@ impl ChainSpec { ForkName::Base => self.genesis_fork_version, ForkName::Altair => self.altair_fork_version, ForkName::Merge => self.bellatrix_fork_version, - ForkName::Shanghai => self.shanghai_fork_version, + ForkName::Capella => self.capella_fork_version, } } @@ -264,7 +266,7 @@ impl ChainSpec { ForkName::Base => Some(Epoch::new(0)), ForkName::Altair => self.altair_fork_epoch, ForkName::Merge => self.bellatrix_fork_epoch, - ForkName::Shanghai => self.shanghai_fork_epoch, + ForkName::Capella => self.capella_fork_epoch, } } @@ -274,7 +276,7 @@ impl ChainSpec { BeaconState::Base(_) => self.inactivity_penalty_quotient, BeaconState::Altair(_) => self.inactivity_penalty_quotient_altair, BeaconState::Merge(_) => self.inactivity_penalty_quotient_bellatrix, - BeaconState::Shanghai(_) => self.inactivity_penalty_quotient_bellatrix, + BeaconState::Capella(_) => self.inactivity_penalty_quotient_bellatrix, } } @@ -287,7 +289,7 @@ impl ChainSpec { BeaconState::Base(_) => self.proportional_slashing_multiplier, BeaconState::Altair(_) => self.proportional_slashing_multiplier_altair, BeaconState::Merge(_) => self.proportional_slashing_multiplier_bellatrix, - BeaconState::Shanghai(_) => self.proportional_slashing_multiplier_bellatrix, + BeaconState::Capella(_) => self.proportional_slashing_multiplier_bellatrix, } } @@ -300,7 +302,7 @@ impl ChainSpec { BeaconState::Base(_) => self.min_slashing_penalty_quotient, BeaconState::Altair(_) => self.min_slashing_penalty_quotient_altair, BeaconState::Merge(_) => self.min_slashing_penalty_quotient_bellatrix, - BeaconState::Shanghai(_) => self.min_slashing_penalty_quotient_bellatrix, + BeaconState::Capella(_) => self.min_slashing_penalty_quotient_bellatrix, } } @@ -583,12 +585,11 @@ impl ChainSpec { safe_slots_to_import_optimistically: 128u64, /* - * Shanghai hardfork params + * Capella hardfork params */ //FIXME(sean) - shanghai_fork_version: [0x03, 0x00, 0x00, 0x00], - shanghai_fork_epoch: None, - + capella_fork_version: [0x03, 0x00, 0x00, 0x00], + capella_fork_epoch: None, /* * Network specific */ @@ -644,10 +645,10 @@ impl ChainSpec { // `Uint256::MAX` which is `2*256- 1`. .checked_add(Uint256::one()) .expect("addition does not overflow"), - // Shanghai + // Capella //FIXME(sean) - shanghai_fork_version: [0x03, 0x00, 0x00, 0x01], - shanghai_fork_epoch: None, + capella_fork_version: [0x03, 0x00, 0x00, 0x01], + capella_fork_epoch: None, // Other network_id: 2, // lighthouse testnet network id deposit_chain_id: 5, @@ -804,8 +805,8 @@ impl ChainSpec { safe_slots_to_import_optimistically: 128u64, //FIXME(sean) - shanghai_fork_version: [0x03, 0x00, 0x00, 0x64], - shanghai_fork_epoch: None, + capella_fork_version: [0x03, 0x00, 0x00, 0x64], + capella_fork_epoch: None, /* * Network specific @@ -883,14 +884,14 @@ pub struct Config { pub bellatrix_fork_epoch: Option>, // FIXME(sean): remove this default - #[serde(default = "default_shanghai_fork_version")] + #[serde(default = "default_capella_fork_version")] #[serde(with = "eth2_serde_utils::bytes_4_hex")] - shanghai_fork_version: [u8; 4], + capella_fork_version: [u8; 4], // FIXME(sean): remove this default - #[serde(default = "default_shanghai_fork_epoch")] + #[serde(default = "default_capella_fork_epoch")] #[serde(serialize_with = "serialize_fork_epoch")] #[serde(deserialize_with = "deserialize_fork_epoch")] - pub shanghai_fork_epoch: Option>, + pub capella_fork_epoch: Option>, #[serde(with = "eth2_serde_utils::quoted_u64")] seconds_per_slot: u64, @@ -929,7 +930,7 @@ fn default_bellatrix_fork_version() -> [u8; 4] { [0xff, 0xff, 0xff, 0xff] } -fn default_shanghai_fork_version() -> [u8; 4] { +fn default_capella_fork_version() -> [u8; 4] { // This value shouldn't be used. [0xff, 0xff, 0xff, 0xff] } @@ -1030,9 +1031,9 @@ impl Config { bellatrix_fork_epoch: spec .bellatrix_fork_epoch .map(|epoch| MaybeQuoted { value: epoch }), - shanghai_fork_version: spec.shanghai_fork_version, - shanghai_fork_epoch: spec - .shanghai_fork_epoch + capella_fork_version: spec.capella_fork_version, + capella_fork_epoch: spec + .capella_fork_epoch .map(|epoch| MaybeQuoted { value: epoch }), seconds_per_slot: spec.seconds_per_slot, @@ -1079,8 +1080,8 @@ impl Config { altair_fork_epoch, bellatrix_fork_epoch, bellatrix_fork_version, - shanghai_fork_epoch, - shanghai_fork_version, + capella_fork_epoch, + capella_fork_version, seconds_per_slot, seconds_per_eth1_block, min_validator_withdrawability_delay, @@ -1111,8 +1112,8 @@ impl Config { altair_fork_epoch: altair_fork_epoch.map(|q| q.value), bellatrix_fork_epoch: bellatrix_fork_epoch.map(|q| q.value), bellatrix_fork_version, - shanghai_fork_epoch: shanghai_fork_epoch.map(|q| q.value), - shanghai_fork_version, + capella_fork_epoch: capella_fork_epoch.map(|q| q.value), + capella_fork_version, seconds_per_slot, seconds_per_eth1_block, min_validator_withdrawability_delay, diff --git a/consensus/types/src/consts.rs b/consensus/types/src/consts.rs index a9377bc3e..8e12b05fb 100644 --- a/consensus/types/src/consts.rs +++ b/consensus/types/src/consts.rs @@ -22,3 +22,16 @@ pub mod altair { pub mod merge { pub const INTERVALS_PER_SLOT: u64 = 3; } +pub mod cappella { + use crate::Uint256; + + use lazy_static::lazy_static; + + lazy_static! { + pub static ref BLS_MODULUS: Uint256 = Uint256::from_dec_str( + "52435875175126190479447740508185965837690552500527637822603658699938581184513" + ) + .expect("should initialize BLS_MODULUS"); + } + pub const BLOB_TX_TYPE: u8 = 5; +} diff --git a/consensus/types/src/eth_spec.rs b/consensus/types/src/eth_spec.rs index 6bf462b02..a55446669 100644 --- a/consensus/types/src/eth_spec.rs +++ b/consensus/types/src/eth_spec.rs @@ -96,10 +96,10 @@ pub trait EthSpec: 'static + Default + Sync + Send + Clone + Debug + PartialEq + type MinGasLimit: Unsigned + Clone + Sync + Send + Debug + PartialEq; type MaxExtraDataBytes: Unsigned + Clone + Sync + Send + Debug + PartialEq; /* - * New in Shanghaisharding + * New in Capella */ - type MaxObjectListSize: Unsigned + Clone + Sync + Send + Debug + PartialEq; - type ChunksPerBlob: Unsigned + Clone + Sync + Send + Debug + PartialEq; + type MaxBlobsPerBlock: Unsigned + Clone + Sync + Send + Debug + PartialEq; + type FieldElementsPerBlob: Unsigned + Clone + Sync + Send + Debug + PartialEq; /* * Derived values (set these CAREFULLY) */ @@ -229,11 +229,11 @@ pub trait EthSpec: 'static + Default + Sync + Send + Clone + Debug + PartialEq + } fn max_object_list_size() -> usize { - Self::MaxObjectListSize::to_usize() + Self::MaxBlobsPerBlock::to_usize() } fn chunks_per_blob() -> usize { - Self::ChunksPerBlob::to_usize() + Self::FieldElementsPerBlob::to_usize() } } @@ -275,8 +275,8 @@ impl EthSpec for MainnetEthSpec { type GasLimitDenominator = U1024; type MinGasLimit = U5000; type MaxExtraDataBytes = U32; - type MaxObjectListSize = U16777216; // 2**24 - type ChunksPerBlob = U4096; + type MaxBlobsPerBlock = U16777216; // 2**24 + type FieldElementsPerBlob = U4096; type SyncSubcommitteeSize = U128; // 512 committee size / 4 sync committee subnet count type MaxPendingAttestations = U4096; // 128 max attestations * 32 slots per epoch type SlotsPerEth1VotingPeriod = U2048; // 64 epochs * 32 slots per epoch @@ -325,8 +325,8 @@ impl EthSpec for MinimalEthSpec { GasLimitDenominator, MinGasLimit, MaxExtraDataBytes, - MaxObjectListSize, - ChunksPerBlob + MaxBlobsPerBlock, + FieldElementsPerBlob }); fn default_spec() -> ChainSpec { @@ -371,8 +371,8 @@ impl EthSpec for GnosisEthSpec { type SyncSubcommitteeSize = U128; // 512 committee size / 4 sync committee subnet count type MaxPendingAttestations = U2048; // 128 max attestations * 16 slots per epoch type SlotsPerEth1VotingPeriod = U1024; // 64 epochs * 16 slots per epoch - type MaxObjectListSize = U16777216; // 2**24 - type ChunksPerBlob = U4096; + type MaxBlobsPerBlock = U16777216; // 2**24 + type FieldElementsPerBlob = U4096; fn default_spec() -> ChainSpec { ChainSpec::gnosis() diff --git a/consensus/types/src/fork_context.rs b/consensus/types/src/fork_context.rs index 742136ca9..90d1fbc68 100644 --- a/consensus/types/src/fork_context.rs +++ b/consensus/types/src/fork_context.rs @@ -47,10 +47,10 @@ impl ForkContext { )); } - if spec.shanghai_fork_epoch.is_some() { + if spec.capella_fork_epoch.is_some() { fork_to_digest.push(( - ForkName::Shanghai, - ChainSpec::compute_fork_digest(spec.shanghai_fork_version, genesis_validators_root), + ForkName::Capella, + ChainSpec::compute_fork_digest(spec.capella_fork_version, genesis_validators_root), )); } diff --git a/consensus/types/src/fork_name.rs b/consensus/types/src/fork_name.rs index 88108ffa3..a87e2b521 100644 --- a/consensus/types/src/fork_name.rs +++ b/consensus/types/src/fork_name.rs @@ -11,7 +11,7 @@ pub enum ForkName { Base, Altair, Merge, - Shanghai, + Capella, } impl ForkName { @@ -39,9 +39,9 @@ impl ForkName { spec.bellatrix_fork_epoch = Some(Epoch::new(0)); spec } - ForkName::Shanghai => { + ForkName::Capella => { spec.bellatrix_fork_epoch = Some(Epoch::new(0)); - spec.shanghai_fork_epoch = Some(Epoch::new(0)); + spec.capella_fork_epoch = Some(Epoch::new(0)); spec } } @@ -55,7 +55,7 @@ impl ForkName { ForkName::Base => None, ForkName::Altair => Some(ForkName::Base), ForkName::Merge => Some(ForkName::Altair), - ForkName::Shanghai => Some(ForkName::Merge), + ForkName::Capella => Some(ForkName::Merge), } } @@ -66,8 +66,8 @@ impl ForkName { match self { ForkName::Base => Some(ForkName::Altair), ForkName::Altair => Some(ForkName::Merge), - ForkName::Merge => Some(ForkName::Shanghai), - ForkName::Shanghai => None, + ForkName::Merge => Some(ForkName::Capella), + ForkName::Capella => None, } } } @@ -110,7 +110,7 @@ macro_rules! map_fork_name_with { ($t::Merge(value), extra_data) } //TODO: don't have a beacon state variant for the new fork yet - ForkName::Shanghai => { + ForkName::Capella => { let (value, extra_data) = $body; ($t::Merge(value), extra_data) } @@ -137,7 +137,7 @@ impl Display for ForkName { ForkName::Base => "phase0".fmt(f), ForkName::Altair => "altair".fmt(f), ForkName::Merge => "bellatrix".fmt(f), - ForkName::Shanghai => "shanghai".fmt(f), + ForkName::Capella => "capella".fmt(f), } } } diff --git a/consensus/types/src/lib.rs b/consensus/types/src/lib.rs index 804b82a24..b1437650b 100644 --- a/consensus/types/src/lib.rs +++ b/consensus/types/src/lib.rs @@ -86,11 +86,13 @@ pub mod sync_subnet_id; mod tree_hash_impls; pub mod validator_registration_data; -mod blob_wrapper; +mod blobs_sidecar; mod kzg_commitment; +mod signed_blobs_sidecar; pub mod slot_data; #[cfg(feature = "sqlite")] pub mod sqlite; + pub use kzg_commitment::KZGCommitment; use ethereum_types::{H160, H256}; @@ -101,17 +103,17 @@ pub use crate::attestation_data::AttestationData; pub use crate::attestation_duty::AttestationDuty; pub use crate::attester_slashing::AttesterSlashing; pub use crate::beacon_block::{ - BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockShanghai, BeaconBlockMerge, BeaconBlockRef, + BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockCapella, BeaconBlockMerge, BeaconBlockRef, BeaconBlockRefMut, BlindedBeaconBlock, }; pub use crate::beacon_block_body::{ - BeaconBlockBody, BeaconBlockBodyAltair, BeaconBlockBodyBase, BeaconBlockBodyMerge, - BeaconBlockBodyRef, BeaconBlockBodyRefMut, BeaconBlockBodyShanghai, + BeaconBlockBody, BeaconBlockBodyAltair, BeaconBlockBodyBase, BeaconBlockBodyCapella, + BeaconBlockBodyMerge, BeaconBlockBodyRef, BeaconBlockBodyRefMut, }; pub use crate::beacon_block_header::BeaconBlockHeader; pub use crate::beacon_committee::{BeaconCommittee, OwnedBeaconCommittee}; pub use crate::beacon_state::{BeaconTreeHashCache, Error as BeaconStateError, *}; -pub use crate::blob_wrapper::BlobWrapper; +pub use crate::blobs_sidecar::BlobsSidecar; pub use crate::chain_spec::{ChainSpec, Config, Domain}; pub use crate::checkpoint::Checkpoint; pub use crate::config_and_preset::{ @@ -148,7 +150,7 @@ pub use crate::shuffling_id::AttestationShufflingId; pub use crate::signed_aggregate_and_proof::SignedAggregateAndProof; pub use crate::signed_beacon_block::{ SignedBeaconBlock, SignedBeaconBlockAltair, SignedBeaconBlockBase, SignedBeaconBlockHash, - SignedBeaconBlockMerge, SignedBlindedBeaconBlock,SignedBeaconBlockShanghai + SignedBeaconBlockMerge, SignedBlindedBeaconBlock,SignedBeaconBlockCapella }; pub use crate::signed_beacon_block_header::SignedBeaconBlockHeader; pub use crate::signed_contribution_and_proof::SignedContributionAndProof; diff --git a/consensus/types/src/signed_beacon_block.rs b/consensus/types/src/signed_beacon_block.rs index 49822da82..de8b65f50 100644 --- a/consensus/types/src/signed_beacon_block.rs +++ b/consensus/types/src/signed_beacon_block.rs @@ -38,7 +38,7 @@ impl From for Hash256 { /// A `BeaconBlock` and a signature from its proposer. #[superstruct( - variants(Base, Altair, Merge, Shanghai), + variants(Base, Altair, Merge, Capella), variant_attributes( derive( Debug, @@ -72,8 +72,8 @@ pub struct SignedBeaconBlock = FullPayload, #[superstruct(only(Merge), partial_getter(rename = "message_merge"))] pub message: BeaconBlockMerge, - #[superstruct(only(Shanghai), partial_getter(rename = "message_shanghai"))] - pub message: BeaconBlockShanghai, + #[superstruct(only(Capella), partial_getter(rename = "message_capella"))] + pub message: BeaconBlockCapella, pub signature: Signature, } @@ -131,8 +131,8 @@ impl> SignedBeaconBlock { BeaconBlock::Merge(message) => { SignedBeaconBlock::Merge(SignedBeaconBlockMerge { message, signature }) } - BeaconBlock::Shanghai(message) => { - SignedBeaconBlock::Shanghai(SignedBeaconBlockShanghai { message, signature }) + BeaconBlock::Capella(message) => { + SignedBeaconBlock::Capella(SignedBeaconBlockCapella { message, signature }) } } } diff --git a/consensus/types/src/signed_blobs_sidecar.rs b/consensus/types/src/signed_blobs_sidecar.rs new file mode 100644 index 000000000..f5f60e2bd --- /dev/null +++ b/consensus/types/src/signed_blobs_sidecar.rs @@ -0,0 +1,15 @@ +use crate::{Blob, BlobsSidecar, EthSpec, Hash256, Slot}; +use bls::Signature; +use serde_derive::{Deserialize, Serialize}; +use ssz::Encode; +use ssz_derive::{Decode, Encode}; +use ssz_types::VariableList; +use tree_hash::TreeHash; +use tree_hash_derive::TreeHash; + +#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] +#[derive(Debug, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, PartialEq)] +pub struct SignedBlobsSidecar { + pub message: BlobsSidecar, + pub signature: Signature, +} diff --git a/testing/ef_tests/src/cases/common.rs b/testing/ef_tests/src/cases/common.rs index b695015d7..c172d880a 100644 --- a/testing/ef_tests/src/cases/common.rs +++ b/testing/ef_tests/src/cases/common.rs @@ -78,6 +78,6 @@ pub fn previous_fork(fork_name: ForkName) -> ForkName { ForkName::Base => ForkName::Base, ForkName::Altair => ForkName::Base, ForkName::Merge => ForkName::Altair, // TODO: Check this when tests are released.. - ForkName::Shanghai => ForkName::Merge, // TODO: Check this when tests are released.. + ForkName::Capella => ForkName::Merge, // TODO: Check this when tests are released.. } } diff --git a/testing/ef_tests/src/cases/epoch_processing.rs b/testing/ef_tests/src/cases/epoch_processing.rs index 04470c73c..2652c792e 100644 --- a/testing/ef_tests/src/cases/epoch_processing.rs +++ b/testing/ef_tests/src/cases/epoch_processing.rs @@ -97,7 +97,7 @@ impl EpochTransition for JustificationAndFinalization { justification_and_finalization_state.apply_changes_to_state(state); Ok(()) } - BeaconState::Altair(_) | BeaconState::Merge(_) | BeaconState::Shanghai(_) => { + BeaconState::Altair(_) | BeaconState::Merge(_) | BeaconState::Capella(_) => { let justification_and_finalization_state = altair::process_justification_and_finalization( state, @@ -118,7 +118,7 @@ impl EpochTransition for RewardsAndPenalties { validator_statuses.process_attestations(state)?; base::process_rewards_and_penalties(state, &mut validator_statuses, spec) } - BeaconState::Altair(_) | BeaconState::Merge(_) | BeaconState::Shanghai(_) => { + BeaconState::Altair(_) | BeaconState::Merge(_) | BeaconState::Capella(_) => { altair::process_rewards_and_penalties( state, &altair::ParticipationCache::new(state, spec).unwrap(), @@ -147,7 +147,7 @@ impl EpochTransition for Slashings { spec, )?; } - BeaconState::Altair(_) | BeaconState::Merge(_) | BeaconState::Shanghai(_) => { + BeaconState::Altair(_) | BeaconState::Merge(_) | BeaconState::Capella(_) => { process_slashings( state, altair::ParticipationCache::new(state, spec) @@ -205,7 +205,7 @@ impl EpochTransition for SyncCommitteeUpdates { fn run(state: &mut BeaconState, spec: &ChainSpec) -> Result<(), EpochProcessingError> { match state { BeaconState::Base(_) => Ok(()), - BeaconState::Altair(_) | BeaconState::Merge(_) | BeaconState::Shanghai(_) => { + BeaconState::Altair(_) | BeaconState::Merge(_) | BeaconState::Capella(_) => { altair::process_sync_committee_updates(state, spec) } } @@ -216,7 +216,7 @@ impl EpochTransition for InactivityUpdates { fn run(state: &mut BeaconState, spec: &ChainSpec) -> Result<(), EpochProcessingError> { match state { BeaconState::Base(_) => Ok(()), - BeaconState::Altair(_) | BeaconState::Merge(_) | BeaconState::Shanghai(_) => { + BeaconState::Altair(_) | BeaconState::Merge(_) | BeaconState::Capella(_) => { altair::process_inactivity_updates( state, &altair::ParticipationCache::new(state, spec).unwrap(), @@ -231,7 +231,7 @@ impl EpochTransition for ParticipationFlagUpdates { fn run(state: &mut BeaconState, _: &ChainSpec) -> Result<(), EpochProcessingError> { match state { BeaconState::Base(_) => Ok(()), - BeaconState::Altair(_) | BeaconState::Merge(_) | BeaconState::Shanghai(_) => { + BeaconState::Altair(_) | BeaconState::Merge(_) | BeaconState::Capella(_) => { altair::process_participation_flag_updates(state) } } @@ -280,7 +280,7 @@ impl> Case for EpochProcessing { } // No phase0 tests for Altair and later. ForkName::Altair | ForkName::Merge => T::name() != "participation_record_updates", - ForkName::Shanghai => false, // TODO: revisit when tests are out + ForkName::Capella => false, // TODO: revisit when tests are out } } diff --git a/testing/ef_tests/src/cases/fork.rs b/testing/ef_tests/src/cases/fork.rs index 57c4f1254..78d207357 100644 --- a/testing/ef_tests/src/cases/fork.rs +++ b/testing/ef_tests/src/cases/fork.rs @@ -61,7 +61,7 @@ impl Case for ForkTest { ForkName::Base => panic!("phase0 not supported"), ForkName::Altair => upgrade_to_altair(&mut result_state, spec).map(|_| result_state), ForkName::Merge => upgrade_to_bellatrix(&mut result_state, spec).map(|_| result_state), - ForkName::Shanghai => panic!("shanghai not supported"), + ForkName::Capella => panic!("capella not supported"), }; compare_beacon_state_results_without_caches(&mut result, &mut expected) diff --git a/testing/ef_tests/src/cases/operations.rs b/testing/ef_tests/src/cases/operations.rs index bfa63bfe6..b8d46dd3d 100644 --- a/testing/ef_tests/src/cases/operations.rs +++ b/testing/ef_tests/src/cases/operations.rs @@ -81,7 +81,7 @@ impl Operation for Attestation { BeaconState::Base(_) => { base::process_attestations(state, &[self.clone()], VerifySignatures::True, spec) } - BeaconState::Altair(_) | BeaconState::Merge(_) | BeaconState::Shanghai(_) => { + BeaconState::Altair(_) | BeaconState::Merge(_) | BeaconState::Capella(_) => { altair::process_attestation( state, self, diff --git a/testing/ef_tests/src/cases/transition.rs b/testing/ef_tests/src/cases/transition.rs index bbc98994a..02f2f8ff0 100644 --- a/testing/ef_tests/src/cases/transition.rs +++ b/testing/ef_tests/src/cases/transition.rs @@ -42,9 +42,9 @@ impl LoadCase for TransitionTest { spec.altair_fork_epoch = Some(Epoch::new(0)); spec.bellatrix_fork_epoch = Some(metadata.fork_epoch); } - ForkName::Shanghai => { + ForkName::Capella => { spec.bellatrix_fork_epoch = Some(Epoch::new(0)); - spec.shanghai_fork_epoch = Some(metadata.fork_epoch); + spec.capella_fork_epoch = Some(metadata.fork_epoch); } } diff --git a/validator_client/src/signing_method/web3signer.rs b/validator_client/src/signing_method/web3signer.rs index 967d6b139..4e39dc735 100644 --- a/validator_client/src/signing_method/web3signer.rs +++ b/validator_client/src/signing_method/web3signer.rs @@ -90,8 +90,8 @@ impl<'a, T: EthSpec, Payload: ExecPayload> Web3SignerObject<'a, T, Payload> { block: None, block_header: Some(block.block_header()), }), - BeaconBlock::Shanghai(_) => Ok(Web3SignerObject::BeaconBlock { - version: ForkName::Shanghai, + BeaconBlock::Capella(_) => Ok(Web3SignerObject::BeaconBlock { + version: ForkName::Capella, block: None, block_header: Some(block.block_header()), }),