Use SSZ enc/dec proc macros on most types
Some types were skipped as they have non-standard serialization.
This commit is contained in:
parent
345c527d33
commit
fc0bf578f8
@ -3,8 +3,9 @@ use crate::test_utils::TestRandom;
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Encode, Decode)]
|
||||
pub struct Attestation {
|
||||
pub aggregation_bitfield: Bitfield,
|
||||
pub data: AttestationData,
|
||||
@ -33,32 +34,6 @@ impl Attestation {
|
||||
}
|
||||
}
|
||||
|
||||
impl Encodable for Attestation {
|
||||
fn ssz_append(&self, s: &mut SszStream) {
|
||||
s.append(&self.aggregation_bitfield);
|
||||
s.append(&self.data);
|
||||
s.append(&self.custody_bitfield);
|
||||
s.append(&self.aggregate_signature);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for Attestation {
|
||||
fn ssz_decode(bytes: &[u8], i: usize) -> Result<(Self, usize), DecodeError> {
|
||||
let (aggregation_bitfield, i) = Bitfield::ssz_decode(bytes, i)?;
|
||||
let (data, i) = AttestationData::ssz_decode(bytes, i)?;
|
||||
let (custody_bitfield, i) = Bitfield::ssz_decode(bytes, i)?;
|
||||
let (aggregate_signature, i) = AggregateSignature::ssz_decode(bytes, i)?;
|
||||
|
||||
let attestation_record = Self {
|
||||
aggregation_bitfield,
|
||||
data,
|
||||
custody_bitfield,
|
||||
aggregate_signature,
|
||||
};
|
||||
Ok((attestation_record, i))
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeHash for Attestation {
|
||||
fn hash_tree_root(&self) -> Vec<u8> {
|
||||
let mut result: Vec<u8> = vec![];
|
||||
|
@ -3,6 +3,7 @@ use crate::{AttestationDataAndCustodyBit, Crosslink, Epoch, Hash256, Slot};
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
|
||||
pub const SSZ_ATTESTION_DATA_LENGTH: usize = {
|
||||
8 + // slot
|
||||
@ -15,7 +16,7 @@ pub const SSZ_ATTESTION_DATA_LENGTH: usize = {
|
||||
32 // justified_block_root
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Hash)]
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Hash, Encode, Decode)]
|
||||
pub struct AttestationData {
|
||||
pub slot: Slot,
|
||||
pub shard: u64,
|
||||
@ -43,44 +44,6 @@ impl AttestationData {
|
||||
}
|
||||
}
|
||||
|
||||
impl Encodable for AttestationData {
|
||||
fn ssz_append(&self, s: &mut SszStream) {
|
||||
s.append(&self.slot);
|
||||
s.append(&self.shard);
|
||||
s.append(&self.beacon_block_root);
|
||||
s.append(&self.epoch_boundary_root);
|
||||
s.append(&self.shard_block_root);
|
||||
s.append(&self.latest_crosslink);
|
||||
s.append(&self.justified_epoch);
|
||||
s.append(&self.justified_block_root);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for AttestationData {
|
||||
fn ssz_decode(bytes: &[u8], i: usize) -> Result<(Self, usize), DecodeError> {
|
||||
let (slot, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (shard, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (beacon_block_root, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (epoch_boundary_root, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (shard_block_root, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (latest_crosslink, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (justified_epoch, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (justified_block_root, i) = <_>::ssz_decode(bytes, i)?;
|
||||
|
||||
let attestation_data = AttestationData {
|
||||
slot,
|
||||
shard,
|
||||
beacon_block_root,
|
||||
epoch_boundary_root,
|
||||
shard_block_root,
|
||||
latest_crosslink,
|
||||
justified_epoch,
|
||||
justified_block_root,
|
||||
};
|
||||
Ok((attestation_data, i))
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeHash for AttestationData {
|
||||
fn hash_tree_root(&self) -> Vec<u8> {
|
||||
let mut result: Vec<u8> = vec![];
|
||||
|
@ -3,31 +3,14 @@ use crate::test_utils::TestRandom;
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz::{Decodable, DecodeError, Encodable, SszStream, TreeHash};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Encode, Decode)]
|
||||
pub struct AttestationDataAndCustodyBit {
|
||||
pub data: AttestationData,
|
||||
pub custody_bit: bool,
|
||||
}
|
||||
|
||||
impl Encodable for AttestationDataAndCustodyBit {
|
||||
fn ssz_append(&self, s: &mut SszStream) {
|
||||
s.append(&self.data);
|
||||
// TODO: deal with bools
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for AttestationDataAndCustodyBit {
|
||||
fn ssz_decode(bytes: &[u8], i: usize) -> Result<(Self, usize), DecodeError> {
|
||||
let (data, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let custody_bit = false;
|
||||
|
||||
let attestation_data_and_custody_bit = AttestationDataAndCustodyBit { data, custody_bit };
|
||||
|
||||
Ok((attestation_data_and_custody_bit, i))
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeHash for AttestationDataAndCustodyBit {
|
||||
fn hash_tree_root(&self) -> Vec<u8> {
|
||||
let mut result: Vec<u8> = vec![];
|
||||
|
@ -2,35 +2,14 @@ use crate::{test_utils::TestRandom, SlashableAttestation};
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize)]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode)]
|
||||
pub struct AttesterSlashing {
|
||||
pub slashable_attestation_1: SlashableAttestation,
|
||||
pub slashable_attestation_2: SlashableAttestation,
|
||||
}
|
||||
|
||||
impl Encodable for AttesterSlashing {
|
||||
fn ssz_append(&self, s: &mut SszStream) {
|
||||
s.append(&self.slashable_attestation_1);
|
||||
s.append(&self.slashable_attestation_2);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for AttesterSlashing {
|
||||
fn ssz_decode(bytes: &[u8], i: usize) -> Result<(Self, usize), DecodeError> {
|
||||
let (slashable_attestation_1, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (slashable_attestation_2, i) = <_>::ssz_decode(bytes, i)?;
|
||||
|
||||
Ok((
|
||||
AttesterSlashing {
|
||||
slashable_attestation_1,
|
||||
slashable_attestation_2,
|
||||
},
|
||||
i,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeHash for AttesterSlashing {
|
||||
fn hash_tree_root(&self) -> Vec<u8> {
|
||||
let mut result: Vec<u8> = vec![];
|
||||
|
@ -4,8 +4,9 @@ use bls::Signature;
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize)]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode)]
|
||||
pub struct BeaconBlock {
|
||||
pub slot: Slot,
|
||||
pub parent_root: Hash256,
|
||||
@ -59,43 +60,6 @@ impl BeaconBlock {
|
||||
}
|
||||
}
|
||||
|
||||
impl Encodable for BeaconBlock {
|
||||
fn ssz_append(&self, s: &mut SszStream) {
|
||||
s.append(&self.slot);
|
||||
s.append(&self.parent_root);
|
||||
s.append(&self.state_root);
|
||||
s.append(&self.randao_reveal);
|
||||
s.append(&self.eth1_data);
|
||||
s.append(&self.signature);
|
||||
s.append(&self.body);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for BeaconBlock {
|
||||
fn ssz_decode(bytes: &[u8], i: usize) -> Result<(Self, usize), DecodeError> {
|
||||
let (slot, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (parent_root, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (state_root, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (randao_reveal, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (eth1_data, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (signature, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (body, i) = <_>::ssz_decode(bytes, i)?;
|
||||
|
||||
Ok((
|
||||
Self {
|
||||
slot,
|
||||
parent_root,
|
||||
state_root,
|
||||
randao_reveal,
|
||||
eth1_data,
|
||||
signature,
|
||||
body,
|
||||
},
|
||||
i,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeHash for BeaconBlock {
|
||||
fn hash_tree_root(&self) -> Vec<u8> {
|
||||
let mut result: Vec<u8> = vec![];
|
||||
|
@ -3,8 +3,9 @@ use crate::test_utils::TestRandom;
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Default, Serialize)]
|
||||
#[derive(Debug, PartialEq, Clone, Default, Serialize, Encode, Decode)]
|
||||
pub struct BeaconBlockBody {
|
||||
pub proposer_slashings: Vec<ProposerSlashing>,
|
||||
pub attester_slashings: Vec<AttesterSlashing>,
|
||||
@ -13,37 +14,6 @@ pub struct BeaconBlockBody {
|
||||
pub exits: Vec<Exit>,
|
||||
}
|
||||
|
||||
impl Encodable for BeaconBlockBody {
|
||||
fn ssz_append(&self, s: &mut SszStream) {
|
||||
s.append_vec(&self.proposer_slashings);
|
||||
s.append_vec(&self.attester_slashings);
|
||||
s.append_vec(&self.attestations);
|
||||
s.append_vec(&self.deposits);
|
||||
s.append_vec(&self.exits);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for BeaconBlockBody {
|
||||
fn ssz_decode(bytes: &[u8], i: usize) -> Result<(Self, usize), DecodeError> {
|
||||
let (proposer_slashings, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (attester_slashings, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (attestations, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (deposits, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (exits, i) = <_>::ssz_decode(bytes, i)?;
|
||||
|
||||
Ok((
|
||||
Self {
|
||||
proposer_slashings,
|
||||
attester_slashings,
|
||||
attestations,
|
||||
deposits,
|
||||
exits,
|
||||
},
|
||||
i,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeHash for BeaconBlockBody {
|
||||
fn hash_tree_root(&self) -> Vec<u8> {
|
||||
let mut result: Vec<u8> = vec![];
|
||||
|
@ -9,6 +9,7 @@ use honey_badger_split::SplitExt;
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use swap_or_not_shuffle::get_permutated_index;
|
||||
|
||||
mod tests;
|
||||
@ -50,7 +51,7 @@ macro_rules! safe_sub_assign {
|
||||
};
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Default, Serialize)]
|
||||
#[derive(Debug, PartialEq, Clone, Default, Serialize, Encode, Decode)]
|
||||
pub struct BeaconState {
|
||||
// Misc
|
||||
pub slot: Slot,
|
||||
@ -928,97 +929,6 @@ impl From<AttestationParticipantsError> for InclusionError {
|
||||
}
|
||||
}
|
||||
|
||||
impl Encodable for BeaconState {
|
||||
fn ssz_append(&self, s: &mut SszStream) {
|
||||
s.append(&self.slot);
|
||||
s.append(&self.genesis_time);
|
||||
s.append(&self.fork);
|
||||
s.append(&self.validator_registry);
|
||||
s.append(&self.validator_balances);
|
||||
s.append(&self.validator_registry_update_epoch);
|
||||
s.append(&self.latest_randao_mixes);
|
||||
s.append(&self.previous_epoch_start_shard);
|
||||
s.append(&self.current_epoch_start_shard);
|
||||
s.append(&self.previous_calculation_epoch);
|
||||
s.append(&self.current_calculation_epoch);
|
||||
s.append(&self.previous_epoch_seed);
|
||||
s.append(&self.current_epoch_seed);
|
||||
s.append(&self.previous_justified_epoch);
|
||||
s.append(&self.justified_epoch);
|
||||
s.append(&self.justification_bitfield);
|
||||
s.append(&self.finalized_epoch);
|
||||
s.append(&self.latest_crosslinks);
|
||||
s.append(&self.latest_block_roots);
|
||||
s.append(&self.latest_index_roots);
|
||||
s.append(&self.latest_penalized_balances);
|
||||
s.append(&self.latest_attestations);
|
||||
s.append(&self.batched_block_roots);
|
||||
s.append(&self.latest_eth1_data);
|
||||
s.append(&self.eth1_data_votes);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for BeaconState {
|
||||
fn ssz_decode(bytes: &[u8], i: usize) -> Result<(Self, usize), DecodeError> {
|
||||
let (slot, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (genesis_time, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (fork, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (validator_registry, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (validator_balances, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (validator_registry_update_epoch, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (latest_randao_mixes, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (previous_epoch_start_shard, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (current_epoch_start_shard, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (previous_calculation_epoch, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (current_calculation_epoch, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (previous_epoch_seed, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (current_epoch_seed, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (previous_justified_epoch, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (justified_epoch, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (justification_bitfield, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (finalized_epoch, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (latest_crosslinks, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (latest_block_roots, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (latest_index_roots, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (latest_penalized_balances, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (latest_attestations, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (batched_block_roots, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (latest_eth1_data, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (eth1_data_votes, i) = <_>::ssz_decode(bytes, i)?;
|
||||
|
||||
Ok((
|
||||
Self {
|
||||
slot,
|
||||
genesis_time,
|
||||
fork,
|
||||
validator_registry,
|
||||
validator_balances,
|
||||
validator_registry_update_epoch,
|
||||
latest_randao_mixes,
|
||||
previous_epoch_start_shard,
|
||||
current_epoch_start_shard,
|
||||
previous_calculation_epoch,
|
||||
current_calculation_epoch,
|
||||
previous_epoch_seed,
|
||||
current_epoch_seed,
|
||||
previous_justified_epoch,
|
||||
justified_epoch,
|
||||
justification_bitfield,
|
||||
finalized_epoch,
|
||||
latest_crosslinks,
|
||||
latest_block_roots,
|
||||
latest_index_roots,
|
||||
latest_penalized_balances,
|
||||
latest_attestations,
|
||||
batched_block_roots,
|
||||
latest_eth1_data,
|
||||
eth1_data_votes,
|
||||
},
|
||||
i,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeHash for BeaconState {
|
||||
fn hash_tree_root(&self) -> Vec<u8> {
|
||||
let mut result: Vec<u8> = vec![];
|
||||
|
@ -3,35 +3,14 @@ use crate::test_utils::TestRandom;
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize)]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode)]
|
||||
pub struct CasperSlashing {
|
||||
pub slashable_vote_data_1: SlashableVoteData,
|
||||
pub slashable_vote_data_2: SlashableVoteData,
|
||||
}
|
||||
|
||||
impl Encodable for CasperSlashing {
|
||||
fn ssz_append(&self, s: &mut SszStream) {
|
||||
s.append(&self.slashable_vote_data_1);
|
||||
s.append(&self.slashable_vote_data_2);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for CasperSlashing {
|
||||
fn ssz_decode(bytes: &[u8], i: usize) -> Result<(Self, usize), DecodeError> {
|
||||
let (slashable_vote_data_1, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (slashable_vote_data_2, i) = <_>::ssz_decode(bytes, i)?;
|
||||
|
||||
Ok((
|
||||
CasperSlashing {
|
||||
slashable_vote_data_1,
|
||||
slashable_vote_data_2,
|
||||
},
|
||||
i,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeHash for CasperSlashing {
|
||||
fn hash_tree_root(&self) -> Vec<u8> {
|
||||
let mut result: Vec<u8> = vec![];
|
||||
|
@ -3,8 +3,9 @@ use crate::{Epoch, Hash256};
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Hash)]
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Hash, Encode, Decode)]
|
||||
pub struct Crosslink {
|
||||
pub epoch: Epoch,
|
||||
pub shard_block_root: Hash256,
|
||||
@ -20,28 +21,6 @@ impl Crosslink {
|
||||
}
|
||||
}
|
||||
|
||||
impl Encodable for Crosslink {
|
||||
fn ssz_append(&self, s: &mut SszStream) {
|
||||
s.append(&self.epoch);
|
||||
s.append(&self.shard_block_root);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for Crosslink {
|
||||
fn ssz_decode(bytes: &[u8], i: usize) -> Result<(Self, usize), DecodeError> {
|
||||
let (epoch, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (shard_block_root, i) = <_>::ssz_decode(bytes, i)?;
|
||||
|
||||
Ok((
|
||||
Self {
|
||||
epoch,
|
||||
shard_block_root,
|
||||
},
|
||||
i,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeHash for Crosslink {
|
||||
fn hash_tree_root(&self) -> Vec<u8> {
|
||||
let mut result: Vec<u8> = vec![];
|
||||
|
@ -3,39 +3,15 @@ use crate::test_utils::TestRandom;
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize)]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode)]
|
||||
pub struct Deposit {
|
||||
pub branch: Vec<Hash256>,
|
||||
pub index: u64,
|
||||
pub deposit_data: DepositData,
|
||||
}
|
||||
|
||||
impl Encodable for Deposit {
|
||||
fn ssz_append(&self, s: &mut SszStream) {
|
||||
s.append_vec(&self.branch);
|
||||
s.append(&self.index);
|
||||
s.append(&self.deposit_data);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for Deposit {
|
||||
fn ssz_decode(bytes: &[u8], i: usize) -> Result<(Self, usize), DecodeError> {
|
||||
let (branch, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (index, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (deposit_data, i) = <_>::ssz_decode(bytes, i)?;
|
||||
|
||||
Ok((
|
||||
Self {
|
||||
branch,
|
||||
index,
|
||||
deposit_data,
|
||||
},
|
||||
i,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeHash for Deposit {
|
||||
fn hash_tree_root(&self) -> Vec<u8> {
|
||||
let mut result: Vec<u8> = vec![];
|
||||
|
@ -3,39 +3,15 @@ use crate::test_utils::TestRandom;
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize)]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode)]
|
||||
pub struct DepositData {
|
||||
pub amount: u64,
|
||||
pub timestamp: u64,
|
||||
pub deposit_input: DepositInput,
|
||||
}
|
||||
|
||||
impl Encodable for DepositData {
|
||||
fn ssz_append(&self, s: &mut SszStream) {
|
||||
s.append(&self.amount);
|
||||
s.append(&self.timestamp);
|
||||
s.append(&self.deposit_input);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for DepositData {
|
||||
fn ssz_decode(bytes: &[u8], i: usize) -> Result<(Self, usize), DecodeError> {
|
||||
let (amount, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (timestamp, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (deposit_input, i) = <_>::ssz_decode(bytes, i)?;
|
||||
|
||||
Ok((
|
||||
Self {
|
||||
amount,
|
||||
timestamp,
|
||||
deposit_input,
|
||||
},
|
||||
i,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeHash for DepositData {
|
||||
fn hash_tree_root(&self) -> Vec<u8> {
|
||||
let mut result: Vec<u8> = vec![];
|
||||
|
@ -4,39 +4,15 @@ use bls::{PublicKey, Signature};
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize)]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode)]
|
||||
pub struct DepositInput {
|
||||
pub pubkey: PublicKey,
|
||||
pub withdrawal_credentials: Hash256,
|
||||
pub proof_of_possession: Signature,
|
||||
}
|
||||
|
||||
impl Encodable for DepositInput {
|
||||
fn ssz_append(&self, s: &mut SszStream) {
|
||||
s.append(&self.pubkey);
|
||||
s.append(&self.withdrawal_credentials);
|
||||
s.append(&self.proof_of_possession);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for DepositInput {
|
||||
fn ssz_decode(bytes: &[u8], i: usize) -> Result<(Self, usize), DecodeError> {
|
||||
let (pubkey, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (withdrawal_credentials, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (proof_of_possession, i) = <_>::ssz_decode(bytes, i)?;
|
||||
|
||||
Ok((
|
||||
Self {
|
||||
pubkey,
|
||||
withdrawal_credentials,
|
||||
proof_of_possession,
|
||||
},
|
||||
i,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeHash for DepositInput {
|
||||
fn hash_tree_root(&self) -> Vec<u8> {
|
||||
let mut result: Vec<u8> = vec![];
|
||||
|
@ -3,36 +3,15 @@ use crate::test_utils::TestRandom;
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
|
||||
// Note: this is refer to as DepositRootVote in specs
|
||||
#[derive(Debug, PartialEq, Clone, Default, Serialize)]
|
||||
#[derive(Debug, PartialEq, Clone, Default, Serialize, Encode, Decode)]
|
||||
pub struct Eth1Data {
|
||||
pub deposit_root: Hash256,
|
||||
pub block_hash: Hash256,
|
||||
}
|
||||
|
||||
impl Encodable for Eth1Data {
|
||||
fn ssz_append(&self, s: &mut SszStream) {
|
||||
s.append(&self.deposit_root);
|
||||
s.append(&self.block_hash);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for Eth1Data {
|
||||
fn ssz_decode(bytes: &[u8], i: usize) -> Result<(Self, usize), DecodeError> {
|
||||
let (deposit_root, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (block_hash, i) = <_>::ssz_decode(bytes, i)?;
|
||||
|
||||
Ok((
|
||||
Self {
|
||||
deposit_root,
|
||||
block_hash,
|
||||
},
|
||||
i,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeHash for Eth1Data {
|
||||
fn hash_tree_root(&self) -> Vec<u8> {
|
||||
let mut result: Vec<u8> = vec![];
|
||||
|
@ -3,36 +3,15 @@ use crate::test_utils::TestRandom;
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
|
||||
// Note: this is refer to as DepositRootVote in specs
|
||||
#[derive(Debug, PartialEq, Clone, Default, Serialize)]
|
||||
#[derive(Debug, PartialEq, Clone, Default, Serialize, Encode, Decode)]
|
||||
pub struct Eth1DataVote {
|
||||
pub eth1_data: Eth1Data,
|
||||
pub vote_count: u64,
|
||||
}
|
||||
|
||||
impl Encodable for Eth1DataVote {
|
||||
fn ssz_append(&self, s: &mut SszStream) {
|
||||
s.append(&self.eth1_data);
|
||||
s.append(&self.vote_count);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for Eth1DataVote {
|
||||
fn ssz_decode(bytes: &[u8], i: usize) -> Result<(Self, usize), DecodeError> {
|
||||
let (eth1_data, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (vote_count, i) = <_>::ssz_decode(bytes, i)?;
|
||||
|
||||
Ok((
|
||||
Self {
|
||||
eth1_data,
|
||||
vote_count,
|
||||
},
|
||||
i,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeHash for Eth1DataVote {
|
||||
fn hash_tree_root(&self) -> Vec<u8> {
|
||||
let mut result: Vec<u8> = vec![];
|
||||
|
@ -3,39 +3,15 @@ use bls::Signature;
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize)]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode)]
|
||||
pub struct Exit {
|
||||
pub epoch: Epoch,
|
||||
pub validator_index: u64,
|
||||
pub signature: Signature,
|
||||
}
|
||||
|
||||
impl Encodable for Exit {
|
||||
fn ssz_append(&self, s: &mut SszStream) {
|
||||
s.append(&self.epoch);
|
||||
s.append(&self.validator_index);
|
||||
s.append(&self.signature);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for Exit {
|
||||
fn ssz_decode(bytes: &[u8], i: usize) -> Result<(Self, usize), DecodeError> {
|
||||
let (epoch, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (validator_index, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (signature, i) = <_>::ssz_decode(bytes, i)?;
|
||||
|
||||
Ok((
|
||||
Self {
|
||||
epoch,
|
||||
validator_index,
|
||||
signature,
|
||||
},
|
||||
i,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeHash for Exit {
|
||||
fn hash_tree_root(&self) -> Vec<u8> {
|
||||
let mut result: Vec<u8> = vec![];
|
||||
|
@ -2,39 +2,15 @@ use crate::{test_utils::TestRandom, Epoch};
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Encode, Decode)]
|
||||
pub struct Fork {
|
||||
pub previous_version: u64,
|
||||
pub current_version: u64,
|
||||
pub epoch: Epoch,
|
||||
}
|
||||
|
||||
impl Encodable for Fork {
|
||||
fn ssz_append(&self, s: &mut SszStream) {
|
||||
s.append(&self.previous_version);
|
||||
s.append(&self.current_version);
|
||||
s.append(&self.epoch);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for Fork {
|
||||
fn ssz_decode(bytes: &[u8], i: usize) -> Result<(Self, usize), DecodeError> {
|
||||
let (previous_version, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (current_version, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (epoch, i) = <_>::ssz_decode(bytes, i)?;
|
||||
|
||||
Ok((
|
||||
Self {
|
||||
previous_version,
|
||||
current_version,
|
||||
epoch,
|
||||
},
|
||||
i,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeHash for Fork {
|
||||
fn hash_tree_root(&self) -> Vec<u8> {
|
||||
let mut result: Vec<u8> = vec![];
|
||||
|
@ -3,8 +3,9 @@ use crate::{AttestationData, Bitfield, Slot};
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Encode, Decode)]
|
||||
pub struct PendingAttestation {
|
||||
pub aggregation_bitfield: Bitfield,
|
||||
pub data: AttestationData,
|
||||
@ -12,34 +13,6 @@ pub struct PendingAttestation {
|
||||
pub inclusion_slot: Slot,
|
||||
}
|
||||
|
||||
impl Encodable for PendingAttestation {
|
||||
fn ssz_append(&self, s: &mut SszStream) {
|
||||
s.append(&self.aggregation_bitfield);
|
||||
s.append(&self.data);
|
||||
s.append(&self.custody_bitfield);
|
||||
s.append(&self.inclusion_slot);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for PendingAttestation {
|
||||
fn ssz_decode(bytes: &[u8], i: usize) -> Result<(Self, usize), DecodeError> {
|
||||
let (aggregation_bitfield, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (data, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (custody_bitfield, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (inclusion_slot, i) = <_>::ssz_decode(bytes, i)?;
|
||||
|
||||
Ok((
|
||||
Self {
|
||||
data,
|
||||
aggregation_bitfield,
|
||||
custody_bitfield,
|
||||
inclusion_slot,
|
||||
},
|
||||
i,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeHash for PendingAttestation {
|
||||
fn hash_tree_root(&self) -> Vec<u8> {
|
||||
let mut result: Vec<u8> = vec![];
|
||||
|
@ -3,39 +3,15 @@ use crate::{Hash256, Slot};
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Default, Serialize)]
|
||||
#[derive(Debug, PartialEq, Clone, Default, Serialize, Encode, Decode)]
|
||||
pub struct ProposalSignedData {
|
||||
pub slot: Slot,
|
||||
pub shard: u64,
|
||||
pub block_root: Hash256,
|
||||
}
|
||||
|
||||
impl Encodable for ProposalSignedData {
|
||||
fn ssz_append(&self, s: &mut SszStream) {
|
||||
s.append(&self.slot);
|
||||
s.append(&self.shard);
|
||||
s.append(&self.block_root);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for ProposalSignedData {
|
||||
fn ssz_decode(bytes: &[u8], i: usize) -> Result<(Self, usize), DecodeError> {
|
||||
let (slot, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (shard, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (block_root, i) = <_>::ssz_decode(bytes, i)?;
|
||||
|
||||
Ok((
|
||||
ProposalSignedData {
|
||||
slot,
|
||||
shard,
|
||||
block_root,
|
||||
},
|
||||
i,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeHash for ProposalSignedData {
|
||||
fn hash_tree_root(&self) -> Vec<u8> {
|
||||
let mut result: Vec<u8> = vec![];
|
||||
|
@ -4,8 +4,9 @@ use bls::Signature;
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize)]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode)]
|
||||
pub struct ProposerSlashing {
|
||||
pub proposer_index: u64,
|
||||
pub proposal_data_1: ProposalSignedData,
|
||||
@ -14,37 +15,6 @@ pub struct ProposerSlashing {
|
||||
pub proposal_signature_2: Signature,
|
||||
}
|
||||
|
||||
impl Encodable for ProposerSlashing {
|
||||
fn ssz_append(&self, s: &mut SszStream) {
|
||||
s.append(&self.proposer_index);
|
||||
s.append(&self.proposal_data_1);
|
||||
s.append(&self.proposal_signature_1);
|
||||
s.append(&self.proposal_data_2);
|
||||
s.append(&self.proposal_signature_2);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for ProposerSlashing {
|
||||
fn ssz_decode(bytes: &[u8], i: usize) -> Result<(Self, usize), DecodeError> {
|
||||
let (proposer_index, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (proposal_data_1, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (proposal_signature_1, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (proposal_data_2, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (proposal_signature_2, i) = <_>::ssz_decode(bytes, i)?;
|
||||
|
||||
Ok((
|
||||
ProposerSlashing {
|
||||
proposer_index,
|
||||
proposal_data_1,
|
||||
proposal_signature_1,
|
||||
proposal_data_2,
|
||||
proposal_signature_2,
|
||||
},
|
||||
i,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeHash for ProposerSlashing {
|
||||
fn hash_tree_root(&self) -> Vec<u8> {
|
||||
let mut result: Vec<u8> = vec![];
|
||||
|
@ -2,39 +2,15 @@ use crate::{test_utils::TestRandom, Slot};
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize)]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode)]
|
||||
pub struct ShardReassignmentRecord {
|
||||
pub validator_index: u64,
|
||||
pub shard: u64,
|
||||
pub slot: Slot,
|
||||
}
|
||||
|
||||
impl Encodable for ShardReassignmentRecord {
|
||||
fn ssz_append(&self, s: &mut SszStream) {
|
||||
s.append(&self.validator_index);
|
||||
s.append(&self.shard);
|
||||
s.append(&self.slot);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for ShardReassignmentRecord {
|
||||
fn ssz_decode(bytes: &[u8], i: usize) -> Result<(Self, usize), DecodeError> {
|
||||
let (validator_index, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (shard, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (slot, i) = <_>::ssz_decode(bytes, i)?;
|
||||
|
||||
Ok((
|
||||
Self {
|
||||
validator_index,
|
||||
shard,
|
||||
slot,
|
||||
},
|
||||
i,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeHash for ShardReassignmentRecord {
|
||||
fn hash_tree_root(&self) -> Vec<u8> {
|
||||
let mut result: Vec<u8> = vec![];
|
||||
|
@ -2,8 +2,9 @@ use crate::{test_utils::TestRandom, AggregateSignature, AttestationData, Bitfiel
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize)]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode)]
|
||||
pub struct SlashableAttestation {
|
||||
pub validator_indices: Vec<u64>,
|
||||
pub data: AttestationData,
|
||||
@ -11,34 +12,6 @@ pub struct SlashableAttestation {
|
||||
pub aggregate_signature: AggregateSignature,
|
||||
}
|
||||
|
||||
impl Encodable for SlashableAttestation {
|
||||
fn ssz_append(&self, s: &mut SszStream) {
|
||||
s.append_vec(&self.validator_indices);
|
||||
s.append(&self.data);
|
||||
s.append(&self.custody_bitfield);
|
||||
s.append(&self.aggregate_signature);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for SlashableAttestation {
|
||||
fn ssz_decode(bytes: &[u8], i: usize) -> Result<(Self, usize), DecodeError> {
|
||||
let (validator_indices, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (data, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (custody_bitfield, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (aggregate_signature, i) = <_>::ssz_decode(bytes, i)?;
|
||||
|
||||
Ok((
|
||||
SlashableAttestation {
|
||||
validator_indices,
|
||||
data,
|
||||
custody_bitfield,
|
||||
aggregate_signature,
|
||||
},
|
||||
i,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeHash for SlashableAttestation {
|
||||
fn hash_tree_root(&self) -> Vec<u8> {
|
||||
let mut result: Vec<u8> = vec![];
|
||||
|
@ -4,8 +4,9 @@ use bls::AggregateSignature;
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize)]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode)]
|
||||
pub struct SlashableVoteData {
|
||||
pub custody_bit_0_indices: Vec<u32>,
|
||||
pub custody_bit_1_indices: Vec<u32>,
|
||||
@ -13,34 +14,6 @@ pub struct SlashableVoteData {
|
||||
pub aggregate_signature: AggregateSignature,
|
||||
}
|
||||
|
||||
impl Encodable for SlashableVoteData {
|
||||
fn ssz_append(&self, s: &mut SszStream) {
|
||||
s.append_vec(&self.custody_bit_0_indices);
|
||||
s.append_vec(&self.custody_bit_1_indices);
|
||||
s.append(&self.data);
|
||||
s.append(&self.aggregate_signature);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for SlashableVoteData {
|
||||
fn ssz_decode(bytes: &[u8], i: usize) -> Result<(Self, usize), DecodeError> {
|
||||
let (custody_bit_0_indices, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (custody_bit_1_indices, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (data, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (aggregate_signature, i) = <_>::ssz_decode(bytes, i)?;
|
||||
|
||||
Ok((
|
||||
SlashableVoteData {
|
||||
custody_bit_0_indices,
|
||||
custody_bit_1_indices,
|
||||
data,
|
||||
aggregate_signature,
|
||||
},
|
||||
i,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeHash for SlashableVoteData {
|
||||
fn hash_tree_root(&self) -> Vec<u8> {
|
||||
let mut result: Vec<u8> = vec![];
|
||||
|
@ -3,9 +3,10 @@ use bls::PublicKey;
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz::{hash, Decodable, DecodeError, Encodable, SszStream, TreeHash};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
|
||||
// The information gathered from the PoW chain validator registration function.
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Encode, Decode)]
|
||||
pub struct ValidatorRegistryDeltaBlock {
|
||||
pub latest_registry_delta_root: Hash256,
|
||||
pub validator_index: u32,
|
||||
@ -27,37 +28,6 @@ impl Default for ValidatorRegistryDeltaBlock {
|
||||
}
|
||||
}
|
||||
|
||||
impl Encodable for ValidatorRegistryDeltaBlock {
|
||||
fn ssz_append(&self, s: &mut SszStream) {
|
||||
s.append(&self.latest_registry_delta_root);
|
||||
s.append(&self.validator_index);
|
||||
s.append(&self.pubkey);
|
||||
s.append(&self.slot);
|
||||
s.append(&self.flag);
|
||||
}
|
||||
}
|
||||
|
||||
impl Decodable for ValidatorRegistryDeltaBlock {
|
||||
fn ssz_decode(bytes: &[u8], i: usize) -> Result<(Self, usize), DecodeError> {
|
||||
let (latest_registry_delta_root, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (validator_index, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (pubkey, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (slot, i) = <_>::ssz_decode(bytes, i)?;
|
||||
let (flag, i) = <_>::ssz_decode(bytes, i)?;
|
||||
|
||||
Ok((
|
||||
Self {
|
||||
latest_registry_delta_root,
|
||||
validator_index,
|
||||
pubkey,
|
||||
slot,
|
||||
flag,
|
||||
},
|
||||
i,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeHash for ValidatorRegistryDeltaBlock {
|
||||
fn hash_tree_root(&self) -> Vec<u8> {
|
||||
let mut result: Vec<u8> = vec![];
|
||||
|
Loading…
Reference in New Issue
Block a user