add/update types
This commit is contained in:
parent
ff145b986f
commit
de44b300c0
11
Cargo.lock
generated
11
Cargo.lock
generated
@ -5736,6 +5736,16 @@ dependencies = [
|
|||||||
"serde_derive",
|
"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]]
|
[[package]]
|
||||||
name = "serde_array_query"
|
name = "serde_array_query"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@ -7107,6 +7117,7 @@ dependencies = [
|
|||||||
"rusqlite",
|
"rusqlite",
|
||||||
"safe_arith",
|
"safe_arith",
|
||||||
"serde",
|
"serde",
|
||||||
|
"serde-big-array",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_with",
|
"serde_with",
|
||||||
|
@ -296,7 +296,8 @@ 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 => {
|
//TODO(sean): figure this out
|
||||||
|
ForkName::Altair | ForkName::Merge | ForkName::Dank => {
|
||||||
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, SignedBeaconBlockDank, SignedBeaconBlockMerge,
|
||||||
};
|
};
|
||||||
use unsigned_varint::codec::Uvi;
|
use unsigned_varint::codec::Uvi;
|
||||||
|
|
||||||
@ -407,6 +407,7 @@ 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::Dank { .. } => fork_context.to_context_bytes(ForkName::Dank),
|
||||||
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 +587,9 @@ fn handle_v2_response<T: EthSpec>(
|
|||||||
decoded_buffer,
|
decoded_buffer,
|
||||||
)?),
|
)?),
|
||||||
)))),
|
)))),
|
||||||
|
ForkName::Dank => Ok(Some(RPCResponse::BlocksByRange(Box::new(
|
||||||
|
SignedBeaconBlock::Dank(SignedBeaconBlockDank::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 +605,9 @@ fn handle_v2_response<T: EthSpec>(
|
|||||||
decoded_buffer,
|
decoded_buffer,
|
||||||
)?),
|
)?),
|
||||||
)))),
|
)))),
|
||||||
|
ForkName::Dank => Ok(Some(RPCResponse::BlocksByRoot(Box::new(
|
||||||
|
SignedBeaconBlock::Dank(SignedBeaconBlockDank::from_ssz_bytes(decoded_buffer)?),
|
||||||
|
)))),
|
||||||
},
|
},
|
||||||
_ => Err(RPCError::ErrorResponse(
|
_ => Err(RPCError::ErrorResponse(
|
||||||
RPCResponseErrorCode::InvalidRequest,
|
RPCResponseErrorCode::InvalidRequest,
|
||||||
|
@ -11,8 +11,8 @@ 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,
|
SignedBeaconBlockDank, SignedBeaconBlockMerge, SignedContributionAndProof, SignedVoluntaryExit,
|
||||||
SyncCommitteeMessage, SyncSubnetId,
|
SubnetId, SyncCommitteeMessage, SyncSubnetId,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
@ -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::Dank) => SignedBeaconBlock::<T>::Dank(
|
||||||
|
SignedBeaconBlockDank::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: {:?}",
|
||||||
|
@ -374,6 +374,7 @@ macro_rules! impl_decodable_for_u8_array {
|
|||||||
|
|
||||||
impl_decodable_for_u8_array!(4);
|
impl_decodable_for_u8_array!(4);
|
||||||
impl_decodable_for_u8_array!(32);
|
impl_decodable_for_u8_array!(32);
|
||||||
|
impl_decodable_for_u8_array!(48);
|
||||||
|
|
||||||
macro_rules! impl_for_vec {
|
macro_rules! impl_for_vec {
|
||||||
($type: ty, $max_len: expr) => {
|
($type: ty, $max_len: expr) => {
|
||||||
|
@ -483,6 +483,7 @@ macro_rules! impl_encodable_for_u8_array {
|
|||||||
|
|
||||||
impl_encodable_for_u8_array!(4);
|
impl_encodable_for_u8_array!(4);
|
||||||
impl_encodable_for_u8_array!(32);
|
impl_encodable_for_u8_array!(32);
|
||||||
|
impl_encodable_for_u8_array!(48);
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
@ -230,7 +230,9 @@ pub fn process_attestations<'a, T: EthSpec, Payload: ExecPayload<T>>(
|
|||||||
BeaconBlockBodyRef::Base(_) => {
|
BeaconBlockBodyRef::Base(_) => {
|
||||||
base::process_attestations(state, block_body.attestations(), verify_signatures, spec)?;
|
base::process_attestations(state, block_body.attestations(), verify_signatures, spec)?;
|
||||||
}
|
}
|
||||||
BeaconBlockBodyRef::Altair(_) | BeaconBlockBodyRef::Merge(_) => {
|
BeaconBlockBodyRef::Altair(_)
|
||||||
|
| BeaconBlockBodyRef::Merge(_)
|
||||||
|
| BeaconBlockBodyRef::Dank(_) => {
|
||||||
altair::process_attestations(
|
altair::process_attestations(
|
||||||
state,
|
state,
|
||||||
block_body.attestations(),
|
block_body.attestations(),
|
||||||
|
@ -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!(4);
|
||||||
impl_for_lt_32byte_u8_array!(32);
|
impl_for_lt_32byte_u8_array!(32);
|
||||||
|
impl_for_lt_32byte_u8_array!(48);
|
||||||
|
|
||||||
impl TreeHash for U128 {
|
impl TreeHash for U128 {
|
||||||
fn tree_hash_type() -> TreeHashType {
|
fn tree_hash_type() -> TreeHashType {
|
||||||
|
@ -9,6 +9,7 @@ name = "benches"
|
|||||||
harness = false
|
harness = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
serde-big-array = {version = "0.3.2", features = ["const-generics"]}
|
||||||
bls = { path = "../../crypto/bls" }
|
bls = { path = "../../crypto/bls" }
|
||||||
compare_fields = { path = "../../common/compare_fields" }
|
compare_fields = { path = "../../common/compare_fields" }
|
||||||
compare_fields_derive = { path = "../../common/compare_fields_derive" }
|
compare_fields_derive = { path = "../../common/compare_fields_derive" }
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::beacon_block_body::{
|
use crate::beacon_block_body::{
|
||||||
BeaconBlockBodyAltair, BeaconBlockBodyBase, BeaconBlockBodyMerge, BeaconBlockBodyRef,
|
BeaconBlockBodyAltair, BeaconBlockBodyBase, BeaconBlockBodyDank, BeaconBlockBodyMerge,
|
||||||
BeaconBlockBodyRefMut,
|
BeaconBlockBodyRef, BeaconBlockBodyRefMut,
|
||||||
};
|
};
|
||||||
use crate::test_utils::TestRandom;
|
use crate::test_utils::TestRandom;
|
||||||
use crate::*;
|
use crate::*;
|
||||||
@ -17,7 +17,7 @@ use tree_hash_derive::TreeHash;
|
|||||||
|
|
||||||
/// A block of the `BeaconChain`.
|
/// A block of the `BeaconChain`.
|
||||||
#[superstruct(
|
#[superstruct(
|
||||||
variants(Base, Altair, Merge),
|
variants(Base, Altair, Merge, Dank),
|
||||||
variant_attributes(
|
variant_attributes(
|
||||||
derive(
|
derive(
|
||||||
Debug,
|
Debug,
|
||||||
@ -64,6 +64,8 @@ pub struct BeaconBlock<T: EthSpec, Payload: ExecPayload<T> = FullPayload<T>> {
|
|||||||
pub body: BeaconBlockBodyAltair<T, Payload>,
|
pub body: BeaconBlockBodyAltair<T, Payload>,
|
||||||
#[superstruct(only(Merge), partial_getter(rename = "body_merge"))]
|
#[superstruct(only(Merge), partial_getter(rename = "body_merge"))]
|
||||||
pub body: BeaconBlockBodyMerge<T, Payload>,
|
pub body: BeaconBlockBodyMerge<T, Payload>,
|
||||||
|
#[superstruct(only(Dank), partial_getter(rename = "body_dank"))]
|
||||||
|
pub body: BeaconBlockBodyDank<T, Payload>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type BlindedBeaconBlock<E> = BeaconBlock<E, BlindedPayload<E>>;
|
pub type BlindedBeaconBlock<E> = BeaconBlock<E, BlindedPayload<E>>;
|
||||||
@ -189,6 +191,7 @@ impl<'a, T: EthSpec, Payload: ExecPayload<T>> BeaconBlockRef<'a, T, Payload> {
|
|||||||
BeaconBlockRef::Base { .. } => ForkName::Base,
|
BeaconBlockRef::Base { .. } => ForkName::Base,
|
||||||
BeaconBlockRef::Altair { .. } => ForkName::Altair,
|
BeaconBlockRef::Altair { .. } => ForkName::Altair,
|
||||||
BeaconBlockRef::Merge { .. } => ForkName::Merge,
|
BeaconBlockRef::Merge { .. } => ForkName::Merge,
|
||||||
|
BeaconBlockRef::Dank { .. } => ForkName::Dank,
|
||||||
};
|
};
|
||||||
|
|
||||||
if fork_at_slot == object_fork {
|
if fork_at_slot == object_fork {
|
||||||
|
13
consensus/types/src/beacon_block_and_blobs.rs
Normal file
13
consensus/types/src/beacon_block_and_blobs.rs
Normal file
@ -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<E: EthSpec> {
|
||||||
|
pub block: SignedBeaconBlock<E>,
|
||||||
|
pub blobs: VariableList<Blob<E::ChunksPerBlob>, E::MaxObjectListSize>,
|
||||||
|
}
|
@ -13,7 +13,7 @@ use tree_hash_derive::TreeHash;
|
|||||||
///
|
///
|
||||||
/// This *superstruct* abstracts over the hard-fork.
|
/// This *superstruct* abstracts over the hard-fork.
|
||||||
#[superstruct(
|
#[superstruct(
|
||||||
variants(Base, Altair, Merge),
|
variants(Base, Altair, Merge, Dank),
|
||||||
variant_attributes(
|
variant_attributes(
|
||||||
derive(
|
derive(
|
||||||
Debug,
|
Debug,
|
||||||
@ -47,14 +47,16 @@ pub struct BeaconBlockBody<T: EthSpec, Payload: ExecPayload<T> = FullPayload<T>>
|
|||||||
pub attestations: VariableList<Attestation<T>, T::MaxAttestations>,
|
pub attestations: VariableList<Attestation<T>, T::MaxAttestations>,
|
||||||
pub deposits: VariableList<Deposit, T::MaxDeposits>,
|
pub deposits: VariableList<Deposit, T::MaxDeposits>,
|
||||||
pub voluntary_exits: VariableList<SignedVoluntaryExit, T::MaxVoluntaryExits>,
|
pub voluntary_exits: VariableList<SignedVoluntaryExit, T::MaxVoluntaryExits>,
|
||||||
#[superstruct(only(Altair, Merge))]
|
#[superstruct(only(Altair, Merge, Dank))]
|
||||||
pub sync_aggregate: SyncAggregate<T>,
|
pub sync_aggregate: SyncAggregate<T>,
|
||||||
// We flatten the execution payload so that serde can use the name of the inner type,
|
// 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
|
// either `execution_payload` for full payloads, or `execution_payload_header` for blinded
|
||||||
// payloads.
|
// payloads.
|
||||||
#[superstruct(only(Merge))]
|
#[superstruct(only(Merge, Dank))]
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub execution_payload: Payload,
|
pub execution_payload: Payload,
|
||||||
|
#[superstruct(only(Dank))]
|
||||||
|
pub blob_kzgs: VariableList<KZGCommitment, T::MaxObjectListSize>,
|
||||||
#[superstruct(only(Base, Altair))]
|
#[superstruct(only(Base, Altair))]
|
||||||
#[ssz(skip_serializing, skip_deserializing)]
|
#[ssz(skip_serializing, skip_deserializing)]
|
||||||
#[tree_hash(skip_hashing)]
|
#[tree_hash(skip_hashing)]
|
||||||
@ -69,6 +71,7 @@ impl<'a, T: EthSpec> BeaconBlockBodyRef<'a, T> {
|
|||||||
BeaconBlockBodyRef::Base { .. } => ForkName::Base,
|
BeaconBlockBodyRef::Base { .. } => ForkName::Base,
|
||||||
BeaconBlockBodyRef::Altair { .. } => ForkName::Altair,
|
BeaconBlockBodyRef::Altair { .. } => ForkName::Altair,
|
||||||
BeaconBlockBodyRef::Merge { .. } => ForkName::Merge,
|
BeaconBlockBodyRef::Merge { .. } => ForkName::Merge,
|
||||||
|
BeaconBlockBodyRef::Dank { .. } => ForkName::Dank,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,6 +150,10 @@ pub struct ChainSpec {
|
|||||||
pub terminal_block_hash_activation_epoch: Epoch,
|
pub terminal_block_hash_activation_epoch: Epoch,
|
||||||
pub safe_slots_to_import_optimistically: u64,
|
pub safe_slots_to_import_optimistically: u64,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Danksharding hard fork params
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Networking
|
* Networking
|
||||||
*/
|
*/
|
||||||
@ -245,6 +249,8 @@ impl ChainSpec {
|
|||||||
ForkName::Base => self.genesis_fork_version,
|
ForkName::Base => self.genesis_fork_version,
|
||||||
ForkName::Altair => self.altair_fork_version,
|
ForkName::Altair => self.altair_fork_version,
|
||||||
ForkName::Merge => self.bellatrix_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::Base => Some(Epoch::new(0)),
|
||||||
ForkName::Altair => self.altair_fork_epoch,
|
ForkName::Altair => self.altair_fork_epoch,
|
||||||
ForkName::Merge => self.bellatrix_fork_epoch,
|
ForkName::Merge => self.bellatrix_fork_epoch,
|
||||||
|
//TODO: update this
|
||||||
|
ForkName::Dank => self.bellatrix_fork_epoch,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,6 +95,11 @@ pub trait EthSpec: 'static + Default + Sync + Send + Clone + Debug + PartialEq +
|
|||||||
type GasLimitDenominator: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
type GasLimitDenominator: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
||||||
type MinGasLimit: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
type MinGasLimit: Unsigned + Clone + Sync + Send + Debug + PartialEq;
|
||||||
type MaxExtraDataBytes: 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)
|
* Derived values (set these CAREFULLY)
|
||||||
*/
|
*/
|
||||||
@ -262,6 +267,8 @@ impl EthSpec for MainnetEthSpec {
|
|||||||
type GasLimitDenominator = U1024;
|
type GasLimitDenominator = U1024;
|
||||||
type MinGasLimit = U5000;
|
type MinGasLimit = U5000;
|
||||||
type MaxExtraDataBytes = U32;
|
type MaxExtraDataBytes = U32;
|
||||||
|
type MaxObjectListSize = U16777216; // 2**24
|
||||||
|
type ChunksPerBlob = U4096;
|
||||||
type SyncSubcommitteeSize = U128; // 512 committee size / 4 sync committee subnet count
|
type SyncSubcommitteeSize = U128; // 512 committee size / 4 sync committee subnet count
|
||||||
type MaxPendingAttestations = U4096; // 128 max attestations * 32 slots per epoch
|
type MaxPendingAttestations = U4096; // 128 max attestations * 32 slots per epoch
|
||||||
type SlotsPerEth1VotingPeriod = U2048; // 64 epochs * 32 slots per epoch
|
type SlotsPerEth1VotingPeriod = U2048; // 64 epochs * 32 slots per epoch
|
||||||
@ -309,7 +316,9 @@ impl EthSpec for MinimalEthSpec {
|
|||||||
BytesPerLogsBloom,
|
BytesPerLogsBloom,
|
||||||
GasLimitDenominator,
|
GasLimitDenominator,
|
||||||
MinGasLimit,
|
MinGasLimit,
|
||||||
MaxExtraDataBytes
|
MaxExtraDataBytes,
|
||||||
|
MaxObjectListSize,
|
||||||
|
ChunksPerBlob
|
||||||
});
|
});
|
||||||
|
|
||||||
fn default_spec() -> ChainSpec {
|
fn default_spec() -> ChainSpec {
|
||||||
@ -354,6 +363,8 @@ impl EthSpec for GnosisEthSpec {
|
|||||||
type SyncSubcommitteeSize = U128; // 512 committee size / 4 sync committee subnet count
|
type SyncSubcommitteeSize = U128; // 512 committee size / 4 sync committee subnet count
|
||||||
type MaxPendingAttestations = U2048; // 128 max attestations * 16 slots per epoch
|
type MaxPendingAttestations = U2048; // 128 max attestations * 16 slots per epoch
|
||||||
type SlotsPerEth1VotingPeriod = U1024; // 64 epochs * 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 {
|
fn default_spec() -> ChainSpec {
|
||||||
ChainSpec::gnosis()
|
ChainSpec::gnosis()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use crate::{ChainSpec, Epoch};
|
use crate::{ChainSpec, Epoch, Fork};
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::fmt::{self, Display, Formatter};
|
use std::fmt::{self, Display, Formatter};
|
||||||
@ -11,6 +11,7 @@ pub enum ForkName {
|
|||||||
Base,
|
Base,
|
||||||
Altair,
|
Altair,
|
||||||
Merge,
|
Merge,
|
||||||
|
Dank,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ForkName {
|
impl ForkName {
|
||||||
@ -38,6 +39,12 @@ impl ForkName {
|
|||||||
spec.bellatrix_fork_epoch = Some(Epoch::new(0));
|
spec.bellatrix_fork_epoch = Some(Epoch::new(0));
|
||||||
spec
|
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::Base => None,
|
||||||
ForkName::Altair => Some(ForkName::Base),
|
ForkName::Altair => Some(ForkName::Base),
|
||||||
ForkName::Merge => Some(ForkName::Altair),
|
ForkName::Merge => Some(ForkName::Altair),
|
||||||
|
ForkName::Dank => Some(ForkName::Merge),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +67,8 @@ impl ForkName {
|
|||||||
match self {
|
match self {
|
||||||
ForkName::Base => Some(ForkName::Altair),
|
ForkName::Base => Some(ForkName::Altair),
|
||||||
ForkName::Altair => Some(ForkName::Merge),
|
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;
|
let (value, extra_data) = $body;
|
||||||
($t::Merge(value), extra_data)
|
($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::Base => "phase0".fmt(f),
|
||||||
ForkName::Altair => "altair".fmt(f),
|
ForkName::Altair => "altair".fmt(f),
|
||||||
ForkName::Merge => "bellatrix".fmt(f),
|
ForkName::Merge => "bellatrix".fmt(f),
|
||||||
|
ForkName::Dank => "dank".fmt(f),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
63
consensus/types/src/kzg_commitment.rs
Normal file
63
consensus/types/src/kzg_commitment.rs
Normal file
@ -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<u8> {
|
||||||
|
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<Self, DecodeError> {
|
||||||
|
<[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<u8>) {
|
||||||
|
self.0.ssz_append(buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ssz_bytes_len(&self) -> usize {
|
||||||
|
self.0.ssz_bytes_len()
|
||||||
|
}
|
||||||
|
}
|
@ -86,11 +86,15 @@ pub mod sync_subnet_id;
|
|||||||
mod tree_hash_impls;
|
mod tree_hash_impls;
|
||||||
pub mod validator_registration_data;
|
pub mod validator_registration_data;
|
||||||
|
|
||||||
|
mod beacon_block_and_blobs;
|
||||||
|
mod kzg_commitment;
|
||||||
pub mod slot_data;
|
pub mod slot_data;
|
||||||
#[cfg(feature = "sqlite")]
|
#[cfg(feature = "sqlite")]
|
||||||
pub mod sqlite;
|
pub mod sqlite;
|
||||||
|
pub use kzg_commitment::KZGCommitment;
|
||||||
|
|
||||||
use ethereum_types::{H160, H256};
|
use ethereum_types::{H160, H256};
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
pub use crate::aggregate_and_proof::AggregateAndProof;
|
pub use crate::aggregate_and_proof::AggregateAndProof;
|
||||||
pub use crate::attestation::{Attestation, Error as AttestationError};
|
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::attestation_duty::AttestationDuty;
|
||||||
pub use crate::attester_slashing::AttesterSlashing;
|
pub use crate::attester_slashing::AttesterSlashing;
|
||||||
pub use crate::beacon_block::{
|
pub use crate::beacon_block::{
|
||||||
BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockMerge, BeaconBlockRef,
|
BeaconBlock, BeaconBlockAltair, BeaconBlockBase, BeaconBlockDank, BeaconBlockMerge, BeaconBlockRef,
|
||||||
BeaconBlockRefMut, BlindedBeaconBlock,
|
BeaconBlockRefMut, BlindedBeaconBlock,
|
||||||
};
|
};
|
||||||
pub use crate::beacon_block_body::{
|
pub use crate::beacon_block_body::{
|
||||||
BeaconBlockBody, BeaconBlockBodyAltair, BeaconBlockBodyBase, BeaconBlockBodyMerge,
|
BeaconBlockBody, BeaconBlockBodyAltair, BeaconBlockBodyBase, BeaconBlockBodyDank,
|
||||||
BeaconBlockBodyRef, BeaconBlockBodyRefMut,
|
BeaconBlockBodyMerge, BeaconBlockBodyRef, BeaconBlockBodyRefMut,
|
||||||
};
|
};
|
||||||
pub use crate::beacon_block_header::BeaconBlockHeader;
|
pub use crate::beacon_block_header::BeaconBlockHeader;
|
||||||
pub use crate::beacon_committee::{BeaconCommittee, OwnedBeaconCommittee};
|
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_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,SignedBeaconBlockDank
|
||||||
};
|
};
|
||||||
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;
|
||||||
@ -165,12 +169,15 @@ pub use crate::validator::Validator;
|
|||||||
pub use crate::validator_registration_data::*;
|
pub use crate::validator_registration_data::*;
|
||||||
pub use crate::validator_subscription::ValidatorSubscription;
|
pub use crate::validator_subscription::ValidatorSubscription;
|
||||||
pub use crate::voluntary_exit::VoluntaryExit;
|
pub use crate::voluntary_exit::VoluntaryExit;
|
||||||
|
use serde_big_array::BigArray;
|
||||||
|
|
||||||
pub type CommitteeIndex = u64;
|
pub type CommitteeIndex = u64;
|
||||||
pub type Hash256 = H256;
|
pub type Hash256 = H256;
|
||||||
pub type Uint256 = ethereum_types::U256;
|
pub type Uint256 = ethereum_types::U256;
|
||||||
pub type Address = H160;
|
pub type Address = H160;
|
||||||
pub type ForkVersion = [u8; 4];
|
pub type ForkVersion = [u8; 4];
|
||||||
|
pub type BLSFieldElement = Uint256;
|
||||||
|
pub type Blob<T> = FixedVector<BLSFieldElement, T>;
|
||||||
|
|
||||||
pub use bls::{
|
pub use bls::{
|
||||||
AggregatePublicKey, AggregateSignature, Keypair, PublicKey, PublicKeyBytes, SecretKey,
|
AggregatePublicKey, AggregateSignature, Keypair, PublicKey, PublicKeyBytes, SecretKey,
|
||||||
|
@ -38,7 +38,7 @@ impl From<SignedBeaconBlockHash> for Hash256 {
|
|||||||
|
|
||||||
/// A `BeaconBlock` and a signature from its proposer.
|
/// A `BeaconBlock` and a signature from its proposer.
|
||||||
#[superstruct(
|
#[superstruct(
|
||||||
variants(Base, Altair, Merge),
|
variants(Base, Altair, Merge, Dank),
|
||||||
variant_attributes(
|
variant_attributes(
|
||||||
derive(
|
derive(
|
||||||
Debug,
|
Debug,
|
||||||
@ -72,6 +72,8 @@ pub struct SignedBeaconBlock<E: EthSpec, Payload: ExecPayload<E> = FullPayload<E
|
|||||||
pub message: BeaconBlockAltair<E, Payload>,
|
pub message: BeaconBlockAltair<E, Payload>,
|
||||||
#[superstruct(only(Merge), partial_getter(rename = "message_merge"))]
|
#[superstruct(only(Merge), partial_getter(rename = "message_merge"))]
|
||||||
pub message: BeaconBlockMerge<E, Payload>,
|
pub message: BeaconBlockMerge<E, Payload>,
|
||||||
|
#[superstruct(only(Dank), partial_getter(rename = "message_dank"))]
|
||||||
|
pub message: BeaconBlockDank<E, Payload>,
|
||||||
pub signature: Signature,
|
pub signature: Signature,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,6 +131,9 @@ impl<E: EthSpec, Payload: ExecPayload<E>> SignedBeaconBlock<E, Payload> {
|
|||||||
BeaconBlock::Merge(message) => {
|
BeaconBlock::Merge(message) => {
|
||||||
SignedBeaconBlock::Merge(SignedBeaconBlockMerge { message, signature })
|
SignedBeaconBlock::Merge(SignedBeaconBlockMerge { message, signature })
|
||||||
}
|
}
|
||||||
|
BeaconBlock::Dank(message) => {
|
||||||
|
SignedBeaconBlock::Dank(SignedBeaconBlockDank { message, signature })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,5 +78,6 @@ pub fn previous_fork(fork_name: ForkName) -> ForkName {
|
|||||||
ForkName::Base => ForkName::Base,
|
ForkName::Base => ForkName::Base,
|
||||||
ForkName::Altair => ForkName::Base,
|
ForkName::Altair => ForkName::Base,
|
||||||
ForkName::Merge => ForkName::Altair, // TODO: Check this when tests are released..
|
ForkName::Merge => ForkName::Altair, // TODO: Check this when tests are released..
|
||||||
|
ForkName::Dank => ForkName::Merge, // TODO: Check this when tests are released..
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -278,6 +278,7 @@ impl<E: EthSpec, T: EpochTransition<E>> Case for EpochProcessing<E, T> {
|
|||||||
}
|
}
|
||||||
// No phase0 tests for Altair and later.
|
// No phase0 tests for Altair and later.
|
||||||
ForkName::Altair | ForkName::Merge => T::name() != "participation_record_updates",
|
ForkName::Altair | ForkName::Merge => T::name() != "participation_record_updates",
|
||||||
|
ForkName::Dank => false, // TODO: revisit when tests are out
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +61,7 @@ impl<E: EthSpec> Case for ForkTest<E> {
|
|||||||
ForkName::Base => panic!("phase0 not supported"),
|
ForkName::Base => panic!("phase0 not supported"),
|
||||||
ForkName::Altair => upgrade_to_altair(&mut result_state, spec).map(|_| result_state),
|
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::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)
|
compare_beacon_state_results_without_caches(&mut result, &mut expected)
|
||||||
|
@ -42,6 +42,11 @@ impl<E: EthSpec> LoadCase for TransitionTest<E> {
|
|||||||
spec.altair_fork_epoch = Some(Epoch::new(0));
|
spec.altair_fork_epoch = Some(Epoch::new(0));
|
||||||
spec.bellatrix_fork_epoch = Some(metadata.fork_epoch);
|
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
|
// Load blocks
|
||||||
|
@ -90,6 +90,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::Dank(_) => Ok(Web3SignerObject::BeaconBlock {
|
||||||
|
version: ForkName::Dank,
|
||||||
|
block: None,
|
||||||
|
block_header: Some(block.block_header()),
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user