From 82b131d37fef84b93c4a3477ee8093a0b39f81e7 Mon Sep 17 00:00:00 2001 From: ethDreamer <37123614+ethDreamer@users.noreply.github.com> Date: Mon, 22 Apr 2024 19:21:21 -0500 Subject: [PATCH] Electra: Add New Containers (#5607) * Electra: Add New Containers --- consensus/types/src/consolidation.rs | 35 ++++++++++++++++++ consensus/types/src/deposit_receipt.rs | 37 +++++++++++++++++++ .../src/execution_layer_withdrawal_request.rs | 34 +++++++++++++++++ consensus/types/src/lib.rs | 14 +++++++ .../types/src/pending_balance_deposit.rs | 33 +++++++++++++++++ consensus/types/src/pending_consolidation.rs | 33 +++++++++++++++++ .../types/src/pending_partial_withdrawal.rs | 35 ++++++++++++++++++ consensus/types/src/signed_consolidation.rs | 32 ++++++++++++++++ 8 files changed, 253 insertions(+) create mode 100644 consensus/types/src/consolidation.rs create mode 100644 consensus/types/src/deposit_receipt.rs create mode 100644 consensus/types/src/execution_layer_withdrawal_request.rs create mode 100644 consensus/types/src/pending_balance_deposit.rs create mode 100644 consensus/types/src/pending_consolidation.rs create mode 100644 consensus/types/src/pending_partial_withdrawal.rs create mode 100644 consensus/types/src/signed_consolidation.rs diff --git a/consensus/types/src/consolidation.rs b/consensus/types/src/consolidation.rs new file mode 100644 index 00000000000..09a2d4bb0c3 --- /dev/null +++ b/consensus/types/src/consolidation.rs @@ -0,0 +1,35 @@ +use crate::test_utils::TestRandom; +use crate::Epoch; +use serde::{Deserialize, Serialize}; +use ssz_derive::{Decode, Encode}; +use test_random_derive::TestRandom; +use tree_hash_derive::TreeHash; + +#[derive( + arbitrary::Arbitrary, + Debug, + PartialEq, + Eq, + Hash, + Clone, + Serialize, + Deserialize, + Encode, + Decode, + TreeHash, + TestRandom, +)] +pub struct Consolidation { + #[serde(with = "serde_utils::quoted_u64")] + pub source_index: u64, + #[serde(with = "serde_utils::quoted_u64")] + pub target_index: u64, + pub epoch: Epoch, +} + +#[cfg(test)] +mod tests { + use super::*; + + ssz_and_tree_hash_tests!(Consolidation); +} diff --git a/consensus/types/src/deposit_receipt.rs b/consensus/types/src/deposit_receipt.rs new file mode 100644 index 00000000000..6a08f717f3d --- /dev/null +++ b/consensus/types/src/deposit_receipt.rs @@ -0,0 +1,37 @@ +use crate::test_utils::TestRandom; +use crate::{Hash256, PublicKeyBytes, Signature}; +use serde::{Deserialize, Serialize}; +use ssz_derive::{Decode, Encode}; +use test_random_derive::TestRandom; +use tree_hash_derive::TreeHash; + +#[derive( + arbitrary::Arbitrary, + Debug, + PartialEq, + Eq, + Hash, + Clone, + Serialize, + Deserialize, + Encode, + Decode, + TreeHash, + TestRandom, +)] +pub struct DepositReceipt { + pub pubkey: PublicKeyBytes, + pub withdrawal_credentials: Hash256, + #[serde(with = "serde_utils::quoted_u64")] + pub amount: u64, + pub signature: Signature, + #[serde(with = "serde_utils::quoted_u64")] + pub index: u64, +} + +#[cfg(test)] +mod tests { + use super::*; + + ssz_and_tree_hash_tests!(DepositReceipt); +} diff --git a/consensus/types/src/execution_layer_withdrawal_request.rs b/consensus/types/src/execution_layer_withdrawal_request.rs new file mode 100644 index 00000000000..b1d814c2834 --- /dev/null +++ b/consensus/types/src/execution_layer_withdrawal_request.rs @@ -0,0 +1,34 @@ +use crate::test_utils::TestRandom; +use crate::{Address, PublicKeyBytes}; +use serde::{Deserialize, Serialize}; +use ssz_derive::{Decode, Encode}; +use test_random_derive::TestRandom; +use tree_hash_derive::TreeHash; + +#[derive( + arbitrary::Arbitrary, + Debug, + PartialEq, + Eq, + Hash, + Clone, + Serialize, + Deserialize, + Encode, + Decode, + TreeHash, + TestRandom, +)] +pub struct ExecutionLayerWithdrawalRequest { + pub source_address: Address, + pub validator_pubkey: PublicKeyBytes, + #[serde(with = "serde_utils::quoted_u64")] + pub amount: u64, +} + +#[cfg(test)] +mod tests { + use super::*; + + ssz_and_tree_hash_tests!(ExecutionLayerWithdrawalRequest); +} diff --git a/consensus/types/src/lib.rs b/consensus/types/src/lib.rs index 6551ebc1dda..dee55789398 100644 --- a/consensus/types/src/lib.rs +++ b/consensus/types/src/lib.rs @@ -29,16 +29,19 @@ pub mod bls_to_execution_change; pub mod builder_bid; pub mod chain_spec; pub mod checkpoint; +pub mod consolidation; pub mod consts; pub mod contribution_and_proof; pub mod deposit; pub mod deposit_data; pub mod deposit_message; +pub mod deposit_receipt; pub mod deposit_tree_snapshot; pub mod enr_fork_id; pub mod eth1_data; pub mod eth_spec; pub mod execution_block_hash; +pub mod execution_layer_withdrawal_request; pub mod execution_payload; pub mod execution_payload_header; pub mod fork; @@ -54,6 +57,9 @@ pub mod light_client_finality_update; pub mod light_client_optimistic_update; pub mod light_client_update; pub mod pending_attestation; +pub mod pending_balance_deposit; +pub mod pending_consolidation; +pub mod pending_partial_withdrawal; pub mod proposer_preparation_data; pub mod proposer_slashing; pub mod relative_epoch; @@ -63,6 +69,7 @@ pub mod signed_aggregate_and_proof; pub mod signed_beacon_block; pub mod signed_beacon_block_header; pub mod signed_bls_to_execution_change; +pub mod signed_consolidation; pub mod signed_contribution_and_proof; pub mod signed_voluntary_exit; pub mod signing_data; @@ -133,10 +140,12 @@ pub use crate::checkpoint::Checkpoint; pub use crate::config_and_preset::{ ConfigAndPreset, ConfigAndPresetCapella, ConfigAndPresetDeneb, ConfigAndPresetElectra, }; +pub use crate::consolidation::Consolidation; pub use crate::contribution_and_proof::ContributionAndProof; pub use crate::deposit::{Deposit, DEPOSIT_TREE_DEPTH}; pub use crate::deposit_data::DepositData; pub use crate::deposit_message::DepositMessage; +pub use crate::deposit_receipt::DepositReceipt; pub use crate::deposit_tree_snapshot::{DepositTreeSnapshot, FinalizedExecutionBlock}; pub use crate::enr_fork_id::EnrForkId; pub use crate::epoch_cache::{EpochCache, EpochCacheError, EpochCacheKey}; @@ -144,6 +153,7 @@ pub use crate::eth1_data::Eth1Data; pub use crate::eth_spec::EthSpecId; pub use crate::execution_block_hash::ExecutionBlockHash; pub use crate::execution_block_header::ExecutionBlockHeader; +pub use crate::execution_layer_withdrawal_request::ExecutionLayerWithdrawalRequest; pub use crate::execution_payload::{ ExecutionPayload, ExecutionPayloadCapella, ExecutionPayloadDeneb, ExecutionPayloadElectra, ExecutionPayloadMerge, ExecutionPayloadRef, Transaction, Transactions, Withdrawals, @@ -189,6 +199,9 @@ pub use crate::payload::{ FullPayloadRef, OwnedExecPayload, }; pub use crate::pending_attestation::PendingAttestation; +pub use crate::pending_balance_deposit::PendingBalanceDeposit; +pub use crate::pending_consolidation::PendingConsolidation; +pub use crate::pending_partial_withdrawal::PendingPartialWithdrawal; pub use crate::preset::{ AltairPreset, BasePreset, BellatrixPreset, CapellaPreset, DenebPreset, ElectraPreset, }; @@ -207,6 +220,7 @@ pub use crate::signed_beacon_block::{ }; pub use crate::signed_beacon_block_header::SignedBeaconBlockHeader; pub use crate::signed_bls_to_execution_change::SignedBlsToExecutionChange; +pub use crate::signed_consolidation::SignedConsolidation; pub use crate::signed_contribution_and_proof::SignedContributionAndProof; pub use crate::signed_voluntary_exit::SignedVoluntaryExit; pub use crate::signing_data::{SignedRoot, SigningData}; diff --git a/consensus/types/src/pending_balance_deposit.rs b/consensus/types/src/pending_balance_deposit.rs new file mode 100644 index 00000000000..a2bce577f87 --- /dev/null +++ b/consensus/types/src/pending_balance_deposit.rs @@ -0,0 +1,33 @@ +use crate::test_utils::TestRandom; +use serde::{Deserialize, Serialize}; +use ssz_derive::{Decode, Encode}; +use test_random_derive::TestRandom; +use tree_hash_derive::TreeHash; + +#[derive( + arbitrary::Arbitrary, + Debug, + PartialEq, + Eq, + Hash, + Clone, + Serialize, + Deserialize, + Encode, + Decode, + TreeHash, + TestRandom, +)] +pub struct PendingBalanceDeposit { + #[serde(with = "serde_utils::quoted_u64")] + pub index: u64, + #[serde(with = "serde_utils::quoted_u64")] + pub amount: u64, +} + +#[cfg(test)] +mod tests { + use super::*; + + ssz_and_tree_hash_tests!(PendingBalanceDeposit); +} diff --git a/consensus/types/src/pending_consolidation.rs b/consensus/types/src/pending_consolidation.rs new file mode 100644 index 00000000000..6e0b74a7383 --- /dev/null +++ b/consensus/types/src/pending_consolidation.rs @@ -0,0 +1,33 @@ +use crate::test_utils::TestRandom; +use serde::{Deserialize, Serialize}; +use ssz_derive::{Decode, Encode}; +use test_random_derive::TestRandom; +use tree_hash_derive::TreeHash; + +#[derive( + arbitrary::Arbitrary, + Debug, + PartialEq, + Eq, + Hash, + Clone, + Serialize, + Deserialize, + Encode, + Decode, + TreeHash, + TestRandom, +)] +pub struct PendingConsolidation { + #[serde(with = "serde_utils::quoted_u64")] + pub source_index: u64, + #[serde(with = "serde_utils::quoted_u64")] + pub target_index: u64, +} + +#[cfg(test)] +mod tests { + use super::*; + + ssz_and_tree_hash_tests!(PendingConsolidation); +} diff --git a/consensus/types/src/pending_partial_withdrawal.rs b/consensus/types/src/pending_partial_withdrawal.rs new file mode 100644 index 00000000000..e5ace7b2736 --- /dev/null +++ b/consensus/types/src/pending_partial_withdrawal.rs @@ -0,0 +1,35 @@ +use crate::test_utils::TestRandom; +use crate::Epoch; +use serde::{Deserialize, Serialize}; +use ssz_derive::{Decode, Encode}; +use test_random_derive::TestRandom; +use tree_hash_derive::TreeHash; + +#[derive( + arbitrary::Arbitrary, + Debug, + PartialEq, + Eq, + Hash, + Clone, + Serialize, + Deserialize, + Encode, + Decode, + TreeHash, + TestRandom, +)] +pub struct PendingPartialWithdrawal { + #[serde(with = "serde_utils::quoted_u64")] + pub index: u64, + #[serde(with = "serde_utils::quoted_u64")] + pub amount: u64, + pub withdrawable_epoch: Epoch, +} + +#[cfg(test)] +mod tests { + use super::*; + + ssz_and_tree_hash_tests!(PendingPartialWithdrawal); +} diff --git a/consensus/types/src/signed_consolidation.rs b/consensus/types/src/signed_consolidation.rs new file mode 100644 index 00000000000..f004ec23bd4 --- /dev/null +++ b/consensus/types/src/signed_consolidation.rs @@ -0,0 +1,32 @@ +use crate::test_utils::TestRandom; +use crate::{Consolidation, Signature}; +use serde::{Deserialize, Serialize}; +use ssz_derive::{Decode, Encode}; +use test_random_derive::TestRandom; +use tree_hash_derive::TreeHash; + +#[derive( + arbitrary::Arbitrary, + Debug, + PartialEq, + Eq, + Hash, + Clone, + Serialize, + Deserialize, + Encode, + Decode, + TreeHash, + TestRandom, +)] +pub struct SignedConsolidation { + pub message: Consolidation, + pub signature: Signature, +} + +#[cfg(test)] +mod tests { + use super::*; + + ssz_and_tree_hash_tests!(SignedConsolidation); +}