get spec tests working and fix json serialization
This commit is contained in:
parent
abc933faa8
commit
beddcfaac2
11
Cargo.lock
generated
11
Cargo.lock
generated
@ -3095,7 +3095,6 @@ dependencies = [
|
||||
"hex",
|
||||
"rand 0.7.3",
|
||||
"serde",
|
||||
"serde-big-array",
|
||||
"serde_derive",
|
||||
"tree_hash",
|
||||
]
|
||||
@ -5587,16 +5586,6 @@ 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"
|
||||
|
4
Makefile
4
Makefile
@ -21,7 +21,7 @@ CROSS_FEATURES ?= gnosis,slasher-lmdb,slasher-mdbx
|
||||
CROSS_PROFILE ?= release
|
||||
|
||||
# List of features to use when running EF tests.
|
||||
EF_TEST_FEATURES ?= beacon_chain/withdrawals,beacon_chain/withdrawals-processing
|
||||
EF_TEST_FEATURES ?= withdrawals,withdrawals-processing
|
||||
|
||||
# Cargo profile for regular builds.
|
||||
PROFILE ?= release
|
||||
@ -38,7 +38,7 @@ install:
|
||||
|
||||
# Builds the lcli binary in release (optimized).
|
||||
install-lcli:
|
||||
cargo install --path lcli --force --locked --features "$(FEATURES)" --profile "$(PROFILE)"
|
||||
cargo install --path lcli --force --locked --features "$(FEATURES),$(EF_TEST_FEATURES)" --profile "$(PROFILE)"
|
||||
|
||||
# The following commands use `cross` to build a cross-compile.
|
||||
#
|
||||
|
@ -3707,120 +3707,142 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
} = partial_beacon_block;
|
||||
|
||||
let (inner_block, blobs_opt) = match &state {
|
||||
BeaconState::Base(_) => (BeaconBlock::Base(BeaconBlockBase {
|
||||
slot,
|
||||
proposer_index,
|
||||
parent_root,
|
||||
state_root: Hash256::zero(),
|
||||
body: BeaconBlockBodyBase {
|
||||
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(),
|
||||
_phantom: PhantomData,
|
||||
},
|
||||
}), None),
|
||||
BeaconState::Altair(_) => (BeaconBlock::Altair(BeaconBlockAltair {
|
||||
slot,
|
||||
proposer_index,
|
||||
parent_root,
|
||||
state_root: Hash256::zero(),
|
||||
body: BeaconBlockBodyAltair {
|
||||
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)?,
|
||||
_phantom: PhantomData,
|
||||
},
|
||||
}), None),
|
||||
BeaconState::Base(_) => (
|
||||
BeaconBlock::Base(BeaconBlockBase {
|
||||
slot,
|
||||
proposer_index,
|
||||
parent_root,
|
||||
state_root: Hash256::zero(),
|
||||
body: BeaconBlockBodyBase {
|
||||
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(),
|
||||
_phantom: PhantomData,
|
||||
},
|
||||
}),
|
||||
None,
|
||||
),
|
||||
BeaconState::Altair(_) => (
|
||||
BeaconBlock::Altair(BeaconBlockAltair {
|
||||
slot,
|
||||
proposer_index,
|
||||
parent_root,
|
||||
state_root: Hash256::zero(),
|
||||
body: BeaconBlockBodyAltair {
|
||||
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)?,
|
||||
_phantom: PhantomData,
|
||||
},
|
||||
}),
|
||||
None,
|
||||
),
|
||||
BeaconState::Merge(_) => {
|
||||
let (payload, _, _) = block_contents.ok_or(BlockProductionError::MissingExecutionPayload)?.deconstruct();
|
||||
(BeaconBlock::Merge(BeaconBlockMerge {
|
||||
slot,
|
||||
proposer_index,
|
||||
parent_root,
|
||||
state_root: Hash256::zero(),
|
||||
body: BeaconBlockBodyMerge {
|
||||
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: payload
|
||||
.try_into()
|
||||
.map_err(|_| BlockProductionError::InvalidPayloadFork)?,
|
||||
},
|
||||
}), None)
|
||||
},
|
||||
let (payload, _, _) = block_contents
|
||||
.ok_or(BlockProductionError::MissingExecutionPayload)?
|
||||
.deconstruct();
|
||||
(
|
||||
BeaconBlock::Merge(BeaconBlockMerge {
|
||||
slot,
|
||||
proposer_index,
|
||||
parent_root,
|
||||
state_root: Hash256::zero(),
|
||||
body: BeaconBlockBodyMerge {
|
||||
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: payload
|
||||
.try_into()
|
||||
.map_err(|_| BlockProductionError::InvalidPayloadFork)?,
|
||||
},
|
||||
}),
|
||||
None,
|
||||
)
|
||||
}
|
||||
BeaconState::Capella(_) => {
|
||||
let (payload, _, _) = block_contents.ok_or(BlockProductionError::MissingExecutionPayload)?.deconstruct();
|
||||
let (payload, _, _) = block_contents
|
||||
.ok_or(BlockProductionError::MissingExecutionPayload)?
|
||||
.deconstruct();
|
||||
|
||||
(BeaconBlock::Capella(BeaconBlockCapella {
|
||||
slot,
|
||||
proposer_index,
|
||||
parent_root,
|
||||
state_root: Hash256::zero(),
|
||||
body: BeaconBlockBodyCapella {
|
||||
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: payload
|
||||
.try_into()
|
||||
.map_err(|_| BlockProductionError::InvalidPayloadFork)?,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
bls_to_execution_changes: bls_to_execution_changes.into(),
|
||||
},
|
||||
}), None)
|
||||
},
|
||||
(
|
||||
BeaconBlock::Capella(BeaconBlockCapella {
|
||||
slot,
|
||||
proposer_index,
|
||||
parent_root,
|
||||
state_root: Hash256::zero(),
|
||||
body: BeaconBlockBodyCapella {
|
||||
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: payload
|
||||
.try_into()
|
||||
.map_err(|_| BlockProductionError::InvalidPayloadFork)?,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
bls_to_execution_changes: bls_to_execution_changes.into(),
|
||||
},
|
||||
}),
|
||||
None,
|
||||
)
|
||||
}
|
||||
BeaconState::Eip4844(_) => {
|
||||
let (payload, kzg_commitments, blobs) = block_contents.ok_or(BlockProductionError::MissingExecutionPayload)?.deconstruct();
|
||||
let (payload, kzg_commitments, blobs) = block_contents
|
||||
.ok_or(BlockProductionError::MissingExecutionPayload)?
|
||||
.deconstruct();
|
||||
|
||||
(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: payload
|
||||
.try_into()
|
||||
.map_err(|_| BlockProductionError::InvalidPayloadFork)?,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
bls_to_execution_changes: bls_to_execution_changes.into(),
|
||||
blob_kzg_commitments: VariableList::from(kzg_commitments.ok_or(BlockProductionError::InvalidPayloadFork)?),
|
||||
},
|
||||
}), blobs)
|
||||
(
|
||||
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: payload
|
||||
.try_into()
|
||||
.map_err(|_| BlockProductionError::InvalidPayloadFork)?,
|
||||
#[cfg(feature = "withdrawals")]
|
||||
bls_to_execution_changes: bls_to_execution_changes.into(),
|
||||
blob_kzg_commitments: kzg_commitments
|
||||
.ok_or(BlockProductionError::InvalidPayloadFork)?,
|
||||
},
|
||||
}),
|
||||
blobs,
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
@ -3881,8 +3903,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
let blobs_sidecar = BlobsSidecar {
|
||||
beacon_block_slot: slot,
|
||||
beacon_block_root,
|
||||
blobs: VariableList::from(blobs),
|
||||
kzg_aggregate_proof: KzgProof::default(),
|
||||
blobs,
|
||||
kzg_aggregated_proof: KzgProof::default(),
|
||||
};
|
||||
self.blob_cache.put(beacon_block_root, blobs_sidecar);
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ pub fn validate_blob_for_gossip<T: BeaconChainTypes>(
|
||||
// }
|
||||
|
||||
// Verify that the KZG proof is a valid G1 point
|
||||
if PublicKey::deserialize(&blob_sidecar.kzg_aggregate_proof.0).is_err() {
|
||||
if PublicKey::deserialize(&blob_sidecar.kzg_aggregated_proof.0).is_err() {
|
||||
return Err(BlobError::InvalidKZGCommitment);
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ pub fn validate_blobs_sidecar<T: EthSpec>(
|
||||
kzg.verify_aggregate_kzg_proof(
|
||||
&blobs,
|
||||
expected_kzg_commitments,
|
||||
blobs_sidecar.kzg_aggregate_proof,
|
||||
blobs_sidecar.kzg_aggregated_proof,
|
||||
)
|
||||
.map_err(|e| format!("Failed to verify kzg proof: {:?}", e))
|
||||
}
|
||||
|
@ -747,10 +747,10 @@ impl HttpJsonRpc {
|
||||
pub async fn get_blobs_bundle_v1<T: EthSpec>(
|
||||
&self,
|
||||
payload_id: PayloadId,
|
||||
) -> Result<JsonBlobBundles<T>, Error> {
|
||||
) -> Result<JsonBlobsBundle<T>, Error> {
|
||||
let params = json!([JsonPayloadIdRequest::from(payload_id)]);
|
||||
|
||||
let response: JsonBlobBundles<T> = self
|
||||
let response: JsonBlobsBundle<T> = self
|
||||
.rpc_request(
|
||||
ENGINE_GET_BLOBS_BUNDLE_V1,
|
||||
params,
|
||||
|
@ -424,10 +424,11 @@ impl From<JsonPayloadAttributes> for PayloadAttributes {
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(bound = "T: EthSpec", rename_all = "camelCase")]
|
||||
pub struct JsonBlobBundles<T: EthSpec> {
|
||||
pub struct JsonBlobsBundle<T: EthSpec> {
|
||||
pub block_hash: ExecutionBlockHash,
|
||||
pub kzgs: Vec<KzgCommitment>,
|
||||
pub blobs: Vec<Blob<T>>,
|
||||
pub kzgs: VariableList<KzgCommitment, T::MaxBlobsPerBlock>,
|
||||
#[serde(with = "ssz_types::serde_utils::list_of_hex_fixed_vec")]
|
||||
pub blobs: VariableList<Blob<T>, T::MaxBlobsPerBlock>,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
|
@ -95,13 +95,19 @@ pub enum BlockProposalContents<T: EthSpec, Payload: AbstractExecPayload<T>> {
|
||||
Payload(Payload),
|
||||
PayloadAndBlobs {
|
||||
payload: Payload,
|
||||
kzg_commitments: Vec<KzgCommitment>,
|
||||
blobs: Vec<Blob<T>>,
|
||||
kzg_commitments: VariableList<KzgCommitment, T::MaxBlobsPerBlock>,
|
||||
blobs: VariableList<Blob<T>, T::MaxBlobsPerBlock>,
|
||||
},
|
||||
}
|
||||
|
||||
impl<T: EthSpec, Payload: AbstractExecPayload<T>> BlockProposalContents<T, Payload> {
|
||||
pub fn deconstruct(self) -> (Payload, Option<Vec<KzgCommitment>>, Option<Vec<Blob<T>>>) {
|
||||
pub fn deconstruct(
|
||||
self,
|
||||
) -> (
|
||||
Payload,
|
||||
Option<VariableList<KzgCommitment, T::MaxBlobsPerBlock>>,
|
||||
Option<VariableList<Blob<T>, T::MaxBlobsPerBlock>>,
|
||||
) {
|
||||
match self {
|
||||
Self::Payload(payload) => (payload, None, None),
|
||||
Self::PayloadAndBlobs {
|
||||
@ -132,26 +138,6 @@ impl<T: EthSpec, Payload: AbstractExecPayload<T>> BlockProposalContents<T, Paylo
|
||||
} => payload,
|
||||
}
|
||||
}
|
||||
pub fn kzg_commitments(&self) -> Option<&[KzgCommitment]> {
|
||||
match self {
|
||||
Self::Payload(_) => None,
|
||||
Self::PayloadAndBlobs {
|
||||
payload: _,
|
||||
kzg_commitments,
|
||||
blobs: _,
|
||||
} => Some(kzg_commitments),
|
||||
}
|
||||
}
|
||||
pub fn blobs(&self) -> Option<&[Blob<T>]> {
|
||||
match self {
|
||||
Self::Payload(_) => None,
|
||||
Self::PayloadAndBlobs {
|
||||
payload: _,
|
||||
kzg_commitments: _,
|
||||
blobs,
|
||||
} => Some(blobs),
|
||||
}
|
||||
}
|
||||
pub fn default_at_fork(fork_name: ForkName) -> Self {
|
||||
match fork_name {
|
||||
ForkName::Base | ForkName::Altair | ForkName::Merge | ForkName::Capella => {
|
||||
@ -159,8 +145,8 @@ impl<T: EthSpec, Payload: AbstractExecPayload<T>> BlockProposalContents<T, Paylo
|
||||
}
|
||||
ForkName::Eip4844 => BlockProposalContents::PayloadAndBlobs {
|
||||
payload: Payload::default_at_fork(fork_name),
|
||||
blobs: vec![],
|
||||
kzg_commitments: vec![],
|
||||
blobs: VariableList::default(),
|
||||
kzg_commitments: VariableList::default(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ pub async fn handle_rpc<T: EthSpec>(
|
||||
.unwrap())
|
||||
}
|
||||
}
|
||||
ENGINE_NEW_PAYLOAD_V1 => {
|
||||
ENGINE_NEW_PAYLOAD_V1 | ENGINE_NEW_PAYLOAD_V2 => {
|
||||
let request: JsonExecutionPayload<T> = get_param(params, 0)?;
|
||||
|
||||
// Canned responses set by block hash take priority.
|
||||
@ -120,7 +120,7 @@ pub async fn handle_rpc<T: EthSpec>(
|
||||
|
||||
Ok(serde_json::to_value(JsonExecutionPayloadV1::try_from(response).unwrap()).unwrap())
|
||||
}
|
||||
ENGINE_FORKCHOICE_UPDATED_V1 => {
|
||||
ENGINE_FORKCHOICE_UPDATED_V1 | ENGINE_FORKCHOICE_UPDATED_V2 => {
|
||||
let forkchoice_state: JsonForkchoiceStateV1 = get_param(params, 0)?;
|
||||
let payload_attributes: Option<JsonPayloadAttributes> = get_param(params, 1)?;
|
||||
|
||||
@ -153,6 +153,19 @@ pub async fn handle_rpc<T: EthSpec>(
|
||||
|
||||
Ok(serde_json::to_value(response).unwrap())
|
||||
}
|
||||
|
||||
ENGINE_GET_PAYLOAD_V2 => {
|
||||
let request: JsonPayloadIdRequest = get_param(params, 0)?;
|
||||
let id = request.into();
|
||||
|
||||
let response = ctx
|
||||
.execution_block_generator
|
||||
.write()
|
||||
.get_payload(&id)
|
||||
.ok_or_else(|| format!("no payload for id {:?}", id))?;
|
||||
|
||||
Ok(serde_json::to_value(JsonExecutionPayloadV2::try_from(response).unwrap()).unwrap())
|
||||
}
|
||||
ENGINE_EXCHANGE_TRANSITION_CONFIGURATION_V1 => {
|
||||
let block_generator = ctx.execution_block_generator.read();
|
||||
let transition_config: TransitionConfigurationV1 = TransitionConfigurationV1 {
|
||||
|
77
consensus/ssz_types/src/serde_utils/list_of_hex_fixed_vec.rs
Normal file
77
consensus/ssz_types/src/serde_utils/list_of_hex_fixed_vec.rs
Normal file
@ -0,0 +1,77 @@
|
||||
//! Serialize `VariableList<FixedVector<u8, M>, N>` as list of 0x-prefixed hex string.
|
||||
use crate::{FixedVector, VariableList};
|
||||
use serde::{ser::SerializeSeq, Deserialize, Deserializer, Serialize, Serializer};
|
||||
use std::marker::PhantomData;
|
||||
use typenum::Unsigned;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(transparent)]
|
||||
pub struct WrappedListOwned<N: Unsigned>(
|
||||
#[serde(with = "crate::serde_utils::hex_fixed_vec")] FixedVector<u8, N>,
|
||||
);
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(transparent)]
|
||||
pub struct WrappedListRef<'a, N: Unsigned>(
|
||||
#[serde(with = "crate::serde_utils::hex_fixed_vec")] &'a FixedVector<u8, N>,
|
||||
);
|
||||
|
||||
pub fn serialize<S, M, N>(
|
||||
list: &VariableList<FixedVector<u8, M>, N>,
|
||||
serializer: S,
|
||||
) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
M: Unsigned,
|
||||
N: Unsigned,
|
||||
{
|
||||
let mut seq = serializer.serialize_seq(Some(list.len()))?;
|
||||
for bytes in list {
|
||||
seq.serialize_element(&WrappedListRef(bytes))?;
|
||||
}
|
||||
seq.end()
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Visitor<M, N> {
|
||||
_phantom_m: PhantomData<M>,
|
||||
_phantom_n: PhantomData<N>,
|
||||
}
|
||||
|
||||
impl<'a, M, N> serde::de::Visitor<'a> for Visitor<M, N>
|
||||
where
|
||||
M: Unsigned,
|
||||
N: Unsigned,
|
||||
{
|
||||
type Value = VariableList<FixedVector<u8, M>, N>;
|
||||
|
||||
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(formatter, "a list of 0x-prefixed hex bytes")
|
||||
}
|
||||
|
||||
fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
|
||||
where
|
||||
A: serde::de::SeqAccess<'a>,
|
||||
{
|
||||
let mut list: VariableList<FixedVector<u8, M>, N> = <_>::default();
|
||||
|
||||
while let Some(val) = seq.next_element::<WrappedListOwned<M>>()? {
|
||||
list.push(val.0).map_err(|e| {
|
||||
serde::de::Error::custom(format!("failed to push value to list: {:?}.", e))
|
||||
})?;
|
||||
}
|
||||
|
||||
Ok(list)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn deserialize<'de, D, M, N>(
|
||||
deserializer: D,
|
||||
) -> Result<VariableList<FixedVector<u8, M>, N>, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
M: Unsigned,
|
||||
N: Unsigned,
|
||||
{
|
||||
deserializer.deserialize_seq(Visitor::default())
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
pub mod hex_fixed_vec;
|
||||
pub mod hex_var_list;
|
||||
pub mod list_of_hex_fixed_vec;
|
||||
pub mod list_of_hex_var_list;
|
||||
pub mod quoted_u64_fixed_vec;
|
||||
pub mod quoted_u64_var_list;
|
||||
|
@ -19,7 +19,6 @@ pub use process_operations::process_operations;
|
||||
pub use verify_attestation::{
|
||||
verify_attestation_for_block_inclusion, verify_attestation_for_state,
|
||||
};
|
||||
#[cfg(all(feature = "withdrawals", feature = "withdrawals-processing"))]
|
||||
pub use verify_bls_to_execution_change::verify_bls_to_execution_change;
|
||||
pub use verify_deposit::{
|
||||
get_existing_validator_index, verify_deposit_merkle_proof, verify_deposit_signature,
|
||||
@ -36,13 +35,11 @@ pub mod signature_sets;
|
||||
pub mod tests;
|
||||
mod verify_attestation;
|
||||
mod verify_attester_slashing;
|
||||
#[cfg(all(feature = "withdrawals", feature = "withdrawals-processing"))]
|
||||
mod verify_bls_to_execution_change;
|
||||
mod verify_deposit;
|
||||
mod verify_exit;
|
||||
mod verify_proposer_slashing;
|
||||
|
||||
#[cfg(feature = "withdrawals-processing")]
|
||||
use crate::common::decrease_balance;
|
||||
|
||||
#[cfg(feature = "arbitrary-fuzz")]
|
||||
@ -523,7 +520,6 @@ pub fn get_expected_withdrawals<T: EthSpec>(
|
||||
}
|
||||
|
||||
/// FIXME: add link to this function once the spec is stable
|
||||
#[cfg(all(feature = "withdrawals", feature = "withdrawals-processing"))]
|
||||
pub fn process_withdrawals<'payload, T: EthSpec, Payload: AbstractExecPayload<T>>(
|
||||
state: &mut BeaconState<T>,
|
||||
payload: Payload::Ref<'payload>,
|
||||
|
@ -289,7 +289,6 @@ pub fn process_exits<T: EthSpec>(
|
||||
///
|
||||
/// Returns `Ok(())` if the validation and state updates completed successfully. Otherwise returs
|
||||
/// an `Err` describing the invalid object or cause of failure.
|
||||
#[cfg(all(feature = "withdrawals", feature = "withdrawals-processing"))]
|
||||
pub fn process_bls_to_execution_changes<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
bls_to_execution_changes: &[SignedBlsToExecutionChange],
|
||||
|
@ -12,8 +12,9 @@ use tree_hash_derive::TreeHash;
|
||||
pub struct BlobsSidecar<T: EthSpec> {
|
||||
pub beacon_block_root: Hash256,
|
||||
pub beacon_block_slot: Slot,
|
||||
#[serde(with = "ssz_types::serde_utils::list_of_hex_fixed_vec")]
|
||||
pub blobs: VariableList<Blob<T>, T::MaxBlobsPerBlock>,
|
||||
pub kzg_aggregate_proof: KzgProof,
|
||||
pub kzg_aggregated_proof: KzgProof,
|
||||
}
|
||||
|
||||
impl<T: EthSpec> SignedRoot for BlobsSidecar<T> {}
|
||||
|
@ -254,11 +254,6 @@ pub trait EthSpec: 'static + Default + Sync + Send + Clone + Debug + PartialEq +
|
||||
Self::MaxBlobsPerBlock::to_usize()
|
||||
}
|
||||
|
||||
/// FIXME: why is this called chunks_per_blob??
|
||||
fn chunks_per_blob() -> usize {
|
||||
Self::FieldElementsPerBlob::to_usize()
|
||||
}
|
||||
|
||||
/// Returns the `BYTES_PER_BLOB` constant for the specification.
|
||||
fn bytes_per_blob() -> usize {
|
||||
Self::BytesPerBlob::to_usize()
|
||||
@ -339,6 +334,7 @@ impl EthSpec for MinimalEthSpec {
|
||||
type SlotsPerEth1VotingPeriod = U32; // 4 epochs * 8 slots per epoch
|
||||
type MaxWithdrawalsPerPayload = U4;
|
||||
type FieldElementsPerBlob = U4; //FIXME(sean) this is spec'd out currently but will likely change
|
||||
type BytesPerBlob = U128; //FIXME(sean) this is spec'd out currently but will likely change
|
||||
|
||||
params_from_eth_spec!(MainnetEthSpec {
|
||||
JustificationBitsLength,
|
||||
@ -361,8 +357,7 @@ impl EthSpec for MinimalEthSpec {
|
||||
MaxExtraDataBytes,
|
||||
MaxBlsToExecutionChanges,
|
||||
MaxBlobsPerBlock,
|
||||
BytesPerFieldElement,
|
||||
BytesPerBlob
|
||||
BytesPerFieldElement
|
||||
});
|
||||
|
||||
fn default_spec() -> ChainSpec {
|
||||
|
@ -170,8 +170,9 @@ pub use crate::signed_beacon_block::{
|
||||
SignedBlindedBeaconBlock,
|
||||
};
|
||||
pub use crate::signed_beacon_block_header::SignedBeaconBlockHeader;
|
||||
pub use crate::signed_bls_to_execution_change::SignedBlsToExecutionChange;
|
||||
pub use crate::signed_block_and_blobs::SignedBeaconBlockAndBlobsSidecar;
|
||||
pub use crate::signed_block_and_blobs::SignedBeaconBlockAndBlobsSidecarDecode;
|
||||
pub use crate::signed_bls_to_execution_change::SignedBlsToExecutionChange;
|
||||
pub use crate::signed_contribution_and_proof::SignedContributionAndProof;
|
||||
pub use crate::signed_voluntary_exit::SignedVoluntaryExit;
|
||||
pub use crate::signing_data::{SignedRoot, SigningData};
|
||||
|
@ -14,7 +14,6 @@ derivative = "2.1.1"
|
||||
rand = "0.7.3"
|
||||
serde = "1.0.116"
|
||||
serde_derive = "1.0.116"
|
||||
serde-big-array = {version = "0.3.2", features = ["const-generics"]}
|
||||
eth2_serde_utils = "0.1.1"
|
||||
hex = "0.4.2"
|
||||
eth2_hashing = "0.3.0"
|
||||
|
@ -1,15 +1,18 @@
|
||||
use derivative::Derivative;
|
||||
use serde_big_array::BigArray;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use serde::de::{Deserialize, Deserializer};
|
||||
use serde::ser::{Serialize, Serializer};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use std::fmt;
|
||||
use std::fmt::{Display, Formatter};
|
||||
use std::fmt::{Debug, Display, Formatter};
|
||||
use std::str::FromStr;
|
||||
use tree_hash::{PackedEncoding, TreeHash};
|
||||
|
||||
#[derive(Derivative, Debug, Clone, Encode, Decode, Serialize, Deserialize)]
|
||||
const KZG_COMMITMENT_BYTES_LEN: usize = 48;
|
||||
|
||||
#[derive(Derivative, Clone, Encode, Decode)]
|
||||
#[derivative(PartialEq, Eq, Hash)]
|
||||
#[ssz(struct_behaviour = "transparent")]
|
||||
pub struct KzgCommitment(#[serde(with = "BigArray")] pub [u8; 48]);
|
||||
pub struct KzgCommitment(pub [u8; KZG_COMMITMENT_BYTES_LEN]);
|
||||
|
||||
impl Display for KzgCommitment {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
@ -19,7 +22,7 @@ impl Display for KzgCommitment {
|
||||
|
||||
impl TreeHash for KzgCommitment {
|
||||
fn tree_hash_type() -> tree_hash::TreeHashType {
|
||||
<[u8; 48] as TreeHash>::tree_hash_type()
|
||||
<[u8; KZG_COMMITMENT_BYTES_LEN] as TreeHash>::tree_hash_type()
|
||||
}
|
||||
|
||||
fn tree_hash_packed_encoding(&self) -> PackedEncoding {
|
||||
@ -27,10 +30,75 @@ impl TreeHash for KzgCommitment {
|
||||
}
|
||||
|
||||
fn tree_hash_packing_factor() -> usize {
|
||||
<[u8; 48] as TreeHash>::tree_hash_packing_factor()
|
||||
<[u8; KZG_COMMITMENT_BYTES_LEN] as TreeHash>::tree_hash_packing_factor()
|
||||
}
|
||||
|
||||
fn tree_hash_root(&self) -> tree_hash::Hash256 {
|
||||
self.0.tree_hash_root()
|
||||
}
|
||||
}
|
||||
|
||||
impl Serialize for KzgCommitment {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
serializer.serialize_str(&self.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for KzgCommitment {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
pub struct StringVisitor;
|
||||
|
||||
impl<'de> serde::de::Visitor<'de> for StringVisitor {
|
||||
type Value = String;
|
||||
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
formatter.write_str("a hex string with 0x prefix")
|
||||
}
|
||||
|
||||
fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
|
||||
where
|
||||
E: serde::de::Error,
|
||||
{
|
||||
Ok(value.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
let string = deserializer.deserialize_str(StringVisitor)?;
|
||||
<Self as std::str::FromStr>::from_str(&string).map_err(serde::de::Error::custom)
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for KzgCommitment {
|
||||
type Err = String;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
if let Some(stripped) = s.strip_prefix("0x") {
|
||||
let bytes = hex::decode(stripped).map_err(|e| e.to_string())?;
|
||||
if bytes.len() == KZG_COMMITMENT_BYTES_LEN {
|
||||
let mut kzg_commitment_bytes = [0; KZG_COMMITMENT_BYTES_LEN];
|
||||
kzg_commitment_bytes[..].copy_from_slice(&bytes);
|
||||
Ok(Self(kzg_commitment_bytes))
|
||||
} else {
|
||||
Err(format!(
|
||||
"InvalidByteLength: got {}, expected {}",
|
||||
bytes.len(),
|
||||
KZG_COMMITMENT_BYTES_LEN
|
||||
))
|
||||
}
|
||||
} else {
|
||||
Err("must start with 0x".to_string())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Debug for KzgCommitment {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", eth2_serde_utils::hex::encode(&self.0))
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,16 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_big_array::BigArray;
|
||||
use serde::de::{Deserialize, Deserializer};
|
||||
use serde::ser::{Serialize, Serializer};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use std::fmt;
|
||||
use std::fmt::Debug;
|
||||
use std::str::FromStr;
|
||||
use tree_hash::{PackedEncoding, TreeHash};
|
||||
|
||||
const KZG_PROOF_BYTES_LEN: usize = 48;
|
||||
|
||||
#[derive(Debug, PartialEq, Hash, Clone, Copy, Encode, Decode, Serialize, Deserialize)]
|
||||
#[serde(transparent)]
|
||||
#[derive(PartialEq, Hash, Clone, Copy, Encode, Decode)]
|
||||
#[ssz(struct_behaviour = "transparent")]
|
||||
pub struct KzgProof(#[serde(with = "BigArray")] pub [u8; KZG_PROOF_BYTES_LEN]);
|
||||
pub struct KzgProof(pub [u8; KZG_PROOF_BYTES_LEN]);
|
||||
|
||||
impl fmt::Display for KzgProof {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
@ -19,7 +20,7 @@ impl fmt::Display for KzgProof {
|
||||
|
||||
impl Default for KzgProof {
|
||||
fn default() -> Self {
|
||||
KzgProof([0; 48])
|
||||
KzgProof([0; KZG_PROOF_BYTES_LEN])
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,3 +53,68 @@ impl TreeHash for KzgProof {
|
||||
self.0.tree_hash_root()
|
||||
}
|
||||
}
|
||||
|
||||
impl Serialize for KzgProof {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
serializer.serialize_str(&self.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for KzgProof {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
pub struct StringVisitor;
|
||||
|
||||
impl<'de> serde::de::Visitor<'de> for StringVisitor {
|
||||
type Value = String;
|
||||
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
formatter.write_str("a hex string with 0x prefix")
|
||||
}
|
||||
|
||||
fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
|
||||
where
|
||||
E: serde::de::Error,
|
||||
{
|
||||
Ok(value.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
let string = deserializer.deserialize_str(StringVisitor)?;
|
||||
<Self as std::str::FromStr>::from_str(&string).map_err(serde::de::Error::custom)
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for KzgProof {
|
||||
type Err = String;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
if let Some(stripped) = s.strip_prefix("0x") {
|
||||
let bytes = hex::decode(stripped).map_err(|e| e.to_string())?;
|
||||
if bytes.len() == KZG_PROOF_BYTES_LEN {
|
||||
let mut kzg_proof_bytes = [0; KZG_PROOF_BYTES_LEN];
|
||||
kzg_proof_bytes[..].copy_from_slice(&bytes);
|
||||
Ok(Self(kzg_proof_bytes))
|
||||
} else {
|
||||
Err(format!(
|
||||
"InvalidByteLength: got {}, expected {}",
|
||||
bytes.len(),
|
||||
KZG_PROOF_BYTES_LEN
|
||||
))
|
||||
}
|
||||
} else {
|
||||
Err("must start with 0x".to_string())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Debug for KzgProof {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", eth2_serde_utils::hex::encode(&self.0))
|
||||
}
|
||||
}
|
||||
|
@ -44,8 +44,8 @@ pub fn run_parse_ssz<T: EthSpec>(matches: &ArgMatches) -> Result<(), String> {
|
||||
bytes
|
||||
};
|
||||
|
||||
println!("Using {} spec", T::spec_name());
|
||||
println!("Type: {:?}", type_str);
|
||||
info!("Using {} spec", T::spec_name());
|
||||
info!("Type: {:?}", type_str);
|
||||
|
||||
match type_str {
|
||||
"signed_block_base" => decode_and_print::<SignedBeaconBlockBase<T>>(&bytes, format)?,
|
||||
@ -57,7 +57,7 @@ pub fn run_parse_ssz<T: EthSpec>(matches: &ArgMatches) -> Result<(), String> {
|
||||
"block_altair" => decode_and_print::<BeaconBlockAltair<T>>(&bytes, format)?,
|
||||
"block_merge" => decode_and_print::<BeaconBlockMerge<T>>(&bytes, format)?,
|
||||
"block_capella" => decode_and_print::<BeaconBlockCapella<T>>(&bytes, format)?,
|
||||
"block_eip4844" => decode_and_print::<SignedBeaconBlockEip4844<T>>(&bytes, format)?,
|
||||
"block_eip4844" => decode_and_print::<BeaconBlockEip4844<T>>(&bytes, format)?,
|
||||
"state_base" => decode_and_print::<BeaconStateBase<T>>(&bytes, format)?,
|
||||
"state_altair" => decode_and_print::<BeaconStateAltair<T>>(&bytes, format)?,
|
||||
"state_merge" => decode_and_print::<BeaconStateMerge<T>>(&bytes, format)?,
|
||||
|
@ -289,7 +289,7 @@ impl<E: EthSpec, T: EpochTransition<E>> Case for EpochProcessing<E, T> {
|
||||
&& T::name() != "participation_flag_updates"
|
||||
}
|
||||
// No phase0 tests for Altair and later.
|
||||
ForkName::Altair | ForkName::Merge | ForkName::Capella | ForkName::Eip4844=> {
|
||||
ForkName::Altair | ForkName::Merge | ForkName::Capella | ForkName::Eip4844 => {
|
||||
T::name() != "participation_record_updates"
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,9 @@ use crate::case_result::compare_beacon_state_results_without_caches;
|
||||
use crate::cases::common::previous_fork;
|
||||
use crate::decode::{ssz_decode_state, yaml_decode_file};
|
||||
use serde_derive::Deserialize;
|
||||
use state_processing::upgrade::{upgrade_to_altair, upgrade_to_bellatrix, upgrade_to_capella, upgrade_to_eip4844};
|
||||
use state_processing::upgrade::{
|
||||
upgrade_to_altair, upgrade_to_bellatrix, upgrade_to_capella, upgrade_to_eip4844,
|
||||
};
|
||||
use types::{BeaconState, ForkName};
|
||||
|
||||
#[derive(Debug, Clone, Default, Deserialize)]
|
||||
@ -62,7 +64,8 @@ impl<E: EthSpec> Case for ForkTest<E> {
|
||||
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::Capella => upgrade_to_capella(&mut result_state, spec).map(|_| result_state),
|
||||
ForkName::Eip4844 => upgrade_to_eip4844(&mut result_state, spec).map(|_| result_state), };
|
||||
ForkName::Eip4844 => upgrade_to_eip4844(&mut result_state, spec).map(|_| result_state),
|
||||
};
|
||||
|
||||
compare_beacon_state_results_without_caches(&mut result, &mut expected)
|
||||
}
|
||||
|
@ -4,10 +4,8 @@ use crate::case_result::compare_beacon_state_results_without_caches;
|
||||
use crate::decode::{ssz_decode_file, ssz_decode_file_with, ssz_decode_state, yaml_decode_file};
|
||||
use crate::testing_spec;
|
||||
use serde_derive::Deserialize;
|
||||
// #[cfg(all(feature = "withdrawals", feature = "withdrawals-processing"))]
|
||||
use state_processing::per_block_processing::process_operations::{
|
||||
process_bls_to_execution_changes,
|
||||
};
|
||||
use state_processing::per_block_processing::process_operations::process_bls_to_execution_changes;
|
||||
use state_processing::per_block_processing::process_withdrawals;
|
||||
use state_processing::{
|
||||
per_block_processing::{
|
||||
errors::BlockProcessingError,
|
||||
@ -22,7 +20,6 @@ use state_processing::{
|
||||
};
|
||||
use std::fmt::Debug;
|
||||
use std::path::Path;
|
||||
use state_processing::per_block_processing::process_withdrawals;
|
||||
use types::{
|
||||
Attestation, AttesterSlashing, BeaconBlock, BeaconState, BlindedPayload, ChainSpec, Deposit,
|
||||
EthSpec, ExecutionPayload, ForkName, FullPayload, ProposerSlashing, SignedBlsToExecutionChange,
|
||||
@ -345,7 +342,6 @@ impl<E: EthSpec> Operation<E> for BlindedPayload<E> {
|
||||
}
|
||||
}
|
||||
|
||||
// #[cfg(all(feature = "withdrawals", feature = "withdrawals-processing"))]
|
||||
impl<E: EthSpec> Operation<E> for WithdrawalsPayload<E> {
|
||||
fn handler_name() -> String {
|
||||
"withdrawals".into()
|
||||
@ -356,6 +352,10 @@ impl<E: EthSpec> Operation<E> for WithdrawalsPayload<E> {
|
||||
}
|
||||
|
||||
fn is_enabled_for_fork(fork_name: ForkName) -> bool {
|
||||
if fork_name == ForkName::Capella && !cfg!(feature = "withdrawals-processing") {
|
||||
return false;
|
||||
}
|
||||
|
||||
fork_name != ForkName::Base && fork_name != ForkName::Altair && fork_name != ForkName::Merge
|
||||
}
|
||||
|
||||
@ -374,11 +374,15 @@ impl<E: EthSpec> Operation<E> for WithdrawalsPayload<E> {
|
||||
spec: &ChainSpec,
|
||||
_: &Operations<E, Self>,
|
||||
) -> Result<(), BlockProcessingError> {
|
||||
process_withdrawals::<_, FullPayload<_>>(state, self.payload.to_ref(), spec)
|
||||
//FIXME(sean) remove this once the spec tests sort this out
|
||||
if matches!(state, BeaconState::Eip4844(_)) {
|
||||
Ok(())
|
||||
} else {
|
||||
process_withdrawals::<_, FullPayload<_>>(state, self.payload.to_ref(), spec)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// #[cfg(all(feature = "withdrawals", feature = "withdrawals-processing"))]
|
||||
impl<E: EthSpec> Operation<E> for SignedBlsToExecutionChange {
|
||||
fn handler_name() -> String {
|
||||
"bls_to_execution_change".into()
|
||||
@ -389,6 +393,9 @@ impl<E: EthSpec> Operation<E> for SignedBlsToExecutionChange {
|
||||
}
|
||||
|
||||
fn is_enabled_for_fork(fork_name: ForkName) -> bool {
|
||||
if fork_name == ForkName::Capella && !cfg!(feature = "withdrawals-processing") {
|
||||
return false;
|
||||
}
|
||||
fork_name != ForkName::Base && fork_name != ForkName::Altair && fork_name != ForkName::Merge
|
||||
}
|
||||
|
||||
@ -402,7 +409,12 @@ impl<E: EthSpec> Operation<E> for SignedBlsToExecutionChange {
|
||||
spec: &ChainSpec,
|
||||
_extra: &Operations<E, Self>,
|
||||
) -> Result<(), BlockProcessingError> {
|
||||
process_bls_to_execution_changes(state, &[self.clone()], VerifySignatures::True, spec)
|
||||
//FIXME(sean) remove this once the spec tests sort this out
|
||||
if matches!(state, BeaconState::Eip4844(_)) {
|
||||
Ok(())
|
||||
} else {
|
||||
process_bls_to_execution_changes(state, &[self.clone()], VerifySignatures::True, spec)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,14 @@ impl<E: EthSpec> Case for SanityBlocks<E> {
|
||||
}
|
||||
|
||||
fn result(&self, _case_index: usize, fork_name: ForkName) -> Result<(), Error> {
|
||||
if cfg!(feature = "withdrawals-processing") && fork_name == ForkName::Eip4844 {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if !cfg!(feature = "withdrawals-processing") && fork_name == ForkName::Capella {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
self.metadata.bls_setting.unwrap_or_default().check()?;
|
||||
|
||||
let mut bulk_state = self.pre.clone();
|
||||
|
@ -210,10 +210,6 @@ impl<T, E> SszStaticHandler<T, E> {
|
||||
Self::for_forks(vec![ForkName::Altair])
|
||||
}
|
||||
|
||||
pub fn altair_and_later() -> Self {
|
||||
Self::for_forks(ForkName::list_all()[1..].to_vec())
|
||||
}
|
||||
|
||||
pub fn merge_only() -> Self {
|
||||
Self::for_forks(vec![ForkName::Merge])
|
||||
}
|
||||
@ -222,9 +218,21 @@ impl<T, E> SszStaticHandler<T, E> {
|
||||
Self::for_forks(vec![ForkName::Capella])
|
||||
}
|
||||
|
||||
pub fn eip4844_only() -> Self {
|
||||
Self::for_forks(vec![ForkName::Eip4844])
|
||||
}
|
||||
|
||||
pub fn altair_and_later() -> Self {
|
||||
Self::for_forks(ForkName::list_all()[1..].to_vec())
|
||||
}
|
||||
|
||||
pub fn merge_and_later() -> Self {
|
||||
Self::for_forks(ForkName::list_all()[2..].to_vec())
|
||||
}
|
||||
|
||||
pub fn capella_and_later() -> Self {
|
||||
Self::for_forks(ForkName::list_all()[3..].to_vec())
|
||||
}
|
||||
}
|
||||
|
||||
/// Handler for SSZ types that implement `CachedTreeHash`.
|
||||
|
@ -49,6 +49,7 @@ type_name_generic!(BeaconBlockBodyCapella, "BeaconBlockBody");
|
||||
type_name_generic!(BeaconBlockBodyEip4844, "BeaconBlockBody");
|
||||
type_name!(BeaconBlockHeader);
|
||||
type_name_generic!(BeaconState);
|
||||
type_name_generic!(BlobsSidecar);
|
||||
type_name!(Checkpoint);
|
||||
type_name_generic!(ContributionAndProof);
|
||||
type_name!(Deposit);
|
||||
@ -86,4 +87,8 @@ type_name!(Validator);
|
||||
type_name!(VoluntaryExit);
|
||||
type_name!(Withdrawal);
|
||||
type_name!(BlsToExecutionChange, "BLSToExecutionChange");
|
||||
type_name_generic!(
|
||||
SignedBeaconBlockAndBlobsSidecarDecode,
|
||||
"SignedBeaconBlockAndBlobsSidecar"
|
||||
);
|
||||
type_name!(SignedBlsToExecutionChange, "SignedBLSToExecutionChange");
|
||||
|
@ -215,6 +215,7 @@ macro_rules! ssz_static_test_no_run {
|
||||
#[cfg(feature = "fake_crypto")]
|
||||
mod ssz_static {
|
||||
use ef_tests::{Handler, SszStaticHandler, SszStaticTHCHandler, SszStaticWithSpecHandler};
|
||||
use types::signed_block_and_blobs::SignedBeaconBlockAndBlobsSidecarDecode;
|
||||
use types::*;
|
||||
|
||||
ssz_static_test!(aggregate_and_proof, AggregateAndProof<_>);
|
||||
@ -266,6 +267,10 @@ mod ssz_static {
|
||||
.run();
|
||||
SszStaticHandler::<BeaconBlockBodyCapella<MainnetEthSpec>, MainnetEthSpec>::capella_only()
|
||||
.run();
|
||||
SszStaticHandler::<BeaconBlockBodyEip4844<MinimalEthSpec>, MinimalEthSpec>::eip4844_only()
|
||||
.run();
|
||||
SszStaticHandler::<BeaconBlockBodyEip4844<MainnetEthSpec>, MainnetEthSpec>::eip4844_only()
|
||||
.run();
|
||||
}
|
||||
|
||||
// Altair and later
|
||||
@ -326,6 +331,10 @@ mod ssz_static {
|
||||
.run();
|
||||
SszStaticHandler::<ExecutionPayloadCapella<MainnetEthSpec>, MainnetEthSpec>::capella_only()
|
||||
.run();
|
||||
SszStaticHandler::<ExecutionPayloadEip4844<MinimalEthSpec>, MinimalEthSpec>::eip4844_only()
|
||||
.run();
|
||||
SszStaticHandler::<ExecutionPayloadEip4844<MainnetEthSpec>, MainnetEthSpec>::eip4844_only()
|
||||
.run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -338,24 +347,40 @@ mod ssz_static {
|
||||
::capella_only().run();
|
||||
SszStaticHandler::<ExecutionPayloadHeaderCapella<MainnetEthSpec>, MainnetEthSpec>
|
||||
::capella_only().run();
|
||||
SszStaticHandler::<ExecutionPayloadHeaderEip4844<MinimalEthSpec>, MinimalEthSpec>
|
||||
::eip4844_only().run();
|
||||
SszStaticHandler::<ExecutionPayloadHeaderEip4844<MainnetEthSpec>, MainnetEthSpec>
|
||||
::eip4844_only().run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn withdrawal() {
|
||||
SszStaticHandler::<Withdrawal, MinimalEthSpec>::capella_only().run();
|
||||
SszStaticHandler::<Withdrawal, MainnetEthSpec>::capella_only().run();
|
||||
SszStaticHandler::<Withdrawal, MinimalEthSpec>::capella_and_later().run();
|
||||
SszStaticHandler::<Withdrawal, MainnetEthSpec>::capella_and_later().run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bls_to_execution_change() {
|
||||
SszStaticHandler::<BlsToExecutionChange, MinimalEthSpec>::capella_only().run();
|
||||
SszStaticHandler::<BlsToExecutionChange, MainnetEthSpec>::capella_only().run();
|
||||
SszStaticHandler::<BlsToExecutionChange, MinimalEthSpec>::capella_and_later().run();
|
||||
SszStaticHandler::<BlsToExecutionChange, MainnetEthSpec>::capella_and_later().run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn signed_bls_to_execution_change() {
|
||||
SszStaticHandler::<SignedBlsToExecutionChange, MinimalEthSpec>::capella_only().run();
|
||||
SszStaticHandler::<SignedBlsToExecutionChange, MainnetEthSpec>::capella_only().run();
|
||||
SszStaticHandler::<SignedBlsToExecutionChange, MinimalEthSpec>::capella_and_later().run();
|
||||
SszStaticHandler::<SignedBlsToExecutionChange, MainnetEthSpec>::capella_and_later().run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn blobs_sidecar() {
|
||||
SszStaticHandler::<BlobsSidecar<MinimalEthSpec>, MinimalEthSpec>::eip4844_only().run();
|
||||
SszStaticHandler::<BlobsSidecar<MainnetEthSpec>, MainnetEthSpec>::eip4844_only().run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn signed_blobs_sidecar() {
|
||||
SszStaticHandler::<SignedBeaconBlockAndBlobsSidecarDecode<MinimalEthSpec>, MinimalEthSpec>::eip4844_only().run();
|
||||
SszStaticHandler::<SignedBeaconBlockAndBlobsSidecarDecode<MainnetEthSpec>, MainnetEthSpec>::eip4844_only().run();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user