renamed the macro Hashtree to TreeHash
This commit is contained in:
parent
2ce316235f
commit
d7184345b8
@ -3,9 +3,9 @@ use crate::test_utils::TestRandom;
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz::TreeHash;
|
||||
use ssz_derive::{Decode, Encode, Hashtree};
|
||||
use ssz_derive::{Decode, Encode, TreeHash};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Encode, Decode, Hashtree)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Encode, Decode, TreeHash)]
|
||||
pub struct Attestation {
|
||||
pub aggregation_bitfield: Bitfield,
|
||||
pub data: AttestationData,
|
||||
|
@ -3,7 +3,7 @@ use crate::{AttestationDataAndCustodyBit, Crosslink, Epoch, Hash256, Slot};
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz::TreeHash;
|
||||
use ssz_derive::{Decode, Encode, Hashtree};
|
||||
use ssz_derive::{Decode, Encode, TreeHash};
|
||||
|
||||
pub const SSZ_ATTESTION_DATA_LENGTH: usize = {
|
||||
8 + // slot
|
||||
@ -16,7 +16,7 @@ pub const SSZ_ATTESTION_DATA_LENGTH: usize = {
|
||||
32 // justified_block_root
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Hash, Encode, Decode, Hashtree)]
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Hash, Encode, Decode, TreeHash)]
|
||||
pub struct AttestationData {
|
||||
pub slot: Slot,
|
||||
pub shard: u64,
|
||||
|
@ -2,9 +2,9 @@ use super::AttestationData;
|
||||
use crate::test_utils::TestRandom;
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz_derive::{Decode, Encode, Hashtree};
|
||||
use ssz_derive::{Decode, Encode, TreeHash};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Encode, Decode, Hashtree)]
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Encode, Decode, TreeHash)]
|
||||
pub struct AttestationDataAndCustodyBit {
|
||||
pub data: AttestationData,
|
||||
pub custody_bit: bool,
|
||||
|
@ -1,9 +1,9 @@
|
||||
use crate::{test_utils::TestRandom, SlashableAttestation};
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz_derive::{Decode, Encode, Hashtree};
|
||||
use ssz_derive::{Decode, Encode, TreeHash};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode, Hashtree)]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode, TreeHash)]
|
||||
pub struct AttesterSlashing {
|
||||
pub slashable_attestation_1: SlashableAttestation,
|
||||
pub slashable_attestation_2: SlashableAttestation,
|
||||
|
@ -4,9 +4,9 @@ use bls::Signature;
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz::TreeHash;
|
||||
use ssz_derive::{Decode, Encode, Hashtree};
|
||||
use ssz_derive::{Decode, Encode, TreeHash};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode, Hashtree)]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode, TreeHash)]
|
||||
pub struct BeaconBlock {
|
||||
pub slot: Slot,
|
||||
pub parent_root: Hash256,
|
||||
|
@ -2,9 +2,9 @@ use super::{Attestation, AttesterSlashing, Deposit, Exit, ProposerSlashing};
|
||||
use crate::test_utils::TestRandom;
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz_derive::{Decode, Encode, Hashtree};
|
||||
use ssz_derive::{Decode, Encode, TreeHash};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Default, Serialize, Encode, Decode, Hashtree)]
|
||||
#[derive(Debug, PartialEq, Clone, Default, Serialize, Encode, Decode, TreeHash)]
|
||||
pub struct BeaconBlockBody {
|
||||
pub proposer_slashings: Vec<ProposerSlashing>,
|
||||
pub attester_slashings: Vec<AttesterSlashing>,
|
||||
|
@ -2,9 +2,9 @@ use super::SlashableVoteData;
|
||||
use crate::test_utils::TestRandom;
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz_derive::{Decode, Encode, Hashtree};
|
||||
use ssz_derive::{Decode, Encode, TreeHash};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode, Hashtree)]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode, TreeHash)]
|
||||
pub struct CasperSlashing {
|
||||
pub slashable_vote_data_1: SlashableVoteData,
|
||||
pub slashable_vote_data_2: SlashableVoteData,
|
||||
|
@ -2,9 +2,9 @@ use crate::test_utils::TestRandom;
|
||||
use crate::{Epoch, Hash256};
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz_derive::{Decode, Encode, Hashtree};
|
||||
use ssz_derive::{Decode, Encode, TreeHash};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Hash, Encode, Decode, Hashtree)]
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Hash, Encode, Decode, TreeHash)]
|
||||
pub struct Crosslink {
|
||||
pub epoch: Epoch,
|
||||
pub shard_block_root: Hash256,
|
||||
|
@ -2,9 +2,9 @@ use super::{DepositData, Hash256};
|
||||
use crate::test_utils::TestRandom;
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz_derive::{Decode, Encode, Hashtree};
|
||||
use ssz_derive::{Decode, Encode, TreeHash};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode, Hashtree)]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode, TreeHash)]
|
||||
pub struct Deposit {
|
||||
pub branch: Vec<Hash256>,
|
||||
pub index: u64,
|
||||
|
@ -2,9 +2,9 @@ use super::DepositInput;
|
||||
use crate::test_utils::TestRandom;
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz_derive::{Decode, Encode, Hashtree};
|
||||
use ssz_derive::{Decode, Encode, TreeHash};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode, Hashtree)]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode, TreeHash)]
|
||||
pub struct DepositData {
|
||||
pub amount: u64,
|
||||
pub timestamp: u64,
|
||||
|
@ -3,9 +3,9 @@ use crate::test_utils::TestRandom;
|
||||
use bls::{PublicKey, Signature};
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz_derive::{Decode, Encode, Hashtree};
|
||||
use ssz_derive::{Decode, Encode, TreeHash};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode, Hashtree)]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode, TreeHash)]
|
||||
pub struct DepositInput {
|
||||
pub pubkey: PublicKey,
|
||||
pub withdrawal_credentials: Hash256,
|
||||
|
@ -2,10 +2,10 @@ use super::Hash256;
|
||||
use crate::test_utils::TestRandom;
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz_derive::{Decode, Encode, Hashtree};
|
||||
use ssz_derive::{Decode, Encode, TreeHash};
|
||||
|
||||
// Note: this is refer to as DepositRootVote in specs
|
||||
#[derive(Debug, PartialEq, Clone, Default, Serialize, Encode, Decode, Hashtree)]
|
||||
#[derive(Debug, PartialEq, Clone, Default, Serialize, Encode, Decode, TreeHash)]
|
||||
pub struct Eth1Data {
|
||||
pub deposit_root: Hash256,
|
||||
pub block_hash: Hash256,
|
||||
|
@ -2,10 +2,10 @@ use super::Eth1Data;
|
||||
use crate::test_utils::TestRandom;
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz_derive::{Decode, Encode, Hashtree};
|
||||
use ssz_derive::{Decode, Encode, TreeHash};
|
||||
|
||||
// Note: this is refer to as DepositRootVote in specs
|
||||
#[derive(Debug, PartialEq, Clone, Default, Serialize, Encode, Decode, Hashtree)]
|
||||
#[derive(Debug, PartialEq, Clone, Default, Serialize, Encode, Decode, TreeHash)]
|
||||
pub struct Eth1DataVote {
|
||||
pub eth1_data: Eth1Data,
|
||||
pub vote_count: u64,
|
||||
|
@ -2,9 +2,9 @@ use crate::{test_utils::TestRandom, Epoch};
|
||||
use bls::Signature;
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz_derive::{Decode, Encode, Hashtree};
|
||||
use ssz_derive::{Decode, Encode, TreeHash};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode, Hashtree)]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode, TreeHash)]
|
||||
pub struct Exit {
|
||||
pub epoch: Epoch,
|
||||
pub validator_index: u64,
|
||||
|
@ -1,9 +1,9 @@
|
||||
use crate::{test_utils::TestRandom, Epoch};
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz_derive::{Decode, Encode, Hashtree};
|
||||
use ssz_derive::{Decode, Encode, TreeHash};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Encode, Decode, Hashtree)]
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Encode, Decode, TreeHash)]
|
||||
pub struct Fork {
|
||||
pub previous_version: u64,
|
||||
pub current_version: u64,
|
||||
|
@ -2,9 +2,9 @@ use crate::test_utils::TestRandom;
|
||||
use crate::{AttestationData, Bitfield, Slot};
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz_derive::{Decode, Encode, Hashtree};
|
||||
use ssz_derive::{Decode, Encode, TreeHash};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Encode, Decode, Hashtree)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Encode, Decode, TreeHash)]
|
||||
pub struct PendingAttestation {
|
||||
pub aggregation_bitfield: Bitfield,
|
||||
pub data: AttestationData,
|
||||
|
@ -2,9 +2,9 @@ use crate::test_utils::TestRandom;
|
||||
use crate::{Hash256, Slot};
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz_derive::{Decode, Encode, Hashtree};
|
||||
use ssz_derive::{Decode, Encode, TreeHash};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Default, Serialize, Encode, Decode, Hashtree)]
|
||||
#[derive(Debug, PartialEq, Clone, Default, Serialize, Encode, Decode, TreeHash)]
|
||||
pub struct ProposalSignedData {
|
||||
pub slot: Slot,
|
||||
pub shard: u64,
|
||||
|
@ -3,9 +3,9 @@ use crate::test_utils::TestRandom;
|
||||
use bls::Signature;
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz_derive::{Decode, Encode, Hashtree};
|
||||
use ssz_derive::{Decode, Encode, TreeHash};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode, Hashtree)]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode, TreeHash)]
|
||||
pub struct ProposerSlashing {
|
||||
pub proposer_index: u64,
|
||||
pub proposal_data_1: ProposalSignedData,
|
||||
|
@ -1,9 +1,9 @@
|
||||
use crate::{test_utils::TestRandom, Slot};
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz_derive::{Decode, Encode, Hashtree};
|
||||
use ssz_derive::{Decode, Encode, TreeHash};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode, Hashtree)]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode, TreeHash)]
|
||||
pub struct ShardReassignmentRecord {
|
||||
pub validator_index: u64,
|
||||
pub shard: u64,
|
||||
|
@ -1,9 +1,9 @@
|
||||
use crate::{test_utils::TestRandom, AggregateSignature, AttestationData, Bitfield};
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz_derive::{Decode, Encode, Hashtree};
|
||||
use ssz_derive::{Decode, Encode, TreeHash};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode, Hashtree)]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode, TreeHash)]
|
||||
pub struct SlashableAttestation {
|
||||
pub validator_indices: Vec<u64>,
|
||||
pub data: AttestationData,
|
||||
|
@ -4,9 +4,9 @@ use crate::test_utils::TestRandom;
|
||||
use bls::AggregateSignature;
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz_derive::{Decode, Encode, Hashtree};
|
||||
use ssz_derive::{Decode, Encode, TreeHash};
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode, Hashtree)]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Encode, Decode, TreeHash)]
|
||||
pub struct SlashableVoteData {
|
||||
pub custody_bit_0_indices: Vec<u32>,
|
||||
pub custody_bit_1_indices: Vec<u32>,
|
||||
|
@ -2,10 +2,10 @@ use crate::{test_utils::TestRandom, Hash256, Slot};
|
||||
use bls::PublicKey;
|
||||
use rand::RngCore;
|
||||
use serde_derive::Serialize;
|
||||
use ssz_derive::{Decode, Encode, Hashtree};
|
||||
use ssz_derive::{Decode, Encode, TreeHash};
|
||||
|
||||
// The information gathered from the PoW chain validator registration function.
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Encode, Decode, Hashtree)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Encode, Decode, TreeHash)]
|
||||
pub struct ValidatorRegistryDeltaBlock {
|
||||
pub latest_registry_delta_root: Hash256,
|
||||
pub validator_index: u32,
|
||||
|
@ -2,7 +2,7 @@
|
||||
//!
|
||||
//! - `#[derive(Encode)]`
|
||||
//! - `#[derive(Decode)]`
|
||||
//! - `#[derive(Hashtree)]`
|
||||
//! - `#[derive(TreeHash)]`
|
||||
//!
|
||||
//! These macros provide SSZ encoding/decoding for a `struct`. Fields are encoded/decoded in the
|
||||
//! order they are defined.
|
||||
@ -131,8 +131,8 @@ pub fn ssz_decode_derive(input: TokenStream) -> TokenStream {
|
||||
/// Implements `ssz::TreeHash` for some `struct`.
|
||||
///
|
||||
/// Fields are processed in the order they are defined.
|
||||
#[proc_macro_derive(Hashtree)]
|
||||
pub fn ssz_hashtree_derive(input: TokenStream) -> TokenStream {
|
||||
#[proc_macro_derive(TreeHash)]
|
||||
pub fn ssz_tree_hash_derive(input: TokenStream) -> TokenStream {
|
||||
let item = parse_macro_input!(input as DeriveInput);
|
||||
|
||||
let name = &item.ident;
|
||||
|
Loading…
Reference in New Issue
Block a user