2019-11-25 04:48:24 +00:00
|
|
|
#![cfg(test)]
|
|
|
|
|
2020-05-25 00:25:08 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate assert_matches;
|
|
|
|
|
2020-03-04 06:10:22 +00:00
|
|
|
use beacon_chain::{BeaconChain, BeaconChainTypes, StateSkipConfig};
|
2019-11-25 04:48:24 +00:00
|
|
|
use node_test_rig::{
|
|
|
|
environment::{Environment, EnvironmentBuilder},
|
Prepare for public testnet (#628)
* Update to spec v0.9.0
* Update to v0.9.1
* Bump spec tags for v0.9.1
* Formatting, fix CI failures
* Resolve accidental KeyPair merge conflict
* Document new BeaconState functions
* Add `validator` changes from `validator-to-rest`
* Add initial (failing) REST api tests
* Fix signature parsing
* Add more tests
* Refactor http router
* Add working tests for publish beacon block
* Add validator duties tests
* Move account_manager under `lighthouse` binary
* Unify logfile handling in `environment` crate.
* Fix incorrect cache drops in `advance_caches`
* Update fork choice for v0.9.1
* Add `deposit_contract` crate
* Add progress on validator onboarding
* Add unfinished attesation code
* Update account manager CLI
* Write eth1 data file as hex string
* Integrate ValidatorDirectory with validator_client
* Move ValidatorDirectory into validator_client
* Clean up some FIXMEs
* Add beacon_chain_sim
* Fix a few docs/logs
* Expand `beacon_chain_sim`
* Fix spec for `beacon_chain_sim
* More testing for api
* Start work on attestation endpoint
* Reject empty attestations
* Allow attestations to genesis block
* Add working tests for `rest_api` validator endpoint
* Remove grpc from beacon_node
* Start heavy refactor of validator client
- Block production is working
* Prune old validator client files
* Start works on attestation service
* Add attestation service to validator client
* Use full pubkey for validator directories
* Add validator duties post endpoint
* Use par_iter for keypair generation
* Use bulk duties request in validator client
* Add version http endpoint tests
* Add interop keys and startup wait
* Ensure a prompt exit
* Add duties pruning
* Fix compile error in beacon node tests
* Add github workflow
* Modify rust.yaml
* Modify gitlab actions
* Add to CI file
* Add sudo to CI npm install
* Move cargo fmt to own job in tests
* Fix cargo fmt in CI
* Add rustup update before cargo fmt
* Change name of CI job
* Make other CI jobs require cargo fmt
* Add CI badge
* Remove gitlab and travis files
* Add different http timeout for debug
* Update docker file, use makefile in CI
* Use make in the dockerfile, skip the test
* Use the makefile for debug GI test
* Update book
* Tidy grpc and misc things
* Apply discv5 fixes
* Address other minor issues
* Fix warnings
* Attempt fix for addr parsing
* Tidy validator config, CLIs
* Tidy comments
* Tidy signing, reduce ForkService duplication
* Fail if skipping too many slots
* Set default recent genesis time to 0
* Add custom http timeout to validator
* Fix compile bug in node_test_rig
* Remove old bootstrap flag from val CLI
* Update docs
* Tidy val client
* Change val client log levels
* Add comments, more validity checks
* Fix compile error, add comments
* Undo changes to eth2-libp2p/src
* Reduce duplication of keypair generation
* Add more logging for validator duties
* Fix beacon_chain_sim, nitpicks
* Fix compile error, minor nits
* Update to use v0.9.2 version of deposit contract
* Add efforts to automate eth1 testnet deployment
* Fix lcli testnet deployer
* Modify bn CLI to parse eth2_testnet_dir
* Progress with account_manager deposit tools
* Make account manager submit deposits
* Add password option for submitting deposits
* Allow custom deposit amount
* Add long names to lcli clap
* Add password option to lcli deploy command
* Fix minor bugs whilst testing
* Address Michael's comments
* Add refund-deposit-contract to lcli
* Use time instead of skip count for denying long skips
* Improve logging for eth1
* Fix bug with validator services exiting on error
* Drop the block cache after genesis
* Modify eth1 testnet config
* Improve eth1 logging
* Make validator wait until genesis time
* Fix bug in eth1 voting
* Add more logging to eth1 voting
* Handle errors in eth1 http module
* Set SECONDS_PER_DAY to sensible minimum
* Shorten delay before testnet start
* Ensure eth1 block is produced without any votes
* Improve eth1 logging
* Fix broken tests in eth1
* Tidy code in rest_api
* Fix failing test in deposit_contract
* Make CLI args more consistent
* Change validator/duties endpoint
* Add time-based skip slot limiting
* Add new error type missed in previous commit
* Add log when waiting for genesis
* Refactor beacon node CLI
* Remove unused dep
* Add lcli eth1-genesis command
* Fix bug in master merge
* Apply clippy lints to beacon node
* Add support for YamlConfig in Eth2TestnetDir
* Upgrade tesnet deposit contract version
* Remove unnecessary logging and correct formatting
* Add a hardcoded eth2 testnet config
* Ensure http server flag works. Overwrite configs with flags.
* Ensure boot nodes are loaded from testnet dir
* Fix account manager CLI bugs
* Fix bugs with beacon node cli
* Allow testnet dir without boot nodes
* Write genesis state as SSZ
* Remove ---/n from the start of testnet_dir files
* Set default libp2p address
* Tidy account manager CLI, add logging
* Add check to see if testnet dir exists
* Apply reviewers suggestions
* Add HeadTracker struct
* Add fork choice persistence
* Shorten slot time for simulator
* Add the /beacon/heads API endpoint
* Update hardcoded testnet
* Add tests for BeaconChain persistence + fix bugs
* Extend BeaconChain persistence testing
* Ensure chain is finalized b4 persistence tests
* Ensure boot_enr.yaml is include in binary
* Refactor beacon_chain_sim
* Move files about in beacon sim
* Update beacon_chain_sim
* Fix bug with deposit inclusion
* Increase log in genesis service, fix todo
* Tidy sim, fix broken rest_api tests
* Fix more broken tests
* Update testnet
* Fix broken rest api test
* Tidy account manager CLI
* Use tempdir for account manager
* Stop hardcoded testnet dir from creating dir
* Rename Eth2TestnetDir to Eth2TestnetConfig
* Change hardcoded -> hard_coded
* Tidy account manager
* Add log to account manager
* Tidy, ensure head tracker is loaded from disk
* Tidy beacon chain builder
* Tidy eth1_chain
* Adds log support for simulator
* Revert "Adds log support for simulator"
This reverts commit ec77c66a052350f551db145cf20f213823428dd3.
* Adds log support for simulator
* Tidy after self-review
* Change default log level
* Address Michael's delicious PR comments
* Fix off-by-one in tests
2019-12-03 04:28:57 +00:00
|
|
|
testing_client_config, ClientConfig, ClientGenesis, LocalBeaconNode,
|
2019-11-25 04:48:24 +00:00
|
|
|
};
|
2019-12-19 00:45:28 +00:00
|
|
|
use remote_beacon_node::{
|
Initial work towards v0.2.0 (#924)
* Remove ping protocol
* Initial renaming of network services
* Correct rebasing relative to latest master
* Start updating types
* Adds HashMapDelay struct to utils
* Initial network restructure
* Network restructure. Adds new types for v0.2.0
* Removes build artefacts
* Shift validation to beacon chain
* Temporarily remove gossip validation
This is to be updated to match current optimisation efforts.
* Adds AggregateAndProof
* Begin rebuilding pubsub encoding/decoding
* Signature hacking
* Shift gossipsup decoding into eth2_libp2p
* Existing EF tests passing with fake_crypto
* Shifts block encoding/decoding into RPC
* Delete outdated API spec
* All release tests passing bar genesis state parsing
* Update and test YamlConfig
* Update to spec v0.10 compatible BLS
* Updates to BLS EF tests
* Add EF test for AggregateVerify
And delete unused hash2curve tests for uncompressed points
* Update EF tests to v0.10.1
* Use optional block root correctly in block proc
* Use genesis fork in deposit domain. All tests pass
* Fast aggregate verify test
* Update REST API docs
* Fix unused import
* Bump spec tags to v0.10.1
* Add `seconds_per_eth1_block` to chainspec
* Update to timestamp based eth1 voting scheme
* Return None from `get_votes_to_consider` if block cache is empty
* Handle overflows in `is_candidate_block`
* Revert to failing tests
* Fix eth1 data sets test
* Choose default vote according to spec
* Fix collect_valid_votes tests
* Fix `get_votes_to_consider` to choose all eligible blocks
* Uncomment winning_vote tests
* Add comments; remove unused code
* Reduce seconds_per_eth1_block for simulation
* Addressed review comments
* Add test for default vote case
* Fix logs
* Remove unused functions
* Meter default eth1 votes
* Fix comments
* Progress on attestation service
* Address review comments; remove unused dependency
* Initial work on removing libp2p lock
* Add LRU caches to store (rollup)
* Update attestation validation for DB changes (WIP)
* Initial version of should_forward_block
* Scaffold
* Progress on attestation validation
Also, consolidate prod+testing slot clocks so that they share much
of the same implementation and can both handle sub-slot time changes.
* Removes lock from libp2p service
* Completed network lock removal
* Finish(?) attestation processing
* Correct network termination future
* Add slot check to block check
* Correct fmt issues
* Remove Drop implementation for network service
* Add first attempt at attestation proc. re-write
* Add version 2 of attestation processing
* Minor fixes
* Add validator pubkey cache
* Make get_indexed_attestation take a committee
* Link signature processing into new attn verification
* First working version
* Ensure pubkey cache is updated
* Add more metrics, slight optimizations
* Clone committee cache during attestation processing
* Update shuffling cache during block processing
* Remove old commented-out code
* Fix shuffling cache insert bug
* Used indexed attestation in fork choice
* Restructure attn processing, add metrics
* Add more detailed metrics
* Tidy, fix failing tests
* Fix failing tests, tidy
* Address reviewers suggestions
* Disable/delete two outdated tests
* Modification of validator for subscriptions
* Add slot signing to validator client
* Further progress on validation subscription
* Adds necessary validator subscription functionality
* Add new Pubkeys struct to signature_sets
* Refactor with functional approach
* Update beacon chain
* Clean up validator <-> beacon node http types
* Add aggregator status to ValidatorDuty
* Impl Clone for manual slot clock
* Fix minor errors
* Further progress validator client subscription
* Initial subscription and aggregation handling
* Remove decompressed member from pubkey bytes
* Progress to modifying val client for attestation aggregation
* First draft of validator client upgrade for aggregate attestations
* Add hashmap for indices lookup
* Add state cache, remove store cache
* Only build the head committee cache
* Removes lock on a network channel
* Partially implement beacon node subscription http api
* Correct compilation issues
* Change `get_attesting_indices` to use Vec
* Fix failing test
* Partial implementation of timer
* Adds timer, removes exit_future, http api to op pool
* Partial multiple aggregate attestation handling
* Permits bulk messages accross gossipsub network channel
* Correct compile issues
* Improve gosispsub messaging and correct rest api helpers
* Added global gossipsub subscriptions
* Update validator subscriptions data structs
* Tidy
* Re-structure validator subscriptions
* Initial handling of subscriptions
* Re-structure network service
* Add pubkey cache persistence file
* Add more comments
* Integrate persistence file into builder
* Add pubkey cache tests
* Add HashSetDelay and introduce into attestation service
* Handles validator subscriptions
* Add data_dir to beacon chain builder
* Remove Option in pubkey cache persistence file
* Ensure consistency between datadir/data_dir
* Fix failing network test
* Peer subnet discovery gets queued for future subscriptions
* Reorganise attestation service functions
* Initial wiring of attestation service
* First draft of attestation service timing logic
* Correct minor typos
* Tidy
* Fix todos
* Improve tests
* Add PeerInfo to connected peers mapping
* Fix compile error
* Fix compile error from merge
* Split up block processing metrics
* Tidy
* Refactor get_pubkey_from_state
* Remove commented-out code
* Rename state_cache -> checkpoint_cache
* Rename Checkpoint -> Snapshot
* Tidy, add comments
* Tidy up find_head function
* Change some checkpoint -> snapshot
* Add tests
* Expose max_len
* Remove dead code
* Tidy
* Fix bug
* Add sync-speed metric
* Add first attempt at VerifiableBlock
* Start integrating into beacon chain
* Integrate VerifiableBlock
* Rename VerifableBlock -> PartialBlockVerification
* Add start of typed methods
* Add progress
* Add further progress
* Rename structs
* Add full block verification to block_processing.rs
* Further beacon chain integration
* Update checks for gossip
* Add todo
* Start adding segement verification
* Add passing chain segement test
* Initial integration with batch sync
* Minor changes
* Tidy, add more error checking
* Start adding chain_segment tests
* Finish invalid signature tests
* Include single and gossip verified blocks in tests
* Add gossip verification tests
* Start adding docs
* Finish adding comments to block_processing.rs
* Rename block_processing.rs -> block_verification
* Start removing old block processing code
* Fixes beacon_chain compilation
* Fix project-wide compile errors
* Remove old code
* Correct code to pass all tests
* Fix bug with beacon proposer index
* Fix shim for BlockProcessingError
* Only process one epoch at a time
* Fix loop in chain segment processing
* Correct tests from master merge
* Add caching for state.eth1_data_votes
* Add BeaconChain::validator_pubkey
* Revert "Add caching for state.eth1_data_votes"
This reverts commit cd73dcd6434fb8d8e6bf30c5356355598ea7b78e.
Co-authored-by: Grant Wuerker <gwuerker@gmail.com>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
Co-authored-by: Michael Sproul <micsproul@gmail.com>
Co-authored-by: pawan <pawandhananjay@gmail.com>
Co-authored-by: Paul Hauner <paul@paulhauner.com>
2020-03-17 06:24:44 +00:00
|
|
|
Committee, HeadBeaconBlock, PersistedOperationPool, PublishStatus, ValidatorResponse,
|
2019-12-19 00:45:28 +00:00
|
|
|
};
|
Initial work towards v0.2.0 (#924)
* Remove ping protocol
* Initial renaming of network services
* Correct rebasing relative to latest master
* Start updating types
* Adds HashMapDelay struct to utils
* Initial network restructure
* Network restructure. Adds new types for v0.2.0
* Removes build artefacts
* Shift validation to beacon chain
* Temporarily remove gossip validation
This is to be updated to match current optimisation efforts.
* Adds AggregateAndProof
* Begin rebuilding pubsub encoding/decoding
* Signature hacking
* Shift gossipsup decoding into eth2_libp2p
* Existing EF tests passing with fake_crypto
* Shifts block encoding/decoding into RPC
* Delete outdated API spec
* All release tests passing bar genesis state parsing
* Update and test YamlConfig
* Update to spec v0.10 compatible BLS
* Updates to BLS EF tests
* Add EF test for AggregateVerify
And delete unused hash2curve tests for uncompressed points
* Update EF tests to v0.10.1
* Use optional block root correctly in block proc
* Use genesis fork in deposit domain. All tests pass
* Fast aggregate verify test
* Update REST API docs
* Fix unused import
* Bump spec tags to v0.10.1
* Add `seconds_per_eth1_block` to chainspec
* Update to timestamp based eth1 voting scheme
* Return None from `get_votes_to_consider` if block cache is empty
* Handle overflows in `is_candidate_block`
* Revert to failing tests
* Fix eth1 data sets test
* Choose default vote according to spec
* Fix collect_valid_votes tests
* Fix `get_votes_to_consider` to choose all eligible blocks
* Uncomment winning_vote tests
* Add comments; remove unused code
* Reduce seconds_per_eth1_block for simulation
* Addressed review comments
* Add test for default vote case
* Fix logs
* Remove unused functions
* Meter default eth1 votes
* Fix comments
* Progress on attestation service
* Address review comments; remove unused dependency
* Initial work on removing libp2p lock
* Add LRU caches to store (rollup)
* Update attestation validation for DB changes (WIP)
* Initial version of should_forward_block
* Scaffold
* Progress on attestation validation
Also, consolidate prod+testing slot clocks so that they share much
of the same implementation and can both handle sub-slot time changes.
* Removes lock from libp2p service
* Completed network lock removal
* Finish(?) attestation processing
* Correct network termination future
* Add slot check to block check
* Correct fmt issues
* Remove Drop implementation for network service
* Add first attempt at attestation proc. re-write
* Add version 2 of attestation processing
* Minor fixes
* Add validator pubkey cache
* Make get_indexed_attestation take a committee
* Link signature processing into new attn verification
* First working version
* Ensure pubkey cache is updated
* Add more metrics, slight optimizations
* Clone committee cache during attestation processing
* Update shuffling cache during block processing
* Remove old commented-out code
* Fix shuffling cache insert bug
* Used indexed attestation in fork choice
* Restructure attn processing, add metrics
* Add more detailed metrics
* Tidy, fix failing tests
* Fix failing tests, tidy
* Address reviewers suggestions
* Disable/delete two outdated tests
* Modification of validator for subscriptions
* Add slot signing to validator client
* Further progress on validation subscription
* Adds necessary validator subscription functionality
* Add new Pubkeys struct to signature_sets
* Refactor with functional approach
* Update beacon chain
* Clean up validator <-> beacon node http types
* Add aggregator status to ValidatorDuty
* Impl Clone for manual slot clock
* Fix minor errors
* Further progress validator client subscription
* Initial subscription and aggregation handling
* Remove decompressed member from pubkey bytes
* Progress to modifying val client for attestation aggregation
* First draft of validator client upgrade for aggregate attestations
* Add hashmap for indices lookup
* Add state cache, remove store cache
* Only build the head committee cache
* Removes lock on a network channel
* Partially implement beacon node subscription http api
* Correct compilation issues
* Change `get_attesting_indices` to use Vec
* Fix failing test
* Partial implementation of timer
* Adds timer, removes exit_future, http api to op pool
* Partial multiple aggregate attestation handling
* Permits bulk messages accross gossipsub network channel
* Correct compile issues
* Improve gosispsub messaging and correct rest api helpers
* Added global gossipsub subscriptions
* Update validator subscriptions data structs
* Tidy
* Re-structure validator subscriptions
* Initial handling of subscriptions
* Re-structure network service
* Add pubkey cache persistence file
* Add more comments
* Integrate persistence file into builder
* Add pubkey cache tests
* Add HashSetDelay and introduce into attestation service
* Handles validator subscriptions
* Add data_dir to beacon chain builder
* Remove Option in pubkey cache persistence file
* Ensure consistency between datadir/data_dir
* Fix failing network test
* Peer subnet discovery gets queued for future subscriptions
* Reorganise attestation service functions
* Initial wiring of attestation service
* First draft of attestation service timing logic
* Correct minor typos
* Tidy
* Fix todos
* Improve tests
* Add PeerInfo to connected peers mapping
* Fix compile error
* Fix compile error from merge
* Split up block processing metrics
* Tidy
* Refactor get_pubkey_from_state
* Remove commented-out code
* Rename state_cache -> checkpoint_cache
* Rename Checkpoint -> Snapshot
* Tidy, add comments
* Tidy up find_head function
* Change some checkpoint -> snapshot
* Add tests
* Expose max_len
* Remove dead code
* Tidy
* Fix bug
* Add sync-speed metric
* Add first attempt at VerifiableBlock
* Start integrating into beacon chain
* Integrate VerifiableBlock
* Rename VerifableBlock -> PartialBlockVerification
* Add start of typed methods
* Add progress
* Add further progress
* Rename structs
* Add full block verification to block_processing.rs
* Further beacon chain integration
* Update checks for gossip
* Add todo
* Start adding segement verification
* Add passing chain segement test
* Initial integration with batch sync
* Minor changes
* Tidy, add more error checking
* Start adding chain_segment tests
* Finish invalid signature tests
* Include single and gossip verified blocks in tests
* Add gossip verification tests
* Start adding docs
* Finish adding comments to block_processing.rs
* Rename block_processing.rs -> block_verification
* Start removing old block processing code
* Fixes beacon_chain compilation
* Fix project-wide compile errors
* Remove old code
* Correct code to pass all tests
* Fix bug with beacon proposer index
* Fix shim for BlockProcessingError
* Only process one epoch at a time
* Fix loop in chain segment processing
* Correct tests from master merge
* Add caching for state.eth1_data_votes
* Add BeaconChain::validator_pubkey
* Revert "Add caching for state.eth1_data_votes"
This reverts commit cd73dcd6434fb8d8e6bf30c5356355598ea7b78e.
Co-authored-by: Grant Wuerker <gwuerker@gmail.com>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
Co-authored-by: Michael Sproul <micsproul@gmail.com>
Co-authored-by: pawan <pawandhananjay@gmail.com>
Co-authored-by: Paul Hauner <paul@paulhauner.com>
2020-03-17 06:24:44 +00:00
|
|
|
use rest_types::ValidatorDutyBytes;
|
2019-12-06 05:44:03 +00:00
|
|
|
use std::convert::TryInto;
|
2019-11-25 04:48:24 +00:00
|
|
|
use std::sync::Arc;
|
v0.12 fork choice update (#1229)
* Incomplete scraps
* Add progress on new fork choice impl
* Further progress
* First complete compiling version
* Remove chain reference
* Add new lmd_ghost crate
* Start integrating into beacon chain
* Update `milagro_bls` to new release (#1183)
* Update milagro_bls to new release
Signed-off-by: Kirk Baird <baird.k@outlook.com>
* Tidy up fake cryptos
Signed-off-by: Kirk Baird <baird.k@outlook.com>
* move SecretHash to bls and put plaintext back
Signed-off-by: Kirk Baird <baird.k@outlook.com>
* Update state processing for v0.12
* Fix EF test runners for v0.12
* Fix some tests
* Fix broken attestation verification test
* More test fixes
* Rough beacon chain impl working
* Remove fork_choice_2
* Remove checkpoint manager
* Half finished ssz impl
* Add missed file
* Add persistence
* Tidy, fix some compile errors
* Remove RwLock from ProtoArrayForkChoice
* Fix store-based compile errors
* Add comments, tidy
* Move function out of ForkChoice struct
* Start testing
* More testing
* Fix compile error
* Tidy beacon_chain::fork_choice
* Queue attestations from the current slot
* Allow fork choice to handle prior-to-genesis start
* Improve error granularity
* Test attestation dequeuing
* Process attestations during block
* Store target root in fork choice
* Move fork choice verification into new crate
* Update tests
* Consensus updates for v0.12 (#1228)
* Update state processing for v0.12
* Fix EF test runners for v0.12
* Fix some tests
* Fix broken attestation verification test
* More test fixes
* Fix typo found in review
* Add `Block` struct to ProtoArray
* Start fixing get_ancestor
* Add rough progress on testing
* Get fork choice tests working
* Progress with testing
* Fix partialeq impl
* Move slot clock from fc_store
* Improve testing
* Add testing for best justified
* Add clone back to SystemTimeSlotClock
* Add balances test
* Start adding balances cache again
* Wire-in balances cache
* Improve tests
* Remove commented-out tests
* Remove beacon_chain::ForkChoice
* Rename crates
* Update wider codebase to new fork_choice layout
* Move advance_slot in test harness
* Tidy ForkChoice::update_time
* Fix verification tests
* Fix compile error with iter::once
* Fix fork choice tests
* Ensure block attestations are processed
* Fix failing beacon_chain tests
* Add first invalid block check
* Add finalized block check
* Progress with testing, new store builder
* Add fixes to get_ancestor
* Fix old genesis justification test
* Fix remaining fork choice tests
* Change root iteration method
* Move on_verified_block
* Remove unused method
* Start adding attestation verification tests
* Add invalid ffg target test
* Add target epoch test
* Add queued attestation test
* Remove old fork choice verification tests
* Tidy, add test
* Move fork choice lock drop
* Rename BeaconForkChoiceStore
* Add comments, tidy BeaconForkChoiceStore
* Update metrics, rename fork_choice_store.rs
* Remove genesis_block_root from ForkChoice
* Tidy
* Update fork_choice comments
* Tidy, add comments
* Tidy, simplify ForkChoice, fix compile issue
* Tidy, removed dead file
* Increase http request timeout
* Fix failing rest_api test
* Set HTTP timeout back to 5s
* Apply fix to get_ancestor
* Address Michael's comments
* Fix typo
* Revert "Fix broken attestation verification test"
This reverts commit 722cdc903b12611de27916a57eeecfa3224f2279.
Co-authored-by: Kirk Baird <baird.k@outlook.com>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
2020-06-17 01:10:22 +00:00
|
|
|
use std::time::{SystemTime, UNIX_EPOCH};
|
2019-11-25 04:48:24 +00:00
|
|
|
use types::{
|
2020-02-14 11:35:18 +00:00
|
|
|
test_utils::{
|
|
|
|
build_double_vote_attester_slashing, build_proposer_slashing,
|
|
|
|
generate_deterministic_keypair, AttesterSlashingTestTask, ProposerSlashingTestTask,
|
|
|
|
},
|
|
|
|
BeaconBlock, BeaconState, ChainSpec, Domain, Epoch, EthSpec, MinimalEthSpec, PublicKey,
|
2020-03-25 10:14:05 +00:00
|
|
|
RelativeEpoch, Signature, SignedAggregateAndProof, SignedBeaconBlock, SignedRoot, Slot,
|
2020-06-18 09:11:03 +00:00
|
|
|
SubnetId, Validator,
|
2019-11-25 04:48:24 +00:00
|
|
|
};
|
|
|
|
use version;
|
|
|
|
|
|
|
|
type E = MinimalEthSpec;
|
|
|
|
|
|
|
|
fn build_env() -> Environment<E> {
|
|
|
|
EnvironmentBuilder::minimal()
|
|
|
|
.null_logger()
|
|
|
|
.expect("should build env logger")
|
|
|
|
.single_thread_tokio_runtime()
|
|
|
|
.expect("should start tokio runtime")
|
|
|
|
.build()
|
|
|
|
.expect("environment should build")
|
|
|
|
}
|
|
|
|
|
Prepare for public testnet (#628)
* Update to spec v0.9.0
* Update to v0.9.1
* Bump spec tags for v0.9.1
* Formatting, fix CI failures
* Resolve accidental KeyPair merge conflict
* Document new BeaconState functions
* Add `validator` changes from `validator-to-rest`
* Add initial (failing) REST api tests
* Fix signature parsing
* Add more tests
* Refactor http router
* Add working tests for publish beacon block
* Add validator duties tests
* Move account_manager under `lighthouse` binary
* Unify logfile handling in `environment` crate.
* Fix incorrect cache drops in `advance_caches`
* Update fork choice for v0.9.1
* Add `deposit_contract` crate
* Add progress on validator onboarding
* Add unfinished attesation code
* Update account manager CLI
* Write eth1 data file as hex string
* Integrate ValidatorDirectory with validator_client
* Move ValidatorDirectory into validator_client
* Clean up some FIXMEs
* Add beacon_chain_sim
* Fix a few docs/logs
* Expand `beacon_chain_sim`
* Fix spec for `beacon_chain_sim
* More testing for api
* Start work on attestation endpoint
* Reject empty attestations
* Allow attestations to genesis block
* Add working tests for `rest_api` validator endpoint
* Remove grpc from beacon_node
* Start heavy refactor of validator client
- Block production is working
* Prune old validator client files
* Start works on attestation service
* Add attestation service to validator client
* Use full pubkey for validator directories
* Add validator duties post endpoint
* Use par_iter for keypair generation
* Use bulk duties request in validator client
* Add version http endpoint tests
* Add interop keys and startup wait
* Ensure a prompt exit
* Add duties pruning
* Fix compile error in beacon node tests
* Add github workflow
* Modify rust.yaml
* Modify gitlab actions
* Add to CI file
* Add sudo to CI npm install
* Move cargo fmt to own job in tests
* Fix cargo fmt in CI
* Add rustup update before cargo fmt
* Change name of CI job
* Make other CI jobs require cargo fmt
* Add CI badge
* Remove gitlab and travis files
* Add different http timeout for debug
* Update docker file, use makefile in CI
* Use make in the dockerfile, skip the test
* Use the makefile for debug GI test
* Update book
* Tidy grpc and misc things
* Apply discv5 fixes
* Address other minor issues
* Fix warnings
* Attempt fix for addr parsing
* Tidy validator config, CLIs
* Tidy comments
* Tidy signing, reduce ForkService duplication
* Fail if skipping too many slots
* Set default recent genesis time to 0
* Add custom http timeout to validator
* Fix compile bug in node_test_rig
* Remove old bootstrap flag from val CLI
* Update docs
* Tidy val client
* Change val client log levels
* Add comments, more validity checks
* Fix compile error, add comments
* Undo changes to eth2-libp2p/src
* Reduce duplication of keypair generation
* Add more logging for validator duties
* Fix beacon_chain_sim, nitpicks
* Fix compile error, minor nits
* Update to use v0.9.2 version of deposit contract
* Add efforts to automate eth1 testnet deployment
* Fix lcli testnet deployer
* Modify bn CLI to parse eth2_testnet_dir
* Progress with account_manager deposit tools
* Make account manager submit deposits
* Add password option for submitting deposits
* Allow custom deposit amount
* Add long names to lcli clap
* Add password option to lcli deploy command
* Fix minor bugs whilst testing
* Address Michael's comments
* Add refund-deposit-contract to lcli
* Use time instead of skip count for denying long skips
* Improve logging for eth1
* Fix bug with validator services exiting on error
* Drop the block cache after genesis
* Modify eth1 testnet config
* Improve eth1 logging
* Make validator wait until genesis time
* Fix bug in eth1 voting
* Add more logging to eth1 voting
* Handle errors in eth1 http module
* Set SECONDS_PER_DAY to sensible minimum
* Shorten delay before testnet start
* Ensure eth1 block is produced without any votes
* Improve eth1 logging
* Fix broken tests in eth1
* Tidy code in rest_api
* Fix failing test in deposit_contract
* Make CLI args more consistent
* Change validator/duties endpoint
* Add time-based skip slot limiting
* Add new error type missed in previous commit
* Add log when waiting for genesis
* Refactor beacon node CLI
* Remove unused dep
* Add lcli eth1-genesis command
* Fix bug in master merge
* Apply clippy lints to beacon node
* Add support for YamlConfig in Eth2TestnetDir
* Upgrade tesnet deposit contract version
* Remove unnecessary logging and correct formatting
* Add a hardcoded eth2 testnet config
* Ensure http server flag works. Overwrite configs with flags.
* Ensure boot nodes are loaded from testnet dir
* Fix account manager CLI bugs
* Fix bugs with beacon node cli
* Allow testnet dir without boot nodes
* Write genesis state as SSZ
* Remove ---/n from the start of testnet_dir files
* Set default libp2p address
* Tidy account manager CLI, add logging
* Add check to see if testnet dir exists
* Apply reviewers suggestions
* Add HeadTracker struct
* Add fork choice persistence
* Shorten slot time for simulator
* Add the /beacon/heads API endpoint
* Update hardcoded testnet
* Add tests for BeaconChain persistence + fix bugs
* Extend BeaconChain persistence testing
* Ensure chain is finalized b4 persistence tests
* Ensure boot_enr.yaml is include in binary
* Refactor beacon_chain_sim
* Move files about in beacon sim
* Update beacon_chain_sim
* Fix bug with deposit inclusion
* Increase log in genesis service, fix todo
* Tidy sim, fix broken rest_api tests
* Fix more broken tests
* Update testnet
* Fix broken rest api test
* Tidy account manager CLI
* Use tempdir for account manager
* Stop hardcoded testnet dir from creating dir
* Rename Eth2TestnetDir to Eth2TestnetConfig
* Change hardcoded -> hard_coded
* Tidy account manager
* Add log to account manager
* Tidy, ensure head tracker is loaded from disk
* Tidy beacon chain builder
* Tidy eth1_chain
* Adds log support for simulator
* Revert "Adds log support for simulator"
This reverts commit ec77c66a052350f551db145cf20f213823428dd3.
* Adds log support for simulator
* Tidy after self-review
* Change default log level
* Address Michael's delicious PR comments
* Fix off-by-one in tests
2019-12-03 04:28:57 +00:00
|
|
|
fn build_node<E: EthSpec>(env: &mut Environment<E>, config: ClientConfig) -> LocalBeaconNode<E> {
|
|
|
|
let context = env.core_context();
|
|
|
|
env.runtime()
|
|
|
|
.block_on(LocalBeaconNode::production(context, config))
|
|
|
|
.expect("should block until node created")
|
|
|
|
}
|
|
|
|
|
2019-11-25 04:48:24 +00:00
|
|
|
/// Returns the randao reveal for the given slot (assuming the given `beacon_chain` uses
|
|
|
|
/// deterministic keypairs).
|
|
|
|
fn get_randao_reveal<T: BeaconChainTypes>(
|
|
|
|
beacon_chain: Arc<BeaconChain<T>>,
|
|
|
|
slot: Slot,
|
|
|
|
spec: &ChainSpec,
|
|
|
|
) -> Signature {
|
2020-04-01 11:03:03 +00:00
|
|
|
let head = beacon_chain.head().expect("should get head");
|
|
|
|
let fork = head.beacon_state.fork;
|
|
|
|
let genesis_validators_root = head.beacon_state.genesis_validators_root;
|
2019-11-25 04:48:24 +00:00
|
|
|
let proposer_index = beacon_chain
|
|
|
|
.block_proposer(slot)
|
|
|
|
.expect("should get proposer index");
|
|
|
|
let keypair = generate_deterministic_keypair(proposer_index);
|
|
|
|
let epoch = slot.epoch(E::slots_per_epoch());
|
2020-04-01 11:03:03 +00:00
|
|
|
let domain = spec.get_domain(epoch, Domain::Randao, &fork, genesis_validators_root);
|
2020-02-10 23:19:36 +00:00
|
|
|
let message = epoch.signing_root(domain);
|
|
|
|
Signature::new(message.as_bytes(), &keypair.sk)
|
2019-11-25 04:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Signs the given block (assuming the given `beacon_chain` uses deterministic keypairs).
|
|
|
|
fn sign_block<T: BeaconChainTypes>(
|
|
|
|
beacon_chain: Arc<BeaconChain<T>>,
|
2020-02-10 23:19:36 +00:00
|
|
|
block: BeaconBlock<T::EthSpec>,
|
2019-11-25 04:48:24 +00:00
|
|
|
spec: &ChainSpec,
|
2020-02-10 23:19:36 +00:00
|
|
|
) -> SignedBeaconBlock<T::EthSpec> {
|
2020-04-01 11:03:03 +00:00
|
|
|
let head = beacon_chain.head().expect("should get head");
|
|
|
|
let fork = head.beacon_state.fork;
|
|
|
|
let genesis_validators_root = head.beacon_state.genesis_validators_root;
|
2019-11-25 04:48:24 +00:00
|
|
|
let proposer_index = beacon_chain
|
|
|
|
.block_proposer(block.slot)
|
|
|
|
.expect("should get proposer index");
|
|
|
|
let keypair = generate_deterministic_keypair(proposer_index);
|
2020-04-01 11:03:03 +00:00
|
|
|
block.sign(&keypair.sk, &fork, genesis_validators_root, spec)
|
2019-11-25 04:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn validator_produce_attestation() {
|
|
|
|
let mut env = build_env();
|
|
|
|
|
|
|
|
let spec = &E::default_spec();
|
|
|
|
|
Prepare for public testnet (#628)
* Update to spec v0.9.0
* Update to v0.9.1
* Bump spec tags for v0.9.1
* Formatting, fix CI failures
* Resolve accidental KeyPair merge conflict
* Document new BeaconState functions
* Add `validator` changes from `validator-to-rest`
* Add initial (failing) REST api tests
* Fix signature parsing
* Add more tests
* Refactor http router
* Add working tests for publish beacon block
* Add validator duties tests
* Move account_manager under `lighthouse` binary
* Unify logfile handling in `environment` crate.
* Fix incorrect cache drops in `advance_caches`
* Update fork choice for v0.9.1
* Add `deposit_contract` crate
* Add progress on validator onboarding
* Add unfinished attesation code
* Update account manager CLI
* Write eth1 data file as hex string
* Integrate ValidatorDirectory with validator_client
* Move ValidatorDirectory into validator_client
* Clean up some FIXMEs
* Add beacon_chain_sim
* Fix a few docs/logs
* Expand `beacon_chain_sim`
* Fix spec for `beacon_chain_sim
* More testing for api
* Start work on attestation endpoint
* Reject empty attestations
* Allow attestations to genesis block
* Add working tests for `rest_api` validator endpoint
* Remove grpc from beacon_node
* Start heavy refactor of validator client
- Block production is working
* Prune old validator client files
* Start works on attestation service
* Add attestation service to validator client
* Use full pubkey for validator directories
* Add validator duties post endpoint
* Use par_iter for keypair generation
* Use bulk duties request in validator client
* Add version http endpoint tests
* Add interop keys and startup wait
* Ensure a prompt exit
* Add duties pruning
* Fix compile error in beacon node tests
* Add github workflow
* Modify rust.yaml
* Modify gitlab actions
* Add to CI file
* Add sudo to CI npm install
* Move cargo fmt to own job in tests
* Fix cargo fmt in CI
* Add rustup update before cargo fmt
* Change name of CI job
* Make other CI jobs require cargo fmt
* Add CI badge
* Remove gitlab and travis files
* Add different http timeout for debug
* Update docker file, use makefile in CI
* Use make in the dockerfile, skip the test
* Use the makefile for debug GI test
* Update book
* Tidy grpc and misc things
* Apply discv5 fixes
* Address other minor issues
* Fix warnings
* Attempt fix for addr parsing
* Tidy validator config, CLIs
* Tidy comments
* Tidy signing, reduce ForkService duplication
* Fail if skipping too many slots
* Set default recent genesis time to 0
* Add custom http timeout to validator
* Fix compile bug in node_test_rig
* Remove old bootstrap flag from val CLI
* Update docs
* Tidy val client
* Change val client log levels
* Add comments, more validity checks
* Fix compile error, add comments
* Undo changes to eth2-libp2p/src
* Reduce duplication of keypair generation
* Add more logging for validator duties
* Fix beacon_chain_sim, nitpicks
* Fix compile error, minor nits
* Update to use v0.9.2 version of deposit contract
* Add efforts to automate eth1 testnet deployment
* Fix lcli testnet deployer
* Modify bn CLI to parse eth2_testnet_dir
* Progress with account_manager deposit tools
* Make account manager submit deposits
* Add password option for submitting deposits
* Allow custom deposit amount
* Add long names to lcli clap
* Add password option to lcli deploy command
* Fix minor bugs whilst testing
* Address Michael's comments
* Add refund-deposit-contract to lcli
* Use time instead of skip count for denying long skips
* Improve logging for eth1
* Fix bug with validator services exiting on error
* Drop the block cache after genesis
* Modify eth1 testnet config
* Improve eth1 logging
* Make validator wait until genesis time
* Fix bug in eth1 voting
* Add more logging to eth1 voting
* Handle errors in eth1 http module
* Set SECONDS_PER_DAY to sensible minimum
* Shorten delay before testnet start
* Ensure eth1 block is produced without any votes
* Improve eth1 logging
* Fix broken tests in eth1
* Tidy code in rest_api
* Fix failing test in deposit_contract
* Make CLI args more consistent
* Change validator/duties endpoint
* Add time-based skip slot limiting
* Add new error type missed in previous commit
* Add log when waiting for genesis
* Refactor beacon node CLI
* Remove unused dep
* Add lcli eth1-genesis command
* Fix bug in master merge
* Apply clippy lints to beacon node
* Add support for YamlConfig in Eth2TestnetDir
* Upgrade tesnet deposit contract version
* Remove unnecessary logging and correct formatting
* Add a hardcoded eth2 testnet config
* Ensure http server flag works. Overwrite configs with flags.
* Ensure boot nodes are loaded from testnet dir
* Fix account manager CLI bugs
* Fix bugs with beacon node cli
* Allow testnet dir without boot nodes
* Write genesis state as SSZ
* Remove ---/n from the start of testnet_dir files
* Set default libp2p address
* Tidy account manager CLI, add logging
* Add check to see if testnet dir exists
* Apply reviewers suggestions
* Add HeadTracker struct
* Add fork choice persistence
* Shorten slot time for simulator
* Add the /beacon/heads API endpoint
* Update hardcoded testnet
* Add tests for BeaconChain persistence + fix bugs
* Extend BeaconChain persistence testing
* Ensure chain is finalized b4 persistence tests
* Ensure boot_enr.yaml is include in binary
* Refactor beacon_chain_sim
* Move files about in beacon sim
* Update beacon_chain_sim
* Fix bug with deposit inclusion
* Increase log in genesis service, fix todo
* Tidy sim, fix broken rest_api tests
* Fix more broken tests
* Update testnet
* Fix broken rest api test
* Tidy account manager CLI
* Use tempdir for account manager
* Stop hardcoded testnet dir from creating dir
* Rename Eth2TestnetDir to Eth2TestnetConfig
* Change hardcoded -> hard_coded
* Tidy account manager
* Add log to account manager
* Tidy, ensure head tracker is loaded from disk
* Tidy beacon chain builder
* Tidy eth1_chain
* Adds log support for simulator
* Revert "Adds log support for simulator"
This reverts commit ec77c66a052350f551db145cf20f213823428dd3.
* Adds log support for simulator
* Tidy after self-review
* Change default log level
* Address Michael's delicious PR comments
* Fix off-by-one in tests
2019-12-03 04:28:57 +00:00
|
|
|
let node = build_node(&mut env, testing_client_config());
|
2019-11-25 04:48:24 +00:00
|
|
|
let remote_node = node.remote_node().expect("should produce remote node");
|
|
|
|
|
|
|
|
let beacon_chain = node
|
|
|
|
.client
|
|
|
|
.beacon_chain()
|
|
|
|
.expect("client should have beacon chain");
|
2020-04-08 06:46:37 +00:00
|
|
|
let genesis_validators_root = beacon_chain.genesis_validators_root;
|
2020-01-21 07:38:56 +00:00
|
|
|
let state = beacon_chain.head().expect("should get head").beacon_state;
|
2019-11-25 04:48:24 +00:00
|
|
|
|
2020-05-06 11:42:56 +00:00
|
|
|
// Find a validator that has duties in the current slot of the chain.
|
|
|
|
let mut validator_index = 0;
|
|
|
|
let duties = loop {
|
|
|
|
let duties = state
|
|
|
|
.get_attestation_duties(validator_index, RelativeEpoch::Current)
|
|
|
|
.expect("should have attestation duties cache")
|
|
|
|
.expect("should have attestation duties");
|
|
|
|
|
|
|
|
if duties.slot == node.client.beacon_chain().unwrap().slot().unwrap() {
|
|
|
|
break duties;
|
|
|
|
} else {
|
|
|
|
validator_index += 1
|
|
|
|
}
|
|
|
|
};
|
2019-11-25 04:48:24 +00:00
|
|
|
|
|
|
|
let mut attestation = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(
|
|
|
|
remote_node
|
|
|
|
.http
|
|
|
|
.validator()
|
|
|
|
.produce_attestation(duties.slot, duties.index),
|
|
|
|
)
|
|
|
|
.expect("should fetch attestation from http api");
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
attestation.data.index, duties.index,
|
|
|
|
"should have same index"
|
|
|
|
);
|
|
|
|
assert_eq!(attestation.data.slot, duties.slot, "should have same slot");
|
|
|
|
assert_eq!(
|
|
|
|
attestation.aggregation_bits.num_set_bits(),
|
|
|
|
0,
|
|
|
|
"should have empty aggregation bits"
|
|
|
|
);
|
|
|
|
|
|
|
|
let keypair = generate_deterministic_keypair(validator_index);
|
|
|
|
|
|
|
|
// Fetch the duties again, but via HTTP for authenticity.
|
|
|
|
let duties = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(remote_node.http.validator().get_duties(
|
|
|
|
attestation.data.slot.epoch(E::slots_per_epoch()),
|
|
|
|
&[keypair.pk.clone()],
|
|
|
|
))
|
|
|
|
.expect("should fetch duties from http api");
|
|
|
|
let duties = &duties[0];
|
2020-06-18 09:11:03 +00:00
|
|
|
let committee_count = duties
|
|
|
|
.committee_count_at_slot
|
|
|
|
.expect("should have committee count");
|
|
|
|
let subnet_id = SubnetId::compute_subnet::<E>(
|
|
|
|
attestation.data.slot,
|
|
|
|
attestation.data.index,
|
|
|
|
committee_count,
|
|
|
|
spec,
|
|
|
|
)
|
|
|
|
.unwrap();
|
2020-03-25 10:14:05 +00:00
|
|
|
// Try publishing the attestation without a signature or a committee bit set, ensure it is
|
|
|
|
// raises an error.
|
2020-05-06 11:42:56 +00:00
|
|
|
let publish_status = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(
|
|
|
|
remote_node
|
|
|
|
.http
|
|
|
|
.validator()
|
2020-06-18 09:11:03 +00:00
|
|
|
.publish_attestations(vec![(attestation.clone(), subnet_id)]),
|
2020-05-06 11:42:56 +00:00
|
|
|
)
|
|
|
|
.expect("should publish unsigned attestation");
|
2020-03-25 10:14:05 +00:00
|
|
|
assert!(
|
2020-05-06 11:42:56 +00:00
|
|
|
!publish_status.is_valid(),
|
|
|
|
"the unsigned published attestation should be invalid"
|
2020-03-25 10:14:05 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// Set the aggregation bit.
|
|
|
|
attestation
|
|
|
|
.aggregation_bits
|
|
|
|
.set(
|
|
|
|
duties
|
|
|
|
.attestation_committee_position
|
|
|
|
.expect("should have committee position"),
|
|
|
|
true,
|
|
|
|
)
|
|
|
|
.expect("should set attestation bit");
|
|
|
|
|
|
|
|
// Try publishing with an aggreagation bit set, but an invalid signature.
|
2019-11-25 04:48:24 +00:00
|
|
|
let publish_status = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(
|
|
|
|
remote_node
|
|
|
|
.http
|
|
|
|
.validator()
|
2020-06-18 09:11:03 +00:00
|
|
|
.publish_attestations(vec![(attestation.clone(), subnet_id)]),
|
2019-11-25 04:48:24 +00:00
|
|
|
)
|
2020-03-25 10:14:05 +00:00
|
|
|
.expect("should publish attestation with invalid signature");
|
2019-11-25 04:48:24 +00:00
|
|
|
assert!(
|
|
|
|
!publish_status.is_valid(),
|
|
|
|
"the unsigned published attestation should not be valid"
|
|
|
|
);
|
|
|
|
|
2020-03-25 10:14:05 +00:00
|
|
|
// Un-set the aggregation bit, so signing doesn't error.
|
|
|
|
attestation
|
|
|
|
.aggregation_bits
|
|
|
|
.set(
|
|
|
|
duties
|
|
|
|
.attestation_committee_position
|
|
|
|
.expect("should have committee position"),
|
|
|
|
false,
|
|
|
|
)
|
|
|
|
.expect("should un-set attestation bit");
|
|
|
|
|
2019-11-25 04:48:24 +00:00
|
|
|
attestation
|
|
|
|
.sign(
|
|
|
|
&keypair.sk,
|
|
|
|
duties
|
|
|
|
.attestation_committee_position
|
|
|
|
.expect("should have committee position"),
|
|
|
|
&state.fork,
|
2020-04-01 11:03:03 +00:00
|
|
|
state.genesis_validators_root,
|
2019-11-25 04:48:24 +00:00
|
|
|
spec,
|
|
|
|
)
|
|
|
|
.expect("should sign attestation");
|
|
|
|
|
|
|
|
// Try publishing the valid attestation.
|
|
|
|
let publish_status = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(
|
|
|
|
remote_node
|
|
|
|
.http
|
|
|
|
.validator()
|
2020-06-18 09:11:03 +00:00
|
|
|
.publish_attestations(vec![(attestation.clone(), subnet_id)]),
|
2019-11-25 04:48:24 +00:00
|
|
|
)
|
|
|
|
.expect("should publish attestation");
|
|
|
|
assert!(
|
|
|
|
publish_status.is_valid(),
|
|
|
|
"the signed published attestation should be valid"
|
2020-03-25 10:14:05 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// Try obtaining an aggregated attestation with a matching attestation data to the previous
|
|
|
|
// one.
|
|
|
|
let aggregated_attestation = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(
|
|
|
|
remote_node
|
|
|
|
.http
|
|
|
|
.validator()
|
|
|
|
.produce_aggregate_attestation(&attestation.data),
|
|
|
|
)
|
|
|
|
.expect("should fetch aggregated attestation from http api");
|
|
|
|
|
|
|
|
let signed_aggregate_and_proof = SignedAggregateAndProof::from_aggregate(
|
|
|
|
validator_index as u64,
|
|
|
|
aggregated_attestation,
|
2020-05-06 11:42:56 +00:00
|
|
|
None,
|
2020-03-25 10:14:05 +00:00
|
|
|
&keypair.sk,
|
|
|
|
&state.fork,
|
2020-04-08 06:46:37 +00:00
|
|
|
genesis_validators_root,
|
2020-03-25 10:14:05 +00:00
|
|
|
spec,
|
|
|
|
);
|
|
|
|
|
|
|
|
// Publish the signed aggregate.
|
|
|
|
let publish_status = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(
|
|
|
|
remote_node
|
|
|
|
.http
|
|
|
|
.validator()
|
|
|
|
.publish_aggregate_and_proof(vec![signed_aggregate_and_proof]),
|
|
|
|
)
|
|
|
|
.expect("should publish aggregate and proof");
|
|
|
|
assert!(
|
|
|
|
publish_status.is_valid(),
|
|
|
|
"the signed aggregate and proof should be valid"
|
2019-11-25 04:48:24 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn validator_duties() {
|
|
|
|
let mut env = build_env();
|
|
|
|
|
|
|
|
let spec = &E::default_spec();
|
|
|
|
|
Prepare for public testnet (#628)
* Update to spec v0.9.0
* Update to v0.9.1
* Bump spec tags for v0.9.1
* Formatting, fix CI failures
* Resolve accidental KeyPair merge conflict
* Document new BeaconState functions
* Add `validator` changes from `validator-to-rest`
* Add initial (failing) REST api tests
* Fix signature parsing
* Add more tests
* Refactor http router
* Add working tests for publish beacon block
* Add validator duties tests
* Move account_manager under `lighthouse` binary
* Unify logfile handling in `environment` crate.
* Fix incorrect cache drops in `advance_caches`
* Update fork choice for v0.9.1
* Add `deposit_contract` crate
* Add progress on validator onboarding
* Add unfinished attesation code
* Update account manager CLI
* Write eth1 data file as hex string
* Integrate ValidatorDirectory with validator_client
* Move ValidatorDirectory into validator_client
* Clean up some FIXMEs
* Add beacon_chain_sim
* Fix a few docs/logs
* Expand `beacon_chain_sim`
* Fix spec for `beacon_chain_sim
* More testing for api
* Start work on attestation endpoint
* Reject empty attestations
* Allow attestations to genesis block
* Add working tests for `rest_api` validator endpoint
* Remove grpc from beacon_node
* Start heavy refactor of validator client
- Block production is working
* Prune old validator client files
* Start works on attestation service
* Add attestation service to validator client
* Use full pubkey for validator directories
* Add validator duties post endpoint
* Use par_iter for keypair generation
* Use bulk duties request in validator client
* Add version http endpoint tests
* Add interop keys and startup wait
* Ensure a prompt exit
* Add duties pruning
* Fix compile error in beacon node tests
* Add github workflow
* Modify rust.yaml
* Modify gitlab actions
* Add to CI file
* Add sudo to CI npm install
* Move cargo fmt to own job in tests
* Fix cargo fmt in CI
* Add rustup update before cargo fmt
* Change name of CI job
* Make other CI jobs require cargo fmt
* Add CI badge
* Remove gitlab and travis files
* Add different http timeout for debug
* Update docker file, use makefile in CI
* Use make in the dockerfile, skip the test
* Use the makefile for debug GI test
* Update book
* Tidy grpc and misc things
* Apply discv5 fixes
* Address other minor issues
* Fix warnings
* Attempt fix for addr parsing
* Tidy validator config, CLIs
* Tidy comments
* Tidy signing, reduce ForkService duplication
* Fail if skipping too many slots
* Set default recent genesis time to 0
* Add custom http timeout to validator
* Fix compile bug in node_test_rig
* Remove old bootstrap flag from val CLI
* Update docs
* Tidy val client
* Change val client log levels
* Add comments, more validity checks
* Fix compile error, add comments
* Undo changes to eth2-libp2p/src
* Reduce duplication of keypair generation
* Add more logging for validator duties
* Fix beacon_chain_sim, nitpicks
* Fix compile error, minor nits
* Update to use v0.9.2 version of deposit contract
* Add efforts to automate eth1 testnet deployment
* Fix lcli testnet deployer
* Modify bn CLI to parse eth2_testnet_dir
* Progress with account_manager deposit tools
* Make account manager submit deposits
* Add password option for submitting deposits
* Allow custom deposit amount
* Add long names to lcli clap
* Add password option to lcli deploy command
* Fix minor bugs whilst testing
* Address Michael's comments
* Add refund-deposit-contract to lcli
* Use time instead of skip count for denying long skips
* Improve logging for eth1
* Fix bug with validator services exiting on error
* Drop the block cache after genesis
* Modify eth1 testnet config
* Improve eth1 logging
* Make validator wait until genesis time
* Fix bug in eth1 voting
* Add more logging to eth1 voting
* Handle errors in eth1 http module
* Set SECONDS_PER_DAY to sensible minimum
* Shorten delay before testnet start
* Ensure eth1 block is produced without any votes
* Improve eth1 logging
* Fix broken tests in eth1
* Tidy code in rest_api
* Fix failing test in deposit_contract
* Make CLI args more consistent
* Change validator/duties endpoint
* Add time-based skip slot limiting
* Add new error type missed in previous commit
* Add log when waiting for genesis
* Refactor beacon node CLI
* Remove unused dep
* Add lcli eth1-genesis command
* Fix bug in master merge
* Apply clippy lints to beacon node
* Add support for YamlConfig in Eth2TestnetDir
* Upgrade tesnet deposit contract version
* Remove unnecessary logging and correct formatting
* Add a hardcoded eth2 testnet config
* Ensure http server flag works. Overwrite configs with flags.
* Ensure boot nodes are loaded from testnet dir
* Fix account manager CLI bugs
* Fix bugs with beacon node cli
* Allow testnet dir without boot nodes
* Write genesis state as SSZ
* Remove ---/n from the start of testnet_dir files
* Set default libp2p address
* Tidy account manager CLI, add logging
* Add check to see if testnet dir exists
* Apply reviewers suggestions
* Add HeadTracker struct
* Add fork choice persistence
* Shorten slot time for simulator
* Add the /beacon/heads API endpoint
* Update hardcoded testnet
* Add tests for BeaconChain persistence + fix bugs
* Extend BeaconChain persistence testing
* Ensure chain is finalized b4 persistence tests
* Ensure boot_enr.yaml is include in binary
* Refactor beacon_chain_sim
* Move files about in beacon sim
* Update beacon_chain_sim
* Fix bug with deposit inclusion
* Increase log in genesis service, fix todo
* Tidy sim, fix broken rest_api tests
* Fix more broken tests
* Update testnet
* Fix broken rest api test
* Tidy account manager CLI
* Use tempdir for account manager
* Stop hardcoded testnet dir from creating dir
* Rename Eth2TestnetDir to Eth2TestnetConfig
* Change hardcoded -> hard_coded
* Tidy account manager
* Add log to account manager
* Tidy, ensure head tracker is loaded from disk
* Tidy beacon chain builder
* Tidy eth1_chain
* Adds log support for simulator
* Revert "Adds log support for simulator"
This reverts commit ec77c66a052350f551db145cf20f213823428dd3.
* Adds log support for simulator
* Tidy after self-review
* Change default log level
* Address Michael's delicious PR comments
* Fix off-by-one in tests
2019-12-03 04:28:57 +00:00
|
|
|
let node = build_node(&mut env, testing_client_config());
|
2019-11-25 04:48:24 +00:00
|
|
|
let remote_node = node.remote_node().expect("should produce remote node");
|
|
|
|
|
|
|
|
let beacon_chain = node
|
|
|
|
.client
|
|
|
|
.beacon_chain()
|
|
|
|
.expect("client should have beacon chain");
|
|
|
|
|
2019-11-27 07:37:09 +00:00
|
|
|
let mut epoch = Epoch::new(0);
|
2019-11-25 04:48:24 +00:00
|
|
|
|
|
|
|
let validators = beacon_chain
|
|
|
|
.head()
|
2020-01-06 06:30:37 +00:00
|
|
|
.expect("should get head")
|
2019-11-25 04:48:24 +00:00
|
|
|
.beacon_state
|
|
|
|
.validators
|
|
|
|
.iter()
|
2019-12-06 05:44:03 +00:00
|
|
|
.map(|v| (&v.pubkey).try_into().expect("pubkey should be valid"))
|
2019-11-25 04:48:24 +00:00
|
|
|
.collect::<Vec<_>>();
|
|
|
|
|
|
|
|
let duties = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(remote_node.http.validator().get_duties(epoch, &validators))
|
|
|
|
.expect("should fetch duties from http api");
|
|
|
|
|
2019-11-27 07:37:09 +00:00
|
|
|
// 1. Check at the current epoch.
|
|
|
|
check_duties(
|
|
|
|
duties,
|
|
|
|
epoch,
|
|
|
|
validators.clone(),
|
|
|
|
beacon_chain.clone(),
|
|
|
|
spec,
|
|
|
|
);
|
|
|
|
|
|
|
|
epoch += 4;
|
|
|
|
let duties = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(remote_node.http.validator().get_duties(epoch, &validators))
|
|
|
|
.expect("should fetch duties from http api");
|
|
|
|
|
|
|
|
// 2. Check with a long skip forward.
|
2019-11-25 04:48:24 +00:00
|
|
|
check_duties(duties, epoch, validators, beacon_chain, spec);
|
2019-11-27 07:37:09 +00:00
|
|
|
|
|
|
|
// TODO: test an epoch in the past. Blocked because the `LocalBeaconNode` cannot produce a
|
|
|
|
// chain, yet.
|
2019-11-25 04:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn check_duties<T: BeaconChainTypes>(
|
Initial work towards v0.2.0 (#924)
* Remove ping protocol
* Initial renaming of network services
* Correct rebasing relative to latest master
* Start updating types
* Adds HashMapDelay struct to utils
* Initial network restructure
* Network restructure. Adds new types for v0.2.0
* Removes build artefacts
* Shift validation to beacon chain
* Temporarily remove gossip validation
This is to be updated to match current optimisation efforts.
* Adds AggregateAndProof
* Begin rebuilding pubsub encoding/decoding
* Signature hacking
* Shift gossipsup decoding into eth2_libp2p
* Existing EF tests passing with fake_crypto
* Shifts block encoding/decoding into RPC
* Delete outdated API spec
* All release tests passing bar genesis state parsing
* Update and test YamlConfig
* Update to spec v0.10 compatible BLS
* Updates to BLS EF tests
* Add EF test for AggregateVerify
And delete unused hash2curve tests for uncompressed points
* Update EF tests to v0.10.1
* Use optional block root correctly in block proc
* Use genesis fork in deposit domain. All tests pass
* Fast aggregate verify test
* Update REST API docs
* Fix unused import
* Bump spec tags to v0.10.1
* Add `seconds_per_eth1_block` to chainspec
* Update to timestamp based eth1 voting scheme
* Return None from `get_votes_to_consider` if block cache is empty
* Handle overflows in `is_candidate_block`
* Revert to failing tests
* Fix eth1 data sets test
* Choose default vote according to spec
* Fix collect_valid_votes tests
* Fix `get_votes_to_consider` to choose all eligible blocks
* Uncomment winning_vote tests
* Add comments; remove unused code
* Reduce seconds_per_eth1_block for simulation
* Addressed review comments
* Add test for default vote case
* Fix logs
* Remove unused functions
* Meter default eth1 votes
* Fix comments
* Progress on attestation service
* Address review comments; remove unused dependency
* Initial work on removing libp2p lock
* Add LRU caches to store (rollup)
* Update attestation validation for DB changes (WIP)
* Initial version of should_forward_block
* Scaffold
* Progress on attestation validation
Also, consolidate prod+testing slot clocks so that they share much
of the same implementation and can both handle sub-slot time changes.
* Removes lock from libp2p service
* Completed network lock removal
* Finish(?) attestation processing
* Correct network termination future
* Add slot check to block check
* Correct fmt issues
* Remove Drop implementation for network service
* Add first attempt at attestation proc. re-write
* Add version 2 of attestation processing
* Minor fixes
* Add validator pubkey cache
* Make get_indexed_attestation take a committee
* Link signature processing into new attn verification
* First working version
* Ensure pubkey cache is updated
* Add more metrics, slight optimizations
* Clone committee cache during attestation processing
* Update shuffling cache during block processing
* Remove old commented-out code
* Fix shuffling cache insert bug
* Used indexed attestation in fork choice
* Restructure attn processing, add metrics
* Add more detailed metrics
* Tidy, fix failing tests
* Fix failing tests, tidy
* Address reviewers suggestions
* Disable/delete two outdated tests
* Modification of validator for subscriptions
* Add slot signing to validator client
* Further progress on validation subscription
* Adds necessary validator subscription functionality
* Add new Pubkeys struct to signature_sets
* Refactor with functional approach
* Update beacon chain
* Clean up validator <-> beacon node http types
* Add aggregator status to ValidatorDuty
* Impl Clone for manual slot clock
* Fix minor errors
* Further progress validator client subscription
* Initial subscription and aggregation handling
* Remove decompressed member from pubkey bytes
* Progress to modifying val client for attestation aggregation
* First draft of validator client upgrade for aggregate attestations
* Add hashmap for indices lookup
* Add state cache, remove store cache
* Only build the head committee cache
* Removes lock on a network channel
* Partially implement beacon node subscription http api
* Correct compilation issues
* Change `get_attesting_indices` to use Vec
* Fix failing test
* Partial implementation of timer
* Adds timer, removes exit_future, http api to op pool
* Partial multiple aggregate attestation handling
* Permits bulk messages accross gossipsub network channel
* Correct compile issues
* Improve gosispsub messaging and correct rest api helpers
* Added global gossipsub subscriptions
* Update validator subscriptions data structs
* Tidy
* Re-structure validator subscriptions
* Initial handling of subscriptions
* Re-structure network service
* Add pubkey cache persistence file
* Add more comments
* Integrate persistence file into builder
* Add pubkey cache tests
* Add HashSetDelay and introduce into attestation service
* Handles validator subscriptions
* Add data_dir to beacon chain builder
* Remove Option in pubkey cache persistence file
* Ensure consistency between datadir/data_dir
* Fix failing network test
* Peer subnet discovery gets queued for future subscriptions
* Reorganise attestation service functions
* Initial wiring of attestation service
* First draft of attestation service timing logic
* Correct minor typos
* Tidy
* Fix todos
* Improve tests
* Add PeerInfo to connected peers mapping
* Fix compile error
* Fix compile error from merge
* Split up block processing metrics
* Tidy
* Refactor get_pubkey_from_state
* Remove commented-out code
* Rename state_cache -> checkpoint_cache
* Rename Checkpoint -> Snapshot
* Tidy, add comments
* Tidy up find_head function
* Change some checkpoint -> snapshot
* Add tests
* Expose max_len
* Remove dead code
* Tidy
* Fix bug
* Add sync-speed metric
* Add first attempt at VerifiableBlock
* Start integrating into beacon chain
* Integrate VerifiableBlock
* Rename VerifableBlock -> PartialBlockVerification
* Add start of typed methods
* Add progress
* Add further progress
* Rename structs
* Add full block verification to block_processing.rs
* Further beacon chain integration
* Update checks for gossip
* Add todo
* Start adding segement verification
* Add passing chain segement test
* Initial integration with batch sync
* Minor changes
* Tidy, add more error checking
* Start adding chain_segment tests
* Finish invalid signature tests
* Include single and gossip verified blocks in tests
* Add gossip verification tests
* Start adding docs
* Finish adding comments to block_processing.rs
* Rename block_processing.rs -> block_verification
* Start removing old block processing code
* Fixes beacon_chain compilation
* Fix project-wide compile errors
* Remove old code
* Correct code to pass all tests
* Fix bug with beacon proposer index
* Fix shim for BlockProcessingError
* Only process one epoch at a time
* Fix loop in chain segment processing
* Correct tests from master merge
* Add caching for state.eth1_data_votes
* Add BeaconChain::validator_pubkey
* Revert "Add caching for state.eth1_data_votes"
This reverts commit cd73dcd6434fb8d8e6bf30c5356355598ea7b78e.
Co-authored-by: Grant Wuerker <gwuerker@gmail.com>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
Co-authored-by: Michael Sproul <micsproul@gmail.com>
Co-authored-by: pawan <pawandhananjay@gmail.com>
Co-authored-by: Paul Hauner <paul@paulhauner.com>
2020-03-17 06:24:44 +00:00
|
|
|
duties: Vec<ValidatorDutyBytes>,
|
2019-11-25 04:48:24 +00:00
|
|
|
epoch: Epoch,
|
|
|
|
validators: Vec<PublicKey>,
|
|
|
|
beacon_chain: Arc<BeaconChain<T>>,
|
|
|
|
spec: &ChainSpec,
|
|
|
|
) {
|
|
|
|
assert_eq!(
|
|
|
|
validators.len(),
|
|
|
|
duties.len(),
|
|
|
|
"there should be a duty for each validator"
|
|
|
|
);
|
|
|
|
|
2020-02-04 01:43:04 +00:00
|
|
|
let mut state = beacon_chain
|
2020-03-04 06:10:22 +00:00
|
|
|
.state_at_slot(
|
|
|
|
epoch.start_slot(T::EthSpec::slots_per_epoch()),
|
|
|
|
StateSkipConfig::WithStateRoots,
|
|
|
|
)
|
2019-11-27 07:37:09 +00:00
|
|
|
.expect("should get state at slot");
|
2019-11-25 04:48:24 +00:00
|
|
|
|
2020-02-04 01:43:04 +00:00
|
|
|
state.build_all_caches(spec).expect("should build caches");
|
|
|
|
|
2019-11-25 04:48:24 +00:00
|
|
|
validators
|
|
|
|
.iter()
|
|
|
|
.zip(duties.iter())
|
|
|
|
.for_each(|(validator, duty)| {
|
2019-12-06 05:44:03 +00:00
|
|
|
assert_eq!(
|
|
|
|
*validator,
|
|
|
|
(&duty.validator_pubkey)
|
|
|
|
.try_into()
|
|
|
|
.expect("should be valid pubkey"),
|
|
|
|
"pubkey should match"
|
|
|
|
);
|
2019-11-25 04:48:24 +00:00
|
|
|
|
|
|
|
let validator_index = state
|
2019-12-06 05:44:03 +00:00
|
|
|
.get_validator_index(&validator.clone().into())
|
2019-11-25 04:48:24 +00:00
|
|
|
.expect("should have pubkey cache")
|
|
|
|
.expect("pubkey should exist");
|
|
|
|
|
|
|
|
let attestation_duty = state
|
|
|
|
.get_attestation_duties(validator_index, RelativeEpoch::Current)
|
|
|
|
.expect("should have attestation duties cache")
|
|
|
|
.expect("should have attestation duties");
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
Some(attestation_duty.slot),
|
|
|
|
duty.attestation_slot,
|
|
|
|
"attestation slot should match"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
Some(attestation_duty.index),
|
|
|
|
duty.attestation_committee_index,
|
|
|
|
"attestation index should match"
|
|
|
|
);
|
|
|
|
|
2019-12-04 23:56:37 +00:00
|
|
|
if !duty.block_proposal_slots.is_empty() {
|
|
|
|
for slot in &duty.block_proposal_slots {
|
|
|
|
let expected_proposer = state
|
|
|
|
.get_beacon_proposer_index(*slot, spec)
|
|
|
|
.expect("should know proposer");
|
|
|
|
assert_eq!(
|
|
|
|
expected_proposer, validator_index,
|
|
|
|
"should get correct proposal slot"
|
|
|
|
);
|
|
|
|
}
|
2019-11-25 04:48:24 +00:00
|
|
|
} else {
|
|
|
|
epoch.slot_iter(E::slots_per_epoch()).for_each(|slot| {
|
|
|
|
let slot_proposer = state
|
|
|
|
.get_beacon_proposer_index(slot, spec)
|
|
|
|
.expect("should know proposer");
|
2020-05-13 07:05:12 +00:00
|
|
|
assert_ne!(
|
|
|
|
slot_proposer, validator_index,
|
2019-11-25 04:48:24 +00:00
|
|
|
"validator should not have proposal slot in this epoch"
|
|
|
|
)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
});
|
2019-12-04 23:56:37 +00:00
|
|
|
|
|
|
|
// Validator duties should include a proposer for every slot of the epoch.
|
|
|
|
let mut all_proposer_slots: Vec<Slot> = duties
|
|
|
|
.iter()
|
|
|
|
.flat_map(|duty| duty.block_proposal_slots.clone())
|
|
|
|
.collect();
|
|
|
|
all_proposer_slots.sort();
|
|
|
|
|
|
|
|
let all_slots: Vec<Slot> = epoch.slot_iter(E::slots_per_epoch()).collect();
|
|
|
|
assert_eq!(all_proposer_slots, all_slots);
|
2019-11-25 04:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn validator_block_post() {
|
|
|
|
let mut env = build_env();
|
|
|
|
|
|
|
|
let spec = &E::default_spec();
|
|
|
|
|
v0.12 fork choice update (#1229)
* Incomplete scraps
* Add progress on new fork choice impl
* Further progress
* First complete compiling version
* Remove chain reference
* Add new lmd_ghost crate
* Start integrating into beacon chain
* Update `milagro_bls` to new release (#1183)
* Update milagro_bls to new release
Signed-off-by: Kirk Baird <baird.k@outlook.com>
* Tidy up fake cryptos
Signed-off-by: Kirk Baird <baird.k@outlook.com>
* move SecretHash to bls and put plaintext back
Signed-off-by: Kirk Baird <baird.k@outlook.com>
* Update state processing for v0.12
* Fix EF test runners for v0.12
* Fix some tests
* Fix broken attestation verification test
* More test fixes
* Rough beacon chain impl working
* Remove fork_choice_2
* Remove checkpoint manager
* Half finished ssz impl
* Add missed file
* Add persistence
* Tidy, fix some compile errors
* Remove RwLock from ProtoArrayForkChoice
* Fix store-based compile errors
* Add comments, tidy
* Move function out of ForkChoice struct
* Start testing
* More testing
* Fix compile error
* Tidy beacon_chain::fork_choice
* Queue attestations from the current slot
* Allow fork choice to handle prior-to-genesis start
* Improve error granularity
* Test attestation dequeuing
* Process attestations during block
* Store target root in fork choice
* Move fork choice verification into new crate
* Update tests
* Consensus updates for v0.12 (#1228)
* Update state processing for v0.12
* Fix EF test runners for v0.12
* Fix some tests
* Fix broken attestation verification test
* More test fixes
* Fix typo found in review
* Add `Block` struct to ProtoArray
* Start fixing get_ancestor
* Add rough progress on testing
* Get fork choice tests working
* Progress with testing
* Fix partialeq impl
* Move slot clock from fc_store
* Improve testing
* Add testing for best justified
* Add clone back to SystemTimeSlotClock
* Add balances test
* Start adding balances cache again
* Wire-in balances cache
* Improve tests
* Remove commented-out tests
* Remove beacon_chain::ForkChoice
* Rename crates
* Update wider codebase to new fork_choice layout
* Move advance_slot in test harness
* Tidy ForkChoice::update_time
* Fix verification tests
* Fix compile error with iter::once
* Fix fork choice tests
* Ensure block attestations are processed
* Fix failing beacon_chain tests
* Add first invalid block check
* Add finalized block check
* Progress with testing, new store builder
* Add fixes to get_ancestor
* Fix old genesis justification test
* Fix remaining fork choice tests
* Change root iteration method
* Move on_verified_block
* Remove unused method
* Start adding attestation verification tests
* Add invalid ffg target test
* Add target epoch test
* Add queued attestation test
* Remove old fork choice verification tests
* Tidy, add test
* Move fork choice lock drop
* Rename BeaconForkChoiceStore
* Add comments, tidy BeaconForkChoiceStore
* Update metrics, rename fork_choice_store.rs
* Remove genesis_block_root from ForkChoice
* Tidy
* Update fork_choice comments
* Tidy, add comments
* Tidy, simplify ForkChoice, fix compile issue
* Tidy, removed dead file
* Increase http request timeout
* Fix failing rest_api test
* Set HTTP timeout back to 5s
* Apply fix to get_ancestor
* Address Michael's comments
* Fix typo
* Revert "Fix broken attestation verification test"
This reverts commit 722cdc903b12611de27916a57eeecfa3224f2279.
Co-authored-by: Kirk Baird <baird.k@outlook.com>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
2020-06-17 01:10:22 +00:00
|
|
|
let two_slots_secs = (spec.milliseconds_per_slot / 1_000) * 2;
|
|
|
|
|
2019-11-25 04:48:24 +00:00
|
|
|
let mut config = testing_client_config();
|
|
|
|
config.genesis = ClientGenesis::Interop {
|
|
|
|
validator_count: 8,
|
v0.12 fork choice update (#1229)
* Incomplete scraps
* Add progress on new fork choice impl
* Further progress
* First complete compiling version
* Remove chain reference
* Add new lmd_ghost crate
* Start integrating into beacon chain
* Update `milagro_bls` to new release (#1183)
* Update milagro_bls to new release
Signed-off-by: Kirk Baird <baird.k@outlook.com>
* Tidy up fake cryptos
Signed-off-by: Kirk Baird <baird.k@outlook.com>
* move SecretHash to bls and put plaintext back
Signed-off-by: Kirk Baird <baird.k@outlook.com>
* Update state processing for v0.12
* Fix EF test runners for v0.12
* Fix some tests
* Fix broken attestation verification test
* More test fixes
* Rough beacon chain impl working
* Remove fork_choice_2
* Remove checkpoint manager
* Half finished ssz impl
* Add missed file
* Add persistence
* Tidy, fix some compile errors
* Remove RwLock from ProtoArrayForkChoice
* Fix store-based compile errors
* Add comments, tidy
* Move function out of ForkChoice struct
* Start testing
* More testing
* Fix compile error
* Tidy beacon_chain::fork_choice
* Queue attestations from the current slot
* Allow fork choice to handle prior-to-genesis start
* Improve error granularity
* Test attestation dequeuing
* Process attestations during block
* Store target root in fork choice
* Move fork choice verification into new crate
* Update tests
* Consensus updates for v0.12 (#1228)
* Update state processing for v0.12
* Fix EF test runners for v0.12
* Fix some tests
* Fix broken attestation verification test
* More test fixes
* Fix typo found in review
* Add `Block` struct to ProtoArray
* Start fixing get_ancestor
* Add rough progress on testing
* Get fork choice tests working
* Progress with testing
* Fix partialeq impl
* Move slot clock from fc_store
* Improve testing
* Add testing for best justified
* Add clone back to SystemTimeSlotClock
* Add balances test
* Start adding balances cache again
* Wire-in balances cache
* Improve tests
* Remove commented-out tests
* Remove beacon_chain::ForkChoice
* Rename crates
* Update wider codebase to new fork_choice layout
* Move advance_slot in test harness
* Tidy ForkChoice::update_time
* Fix verification tests
* Fix compile error with iter::once
* Fix fork choice tests
* Ensure block attestations are processed
* Fix failing beacon_chain tests
* Add first invalid block check
* Add finalized block check
* Progress with testing, new store builder
* Add fixes to get_ancestor
* Fix old genesis justification test
* Fix remaining fork choice tests
* Change root iteration method
* Move on_verified_block
* Remove unused method
* Start adding attestation verification tests
* Add invalid ffg target test
* Add target epoch test
* Add queued attestation test
* Remove old fork choice verification tests
* Tidy, add test
* Move fork choice lock drop
* Rename BeaconForkChoiceStore
* Add comments, tidy BeaconForkChoiceStore
* Update metrics, rename fork_choice_store.rs
* Remove genesis_block_root from ForkChoice
* Tidy
* Update fork_choice comments
* Tidy, add comments
* Tidy, simplify ForkChoice, fix compile issue
* Tidy, removed dead file
* Increase http request timeout
* Fix failing rest_api test
* Set HTTP timeout back to 5s
* Apply fix to get_ancestor
* Address Michael's comments
* Fix typo
* Revert "Fix broken attestation verification test"
This reverts commit 722cdc903b12611de27916a57eeecfa3224f2279.
Co-authored-by: Kirk Baird <baird.k@outlook.com>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
2020-06-17 01:10:22 +00:00
|
|
|
genesis_time: SystemTime::now()
|
|
|
|
.duration_since(UNIX_EPOCH)
|
|
|
|
.unwrap()
|
|
|
|
.as_secs()
|
|
|
|
- two_slots_secs,
|
2019-11-25 04:48:24 +00:00
|
|
|
};
|
|
|
|
|
Prepare for public testnet (#628)
* Update to spec v0.9.0
* Update to v0.9.1
* Bump spec tags for v0.9.1
* Formatting, fix CI failures
* Resolve accidental KeyPair merge conflict
* Document new BeaconState functions
* Add `validator` changes from `validator-to-rest`
* Add initial (failing) REST api tests
* Fix signature parsing
* Add more tests
* Refactor http router
* Add working tests for publish beacon block
* Add validator duties tests
* Move account_manager under `lighthouse` binary
* Unify logfile handling in `environment` crate.
* Fix incorrect cache drops in `advance_caches`
* Update fork choice for v0.9.1
* Add `deposit_contract` crate
* Add progress on validator onboarding
* Add unfinished attesation code
* Update account manager CLI
* Write eth1 data file as hex string
* Integrate ValidatorDirectory with validator_client
* Move ValidatorDirectory into validator_client
* Clean up some FIXMEs
* Add beacon_chain_sim
* Fix a few docs/logs
* Expand `beacon_chain_sim`
* Fix spec for `beacon_chain_sim
* More testing for api
* Start work on attestation endpoint
* Reject empty attestations
* Allow attestations to genesis block
* Add working tests for `rest_api` validator endpoint
* Remove grpc from beacon_node
* Start heavy refactor of validator client
- Block production is working
* Prune old validator client files
* Start works on attestation service
* Add attestation service to validator client
* Use full pubkey for validator directories
* Add validator duties post endpoint
* Use par_iter for keypair generation
* Use bulk duties request in validator client
* Add version http endpoint tests
* Add interop keys and startup wait
* Ensure a prompt exit
* Add duties pruning
* Fix compile error in beacon node tests
* Add github workflow
* Modify rust.yaml
* Modify gitlab actions
* Add to CI file
* Add sudo to CI npm install
* Move cargo fmt to own job in tests
* Fix cargo fmt in CI
* Add rustup update before cargo fmt
* Change name of CI job
* Make other CI jobs require cargo fmt
* Add CI badge
* Remove gitlab and travis files
* Add different http timeout for debug
* Update docker file, use makefile in CI
* Use make in the dockerfile, skip the test
* Use the makefile for debug GI test
* Update book
* Tidy grpc and misc things
* Apply discv5 fixes
* Address other minor issues
* Fix warnings
* Attempt fix for addr parsing
* Tidy validator config, CLIs
* Tidy comments
* Tidy signing, reduce ForkService duplication
* Fail if skipping too many slots
* Set default recent genesis time to 0
* Add custom http timeout to validator
* Fix compile bug in node_test_rig
* Remove old bootstrap flag from val CLI
* Update docs
* Tidy val client
* Change val client log levels
* Add comments, more validity checks
* Fix compile error, add comments
* Undo changes to eth2-libp2p/src
* Reduce duplication of keypair generation
* Add more logging for validator duties
* Fix beacon_chain_sim, nitpicks
* Fix compile error, minor nits
* Update to use v0.9.2 version of deposit contract
* Add efforts to automate eth1 testnet deployment
* Fix lcli testnet deployer
* Modify bn CLI to parse eth2_testnet_dir
* Progress with account_manager deposit tools
* Make account manager submit deposits
* Add password option for submitting deposits
* Allow custom deposit amount
* Add long names to lcli clap
* Add password option to lcli deploy command
* Fix minor bugs whilst testing
* Address Michael's comments
* Add refund-deposit-contract to lcli
* Use time instead of skip count for denying long skips
* Improve logging for eth1
* Fix bug with validator services exiting on error
* Drop the block cache after genesis
* Modify eth1 testnet config
* Improve eth1 logging
* Make validator wait until genesis time
* Fix bug in eth1 voting
* Add more logging to eth1 voting
* Handle errors in eth1 http module
* Set SECONDS_PER_DAY to sensible minimum
* Shorten delay before testnet start
* Ensure eth1 block is produced without any votes
* Improve eth1 logging
* Fix broken tests in eth1
* Tidy code in rest_api
* Fix failing test in deposit_contract
* Make CLI args more consistent
* Change validator/duties endpoint
* Add time-based skip slot limiting
* Add new error type missed in previous commit
* Add log when waiting for genesis
* Refactor beacon node CLI
* Remove unused dep
* Add lcli eth1-genesis command
* Fix bug in master merge
* Apply clippy lints to beacon node
* Add support for YamlConfig in Eth2TestnetDir
* Upgrade tesnet deposit contract version
* Remove unnecessary logging and correct formatting
* Add a hardcoded eth2 testnet config
* Ensure http server flag works. Overwrite configs with flags.
* Ensure boot nodes are loaded from testnet dir
* Fix account manager CLI bugs
* Fix bugs with beacon node cli
* Allow testnet dir without boot nodes
* Write genesis state as SSZ
* Remove ---/n from the start of testnet_dir files
* Set default libp2p address
* Tidy account manager CLI, add logging
* Add check to see if testnet dir exists
* Apply reviewers suggestions
* Add HeadTracker struct
* Add fork choice persistence
* Shorten slot time for simulator
* Add the /beacon/heads API endpoint
* Update hardcoded testnet
* Add tests for BeaconChain persistence + fix bugs
* Extend BeaconChain persistence testing
* Ensure chain is finalized b4 persistence tests
* Ensure boot_enr.yaml is include in binary
* Refactor beacon_chain_sim
* Move files about in beacon sim
* Update beacon_chain_sim
* Fix bug with deposit inclusion
* Increase log in genesis service, fix todo
* Tidy sim, fix broken rest_api tests
* Fix more broken tests
* Update testnet
* Fix broken rest api test
* Tidy account manager CLI
* Use tempdir for account manager
* Stop hardcoded testnet dir from creating dir
* Rename Eth2TestnetDir to Eth2TestnetConfig
* Change hardcoded -> hard_coded
* Tidy account manager
* Add log to account manager
* Tidy, ensure head tracker is loaded from disk
* Tidy beacon chain builder
* Tidy eth1_chain
* Adds log support for simulator
* Revert "Adds log support for simulator"
This reverts commit ec77c66a052350f551db145cf20f213823428dd3.
* Adds log support for simulator
* Tidy after self-review
* Change default log level
* Address Michael's delicious PR comments
* Fix off-by-one in tests
2019-12-03 04:28:57 +00:00
|
|
|
let node = build_node(&mut env, config);
|
2019-11-25 04:48:24 +00:00
|
|
|
let remote_node = node.remote_node().expect("should produce remote node");
|
|
|
|
|
|
|
|
let beacon_chain = node
|
|
|
|
.client
|
|
|
|
.beacon_chain()
|
|
|
|
.expect("client should have beacon chain");
|
|
|
|
|
|
|
|
let slot = Slot::new(1);
|
|
|
|
let randao_reveal = get_randao_reveal(beacon_chain.clone(), slot, spec);
|
|
|
|
|
2020-02-10 23:19:36 +00:00
|
|
|
let block = env
|
2019-11-25 04:48:24 +00:00
|
|
|
.runtime()
|
|
|
|
.block_on(
|
|
|
|
remote_node
|
|
|
|
.http
|
|
|
|
.validator()
|
2020-01-21 07:38:56 +00:00
|
|
|
.produce_block(slot, randao_reveal),
|
2019-11-25 04:48:24 +00:00
|
|
|
)
|
|
|
|
.expect("should fetch block from http api");
|
|
|
|
|
|
|
|
// Try publishing the block without a signature, ensure it is flagged as invalid.
|
2020-02-10 23:19:36 +00:00
|
|
|
let empty_sig_block = SignedBeaconBlock {
|
|
|
|
message: block.clone(),
|
|
|
|
signature: Signature::empty_signature(),
|
|
|
|
};
|
2019-11-25 04:48:24 +00:00
|
|
|
let publish_status = env
|
|
|
|
.runtime()
|
2020-02-10 23:19:36 +00:00
|
|
|
.block_on(remote_node.http.validator().publish_block(empty_sig_block))
|
2019-11-25 04:48:24 +00:00
|
|
|
.expect("should publish block");
|
2019-11-26 20:29:51 +00:00
|
|
|
if cfg!(not(feature = "fake_crypto")) {
|
|
|
|
assert!(
|
|
|
|
!publish_status.is_valid(),
|
|
|
|
"the unsigned published block should not be valid"
|
|
|
|
);
|
|
|
|
}
|
2019-11-25 04:48:24 +00:00
|
|
|
|
2020-02-10 23:19:36 +00:00
|
|
|
let signed_block = sign_block(beacon_chain.clone(), block, spec);
|
|
|
|
let block_root = signed_block.canonical_root();
|
2019-11-25 04:48:24 +00:00
|
|
|
|
|
|
|
let publish_status = env
|
|
|
|
.runtime()
|
2020-02-10 23:19:36 +00:00
|
|
|
.block_on(remote_node.http.validator().publish_block(signed_block))
|
2019-11-25 04:48:24 +00:00
|
|
|
.expect("should publish block");
|
2019-11-26 20:29:51 +00:00
|
|
|
|
|
|
|
if cfg!(not(feature = "fake_crypto")) {
|
|
|
|
assert_eq!(
|
|
|
|
publish_status,
|
|
|
|
PublishStatus::Valid,
|
|
|
|
"the signed published block should be valid"
|
|
|
|
);
|
|
|
|
}
|
2019-11-25 04:48:24 +00:00
|
|
|
|
|
|
|
let head = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(remote_node.http.beacon().get_head())
|
|
|
|
.expect("should get head");
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
head.block_root, block_root,
|
|
|
|
"the published block should become the head block"
|
|
|
|
);
|
2019-12-19 00:45:28 +00:00
|
|
|
|
|
|
|
// Note: this heads check is not super useful for this test, however it is include so it get
|
|
|
|
// _some_ testing. If you remove this call, make sure it's tested somewhere else.
|
|
|
|
let heads = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(remote_node.http.beacon().get_heads())
|
|
|
|
.expect("should get heads");
|
|
|
|
|
|
|
|
assert_eq!(heads.len(), 1, "there should be only one head");
|
|
|
|
assert_eq!(
|
|
|
|
heads,
|
|
|
|
vec![HeadBeaconBlock {
|
|
|
|
beacon_block_root: head.block_root,
|
|
|
|
beacon_block_slot: head.slot,
|
|
|
|
}],
|
|
|
|
"there should be only one head"
|
|
|
|
);
|
2019-11-25 04:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn validator_block_get() {
|
|
|
|
let mut env = build_env();
|
|
|
|
|
|
|
|
let spec = &E::default_spec();
|
|
|
|
|
Prepare for public testnet (#628)
* Update to spec v0.9.0
* Update to v0.9.1
* Bump spec tags for v0.9.1
* Formatting, fix CI failures
* Resolve accidental KeyPair merge conflict
* Document new BeaconState functions
* Add `validator` changes from `validator-to-rest`
* Add initial (failing) REST api tests
* Fix signature parsing
* Add more tests
* Refactor http router
* Add working tests for publish beacon block
* Add validator duties tests
* Move account_manager under `lighthouse` binary
* Unify logfile handling in `environment` crate.
* Fix incorrect cache drops in `advance_caches`
* Update fork choice for v0.9.1
* Add `deposit_contract` crate
* Add progress on validator onboarding
* Add unfinished attesation code
* Update account manager CLI
* Write eth1 data file as hex string
* Integrate ValidatorDirectory with validator_client
* Move ValidatorDirectory into validator_client
* Clean up some FIXMEs
* Add beacon_chain_sim
* Fix a few docs/logs
* Expand `beacon_chain_sim`
* Fix spec for `beacon_chain_sim
* More testing for api
* Start work on attestation endpoint
* Reject empty attestations
* Allow attestations to genesis block
* Add working tests for `rest_api` validator endpoint
* Remove grpc from beacon_node
* Start heavy refactor of validator client
- Block production is working
* Prune old validator client files
* Start works on attestation service
* Add attestation service to validator client
* Use full pubkey for validator directories
* Add validator duties post endpoint
* Use par_iter for keypair generation
* Use bulk duties request in validator client
* Add version http endpoint tests
* Add interop keys and startup wait
* Ensure a prompt exit
* Add duties pruning
* Fix compile error in beacon node tests
* Add github workflow
* Modify rust.yaml
* Modify gitlab actions
* Add to CI file
* Add sudo to CI npm install
* Move cargo fmt to own job in tests
* Fix cargo fmt in CI
* Add rustup update before cargo fmt
* Change name of CI job
* Make other CI jobs require cargo fmt
* Add CI badge
* Remove gitlab and travis files
* Add different http timeout for debug
* Update docker file, use makefile in CI
* Use make in the dockerfile, skip the test
* Use the makefile for debug GI test
* Update book
* Tidy grpc and misc things
* Apply discv5 fixes
* Address other minor issues
* Fix warnings
* Attempt fix for addr parsing
* Tidy validator config, CLIs
* Tidy comments
* Tidy signing, reduce ForkService duplication
* Fail if skipping too many slots
* Set default recent genesis time to 0
* Add custom http timeout to validator
* Fix compile bug in node_test_rig
* Remove old bootstrap flag from val CLI
* Update docs
* Tidy val client
* Change val client log levels
* Add comments, more validity checks
* Fix compile error, add comments
* Undo changes to eth2-libp2p/src
* Reduce duplication of keypair generation
* Add more logging for validator duties
* Fix beacon_chain_sim, nitpicks
* Fix compile error, minor nits
* Update to use v0.9.2 version of deposit contract
* Add efforts to automate eth1 testnet deployment
* Fix lcli testnet deployer
* Modify bn CLI to parse eth2_testnet_dir
* Progress with account_manager deposit tools
* Make account manager submit deposits
* Add password option for submitting deposits
* Allow custom deposit amount
* Add long names to lcli clap
* Add password option to lcli deploy command
* Fix minor bugs whilst testing
* Address Michael's comments
* Add refund-deposit-contract to lcli
* Use time instead of skip count for denying long skips
* Improve logging for eth1
* Fix bug with validator services exiting on error
* Drop the block cache after genesis
* Modify eth1 testnet config
* Improve eth1 logging
* Make validator wait until genesis time
* Fix bug in eth1 voting
* Add more logging to eth1 voting
* Handle errors in eth1 http module
* Set SECONDS_PER_DAY to sensible minimum
* Shorten delay before testnet start
* Ensure eth1 block is produced without any votes
* Improve eth1 logging
* Fix broken tests in eth1
* Tidy code in rest_api
* Fix failing test in deposit_contract
* Make CLI args more consistent
* Change validator/duties endpoint
* Add time-based skip slot limiting
* Add new error type missed in previous commit
* Add log when waiting for genesis
* Refactor beacon node CLI
* Remove unused dep
* Add lcli eth1-genesis command
* Fix bug in master merge
* Apply clippy lints to beacon node
* Add support for YamlConfig in Eth2TestnetDir
* Upgrade tesnet deposit contract version
* Remove unnecessary logging and correct formatting
* Add a hardcoded eth2 testnet config
* Ensure http server flag works. Overwrite configs with flags.
* Ensure boot nodes are loaded from testnet dir
* Fix account manager CLI bugs
* Fix bugs with beacon node cli
* Allow testnet dir without boot nodes
* Write genesis state as SSZ
* Remove ---/n from the start of testnet_dir files
* Set default libp2p address
* Tidy account manager CLI, add logging
* Add check to see if testnet dir exists
* Apply reviewers suggestions
* Add HeadTracker struct
* Add fork choice persistence
* Shorten slot time for simulator
* Add the /beacon/heads API endpoint
* Update hardcoded testnet
* Add tests for BeaconChain persistence + fix bugs
* Extend BeaconChain persistence testing
* Ensure chain is finalized b4 persistence tests
* Ensure boot_enr.yaml is include in binary
* Refactor beacon_chain_sim
* Move files about in beacon sim
* Update beacon_chain_sim
* Fix bug with deposit inclusion
* Increase log in genesis service, fix todo
* Tidy sim, fix broken rest_api tests
* Fix more broken tests
* Update testnet
* Fix broken rest api test
* Tidy account manager CLI
* Use tempdir for account manager
* Stop hardcoded testnet dir from creating dir
* Rename Eth2TestnetDir to Eth2TestnetConfig
* Change hardcoded -> hard_coded
* Tidy account manager
* Add log to account manager
* Tidy, ensure head tracker is loaded from disk
* Tidy beacon chain builder
* Tidy eth1_chain
* Adds log support for simulator
* Revert "Adds log support for simulator"
This reverts commit ec77c66a052350f551db145cf20f213823428dd3.
* Adds log support for simulator
* Tidy after self-review
* Change default log level
* Address Michael's delicious PR comments
* Fix off-by-one in tests
2019-12-03 04:28:57 +00:00
|
|
|
let node = build_node(&mut env, testing_client_config());
|
2019-11-25 04:48:24 +00:00
|
|
|
let remote_node = node.remote_node().expect("should produce remote node");
|
|
|
|
|
|
|
|
let beacon_chain = node
|
|
|
|
.client
|
|
|
|
.beacon_chain()
|
|
|
|
.expect("client should have beacon chain");
|
|
|
|
|
|
|
|
let slot = Slot::new(1);
|
2020-01-21 07:38:56 +00:00
|
|
|
let randao_reveal = get_randao_reveal(beacon_chain, slot, spec);
|
2019-11-25 04:48:24 +00:00
|
|
|
|
|
|
|
let block = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(
|
|
|
|
remote_node
|
|
|
|
.http
|
|
|
|
.validator()
|
|
|
|
.produce_block(slot, randao_reveal.clone()),
|
|
|
|
)
|
|
|
|
.expect("should fetch block from http api");
|
|
|
|
|
|
|
|
let (expected_block, _state) = node
|
|
|
|
.client
|
|
|
|
.beacon_chain()
|
|
|
|
.expect("client should have beacon chain")
|
|
|
|
.produce_block(randao_reveal, slot)
|
|
|
|
.expect("should produce block");
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
block, expected_block,
|
|
|
|
"the block returned from the API should be as expected"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn beacon_state() {
|
|
|
|
let mut env = build_env();
|
|
|
|
|
Prepare for public testnet (#628)
* Update to spec v0.9.0
* Update to v0.9.1
* Bump spec tags for v0.9.1
* Formatting, fix CI failures
* Resolve accidental KeyPair merge conflict
* Document new BeaconState functions
* Add `validator` changes from `validator-to-rest`
* Add initial (failing) REST api tests
* Fix signature parsing
* Add more tests
* Refactor http router
* Add working tests for publish beacon block
* Add validator duties tests
* Move account_manager under `lighthouse` binary
* Unify logfile handling in `environment` crate.
* Fix incorrect cache drops in `advance_caches`
* Update fork choice for v0.9.1
* Add `deposit_contract` crate
* Add progress on validator onboarding
* Add unfinished attesation code
* Update account manager CLI
* Write eth1 data file as hex string
* Integrate ValidatorDirectory with validator_client
* Move ValidatorDirectory into validator_client
* Clean up some FIXMEs
* Add beacon_chain_sim
* Fix a few docs/logs
* Expand `beacon_chain_sim`
* Fix spec for `beacon_chain_sim
* More testing for api
* Start work on attestation endpoint
* Reject empty attestations
* Allow attestations to genesis block
* Add working tests for `rest_api` validator endpoint
* Remove grpc from beacon_node
* Start heavy refactor of validator client
- Block production is working
* Prune old validator client files
* Start works on attestation service
* Add attestation service to validator client
* Use full pubkey for validator directories
* Add validator duties post endpoint
* Use par_iter for keypair generation
* Use bulk duties request in validator client
* Add version http endpoint tests
* Add interop keys and startup wait
* Ensure a prompt exit
* Add duties pruning
* Fix compile error in beacon node tests
* Add github workflow
* Modify rust.yaml
* Modify gitlab actions
* Add to CI file
* Add sudo to CI npm install
* Move cargo fmt to own job in tests
* Fix cargo fmt in CI
* Add rustup update before cargo fmt
* Change name of CI job
* Make other CI jobs require cargo fmt
* Add CI badge
* Remove gitlab and travis files
* Add different http timeout for debug
* Update docker file, use makefile in CI
* Use make in the dockerfile, skip the test
* Use the makefile for debug GI test
* Update book
* Tidy grpc and misc things
* Apply discv5 fixes
* Address other minor issues
* Fix warnings
* Attempt fix for addr parsing
* Tidy validator config, CLIs
* Tidy comments
* Tidy signing, reduce ForkService duplication
* Fail if skipping too many slots
* Set default recent genesis time to 0
* Add custom http timeout to validator
* Fix compile bug in node_test_rig
* Remove old bootstrap flag from val CLI
* Update docs
* Tidy val client
* Change val client log levels
* Add comments, more validity checks
* Fix compile error, add comments
* Undo changes to eth2-libp2p/src
* Reduce duplication of keypair generation
* Add more logging for validator duties
* Fix beacon_chain_sim, nitpicks
* Fix compile error, minor nits
* Update to use v0.9.2 version of deposit contract
* Add efforts to automate eth1 testnet deployment
* Fix lcli testnet deployer
* Modify bn CLI to parse eth2_testnet_dir
* Progress with account_manager deposit tools
* Make account manager submit deposits
* Add password option for submitting deposits
* Allow custom deposit amount
* Add long names to lcli clap
* Add password option to lcli deploy command
* Fix minor bugs whilst testing
* Address Michael's comments
* Add refund-deposit-contract to lcli
* Use time instead of skip count for denying long skips
* Improve logging for eth1
* Fix bug with validator services exiting on error
* Drop the block cache after genesis
* Modify eth1 testnet config
* Improve eth1 logging
* Make validator wait until genesis time
* Fix bug in eth1 voting
* Add more logging to eth1 voting
* Handle errors in eth1 http module
* Set SECONDS_PER_DAY to sensible minimum
* Shorten delay before testnet start
* Ensure eth1 block is produced without any votes
* Improve eth1 logging
* Fix broken tests in eth1
* Tidy code in rest_api
* Fix failing test in deposit_contract
* Make CLI args more consistent
* Change validator/duties endpoint
* Add time-based skip slot limiting
* Add new error type missed in previous commit
* Add log when waiting for genesis
* Refactor beacon node CLI
* Remove unused dep
* Add lcli eth1-genesis command
* Fix bug in master merge
* Apply clippy lints to beacon node
* Add support for YamlConfig in Eth2TestnetDir
* Upgrade tesnet deposit contract version
* Remove unnecessary logging and correct formatting
* Add a hardcoded eth2 testnet config
* Ensure http server flag works. Overwrite configs with flags.
* Ensure boot nodes are loaded from testnet dir
* Fix account manager CLI bugs
* Fix bugs with beacon node cli
* Allow testnet dir without boot nodes
* Write genesis state as SSZ
* Remove ---/n from the start of testnet_dir files
* Set default libp2p address
* Tidy account manager CLI, add logging
* Add check to see if testnet dir exists
* Apply reviewers suggestions
* Add HeadTracker struct
* Add fork choice persistence
* Shorten slot time for simulator
* Add the /beacon/heads API endpoint
* Update hardcoded testnet
* Add tests for BeaconChain persistence + fix bugs
* Extend BeaconChain persistence testing
* Ensure chain is finalized b4 persistence tests
* Ensure boot_enr.yaml is include in binary
* Refactor beacon_chain_sim
* Move files about in beacon sim
* Update beacon_chain_sim
* Fix bug with deposit inclusion
* Increase log in genesis service, fix todo
* Tidy sim, fix broken rest_api tests
* Fix more broken tests
* Update testnet
* Fix broken rest api test
* Tidy account manager CLI
* Use tempdir for account manager
* Stop hardcoded testnet dir from creating dir
* Rename Eth2TestnetDir to Eth2TestnetConfig
* Change hardcoded -> hard_coded
* Tidy account manager
* Add log to account manager
* Tidy, ensure head tracker is loaded from disk
* Tidy beacon chain builder
* Tidy eth1_chain
* Adds log support for simulator
* Revert "Adds log support for simulator"
This reverts commit ec77c66a052350f551db145cf20f213823428dd3.
* Adds log support for simulator
* Tidy after self-review
* Change default log level
* Address Michael's delicious PR comments
* Fix off-by-one in tests
2019-12-03 04:28:57 +00:00
|
|
|
let node = build_node(&mut env, testing_client_config());
|
2019-11-25 04:48:24 +00:00
|
|
|
let remote_node = node.remote_node().expect("should produce remote node");
|
|
|
|
|
|
|
|
let (state_by_slot, root) = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(remote_node.http.beacon().get_state_by_slot(Slot::new(0)))
|
|
|
|
.expect("should fetch state from http api");
|
|
|
|
|
|
|
|
let (state_by_root, root_2) = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(remote_node.http.beacon().get_state_by_root(root))
|
|
|
|
.expect("should fetch state from http api");
|
|
|
|
|
|
|
|
let mut db_state = node
|
|
|
|
.client
|
|
|
|
.beacon_chain()
|
|
|
|
.expect("client should have beacon chain")
|
2020-03-04 06:10:22 +00:00
|
|
|
.state_at_slot(Slot::new(0), StateSkipConfig::WithStateRoots)
|
2019-11-25 04:48:24 +00:00
|
|
|
.expect("should find state");
|
|
|
|
db_state.drop_all_caches();
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
root, root_2,
|
|
|
|
"the two roots returned from the api should be identical"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
root,
|
|
|
|
db_state.canonical_root(),
|
|
|
|
"root from database should match that from the API"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
state_by_slot, db_state,
|
|
|
|
"genesis state by slot from api should match that from the DB"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
state_by_root, db_state,
|
|
|
|
"genesis state by root from api should match that from the DB"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn beacon_block() {
|
|
|
|
let mut env = build_env();
|
|
|
|
|
Prepare for public testnet (#628)
* Update to spec v0.9.0
* Update to v0.9.1
* Bump spec tags for v0.9.1
* Formatting, fix CI failures
* Resolve accidental KeyPair merge conflict
* Document new BeaconState functions
* Add `validator` changes from `validator-to-rest`
* Add initial (failing) REST api tests
* Fix signature parsing
* Add more tests
* Refactor http router
* Add working tests for publish beacon block
* Add validator duties tests
* Move account_manager under `lighthouse` binary
* Unify logfile handling in `environment` crate.
* Fix incorrect cache drops in `advance_caches`
* Update fork choice for v0.9.1
* Add `deposit_contract` crate
* Add progress on validator onboarding
* Add unfinished attesation code
* Update account manager CLI
* Write eth1 data file as hex string
* Integrate ValidatorDirectory with validator_client
* Move ValidatorDirectory into validator_client
* Clean up some FIXMEs
* Add beacon_chain_sim
* Fix a few docs/logs
* Expand `beacon_chain_sim`
* Fix spec for `beacon_chain_sim
* More testing for api
* Start work on attestation endpoint
* Reject empty attestations
* Allow attestations to genesis block
* Add working tests for `rest_api` validator endpoint
* Remove grpc from beacon_node
* Start heavy refactor of validator client
- Block production is working
* Prune old validator client files
* Start works on attestation service
* Add attestation service to validator client
* Use full pubkey for validator directories
* Add validator duties post endpoint
* Use par_iter for keypair generation
* Use bulk duties request in validator client
* Add version http endpoint tests
* Add interop keys and startup wait
* Ensure a prompt exit
* Add duties pruning
* Fix compile error in beacon node tests
* Add github workflow
* Modify rust.yaml
* Modify gitlab actions
* Add to CI file
* Add sudo to CI npm install
* Move cargo fmt to own job in tests
* Fix cargo fmt in CI
* Add rustup update before cargo fmt
* Change name of CI job
* Make other CI jobs require cargo fmt
* Add CI badge
* Remove gitlab and travis files
* Add different http timeout for debug
* Update docker file, use makefile in CI
* Use make in the dockerfile, skip the test
* Use the makefile for debug GI test
* Update book
* Tidy grpc and misc things
* Apply discv5 fixes
* Address other minor issues
* Fix warnings
* Attempt fix for addr parsing
* Tidy validator config, CLIs
* Tidy comments
* Tidy signing, reduce ForkService duplication
* Fail if skipping too many slots
* Set default recent genesis time to 0
* Add custom http timeout to validator
* Fix compile bug in node_test_rig
* Remove old bootstrap flag from val CLI
* Update docs
* Tidy val client
* Change val client log levels
* Add comments, more validity checks
* Fix compile error, add comments
* Undo changes to eth2-libp2p/src
* Reduce duplication of keypair generation
* Add more logging for validator duties
* Fix beacon_chain_sim, nitpicks
* Fix compile error, minor nits
* Update to use v0.9.2 version of deposit contract
* Add efforts to automate eth1 testnet deployment
* Fix lcli testnet deployer
* Modify bn CLI to parse eth2_testnet_dir
* Progress with account_manager deposit tools
* Make account manager submit deposits
* Add password option for submitting deposits
* Allow custom deposit amount
* Add long names to lcli clap
* Add password option to lcli deploy command
* Fix minor bugs whilst testing
* Address Michael's comments
* Add refund-deposit-contract to lcli
* Use time instead of skip count for denying long skips
* Improve logging for eth1
* Fix bug with validator services exiting on error
* Drop the block cache after genesis
* Modify eth1 testnet config
* Improve eth1 logging
* Make validator wait until genesis time
* Fix bug in eth1 voting
* Add more logging to eth1 voting
* Handle errors in eth1 http module
* Set SECONDS_PER_DAY to sensible minimum
* Shorten delay before testnet start
* Ensure eth1 block is produced without any votes
* Improve eth1 logging
* Fix broken tests in eth1
* Tidy code in rest_api
* Fix failing test in deposit_contract
* Make CLI args more consistent
* Change validator/duties endpoint
* Add time-based skip slot limiting
* Add new error type missed in previous commit
* Add log when waiting for genesis
* Refactor beacon node CLI
* Remove unused dep
* Add lcli eth1-genesis command
* Fix bug in master merge
* Apply clippy lints to beacon node
* Add support for YamlConfig in Eth2TestnetDir
* Upgrade tesnet deposit contract version
* Remove unnecessary logging and correct formatting
* Add a hardcoded eth2 testnet config
* Ensure http server flag works. Overwrite configs with flags.
* Ensure boot nodes are loaded from testnet dir
* Fix account manager CLI bugs
* Fix bugs with beacon node cli
* Allow testnet dir without boot nodes
* Write genesis state as SSZ
* Remove ---/n from the start of testnet_dir files
* Set default libp2p address
* Tidy account manager CLI, add logging
* Add check to see if testnet dir exists
* Apply reviewers suggestions
* Add HeadTracker struct
* Add fork choice persistence
* Shorten slot time for simulator
* Add the /beacon/heads API endpoint
* Update hardcoded testnet
* Add tests for BeaconChain persistence + fix bugs
* Extend BeaconChain persistence testing
* Ensure chain is finalized b4 persistence tests
* Ensure boot_enr.yaml is include in binary
* Refactor beacon_chain_sim
* Move files about in beacon sim
* Update beacon_chain_sim
* Fix bug with deposit inclusion
* Increase log in genesis service, fix todo
* Tidy sim, fix broken rest_api tests
* Fix more broken tests
* Update testnet
* Fix broken rest api test
* Tidy account manager CLI
* Use tempdir for account manager
* Stop hardcoded testnet dir from creating dir
* Rename Eth2TestnetDir to Eth2TestnetConfig
* Change hardcoded -> hard_coded
* Tidy account manager
* Add log to account manager
* Tidy, ensure head tracker is loaded from disk
* Tidy beacon chain builder
* Tidy eth1_chain
* Adds log support for simulator
* Revert "Adds log support for simulator"
This reverts commit ec77c66a052350f551db145cf20f213823428dd3.
* Adds log support for simulator
* Tidy after self-review
* Change default log level
* Address Michael's delicious PR comments
* Fix off-by-one in tests
2019-12-03 04:28:57 +00:00
|
|
|
let node = build_node(&mut env, testing_client_config());
|
2019-11-25 04:48:24 +00:00
|
|
|
let remote_node = node.remote_node().expect("should produce remote node");
|
|
|
|
|
|
|
|
let (block_by_slot, root) = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(remote_node.http.beacon().get_block_by_slot(Slot::new(0)))
|
|
|
|
.expect("should fetch block from http api");
|
|
|
|
|
|
|
|
let (block_by_root, root_2) = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(remote_node.http.beacon().get_block_by_root(root))
|
|
|
|
.expect("should fetch block from http api");
|
|
|
|
|
|
|
|
let db_block = node
|
|
|
|
.client
|
|
|
|
.beacon_chain()
|
|
|
|
.expect("client should have beacon chain")
|
|
|
|
.block_at_slot(Slot::new(0))
|
|
|
|
.expect("should find block")
|
|
|
|
.expect("block should not be none");
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
root, root_2,
|
|
|
|
"the two roots returned from the api should be identical"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
root,
|
|
|
|
db_block.canonical_root(),
|
|
|
|
"root from database should match that from the API"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
block_by_slot, db_block,
|
|
|
|
"genesis block by slot from api should match that from the DB"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
block_by_root, db_block,
|
|
|
|
"genesis block by root from api should match that from the DB"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn genesis_time() {
|
|
|
|
let mut env = build_env();
|
|
|
|
|
Prepare for public testnet (#628)
* Update to spec v0.9.0
* Update to v0.9.1
* Bump spec tags for v0.9.1
* Formatting, fix CI failures
* Resolve accidental KeyPair merge conflict
* Document new BeaconState functions
* Add `validator` changes from `validator-to-rest`
* Add initial (failing) REST api tests
* Fix signature parsing
* Add more tests
* Refactor http router
* Add working tests for publish beacon block
* Add validator duties tests
* Move account_manager under `lighthouse` binary
* Unify logfile handling in `environment` crate.
* Fix incorrect cache drops in `advance_caches`
* Update fork choice for v0.9.1
* Add `deposit_contract` crate
* Add progress on validator onboarding
* Add unfinished attesation code
* Update account manager CLI
* Write eth1 data file as hex string
* Integrate ValidatorDirectory with validator_client
* Move ValidatorDirectory into validator_client
* Clean up some FIXMEs
* Add beacon_chain_sim
* Fix a few docs/logs
* Expand `beacon_chain_sim`
* Fix spec for `beacon_chain_sim
* More testing for api
* Start work on attestation endpoint
* Reject empty attestations
* Allow attestations to genesis block
* Add working tests for `rest_api` validator endpoint
* Remove grpc from beacon_node
* Start heavy refactor of validator client
- Block production is working
* Prune old validator client files
* Start works on attestation service
* Add attestation service to validator client
* Use full pubkey for validator directories
* Add validator duties post endpoint
* Use par_iter for keypair generation
* Use bulk duties request in validator client
* Add version http endpoint tests
* Add interop keys and startup wait
* Ensure a prompt exit
* Add duties pruning
* Fix compile error in beacon node tests
* Add github workflow
* Modify rust.yaml
* Modify gitlab actions
* Add to CI file
* Add sudo to CI npm install
* Move cargo fmt to own job in tests
* Fix cargo fmt in CI
* Add rustup update before cargo fmt
* Change name of CI job
* Make other CI jobs require cargo fmt
* Add CI badge
* Remove gitlab and travis files
* Add different http timeout for debug
* Update docker file, use makefile in CI
* Use make in the dockerfile, skip the test
* Use the makefile for debug GI test
* Update book
* Tidy grpc and misc things
* Apply discv5 fixes
* Address other minor issues
* Fix warnings
* Attempt fix for addr parsing
* Tidy validator config, CLIs
* Tidy comments
* Tidy signing, reduce ForkService duplication
* Fail if skipping too many slots
* Set default recent genesis time to 0
* Add custom http timeout to validator
* Fix compile bug in node_test_rig
* Remove old bootstrap flag from val CLI
* Update docs
* Tidy val client
* Change val client log levels
* Add comments, more validity checks
* Fix compile error, add comments
* Undo changes to eth2-libp2p/src
* Reduce duplication of keypair generation
* Add more logging for validator duties
* Fix beacon_chain_sim, nitpicks
* Fix compile error, minor nits
* Update to use v0.9.2 version of deposit contract
* Add efforts to automate eth1 testnet deployment
* Fix lcli testnet deployer
* Modify bn CLI to parse eth2_testnet_dir
* Progress with account_manager deposit tools
* Make account manager submit deposits
* Add password option for submitting deposits
* Allow custom deposit amount
* Add long names to lcli clap
* Add password option to lcli deploy command
* Fix minor bugs whilst testing
* Address Michael's comments
* Add refund-deposit-contract to lcli
* Use time instead of skip count for denying long skips
* Improve logging for eth1
* Fix bug with validator services exiting on error
* Drop the block cache after genesis
* Modify eth1 testnet config
* Improve eth1 logging
* Make validator wait until genesis time
* Fix bug in eth1 voting
* Add more logging to eth1 voting
* Handle errors in eth1 http module
* Set SECONDS_PER_DAY to sensible minimum
* Shorten delay before testnet start
* Ensure eth1 block is produced without any votes
* Improve eth1 logging
* Fix broken tests in eth1
* Tidy code in rest_api
* Fix failing test in deposit_contract
* Make CLI args more consistent
* Change validator/duties endpoint
* Add time-based skip slot limiting
* Add new error type missed in previous commit
* Add log when waiting for genesis
* Refactor beacon node CLI
* Remove unused dep
* Add lcli eth1-genesis command
* Fix bug in master merge
* Apply clippy lints to beacon node
* Add support for YamlConfig in Eth2TestnetDir
* Upgrade tesnet deposit contract version
* Remove unnecessary logging and correct formatting
* Add a hardcoded eth2 testnet config
* Ensure http server flag works. Overwrite configs with flags.
* Ensure boot nodes are loaded from testnet dir
* Fix account manager CLI bugs
* Fix bugs with beacon node cli
* Allow testnet dir without boot nodes
* Write genesis state as SSZ
* Remove ---/n from the start of testnet_dir files
* Set default libp2p address
* Tidy account manager CLI, add logging
* Add check to see if testnet dir exists
* Apply reviewers suggestions
* Add HeadTracker struct
* Add fork choice persistence
* Shorten slot time for simulator
* Add the /beacon/heads API endpoint
* Update hardcoded testnet
* Add tests for BeaconChain persistence + fix bugs
* Extend BeaconChain persistence testing
* Ensure chain is finalized b4 persistence tests
* Ensure boot_enr.yaml is include in binary
* Refactor beacon_chain_sim
* Move files about in beacon sim
* Update beacon_chain_sim
* Fix bug with deposit inclusion
* Increase log in genesis service, fix todo
* Tidy sim, fix broken rest_api tests
* Fix more broken tests
* Update testnet
* Fix broken rest api test
* Tidy account manager CLI
* Use tempdir for account manager
* Stop hardcoded testnet dir from creating dir
* Rename Eth2TestnetDir to Eth2TestnetConfig
* Change hardcoded -> hard_coded
* Tidy account manager
* Add log to account manager
* Tidy, ensure head tracker is loaded from disk
* Tidy beacon chain builder
* Tidy eth1_chain
* Adds log support for simulator
* Revert "Adds log support for simulator"
This reverts commit ec77c66a052350f551db145cf20f213823428dd3.
* Adds log support for simulator
* Tidy after self-review
* Change default log level
* Address Michael's delicious PR comments
* Fix off-by-one in tests
2019-12-03 04:28:57 +00:00
|
|
|
let node = build_node(&mut env, testing_client_config());
|
2019-11-25 04:48:24 +00:00
|
|
|
let remote_node = node.remote_node().expect("should produce remote node");
|
|
|
|
|
|
|
|
let genesis_time = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(remote_node.http.beacon().get_genesis_time())
|
|
|
|
.expect("should fetch genesis time from http api");
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
node.client
|
|
|
|
.beacon_chain()
|
|
|
|
.expect("should have beacon chain")
|
|
|
|
.head()
|
2020-01-06 06:30:37 +00:00
|
|
|
.expect("should get head")
|
2019-11-25 04:48:24 +00:00
|
|
|
.beacon_state
|
|
|
|
.genesis_time,
|
|
|
|
genesis_time,
|
|
|
|
"should match genesis time from head state"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-04-01 11:03:03 +00:00
|
|
|
#[test]
|
|
|
|
fn genesis_validators_root() {
|
|
|
|
let mut env = build_env();
|
|
|
|
|
|
|
|
let node = build_node(&mut env, testing_client_config());
|
|
|
|
let remote_node = node.remote_node().expect("should produce remote node");
|
|
|
|
|
|
|
|
let genesis_validators_root = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(remote_node.http.beacon().get_genesis_validators_root())
|
|
|
|
.expect("should fetch genesis time from http api");
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
node.client
|
|
|
|
.beacon_chain()
|
|
|
|
.expect("should have beacon chain")
|
|
|
|
.head()
|
|
|
|
.expect("should get head")
|
|
|
|
.beacon_state
|
|
|
|
.genesis_validators_root,
|
|
|
|
genesis_validators_root,
|
|
|
|
"should match genesis time from head state"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-11-25 04:48:24 +00:00
|
|
|
#[test]
|
|
|
|
fn fork() {
|
|
|
|
let mut env = build_env();
|
|
|
|
|
Prepare for public testnet (#628)
* Update to spec v0.9.0
* Update to v0.9.1
* Bump spec tags for v0.9.1
* Formatting, fix CI failures
* Resolve accidental KeyPair merge conflict
* Document new BeaconState functions
* Add `validator` changes from `validator-to-rest`
* Add initial (failing) REST api tests
* Fix signature parsing
* Add more tests
* Refactor http router
* Add working tests for publish beacon block
* Add validator duties tests
* Move account_manager under `lighthouse` binary
* Unify logfile handling in `environment` crate.
* Fix incorrect cache drops in `advance_caches`
* Update fork choice for v0.9.1
* Add `deposit_contract` crate
* Add progress on validator onboarding
* Add unfinished attesation code
* Update account manager CLI
* Write eth1 data file as hex string
* Integrate ValidatorDirectory with validator_client
* Move ValidatorDirectory into validator_client
* Clean up some FIXMEs
* Add beacon_chain_sim
* Fix a few docs/logs
* Expand `beacon_chain_sim`
* Fix spec for `beacon_chain_sim
* More testing for api
* Start work on attestation endpoint
* Reject empty attestations
* Allow attestations to genesis block
* Add working tests for `rest_api` validator endpoint
* Remove grpc from beacon_node
* Start heavy refactor of validator client
- Block production is working
* Prune old validator client files
* Start works on attestation service
* Add attestation service to validator client
* Use full pubkey for validator directories
* Add validator duties post endpoint
* Use par_iter for keypair generation
* Use bulk duties request in validator client
* Add version http endpoint tests
* Add interop keys and startup wait
* Ensure a prompt exit
* Add duties pruning
* Fix compile error in beacon node tests
* Add github workflow
* Modify rust.yaml
* Modify gitlab actions
* Add to CI file
* Add sudo to CI npm install
* Move cargo fmt to own job in tests
* Fix cargo fmt in CI
* Add rustup update before cargo fmt
* Change name of CI job
* Make other CI jobs require cargo fmt
* Add CI badge
* Remove gitlab and travis files
* Add different http timeout for debug
* Update docker file, use makefile in CI
* Use make in the dockerfile, skip the test
* Use the makefile for debug GI test
* Update book
* Tidy grpc and misc things
* Apply discv5 fixes
* Address other minor issues
* Fix warnings
* Attempt fix for addr parsing
* Tidy validator config, CLIs
* Tidy comments
* Tidy signing, reduce ForkService duplication
* Fail if skipping too many slots
* Set default recent genesis time to 0
* Add custom http timeout to validator
* Fix compile bug in node_test_rig
* Remove old bootstrap flag from val CLI
* Update docs
* Tidy val client
* Change val client log levels
* Add comments, more validity checks
* Fix compile error, add comments
* Undo changes to eth2-libp2p/src
* Reduce duplication of keypair generation
* Add more logging for validator duties
* Fix beacon_chain_sim, nitpicks
* Fix compile error, minor nits
* Update to use v0.9.2 version of deposit contract
* Add efforts to automate eth1 testnet deployment
* Fix lcli testnet deployer
* Modify bn CLI to parse eth2_testnet_dir
* Progress with account_manager deposit tools
* Make account manager submit deposits
* Add password option for submitting deposits
* Allow custom deposit amount
* Add long names to lcli clap
* Add password option to lcli deploy command
* Fix minor bugs whilst testing
* Address Michael's comments
* Add refund-deposit-contract to lcli
* Use time instead of skip count for denying long skips
* Improve logging for eth1
* Fix bug with validator services exiting on error
* Drop the block cache after genesis
* Modify eth1 testnet config
* Improve eth1 logging
* Make validator wait until genesis time
* Fix bug in eth1 voting
* Add more logging to eth1 voting
* Handle errors in eth1 http module
* Set SECONDS_PER_DAY to sensible minimum
* Shorten delay before testnet start
* Ensure eth1 block is produced without any votes
* Improve eth1 logging
* Fix broken tests in eth1
* Tidy code in rest_api
* Fix failing test in deposit_contract
* Make CLI args more consistent
* Change validator/duties endpoint
* Add time-based skip slot limiting
* Add new error type missed in previous commit
* Add log when waiting for genesis
* Refactor beacon node CLI
* Remove unused dep
* Add lcli eth1-genesis command
* Fix bug in master merge
* Apply clippy lints to beacon node
* Add support for YamlConfig in Eth2TestnetDir
* Upgrade tesnet deposit contract version
* Remove unnecessary logging and correct formatting
* Add a hardcoded eth2 testnet config
* Ensure http server flag works. Overwrite configs with flags.
* Ensure boot nodes are loaded from testnet dir
* Fix account manager CLI bugs
* Fix bugs with beacon node cli
* Allow testnet dir without boot nodes
* Write genesis state as SSZ
* Remove ---/n from the start of testnet_dir files
* Set default libp2p address
* Tidy account manager CLI, add logging
* Add check to see if testnet dir exists
* Apply reviewers suggestions
* Add HeadTracker struct
* Add fork choice persistence
* Shorten slot time for simulator
* Add the /beacon/heads API endpoint
* Update hardcoded testnet
* Add tests for BeaconChain persistence + fix bugs
* Extend BeaconChain persistence testing
* Ensure chain is finalized b4 persistence tests
* Ensure boot_enr.yaml is include in binary
* Refactor beacon_chain_sim
* Move files about in beacon sim
* Update beacon_chain_sim
* Fix bug with deposit inclusion
* Increase log in genesis service, fix todo
* Tidy sim, fix broken rest_api tests
* Fix more broken tests
* Update testnet
* Fix broken rest api test
* Tidy account manager CLI
* Use tempdir for account manager
* Stop hardcoded testnet dir from creating dir
* Rename Eth2TestnetDir to Eth2TestnetConfig
* Change hardcoded -> hard_coded
* Tidy account manager
* Add log to account manager
* Tidy, ensure head tracker is loaded from disk
* Tidy beacon chain builder
* Tidy eth1_chain
* Adds log support for simulator
* Revert "Adds log support for simulator"
This reverts commit ec77c66a052350f551db145cf20f213823428dd3.
* Adds log support for simulator
* Tidy after self-review
* Change default log level
* Address Michael's delicious PR comments
* Fix off-by-one in tests
2019-12-03 04:28:57 +00:00
|
|
|
let node = build_node(&mut env, testing_client_config());
|
2019-11-25 04:48:24 +00:00
|
|
|
let remote_node = node.remote_node().expect("should produce remote node");
|
|
|
|
|
|
|
|
let fork = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(remote_node.http.beacon().get_fork())
|
|
|
|
.expect("should fetch from http api");
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
node.client
|
|
|
|
.beacon_chain()
|
|
|
|
.expect("should have beacon chain")
|
|
|
|
.head()
|
2020-01-06 06:30:37 +00:00
|
|
|
.expect("should get head")
|
2019-11-25 04:48:24 +00:00
|
|
|
.beacon_state
|
|
|
|
.fork,
|
|
|
|
fork,
|
|
|
|
"should match head state"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn eth2_config() {
|
|
|
|
let mut env = build_env();
|
|
|
|
|
Prepare for public testnet (#628)
* Update to spec v0.9.0
* Update to v0.9.1
* Bump spec tags for v0.9.1
* Formatting, fix CI failures
* Resolve accidental KeyPair merge conflict
* Document new BeaconState functions
* Add `validator` changes from `validator-to-rest`
* Add initial (failing) REST api tests
* Fix signature parsing
* Add more tests
* Refactor http router
* Add working tests for publish beacon block
* Add validator duties tests
* Move account_manager under `lighthouse` binary
* Unify logfile handling in `environment` crate.
* Fix incorrect cache drops in `advance_caches`
* Update fork choice for v0.9.1
* Add `deposit_contract` crate
* Add progress on validator onboarding
* Add unfinished attesation code
* Update account manager CLI
* Write eth1 data file as hex string
* Integrate ValidatorDirectory with validator_client
* Move ValidatorDirectory into validator_client
* Clean up some FIXMEs
* Add beacon_chain_sim
* Fix a few docs/logs
* Expand `beacon_chain_sim`
* Fix spec for `beacon_chain_sim
* More testing for api
* Start work on attestation endpoint
* Reject empty attestations
* Allow attestations to genesis block
* Add working tests for `rest_api` validator endpoint
* Remove grpc from beacon_node
* Start heavy refactor of validator client
- Block production is working
* Prune old validator client files
* Start works on attestation service
* Add attestation service to validator client
* Use full pubkey for validator directories
* Add validator duties post endpoint
* Use par_iter for keypair generation
* Use bulk duties request in validator client
* Add version http endpoint tests
* Add interop keys and startup wait
* Ensure a prompt exit
* Add duties pruning
* Fix compile error in beacon node tests
* Add github workflow
* Modify rust.yaml
* Modify gitlab actions
* Add to CI file
* Add sudo to CI npm install
* Move cargo fmt to own job in tests
* Fix cargo fmt in CI
* Add rustup update before cargo fmt
* Change name of CI job
* Make other CI jobs require cargo fmt
* Add CI badge
* Remove gitlab and travis files
* Add different http timeout for debug
* Update docker file, use makefile in CI
* Use make in the dockerfile, skip the test
* Use the makefile for debug GI test
* Update book
* Tidy grpc and misc things
* Apply discv5 fixes
* Address other minor issues
* Fix warnings
* Attempt fix for addr parsing
* Tidy validator config, CLIs
* Tidy comments
* Tidy signing, reduce ForkService duplication
* Fail if skipping too many slots
* Set default recent genesis time to 0
* Add custom http timeout to validator
* Fix compile bug in node_test_rig
* Remove old bootstrap flag from val CLI
* Update docs
* Tidy val client
* Change val client log levels
* Add comments, more validity checks
* Fix compile error, add comments
* Undo changes to eth2-libp2p/src
* Reduce duplication of keypair generation
* Add more logging for validator duties
* Fix beacon_chain_sim, nitpicks
* Fix compile error, minor nits
* Update to use v0.9.2 version of deposit contract
* Add efforts to automate eth1 testnet deployment
* Fix lcli testnet deployer
* Modify bn CLI to parse eth2_testnet_dir
* Progress with account_manager deposit tools
* Make account manager submit deposits
* Add password option for submitting deposits
* Allow custom deposit amount
* Add long names to lcli clap
* Add password option to lcli deploy command
* Fix minor bugs whilst testing
* Address Michael's comments
* Add refund-deposit-contract to lcli
* Use time instead of skip count for denying long skips
* Improve logging for eth1
* Fix bug with validator services exiting on error
* Drop the block cache after genesis
* Modify eth1 testnet config
* Improve eth1 logging
* Make validator wait until genesis time
* Fix bug in eth1 voting
* Add more logging to eth1 voting
* Handle errors in eth1 http module
* Set SECONDS_PER_DAY to sensible minimum
* Shorten delay before testnet start
* Ensure eth1 block is produced without any votes
* Improve eth1 logging
* Fix broken tests in eth1
* Tidy code in rest_api
* Fix failing test in deposit_contract
* Make CLI args more consistent
* Change validator/duties endpoint
* Add time-based skip slot limiting
* Add new error type missed in previous commit
* Add log when waiting for genesis
* Refactor beacon node CLI
* Remove unused dep
* Add lcli eth1-genesis command
* Fix bug in master merge
* Apply clippy lints to beacon node
* Add support for YamlConfig in Eth2TestnetDir
* Upgrade tesnet deposit contract version
* Remove unnecessary logging and correct formatting
* Add a hardcoded eth2 testnet config
* Ensure http server flag works. Overwrite configs with flags.
* Ensure boot nodes are loaded from testnet dir
* Fix account manager CLI bugs
* Fix bugs with beacon node cli
* Allow testnet dir without boot nodes
* Write genesis state as SSZ
* Remove ---/n from the start of testnet_dir files
* Set default libp2p address
* Tidy account manager CLI, add logging
* Add check to see if testnet dir exists
* Apply reviewers suggestions
* Add HeadTracker struct
* Add fork choice persistence
* Shorten slot time for simulator
* Add the /beacon/heads API endpoint
* Update hardcoded testnet
* Add tests for BeaconChain persistence + fix bugs
* Extend BeaconChain persistence testing
* Ensure chain is finalized b4 persistence tests
* Ensure boot_enr.yaml is include in binary
* Refactor beacon_chain_sim
* Move files about in beacon sim
* Update beacon_chain_sim
* Fix bug with deposit inclusion
* Increase log in genesis service, fix todo
* Tidy sim, fix broken rest_api tests
* Fix more broken tests
* Update testnet
* Fix broken rest api test
* Tidy account manager CLI
* Use tempdir for account manager
* Stop hardcoded testnet dir from creating dir
* Rename Eth2TestnetDir to Eth2TestnetConfig
* Change hardcoded -> hard_coded
* Tidy account manager
* Add log to account manager
* Tidy, ensure head tracker is loaded from disk
* Tidy beacon chain builder
* Tidy eth1_chain
* Adds log support for simulator
* Revert "Adds log support for simulator"
This reverts commit ec77c66a052350f551db145cf20f213823428dd3.
* Adds log support for simulator
* Tidy after self-review
* Change default log level
* Address Michael's delicious PR comments
* Fix off-by-one in tests
2019-12-03 04:28:57 +00:00
|
|
|
let node = build_node(&mut env, testing_client_config());
|
2019-11-25 04:48:24 +00:00
|
|
|
let remote_node = node.remote_node().expect("should produce remote node");
|
|
|
|
|
|
|
|
let eth2_config = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(remote_node.http.spec().get_eth2_config())
|
|
|
|
.expect("should fetch eth2 config from http api");
|
|
|
|
|
|
|
|
// TODO: check the entire eth2_config, not just the spec.
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
node.client
|
|
|
|
.beacon_chain()
|
|
|
|
.expect("should have beacon chain")
|
|
|
|
.spec,
|
|
|
|
eth2_config.spec,
|
|
|
|
"should match genesis time from head state"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn get_version() {
|
|
|
|
let mut env = build_env();
|
|
|
|
|
Prepare for public testnet (#628)
* Update to spec v0.9.0
* Update to v0.9.1
* Bump spec tags for v0.9.1
* Formatting, fix CI failures
* Resolve accidental KeyPair merge conflict
* Document new BeaconState functions
* Add `validator` changes from `validator-to-rest`
* Add initial (failing) REST api tests
* Fix signature parsing
* Add more tests
* Refactor http router
* Add working tests for publish beacon block
* Add validator duties tests
* Move account_manager under `lighthouse` binary
* Unify logfile handling in `environment` crate.
* Fix incorrect cache drops in `advance_caches`
* Update fork choice for v0.9.1
* Add `deposit_contract` crate
* Add progress on validator onboarding
* Add unfinished attesation code
* Update account manager CLI
* Write eth1 data file as hex string
* Integrate ValidatorDirectory with validator_client
* Move ValidatorDirectory into validator_client
* Clean up some FIXMEs
* Add beacon_chain_sim
* Fix a few docs/logs
* Expand `beacon_chain_sim`
* Fix spec for `beacon_chain_sim
* More testing for api
* Start work on attestation endpoint
* Reject empty attestations
* Allow attestations to genesis block
* Add working tests for `rest_api` validator endpoint
* Remove grpc from beacon_node
* Start heavy refactor of validator client
- Block production is working
* Prune old validator client files
* Start works on attestation service
* Add attestation service to validator client
* Use full pubkey for validator directories
* Add validator duties post endpoint
* Use par_iter for keypair generation
* Use bulk duties request in validator client
* Add version http endpoint tests
* Add interop keys and startup wait
* Ensure a prompt exit
* Add duties pruning
* Fix compile error in beacon node tests
* Add github workflow
* Modify rust.yaml
* Modify gitlab actions
* Add to CI file
* Add sudo to CI npm install
* Move cargo fmt to own job in tests
* Fix cargo fmt in CI
* Add rustup update before cargo fmt
* Change name of CI job
* Make other CI jobs require cargo fmt
* Add CI badge
* Remove gitlab and travis files
* Add different http timeout for debug
* Update docker file, use makefile in CI
* Use make in the dockerfile, skip the test
* Use the makefile for debug GI test
* Update book
* Tidy grpc and misc things
* Apply discv5 fixes
* Address other minor issues
* Fix warnings
* Attempt fix for addr parsing
* Tidy validator config, CLIs
* Tidy comments
* Tidy signing, reduce ForkService duplication
* Fail if skipping too many slots
* Set default recent genesis time to 0
* Add custom http timeout to validator
* Fix compile bug in node_test_rig
* Remove old bootstrap flag from val CLI
* Update docs
* Tidy val client
* Change val client log levels
* Add comments, more validity checks
* Fix compile error, add comments
* Undo changes to eth2-libp2p/src
* Reduce duplication of keypair generation
* Add more logging for validator duties
* Fix beacon_chain_sim, nitpicks
* Fix compile error, minor nits
* Update to use v0.9.2 version of deposit contract
* Add efforts to automate eth1 testnet deployment
* Fix lcli testnet deployer
* Modify bn CLI to parse eth2_testnet_dir
* Progress with account_manager deposit tools
* Make account manager submit deposits
* Add password option for submitting deposits
* Allow custom deposit amount
* Add long names to lcli clap
* Add password option to lcli deploy command
* Fix minor bugs whilst testing
* Address Michael's comments
* Add refund-deposit-contract to lcli
* Use time instead of skip count for denying long skips
* Improve logging for eth1
* Fix bug with validator services exiting on error
* Drop the block cache after genesis
* Modify eth1 testnet config
* Improve eth1 logging
* Make validator wait until genesis time
* Fix bug in eth1 voting
* Add more logging to eth1 voting
* Handle errors in eth1 http module
* Set SECONDS_PER_DAY to sensible minimum
* Shorten delay before testnet start
* Ensure eth1 block is produced without any votes
* Improve eth1 logging
* Fix broken tests in eth1
* Tidy code in rest_api
* Fix failing test in deposit_contract
* Make CLI args more consistent
* Change validator/duties endpoint
* Add time-based skip slot limiting
* Add new error type missed in previous commit
* Add log when waiting for genesis
* Refactor beacon node CLI
* Remove unused dep
* Add lcli eth1-genesis command
* Fix bug in master merge
* Apply clippy lints to beacon node
* Add support for YamlConfig in Eth2TestnetDir
* Upgrade tesnet deposit contract version
* Remove unnecessary logging and correct formatting
* Add a hardcoded eth2 testnet config
* Ensure http server flag works. Overwrite configs with flags.
* Ensure boot nodes are loaded from testnet dir
* Fix account manager CLI bugs
* Fix bugs with beacon node cli
* Allow testnet dir without boot nodes
* Write genesis state as SSZ
* Remove ---/n from the start of testnet_dir files
* Set default libp2p address
* Tidy account manager CLI, add logging
* Add check to see if testnet dir exists
* Apply reviewers suggestions
* Add HeadTracker struct
* Add fork choice persistence
* Shorten slot time for simulator
* Add the /beacon/heads API endpoint
* Update hardcoded testnet
* Add tests for BeaconChain persistence + fix bugs
* Extend BeaconChain persistence testing
* Ensure chain is finalized b4 persistence tests
* Ensure boot_enr.yaml is include in binary
* Refactor beacon_chain_sim
* Move files about in beacon sim
* Update beacon_chain_sim
* Fix bug with deposit inclusion
* Increase log in genesis service, fix todo
* Tidy sim, fix broken rest_api tests
* Fix more broken tests
* Update testnet
* Fix broken rest api test
* Tidy account manager CLI
* Use tempdir for account manager
* Stop hardcoded testnet dir from creating dir
* Rename Eth2TestnetDir to Eth2TestnetConfig
* Change hardcoded -> hard_coded
* Tidy account manager
* Add log to account manager
* Tidy, ensure head tracker is loaded from disk
* Tidy beacon chain builder
* Tidy eth1_chain
* Adds log support for simulator
* Revert "Adds log support for simulator"
This reverts commit ec77c66a052350f551db145cf20f213823428dd3.
* Adds log support for simulator
* Tidy after self-review
* Change default log level
* Address Michael's delicious PR comments
* Fix off-by-one in tests
2019-12-03 04:28:57 +00:00
|
|
|
let node = build_node(&mut env, testing_client_config());
|
2019-11-25 04:48:24 +00:00
|
|
|
let remote_node = node.remote_node().expect("should produce remote node");
|
|
|
|
|
|
|
|
let version = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(remote_node.http.node().get_version())
|
|
|
|
.expect("should fetch eth2 config from http api");
|
|
|
|
|
|
|
|
assert_eq!(version::version(), version, "result should be as expected");
|
|
|
|
}
|
2019-12-19 00:45:28 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn get_genesis_state_root() {
|
|
|
|
let mut env = build_env();
|
|
|
|
|
|
|
|
let node = build_node(&mut env, testing_client_config());
|
|
|
|
let remote_node = node.remote_node().expect("should produce remote node");
|
|
|
|
|
|
|
|
let slot = Slot::new(0);
|
|
|
|
|
|
|
|
let result = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(remote_node.http.beacon().get_state_root(slot))
|
|
|
|
.expect("should fetch from http api");
|
|
|
|
|
|
|
|
let expected = node
|
|
|
|
.client
|
|
|
|
.beacon_chain()
|
|
|
|
.expect("should have beacon chain")
|
|
|
|
.rev_iter_state_roots()
|
2020-01-06 06:30:37 +00:00
|
|
|
.expect("should get iter")
|
2020-06-09 23:55:44 +00:00
|
|
|
.map(Result::unwrap)
|
2019-12-19 00:45:28 +00:00
|
|
|
.find(|(_cur_root, cur_slot)| slot == *cur_slot)
|
|
|
|
.map(|(cur_root, _)| cur_root)
|
|
|
|
.expect("chain should have state root at slot");
|
|
|
|
|
|
|
|
assert_eq!(result, expected, "result should be as expected");
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn get_genesis_block_root() {
|
|
|
|
let mut env = build_env();
|
|
|
|
|
|
|
|
let node = build_node(&mut env, testing_client_config());
|
|
|
|
let remote_node = node.remote_node().expect("should produce remote node");
|
|
|
|
|
|
|
|
let slot = Slot::new(0);
|
|
|
|
|
|
|
|
let result = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(remote_node.http.beacon().get_block_root(slot))
|
|
|
|
.expect("should fetch from http api");
|
|
|
|
|
|
|
|
let expected = node
|
|
|
|
.client
|
|
|
|
.beacon_chain()
|
|
|
|
.expect("should have beacon chain")
|
|
|
|
.rev_iter_block_roots()
|
2020-01-06 06:30:37 +00:00
|
|
|
.expect("should get iter")
|
2020-06-09 23:55:44 +00:00
|
|
|
.map(Result::unwrap)
|
2019-12-19 00:45:28 +00:00
|
|
|
.find(|(_cur_root, cur_slot)| slot == *cur_slot)
|
|
|
|
.map(|(cur_root, _)| cur_root)
|
|
|
|
.expect("chain should have state root at slot");
|
|
|
|
|
|
|
|
assert_eq!(result, expected, "result should be as expected");
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn get_validators() {
|
|
|
|
let mut env = build_env();
|
|
|
|
|
|
|
|
let node = build_node(&mut env, testing_client_config());
|
|
|
|
let remote_node = node.remote_node().expect("should produce remote node");
|
|
|
|
let chain = node
|
|
|
|
.client
|
|
|
|
.beacon_chain()
|
|
|
|
.expect("node should have beacon chain");
|
2020-01-06 06:30:37 +00:00
|
|
|
let state = &chain.head().expect("should get head").beacon_state;
|
2019-12-19 00:45:28 +00:00
|
|
|
|
|
|
|
let validators = state.validators.iter().take(2).collect::<Vec<_>>();
|
|
|
|
let pubkeys = validators
|
|
|
|
.iter()
|
|
|
|
.map(|v| (&v.pubkey).try_into().expect("should decode pubkey bytes"))
|
|
|
|
.collect();
|
|
|
|
|
|
|
|
let result = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(remote_node.http.beacon().get_validators(pubkeys, None))
|
|
|
|
.expect("should fetch from http api");
|
|
|
|
|
|
|
|
result
|
|
|
|
.iter()
|
|
|
|
.zip(validators.iter())
|
|
|
|
.for_each(|(response, validator)| compare_validator_response(state, response, validator));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn get_all_validators() {
|
|
|
|
let mut env = build_env();
|
|
|
|
|
|
|
|
let node = build_node(&mut env, testing_client_config());
|
|
|
|
let remote_node = node.remote_node().expect("should produce remote node");
|
|
|
|
let chain = node
|
|
|
|
.client
|
|
|
|
.beacon_chain()
|
|
|
|
.expect("node should have beacon chain");
|
2020-01-06 06:30:37 +00:00
|
|
|
let state = &chain.head().expect("should get head").beacon_state;
|
2019-12-19 00:45:28 +00:00
|
|
|
|
|
|
|
let result = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(remote_node.http.beacon().get_all_validators(None))
|
|
|
|
.expect("should fetch from http api");
|
|
|
|
|
|
|
|
result
|
|
|
|
.iter()
|
|
|
|
.zip(state.validators.iter())
|
|
|
|
.for_each(|(response, validator)| compare_validator_response(state, response, validator));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn get_active_validators() {
|
|
|
|
let mut env = build_env();
|
|
|
|
|
|
|
|
let node = build_node(&mut env, testing_client_config());
|
|
|
|
let remote_node = node.remote_node().expect("should produce remote node");
|
|
|
|
let chain = node
|
|
|
|
.client
|
|
|
|
.beacon_chain()
|
|
|
|
.expect("node should have beacon chain");
|
2020-01-06 06:30:37 +00:00
|
|
|
let state = &chain.head().expect("should get head").beacon_state;
|
2019-12-19 00:45:28 +00:00
|
|
|
|
|
|
|
let result = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(remote_node.http.beacon().get_active_validators(None))
|
|
|
|
.expect("should fetch from http api");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This test isn't comprehensive because all of the validators in the state are active (i.e.,
|
|
|
|
* there is no one to exclude.
|
|
|
|
*
|
|
|
|
* This should be fixed once we can generate more interesting scenarios with the
|
|
|
|
* `NodeTestRig`.
|
|
|
|
*/
|
|
|
|
|
|
|
|
let validators = state
|
|
|
|
.validators
|
|
|
|
.iter()
|
|
|
|
.filter(|validator| validator.is_active_at(state.current_epoch()));
|
|
|
|
|
|
|
|
result
|
|
|
|
.iter()
|
|
|
|
.zip(validators)
|
|
|
|
.for_each(|(response, validator)| compare_validator_response(state, response, validator));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn get_committees() {
|
|
|
|
let mut env = build_env();
|
|
|
|
|
|
|
|
let node = build_node(&mut env, testing_client_config());
|
|
|
|
let remote_node = node.remote_node().expect("should produce remote node");
|
|
|
|
let chain = node
|
|
|
|
.client
|
|
|
|
.beacon_chain()
|
|
|
|
.expect("node should have beacon chain");
|
|
|
|
|
|
|
|
let epoch = Epoch::new(0);
|
|
|
|
|
|
|
|
let result = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(remote_node.http.beacon().get_committees(epoch))
|
|
|
|
.expect("should fetch from http api");
|
|
|
|
|
|
|
|
let expected = chain
|
|
|
|
.head()
|
2020-01-06 06:30:37 +00:00
|
|
|
.expect("should get head")
|
2019-12-19 00:45:28 +00:00
|
|
|
.beacon_state
|
|
|
|
.get_beacon_committees_at_epoch(RelativeEpoch::Current)
|
|
|
|
.expect("should get committees")
|
|
|
|
.iter()
|
|
|
|
.map(|c| Committee {
|
|
|
|
slot: c.slot,
|
|
|
|
index: c.index,
|
|
|
|
committee: c.committee.to_vec(),
|
|
|
|
})
|
|
|
|
.collect::<Vec<_>>();
|
|
|
|
|
|
|
|
assert_eq!(result, expected, "result should be as expected");
|
|
|
|
}
|
|
|
|
|
2020-01-29 04:05:00 +00:00
|
|
|
#[test]
|
|
|
|
fn get_fork_choice() {
|
|
|
|
let mut env = build_env();
|
|
|
|
|
|
|
|
let node = build_node(&mut env, testing_client_config());
|
|
|
|
let remote_node = node.remote_node().expect("should produce remote node");
|
|
|
|
|
|
|
|
let fork_choice = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(remote_node.http.advanced().get_fork_choice())
|
|
|
|
.expect("should not error when getting fork choice");
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
fork_choice,
|
|
|
|
*node
|
|
|
|
.client
|
|
|
|
.beacon_chain()
|
|
|
|
.expect("node should have beacon chain")
|
|
|
|
.fork_choice
|
v0.12 fork choice update (#1229)
* Incomplete scraps
* Add progress on new fork choice impl
* Further progress
* First complete compiling version
* Remove chain reference
* Add new lmd_ghost crate
* Start integrating into beacon chain
* Update `milagro_bls` to new release (#1183)
* Update milagro_bls to new release
Signed-off-by: Kirk Baird <baird.k@outlook.com>
* Tidy up fake cryptos
Signed-off-by: Kirk Baird <baird.k@outlook.com>
* move SecretHash to bls and put plaintext back
Signed-off-by: Kirk Baird <baird.k@outlook.com>
* Update state processing for v0.12
* Fix EF test runners for v0.12
* Fix some tests
* Fix broken attestation verification test
* More test fixes
* Rough beacon chain impl working
* Remove fork_choice_2
* Remove checkpoint manager
* Half finished ssz impl
* Add missed file
* Add persistence
* Tidy, fix some compile errors
* Remove RwLock from ProtoArrayForkChoice
* Fix store-based compile errors
* Add comments, tidy
* Move function out of ForkChoice struct
* Start testing
* More testing
* Fix compile error
* Tidy beacon_chain::fork_choice
* Queue attestations from the current slot
* Allow fork choice to handle prior-to-genesis start
* Improve error granularity
* Test attestation dequeuing
* Process attestations during block
* Store target root in fork choice
* Move fork choice verification into new crate
* Update tests
* Consensus updates for v0.12 (#1228)
* Update state processing for v0.12
* Fix EF test runners for v0.12
* Fix some tests
* Fix broken attestation verification test
* More test fixes
* Fix typo found in review
* Add `Block` struct to ProtoArray
* Start fixing get_ancestor
* Add rough progress on testing
* Get fork choice tests working
* Progress with testing
* Fix partialeq impl
* Move slot clock from fc_store
* Improve testing
* Add testing for best justified
* Add clone back to SystemTimeSlotClock
* Add balances test
* Start adding balances cache again
* Wire-in balances cache
* Improve tests
* Remove commented-out tests
* Remove beacon_chain::ForkChoice
* Rename crates
* Update wider codebase to new fork_choice layout
* Move advance_slot in test harness
* Tidy ForkChoice::update_time
* Fix verification tests
* Fix compile error with iter::once
* Fix fork choice tests
* Ensure block attestations are processed
* Fix failing beacon_chain tests
* Add first invalid block check
* Add finalized block check
* Progress with testing, new store builder
* Add fixes to get_ancestor
* Fix old genesis justification test
* Fix remaining fork choice tests
* Change root iteration method
* Move on_verified_block
* Remove unused method
* Start adding attestation verification tests
* Add invalid ffg target test
* Add target epoch test
* Add queued attestation test
* Remove old fork choice verification tests
* Tidy, add test
* Move fork choice lock drop
* Rename BeaconForkChoiceStore
* Add comments, tidy BeaconForkChoiceStore
* Update metrics, rename fork_choice_store.rs
* Remove genesis_block_root from ForkChoice
* Tidy
* Update fork_choice comments
* Tidy, add comments
* Tidy, simplify ForkChoice, fix compile issue
* Tidy, removed dead file
* Increase http request timeout
* Fix failing rest_api test
* Set HTTP timeout back to 5s
* Apply fix to get_ancestor
* Address Michael's comments
* Fix typo
* Revert "Fix broken attestation verification test"
This reverts commit 722cdc903b12611de27916a57eeecfa3224f2279.
Co-authored-by: Kirk Baird <baird.k@outlook.com>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
2020-06-17 01:10:22 +00:00
|
|
|
.read()
|
|
|
|
.proto_array()
|
2020-01-29 04:05:00 +00:00
|
|
|
.core_proto_array(),
|
|
|
|
"result should be as expected"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-02-04 01:43:04 +00:00
|
|
|
#[test]
|
|
|
|
fn get_operation_pool() {
|
|
|
|
let mut env = build_env();
|
|
|
|
|
|
|
|
let node = build_node(&mut env, testing_client_config());
|
|
|
|
let remote_node = node.remote_node().expect("should produce remote node");
|
|
|
|
|
|
|
|
let result = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(remote_node.http.advanced().get_operation_pool())
|
|
|
|
.expect("should not error when getting fork choice");
|
|
|
|
|
|
|
|
let expected = PersistedOperationPool::from_operation_pool(
|
|
|
|
&node
|
|
|
|
.client
|
|
|
|
.beacon_chain()
|
|
|
|
.expect("node should have chain")
|
|
|
|
.op_pool,
|
|
|
|
);
|
|
|
|
|
|
|
|
assert_eq!(result, expected, "result should be as expected");
|
|
|
|
}
|
|
|
|
|
2019-12-19 00:45:28 +00:00
|
|
|
fn compare_validator_response<T: EthSpec>(
|
|
|
|
state: &BeaconState<T>,
|
|
|
|
response: &ValidatorResponse,
|
|
|
|
validator: &Validator,
|
|
|
|
) {
|
|
|
|
let response_validator = response.validator.clone().expect("should have validator");
|
|
|
|
let i = response
|
|
|
|
.validator_index
|
|
|
|
.expect("should have validator index");
|
|
|
|
let balance = response.balance.expect("should have balance");
|
|
|
|
|
|
|
|
assert_eq!(response.pubkey, validator.pubkey, "pubkey");
|
|
|
|
assert_eq!(response_validator, *validator, "validator");
|
|
|
|
assert_eq!(state.balances[i], balance, "balances");
|
|
|
|
assert_eq!(state.validators[i], *validator, "validator index");
|
|
|
|
}
|
2020-02-14 11:35:18 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn proposer_slashing() {
|
|
|
|
let mut env = build_env();
|
|
|
|
|
|
|
|
let node = build_node(&mut env, testing_client_config());
|
|
|
|
let remote_node = node.remote_node().expect("should produce remote node");
|
|
|
|
let chain = node
|
|
|
|
.client
|
|
|
|
.beacon_chain()
|
|
|
|
.expect("node should have beacon chain");
|
|
|
|
|
|
|
|
let state = chain
|
|
|
|
.head()
|
|
|
|
.expect("should have retrieved state")
|
|
|
|
.beacon_state;
|
|
|
|
|
|
|
|
let spec = &chain.spec;
|
|
|
|
|
|
|
|
// Check that there are no proposer slashings before insertion
|
2020-06-18 11:06:34 +00:00
|
|
|
let (proposer_slashings, _attester_slashings) = chain.op_pool.get_slashings(&state);
|
2020-02-14 11:35:18 +00:00
|
|
|
assert_eq!(proposer_slashings.len(), 0);
|
|
|
|
|
|
|
|
let slot = state.slot;
|
|
|
|
let proposer_index = chain
|
|
|
|
.block_proposer(slot)
|
|
|
|
.expect("should get proposer index");
|
|
|
|
let keypair = generate_deterministic_keypair(proposer_index);
|
|
|
|
let key = &keypair.sk;
|
|
|
|
let fork = &state.fork;
|
|
|
|
let proposer_slashing = build_proposer_slashing::<E>(
|
|
|
|
ProposerSlashingTestTask::Valid,
|
|
|
|
proposer_index as u64,
|
|
|
|
&key,
|
|
|
|
fork,
|
2020-04-01 11:03:03 +00:00
|
|
|
state.genesis_validators_root,
|
2020-02-14 11:35:18 +00:00
|
|
|
spec,
|
|
|
|
);
|
|
|
|
|
|
|
|
let result = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(
|
|
|
|
remote_node
|
|
|
|
.http
|
|
|
|
.beacon()
|
|
|
|
.proposer_slashing(proposer_slashing.clone()),
|
|
|
|
)
|
|
|
|
.expect("should fetch from http api");
|
|
|
|
assert!(result, true);
|
|
|
|
|
|
|
|
// Length should be just one as we've inserted only one proposer slashing
|
2020-06-18 11:06:34 +00:00
|
|
|
let (proposer_slashings, _attester_slashings) = chain.op_pool.get_slashings(&state);
|
2020-02-14 11:35:18 +00:00
|
|
|
assert_eq!(proposer_slashings.len(), 1);
|
|
|
|
assert_eq!(proposer_slashing.clone(), proposer_slashings[0]);
|
|
|
|
|
|
|
|
let mut invalid_proposer_slashing = build_proposer_slashing::<E>(
|
|
|
|
ProposerSlashingTestTask::Valid,
|
|
|
|
proposer_index as u64,
|
|
|
|
&key,
|
|
|
|
fork,
|
2020-04-01 11:03:03 +00:00
|
|
|
state.genesis_validators_root,
|
2020-02-14 11:35:18 +00:00
|
|
|
spec,
|
|
|
|
);
|
|
|
|
invalid_proposer_slashing.signed_header_2 = invalid_proposer_slashing.signed_header_1.clone();
|
|
|
|
|
|
|
|
let result = env.runtime().block_on(
|
|
|
|
remote_node
|
|
|
|
.http
|
|
|
|
.beacon()
|
|
|
|
.proposer_slashing(invalid_proposer_slashing),
|
|
|
|
);
|
|
|
|
assert!(result.is_err());
|
|
|
|
|
|
|
|
// Length should still be one as we've inserted nothing since last time.
|
2020-06-18 11:06:34 +00:00
|
|
|
let (proposer_slashings, _attester_slashings) = chain.op_pool.get_slashings(&state);
|
2020-02-14 11:35:18 +00:00
|
|
|
assert_eq!(proposer_slashings.len(), 1);
|
|
|
|
assert_eq!(proposer_slashing, proposer_slashings[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn attester_slashing() {
|
|
|
|
let mut env = build_env();
|
|
|
|
|
|
|
|
let node = build_node(&mut env, testing_client_config());
|
|
|
|
let remote_node = node.remote_node().expect("should produce remote node");
|
|
|
|
let chain = node
|
|
|
|
.client
|
|
|
|
.beacon_chain()
|
|
|
|
.expect("node should have beacon chain");
|
|
|
|
|
|
|
|
let state = chain
|
|
|
|
.head()
|
|
|
|
.expect("should have retrieved state")
|
|
|
|
.beacon_state;
|
|
|
|
let slot = state.slot;
|
|
|
|
let spec = &chain.spec;
|
|
|
|
|
|
|
|
let proposer_index = chain
|
|
|
|
.block_proposer(slot)
|
|
|
|
.expect("should get proposer index");
|
|
|
|
let keypair = generate_deterministic_keypair(proposer_index);
|
|
|
|
|
|
|
|
let secret_keys = vec![&keypair.sk];
|
|
|
|
let validator_indices = vec![proposer_index as u64];
|
|
|
|
let fork = &state.fork;
|
|
|
|
|
|
|
|
// Checking there are no attester slashings before insertion
|
2020-06-18 11:06:34 +00:00
|
|
|
let (_proposer_slashings, attester_slashings) = chain.op_pool.get_slashings(&state);
|
2020-02-14 11:35:18 +00:00
|
|
|
assert_eq!(attester_slashings.len(), 0);
|
|
|
|
|
|
|
|
let attester_slashing = build_double_vote_attester_slashing(
|
|
|
|
AttesterSlashingTestTask::Valid,
|
|
|
|
&validator_indices[..],
|
|
|
|
&secret_keys[..],
|
|
|
|
fork,
|
2020-04-01 11:03:03 +00:00
|
|
|
state.genesis_validators_root,
|
2020-02-14 11:35:18 +00:00
|
|
|
spec,
|
|
|
|
);
|
|
|
|
|
|
|
|
let result = env
|
|
|
|
.runtime()
|
|
|
|
.block_on(
|
|
|
|
remote_node
|
|
|
|
.http
|
|
|
|
.beacon()
|
|
|
|
.attester_slashing(attester_slashing.clone()),
|
|
|
|
)
|
|
|
|
.expect("should fetch from http api");
|
|
|
|
assert!(result, true);
|
|
|
|
|
|
|
|
// Length should be just one as we've inserted only one attester slashing
|
2020-06-18 11:06:34 +00:00
|
|
|
let (_proposer_slashings, attester_slashings) = chain.op_pool.get_slashings(&state);
|
2020-02-14 11:35:18 +00:00
|
|
|
assert_eq!(attester_slashings.len(), 1);
|
|
|
|
assert_eq!(attester_slashing, attester_slashings[0]);
|
|
|
|
|
|
|
|
// Building an invalid attester slashing
|
|
|
|
let mut invalid_attester_slashing = build_double_vote_attester_slashing(
|
|
|
|
AttesterSlashingTestTask::Valid,
|
|
|
|
&validator_indices[..],
|
|
|
|
&secret_keys[..],
|
|
|
|
fork,
|
2020-04-01 11:03:03 +00:00
|
|
|
state.genesis_validators_root,
|
2020-02-14 11:35:18 +00:00
|
|
|
spec,
|
|
|
|
);
|
|
|
|
invalid_attester_slashing.attestation_2 = invalid_attester_slashing.attestation_1.clone();
|
|
|
|
|
|
|
|
let result = env.runtime().block_on(
|
|
|
|
remote_node
|
|
|
|
.http
|
|
|
|
.beacon()
|
|
|
|
.attester_slashing(invalid_attester_slashing),
|
|
|
|
);
|
2020-06-18 11:06:34 +00:00
|
|
|
result.unwrap_err();
|
2020-02-14 11:35:18 +00:00
|
|
|
|
|
|
|
// Length should still be one as we've failed to insert the attester slashing.
|
2020-06-18 11:06:34 +00:00
|
|
|
let (_proposer_slashings, attester_slashings) = chain.op_pool.get_slashings(&state);
|
2020-02-14 11:35:18 +00:00
|
|
|
assert_eq!(attester_slashings.len(), 1);
|
|
|
|
assert_eq!(attester_slashing, attester_slashings[0]);
|
|
|
|
}
|
2020-05-25 00:25:08 +00:00
|
|
|
|
|
|
|
mod validator_attestation {
|
|
|
|
use super::*;
|
|
|
|
use http::StatusCode;
|
|
|
|
use node_test_rig::environment::Environment;
|
|
|
|
use remote_beacon_node::{Error::DidNotSucceed, HttpClient};
|
|
|
|
use types::{Attestation, AttestationDuty, MinimalEthSpec};
|
|
|
|
use url::Url;
|
|
|
|
|
|
|
|
fn setup() -> (
|
|
|
|
Environment<MinimalEthSpec>,
|
|
|
|
LocalBeaconNode<MinimalEthSpec>,
|
|
|
|
HttpClient<MinimalEthSpec>,
|
|
|
|
Url,
|
|
|
|
AttestationDuty,
|
|
|
|
) {
|
|
|
|
let mut env = build_env();
|
|
|
|
let node = build_node(&mut env, testing_client_config());
|
|
|
|
let remote_node = node.remote_node().expect("should produce remote node");
|
|
|
|
let client = remote_node.http.clone();
|
|
|
|
let socket_addr = node
|
|
|
|
.client
|
|
|
|
.http_listen_addr()
|
|
|
|
.expect("A remote beacon node must have a http server");
|
|
|
|
let url = Url::parse(&format!(
|
|
|
|
"http://{}:{}/validator/attestation",
|
|
|
|
socket_addr.ip(),
|
|
|
|
socket_addr.port()
|
|
|
|
))
|
|
|
|
.expect("should be valid endpoint");
|
|
|
|
|
|
|
|
// Find a validator that has duties in the current slot of the chain.
|
|
|
|
let mut validator_index = 0;
|
|
|
|
let beacon_chain = node
|
|
|
|
.client
|
|
|
|
.beacon_chain()
|
|
|
|
.expect("client should have beacon chain");
|
|
|
|
let state = beacon_chain.head().expect("should get head").beacon_state;
|
|
|
|
let duties = loop {
|
|
|
|
let duties = state
|
|
|
|
.get_attestation_duties(validator_index, RelativeEpoch::Current)
|
|
|
|
.expect("should have attestation duties cache")
|
|
|
|
.expect("should have attestation duties");
|
|
|
|
|
|
|
|
if duties.slot == node.client.beacon_chain().unwrap().slot().unwrap() {
|
|
|
|
break duties;
|
|
|
|
} else {
|
|
|
|
validator_index += 1
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
(env, node, client, url, duties)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn requires_query_parameters() {
|
|
|
|
let (mut env, _node, client, url, _duties) = setup();
|
|
|
|
|
|
|
|
let attestation = env.runtime().block_on(
|
|
|
|
// query parameters are missing
|
|
|
|
client.json_get::<Attestation<MinimalEthSpec>>(url.clone(), vec![]),
|
|
|
|
);
|
|
|
|
|
|
|
|
assert_matches!(
|
|
|
|
attestation.expect_err("should not succeed"),
|
|
|
|
DidNotSucceed { status, body } => {
|
|
|
|
assert_eq!(status, StatusCode::BAD_REQUEST);
|
|
|
|
assert_eq!(body, "URL query must be valid and contain at least one of the following keys: [\"slot\"]".to_owned());
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn requires_slot() {
|
|
|
|
let (mut env, _node, client, url, duties) = setup();
|
|
|
|
|
|
|
|
let attestation = env.runtime().block_on(
|
|
|
|
// `slot` is missing
|
|
|
|
client.json_get::<Attestation<MinimalEthSpec>>(
|
|
|
|
url.clone(),
|
|
|
|
vec![("committee_index".into(), format!("{}", duties.index))],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
assert_matches!(
|
|
|
|
attestation.expect_err("should not succeed"),
|
|
|
|
DidNotSucceed { status, body } => {
|
|
|
|
assert_eq!(status, StatusCode::BAD_REQUEST);
|
|
|
|
assert_eq!(body, "URL query must be valid and contain at least one of the following keys: [\"slot\"]".to_owned());
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn requires_committee_index() {
|
|
|
|
let (mut env, _node, client, url, duties) = setup();
|
|
|
|
|
|
|
|
let attestation = env.runtime().block_on(
|
|
|
|
// `committee_index` is missing.
|
|
|
|
client.json_get::<Attestation<MinimalEthSpec>>(
|
|
|
|
url.clone(),
|
|
|
|
vec![("slot".into(), format!("{}", duties.slot))],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
assert_matches!(
|
|
|
|
attestation.expect_err("should not succeed"),
|
|
|
|
DidNotSucceed { status, body } => {
|
|
|
|
assert_eq!(status, StatusCode::BAD_REQUEST);
|
|
|
|
assert_eq!(body, "URL query must be valid and contain at least one of the following keys: [\"committee_index\"]".to_owned());
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2020-05-28 01:24:24 +00:00
|
|
|
|
2020-06-01 11:18:31 +00:00
|
|
|
#[cfg(target_os = "linux")]
|
2020-05-28 01:24:24 +00:00
|
|
|
#[test]
|
|
|
|
fn get_health() {
|
|
|
|
let mut env = build_env();
|
|
|
|
|
|
|
|
let node = build_node(&mut env, testing_client_config());
|
|
|
|
let remote_node = node.remote_node().expect("should produce remote node");
|
|
|
|
|
|
|
|
env.runtime()
|
|
|
|
.block_on(remote_node.http.node().get_health())
|
|
|
|
.unwrap();
|
|
|
|
}
|