From d84850b892ba2bc5ffaafb4d9b6f267e64ad88c5 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Fri, 15 Mar 2019 15:40:28 +1100 Subject: [PATCH] Add `BeaconBlockHeader` type. --- eth2/types/src/beacon_block_header.rs | 38 +++++++++++++++++++++++++++ eth2/types/src/lib.rs | 2 ++ 2 files changed, 40 insertions(+) create mode 100644 eth2/types/src/beacon_block_header.rs diff --git a/eth2/types/src/beacon_block_header.rs b/eth2/types/src/beacon_block_header.rs new file mode 100644 index 000000000..029c7e56b --- /dev/null +++ b/eth2/types/src/beacon_block_header.rs @@ -0,0 +1,38 @@ +use crate::test_utils::TestRandom; +use crate::*; +use bls::Signature; +use rand::RngCore; +use serde_derive::{Deserialize, Serialize}; +use ssz::TreeHash; +use ssz_derive::{Decode, Encode, SignedRoot, TreeHash}; +use test_random_derive::TestRandom; + +/// A header of a `BeaconBlock`. +/// +/// Spec v0.5.0 +#[derive( + Debug, + PartialEq, + Clone, + Serialize, + Deserialize, + Encode, + Decode, + TreeHash, + TestRandom, + SignedRoot, +)] +pub struct BeaconBlockHeader { + pub slot: Slot, + pub previous_block_root: Hash256, + pub state_root: Hash256, + pub block_body_root: Hash256, + pub signature: Signature, +} + +#[cfg(test)] +mod tests { + use super::*; + + ssz_tests!(BeaconBlockHeader); +} diff --git a/eth2/types/src/lib.rs b/eth2/types/src/lib.rs index 7b1d84837..2fcb3237d 100644 --- a/eth2/types/src/lib.rs +++ b/eth2/types/src/lib.rs @@ -9,6 +9,7 @@ pub mod attestation_data_and_custody_bit; pub mod attester_slashing; pub mod beacon_block; pub mod beacon_block_body; +pub mod beacon_block_header; pub mod beacon_state; pub mod chain_spec; pub mod crosslink; @@ -43,6 +44,7 @@ pub use crate::attestation_data_and_custody_bit::AttestationDataAndCustodyBit; pub use crate::attester_slashing::AttesterSlashing; pub use crate::beacon_block::BeaconBlock; pub use crate::beacon_block_body::BeaconBlockBody; +pub use crate::beacon_block_header::BeaconBlockHeader; pub use crate::beacon_state::{BeaconState, Error as BeaconStateError, RelativeEpoch}; pub use crate::chain_spec::{ChainSpec, Domain}; pub use crate::crosslink::Crosslink;