Skip to content

Commit

Permalink
Electra: Add New Containers (sigp#5607)
Browse files Browse the repository at this point in the history
* Electra: Add New Containers
  • Loading branch information
ethDreamer authored Apr 23, 2024
1 parent ad7f0e0 commit 82b131d
Show file tree
Hide file tree
Showing 8 changed files with 253 additions and 0 deletions.
35 changes: 35 additions & 0 deletions consensus/types/src/consolidation.rs
Original file line number Diff line number Diff line change
@@ -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);
}
37 changes: 37 additions & 0 deletions consensus/types/src/deposit_receipt.rs
Original file line number Diff line number Diff line change
@@ -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);
}
34 changes: 34 additions & 0 deletions consensus/types/src/execution_layer_withdrawal_request.rs
Original file line number Diff line number Diff line change
@@ -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);
}
14 changes: 14 additions & 0 deletions consensus/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -133,17 +140,20 @@ 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};
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,
Expand Down Expand Up @@ -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,
};
Expand All @@ -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};
Expand Down
33 changes: 33 additions & 0 deletions consensus/types/src/pending_balance_deposit.rs
Original file line number Diff line number Diff line change
@@ -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);
}
33 changes: 33 additions & 0 deletions consensus/types/src/pending_consolidation.rs
Original file line number Diff line number Diff line change
@@ -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);
}
35 changes: 35 additions & 0 deletions consensus/types/src/pending_partial_withdrawal.rs
Original file line number Diff line number Diff line change
@@ -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);
}
32 changes: 32 additions & 0 deletions consensus/types/src/signed_consolidation.rs
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 82b131d

Please sign in to comment.