From de44b300c089de05a834a920a5993de5c12c5a09 Mon Sep 17 00:00:00 2001 From: realbigsean Date: Fri, 18 Feb 2022 18:29:05 -0700 Subject: [PATCH] add/update types --- Cargo.lock | 11 ++++ beacon_node/lighthouse_network/src/config.rs | 3 +- .../src/rpc/codec/ssz_snappy.rs | 9 ++- .../lighthouse_network/src/types/pubsub.rs | 8 ++- consensus/ssz/src/decode/impls.rs | 1 + consensus/ssz/src/encode/impls.rs | 1 + .../process_operations.rs | 4 +- consensus/tree_hash/src/impls.rs | 1 + consensus/types/Cargo.toml | 1 + consensus/types/src/beacon_block.rs | 9 ++- consensus/types/src/beacon_block_and_blobs.rs | 13 ++++ consensus/types/src/beacon_block_body.rs | 9 ++- consensus/types/src/chain_spec.rs | 8 +++ consensus/types/src/eth_spec.rs | 13 +++- consensus/types/src/fork_name.rs | 19 +++++- consensus/types/src/kzg_commitment.rs | 63 +++++++++++++++++++ consensus/types/src/lib.rs | 15 +++-- consensus/types/src/signed_beacon_block.rs | 7 ++- testing/ef_tests/src/cases/common.rs | 1 + .../ef_tests/src/cases/epoch_processing.rs | 1 + testing/ef_tests/src/cases/fork.rs | 1 + testing/ef_tests/src/cases/transition.rs | 5 ++ .../src/signing_method/web3signer.rs | 5 ++ 23 files changed, 189 insertions(+), 19 deletions(-) create mode 100644 consensus/types/src/beacon_block_and_blobs.rs create mode 100644 consensus/types/src/kzg_commitment.rs diff --git a/Cargo.lock b/Cargo.lock index cfefa6c11..4dfd070f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5736,6 +5736,16 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-big-array" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18b20e7752957bbe9661cff4e0bb04d183d0948cdab2ea58cdb9df36a61dfe62" +dependencies = [ + "serde", + "serde_derive", +] + [[package]] name = "serde_array_query" version = "0.1.0" @@ -7107,6 +7117,7 @@ dependencies = [ "rusqlite", "safe_arith", "serde", + "serde-big-array", "serde_derive", "serde_json", "serde_with", diff --git a/beacon_node/lighthouse_network/src/config.rs b/beacon_node/lighthouse_network/src/config.rs index 263ef0c7c..ca2178432 100644 --- a/beacon_node/lighthouse_network/src/config.rs +++ b/beacon_node/lighthouse_network/src/config.rs @@ -296,7 +296,8 @@ pub fn gossipsub_config(network_load: u8, fork_context: Arc) -> Gos match fork_context.current_fork() { // 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 - ForkName::Altair | ForkName::Merge => { + //TODO(sean): figure this out + ForkName::Altair | ForkName::Merge | ForkName::Dank => { 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 a46a05a8c..699d877ef 100644 --- a/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs +++ b/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs @@ -17,7 +17,7 @@ use std::sync::Arc; use tokio_util::codec::{Decoder, Encoder}; use types::{ EthSpec, ForkContext, ForkName, SignedBeaconBlock, SignedBeaconBlockAltair, - SignedBeaconBlockBase, SignedBeaconBlockMerge, + SignedBeaconBlockBase, SignedBeaconBlockDank, SignedBeaconBlockMerge, }; use unsigned_varint::codec::Uvi; @@ -407,6 +407,7 @@ 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::Dank { .. } => fork_context.to_context_bytes(ForkName::Dank), SignedBeaconBlock::Merge { .. } => { // Merge context being `None` implies that "merge never happened". fork_context.to_context_bytes(ForkName::Merge) @@ -586,6 +587,9 @@ fn handle_v2_response( decoded_buffer, )?), )))), + ForkName::Dank => Ok(Some(RPCResponse::BlocksByRange(Box::new( + SignedBeaconBlock::Dank(SignedBeaconBlockDank::from_ssz_bytes(decoded_buffer)?), + )))), }, Protocol::BlocksByRoot => match fork_name { ForkName::Altair => Ok(Some(RPCResponse::BlocksByRoot(Arc::new( @@ -601,6 +605,9 @@ fn handle_v2_response( decoded_buffer, )?), )))), + ForkName::Dank => Ok(Some(RPCResponse::BlocksByRoot(Box::new( + SignedBeaconBlock::Dank(SignedBeaconBlockDank::from_ssz_bytes(decoded_buffer)?), + )))), }, _ => Err(RPCError::ErrorResponse( RPCResponseErrorCode::InvalidRequest, diff --git a/beacon_node/lighthouse_network/src/types/pubsub.rs b/beacon_node/lighthouse_network/src/types/pubsub.rs index a01072f8e..291cde46c 100644 --- a/beacon_node/lighthouse_network/src/types/pubsub.rs +++ b/beacon_node/lighthouse_network/src/types/pubsub.rs @@ -11,8 +11,8 @@ use std::sync::Arc; use types::{ Attestation, AttesterSlashing, EthSpec, ForkContext, ForkName, ProposerSlashing, SignedAggregateAndProof, SignedBeaconBlock, SignedBeaconBlockAltair, SignedBeaconBlockBase, - SignedBeaconBlockMerge, SignedContributionAndProof, SignedVoluntaryExit, SubnetId, - SyncCommitteeMessage, SyncSubnetId, + SignedBeaconBlockDank, SignedBeaconBlockMerge, SignedContributionAndProof, SignedVoluntaryExit, + SubnetId, SyncCommitteeMessage, SyncSubnetId, }; #[derive(Debug, Clone, PartialEq)] @@ -167,6 +167,10 @@ impl PubsubMessage { SignedBeaconBlockMerge::from_ssz_bytes(data) .map_err(|e| format!("{:?}", e))?, ), + Some(ForkName::Dank) => SignedBeaconBlock::::Dank( + SignedBeaconBlockDank::from_ssz_bytes(data) + .map_err(|e| format!("{:?}", e))?, + ), None => { return Err(format!( "Unknown gossipsub fork digest: {:?}", diff --git a/consensus/ssz/src/decode/impls.rs b/consensus/ssz/src/decode/impls.rs index d91ddabe0..99f318585 100644 --- a/consensus/ssz/src/decode/impls.rs +++ b/consensus/ssz/src/decode/impls.rs @@ -374,6 +374,7 @@ macro_rules! impl_decodable_for_u8_array { impl_decodable_for_u8_array!(4); impl_decodable_for_u8_array!(32); +impl_decodable_for_u8_array!(48); macro_rules! impl_for_vec { ($type: ty, $max_len: expr) => { diff --git a/consensus/ssz/src/encode/impls.rs b/consensus/ssz/src/encode/impls.rs index cfd95ba40..1faf9123f 100644 --- a/consensus/ssz/src/encode/impls.rs +++ b/consensus/ssz/src/encode/impls.rs @@ -483,6 +483,7 @@ macro_rules! impl_encodable_for_u8_array { impl_encodable_for_u8_array!(4); impl_encodable_for_u8_array!(32); +impl_encodable_for_u8_array!(48); #[cfg(test)] mod tests { 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 31a4ac1fb..0d74ac4dc 100644 --- a/consensus/state_processing/src/per_block_processing/process_operations.rs +++ b/consensus/state_processing/src/per_block_processing/process_operations.rs @@ -230,7 +230,9 @@ pub fn process_attestations<'a, T: EthSpec, Payload: ExecPayload>( BeaconBlockBodyRef::Base(_) => { base::process_attestations(state, block_body.attestations(), verify_signatures, spec)?; } - BeaconBlockBodyRef::Altair(_) | BeaconBlockBodyRef::Merge(_) => { + BeaconBlockBodyRef::Altair(_) + | BeaconBlockBodyRef::Merge(_) + | BeaconBlockBodyRef::Dank(_) => { altair::process_attestations( state, block_body.attestations(), diff --git a/consensus/tree_hash/src/impls.rs b/consensus/tree_hash/src/impls.rs index cf05d2a3d..f27c52918 100644 --- a/consensus/tree_hash/src/impls.rs +++ b/consensus/tree_hash/src/impls.rs @@ -81,6 +81,7 @@ macro_rules! impl_for_lt_32byte_u8_array { impl_for_lt_32byte_u8_array!(4); impl_for_lt_32byte_u8_array!(32); +impl_for_lt_32byte_u8_array!(48); impl TreeHash for U128 { fn tree_hash_type() -> TreeHashType { diff --git a/consensus/types/Cargo.toml b/consensus/types/Cargo.toml index 68fdbf799..397d916dc 100644 --- a/consensus/types/Cargo.toml +++ b/consensus/types/Cargo.toml @@ -9,6 +9,7 @@ name = "benches" harness = false [dependencies] +serde-big-array = {version = "0.3.2", features = ["const-generics"]} bls = { path = "../../crypto/bls" } compare_fields = { path = "../../common/compare_fields" } compare_fields_derive = { path = "../../common/compare_fields_derive" } diff --git a/consensus/types/src/beacon_block.rs b/consensus/types/src/beacon_block.rs index 0ec1f9a37..f9f2d8651 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, + BeaconBlockBodyAltair, BeaconBlockBodyBase, BeaconBlockBodyDank, 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), + variants(Base, Altair, Merge, Dank), variant_attributes( derive( Debug, @@ -64,6 +64,8 @@ pub struct BeaconBlock = FullPayload> { pub body: BeaconBlockBodyAltair, #[superstruct(only(Merge), partial_getter(rename = "body_merge"))] pub body: BeaconBlockBodyMerge, + #[superstruct(only(Dank), partial_getter(rename = "body_dank"))] + pub body: BeaconBlockBodyDank, } pub type BlindedBeaconBlock = BeaconBlock>; @@ -189,6 +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::Dank { .. } => ForkName::Dank, }; if fork_at_slot == object_fork { diff --git a/consensus/types/src/beacon_block_and_blobs.rs b/consensus/types/src/beacon_block_and_blobs.rs new file mode 100644 index 000000000..b39fff771 --- /dev/null +++ b/consensus/types/src/beacon_block_and_blobs.rs @@ -0,0 +1,13 @@ +use crate::{BLSFieldElement, Blob, EthSpec, SignedBeaconBlock}; +use serde_derive::{Deserialize, Serialize}; +use ssz_derive::{Decode, Encode}; +use ssz_types::{FixedVector, VariableList}; +use tree_hash::TreeHash; +use tree_hash_derive::TreeHash; + +#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] +#[derive(Debug, Clone, Serialize, Deserialize, Encode, TreeHash)] +pub struct BeaconBlockAndBlobs { + pub block: SignedBeaconBlock, + pub blobs: VariableList, E::MaxObjectListSize>, +} diff --git a/consensus/types/src/beacon_block_body.rs b/consensus/types/src/beacon_block_body.rs index 381a9bd43..e8c66d2d3 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), + variants(Base, Altair, Merge, Dank), variant_attributes( derive( Debug, @@ -47,14 +47,16 @@ pub struct BeaconBlockBody = FullPayload> pub attestations: VariableList, T::MaxAttestations>, pub deposits: VariableList, pub voluntary_exits: VariableList, - #[superstruct(only(Altair, Merge))] + #[superstruct(only(Altair, Merge, Dank))] 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))] + #[superstruct(only(Merge, Dank))] #[serde(flatten)] pub execution_payload: Payload, + #[superstruct(only(Dank))] + pub blob_kzgs: VariableList, #[superstruct(only(Base, Altair))] #[ssz(skip_serializing, skip_deserializing)] #[tree_hash(skip_hashing)] @@ -69,6 +71,7 @@ impl<'a, T: EthSpec> BeaconBlockBodyRef<'a, T> { BeaconBlockBodyRef::Base { .. } => ForkName::Base, BeaconBlockBodyRef::Altair { .. } => ForkName::Altair, BeaconBlockBodyRef::Merge { .. } => ForkName::Merge, + BeaconBlockBodyRef::Dank { .. } => ForkName::Dank, } } } diff --git a/consensus/types/src/chain_spec.rs b/consensus/types/src/chain_spec.rs index b2ba24ac3..6bfae08a4 100644 --- a/consensus/types/src/chain_spec.rs +++ b/consensus/types/src/chain_spec.rs @@ -150,6 +150,10 @@ pub struct ChainSpec { pub terminal_block_hash_activation_epoch: Epoch, pub safe_slots_to_import_optimistically: u64, + /* + * Danksharding hard fork params + */ + /* * Networking */ @@ -245,6 +249,8 @@ impl ChainSpec { ForkName::Base => self.genesis_fork_version, ForkName::Altair => self.altair_fork_version, ForkName::Merge => self.bellatrix_fork_version, + //TODO: update this + ForkName::Dank => self.bellatrix_fork_version, } } @@ -254,6 +260,8 @@ impl ChainSpec { ForkName::Base => Some(Epoch::new(0)), ForkName::Altair => self.altair_fork_epoch, ForkName::Merge => self.bellatrix_fork_epoch, + //TODO: update this + ForkName::Dank => self.bellatrix_fork_epoch, } } diff --git a/consensus/types/src/eth_spec.rs b/consensus/types/src/eth_spec.rs index e61697602..742a90ad3 100644 --- a/consensus/types/src/eth_spec.rs +++ b/consensus/types/src/eth_spec.rs @@ -95,6 +95,11 @@ pub trait EthSpec: 'static + Default + Sync + Send + Clone + Debug + PartialEq + type GasLimitDenominator: Unsigned + Clone + Sync + Send + Debug + PartialEq; type MinGasLimit: Unsigned + Clone + Sync + Send + Debug + PartialEq; type MaxExtraDataBytes: Unsigned + Clone + Sync + Send + Debug + PartialEq; + /* + * New in Danksharding + */ + type MaxObjectListSize: Unsigned + Clone + Sync + Send + Debug + PartialEq; + type ChunksPerBlob: Unsigned + Clone + Sync + Send + Debug + PartialEq; /* * Derived values (set these CAREFULLY) */ @@ -262,6 +267,8 @@ impl EthSpec for MainnetEthSpec { type GasLimitDenominator = U1024; type MinGasLimit = U5000; type MaxExtraDataBytes = U32; + type MaxObjectListSize = U16777216; // 2**24 + type ChunksPerBlob = 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 @@ -309,7 +316,9 @@ impl EthSpec for MinimalEthSpec { BytesPerLogsBloom, GasLimitDenominator, MinGasLimit, - MaxExtraDataBytes + MaxExtraDataBytes, + MaxObjectListSize, + ChunksPerBlob }); fn default_spec() -> ChainSpec { @@ -354,6 +363,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; fn default_spec() -> ChainSpec { ChainSpec::gnosis() diff --git a/consensus/types/src/fork_name.rs b/consensus/types/src/fork_name.rs index e97b08309..dd83cf5a3 100644 --- a/consensus/types/src/fork_name.rs +++ b/consensus/types/src/fork_name.rs @@ -1,4 +1,4 @@ -use crate::{ChainSpec, Epoch}; +use crate::{ChainSpec, Epoch, Fork}; use serde_derive::{Deserialize, Serialize}; use std::convert::TryFrom; use std::fmt::{self, Display, Formatter}; @@ -11,6 +11,7 @@ pub enum ForkName { Base, Altair, Merge, + Dank, } impl ForkName { @@ -38,6 +39,12 @@ impl ForkName { spec.bellatrix_fork_epoch = Some(Epoch::new(0)); spec } + //TODO(sean): update + ForkName::Dank => { + spec.altair_fork_epoch = Some(Epoch::new(0)); + spec.bellatrix_fork_epoch = Some(Epoch::new(0)); + spec + } } } @@ -49,6 +56,7 @@ impl ForkName { ForkName::Base => None, ForkName::Altair => Some(ForkName::Base), ForkName::Merge => Some(ForkName::Altair), + ForkName::Dank => Some(ForkName::Merge), } } @@ -59,7 +67,8 @@ impl ForkName { match self { ForkName::Base => Some(ForkName::Altair), ForkName::Altair => Some(ForkName::Merge), - ForkName::Merge => None, + ForkName::Merge => Some(ForkName::Dank), + ForkName::Dank => None, } } } @@ -101,6 +110,11 @@ macro_rules! map_fork_name_with { let (value, extra_data) = $body; ($t::Merge(value), extra_data) } + //TODO: don't have a beacon state variant for the new fork yet + ForkName::Dank => { + let (value, extra_data) = $body; + ($t::Merge(value), extra_data) + } } }; } @@ -124,6 +138,7 @@ impl Display for ForkName { ForkName::Base => "phase0".fmt(f), ForkName::Altair => "altair".fmt(f), ForkName::Merge => "bellatrix".fmt(f), + ForkName::Dank => "dank".fmt(f), } } } diff --git a/consensus/types/src/kzg_commitment.rs b/consensus/types/src/kzg_commitment.rs new file mode 100644 index 000000000..154cb6b00 --- /dev/null +++ b/consensus/types/src/kzg_commitment.rs @@ -0,0 +1,63 @@ +use crate::test_utils::TestRandom; +use crate::*; +use derivative::Derivative; +use serde_derive::{Deserialize, Serialize}; +use ssz::{Decode, DecodeError, Encode}; +use ssz_derive::{Decode, Encode}; +use ssz_types::VariableList; +use superstruct::superstruct; +use test_random_derive::TestRandom; +use tree_hash::TreeHash; +use tree_hash_derive::TreeHash; + +//TODO: is there a way around this newtype +#[derive(Derivative, Debug, Clone, Serialize, Deserialize)] +#[derivative(PartialEq, Eq, Hash)] +pub struct KZGCommitment(#[serde(with = "BigArray")] [u8; 48]); +impl TreeHash for KZGCommitment { + fn tree_hash_type() -> tree_hash::TreeHashType { + <[u8; 48] as TreeHash>::tree_hash_type() + } + + fn tree_hash_packed_encoding(&self) -> Vec { + self.0.tree_hash_packed_encoding() + } + + fn tree_hash_packing_factor() -> usize { + <[u8; 48] as TreeHash>::tree_hash_packing_factor() + } + + fn tree_hash_root(&self) -> tree_hash::Hash256 { + self.0.tree_hash_root() + } +} + +impl TestRandom for KZGCommitment { + fn random_for_test(rng: &mut impl rand::RngCore) -> Self { + KZGCommitment(<[u8; 48] as TestRandom>::random_for_test(rng)) + } +} + +impl Decode for KZGCommitment { + fn is_ssz_fixed_len() -> bool { + <[u8; 48] as Decode>::is_ssz_fixed_len() + } + + fn from_ssz_bytes(bytes: &[u8]) -> Result { + <[u8; 48] as Decode>::from_ssz_bytes(bytes).map(KZGCommitment) + } +} + +impl Encode for KZGCommitment { + fn is_ssz_fixed_len() -> bool { + <[u8; 48] as Encode>::is_ssz_fixed_len() + } + + fn ssz_append(&self, buf: &mut Vec) { + self.0.ssz_append(buf) + } + + fn ssz_bytes_len(&self) -> usize { + self.0.ssz_bytes_len() + } +} diff --git a/consensus/types/src/lib.rs b/consensus/types/src/lib.rs index 32300173e..28234130d 100644 --- a/consensus/types/src/lib.rs +++ b/consensus/types/src/lib.rs @@ -86,11 +86,15 @@ pub mod sync_subnet_id; mod tree_hash_impls; pub mod validator_registration_data; +mod beacon_block_and_blobs; +mod kzg_commitment; pub mod slot_data; #[cfg(feature = "sqlite")] pub mod sqlite; +pub use kzg_commitment::KZGCommitment; use ethereum_types::{H160, H256}; +use serde::Serialize; pub use crate::aggregate_and_proof::AggregateAndProof; pub use crate::attestation::{Attestation, Error as AttestationError}; @@ -98,12 +102,12 @@ 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, BeaconBlockMerge, BeaconBlockRef, + BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockDank, BeaconBlockMerge, BeaconBlockRef, BeaconBlockRefMut, BlindedBeaconBlock, }; pub use crate::beacon_block_body::{ - BeaconBlockBody, BeaconBlockBodyAltair, BeaconBlockBodyBase, BeaconBlockBodyMerge, - BeaconBlockBodyRef, BeaconBlockBodyRefMut, + BeaconBlockBody, BeaconBlockBodyAltair, BeaconBlockBodyBase, BeaconBlockBodyDank, + BeaconBlockBodyMerge, BeaconBlockBodyRef, BeaconBlockBodyRefMut, }; pub use crate::beacon_block_header::BeaconBlockHeader; pub use crate::beacon_committee::{BeaconCommittee, OwnedBeaconCommittee}; @@ -144,7 +148,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, + SignedBeaconBlockMerge, SignedBlindedBeaconBlock,SignedBeaconBlockDank }; pub use crate::signed_beacon_block_header::SignedBeaconBlockHeader; pub use crate::signed_contribution_and_proof::SignedContributionAndProof; @@ -165,12 +169,15 @@ pub use crate::validator::Validator; pub use crate::validator_registration_data::*; pub use crate::validator_subscription::ValidatorSubscription; pub use crate::voluntary_exit::VoluntaryExit; +use serde_big_array::BigArray; pub type CommitteeIndex = u64; pub type Hash256 = H256; pub type Uint256 = ethereum_types::U256; pub type Address = H160; pub type ForkVersion = [u8; 4]; +pub type BLSFieldElement = Uint256; +pub type Blob = FixedVector; pub use bls::{ AggregatePublicKey, AggregateSignature, Keypair, PublicKey, PublicKeyBytes, SecretKey, diff --git a/consensus/types/src/signed_beacon_block.rs b/consensus/types/src/signed_beacon_block.rs index 5c40c4685..317cfddca 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), + variants(Base, Altair, Merge, Dank), variant_attributes( derive( Debug, @@ -72,6 +72,8 @@ pub struct SignedBeaconBlock = FullPayload, #[superstruct(only(Merge), partial_getter(rename = "message_merge"))] pub message: BeaconBlockMerge, + #[superstruct(only(Dank), partial_getter(rename = "message_dank"))] + pub message: BeaconBlockDank, pub signature: Signature, } @@ -129,6 +131,9 @@ impl> SignedBeaconBlock { BeaconBlock::Merge(message) => { SignedBeaconBlock::Merge(SignedBeaconBlockMerge { message, signature }) } + BeaconBlock::Dank(message) => { + SignedBeaconBlock::Dank(SignedBeaconBlockDank { message, signature }) + } } } diff --git a/testing/ef_tests/src/cases/common.rs b/testing/ef_tests/src/cases/common.rs index e77e56193..5cb460b4f 100644 --- a/testing/ef_tests/src/cases/common.rs +++ b/testing/ef_tests/src/cases/common.rs @@ -78,5 +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::Dank => 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 0283d13da..1c3f42e18 100644 --- a/testing/ef_tests/src/cases/epoch_processing.rs +++ b/testing/ef_tests/src/cases/epoch_processing.rs @@ -278,6 +278,7 @@ impl> Case for EpochProcessing { } // No phase0 tests for Altair and later. ForkName::Altair | ForkName::Merge => T::name() != "participation_record_updates", + ForkName::Dank => 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 ae12447ab..bbe84409e 100644 --- a/testing/ef_tests/src/cases/fork.rs +++ b/testing/ef_tests/src/cases/fork.rs @@ -61,6 +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::Dank => panic!("danksharding not supported"), }; compare_beacon_state_results_without_caches(&mut result, &mut expected) diff --git a/testing/ef_tests/src/cases/transition.rs b/testing/ef_tests/src/cases/transition.rs index d2b1bb2c6..f97949c39 100644 --- a/testing/ef_tests/src/cases/transition.rs +++ b/testing/ef_tests/src/cases/transition.rs @@ -42,6 +42,11 @@ impl LoadCase for TransitionTest { spec.altair_fork_epoch = Some(Epoch::new(0)); spec.bellatrix_fork_epoch = Some(metadata.fork_epoch); } + //TODO(sean): fix + ForkName::Dank => { + spec.altair_fork_epoch = Some(Epoch::new(0)); + spec.bellatrix_fork_epoch = Some(metadata.fork_epoch); + } } // Load blocks diff --git a/validator_client/src/signing_method/web3signer.rs b/validator_client/src/signing_method/web3signer.rs index cf02ae0c3..d16d7693c 100644 --- a/validator_client/src/signing_method/web3signer.rs +++ b/validator_client/src/signing_method/web3signer.rs @@ -90,6 +90,11 @@ impl<'a, T: EthSpec, Payload: ExecPayload> Web3SignerObject<'a, T, Payload> { block: None, block_header: Some(block.block_header()), }), + BeaconBlock::Dank(_) => Ok(Web3SignerObject::BeaconBlock { + version: ForkName::Dank, + block: None, + block_header: Some(block.block_header()), + }), } }