Adding a #[signed_root(skip_hashing)] macro

Lets the user annotate fields of a struct to skip for signed root
hashing.

Also added tests in a `eth2/utils/tests` crate, so that we can test
whether these derived macros work as intended.
This commit is contained in:
Sean Yu
2019-03-27 14:57:50 -07:00
parent a46f676f89
commit 8cb6368fe6
9 changed files with 129 additions and 16 deletions

View File

@@ -25,6 +25,7 @@ pub struct Attestation {
pub aggregation_bitfield: Bitfield,
pub data: AttestationData,
pub custody_bitfield: Bitfield,
#[signed_root(skip_hashing)]
pub aggregate_signature: AggregateSignature,
}

View File

@@ -27,6 +27,7 @@ pub struct BeaconBlock {
pub previous_block_root: Hash256,
pub state_root: Hash256,
pub body: BeaconBlockBody,
#[signed_root(skip_hashing)]
pub signature: Signature,
}

View File

@@ -27,6 +27,7 @@ pub struct BeaconBlockHeader {
pub previous_block_root: Hash256,
pub state_root: Hash256,
pub block_body_root: Hash256,
#[signed_root(skip_hashing)]
pub signature: Signature,
}

View File

@@ -25,6 +25,7 @@ use test_random_derive::TestRandom;
pub struct DepositInput {
pub pubkey: PublicKey,
pub withdrawal_credentials: Hash256,
#[signed_root(skip_hashing)]
pub proof_of_possession: Signature,
}

View File

@@ -27,6 +27,7 @@ pub struct SlashableAttestation {
pub validator_indices: Vec<u64>,
pub data: AttestationData,
pub custody_bitfield: Bitfield,
#[signed_root(skip_hashing)]
pub aggregate_signature: AggregateSignature,
}

View File

@@ -32,6 +32,7 @@ pub struct Transfer {
pub slot: Slot,
pub pubkey: PublicKey,
#[derivative(Hash = "ignore")]
#[signed_root(skip_hashing)]
pub signature: Signature,
}

View File

@@ -24,6 +24,7 @@ use test_random_derive::TestRandom;
pub struct VoluntaryExit {
pub epoch: Epoch,
pub validator_index: u64,
#[signed_root(skip_hashing)]
pub signature: Signature,
}