Update various v0.5.1 tags, delete old file

This commit is contained in:
Paul Hauner 2019-05-22 13:03:51 +10:00
parent 9790968378
commit fabb42a162
No known key found for this signature in database
GPG Key ID: 5E2CFF9B75FA63DF
6 changed files with 23 additions and 91 deletions

View File

@ -1,29 +1,30 @@
use super::AttestationData;
use crate::test_utils::TestRandom;
use rand::RngCore;
use serde_derive::Serialize;
use ssz_derive::{Decode, Encode};
use test_random_derive::TestRandom;
use tree_hash_derive::{CachedTreeHash, TreeHash};
/// Used for pairing an attestation with a proof-of-custody.
///
/// Spec v0.5.1
#[derive(Debug, Clone, PartialEq, Default, Serialize, Encode, Decode, TreeHash, CachedTreeHash)]
/// Spec v0.6.1
#[derive(
Debug,
Clone,
PartialEq,
Default,
Serialize,
Encode,
Decode,
TreeHash,
CachedTreeHash,
TestRandom,
)]
pub struct AttestationDataAndCustodyBit {
pub data: AttestationData,
pub custody_bit: bool,
}
impl TestRandom for AttestationDataAndCustodyBit {
fn random_for_test(rng: &mut impl RngCore) -> Self {
Self {
data: <_>::random_for_test(rng),
custody_bit: <_>::random_for_test(rng),
}
}
}
#[cfg(test)]
mod test {
use super::*;

View File

@ -56,35 +56,35 @@ pub trait EthSpec:
/// Returns the `SHARD_COUNT` constant for this specification.
///
/// Spec v0.5.1
/// Spec v0.6.1
fn shard_count() -> usize {
Self::ShardCount::to_usize()
}
/// Returns the `SLOTS_PER_HISTORICAL_ROOT` constant for this specification.
///
/// Spec v0.5.1
/// Spec v0.6.1
fn slots_per_historical_root() -> usize {
Self::SlotsPerHistoricalRoot::to_usize()
}
/// Returns the `LATEST_RANDAO_MIXES_LENGTH` constant for this specification.
///
/// Spec v0.5.1
/// Spec v0.6.1
fn latest_randao_mixes_length() -> usize {
Self::LatestRandaoMixesLength::to_usize()
}
/// Returns the `LATEST_ACTIVE_INDEX_ROOTS` constant for this specification.
///
/// Spec v0.5.1
/// Spec v0.6.1
fn latest_active_index_roots() -> usize {
Self::LatestActiveIndexRootsLength::to_usize()
}
/// Returns the `LATEST_SLASHED_EXIT_LENGTH` constant for this specification.
///
/// Spec v0.5.1
/// Spec v0.6.1
fn latest_slashed_exit_length() -> usize {
Self::LatestSlashedExitLength::to_usize()
}
@ -92,7 +92,7 @@ pub trait EthSpec:
/// Ethereum Foundation specifications.
///
/// Spec v0.5.1
/// Spec v0.6.1
#[derive(Clone, PartialEq, Debug, Default, Serialize, Deserialize)]
pub struct FoundationEthSpec;
@ -111,8 +111,6 @@ impl EthSpec for FoundationEthSpec {
pub type FoundationBeaconState = BeaconState<FoundationEthSpec>;
/// Ethereum Foundation specifications, modified to be suitable for < 1000 validators.
///
/// Spec v0.5.1
#[derive(Clone, PartialEq, Debug, Default, Serialize, Deserialize)]
pub struct FewValidatorsEthSpec;
@ -131,8 +129,6 @@ impl EthSpec for FewValidatorsEthSpec {
pub type FewValidatorsBeaconState = BeaconState<FewValidatorsEthSpec>;
/// Specifications suitable for a small-scale (< 1000 validators) lighthouse testnet.
///
/// Spec v0.5.1
#[derive(Clone, PartialEq, Debug, Default, Serialize, Deserialize)]
pub struct LighthouseTestnetEthSpec;

View File

@ -35,7 +35,7 @@ pub struct DepositData {
impl DepositData {
/// Generate the signature for a given DepositData details.
///
/// Spec v0.5.1
/// Spec v0.6.1
pub fn create_signature(
&self,
secret_key: &SecretKey,
@ -48,16 +48,6 @@ impl DepositData {
Signature::new(msg.as_slice(), domain, secret_key)
}
/// Verify that proof-of-possession is valid.
///
/// Spec v0.5.1
pub fn validate_signature(&self, epoch: Epoch, fork: &Fork, spec: &ChainSpec) -> bool {
let msg = self.signed_root();
let domain = spec.get_domain(epoch, Domain::Deposit, fork);
self.signature.verify(&msg, domain, &self.pubkey)
}
}
#[cfg(test)]
@ -66,23 +56,4 @@ mod tests {
ssz_tests!(DepositData);
cached_tree_hash_tests!(DepositData);
#[test]
fn can_create_and_validate() {
let spec = ChainSpec::foundation();
let fork = Fork::genesis(&spec);
let keypair = Keypair::random();
let epoch = Epoch::new(0);
let mut deposit_input = DepositData {
pubkey: keypair.pk.clone(),
amount: 0,
withdrawal_credentials: Hash256::zero(),
signature: Signature::empty_signature(),
};
deposit_input.signature = deposit_input.create_signature(&keypair.sk, epoch, &fork, &spec);
assert!(deposit_input.validate_signature(epoch, &fork, &spec));
}
}

View File

@ -1,36 +0,0 @@
use super::Eth1Data;
use crate::test_utils::TestRandom;
use serde_derive::{Deserialize, Serialize};
use ssz_derive::{Decode, Encode};
use test_random_derive::TestRandom;
use tree_hash_derive::{CachedTreeHash, TreeHash};
/// A summation of votes for some `Eth1Data`.
///
/// Spec v0.5.1
#[derive(
Debug,
PartialEq,
Clone,
Default,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
CachedTreeHash,
TestRandom,
)]
pub struct Eth1DataVote {
pub eth1_data: Eth1Data,
pub vote_count: u64,
}
#[cfg(test)]
mod tests {
use super::*;
ssz_tests!(Eth1DataVote);
cached_tree_hash_tests!(Eth1DataVote);
}

View File

@ -9,7 +9,7 @@ use tree_hash_derive::{CachedTreeHash, TreeHash};
/// Historical block and state roots.
///
/// Spec v0.5.1
/// Spec v0.6.1
#[derive(
Debug,
Clone,

View File

@ -9,7 +9,7 @@ pub enum Error {
/// Defines the epochs relative to some epoch. Most useful when referring to the committees prior
/// to and following some epoch.
///
/// Spec v0.5.1
/// Spec v0.6.1
#[derive(Debug, PartialEq, Clone, Copy)]
pub enum RelativeEpoch {
/// The prior epoch.