Skip to content

Commit

Permalink
derive TypeInfo trait for beacon types
Browse files Browse the repository at this point in the history
  • Loading branch information
gshep committed Aug 22, 2024
1 parent 0325c5d commit a69c0eb
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion ethereum-common/src/beacon/block.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;

#[derive(Debug, Clone, tree_hash_derive::TreeHash, Decode, Encode, Deserialize)]
#[derive(Debug, Clone, tree_hash_derive::TreeHash, Decode, Encode, Deserialize, TypeInfo)]
pub struct Block {
#[serde(deserialize_with = "utils::deserialize_u64")]
pub slot: u64,
Expand Down
2 changes: 1 addition & 1 deletion ethereum-common/src/beacon/block_body.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;

#[derive(Debug, Clone, Decode, Encode, tree_hash_derive::TreeHash, Deserialize)]
#[derive(Debug, Clone, Decode, Encode, tree_hash_derive::TreeHash, Deserialize, TypeInfo)]
pub struct BlockBody {
pub randao_reveal: SignatureBytes,
pub eth1_data: Eth1Data,
Expand Down
30 changes: 15 additions & 15 deletions ethereum-common/src/beacon/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub type Transaction = base_types::ByteList<1_073_741_824>;
pub type SignatureBytes = base_types::BytesFixed<96>;
pub type BLSPubKey = base_types::BytesFixed<48>;

#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash)]
#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash, TypeInfo)]
pub struct Withdrawal {
#[serde(deserialize_with = "utils::deserialize_u64")]
pub index: u64,
Expand All @@ -21,47 +21,47 @@ pub struct Withdrawal {
pub amount: u64,
}

#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash)]
#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash, TypeInfo)]
pub struct Eth1Data {
pub deposit_root: Bytes32,
#[serde(deserialize_with = "utils::deserialize_u64")]
pub deposit_count: u64,
pub block_hash: Bytes32,
}

#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash)]
#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash, TypeInfo)]
pub struct SignedBeaconBlockHeader {
pub message: BlockHeader,
pub signature: SignatureBytes,
}

#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash)]
#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash, TypeInfo)]
pub struct ProposerSlashing {
pub signed_header_1: SignedBeaconBlockHeader,
pub signed_header_2: SignedBeaconBlockHeader,
}

#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash)]
#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash, TypeInfo)]
pub struct AttesterSlashing {
pub attestation_1: IndexedAttestation,
pub attestation_2: IndexedAttestation,
}

#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash)]
#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash, TypeInfo)]
pub struct IndexedAttestation {
pub attesting_indices: base_types::List<u64, 2_048>,
pub data: AttestationData,
pub signature: SignatureBytes,
}

#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash)]
#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash, TypeInfo)]
pub struct Attestation {
pub aggregation_bits: base_types::Bitlist<2_048>,
pub data: AttestationData,
pub signature: SignatureBytes,
}

#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash)]
#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash, TypeInfo)]
pub struct AttestationData {
#[serde(deserialize_with = "utils::deserialize_u64")]
pub slot: u64,
Expand All @@ -72,20 +72,20 @@ pub struct AttestationData {
pub target: Checkpoint,
}

#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash)]
#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash, TypeInfo)]
pub struct Checkpoint {
#[serde(deserialize_with = "utils::deserialize_u64")]
pub epoch: u64,
pub root: Bytes32,
}

#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash)]
#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash, TypeInfo)]
pub struct Deposit {
pub proof: base_types::FixedArray<Bytes32, 33>,
pub data: DepositData,
}

#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash)]
#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash, TypeInfo)]
pub struct DepositData {
pub pubkey: BLSPubKey,
pub withdrawal_credentials: Bytes32,
Expand All @@ -94,27 +94,27 @@ pub struct DepositData {
pub signature: SignatureBytes,
}

#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash)]
#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash, TypeInfo)]
pub struct SignedVoluntaryExit {
pub message: VoluntaryExit,
pub signature: SignatureBytes,
}

#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash)]
#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash, TypeInfo)]
pub struct VoluntaryExit {
#[serde(deserialize_with = "utils::deserialize_u64")]
pub epoch: u64,
#[serde(deserialize_with = "utils::deserialize_u64")]
pub validator_index: u64,
}

#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash)]
#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash, TypeInfo)]
pub struct SignedBlsToExecutionChange {
pub message: BlsToExecutionChange,
pub signature: SignatureBytes,
}

#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash)]
#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash, TypeInfo)]
pub struct BlsToExecutionChange {
#[serde(deserialize_with = "utils::deserialize_u64")]
pub validator_index: u64,
Expand Down
2 changes: 1 addition & 1 deletion ethereum-common/src/beacon/execution_payload.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;

#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash)]
#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash, TypeInfo)]
pub struct ExecutionPayload {
pub parent_hash: Bytes32,
pub fee_recipient: Address,
Expand Down
6 changes: 3 additions & 3 deletions ethereum-common/src/beacon/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use super::*;

#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash)]
#[derive(Debug, Clone, Decode, Encode, Deserialize, tree_hash_derive::TreeHash, TypeInfo)]
pub struct ExecutionPayload {
pub parent_hash: Bytes32,
pub fee_recipient: Address,
Expand Down Expand Up @@ -54,7 +54,7 @@ impl From<super::ExecutionPayload> for ExecutionPayload {
}
}

#[derive(Debug, Clone, Decode, Encode, tree_hash_derive::TreeHash, Deserialize)]
#[derive(Debug, Clone, Decode, Encode, tree_hash_derive::TreeHash, Deserialize, TypeInfo)]
pub struct BlockBody {
pub randao_reveal: H256,
pub eth1_data: H256,
Expand Down Expand Up @@ -89,7 +89,7 @@ impl From<super::BlockBody> for BlockBody {
}
}

#[derive(Debug, Clone, tree_hash_derive::TreeHash, Decode, Encode, Deserialize)]
#[derive(Debug, Clone, tree_hash_derive::TreeHash, Decode, Encode, Deserialize, TypeInfo)]
pub struct Block {
#[serde(deserialize_with = "utils::deserialize_u64")]
pub slot: u64,
Expand Down

0 comments on commit a69c0eb

Please sign in to comment.