2019-06-16 06:24:33 +00:00
|
|
|
use crate::{BeaconChain, BeaconChainTypes, BlockProcessingOutcome};
|
2019-06-16 19:55:59 +00:00
|
|
|
use lmd_ghost::LmdGhost;
|
2019-07-29 03:45:45 +00:00
|
|
|
use sloggers::{null::NullLoggerBuilder, Build};
|
2019-06-16 06:24:33 +00:00
|
|
|
use slot_clock::SlotClock;
|
|
|
|
use slot_clock::TestingSlotClock;
|
2019-06-20 00:59:19 +00:00
|
|
|
use state_processing::per_slot_processing;
|
2019-06-16 06:24:33 +00:00
|
|
|
use std::marker::PhantomData;
|
|
|
|
use std::sync::Arc;
|
|
|
|
use store::MemoryStore;
|
2019-06-18 17:01:58 +00:00
|
|
|
use store::Store;
|
2019-06-16 06:24:33 +00:00
|
|
|
use tree_hash::{SignedRoot, TreeHash};
|
2019-07-27 20:32:11 +00:00
|
|
|
use types::{
|
|
|
|
test_utils::TestingBeaconStateBuilder, AggregateSignature, Attestation,
|
Update to frozen spec ❄️ (v0.8.1) (#444)
* types: first updates for v0.8
* state_processing: epoch processing v0.8.0
* state_processing: block processing v0.8.0
* tree_hash_derive: support generics in SignedRoot
* types v0.8: update to use ssz_types
* state_processing v0.8: use ssz_types
* ssz_types: add bitwise methods and from_elem
* types: fix v0.8 FIXMEs
* ssz_types: add bitfield shift_up
* ssz_types: iterators and DerefMut for VariableList
* types,state_processing: use VariableList
* ssz_types: fix BitVector Decode impl
Fixed a typo in the implementation of ssz::Decode for BitVector, which caused it
to be considered variable length!
* types: fix test modules for v0.8 update
* types: remove slow type-level arithmetic
* state_processing: fix tests for v0.8
* op_pool: update for v0.8
* ssz_types: Bitfield difference length-independent
Allow computing the difference of two bitfields of different lengths.
* Implement compact committee support
* epoch_processing: committee & active index roots
* state_processing: genesis state builder v0.8
* state_processing: implement v0.8.1
* Further improve tree_hash
* Strip examples, tests from cached_tree_hash
* Update TreeHash, un-impl CachedTreeHash
* Update bitfield TreeHash, un-impl CachedTreeHash
* Update FixedLenVec TreeHash, unimpl CachedTreeHash
* Update update tree_hash_derive for new TreeHash
* Fix TreeHash, un-impl CachedTreeHash for ssz_types
* Remove fixed_len_vec, ssz benches
SSZ benches relied upon fixed_len_vec -- it is easier to just delete
them and rebuild them later (when necessary)
* Remove boolean_bitfield crate
* Fix fake_crypto BLS compile errors
* Update ef_tests for new v.8 type params
* Update ef_tests submodule to v0.8.1 tag
* Make fixes to support parsing ssz ef_tests
* `compact_committee...` to `compact_committees...`
* Derive more traits for `CompactCommittee`
* Flip bitfield byte-endianness
* Fix tree_hash for bitfields
* Modify CLI output for ef_tests
* Bump ssz crate version
* Update ssz_types doc comment
* Del cached tree hash tests from ssz_static tests
* Tidy SSZ dependencies
* Rename ssz_types crate to eth2_ssz_types
* validator_client: update for v0.8
* ssz_types: update union/difference for bit order swap
* beacon_node: update for v0.8, EthSpec
* types: disable cached tree hash, update min spec
* state_processing: fix slot bug in committee update
* tests: temporarily disable fork choice harness test
See #447
* committee cache: prevent out-of-bounds access
In the case where we tried to access the committee of a shard that didn't have a committee in the
current epoch, we were accessing elements beyond the end of the shuffling vector and panicking! This
commit adds a check to make the failure safe and explicit.
* fix bug in get_indexed_attestation and simplify
There was a bug in our implementation of get_indexed_attestation whereby
incorrect "committee indices" were used to index into the custody bitfield. The
bug was only observable in the case where some bits of the custody bitfield were
set to 1. The implementation has been simplified to remove the bug, and a test
added.
* state_proc: workaround for compact committees bug
https://github.com/ethereum/eth2.0-specs/issues/1315
* v0.8: updates to make the EF tests pass
* Remove redundant max operation checks.
* Always supply both messages when checking attestation signatures -- allowing
verification of an attestation with no signatures.
* Swap the order of the fork and domain constant in `get_domain`, to match
the spec.
* rustfmt
* ef_tests: add new epoch processing tests
* Integrate v0.8 into master (compiles)
* Remove unused crates, fix clippy lints
* Replace v0.6.3 tags w/ v0.8.1
* Remove old comment
* Ensure lmd ghost tests only run in release
* Update readme
2019-07-30 02:44:51 +00:00
|
|
|
AttestationDataAndCustodyBit, BeaconBlock, BeaconState, BitList, ChainSpec, Domain, EthSpec,
|
2019-07-27 20:32:11 +00:00
|
|
|
Hash256, Keypair, RelativeEpoch, SecretKey, Signature, Slot,
|
|
|
|
};
|
2019-06-16 06:24:33 +00:00
|
|
|
|
2019-06-26 03:06:08 +00:00
|
|
|
pub use crate::persisted_beacon_chain::{PersistedBeaconChain, BEACON_CHAIN_DB_KEY};
|
|
|
|
|
2019-06-21 01:55:37 +00:00
|
|
|
/// Indicates how the `BeaconChainHarness` should produce blocks.
|
2019-06-20 00:59:19 +00:00
|
|
|
#[derive(Clone, Copy, Debug)]
|
2019-06-21 01:55:37 +00:00
|
|
|
pub enum BlockStrategy {
|
|
|
|
/// Produce blocks upon the canonical head (normal case).
|
2019-06-18 17:01:58 +00:00
|
|
|
OnCanonicalHead,
|
2019-06-21 01:55:37 +00:00
|
|
|
/// Ignore the canonical head and produce blocks upon the block at the given slot.
|
|
|
|
///
|
|
|
|
/// Useful for simulating forks.
|
2019-06-23 00:05:12 +00:00
|
|
|
ForkCanonicalChainAt {
|
|
|
|
/// The slot of the parent of the first block produced.
|
|
|
|
previous_slot: Slot,
|
|
|
|
/// The slot of the first block produced (must be higher than `previous_slot`.
|
|
|
|
first_slot: Slot,
|
|
|
|
},
|
2019-06-18 17:01:58 +00:00
|
|
|
}
|
|
|
|
|
2019-06-21 01:55:37 +00:00
|
|
|
/// Indicates how the `BeaconChainHarness` should produce attestations.
|
2019-06-21 08:54:37 +00:00
|
|
|
#[derive(Clone, Debug)]
|
2019-06-21 01:44:15 +00:00
|
|
|
pub enum AttestationStrategy {
|
2019-06-21 01:55:37 +00:00
|
|
|
/// All validators attest to whichever block the `BeaconChainHarness` has produced.
|
2019-06-21 01:44:15 +00:00
|
|
|
AllValidators,
|
2019-06-21 08:54:37 +00:00
|
|
|
/// Only the given validators should attest. All others should fail to produce attestations.
|
|
|
|
SomeValidators(Vec<usize>),
|
2019-06-21 01:44:15 +00:00
|
|
|
}
|
|
|
|
|
2019-06-21 01:55:37 +00:00
|
|
|
/// Used to make the `BeaconChainHarness` generic over some types.
|
2019-06-16 06:24:33 +00:00
|
|
|
pub struct CommonTypes<L, E>
|
|
|
|
where
|
|
|
|
L: LmdGhost<MemoryStore, E>,
|
|
|
|
E: EthSpec,
|
|
|
|
{
|
|
|
|
_phantom_l: PhantomData<L>,
|
|
|
|
_phantom_e: PhantomData<E>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<L, E> BeaconChainTypes for CommonTypes<L, E>
|
|
|
|
where
|
2019-08-22 06:34:21 +00:00
|
|
|
L: LmdGhost<MemoryStore, E> + 'static,
|
2019-08-23 03:02:17 +00:00
|
|
|
E: EthSpec,
|
2019-06-16 06:24:33 +00:00
|
|
|
{
|
|
|
|
type Store = MemoryStore;
|
|
|
|
type SlotClock = TestingSlotClock;
|
|
|
|
type LmdGhost = L;
|
|
|
|
type EthSpec = E;
|
|
|
|
}
|
|
|
|
|
2019-06-21 01:55:37 +00:00
|
|
|
/// A testing harness which can instantiate a `BeaconChain` and populate it with blocks and
|
|
|
|
/// attestations.
|
2019-07-29 02:08:52 +00:00
|
|
|
///
|
|
|
|
/// Used for testing.
|
2019-06-16 06:24:33 +00:00
|
|
|
pub struct BeaconChainHarness<L, E>
|
|
|
|
where
|
2019-08-22 06:34:21 +00:00
|
|
|
L: LmdGhost<MemoryStore, E> + 'static,
|
2019-08-23 03:02:17 +00:00
|
|
|
E: EthSpec,
|
2019-06-16 06:24:33 +00:00
|
|
|
{
|
2019-06-23 00:05:12 +00:00
|
|
|
pub chain: BeaconChain<CommonTypes<L, E>>,
|
2019-06-26 03:06:08 +00:00
|
|
|
pub keypairs: Vec<Keypair>,
|
|
|
|
pub spec: ChainSpec,
|
2019-06-16 06:24:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<L, E> BeaconChainHarness<L, E>
|
|
|
|
where
|
|
|
|
L: LmdGhost<MemoryStore, E>,
|
|
|
|
E: EthSpec,
|
|
|
|
{
|
2019-06-21 01:55:37 +00:00
|
|
|
/// Instantiate a new harness with `validator_count` initial validators.
|
2019-06-16 06:24:33 +00:00
|
|
|
pub fn new(validator_count: usize) -> Self {
|
2019-08-07 06:40:49 +00:00
|
|
|
let state_builder = TestingBeaconStateBuilder::from_default_keypairs_file_if_exists(
|
|
|
|
validator_count,
|
|
|
|
&E::default_spec(),
|
|
|
|
);
|
|
|
|
let (genesis_state, keypairs) = state_builder.build();
|
2019-06-16 06:24:33 +00:00
|
|
|
|
2019-08-07 06:40:49 +00:00
|
|
|
Self::from_state_and_keypairs(genesis_state, keypairs)
|
|
|
|
}
|
2019-06-16 06:24:33 +00:00
|
|
|
|
2019-08-07 06:40:49 +00:00
|
|
|
/// Instantiate a new harness with an initial validator for each key supplied.
|
|
|
|
pub fn from_keypairs(keypairs: Vec<Keypair>) -> Self {
|
|
|
|
let state_builder = TestingBeaconStateBuilder::from_keypairs(keypairs, &E::default_spec());
|
2019-06-16 06:24:33 +00:00
|
|
|
let (genesis_state, keypairs) = state_builder.build();
|
|
|
|
|
2019-08-07 06:40:49 +00:00
|
|
|
Self::from_state_and_keypairs(genesis_state, keypairs)
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Instantiate a new harness with the given genesis state and a keypair for each of the
|
|
|
|
/// initial validators in the given state.
|
|
|
|
pub fn from_state_and_keypairs(genesis_state: BeaconState<E>, keypairs: Vec<Keypair>) -> Self {
|
|
|
|
let spec = E::default_spec();
|
|
|
|
|
|
|
|
let store = Arc::new(MemoryStore::open());
|
|
|
|
|
2019-06-16 06:24:33 +00:00
|
|
|
let mut genesis_block = BeaconBlock::empty(&spec);
|
|
|
|
genesis_block.state_root = Hash256::from_slice(&genesis_state.tree_hash_root());
|
|
|
|
|
2019-07-29 03:45:45 +00:00
|
|
|
let builder = NullLoggerBuilder;
|
|
|
|
let log = builder.build().expect("logger should build");
|
|
|
|
|
2019-06-16 06:24:33 +00:00
|
|
|
// Slot clock
|
|
|
|
let slot_clock = TestingSlotClock::new(
|
|
|
|
spec.genesis_slot,
|
|
|
|
genesis_state.genesis_time,
|
|
|
|
spec.seconds_per_slot,
|
|
|
|
);
|
|
|
|
|
|
|
|
let chain = BeaconChain::from_genesis(
|
|
|
|
store,
|
|
|
|
slot_clock,
|
|
|
|
genesis_state,
|
|
|
|
genesis_block,
|
|
|
|
spec.clone(),
|
2019-07-29 03:45:45 +00:00
|
|
|
log,
|
2019-06-16 06:24:33 +00:00
|
|
|
)
|
|
|
|
.expect("Terminate if beacon chain generation fails");
|
|
|
|
|
|
|
|
Self {
|
|
|
|
chain,
|
|
|
|
keypairs,
|
|
|
|
spec,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-21 01:55:37 +00:00
|
|
|
/// Advance the slot of the `BeaconChain`.
|
|
|
|
///
|
|
|
|
/// Does not produce blocks or attestations.
|
2019-06-20 00:59:19 +00:00
|
|
|
pub fn advance_slot(&self) {
|
2019-06-16 06:24:33 +00:00
|
|
|
self.chain.slot_clock.advance_slot();
|
|
|
|
self.chain.catchup_state().expect("should catchup state");
|
|
|
|
}
|
|
|
|
|
2019-06-23 00:33:35 +00:00
|
|
|
/// Extend the `BeaconChain` with some blocks and attestations. Returns the root of the
|
|
|
|
/// last-produced block (the head of the chain).
|
2019-06-21 01:55:37 +00:00
|
|
|
///
|
|
|
|
/// Chain will be extended by `num_blocks` blocks.
|
|
|
|
///
|
|
|
|
/// The `block_strategy` dictates where the new blocks will be placed.
|
|
|
|
///
|
|
|
|
/// The `attestation_strategy` dictates which validators will attest to the newly created
|
|
|
|
/// blocks.
|
2019-06-21 01:44:15 +00:00
|
|
|
pub fn extend_chain(
|
|
|
|
&self,
|
2019-06-21 01:55:37 +00:00
|
|
|
num_blocks: usize,
|
|
|
|
block_strategy: BlockStrategy,
|
2019-06-21 01:44:15 +00:00
|
|
|
attestation_strategy: AttestationStrategy,
|
2019-06-23 00:33:35 +00:00
|
|
|
) -> Hash256 {
|
2019-06-23 00:05:12 +00:00
|
|
|
let mut state = {
|
|
|
|
// Determine the slot for the first block (or skipped block).
|
|
|
|
let state_slot = match block_strategy {
|
|
|
|
BlockStrategy::OnCanonicalHead => self.chain.read_slot_clock().unwrap() - 1,
|
|
|
|
BlockStrategy::ForkCanonicalChainAt { previous_slot, .. } => previous_slot,
|
|
|
|
};
|
|
|
|
|
|
|
|
self.get_state_at_slot(state_slot)
|
2019-06-20 00:59:19 +00:00
|
|
|
};
|
|
|
|
|
2019-06-23 00:05:12 +00:00
|
|
|
// Determine the first slot where a block should be built.
|
2019-06-21 01:55:37 +00:00
|
|
|
let mut slot = match block_strategy {
|
|
|
|
BlockStrategy::OnCanonicalHead => self.chain.read_slot_clock().unwrap(),
|
2019-06-23 00:05:12 +00:00
|
|
|
BlockStrategy::ForkCanonicalChainAt { first_slot, .. } => first_slot,
|
2019-06-20 00:59:19 +00:00
|
|
|
};
|
|
|
|
|
2019-06-23 00:33:35 +00:00
|
|
|
let mut head_block_root = None;
|
|
|
|
|
2019-06-21 01:55:37 +00:00
|
|
|
for _ in 0..num_blocks {
|
2019-06-20 00:59:19 +00:00
|
|
|
while self.chain.read_slot_clock().expect("should have a slot") < slot {
|
|
|
|
self.advance_slot();
|
|
|
|
}
|
|
|
|
|
2019-06-21 01:55:37 +00:00
|
|
|
let (block, new_state) = self.build_block(state.clone(), slot, block_strategy);
|
2019-06-20 00:59:19 +00:00
|
|
|
|
|
|
|
let outcome = self
|
|
|
|
.chain
|
|
|
|
.process_block(block)
|
2019-06-20 08:46:03 +00:00
|
|
|
.expect("should not error during block processing");
|
2019-06-20 00:59:19 +00:00
|
|
|
|
2019-06-20 08:46:03 +00:00
|
|
|
if let BlockProcessingOutcome::Processed { block_root } = outcome {
|
2019-06-23 00:33:35 +00:00
|
|
|
head_block_root = Some(block_root);
|
|
|
|
|
2019-08-10 07:47:34 +00:00
|
|
|
self.add_free_attestations(&attestation_strategy, &new_state, block_root, slot);
|
2019-06-20 08:46:03 +00:00
|
|
|
} else {
|
2019-06-23 00:05:12 +00:00
|
|
|
panic!("block should be successfully processed: {:?}", outcome);
|
2019-06-20 08:46:03 +00:00
|
|
|
}
|
|
|
|
|
2019-06-20 00:59:19 +00:00
|
|
|
state = new_state;
|
|
|
|
slot += 1;
|
2019-06-18 17:01:58 +00:00
|
|
|
}
|
2019-06-23 00:33:35 +00:00
|
|
|
|
|
|
|
head_block_root.expect("did not produce any blocks")
|
2019-06-18 17:01:58 +00:00
|
|
|
}
|
|
|
|
|
2019-06-23 00:05:12 +00:00
|
|
|
fn get_state_at_slot(&self, state_slot: Slot) -> BeaconState<E> {
|
|
|
|
let state_root = self
|
|
|
|
.chain
|
2019-08-08 06:47:24 +00:00
|
|
|
.rev_iter_state_roots()
|
2019-06-23 00:05:12 +00:00
|
|
|
.find(|(_hash, slot)| *slot == state_slot)
|
|
|
|
.map(|(hash, _slot)| hash)
|
|
|
|
.expect("could not find state root");
|
|
|
|
|
|
|
|
self.chain
|
|
|
|
.store
|
|
|
|
.get(&state_root)
|
|
|
|
.expect("should read db")
|
|
|
|
.expect("should find state root")
|
|
|
|
}
|
|
|
|
|
2019-06-21 01:55:37 +00:00
|
|
|
/// Returns a newly created block, signed by the proposer for the given slot.
|
2019-06-20 00:59:19 +00:00
|
|
|
fn build_block(
|
|
|
|
&self,
|
|
|
|
mut state: BeaconState<E>,
|
|
|
|
slot: Slot,
|
2019-06-21 01:55:37 +00:00
|
|
|
block_strategy: BlockStrategy,
|
Update to frozen spec ❄️ (v0.8.1) (#444)
* types: first updates for v0.8
* state_processing: epoch processing v0.8.0
* state_processing: block processing v0.8.0
* tree_hash_derive: support generics in SignedRoot
* types v0.8: update to use ssz_types
* state_processing v0.8: use ssz_types
* ssz_types: add bitwise methods and from_elem
* types: fix v0.8 FIXMEs
* ssz_types: add bitfield shift_up
* ssz_types: iterators and DerefMut for VariableList
* types,state_processing: use VariableList
* ssz_types: fix BitVector Decode impl
Fixed a typo in the implementation of ssz::Decode for BitVector, which caused it
to be considered variable length!
* types: fix test modules for v0.8 update
* types: remove slow type-level arithmetic
* state_processing: fix tests for v0.8
* op_pool: update for v0.8
* ssz_types: Bitfield difference length-independent
Allow computing the difference of two bitfields of different lengths.
* Implement compact committee support
* epoch_processing: committee & active index roots
* state_processing: genesis state builder v0.8
* state_processing: implement v0.8.1
* Further improve tree_hash
* Strip examples, tests from cached_tree_hash
* Update TreeHash, un-impl CachedTreeHash
* Update bitfield TreeHash, un-impl CachedTreeHash
* Update FixedLenVec TreeHash, unimpl CachedTreeHash
* Update update tree_hash_derive for new TreeHash
* Fix TreeHash, un-impl CachedTreeHash for ssz_types
* Remove fixed_len_vec, ssz benches
SSZ benches relied upon fixed_len_vec -- it is easier to just delete
them and rebuild them later (when necessary)
* Remove boolean_bitfield crate
* Fix fake_crypto BLS compile errors
* Update ef_tests for new v.8 type params
* Update ef_tests submodule to v0.8.1 tag
* Make fixes to support parsing ssz ef_tests
* `compact_committee...` to `compact_committees...`
* Derive more traits for `CompactCommittee`
* Flip bitfield byte-endianness
* Fix tree_hash for bitfields
* Modify CLI output for ef_tests
* Bump ssz crate version
* Update ssz_types doc comment
* Del cached tree hash tests from ssz_static tests
* Tidy SSZ dependencies
* Rename ssz_types crate to eth2_ssz_types
* validator_client: update for v0.8
* ssz_types: update union/difference for bit order swap
* beacon_node: update for v0.8, EthSpec
* types: disable cached tree hash, update min spec
* state_processing: fix slot bug in committee update
* tests: temporarily disable fork choice harness test
See #447
* committee cache: prevent out-of-bounds access
In the case where we tried to access the committee of a shard that didn't have a committee in the
current epoch, we were accessing elements beyond the end of the shuffling vector and panicking! This
commit adds a check to make the failure safe and explicit.
* fix bug in get_indexed_attestation and simplify
There was a bug in our implementation of get_indexed_attestation whereby
incorrect "committee indices" were used to index into the custody bitfield. The
bug was only observable in the case where some bits of the custody bitfield were
set to 1. The implementation has been simplified to remove the bug, and a test
added.
* state_proc: workaround for compact committees bug
https://github.com/ethereum/eth2.0-specs/issues/1315
* v0.8: updates to make the EF tests pass
* Remove redundant max operation checks.
* Always supply both messages when checking attestation signatures -- allowing
verification of an attestation with no signatures.
* Swap the order of the fork and domain constant in `get_domain`, to match
the spec.
* rustfmt
* ef_tests: add new epoch processing tests
* Integrate v0.8 into master (compiles)
* Remove unused crates, fix clippy lints
* Replace v0.6.3 tags w/ v0.8.1
* Remove old comment
* Ensure lmd ghost tests only run in release
* Update readme
2019-07-30 02:44:51 +00:00
|
|
|
) -> (BeaconBlock<E>, BeaconState<E>) {
|
2019-06-20 00:59:19 +00:00
|
|
|
if slot < state.slot {
|
|
|
|
panic!("produce slot cannot be prior to the state slot");
|
|
|
|
}
|
|
|
|
|
2019-06-20 08:46:03 +00:00
|
|
|
while state.slot < slot {
|
2019-06-20 00:59:19 +00:00
|
|
|
per_slot_processing(&mut state, &self.spec)
|
|
|
|
.expect("should be able to advance state to slot");
|
|
|
|
}
|
|
|
|
|
2019-06-18 17:01:58 +00:00
|
|
|
state.build_all_caches(&self.spec).unwrap();
|
|
|
|
|
2019-06-21 01:55:37 +00:00
|
|
|
let proposer_index = match block_strategy {
|
|
|
|
BlockStrategy::OnCanonicalHead => self
|
2019-06-16 06:24:33 +00:00
|
|
|
.chain
|
|
|
|
.block_proposer(slot)
|
2019-06-18 17:01:58 +00:00
|
|
|
.expect("should get block proposer from chain"),
|
|
|
|
_ => state
|
|
|
|
.get_beacon_proposer_index(slot, RelativeEpoch::Current, &self.spec)
|
|
|
|
.expect("should get block proposer from state"),
|
2019-06-16 06:24:33 +00:00
|
|
|
};
|
|
|
|
|
2019-06-18 17:01:58 +00:00
|
|
|
let sk = &self.keypairs[proposer_index].sk;
|
|
|
|
let fork = &state.fork.clone();
|
2019-06-16 06:24:33 +00:00
|
|
|
|
|
|
|
let randao_reveal = {
|
|
|
|
let epoch = slot.epoch(E::slots_per_epoch());
|
|
|
|
let message = epoch.tree_hash_root();
|
|
|
|
let domain = self.spec.get_domain(epoch, Domain::Randao, fork);
|
|
|
|
Signature::new(&message, domain, sk)
|
|
|
|
};
|
|
|
|
|
2019-06-20 00:59:19 +00:00
|
|
|
let (mut block, state) = self
|
2019-06-16 06:24:33 +00:00
|
|
|
.chain
|
2019-06-18 17:01:58 +00:00
|
|
|
.produce_block_on_state(state, slot, randao_reveal)
|
|
|
|
.expect("should produce block");
|
2019-06-16 06:24:33 +00:00
|
|
|
|
|
|
|
block.signature = {
|
|
|
|
let message = block.signed_root();
|
|
|
|
let epoch = block.slot.epoch(E::slots_per_epoch());
|
|
|
|
let domain = self.spec.get_domain(epoch, Domain::BeaconProposer, fork);
|
|
|
|
Signature::new(&message, domain, sk)
|
|
|
|
};
|
|
|
|
|
2019-06-20 00:59:19 +00:00
|
|
|
(block, state)
|
2019-06-16 06:24:33 +00:00
|
|
|
}
|
2019-06-16 19:55:59 +00:00
|
|
|
|
2019-07-29 20:51:42 +00:00
|
|
|
/// Adds attestations to the `BeaconChain` operations pool and fork choice.
|
2019-06-21 01:55:37 +00:00
|
|
|
///
|
|
|
|
/// The `attestation_strategy` dictates which validators should attest.
|
2019-07-29 20:51:42 +00:00
|
|
|
fn add_free_attestations(
|
2019-06-21 01:37:02 +00:00
|
|
|
&self,
|
2019-06-21 08:54:37 +00:00
|
|
|
attestation_strategy: &AttestationStrategy,
|
2019-06-21 01:37:02 +00:00
|
|
|
state: &BeaconState<E>,
|
|
|
|
head_block_root: Hash256,
|
2019-08-10 07:47:34 +00:00
|
|
|
head_block_slot: Slot,
|
2019-06-21 01:37:02 +00:00
|
|
|
) {
|
2019-08-10 07:47:34 +00:00
|
|
|
self.get_free_attestations(
|
|
|
|
attestation_strategy,
|
|
|
|
state,
|
|
|
|
head_block_root,
|
|
|
|
head_block_slot,
|
|
|
|
)
|
|
|
|
.into_iter()
|
|
|
|
.for_each(|attestation| {
|
|
|
|
self.chain
|
|
|
|
.process_attestation(attestation)
|
|
|
|
.expect("should process attestation");
|
|
|
|
});
|
2019-08-07 06:02:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Generates a `Vec<Attestation>` for some attestation strategy and head_block.
|
|
|
|
pub fn get_free_attestations(
|
|
|
|
&self,
|
|
|
|
attestation_strategy: &AttestationStrategy,
|
|
|
|
state: &BeaconState<E>,
|
|
|
|
head_block_root: Hash256,
|
2019-08-10 07:47:34 +00:00
|
|
|
head_block_slot: Slot,
|
2019-08-07 06:02:30 +00:00
|
|
|
) -> Vec<Attestation<E>> {
|
2019-07-27 20:32:11 +00:00
|
|
|
let spec = &self.spec;
|
|
|
|
let fork = &state.fork;
|
2019-06-16 19:55:59 +00:00
|
|
|
|
2019-06-21 01:44:15 +00:00
|
|
|
let attesting_validators: Vec<usize> = match attestation_strategy {
|
|
|
|
AttestationStrategy::AllValidators => (0..self.keypairs.len()).collect(),
|
2019-06-21 08:54:37 +00:00
|
|
|
AttestationStrategy::SomeValidators(vec) => vec.clone(),
|
2019-06-21 01:44:15 +00:00
|
|
|
};
|
|
|
|
|
2019-08-07 06:02:30 +00:00
|
|
|
let mut vec = vec![];
|
|
|
|
|
2019-06-16 19:55:59 +00:00
|
|
|
state
|
|
|
|
.get_crosslink_committees_at_slot(state.slot)
|
|
|
|
.expect("should get committees")
|
|
|
|
.iter()
|
|
|
|
.for_each(|cc| {
|
2019-07-27 20:32:11 +00:00
|
|
|
let committee_size = cc.committee.len();
|
|
|
|
|
2019-06-16 19:55:59 +00:00
|
|
|
for (i, validator_index) in cc.committee.iter().enumerate() {
|
2019-06-21 01:44:15 +00:00
|
|
|
// Note: searching this array is worst-case `O(n)`. A hashset could be a better
|
|
|
|
// alternative.
|
|
|
|
if attesting_validators.contains(validator_index) {
|
2019-07-27 20:32:11 +00:00
|
|
|
let data = self
|
|
|
|
.chain
|
2019-08-10 07:47:34 +00:00
|
|
|
.produce_attestation_data_for_block(
|
|
|
|
cc.shard,
|
|
|
|
head_block_root,
|
|
|
|
head_block_slot,
|
|
|
|
state,
|
|
|
|
)
|
2019-07-27 20:32:11 +00:00
|
|
|
.expect("should produce attestation data");
|
|
|
|
|
Update to frozen spec ❄️ (v0.8.1) (#444)
* types: first updates for v0.8
* state_processing: epoch processing v0.8.0
* state_processing: block processing v0.8.0
* tree_hash_derive: support generics in SignedRoot
* types v0.8: update to use ssz_types
* state_processing v0.8: use ssz_types
* ssz_types: add bitwise methods and from_elem
* types: fix v0.8 FIXMEs
* ssz_types: add bitfield shift_up
* ssz_types: iterators and DerefMut for VariableList
* types,state_processing: use VariableList
* ssz_types: fix BitVector Decode impl
Fixed a typo in the implementation of ssz::Decode for BitVector, which caused it
to be considered variable length!
* types: fix test modules for v0.8 update
* types: remove slow type-level arithmetic
* state_processing: fix tests for v0.8
* op_pool: update for v0.8
* ssz_types: Bitfield difference length-independent
Allow computing the difference of two bitfields of different lengths.
* Implement compact committee support
* epoch_processing: committee & active index roots
* state_processing: genesis state builder v0.8
* state_processing: implement v0.8.1
* Further improve tree_hash
* Strip examples, tests from cached_tree_hash
* Update TreeHash, un-impl CachedTreeHash
* Update bitfield TreeHash, un-impl CachedTreeHash
* Update FixedLenVec TreeHash, unimpl CachedTreeHash
* Update update tree_hash_derive for new TreeHash
* Fix TreeHash, un-impl CachedTreeHash for ssz_types
* Remove fixed_len_vec, ssz benches
SSZ benches relied upon fixed_len_vec -- it is easier to just delete
them and rebuild them later (when necessary)
* Remove boolean_bitfield crate
* Fix fake_crypto BLS compile errors
* Update ef_tests for new v.8 type params
* Update ef_tests submodule to v0.8.1 tag
* Make fixes to support parsing ssz ef_tests
* `compact_committee...` to `compact_committees...`
* Derive more traits for `CompactCommittee`
* Flip bitfield byte-endianness
* Fix tree_hash for bitfields
* Modify CLI output for ef_tests
* Bump ssz crate version
* Update ssz_types doc comment
* Del cached tree hash tests from ssz_static tests
* Tidy SSZ dependencies
* Rename ssz_types crate to eth2_ssz_types
* validator_client: update for v0.8
* ssz_types: update union/difference for bit order swap
* beacon_node: update for v0.8, EthSpec
* types: disable cached tree hash, update min spec
* state_processing: fix slot bug in committee update
* tests: temporarily disable fork choice harness test
See #447
* committee cache: prevent out-of-bounds access
In the case where we tried to access the committee of a shard that didn't have a committee in the
current epoch, we were accessing elements beyond the end of the shuffling vector and panicking! This
commit adds a check to make the failure safe and explicit.
* fix bug in get_indexed_attestation and simplify
There was a bug in our implementation of get_indexed_attestation whereby
incorrect "committee indices" were used to index into the custody bitfield. The
bug was only observable in the case where some bits of the custody bitfield were
set to 1. The implementation has been simplified to remove the bug, and a test
added.
* state_proc: workaround for compact committees bug
https://github.com/ethereum/eth2.0-specs/issues/1315
* v0.8: updates to make the EF tests pass
* Remove redundant max operation checks.
* Always supply both messages when checking attestation signatures -- allowing
verification of an attestation with no signatures.
* Swap the order of the fork and domain constant in `get_domain`, to match
the spec.
* rustfmt
* ef_tests: add new epoch processing tests
* Integrate v0.8 into master (compiles)
* Remove unused crates, fix clippy lints
* Replace v0.6.3 tags w/ v0.8.1
* Remove old comment
* Ensure lmd ghost tests only run in release
* Update readme
2019-07-30 02:44:51 +00:00
|
|
|
let mut aggregation_bits = BitList::with_capacity(committee_size).unwrap();
|
|
|
|
aggregation_bits.set(i, true).unwrap();
|
|
|
|
let custody_bits = BitList::with_capacity(committee_size).unwrap();
|
2019-07-27 20:32:11 +00:00
|
|
|
|
|
|
|
let signature = {
|
|
|
|
let message = AttestationDataAndCustodyBit {
|
|
|
|
data: data.clone(),
|
|
|
|
custody_bit: false,
|
|
|
|
}
|
|
|
|
.tree_hash_root();
|
|
|
|
|
|
|
|
let domain =
|
Update to frozen spec ❄️ (v0.8.1) (#444)
* types: first updates for v0.8
* state_processing: epoch processing v0.8.0
* state_processing: block processing v0.8.0
* tree_hash_derive: support generics in SignedRoot
* types v0.8: update to use ssz_types
* state_processing v0.8: use ssz_types
* ssz_types: add bitwise methods and from_elem
* types: fix v0.8 FIXMEs
* ssz_types: add bitfield shift_up
* ssz_types: iterators and DerefMut for VariableList
* types,state_processing: use VariableList
* ssz_types: fix BitVector Decode impl
Fixed a typo in the implementation of ssz::Decode for BitVector, which caused it
to be considered variable length!
* types: fix test modules for v0.8 update
* types: remove slow type-level arithmetic
* state_processing: fix tests for v0.8
* op_pool: update for v0.8
* ssz_types: Bitfield difference length-independent
Allow computing the difference of two bitfields of different lengths.
* Implement compact committee support
* epoch_processing: committee & active index roots
* state_processing: genesis state builder v0.8
* state_processing: implement v0.8.1
* Further improve tree_hash
* Strip examples, tests from cached_tree_hash
* Update TreeHash, un-impl CachedTreeHash
* Update bitfield TreeHash, un-impl CachedTreeHash
* Update FixedLenVec TreeHash, unimpl CachedTreeHash
* Update update tree_hash_derive for new TreeHash
* Fix TreeHash, un-impl CachedTreeHash for ssz_types
* Remove fixed_len_vec, ssz benches
SSZ benches relied upon fixed_len_vec -- it is easier to just delete
them and rebuild them later (when necessary)
* Remove boolean_bitfield crate
* Fix fake_crypto BLS compile errors
* Update ef_tests for new v.8 type params
* Update ef_tests submodule to v0.8.1 tag
* Make fixes to support parsing ssz ef_tests
* `compact_committee...` to `compact_committees...`
* Derive more traits for `CompactCommittee`
* Flip bitfield byte-endianness
* Fix tree_hash for bitfields
* Modify CLI output for ef_tests
* Bump ssz crate version
* Update ssz_types doc comment
* Del cached tree hash tests from ssz_static tests
* Tidy SSZ dependencies
* Rename ssz_types crate to eth2_ssz_types
* validator_client: update for v0.8
* ssz_types: update union/difference for bit order swap
* beacon_node: update for v0.8, EthSpec
* types: disable cached tree hash, update min spec
* state_processing: fix slot bug in committee update
* tests: temporarily disable fork choice harness test
See #447
* committee cache: prevent out-of-bounds access
In the case where we tried to access the committee of a shard that didn't have a committee in the
current epoch, we were accessing elements beyond the end of the shuffling vector and panicking! This
commit adds a check to make the failure safe and explicit.
* fix bug in get_indexed_attestation and simplify
There was a bug in our implementation of get_indexed_attestation whereby
incorrect "committee indices" were used to index into the custody bitfield. The
bug was only observable in the case where some bits of the custody bitfield were
set to 1. The implementation has been simplified to remove the bug, and a test
added.
* state_proc: workaround for compact committees bug
https://github.com/ethereum/eth2.0-specs/issues/1315
* v0.8: updates to make the EF tests pass
* Remove redundant max operation checks.
* Always supply both messages when checking attestation signatures -- allowing
verification of an attestation with no signatures.
* Swap the order of the fork and domain constant in `get_domain`, to match
the spec.
* rustfmt
* ef_tests: add new epoch processing tests
* Integrate v0.8 into master (compiles)
* Remove unused crates, fix clippy lints
* Replace v0.6.3 tags w/ v0.8.1
* Remove old comment
* Ensure lmd ghost tests only run in release
* Update readme
2019-07-30 02:44:51 +00:00
|
|
|
spec.get_domain(data.target.epoch, Domain::Attestation, fork);
|
2019-07-27 20:32:11 +00:00
|
|
|
|
|
|
|
let mut agg_sig = AggregateSignature::new();
|
|
|
|
agg_sig.add(&Signature::new(
|
|
|
|
&message,
|
|
|
|
domain,
|
|
|
|
self.get_sk(*validator_index),
|
|
|
|
));
|
|
|
|
|
|
|
|
agg_sig
|
|
|
|
};
|
|
|
|
|
2019-08-09 01:54:35 +00:00
|
|
|
vec.push(Attestation {
|
Update to frozen spec ❄️ (v0.8.1) (#444)
* types: first updates for v0.8
* state_processing: epoch processing v0.8.0
* state_processing: block processing v0.8.0
* tree_hash_derive: support generics in SignedRoot
* types v0.8: update to use ssz_types
* state_processing v0.8: use ssz_types
* ssz_types: add bitwise methods and from_elem
* types: fix v0.8 FIXMEs
* ssz_types: add bitfield shift_up
* ssz_types: iterators and DerefMut for VariableList
* types,state_processing: use VariableList
* ssz_types: fix BitVector Decode impl
Fixed a typo in the implementation of ssz::Decode for BitVector, which caused it
to be considered variable length!
* types: fix test modules for v0.8 update
* types: remove slow type-level arithmetic
* state_processing: fix tests for v0.8
* op_pool: update for v0.8
* ssz_types: Bitfield difference length-independent
Allow computing the difference of two bitfields of different lengths.
* Implement compact committee support
* epoch_processing: committee & active index roots
* state_processing: genesis state builder v0.8
* state_processing: implement v0.8.1
* Further improve tree_hash
* Strip examples, tests from cached_tree_hash
* Update TreeHash, un-impl CachedTreeHash
* Update bitfield TreeHash, un-impl CachedTreeHash
* Update FixedLenVec TreeHash, unimpl CachedTreeHash
* Update update tree_hash_derive for new TreeHash
* Fix TreeHash, un-impl CachedTreeHash for ssz_types
* Remove fixed_len_vec, ssz benches
SSZ benches relied upon fixed_len_vec -- it is easier to just delete
them and rebuild them later (when necessary)
* Remove boolean_bitfield crate
* Fix fake_crypto BLS compile errors
* Update ef_tests for new v.8 type params
* Update ef_tests submodule to v0.8.1 tag
* Make fixes to support parsing ssz ef_tests
* `compact_committee...` to `compact_committees...`
* Derive more traits for `CompactCommittee`
* Flip bitfield byte-endianness
* Fix tree_hash for bitfields
* Modify CLI output for ef_tests
* Bump ssz crate version
* Update ssz_types doc comment
* Del cached tree hash tests from ssz_static tests
* Tidy SSZ dependencies
* Rename ssz_types crate to eth2_ssz_types
* validator_client: update for v0.8
* ssz_types: update union/difference for bit order swap
* beacon_node: update for v0.8, EthSpec
* types: disable cached tree hash, update min spec
* state_processing: fix slot bug in committee update
* tests: temporarily disable fork choice harness test
See #447
* committee cache: prevent out-of-bounds access
In the case where we tried to access the committee of a shard that didn't have a committee in the
current epoch, we were accessing elements beyond the end of the shuffling vector and panicking! This
commit adds a check to make the failure safe and explicit.
* fix bug in get_indexed_attestation and simplify
There was a bug in our implementation of get_indexed_attestation whereby
incorrect "committee indices" were used to index into the custody bitfield. The
bug was only observable in the case where some bits of the custody bitfield were
set to 1. The implementation has been simplified to remove the bug, and a test
added.
* state_proc: workaround for compact committees bug
https://github.com/ethereum/eth2.0-specs/issues/1315
* v0.8: updates to make the EF tests pass
* Remove redundant max operation checks.
* Always supply both messages when checking attestation signatures -- allowing
verification of an attestation with no signatures.
* Swap the order of the fork and domain constant in `get_domain`, to match
the spec.
* rustfmt
* ef_tests: add new epoch processing tests
* Integrate v0.8 into master (compiles)
* Remove unused crates, fix clippy lints
* Replace v0.6.3 tags w/ v0.8.1
* Remove old comment
* Ensure lmd ghost tests only run in release
* Update readme
2019-07-30 02:44:51 +00:00
|
|
|
aggregation_bits,
|
2019-07-27 20:32:11 +00:00
|
|
|
data,
|
Update to frozen spec ❄️ (v0.8.1) (#444)
* types: first updates for v0.8
* state_processing: epoch processing v0.8.0
* state_processing: block processing v0.8.0
* tree_hash_derive: support generics in SignedRoot
* types v0.8: update to use ssz_types
* state_processing v0.8: use ssz_types
* ssz_types: add bitwise methods and from_elem
* types: fix v0.8 FIXMEs
* ssz_types: add bitfield shift_up
* ssz_types: iterators and DerefMut for VariableList
* types,state_processing: use VariableList
* ssz_types: fix BitVector Decode impl
Fixed a typo in the implementation of ssz::Decode for BitVector, which caused it
to be considered variable length!
* types: fix test modules for v0.8 update
* types: remove slow type-level arithmetic
* state_processing: fix tests for v0.8
* op_pool: update for v0.8
* ssz_types: Bitfield difference length-independent
Allow computing the difference of two bitfields of different lengths.
* Implement compact committee support
* epoch_processing: committee & active index roots
* state_processing: genesis state builder v0.8
* state_processing: implement v0.8.1
* Further improve tree_hash
* Strip examples, tests from cached_tree_hash
* Update TreeHash, un-impl CachedTreeHash
* Update bitfield TreeHash, un-impl CachedTreeHash
* Update FixedLenVec TreeHash, unimpl CachedTreeHash
* Update update tree_hash_derive for new TreeHash
* Fix TreeHash, un-impl CachedTreeHash for ssz_types
* Remove fixed_len_vec, ssz benches
SSZ benches relied upon fixed_len_vec -- it is easier to just delete
them and rebuild them later (when necessary)
* Remove boolean_bitfield crate
* Fix fake_crypto BLS compile errors
* Update ef_tests for new v.8 type params
* Update ef_tests submodule to v0.8.1 tag
* Make fixes to support parsing ssz ef_tests
* `compact_committee...` to `compact_committees...`
* Derive more traits for `CompactCommittee`
* Flip bitfield byte-endianness
* Fix tree_hash for bitfields
* Modify CLI output for ef_tests
* Bump ssz crate version
* Update ssz_types doc comment
* Del cached tree hash tests from ssz_static tests
* Tidy SSZ dependencies
* Rename ssz_types crate to eth2_ssz_types
* validator_client: update for v0.8
* ssz_types: update union/difference for bit order swap
* beacon_node: update for v0.8, EthSpec
* types: disable cached tree hash, update min spec
* state_processing: fix slot bug in committee update
* tests: temporarily disable fork choice harness test
See #447
* committee cache: prevent out-of-bounds access
In the case where we tried to access the committee of a shard that didn't have a committee in the
current epoch, we were accessing elements beyond the end of the shuffling vector and panicking! This
commit adds a check to make the failure safe and explicit.
* fix bug in get_indexed_attestation and simplify
There was a bug in our implementation of get_indexed_attestation whereby
incorrect "committee indices" were used to index into the custody bitfield. The
bug was only observable in the case where some bits of the custody bitfield were
set to 1. The implementation has been simplified to remove the bug, and a test
added.
* state_proc: workaround for compact committees bug
https://github.com/ethereum/eth2.0-specs/issues/1315
* v0.8: updates to make the EF tests pass
* Remove redundant max operation checks.
* Always supply both messages when checking attestation signatures -- allowing
verification of an attestation with no signatures.
* Swap the order of the fork and domain constant in `get_domain`, to match
the spec.
* rustfmt
* ef_tests: add new epoch processing tests
* Integrate v0.8 into master (compiles)
* Remove unused crates, fix clippy lints
* Replace v0.6.3 tags w/ v0.8.1
* Remove old comment
* Ensure lmd ghost tests only run in release
* Update readme
2019-07-30 02:44:51 +00:00
|
|
|
custody_bits,
|
2019-07-27 20:32:11 +00:00
|
|
|
signature,
|
2019-08-09 01:54:35 +00:00
|
|
|
})
|
2019-06-21 01:44:15 +00:00
|
|
|
}
|
2019-06-16 19:55:59 +00:00
|
|
|
}
|
|
|
|
});
|
2019-08-07 06:02:30 +00:00
|
|
|
|
|
|
|
vec
|
2019-06-16 19:55:59 +00:00
|
|
|
}
|
|
|
|
|
2019-07-29 02:08:52 +00:00
|
|
|
/// Creates two forks:
|
|
|
|
///
|
|
|
|
/// - The "honest" fork: created by the `honest_validators` who have built `honest_fork_blocks`
|
|
|
|
/// on the head
|
|
|
|
/// - The "faulty" fork: created by the `faulty_validators` who skipped a slot and
|
|
|
|
/// then built `faulty_fork_blocks`.
|
|
|
|
///
|
|
|
|
/// Returns `(honest_head, faulty_head)`, the roots of the blocks at the top of each chain.
|
|
|
|
pub fn generate_two_forks_by_skipping_a_block(
|
|
|
|
&self,
|
|
|
|
honest_validators: &[usize],
|
|
|
|
faulty_validators: &[usize],
|
|
|
|
honest_fork_blocks: usize,
|
|
|
|
faulty_fork_blocks: usize,
|
|
|
|
) -> (Hash256, Hash256) {
|
|
|
|
let initial_head_slot = self.chain.head().beacon_block.slot;
|
|
|
|
|
|
|
|
// Move to the next slot so we may produce some more blocks on the head.
|
|
|
|
self.advance_slot();
|
|
|
|
|
|
|
|
// Extend the chain with blocks where only honest validators agree.
|
|
|
|
let honest_head = self.extend_chain(
|
|
|
|
honest_fork_blocks,
|
|
|
|
BlockStrategy::OnCanonicalHead,
|
|
|
|
AttestationStrategy::SomeValidators(honest_validators.to_vec()),
|
|
|
|
);
|
|
|
|
|
|
|
|
// Go back to the last block where all agreed, and build blocks upon it where only faulty nodes
|
|
|
|
// agree.
|
|
|
|
let faulty_head = self.extend_chain(
|
|
|
|
faulty_fork_blocks,
|
|
|
|
BlockStrategy::ForkCanonicalChainAt {
|
Update to frozen spec ❄️ (v0.8.1) (#444)
* types: first updates for v0.8
* state_processing: epoch processing v0.8.0
* state_processing: block processing v0.8.0
* tree_hash_derive: support generics in SignedRoot
* types v0.8: update to use ssz_types
* state_processing v0.8: use ssz_types
* ssz_types: add bitwise methods and from_elem
* types: fix v0.8 FIXMEs
* ssz_types: add bitfield shift_up
* ssz_types: iterators and DerefMut for VariableList
* types,state_processing: use VariableList
* ssz_types: fix BitVector Decode impl
Fixed a typo in the implementation of ssz::Decode for BitVector, which caused it
to be considered variable length!
* types: fix test modules for v0.8 update
* types: remove slow type-level arithmetic
* state_processing: fix tests for v0.8
* op_pool: update for v0.8
* ssz_types: Bitfield difference length-independent
Allow computing the difference of two bitfields of different lengths.
* Implement compact committee support
* epoch_processing: committee & active index roots
* state_processing: genesis state builder v0.8
* state_processing: implement v0.8.1
* Further improve tree_hash
* Strip examples, tests from cached_tree_hash
* Update TreeHash, un-impl CachedTreeHash
* Update bitfield TreeHash, un-impl CachedTreeHash
* Update FixedLenVec TreeHash, unimpl CachedTreeHash
* Update update tree_hash_derive for new TreeHash
* Fix TreeHash, un-impl CachedTreeHash for ssz_types
* Remove fixed_len_vec, ssz benches
SSZ benches relied upon fixed_len_vec -- it is easier to just delete
them and rebuild them later (when necessary)
* Remove boolean_bitfield crate
* Fix fake_crypto BLS compile errors
* Update ef_tests for new v.8 type params
* Update ef_tests submodule to v0.8.1 tag
* Make fixes to support parsing ssz ef_tests
* `compact_committee...` to `compact_committees...`
* Derive more traits for `CompactCommittee`
* Flip bitfield byte-endianness
* Fix tree_hash for bitfields
* Modify CLI output for ef_tests
* Bump ssz crate version
* Update ssz_types doc comment
* Del cached tree hash tests from ssz_static tests
* Tidy SSZ dependencies
* Rename ssz_types crate to eth2_ssz_types
* validator_client: update for v0.8
* ssz_types: update union/difference for bit order swap
* beacon_node: update for v0.8, EthSpec
* types: disable cached tree hash, update min spec
* state_processing: fix slot bug in committee update
* tests: temporarily disable fork choice harness test
See #447
* committee cache: prevent out-of-bounds access
In the case where we tried to access the committee of a shard that didn't have a committee in the
current epoch, we were accessing elements beyond the end of the shuffling vector and panicking! This
commit adds a check to make the failure safe and explicit.
* fix bug in get_indexed_attestation and simplify
There was a bug in our implementation of get_indexed_attestation whereby
incorrect "committee indices" were used to index into the custody bitfield. The
bug was only observable in the case where some bits of the custody bitfield were
set to 1. The implementation has been simplified to remove the bug, and a test
added.
* state_proc: workaround for compact committees bug
https://github.com/ethereum/eth2.0-specs/issues/1315
* v0.8: updates to make the EF tests pass
* Remove redundant max operation checks.
* Always supply both messages when checking attestation signatures -- allowing
verification of an attestation with no signatures.
* Swap the order of the fork and domain constant in `get_domain`, to match
the spec.
* rustfmt
* ef_tests: add new epoch processing tests
* Integrate v0.8 into master (compiles)
* Remove unused crates, fix clippy lints
* Replace v0.6.3 tags w/ v0.8.1
* Remove old comment
* Ensure lmd ghost tests only run in release
* Update readme
2019-07-30 02:44:51 +00:00
|
|
|
previous_slot: initial_head_slot,
|
2019-07-29 02:08:52 +00:00
|
|
|
// `initial_head_slot + 2` means one slot is skipped.
|
Update to frozen spec ❄️ (v0.8.1) (#444)
* types: first updates for v0.8
* state_processing: epoch processing v0.8.0
* state_processing: block processing v0.8.0
* tree_hash_derive: support generics in SignedRoot
* types v0.8: update to use ssz_types
* state_processing v0.8: use ssz_types
* ssz_types: add bitwise methods and from_elem
* types: fix v0.8 FIXMEs
* ssz_types: add bitfield shift_up
* ssz_types: iterators and DerefMut for VariableList
* types,state_processing: use VariableList
* ssz_types: fix BitVector Decode impl
Fixed a typo in the implementation of ssz::Decode for BitVector, which caused it
to be considered variable length!
* types: fix test modules for v0.8 update
* types: remove slow type-level arithmetic
* state_processing: fix tests for v0.8
* op_pool: update for v0.8
* ssz_types: Bitfield difference length-independent
Allow computing the difference of two bitfields of different lengths.
* Implement compact committee support
* epoch_processing: committee & active index roots
* state_processing: genesis state builder v0.8
* state_processing: implement v0.8.1
* Further improve tree_hash
* Strip examples, tests from cached_tree_hash
* Update TreeHash, un-impl CachedTreeHash
* Update bitfield TreeHash, un-impl CachedTreeHash
* Update FixedLenVec TreeHash, unimpl CachedTreeHash
* Update update tree_hash_derive for new TreeHash
* Fix TreeHash, un-impl CachedTreeHash for ssz_types
* Remove fixed_len_vec, ssz benches
SSZ benches relied upon fixed_len_vec -- it is easier to just delete
them and rebuild them later (when necessary)
* Remove boolean_bitfield crate
* Fix fake_crypto BLS compile errors
* Update ef_tests for new v.8 type params
* Update ef_tests submodule to v0.8.1 tag
* Make fixes to support parsing ssz ef_tests
* `compact_committee...` to `compact_committees...`
* Derive more traits for `CompactCommittee`
* Flip bitfield byte-endianness
* Fix tree_hash for bitfields
* Modify CLI output for ef_tests
* Bump ssz crate version
* Update ssz_types doc comment
* Del cached tree hash tests from ssz_static tests
* Tidy SSZ dependencies
* Rename ssz_types crate to eth2_ssz_types
* validator_client: update for v0.8
* ssz_types: update union/difference for bit order swap
* beacon_node: update for v0.8, EthSpec
* types: disable cached tree hash, update min spec
* state_processing: fix slot bug in committee update
* tests: temporarily disable fork choice harness test
See #447
* committee cache: prevent out-of-bounds access
In the case where we tried to access the committee of a shard that didn't have a committee in the
current epoch, we were accessing elements beyond the end of the shuffling vector and panicking! This
commit adds a check to make the failure safe and explicit.
* fix bug in get_indexed_attestation and simplify
There was a bug in our implementation of get_indexed_attestation whereby
incorrect "committee indices" were used to index into the custody bitfield. The
bug was only observable in the case where some bits of the custody bitfield were
set to 1. The implementation has been simplified to remove the bug, and a test
added.
* state_proc: workaround for compact committees bug
https://github.com/ethereum/eth2.0-specs/issues/1315
* v0.8: updates to make the EF tests pass
* Remove redundant max operation checks.
* Always supply both messages when checking attestation signatures -- allowing
verification of an attestation with no signatures.
* Swap the order of the fork and domain constant in `get_domain`, to match
the spec.
* rustfmt
* ef_tests: add new epoch processing tests
* Integrate v0.8 into master (compiles)
* Remove unused crates, fix clippy lints
* Replace v0.6.3 tags w/ v0.8.1
* Remove old comment
* Ensure lmd ghost tests only run in release
* Update readme
2019-07-30 02:44:51 +00:00
|
|
|
first_slot: initial_head_slot + 2,
|
2019-07-29 02:08:52 +00:00
|
|
|
},
|
|
|
|
AttestationStrategy::SomeValidators(faulty_validators.to_vec()),
|
|
|
|
);
|
|
|
|
|
|
|
|
assert!(honest_head != faulty_head, "forks should be distinct");
|
|
|
|
|
|
|
|
(honest_head, faulty_head)
|
|
|
|
}
|
|
|
|
|
2019-06-21 01:55:37 +00:00
|
|
|
/// Returns the secret key for the given validator index.
|
2019-06-16 19:55:59 +00:00
|
|
|
fn get_sk(&self, validator_index: usize) -> &SecretKey {
|
|
|
|
&self.keypairs[validator_index].sk
|
|
|
|
}
|
2019-06-16 06:24:33 +00:00
|
|
|
}
|