it compiles!
This commit is contained in:
parent
95203c51d4
commit
ca1e17b386
@ -3353,7 +3353,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
// allows it to run concurrently with things like attestation packing.
|
// allows it to run concurrently with things like attestation packing.
|
||||||
let prepare_payload_handle = match &state {
|
let prepare_payload_handle = match &state {
|
||||||
BeaconState::Base(_) | BeaconState::Altair(_) => None,
|
BeaconState::Base(_) | BeaconState::Altair(_) => None,
|
||||||
BeaconState::Merge(_) => {
|
BeaconState::Merge(_) | BeaconState::Eip4844(_) => {
|
||||||
let prepare_payload_handle =
|
let prepare_payload_handle =
|
||||||
get_execution_payload(self.clone(), &state, proposer_index, builder_params)?;
|
get_execution_payload(self.clone(), &state, proposer_index, builder_params)?;
|
||||||
Some(prepare_payload_handle)
|
Some(prepare_payload_handle)
|
||||||
@ -3609,6 +3609,27 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
.ok_or(BlockProductionError::MissingExecutionPayload)?,
|
.ok_or(BlockProductionError::MissingExecutionPayload)?,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
BeaconState::Eip4844(_) => BeaconBlock::Eip4844(BeaconBlockEip4844 {
|
||||||
|
slot,
|
||||||
|
proposer_index,
|
||||||
|
parent_root,
|
||||||
|
state_root: Hash256::zero(),
|
||||||
|
body: BeaconBlockBodyEip4844 {
|
||||||
|
randao_reveal,
|
||||||
|
eth1_data,
|
||||||
|
graffiti,
|
||||||
|
proposer_slashings: proposer_slashings.into(),
|
||||||
|
attester_slashings: attester_slashings.into(),
|
||||||
|
attestations: attestations.into(),
|
||||||
|
deposits: deposits.into(),
|
||||||
|
voluntary_exits: voluntary_exits.into(),
|
||||||
|
sync_aggregate: sync_aggregate
|
||||||
|
.ok_or(BlockProductionError::MissingSyncAggregate)?,
|
||||||
|
execution_payload: execution_payload
|
||||||
|
.ok_or(BlockProductionError::MissingExecutionPayload)?,
|
||||||
|
blob_kzg_commitments: todo!(), // part of partial block or??
|
||||||
|
},
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
let block = SignedBeaconBlock::from_block(
|
let block = SignedBeaconBlock::from_block(
|
||||||
|
@ -296,7 +296,7 @@ pub fn gossipsub_config(network_load: u8, fork_context: Arc<ForkContext>) -> Gos
|
|||||||
match fork_context.current_fork() {
|
match fork_context.current_fork() {
|
||||||
// according to: https://github.com/ethereum/consensus-specs/blob/dev/specs/merge/p2p-interface.md#the-gossip-domain-gossipsub
|
// 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
|
// the derivation of the message-id remains the same in the merge
|
||||||
ForkName::Altair | ForkName::Merge => {
|
ForkName::Altair | ForkName::Merge | ForkName::Eip4844 => {
|
||||||
let topic_len_bytes = topic_bytes.len().to_le_bytes();
|
let topic_len_bytes = topic_bytes.len().to_le_bytes();
|
||||||
let mut vec = Vec::with_capacity(
|
let mut vec = Vec::with_capacity(
|
||||||
prefix.len() + topic_len_bytes.len() + topic_bytes.len() + message.data.len(),
|
prefix.len() + topic_len_bytes.len() + topic_bytes.len() + message.data.len(),
|
||||||
|
@ -17,7 +17,7 @@ use std::sync::Arc;
|
|||||||
use tokio_util::codec::{Decoder, Encoder};
|
use tokio_util::codec::{Decoder, Encoder};
|
||||||
use types::{
|
use types::{
|
||||||
EthSpec, ForkContext, ForkName, SignedBeaconBlock, SignedBeaconBlockAltair,
|
EthSpec, ForkContext, ForkName, SignedBeaconBlock, SignedBeaconBlockAltair,
|
||||||
SignedBeaconBlockBase, SignedBeaconBlockMerge,
|
SignedBeaconBlockBase, SignedBeaconBlockMerge, SignedBeaconBlockEip4844
|
||||||
};
|
};
|
||||||
use unsigned_varint::codec::Uvi;
|
use unsigned_varint::codec::Uvi;
|
||||||
|
|
||||||
@ -407,6 +407,10 @@ fn context_bytes<T: EthSpec>(
|
|||||||
return match **ref_box_block {
|
return match **ref_box_block {
|
||||||
// NOTE: If you are adding another fork type here, be sure to modify the
|
// 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!
|
// `fork_context.to_context_bytes()` function to support it as well!
|
||||||
|
SignedBeaconBlock::Eip4844 { .. } => {
|
||||||
|
// Merge context being `None` implies that "merge never happened".
|
||||||
|
fork_context.to_context_bytes(ForkName::Eip4844)
|
||||||
|
}
|
||||||
SignedBeaconBlock::Merge { .. } => {
|
SignedBeaconBlock::Merge { .. } => {
|
||||||
// Merge context being `None` implies that "merge never happened".
|
// Merge context being `None` implies that "merge never happened".
|
||||||
fork_context.to_context_bytes(ForkName::Merge)
|
fork_context.to_context_bytes(ForkName::Merge)
|
||||||
@ -586,6 +590,11 @@ fn handle_v2_response<T: EthSpec>(
|
|||||||
decoded_buffer,
|
decoded_buffer,
|
||||||
)?),
|
)?),
|
||||||
)))),
|
)))),
|
||||||
|
ForkName::Eip4844 => Ok(Some(RPCResponse::BlocksByRange(Arc::new(
|
||||||
|
SignedBeaconBlock::Eip4844(SignedBeaconBlockEip4844::from_ssz_bytes(
|
||||||
|
decoded_buffer,
|
||||||
|
)?),
|
||||||
|
)))),
|
||||||
},
|
},
|
||||||
Protocol::BlocksByRoot => match fork_name {
|
Protocol::BlocksByRoot => match fork_name {
|
||||||
ForkName::Altair => Ok(Some(RPCResponse::BlocksByRoot(Arc::new(
|
ForkName::Altair => Ok(Some(RPCResponse::BlocksByRoot(Arc::new(
|
||||||
@ -601,6 +610,11 @@ fn handle_v2_response<T: EthSpec>(
|
|||||||
decoded_buffer,
|
decoded_buffer,
|
||||||
)?),
|
)?),
|
||||||
)))),
|
)))),
|
||||||
|
ForkName::Eip4844 => Ok(Some(RPCResponse::BlocksByRange(Arc::new(
|
||||||
|
SignedBeaconBlock::Eip4844(SignedBeaconBlockEip4844::from_ssz_bytes(
|
||||||
|
decoded_buffer,
|
||||||
|
)?),
|
||||||
|
)))),
|
||||||
},
|
},
|
||||||
_ => Err(RPCError::ErrorResponse(
|
_ => Err(RPCError::ErrorResponse(
|
||||||
RPCResponseErrorCode::InvalidRequest,
|
RPCResponseErrorCode::InvalidRequest,
|
||||||
|
@ -71,6 +71,10 @@ lazy_static! {
|
|||||||
+ types::ExecutionPayload::<MainnetEthSpec>::max_execution_payload_size() // adding max size of execution payload (~16gb)
|
+ 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
|
+ ssz::BYTES_PER_LENGTH_OFFSET; // Adding the additional ssz offset for the `ExecutionPayload` field
|
||||||
|
|
||||||
|
pub static ref SIGNED_BEACON_BLOCK_EIP4844_MAX: usize =
|
||||||
|
// Size of a full altair block
|
||||||
|
*SIGNED_BEACON_BLOCK_MERGE_MAX + 999999999; //TODO
|
||||||
|
|
||||||
pub static ref BLOCKS_BY_ROOT_REQUEST_MIN: usize =
|
pub static ref BLOCKS_BY_ROOT_REQUEST_MIN: usize =
|
||||||
VariableList::<Hash256, MaxRequestBlocks>::from(Vec::<Hash256>::new())
|
VariableList::<Hash256, MaxRequestBlocks>::from(Vec::<Hash256>::new())
|
||||||
.as_ssz_bytes()
|
.as_ssz_bytes()
|
||||||
@ -102,6 +106,7 @@ lazy_static! {
|
|||||||
pub(crate) const MAX_RPC_SIZE: usize = 1_048_576; // 1M
|
pub(crate) const MAX_RPC_SIZE: usize = 1_048_576; // 1M
|
||||||
/// The maximum bytes that can be sent across the RPC post-merge.
|
/// The maximum bytes that can be sent across the RPC post-merge.
|
||||||
pub(crate) const MAX_RPC_SIZE_POST_MERGE: usize = 10 * 1_048_576; // 10M
|
pub(crate) const MAX_RPC_SIZE_POST_MERGE: usize = 10 * 1_048_576; // 10M
|
||||||
|
pub(crate) const MAX_RPC_SIZE_POST_EIP4844: usize = 20 * 1_048_576; // 10M
|
||||||
/// The protocol prefix the RPC protocol id.
|
/// The protocol prefix the RPC protocol id.
|
||||||
const PROTOCOL_PREFIX: &str = "/eth2/beacon_chain/req";
|
const PROTOCOL_PREFIX: &str = "/eth2/beacon_chain/req";
|
||||||
/// Time allowed for the first byte of a request to arrive before we time out (Time To First Byte).
|
/// Time allowed for the first byte of a request to arrive before we time out (Time To First Byte).
|
||||||
@ -113,6 +118,7 @@ const REQUEST_TIMEOUT: u64 = 15;
|
|||||||
/// Returns the maximum bytes that can be sent across the RPC.
|
/// Returns the maximum bytes that can be sent across the RPC.
|
||||||
pub fn max_rpc_size(fork_context: &ForkContext) -> usize {
|
pub fn max_rpc_size(fork_context: &ForkContext) -> usize {
|
||||||
match fork_context.current_fork() {
|
match fork_context.current_fork() {
|
||||||
|
ForkName::Eip4844 => MAX_RPC_SIZE_POST_EIP4844,
|
||||||
ForkName::Merge => MAX_RPC_SIZE_POST_MERGE,
|
ForkName::Merge => MAX_RPC_SIZE_POST_MERGE,
|
||||||
ForkName::Altair | ForkName::Base => MAX_RPC_SIZE,
|
ForkName::Altair | ForkName::Base => MAX_RPC_SIZE,
|
||||||
}
|
}
|
||||||
@ -135,6 +141,10 @@ pub fn rpc_block_limits_by_fork(current_fork: ForkName) -> RpcLimits {
|
|||||||
*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 merge blocks
|
||||||
*SIGNED_BEACON_BLOCK_MERGE_MAX, // Merge block is larger than base and altair blocks
|
*SIGNED_BEACON_BLOCK_MERGE_MAX, // Merge block is larger than base and altair blocks
|
||||||
),
|
),
|
||||||
|
ForkName::Eip4844 => RpcLimits::new(
|
||||||
|
*SIGNED_BEACON_BLOCK_BASE_MIN, // Base block is smaller than altair and merge blocks
|
||||||
|
*SIGNED_BEACON_BLOCK_EIP4844_MAX, // Merge block is larger than base and altair blocks
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ use std::sync::Arc;
|
|||||||
use types::{
|
use types::{
|
||||||
Attestation, AttesterSlashing, EthSpec, ForkContext, ForkName, ProposerSlashing,
|
Attestation, AttesterSlashing, EthSpec, ForkContext, ForkName, ProposerSlashing,
|
||||||
SignedAggregateAndProof, SignedBeaconBlock, SignedBeaconBlockAltair, SignedBeaconBlockBase,
|
SignedAggregateAndProof, SignedBeaconBlock, SignedBeaconBlockAltair, SignedBeaconBlockBase,
|
||||||
SignedBeaconBlockMerge, SignedContributionAndProof, SignedVoluntaryExit, SubnetId,
|
SignedBeaconBlockMerge, SignedBeaconBlockEip4844, SignedContributionAndProof, SignedVoluntaryExit, SubnetId,
|
||||||
SyncCommitteeMessage, SyncSubnetId,
|
SyncCommitteeMessage, SyncSubnetId,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -167,6 +167,10 @@ impl<T: EthSpec> PubsubMessage<T> {
|
|||||||
SignedBeaconBlockMerge::from_ssz_bytes(data)
|
SignedBeaconBlockMerge::from_ssz_bytes(data)
|
||||||
.map_err(|e| format!("{:?}", e))?,
|
.map_err(|e| format!("{:?}", e))?,
|
||||||
),
|
),
|
||||||
|
Some(ForkName::Eip4844) => SignedBeaconBlock::<T>::Eip4844(
|
||||||
|
SignedBeaconBlockEip4844::from_ssz_bytes(data)
|
||||||
|
.map_err(|e| format!("{:?}", e))?,
|
||||||
|
),
|
||||||
None => {
|
None => {
|
||||||
return Err(format!(
|
return Err(format!(
|
||||||
"Unknown gossipsub fork digest: {:?}",
|
"Unknown gossipsub fork digest: {:?}",
|
||||||
|
@ -66,9 +66,9 @@ where
|
|||||||
pub current_epoch_attestations: VariableList<PendingAttestation<T>, T::MaxPendingAttestations>,
|
pub current_epoch_attestations: VariableList<PendingAttestation<T>, T::MaxPendingAttestations>,
|
||||||
|
|
||||||
// Participation (Altair and later)
|
// Participation (Altair and later)
|
||||||
#[superstruct(only(Altair, Merge))]
|
#[superstruct(only(Altair, Merge, Eip4844))]
|
||||||
pub previous_epoch_participation: VariableList<ParticipationFlags, T::ValidatorRegistryLimit>,
|
pub previous_epoch_participation: VariableList<ParticipationFlags, T::ValidatorRegistryLimit>,
|
||||||
#[superstruct(only(Altair, Merge))]
|
#[superstruct(only(Altair, Merge, Eip4844))]
|
||||||
pub current_epoch_participation: VariableList<ParticipationFlags, T::ValidatorRegistryLimit>,
|
pub current_epoch_participation: VariableList<ParticipationFlags, T::ValidatorRegistryLimit>,
|
||||||
|
|
||||||
// Finality
|
// Finality
|
||||||
@ -78,17 +78,17 @@ where
|
|||||||
pub finalized_checkpoint: Checkpoint,
|
pub finalized_checkpoint: Checkpoint,
|
||||||
|
|
||||||
// Inactivity
|
// Inactivity
|
||||||
#[superstruct(only(Altair, Merge))]
|
#[superstruct(only(Altair, Merge, Eip4844))]
|
||||||
pub inactivity_scores: VariableList<u64, T::ValidatorRegistryLimit>,
|
pub inactivity_scores: VariableList<u64, T::ValidatorRegistryLimit>,
|
||||||
|
|
||||||
// Light-client sync committees
|
// Light-client sync committees
|
||||||
#[superstruct(only(Altair, Merge))]
|
#[superstruct(only(Altair, Merge, Eip4844))]
|
||||||
pub current_sync_committee: Arc<SyncCommittee<T>>,
|
pub current_sync_committee: Arc<SyncCommittee<T>>,
|
||||||
#[superstruct(only(Altair, Merge))]
|
#[superstruct(only(Altair, Merge, Eip4844))]
|
||||||
pub next_sync_committee: Arc<SyncCommittee<T>>,
|
pub next_sync_committee: Arc<SyncCommittee<T>>,
|
||||||
|
|
||||||
// Execution
|
// Execution
|
||||||
#[superstruct(only(Merge))]
|
#[superstruct(only(Merge, Eip4844))]
|
||||||
pub latest_execution_payload_header: ExecutionPayloadHeader<T>,
|
pub latest_execution_payload_header: ExecutionPayloadHeader<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,6 +178,20 @@ impl<T: EthSpec> PartialBeaconState<T> {
|
|||||||
latest_execution_payload_header
|
latest_execution_payload_header
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
|
BeaconState::Eip4844(s) => impl_from_state_forgetful!(
|
||||||
|
s,
|
||||||
|
outer,
|
||||||
|
Eip4844,
|
||||||
|
PartialBeaconStateEip4844,
|
||||||
|
[
|
||||||
|
previous_epoch_participation,
|
||||||
|
current_epoch_participation,
|
||||||
|
current_sync_committee,
|
||||||
|
next_sync_committee,
|
||||||
|
inactivity_scores,
|
||||||
|
latest_execution_payload_header
|
||||||
|
]
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,6 +379,19 @@ impl<E: EthSpec> TryInto<BeaconState<E>> for PartialBeaconState<E> {
|
|||||||
latest_execution_payload_header
|
latest_execution_payload_header
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
|
PartialBeaconState::Eip4844(inner) => impl_try_into_beacon_state!(
|
||||||
|
inner,
|
||||||
|
Eip4844,
|
||||||
|
BeaconStateEip4844,
|
||||||
|
[
|
||||||
|
previous_epoch_participation,
|
||||||
|
current_epoch_participation,
|
||||||
|
current_sync_committee,
|
||||||
|
next_sync_committee,
|
||||||
|
inactivity_scores,
|
||||||
|
latest_execution_payload_header
|
||||||
|
]
|
||||||
|
),
|
||||||
};
|
};
|
||||||
Ok(state)
|
Ok(state)
|
||||||
}
|
}
|
||||||
|
@ -267,17 +267,17 @@ where
|
|||||||
|
|
||||||
// Inactivity
|
// Inactivity
|
||||||
#[serde(with = "ssz_types::serde_utils::quoted_u64_var_list")]
|
#[serde(with = "ssz_types::serde_utils::quoted_u64_var_list")]
|
||||||
#[superstruct(only(Altair, Merge))]
|
#[superstruct(only(Altair, Merge, Eip4844))]
|
||||||
pub inactivity_scores: VariableList<u64, T::ValidatorRegistryLimit>,
|
pub inactivity_scores: VariableList<u64, T::ValidatorRegistryLimit>,
|
||||||
|
|
||||||
// Light-client sync committees
|
// Light-client sync committees
|
||||||
#[superstruct(only(Altair, Merge))]
|
#[superstruct(only(Altair, Merge, Eip4844))]
|
||||||
pub current_sync_committee: Arc<SyncCommittee<T>>,
|
pub current_sync_committee: Arc<SyncCommittee<T>>,
|
||||||
#[superstruct(only(Altair, Merge))]
|
#[superstruct(only(Altair, Merge, Eip4844))]
|
||||||
pub next_sync_committee: Arc<SyncCommittee<T>>,
|
pub next_sync_committee: Arc<SyncCommittee<T>>,
|
||||||
|
|
||||||
// Execution
|
// Execution
|
||||||
#[superstruct(only(Merge))]
|
#[superstruct(only(Merge, Eip4844))]
|
||||||
pub latest_execution_payload_header: ExecutionPayloadHeader<T>,
|
pub latest_execution_payload_header: ExecutionPayloadHeader<T>,
|
||||||
|
|
||||||
// Caching (not in the spec)
|
// Caching (not in the spec)
|
||||||
|
@ -47,6 +47,16 @@ impl ForkContext {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if spec.bellatrix_fork_epoch.is_some() {
|
||||||
|
fork_to_digest.push((
|
||||||
|
ForkName::Merge,
|
||||||
|
ChainSpec::compute_fork_digest(
|
||||||
|
spec.bellatrix_fork_version,
|
||||||
|
genesis_validators_root,
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
let fork_to_digest: HashMap<ForkName, [u8; 4]> = fork_to_digest.into_iter().collect();
|
let fork_to_digest: HashMap<ForkName, [u8; 4]> = fork_to_digest.into_iter().collect();
|
||||||
|
|
||||||
let digest_to_fork = fork_to_digest
|
let digest_to_fork = fork_to_digest
|
||||||
|
@ -151,7 +151,7 @@ pub use crate::shuffling_id::AttestationShufflingId;
|
|||||||
pub use crate::signed_aggregate_and_proof::SignedAggregateAndProof;
|
pub use crate::signed_aggregate_and_proof::SignedAggregateAndProof;
|
||||||
pub use crate::signed_beacon_block::{
|
pub use crate::signed_beacon_block::{
|
||||||
SignedBeaconBlock, SignedBeaconBlockAltair, SignedBeaconBlockBase, SignedBeaconBlockHash,
|
SignedBeaconBlock, SignedBeaconBlockAltair, SignedBeaconBlockBase, SignedBeaconBlockHash,
|
||||||
SignedBeaconBlockMerge, SignedBlindedBeaconBlock,
|
SignedBeaconBlockMerge, SignedBlindedBeaconBlock, SignedBeaconBlockEip4844,
|
||||||
};
|
};
|
||||||
pub use crate::signed_beacon_block_header::SignedBeaconBlockHeader;
|
pub use crate::signed_beacon_block_header::SignedBeaconBlockHeader;
|
||||||
pub use crate::signed_contribution_and_proof::SignedContributionAndProof;
|
pub use crate::signed_contribution_and_proof::SignedContributionAndProof;
|
||||||
|
@ -26,6 +26,7 @@ pub enum ForkName {
|
|||||||
Phase0,
|
Phase0,
|
||||||
Altair,
|
Altair,
|
||||||
Bellatrix,
|
Bellatrix,
|
||||||
|
Eip4844,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize)]
|
#[derive(Debug, PartialEq, Serialize)]
|
||||||
@ -90,6 +91,11 @@ impl<'a, T: EthSpec, Payload: ExecPayload<T>> Web3SignerObject<'a, T, Payload> {
|
|||||||
block: None,
|
block: None,
|
||||||
block_header: Some(block.block_header()),
|
block_header: Some(block.block_header()),
|
||||||
}),
|
}),
|
||||||
|
BeaconBlock::Eip4844(_) => Ok(Web3SignerObject::BeaconBlock {
|
||||||
|
version: ForkName::Eip4844,
|
||||||
|
block: None,
|
||||||
|
block_header: Some(block.block_header()),
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user