Update to v0.9.1

This commit is contained in:
Michael Sproul
2019-11-11 14:55:54 +11:00
parent aaa5f2042f
commit c36bb94d6e
19 changed files with 38 additions and 243 deletions

View File

@@ -9,7 +9,7 @@ use tree_hash_derive::{SignedRoot, TreeHash};
/// Details an attestation that can be slashable.
///
/// Spec v0.9.0
/// Spec v0.9.1
#[derive(
Debug,
Clone,
@@ -26,7 +26,6 @@ use tree_hash_derive::{SignedRoot, TreeHash};
pub struct Attestation<T: EthSpec> {
pub aggregation_bits: BitList<T::MaxValidatorsPerCommittee>,
pub data: AttestationData,
pub custody_bits: BitList<T::MaxValidatorsPerCommittee>,
#[signed_root(skip_hashing)]
pub signature: AggregateSignature,
}
@@ -47,7 +46,6 @@ impl<T: EthSpec> Attestation<T> {
debug_assert!(self.signers_disjoint_from(other));
self.aggregation_bits = self.aggregation_bits.union(&other.aggregation_bits);
self.custody_bits = self.custody_bits.union(&other.custody_bits);
self.signature.add_aggregate(&other.signature);
}
}

View File

@@ -1,22 +0,0 @@
use super::AttestationData;
use crate::test_utils::TestRandom;
use serde_derive::{Deserialize, Serialize};
use ssz_derive::{Decode, Encode};
use test_random_derive::TestRandom;
use tree_hash_derive::TreeHash;
/// Used for pairing an attestation with a proof-of-custody.
///
/// Spec v0.9.0
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom)]
pub struct AttestationDataAndCustodyBit {
pub data: AttestationData,
pub custody_bit: bool,
}
#[cfg(test)]
mod test {
use super::*;
ssz_tests!(AttestationDataAndCustodyBit);
}

View File

@@ -9,7 +9,7 @@ use tree_hash_derive::{SignedRoot, TreeHash};
///
/// To be included in an `AttesterSlashing`.
///
/// Spec v0.9.0
/// Spec v0.9.1
#[derive(
Debug,
PartialEq,
@@ -25,8 +25,7 @@ use tree_hash_derive::{SignedRoot, TreeHash};
#[serde(bound = "T: EthSpec")]
pub struct IndexedAttestation<T: EthSpec> {
/// Lists validator registry indices, not committee indices.
pub custody_bit_0_indices: VariableList<u64, T::MaxValidatorsPerCommittee>,
pub custody_bit_1_indices: VariableList<u64, T::MaxValidatorsPerCommittee>,
pub attesting_indices: VariableList<u64, T::MaxValidatorsPerCommittee>,
pub data: AttestationData,
#[signed_root(skip_hashing)]
pub signature: AggregateSignature,

View File

@@ -8,7 +8,6 @@ pub mod test_utils;
pub mod attestation;
pub mod attestation_data;
pub mod attestation_data_and_custody_bit;
pub mod attestation_duty;
pub mod attester_slashing;
pub mod beacon_block;
@@ -42,7 +41,6 @@ use ethereum_types::{H160, H256};
pub use crate::attestation::Attestation;
pub use crate::attestation_data::AttestationData;
pub use crate::attestation_data_and_custody_bit::AttestationDataAndCustodyBit;
pub use crate::attestation_duty::AttestationDuty;
pub use crate::attester_slashing::AttesterSlashing;
pub use crate::beacon_block::BeaconBlock;

View File

@@ -16,17 +16,14 @@ impl<T: EthSpec> TestingAttestationBuilder<T> {
let data_builder = TestingAttestationDataBuilder::new(state, index, slot);
let mut aggregation_bits = BitList::with_capacity(committee.len()).unwrap();
let mut custody_bits = BitList::with_capacity(committee.len()).unwrap();
for (i, _) in committee.iter().enumerate() {
custody_bits.set(i, false).unwrap();
aggregation_bits.set(i, false).unwrap();
}
let attestation = Attestation {
aggregation_bits,
data: data_builder.build(),
custody_bits,
signature: AggregateSignature::new(),
};
@@ -46,7 +43,6 @@ impl<T: EthSpec> TestingAttestationBuilder<T> {
secret_keys: &[&SecretKey],
fork: &Fork,
spec: &ChainSpec,
custody_bit: bool,
) -> &mut Self {
assert_eq!(
signing_validators.len(),
@@ -66,18 +62,7 @@ impl<T: EthSpec> TestingAttestationBuilder<T> {
.set(committee_index, true)
.unwrap();
if custody_bit {
self.attestation
.custody_bits
.set(committee_index, true)
.unwrap();
}
let message = AttestationDataAndCustodyBit {
data: self.attestation.data.clone(),
custody_bit,
}
.tree_hash_root();
let message = self.attestation.data.tree_hash_root();
let domain = spec.get_domain(
self.attestation.data.target.epoch,

View File

@@ -50,26 +50,19 @@ impl TestingAttesterSlashingBuilder {
};
let mut attestation_1 = IndexedAttestation {
custody_bit_0_indices: validator_indices.to_vec().into(),
custody_bit_1_indices: VariableList::empty(),
attesting_indices: validator_indices.to_vec().into(),
data: data_1,
signature: AggregateSignature::new(),
};
let mut attestation_2 = IndexedAttestation {
custody_bit_0_indices: validator_indices.to_vec().into(),
custody_bit_1_indices: VariableList::empty(),
attesting_indices: validator_indices.to_vec().into(),
data: data_2,
signature: AggregateSignature::new(),
};
let add_signatures = |attestation: &mut IndexedAttestation<T>| {
// All validators sign with a `false` custody bit.
let attestation_data_and_custody_bit = AttestationDataAndCustodyBit {
data: attestation.data.clone(),
custody_bit: false,
};
let message = attestation_data_and_custody_bit.tree_hash_root();
let message = attestation.data.tree_hash_root();
for validator_index in validator_indices {
let signature = signer(

View File

@@ -181,13 +181,7 @@ impl<T: EthSpec> TestingBeaconBlockBuilder<T> {
.iter()
.map(|validator_index| secret_keys[*validator_index])
.collect();
builder.sign(
signing_validators,
&signing_secret_keys,
&state.fork,
spec,
false,
);
builder.sign(signing_validators, &signing_secret_keys, &state.fork, spec);
builder.build()
})