2019-08-06 12:56:13 +00:00
|
|
|
#![cfg(not(debug_assertions))]
|
2019-06-23 21:45:34 +00:00
|
|
|
|
2019-08-07 06:40:49 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate lazy_static;
|
|
|
|
|
2019-08-07 06:02:30 +00:00
|
|
|
use beacon_chain::AttestationProcessingOutcome;
|
2019-09-04 00:25:30 +00:00
|
|
|
use beacon_chain::{
|
|
|
|
test_utils::{
|
Eth1 Integration (#542)
* Refactor to cache Eth1Data
* Fix merge conflicts and minor refactorings
* Rename Eth1Cache to Eth1DataCache
* Refactor events subscription
* Add deposits module to interface with BeaconChain deposits
* Remove utils
* Rename to types.rs and add trait constraints to Eth1DataFetcher
* Confirm to trait constraints. Make Web3DataFetcher cloneable
* Make fetcher object member of deposit and eth1_data cache and other fixes
* Fix update_cache function
* Move fetch_eth1_data to impl block
* Fix deposit tests
* Create Eth1 object for interfacing with Beacon chain
* Add `run` function for running update_cache and subscribe_deposit_logs tasks
* Add logging
* Run `cargo fmt` and make tests pass
* Convert sync functions to async
* Add timeouts to web3 functions
* Return futures from cache functions
* Add failed chaining of futures
* Working cache updation
* Clean up tests and `update_cache` function
* Refactor `get_eth1_data` functions to work with future returning functions
* Refactor eth1 `run` function to work with modified `update_cache` api
* Minor changes
* Add distance parameter to `update_cache`
* Fix tests and other minor fixes
* Working integration with cache and deposits
* Add merkle_tree construction, proof generation and verification code
* Add function to construct and fetch Deposits for BeaconNode
* Add error handling
* Import ssz
* Add error handling to eth1 cache and fix minor errors
* Run rustfmt
* Fix minor bug
* Rename Eth1Error and change to Result<T>
* Change deposit fetching mechanism from notification based to poll based
* Add deposits from eth1 chain in a given range every `x` blocks
* Modify `run` function to accommodate changes
* Minor fixes
* Fix formatting
* Initial commit. web3 api working.
* Tidied up lib. Add function for fetching logs.
* Refactor with `Eth1DataFetcher` trait
* Add parsing for deposit contract logs and get_eth1_data function
* Add `get_eth1_votes` function
* Refactor to cache Eth1Data
* Fix merge conflicts and minor refactorings
* Rename Eth1Cache to Eth1DataCache
* Refactor events subscription
* Add deposits module to interface with BeaconChain deposits
* Remove utils
* Rename to types.rs and add trait constraints to Eth1DataFetcher
* Confirm to trait constraints. Make Web3DataFetcher cloneable
* Make fetcher object member of deposit and eth1_data cache and other fixes
* Fix update_cache function
* Move fetch_eth1_data to impl block
* Fix deposit tests
* Create Eth1 object for interfacing with Beacon chain
* Add `run` function for running update_cache and subscribe_deposit_logs tasks
* Add logging
* Run `cargo fmt` and make tests pass
* Convert sync functions to async
* Add timeouts to web3 functions
* Return futures from cache functions
* Add failed chaining of futures
* Working cache updation
* Clean up tests and `update_cache` function
* Refactor `get_eth1_data` functions to work with future returning functions
* Refactor eth1 `run` function to work with modified `update_cache` api
* Minor changes
* Add distance parameter to `update_cache`
* Fix tests and other minor fixes
* Working integration with cache and deposits
* Add merkle_tree construction, proof generation and verification code
* Add function to construct and fetch Deposits for BeaconNode
* Add error handling
* Import ssz
* Add error handling to eth1 cache and fix minor errors
* Run rustfmt
* Fix minor bug
* Rename Eth1Error and change to Result<T>
* Change deposit fetching mechanism from notification based to poll based
* Add deposits from eth1 chain in a given range every `x` blocks
* Modify `run` function to accommodate changes
* Minor fixes
* Fix formatting
* Fix merge issue
* Refactor with `Config` struct. Remote `ContractConfig`
* Rename eth1_chain crate to eth1
* Rename files and read abi file using `fs::read`
* Move eth1 to lib
* Remove unnecessary mutability constraint
* Add `Web3Backend` for returning actual eth1 data
* Refactor `get_eth1_votes` to return a Result
* Delete `eth1_chain` crate
* Return `Result` from `get_deposits`
* Fix range of deposits to return to beacon chain
* Add `get_block_height_by_hash` trait function
* Add naive method for getting `previous_eth1_distance`
* Add eth1 config params to main config
* Add instructions for setting up eth1 testing environment
* Add build script to fetch deposit contract abi
* Contract ABI is part of compiled binary
* Fix minor bugs
* Move docs to lib
* Add timeout to config
* Remove print statements
* Change warn to error
* Fix typos
* Removed prints in test and get timeout value from config
* Fixed error types
* Added logging to web3_fetcher
* Refactor for modified web3 api
* Fix minor stuff
* Add build script
* Tidy, hide eth1 integration tests behind flag
* Add http crate
* Add first stages of eth1_test_rig
* Fix deposits on test rig
* Fix bug with deposit count method
* Add block hash getter to http eth1
* Clean eth1 http crate and tests
* Add script to start ganache
* Adds deposit tree to eth1-http
* Extend deposit tree tests
* Tidy tests in eth1-http
* Add more detail to get block request
* Add block cache to eth1-http
* Rename deposit tree to deposit cache
* Add inital updating to eth1-http
* Tidy updater
* Fix compile bugs in tests
* Adds an Eth1DataCache builder
* Reorg eth1-http files
* Add (failing) tests for eth1 updater
* Rename files, fix bug in eth1-http
* Ensure that ganache timestamps are increasing
* Fix bugs with getting eth1data ancestors
* Improve eth1 testing, fix bugs
* Add truncate method to block cache
* Add pruning to block cache update process
* Add tests for block pruning
* Allow for dropping an expired cache.
* Add more comments
* Add first compiling version of deposit updater
* Add common fn for getting range of required blocks
* Add passing deposit update test
* Improve tests
* Fix block pruning bug
* Add tests for running two updates at once
* Add updater services to eth1
* Add deposit collection to beacon chain
* Add incomplete builder experiments
* Add first working version of beacon chain builder
* Update test harness to new beacon chain type
* Rename builder file, tidy
* Add first working client builder
* Progress further on client builder
* Update becaon node binary to use client builder
* Ensure release tests compile
* Remove old eth1 crate
* Add first pass of new lighthouse binary
* Fix websocket server startup
* Remove old binary code from beacon_node crate
* Add first working beacon node tests
* Add genesis crate, new eth1 cache_2
* Add Serivce to Eth1Cache
* Refactor with general eth1 improvements
* Add passing genesis test
* Tidy, add comments
* Add more comments to eth1 service
* Add further eth1 progress
* Fix some bugs with genesis
* Fix eth1 bugs, make eth1 linking more efficient
* Shift logic in genesis service
* Add more comments to genesis service
* Add gzip, max request values, timeouts to http
* Update testnet parameters to suit goerli testnet
* Add ability to vary Fork, fix custom spec
* Be more explicit about deposit fork version
* Start adding beacon chain eth1 option
* Add more flexibility to prod client
* Further runtime refactoring
* Allow for starting from store
* Add bootstrapping to client config
* Add remote_beacon_node crate
* Update eth1 service for more configurability
* Update eth1 tests to use less runtimes
* Patch issues with tests using too many files
* Move dummy eth1 backend flag
* Ensure all tests pass
* Add ganache-cli to Dockerfile
* Use a special docker hub image for testing
* Appease clippy
* Move validator client into lighthouse binary
* Allow starting with dummy eth1 backend
* Improve logging
* Fix dummy eth1 backend from cli
* Add extra testnet command
* Ensure consistent spec in beacon node
* Update eth1 rig to work on goerli
* Tidy lcli, start adding support for yaml config
* Add incomplete YamlConfig struct
* Remove efforts at YamlConfig
* Add incomplete eth1 voting. Blocked on spec issues
* Add (untested) first pass at eth1 vote algo
* Add tests for winning vote
* Add more tests for eth1 chain
* Add more eth1 voting tests
* Added more eth1 voting testing
* Change test name
* Add more tests to eth1 chain
* Tidy eth1 generics, add more tests
* Improve comments
* Tidy beacon_node tests
* Tidy, rename JsonRpc.. to Caching..
* Tidy voting logic
* Tidy builder docs
* Add comments, tidy eth1
* Add more comments to eth1
* Fix bug with winning_vote
* Add doc comments to the `ClientBuilder`
* Remove commented-out code
* Improve `ClientBuilder` docs
* Add comments to client config
* Add decoding test for `ClientConfig`
* Remove unused `DepositSet` struct
* Tidy `block_cache`
* Remove commented out lines
* Remove unused code in `eth1` crate
* Remove old validator binary `main.rs`
* Tidy, fix tests compile error
* Add initial tests for get_deposits
* Remove dead code in eth1_test_rig
* Update TestingDepositBuilder
* Add testing for getting eth1 deposits
* Fix duplicate rand dep
* Remove dead code
* Remove accidentally-added files
* Fix comment in eth1_genesis_service
* Add .gitignore for eth1_test_rig
* Fix bug in eth1_genesis_service
* Remove dead code from eth2_config
* Fix tabs/spaces in root Cargo.toml
* Tidy eth1 crate
* Allow for re-use of eth1 service after genesis
* Update docs for new CLI
* Change README gif
* Tidy eth1 http module
* Tidy eth1 service
* Tidy environment crate
* Remove unused file
* Tidy, add comments
* Remove commented-out code
* Address majority of Michael's comments
* Address other PR comments
* Add link to issue alongside TODO
2019-11-15 03:47:51 +00:00
|
|
|
AttestationStrategy, BeaconChainHarness, BlockStrategy, HarnessType, PersistedBeaconChain,
|
2019-09-04 00:25:30 +00:00
|
|
|
BEACON_CHAIN_DB_KEY,
|
|
|
|
},
|
|
|
|
BlockProcessingOutcome,
|
|
|
|
};
|
2019-12-09 10:17:57 +00:00
|
|
|
use state_processing::{
|
|
|
|
per_slot_processing, per_slot_processing::Error as SlotProcessingError, EpochProcessingError,
|
|
|
|
};
|
Eth1 Integration (#542)
* Refactor to cache Eth1Data
* Fix merge conflicts and minor refactorings
* Rename Eth1Cache to Eth1DataCache
* Refactor events subscription
* Add deposits module to interface with BeaconChain deposits
* Remove utils
* Rename to types.rs and add trait constraints to Eth1DataFetcher
* Confirm to trait constraints. Make Web3DataFetcher cloneable
* Make fetcher object member of deposit and eth1_data cache and other fixes
* Fix update_cache function
* Move fetch_eth1_data to impl block
* Fix deposit tests
* Create Eth1 object for interfacing with Beacon chain
* Add `run` function for running update_cache and subscribe_deposit_logs tasks
* Add logging
* Run `cargo fmt` and make tests pass
* Convert sync functions to async
* Add timeouts to web3 functions
* Return futures from cache functions
* Add failed chaining of futures
* Working cache updation
* Clean up tests and `update_cache` function
* Refactor `get_eth1_data` functions to work with future returning functions
* Refactor eth1 `run` function to work with modified `update_cache` api
* Minor changes
* Add distance parameter to `update_cache`
* Fix tests and other minor fixes
* Working integration with cache and deposits
* Add merkle_tree construction, proof generation and verification code
* Add function to construct and fetch Deposits for BeaconNode
* Add error handling
* Import ssz
* Add error handling to eth1 cache and fix minor errors
* Run rustfmt
* Fix minor bug
* Rename Eth1Error and change to Result<T>
* Change deposit fetching mechanism from notification based to poll based
* Add deposits from eth1 chain in a given range every `x` blocks
* Modify `run` function to accommodate changes
* Minor fixes
* Fix formatting
* Initial commit. web3 api working.
* Tidied up lib. Add function for fetching logs.
* Refactor with `Eth1DataFetcher` trait
* Add parsing for deposit contract logs and get_eth1_data function
* Add `get_eth1_votes` function
* Refactor to cache Eth1Data
* Fix merge conflicts and minor refactorings
* Rename Eth1Cache to Eth1DataCache
* Refactor events subscription
* Add deposits module to interface with BeaconChain deposits
* Remove utils
* Rename to types.rs and add trait constraints to Eth1DataFetcher
* Confirm to trait constraints. Make Web3DataFetcher cloneable
* Make fetcher object member of deposit and eth1_data cache and other fixes
* Fix update_cache function
* Move fetch_eth1_data to impl block
* Fix deposit tests
* Create Eth1 object for interfacing with Beacon chain
* Add `run` function for running update_cache and subscribe_deposit_logs tasks
* Add logging
* Run `cargo fmt` and make tests pass
* Convert sync functions to async
* Add timeouts to web3 functions
* Return futures from cache functions
* Add failed chaining of futures
* Working cache updation
* Clean up tests and `update_cache` function
* Refactor `get_eth1_data` functions to work with future returning functions
* Refactor eth1 `run` function to work with modified `update_cache` api
* Minor changes
* Add distance parameter to `update_cache`
* Fix tests and other minor fixes
* Working integration with cache and deposits
* Add merkle_tree construction, proof generation and verification code
* Add function to construct and fetch Deposits for BeaconNode
* Add error handling
* Import ssz
* Add error handling to eth1 cache and fix minor errors
* Run rustfmt
* Fix minor bug
* Rename Eth1Error and change to Result<T>
* Change deposit fetching mechanism from notification based to poll based
* Add deposits from eth1 chain in a given range every `x` blocks
* Modify `run` function to accommodate changes
* Minor fixes
* Fix formatting
* Fix merge issue
* Refactor with `Config` struct. Remote `ContractConfig`
* Rename eth1_chain crate to eth1
* Rename files and read abi file using `fs::read`
* Move eth1 to lib
* Remove unnecessary mutability constraint
* Add `Web3Backend` for returning actual eth1 data
* Refactor `get_eth1_votes` to return a Result
* Delete `eth1_chain` crate
* Return `Result` from `get_deposits`
* Fix range of deposits to return to beacon chain
* Add `get_block_height_by_hash` trait function
* Add naive method for getting `previous_eth1_distance`
* Add eth1 config params to main config
* Add instructions for setting up eth1 testing environment
* Add build script to fetch deposit contract abi
* Contract ABI is part of compiled binary
* Fix minor bugs
* Move docs to lib
* Add timeout to config
* Remove print statements
* Change warn to error
* Fix typos
* Removed prints in test and get timeout value from config
* Fixed error types
* Added logging to web3_fetcher
* Refactor for modified web3 api
* Fix minor stuff
* Add build script
* Tidy, hide eth1 integration tests behind flag
* Add http crate
* Add first stages of eth1_test_rig
* Fix deposits on test rig
* Fix bug with deposit count method
* Add block hash getter to http eth1
* Clean eth1 http crate and tests
* Add script to start ganache
* Adds deposit tree to eth1-http
* Extend deposit tree tests
* Tidy tests in eth1-http
* Add more detail to get block request
* Add block cache to eth1-http
* Rename deposit tree to deposit cache
* Add inital updating to eth1-http
* Tidy updater
* Fix compile bugs in tests
* Adds an Eth1DataCache builder
* Reorg eth1-http files
* Add (failing) tests for eth1 updater
* Rename files, fix bug in eth1-http
* Ensure that ganache timestamps are increasing
* Fix bugs with getting eth1data ancestors
* Improve eth1 testing, fix bugs
* Add truncate method to block cache
* Add pruning to block cache update process
* Add tests for block pruning
* Allow for dropping an expired cache.
* Add more comments
* Add first compiling version of deposit updater
* Add common fn for getting range of required blocks
* Add passing deposit update test
* Improve tests
* Fix block pruning bug
* Add tests for running two updates at once
* Add updater services to eth1
* Add deposit collection to beacon chain
* Add incomplete builder experiments
* Add first working version of beacon chain builder
* Update test harness to new beacon chain type
* Rename builder file, tidy
* Add first working client builder
* Progress further on client builder
* Update becaon node binary to use client builder
* Ensure release tests compile
* Remove old eth1 crate
* Add first pass of new lighthouse binary
* Fix websocket server startup
* Remove old binary code from beacon_node crate
* Add first working beacon node tests
* Add genesis crate, new eth1 cache_2
* Add Serivce to Eth1Cache
* Refactor with general eth1 improvements
* Add passing genesis test
* Tidy, add comments
* Add more comments to eth1 service
* Add further eth1 progress
* Fix some bugs with genesis
* Fix eth1 bugs, make eth1 linking more efficient
* Shift logic in genesis service
* Add more comments to genesis service
* Add gzip, max request values, timeouts to http
* Update testnet parameters to suit goerli testnet
* Add ability to vary Fork, fix custom spec
* Be more explicit about deposit fork version
* Start adding beacon chain eth1 option
* Add more flexibility to prod client
* Further runtime refactoring
* Allow for starting from store
* Add bootstrapping to client config
* Add remote_beacon_node crate
* Update eth1 service for more configurability
* Update eth1 tests to use less runtimes
* Patch issues with tests using too many files
* Move dummy eth1 backend flag
* Ensure all tests pass
* Add ganache-cli to Dockerfile
* Use a special docker hub image for testing
* Appease clippy
* Move validator client into lighthouse binary
* Allow starting with dummy eth1 backend
* Improve logging
* Fix dummy eth1 backend from cli
* Add extra testnet command
* Ensure consistent spec in beacon node
* Update eth1 rig to work on goerli
* Tidy lcli, start adding support for yaml config
* Add incomplete YamlConfig struct
* Remove efforts at YamlConfig
* Add incomplete eth1 voting. Blocked on spec issues
* Add (untested) first pass at eth1 vote algo
* Add tests for winning vote
* Add more tests for eth1 chain
* Add more eth1 voting tests
* Added more eth1 voting testing
* Change test name
* Add more tests to eth1 chain
* Tidy eth1 generics, add more tests
* Improve comments
* Tidy beacon_node tests
* Tidy, rename JsonRpc.. to Caching..
* Tidy voting logic
* Tidy builder docs
* Add comments, tidy eth1
* Add more comments to eth1
* Fix bug with winning_vote
* Add doc comments to the `ClientBuilder`
* Remove commented-out code
* Improve `ClientBuilder` docs
* Add comments to client config
* Add decoding test for `ClientConfig`
* Remove unused `DepositSet` struct
* Tidy `block_cache`
* Remove commented out lines
* Remove unused code in `eth1` crate
* Remove old validator binary `main.rs`
* Tidy, fix tests compile error
* Add initial tests for get_deposits
* Remove dead code in eth1_test_rig
* Update TestingDepositBuilder
* Add testing for getting eth1 deposits
* Fix duplicate rand dep
* Remove dead code
* Remove accidentally-added files
* Fix comment in eth1_genesis_service
* Add .gitignore for eth1_test_rig
* Fix bug in eth1_genesis_service
* Remove dead code from eth2_config
* Fix tabs/spaces in root Cargo.toml
* Tidy eth1 crate
* Allow for re-use of eth1 service after genesis
* Update docs for new CLI
* Change README gif
* Tidy eth1 http module
* Tidy eth1 service
* Tidy environment crate
* Remove unused file
* Tidy, add comments
* Remove commented-out code
* Address majority of Michael's comments
* Address other PR comments
* Add link to issue alongside TODO
2019-11-15 03:47:51 +00:00
|
|
|
use store::Store;
|
2019-12-16 23:37:12 +00:00
|
|
|
use types::{BeaconStateError, EthSpec, Hash256, Keypair, MinimalEthSpec, RelativeEpoch, Slot};
|
2019-06-23 04:47:23 +00:00
|
|
|
|
|
|
|
// Should ideally be divisible by 3.
|
|
|
|
pub const VALIDATOR_COUNT: usize = 24;
|
|
|
|
|
2019-08-07 06:40:49 +00:00
|
|
|
lazy_static! {
|
|
|
|
/// A cached set of keys.
|
|
|
|
static ref KEYPAIRS: Vec<Keypair> = types::test_utils::generate_deterministic_keypairs(VALIDATOR_COUNT);
|
|
|
|
}
|
|
|
|
|
Eth1 Integration (#542)
* Refactor to cache Eth1Data
* Fix merge conflicts and minor refactorings
* Rename Eth1Cache to Eth1DataCache
* Refactor events subscription
* Add deposits module to interface with BeaconChain deposits
* Remove utils
* Rename to types.rs and add trait constraints to Eth1DataFetcher
* Confirm to trait constraints. Make Web3DataFetcher cloneable
* Make fetcher object member of deposit and eth1_data cache and other fixes
* Fix update_cache function
* Move fetch_eth1_data to impl block
* Fix deposit tests
* Create Eth1 object for interfacing with Beacon chain
* Add `run` function for running update_cache and subscribe_deposit_logs tasks
* Add logging
* Run `cargo fmt` and make tests pass
* Convert sync functions to async
* Add timeouts to web3 functions
* Return futures from cache functions
* Add failed chaining of futures
* Working cache updation
* Clean up tests and `update_cache` function
* Refactor `get_eth1_data` functions to work with future returning functions
* Refactor eth1 `run` function to work with modified `update_cache` api
* Minor changes
* Add distance parameter to `update_cache`
* Fix tests and other minor fixes
* Working integration with cache and deposits
* Add merkle_tree construction, proof generation and verification code
* Add function to construct and fetch Deposits for BeaconNode
* Add error handling
* Import ssz
* Add error handling to eth1 cache and fix minor errors
* Run rustfmt
* Fix minor bug
* Rename Eth1Error and change to Result<T>
* Change deposit fetching mechanism from notification based to poll based
* Add deposits from eth1 chain in a given range every `x` blocks
* Modify `run` function to accommodate changes
* Minor fixes
* Fix formatting
* Initial commit. web3 api working.
* Tidied up lib. Add function for fetching logs.
* Refactor with `Eth1DataFetcher` trait
* Add parsing for deposit contract logs and get_eth1_data function
* Add `get_eth1_votes` function
* Refactor to cache Eth1Data
* Fix merge conflicts and minor refactorings
* Rename Eth1Cache to Eth1DataCache
* Refactor events subscription
* Add deposits module to interface with BeaconChain deposits
* Remove utils
* Rename to types.rs and add trait constraints to Eth1DataFetcher
* Confirm to trait constraints. Make Web3DataFetcher cloneable
* Make fetcher object member of deposit and eth1_data cache and other fixes
* Fix update_cache function
* Move fetch_eth1_data to impl block
* Fix deposit tests
* Create Eth1 object for interfacing with Beacon chain
* Add `run` function for running update_cache and subscribe_deposit_logs tasks
* Add logging
* Run `cargo fmt` and make tests pass
* Convert sync functions to async
* Add timeouts to web3 functions
* Return futures from cache functions
* Add failed chaining of futures
* Working cache updation
* Clean up tests and `update_cache` function
* Refactor `get_eth1_data` functions to work with future returning functions
* Refactor eth1 `run` function to work with modified `update_cache` api
* Minor changes
* Add distance parameter to `update_cache`
* Fix tests and other minor fixes
* Working integration with cache and deposits
* Add merkle_tree construction, proof generation and verification code
* Add function to construct and fetch Deposits for BeaconNode
* Add error handling
* Import ssz
* Add error handling to eth1 cache and fix minor errors
* Run rustfmt
* Fix minor bug
* Rename Eth1Error and change to Result<T>
* Change deposit fetching mechanism from notification based to poll based
* Add deposits from eth1 chain in a given range every `x` blocks
* Modify `run` function to accommodate changes
* Minor fixes
* Fix formatting
* Fix merge issue
* Refactor with `Config` struct. Remote `ContractConfig`
* Rename eth1_chain crate to eth1
* Rename files and read abi file using `fs::read`
* Move eth1 to lib
* Remove unnecessary mutability constraint
* Add `Web3Backend` for returning actual eth1 data
* Refactor `get_eth1_votes` to return a Result
* Delete `eth1_chain` crate
* Return `Result` from `get_deposits`
* Fix range of deposits to return to beacon chain
* Add `get_block_height_by_hash` trait function
* Add naive method for getting `previous_eth1_distance`
* Add eth1 config params to main config
* Add instructions for setting up eth1 testing environment
* Add build script to fetch deposit contract abi
* Contract ABI is part of compiled binary
* Fix minor bugs
* Move docs to lib
* Add timeout to config
* Remove print statements
* Change warn to error
* Fix typos
* Removed prints in test and get timeout value from config
* Fixed error types
* Added logging to web3_fetcher
* Refactor for modified web3 api
* Fix minor stuff
* Add build script
* Tidy, hide eth1 integration tests behind flag
* Add http crate
* Add first stages of eth1_test_rig
* Fix deposits on test rig
* Fix bug with deposit count method
* Add block hash getter to http eth1
* Clean eth1 http crate and tests
* Add script to start ganache
* Adds deposit tree to eth1-http
* Extend deposit tree tests
* Tidy tests in eth1-http
* Add more detail to get block request
* Add block cache to eth1-http
* Rename deposit tree to deposit cache
* Add inital updating to eth1-http
* Tidy updater
* Fix compile bugs in tests
* Adds an Eth1DataCache builder
* Reorg eth1-http files
* Add (failing) tests for eth1 updater
* Rename files, fix bug in eth1-http
* Ensure that ganache timestamps are increasing
* Fix bugs with getting eth1data ancestors
* Improve eth1 testing, fix bugs
* Add truncate method to block cache
* Add pruning to block cache update process
* Add tests for block pruning
* Allow for dropping an expired cache.
* Add more comments
* Add first compiling version of deposit updater
* Add common fn for getting range of required blocks
* Add passing deposit update test
* Improve tests
* Fix block pruning bug
* Add tests for running two updates at once
* Add updater services to eth1
* Add deposit collection to beacon chain
* Add incomplete builder experiments
* Add first working version of beacon chain builder
* Update test harness to new beacon chain type
* Rename builder file, tidy
* Add first working client builder
* Progress further on client builder
* Update becaon node binary to use client builder
* Ensure release tests compile
* Remove old eth1 crate
* Add first pass of new lighthouse binary
* Fix websocket server startup
* Remove old binary code from beacon_node crate
* Add first working beacon node tests
* Add genesis crate, new eth1 cache_2
* Add Serivce to Eth1Cache
* Refactor with general eth1 improvements
* Add passing genesis test
* Tidy, add comments
* Add more comments to eth1 service
* Add further eth1 progress
* Fix some bugs with genesis
* Fix eth1 bugs, make eth1 linking more efficient
* Shift logic in genesis service
* Add more comments to genesis service
* Add gzip, max request values, timeouts to http
* Update testnet parameters to suit goerli testnet
* Add ability to vary Fork, fix custom spec
* Be more explicit about deposit fork version
* Start adding beacon chain eth1 option
* Add more flexibility to prod client
* Further runtime refactoring
* Allow for starting from store
* Add bootstrapping to client config
* Add remote_beacon_node crate
* Update eth1 service for more configurability
* Update eth1 tests to use less runtimes
* Patch issues with tests using too many files
* Move dummy eth1 backend flag
* Ensure all tests pass
* Add ganache-cli to Dockerfile
* Use a special docker hub image for testing
* Appease clippy
* Move validator client into lighthouse binary
* Allow starting with dummy eth1 backend
* Improve logging
* Fix dummy eth1 backend from cli
* Add extra testnet command
* Ensure consistent spec in beacon node
* Update eth1 rig to work on goerli
* Tidy lcli, start adding support for yaml config
* Add incomplete YamlConfig struct
* Remove efforts at YamlConfig
* Add incomplete eth1 voting. Blocked on spec issues
* Add (untested) first pass at eth1 vote algo
* Add tests for winning vote
* Add more tests for eth1 chain
* Add more eth1 voting tests
* Added more eth1 voting testing
* Change test name
* Add more tests to eth1 chain
* Tidy eth1 generics, add more tests
* Improve comments
* Tidy beacon_node tests
* Tidy, rename JsonRpc.. to Caching..
* Tidy voting logic
* Tidy builder docs
* Add comments, tidy eth1
* Add more comments to eth1
* Fix bug with winning_vote
* Add doc comments to the `ClientBuilder`
* Remove commented-out code
* Improve `ClientBuilder` docs
* Add comments to client config
* Add decoding test for `ClientConfig`
* Remove unused `DepositSet` struct
* Tidy `block_cache`
* Remove commented out lines
* Remove unused code in `eth1` crate
* Remove old validator binary `main.rs`
* Tidy, fix tests compile error
* Add initial tests for get_deposits
* Remove dead code in eth1_test_rig
* Update TestingDepositBuilder
* Add testing for getting eth1 deposits
* Fix duplicate rand dep
* Remove dead code
* Remove accidentally-added files
* Fix comment in eth1_genesis_service
* Add .gitignore for eth1_test_rig
* Fix bug in eth1_genesis_service
* Remove dead code from eth2_config
* Fix tabs/spaces in root Cargo.toml
* Tidy eth1 crate
* Allow for re-use of eth1 service after genesis
* Update docs for new CLI
* Change README gif
* Tidy eth1 http module
* Tidy eth1 service
* Tidy environment crate
* Remove unused file
* Tidy, add comments
* Remove commented-out code
* Address majority of Michael's comments
* Address other PR comments
* Add link to issue alongside TODO
2019-11-15 03:47:51 +00:00
|
|
|
fn get_harness(validator_count: usize) -> BeaconChainHarness<HarnessType<MinimalEthSpec>> {
|
|
|
|
let harness = BeaconChainHarness::new(MinimalEthSpec, KEYPAIRS[0..validator_count].to_vec());
|
2019-06-23 04:47:23 +00:00
|
|
|
|
|
|
|
harness.advance_slot();
|
|
|
|
|
|
|
|
harness
|
|
|
|
}
|
|
|
|
|
2019-12-09 10:17:57 +00:00
|
|
|
#[test]
|
|
|
|
fn massive_skips() {
|
|
|
|
let harness = get_harness(8);
|
|
|
|
let spec = &MinimalEthSpec::default_spec();
|
2020-01-06 06:30:37 +00:00
|
|
|
let mut state = harness.chain.head().expect("should get head").beacon_state;
|
2019-12-09 10:17:57 +00:00
|
|
|
|
|
|
|
// Run per_slot_processing until it returns an error.
|
|
|
|
let error = loop {
|
2020-01-03 04:09:00 +00:00
|
|
|
match per_slot_processing(&mut state, None, spec) {
|
2019-12-09 10:17:57 +00:00
|
|
|
Ok(_) => continue,
|
|
|
|
Err(e) => break e,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
assert!(state.slot > 1, "the state should skip at least one slot");
|
|
|
|
assert_eq!(
|
|
|
|
error,
|
|
|
|
SlotProcessingError::EpochProcessingError(EpochProcessingError::BeaconStateError(
|
|
|
|
BeaconStateError::InsufficientValidators
|
|
|
|
)),
|
|
|
|
"should return error indicating that validators have been slashed out"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2019-08-08 06:47:24 +00:00
|
|
|
#[test]
|
|
|
|
fn iterators() {
|
|
|
|
let num_blocks_produced = MinimalEthSpec::slots_per_epoch() * 2 - 1;
|
|
|
|
|
|
|
|
let harness = get_harness(VALIDATOR_COUNT);
|
|
|
|
|
|
|
|
harness.extend_chain(
|
|
|
|
num_blocks_produced as usize,
|
|
|
|
BlockStrategy::OnCanonicalHead,
|
|
|
|
// No need to produce attestations for this test.
|
|
|
|
AttestationStrategy::SomeValidators(vec![]),
|
|
|
|
);
|
|
|
|
|
2020-01-06 06:30:37 +00:00
|
|
|
let block_roots: Vec<(Hash256, Slot)> = harness
|
|
|
|
.chain
|
|
|
|
.rev_iter_block_roots()
|
|
|
|
.expect("should get iter")
|
|
|
|
.collect();
|
|
|
|
let state_roots: Vec<(Hash256, Slot)> = harness
|
|
|
|
.chain
|
|
|
|
.rev_iter_state_roots()
|
|
|
|
.expect("should get iter")
|
|
|
|
.collect();
|
2019-08-08 06:47:24 +00:00
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
block_roots.len(),
|
|
|
|
state_roots.len(),
|
|
|
|
"should be an equal amount of block and state roots"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert!(
|
|
|
|
block_roots.iter().any(|(_root, slot)| *slot == 0),
|
|
|
|
"should contain genesis block root"
|
|
|
|
);
|
|
|
|
assert!(
|
|
|
|
state_roots.iter().any(|(_root, slot)| *slot == 0),
|
|
|
|
"should contain genesis state root"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
block_roots.len(),
|
|
|
|
num_blocks_produced as usize + 1,
|
|
|
|
"should contain all produced blocks, plus the genesis block"
|
|
|
|
);
|
|
|
|
|
|
|
|
block_roots.windows(2).for_each(|x| {
|
|
|
|
assert_eq!(
|
|
|
|
x[1].1,
|
|
|
|
x[0].1 - 1,
|
|
|
|
"block root slots should be decreasing by one"
|
|
|
|
)
|
|
|
|
});
|
|
|
|
state_roots.windows(2).for_each(|x| {
|
|
|
|
assert_eq!(
|
|
|
|
x[1].1,
|
|
|
|
x[0].1 - 1,
|
|
|
|
"state root slots should be decreasing by one"
|
|
|
|
)
|
|
|
|
});
|
|
|
|
|
2020-01-06 06:30:37 +00:00
|
|
|
let head = &harness.chain.head().expect("should get head");
|
2019-08-08 06:47:24 +00:00
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
*block_roots.first().expect("should have some block roots"),
|
2020-02-10 23:19:36 +00:00
|
|
|
(head.beacon_block_root, head.beacon_block.slot()),
|
2019-08-08 06:47:24 +00:00
|
|
|
"first block root and slot should be for the head block"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
*state_roots.first().expect("should have some state roots"),
|
|
|
|
(head.beacon_state_root, head.beacon_state.slot),
|
|
|
|
"first state root and slot should be for the head state"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-06-23 04:47:23 +00:00
|
|
|
#[test]
|
2019-07-29 02:08:52 +00:00
|
|
|
fn chooses_fork() {
|
2019-06-23 04:47:23 +00:00
|
|
|
let harness = get_harness(VALIDATOR_COUNT);
|
|
|
|
|
|
|
|
let two_thirds = (VALIDATOR_COUNT / 3) * 2;
|
|
|
|
let delay = MinimalEthSpec::default_spec().min_attestation_inclusion_delay as usize;
|
|
|
|
|
|
|
|
let honest_validators: Vec<usize> = (0..two_thirds).collect();
|
|
|
|
let faulty_validators: Vec<usize> = (two_thirds..VALIDATOR_COUNT).collect();
|
|
|
|
|
|
|
|
let initial_blocks = delay + 1;
|
|
|
|
let honest_fork_blocks = delay + 1;
|
|
|
|
let faulty_fork_blocks = delay + 2;
|
|
|
|
|
2019-06-24 05:31:36 +00:00
|
|
|
// Build an initial chain where all validators agree.
|
2019-06-23 04:47:23 +00:00
|
|
|
harness.extend_chain(
|
|
|
|
initial_blocks,
|
|
|
|
BlockStrategy::OnCanonicalHead,
|
|
|
|
AttestationStrategy::AllValidators,
|
|
|
|
);
|
|
|
|
|
2019-07-29 02:08:52 +00:00
|
|
|
let (honest_head, faulty_head) = harness.generate_two_forks_by_skipping_a_block(
|
|
|
|
&honest_validators,
|
|
|
|
&faulty_validators,
|
2019-06-23 04:47:23 +00:00
|
|
|
honest_fork_blocks,
|
|
|
|
faulty_fork_blocks,
|
|
|
|
);
|
|
|
|
|
|
|
|
assert!(honest_head != faulty_head, "forks should be distinct");
|
|
|
|
|
2020-01-06 06:30:37 +00:00
|
|
|
let state = &harness.chain.head().expect("should get head").beacon_state;
|
2019-06-23 04:47:23 +00:00
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
state.slot,
|
|
|
|
Slot::from(initial_blocks + honest_fork_blocks),
|
|
|
|
"head should be at the current slot"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert_eq!(
|
2020-01-06 06:30:37 +00:00
|
|
|
harness
|
|
|
|
.chain
|
|
|
|
.head()
|
|
|
|
.expect("should get head")
|
|
|
|
.beacon_block_root,
|
2019-06-23 04:47:23 +00:00
|
|
|
honest_head,
|
|
|
|
"the honest chain should be the canonical chain"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn finalizes_with_full_participation() {
|
|
|
|
let num_blocks_produced = MinimalEthSpec::slots_per_epoch() * 5;
|
|
|
|
|
|
|
|
let harness = get_harness(VALIDATOR_COUNT);
|
|
|
|
|
|
|
|
harness.extend_chain(
|
|
|
|
num_blocks_produced as usize,
|
|
|
|
BlockStrategy::OnCanonicalHead,
|
|
|
|
AttestationStrategy::AllValidators,
|
|
|
|
);
|
|
|
|
|
2020-01-06 06:30:37 +00:00
|
|
|
let state = &harness.chain.head().expect("should get head").beacon_state;
|
2019-06-23 04:47:23 +00:00
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
state.slot, num_blocks_produced,
|
|
|
|
"head should be at the current slot"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
state.current_epoch(),
|
|
|
|
num_blocks_produced / MinimalEthSpec::slots_per_epoch(),
|
|
|
|
"head should be at the expected epoch"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
Update to frozen spec ❄️ (v0.8.1) (#444)
* types: first updates for v0.8
* state_processing: epoch processing v0.8.0
* state_processing: block processing v0.8.0
* tree_hash_derive: support generics in SignedRoot
* types v0.8: update to use ssz_types
* state_processing v0.8: use ssz_types
* ssz_types: add bitwise methods and from_elem
* types: fix v0.8 FIXMEs
* ssz_types: add bitfield shift_up
* ssz_types: iterators and DerefMut for VariableList
* types,state_processing: use VariableList
* ssz_types: fix BitVector Decode impl
Fixed a typo in the implementation of ssz::Decode for BitVector, which caused it
to be considered variable length!
* types: fix test modules for v0.8 update
* types: remove slow type-level arithmetic
* state_processing: fix tests for v0.8
* op_pool: update for v0.8
* ssz_types: Bitfield difference length-independent
Allow computing the difference of two bitfields of different lengths.
* Implement compact committee support
* epoch_processing: committee & active index roots
* state_processing: genesis state builder v0.8
* state_processing: implement v0.8.1
* Further improve tree_hash
* Strip examples, tests from cached_tree_hash
* Update TreeHash, un-impl CachedTreeHash
* Update bitfield TreeHash, un-impl CachedTreeHash
* Update FixedLenVec TreeHash, unimpl CachedTreeHash
* Update update tree_hash_derive for new TreeHash
* Fix TreeHash, un-impl CachedTreeHash for ssz_types
* Remove fixed_len_vec, ssz benches
SSZ benches relied upon fixed_len_vec -- it is easier to just delete
them and rebuild them later (when necessary)
* Remove boolean_bitfield crate
* Fix fake_crypto BLS compile errors
* Update ef_tests for new v.8 type params
* Update ef_tests submodule to v0.8.1 tag
* Make fixes to support parsing ssz ef_tests
* `compact_committee...` to `compact_committees...`
* Derive more traits for `CompactCommittee`
* Flip bitfield byte-endianness
* Fix tree_hash for bitfields
* Modify CLI output for ef_tests
* Bump ssz crate version
* Update ssz_types doc comment
* Del cached tree hash tests from ssz_static tests
* Tidy SSZ dependencies
* Rename ssz_types crate to eth2_ssz_types
* validator_client: update for v0.8
* ssz_types: update union/difference for bit order swap
* beacon_node: update for v0.8, EthSpec
* types: disable cached tree hash, update min spec
* state_processing: fix slot bug in committee update
* tests: temporarily disable fork choice harness test
See #447
* committee cache: prevent out-of-bounds access
In the case where we tried to access the committee of a shard that didn't have a committee in the
current epoch, we were accessing elements beyond the end of the shuffling vector and panicking! This
commit adds a check to make the failure safe and explicit.
* fix bug in get_indexed_attestation and simplify
There was a bug in our implementation of get_indexed_attestation whereby
incorrect "committee indices" were used to index into the custody bitfield. The
bug was only observable in the case where some bits of the custody bitfield were
set to 1. The implementation has been simplified to remove the bug, and a test
added.
* state_proc: workaround for compact committees bug
https://github.com/ethereum/eth2.0-specs/issues/1315
* v0.8: updates to make the EF tests pass
* Remove redundant max operation checks.
* Always supply both messages when checking attestation signatures -- allowing
verification of an attestation with no signatures.
* Swap the order of the fork and domain constant in `get_domain`, to match
the spec.
* rustfmt
* ef_tests: add new epoch processing tests
* Integrate v0.8 into master (compiles)
* Remove unused crates, fix clippy lints
* Replace v0.6.3 tags w/ v0.8.1
* Remove old comment
* Ensure lmd ghost tests only run in release
* Update readme
2019-07-30 02:44:51 +00:00
|
|
|
state.current_justified_checkpoint.epoch,
|
2019-06-23 04:47:23 +00:00
|
|
|
state.current_epoch() - 1,
|
|
|
|
"the head should be justified one behind the current epoch"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
Update to frozen spec ❄️ (v0.8.1) (#444)
* types: first updates for v0.8
* state_processing: epoch processing v0.8.0
* state_processing: block processing v0.8.0
* tree_hash_derive: support generics in SignedRoot
* types v0.8: update to use ssz_types
* state_processing v0.8: use ssz_types
* ssz_types: add bitwise methods and from_elem
* types: fix v0.8 FIXMEs
* ssz_types: add bitfield shift_up
* ssz_types: iterators and DerefMut for VariableList
* types,state_processing: use VariableList
* ssz_types: fix BitVector Decode impl
Fixed a typo in the implementation of ssz::Decode for BitVector, which caused it
to be considered variable length!
* types: fix test modules for v0.8 update
* types: remove slow type-level arithmetic
* state_processing: fix tests for v0.8
* op_pool: update for v0.8
* ssz_types: Bitfield difference length-independent
Allow computing the difference of two bitfields of different lengths.
* Implement compact committee support
* epoch_processing: committee & active index roots
* state_processing: genesis state builder v0.8
* state_processing: implement v0.8.1
* Further improve tree_hash
* Strip examples, tests from cached_tree_hash
* Update TreeHash, un-impl CachedTreeHash
* Update bitfield TreeHash, un-impl CachedTreeHash
* Update FixedLenVec TreeHash, unimpl CachedTreeHash
* Update update tree_hash_derive for new TreeHash
* Fix TreeHash, un-impl CachedTreeHash for ssz_types
* Remove fixed_len_vec, ssz benches
SSZ benches relied upon fixed_len_vec -- it is easier to just delete
them and rebuild them later (when necessary)
* Remove boolean_bitfield crate
* Fix fake_crypto BLS compile errors
* Update ef_tests for new v.8 type params
* Update ef_tests submodule to v0.8.1 tag
* Make fixes to support parsing ssz ef_tests
* `compact_committee...` to `compact_committees...`
* Derive more traits for `CompactCommittee`
* Flip bitfield byte-endianness
* Fix tree_hash for bitfields
* Modify CLI output for ef_tests
* Bump ssz crate version
* Update ssz_types doc comment
* Del cached tree hash tests from ssz_static tests
* Tidy SSZ dependencies
* Rename ssz_types crate to eth2_ssz_types
* validator_client: update for v0.8
* ssz_types: update union/difference for bit order swap
* beacon_node: update for v0.8, EthSpec
* types: disable cached tree hash, update min spec
* state_processing: fix slot bug in committee update
* tests: temporarily disable fork choice harness test
See #447
* committee cache: prevent out-of-bounds access
In the case where we tried to access the committee of a shard that didn't have a committee in the
current epoch, we were accessing elements beyond the end of the shuffling vector and panicking! This
commit adds a check to make the failure safe and explicit.
* fix bug in get_indexed_attestation and simplify
There was a bug in our implementation of get_indexed_attestation whereby
incorrect "committee indices" were used to index into the custody bitfield. The
bug was only observable in the case where some bits of the custody bitfield were
set to 1. The implementation has been simplified to remove the bug, and a test
added.
* state_proc: workaround for compact committees bug
https://github.com/ethereum/eth2.0-specs/issues/1315
* v0.8: updates to make the EF tests pass
* Remove redundant max operation checks.
* Always supply both messages when checking attestation signatures -- allowing
verification of an attestation with no signatures.
* Swap the order of the fork and domain constant in `get_domain`, to match
the spec.
* rustfmt
* ef_tests: add new epoch processing tests
* Integrate v0.8 into master (compiles)
* Remove unused crates, fix clippy lints
* Replace v0.6.3 tags w/ v0.8.1
* Remove old comment
* Ensure lmd ghost tests only run in release
* Update readme
2019-07-30 02:44:51 +00:00
|
|
|
state.finalized_checkpoint.epoch,
|
2019-06-23 04:47:23 +00:00
|
|
|
state.current_epoch() - 2,
|
|
|
|
"the head should be finalized two behind the current epoch"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn finalizes_with_two_thirds_participation() {
|
|
|
|
let num_blocks_produced = MinimalEthSpec::slots_per_epoch() * 5;
|
|
|
|
|
|
|
|
let harness = get_harness(VALIDATOR_COUNT);
|
|
|
|
|
|
|
|
let two_thirds = (VALIDATOR_COUNT / 3) * 2;
|
|
|
|
let attesters = (0..two_thirds).collect();
|
|
|
|
|
|
|
|
harness.extend_chain(
|
|
|
|
num_blocks_produced as usize,
|
|
|
|
BlockStrategy::OnCanonicalHead,
|
|
|
|
AttestationStrategy::SomeValidators(attesters),
|
|
|
|
);
|
|
|
|
|
2020-01-06 06:30:37 +00:00
|
|
|
let state = &harness.chain.head().expect("should get head").beacon_state;
|
2019-06-23 04:47:23 +00:00
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
state.slot, num_blocks_produced,
|
|
|
|
"head should be at the current slot"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
state.current_epoch(),
|
|
|
|
num_blocks_produced / MinimalEthSpec::slots_per_epoch(),
|
|
|
|
"head should be at the expected epoch"
|
|
|
|
);
|
|
|
|
|
|
|
|
// Note: the 2/3rds tests are not justifying the immediately prior epochs because the
|
|
|
|
// `MIN_ATTESTATION_INCLUSION_DELAY` is preventing an adequate number of attestations being
|
|
|
|
// included in blocks during that epoch.
|
|
|
|
|
|
|
|
assert_eq!(
|
Update to frozen spec ❄️ (v0.8.1) (#444)
* types: first updates for v0.8
* state_processing: epoch processing v0.8.0
* state_processing: block processing v0.8.0
* tree_hash_derive: support generics in SignedRoot
* types v0.8: update to use ssz_types
* state_processing v0.8: use ssz_types
* ssz_types: add bitwise methods and from_elem
* types: fix v0.8 FIXMEs
* ssz_types: add bitfield shift_up
* ssz_types: iterators and DerefMut for VariableList
* types,state_processing: use VariableList
* ssz_types: fix BitVector Decode impl
Fixed a typo in the implementation of ssz::Decode for BitVector, which caused it
to be considered variable length!
* types: fix test modules for v0.8 update
* types: remove slow type-level arithmetic
* state_processing: fix tests for v0.8
* op_pool: update for v0.8
* ssz_types: Bitfield difference length-independent
Allow computing the difference of two bitfields of different lengths.
* Implement compact committee support
* epoch_processing: committee & active index roots
* state_processing: genesis state builder v0.8
* state_processing: implement v0.8.1
* Further improve tree_hash
* Strip examples, tests from cached_tree_hash
* Update TreeHash, un-impl CachedTreeHash
* Update bitfield TreeHash, un-impl CachedTreeHash
* Update FixedLenVec TreeHash, unimpl CachedTreeHash
* Update update tree_hash_derive for new TreeHash
* Fix TreeHash, un-impl CachedTreeHash for ssz_types
* Remove fixed_len_vec, ssz benches
SSZ benches relied upon fixed_len_vec -- it is easier to just delete
them and rebuild them later (when necessary)
* Remove boolean_bitfield crate
* Fix fake_crypto BLS compile errors
* Update ef_tests for new v.8 type params
* Update ef_tests submodule to v0.8.1 tag
* Make fixes to support parsing ssz ef_tests
* `compact_committee...` to `compact_committees...`
* Derive more traits for `CompactCommittee`
* Flip bitfield byte-endianness
* Fix tree_hash for bitfields
* Modify CLI output for ef_tests
* Bump ssz crate version
* Update ssz_types doc comment
* Del cached tree hash tests from ssz_static tests
* Tidy SSZ dependencies
* Rename ssz_types crate to eth2_ssz_types
* validator_client: update for v0.8
* ssz_types: update union/difference for bit order swap
* beacon_node: update for v0.8, EthSpec
* types: disable cached tree hash, update min spec
* state_processing: fix slot bug in committee update
* tests: temporarily disable fork choice harness test
See #447
* committee cache: prevent out-of-bounds access
In the case where we tried to access the committee of a shard that didn't have a committee in the
current epoch, we were accessing elements beyond the end of the shuffling vector and panicking! This
commit adds a check to make the failure safe and explicit.
* fix bug in get_indexed_attestation and simplify
There was a bug in our implementation of get_indexed_attestation whereby
incorrect "committee indices" were used to index into the custody bitfield. The
bug was only observable in the case where some bits of the custody bitfield were
set to 1. The implementation has been simplified to remove the bug, and a test
added.
* state_proc: workaround for compact committees bug
https://github.com/ethereum/eth2.0-specs/issues/1315
* v0.8: updates to make the EF tests pass
* Remove redundant max operation checks.
* Always supply both messages when checking attestation signatures -- allowing
verification of an attestation with no signatures.
* Swap the order of the fork and domain constant in `get_domain`, to match
the spec.
* rustfmt
* ef_tests: add new epoch processing tests
* Integrate v0.8 into master (compiles)
* Remove unused crates, fix clippy lints
* Replace v0.6.3 tags w/ v0.8.1
* Remove old comment
* Ensure lmd ghost tests only run in release
* Update readme
2019-07-30 02:44:51 +00:00
|
|
|
state.current_justified_checkpoint.epoch,
|
2019-06-23 04:47:23 +00:00
|
|
|
state.current_epoch() - 2,
|
|
|
|
"the head should be justified two behind the current epoch"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
Update to frozen spec ❄️ (v0.8.1) (#444)
* types: first updates for v0.8
* state_processing: epoch processing v0.8.0
* state_processing: block processing v0.8.0
* tree_hash_derive: support generics in SignedRoot
* types v0.8: update to use ssz_types
* state_processing v0.8: use ssz_types
* ssz_types: add bitwise methods and from_elem
* types: fix v0.8 FIXMEs
* ssz_types: add bitfield shift_up
* ssz_types: iterators and DerefMut for VariableList
* types,state_processing: use VariableList
* ssz_types: fix BitVector Decode impl
Fixed a typo in the implementation of ssz::Decode for BitVector, which caused it
to be considered variable length!
* types: fix test modules for v0.8 update
* types: remove slow type-level arithmetic
* state_processing: fix tests for v0.8
* op_pool: update for v0.8
* ssz_types: Bitfield difference length-independent
Allow computing the difference of two bitfields of different lengths.
* Implement compact committee support
* epoch_processing: committee & active index roots
* state_processing: genesis state builder v0.8
* state_processing: implement v0.8.1
* Further improve tree_hash
* Strip examples, tests from cached_tree_hash
* Update TreeHash, un-impl CachedTreeHash
* Update bitfield TreeHash, un-impl CachedTreeHash
* Update FixedLenVec TreeHash, unimpl CachedTreeHash
* Update update tree_hash_derive for new TreeHash
* Fix TreeHash, un-impl CachedTreeHash for ssz_types
* Remove fixed_len_vec, ssz benches
SSZ benches relied upon fixed_len_vec -- it is easier to just delete
them and rebuild them later (when necessary)
* Remove boolean_bitfield crate
* Fix fake_crypto BLS compile errors
* Update ef_tests for new v.8 type params
* Update ef_tests submodule to v0.8.1 tag
* Make fixes to support parsing ssz ef_tests
* `compact_committee...` to `compact_committees...`
* Derive more traits for `CompactCommittee`
* Flip bitfield byte-endianness
* Fix tree_hash for bitfields
* Modify CLI output for ef_tests
* Bump ssz crate version
* Update ssz_types doc comment
* Del cached tree hash tests from ssz_static tests
* Tidy SSZ dependencies
* Rename ssz_types crate to eth2_ssz_types
* validator_client: update for v0.8
* ssz_types: update union/difference for bit order swap
* beacon_node: update for v0.8, EthSpec
* types: disable cached tree hash, update min spec
* state_processing: fix slot bug in committee update
* tests: temporarily disable fork choice harness test
See #447
* committee cache: prevent out-of-bounds access
In the case where we tried to access the committee of a shard that didn't have a committee in the
current epoch, we were accessing elements beyond the end of the shuffling vector and panicking! This
commit adds a check to make the failure safe and explicit.
* fix bug in get_indexed_attestation and simplify
There was a bug in our implementation of get_indexed_attestation whereby
incorrect "committee indices" were used to index into the custody bitfield. The
bug was only observable in the case where some bits of the custody bitfield were
set to 1. The implementation has been simplified to remove the bug, and a test
added.
* state_proc: workaround for compact committees bug
https://github.com/ethereum/eth2.0-specs/issues/1315
* v0.8: updates to make the EF tests pass
* Remove redundant max operation checks.
* Always supply both messages when checking attestation signatures -- allowing
verification of an attestation with no signatures.
* Swap the order of the fork and domain constant in `get_domain`, to match
the spec.
* rustfmt
* ef_tests: add new epoch processing tests
* Integrate v0.8 into master (compiles)
* Remove unused crates, fix clippy lints
* Replace v0.6.3 tags w/ v0.8.1
* Remove old comment
* Ensure lmd ghost tests only run in release
* Update readme
2019-07-30 02:44:51 +00:00
|
|
|
state.finalized_checkpoint.epoch,
|
2019-06-23 04:47:23 +00:00
|
|
|
state.current_epoch() - 4,
|
|
|
|
"the head should be finalized three behind the current epoch"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn does_not_finalize_with_less_than_two_thirds_participation() {
|
|
|
|
let num_blocks_produced = MinimalEthSpec::slots_per_epoch() * 5;
|
|
|
|
|
|
|
|
let harness = get_harness(VALIDATOR_COUNT);
|
|
|
|
|
|
|
|
let two_thirds = (VALIDATOR_COUNT / 3) * 2;
|
|
|
|
let less_than_two_thirds = two_thirds - 1;
|
|
|
|
let attesters = (0..less_than_two_thirds).collect();
|
|
|
|
|
|
|
|
harness.extend_chain(
|
|
|
|
num_blocks_produced as usize,
|
|
|
|
BlockStrategy::OnCanonicalHead,
|
|
|
|
AttestationStrategy::SomeValidators(attesters),
|
|
|
|
);
|
|
|
|
|
2020-01-06 06:30:37 +00:00
|
|
|
let state = &harness.chain.head().expect("should get head").beacon_state;
|
2019-06-23 04:47:23 +00:00
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
state.slot, num_blocks_produced,
|
|
|
|
"head should be at the current slot"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
state.current_epoch(),
|
|
|
|
num_blocks_produced / MinimalEthSpec::slots_per_epoch(),
|
|
|
|
"head should be at the expected epoch"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
Update to frozen spec ❄️ (v0.8.1) (#444)
* types: first updates for v0.8
* state_processing: epoch processing v0.8.0
* state_processing: block processing v0.8.0
* tree_hash_derive: support generics in SignedRoot
* types v0.8: update to use ssz_types
* state_processing v0.8: use ssz_types
* ssz_types: add bitwise methods and from_elem
* types: fix v0.8 FIXMEs
* ssz_types: add bitfield shift_up
* ssz_types: iterators and DerefMut for VariableList
* types,state_processing: use VariableList
* ssz_types: fix BitVector Decode impl
Fixed a typo in the implementation of ssz::Decode for BitVector, which caused it
to be considered variable length!
* types: fix test modules for v0.8 update
* types: remove slow type-level arithmetic
* state_processing: fix tests for v0.8
* op_pool: update for v0.8
* ssz_types: Bitfield difference length-independent
Allow computing the difference of two bitfields of different lengths.
* Implement compact committee support
* epoch_processing: committee & active index roots
* state_processing: genesis state builder v0.8
* state_processing: implement v0.8.1
* Further improve tree_hash
* Strip examples, tests from cached_tree_hash
* Update TreeHash, un-impl CachedTreeHash
* Update bitfield TreeHash, un-impl CachedTreeHash
* Update FixedLenVec TreeHash, unimpl CachedTreeHash
* Update update tree_hash_derive for new TreeHash
* Fix TreeHash, un-impl CachedTreeHash for ssz_types
* Remove fixed_len_vec, ssz benches
SSZ benches relied upon fixed_len_vec -- it is easier to just delete
them and rebuild them later (when necessary)
* Remove boolean_bitfield crate
* Fix fake_crypto BLS compile errors
* Update ef_tests for new v.8 type params
* Update ef_tests submodule to v0.8.1 tag
* Make fixes to support parsing ssz ef_tests
* `compact_committee...` to `compact_committees...`
* Derive more traits for `CompactCommittee`
* Flip bitfield byte-endianness
* Fix tree_hash for bitfields
* Modify CLI output for ef_tests
* Bump ssz crate version
* Update ssz_types doc comment
* Del cached tree hash tests from ssz_static tests
* Tidy SSZ dependencies
* Rename ssz_types crate to eth2_ssz_types
* validator_client: update for v0.8
* ssz_types: update union/difference for bit order swap
* beacon_node: update for v0.8, EthSpec
* types: disable cached tree hash, update min spec
* state_processing: fix slot bug in committee update
* tests: temporarily disable fork choice harness test
See #447
* committee cache: prevent out-of-bounds access
In the case where we tried to access the committee of a shard that didn't have a committee in the
current epoch, we were accessing elements beyond the end of the shuffling vector and panicking! This
commit adds a check to make the failure safe and explicit.
* fix bug in get_indexed_attestation and simplify
There was a bug in our implementation of get_indexed_attestation whereby
incorrect "committee indices" were used to index into the custody bitfield. The
bug was only observable in the case where some bits of the custody bitfield were
set to 1. The implementation has been simplified to remove the bug, and a test
added.
* state_proc: workaround for compact committees bug
https://github.com/ethereum/eth2.0-specs/issues/1315
* v0.8: updates to make the EF tests pass
* Remove redundant max operation checks.
* Always supply both messages when checking attestation signatures -- allowing
verification of an attestation with no signatures.
* Swap the order of the fork and domain constant in `get_domain`, to match
the spec.
* rustfmt
* ef_tests: add new epoch processing tests
* Integrate v0.8 into master (compiles)
* Remove unused crates, fix clippy lints
* Replace v0.6.3 tags w/ v0.8.1
* Remove old comment
* Ensure lmd ghost tests only run in release
* Update readme
2019-07-30 02:44:51 +00:00
|
|
|
state.current_justified_checkpoint.epoch, 0,
|
2019-06-23 04:47:23 +00:00
|
|
|
"no epoch should have been justified"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
Update to frozen spec ❄️ (v0.8.1) (#444)
* types: first updates for v0.8
* state_processing: epoch processing v0.8.0
* state_processing: block processing v0.8.0
* tree_hash_derive: support generics in SignedRoot
* types v0.8: update to use ssz_types
* state_processing v0.8: use ssz_types
* ssz_types: add bitwise methods and from_elem
* types: fix v0.8 FIXMEs
* ssz_types: add bitfield shift_up
* ssz_types: iterators and DerefMut for VariableList
* types,state_processing: use VariableList
* ssz_types: fix BitVector Decode impl
Fixed a typo in the implementation of ssz::Decode for BitVector, which caused it
to be considered variable length!
* types: fix test modules for v0.8 update
* types: remove slow type-level arithmetic
* state_processing: fix tests for v0.8
* op_pool: update for v0.8
* ssz_types: Bitfield difference length-independent
Allow computing the difference of two bitfields of different lengths.
* Implement compact committee support
* epoch_processing: committee & active index roots
* state_processing: genesis state builder v0.8
* state_processing: implement v0.8.1
* Further improve tree_hash
* Strip examples, tests from cached_tree_hash
* Update TreeHash, un-impl CachedTreeHash
* Update bitfield TreeHash, un-impl CachedTreeHash
* Update FixedLenVec TreeHash, unimpl CachedTreeHash
* Update update tree_hash_derive for new TreeHash
* Fix TreeHash, un-impl CachedTreeHash for ssz_types
* Remove fixed_len_vec, ssz benches
SSZ benches relied upon fixed_len_vec -- it is easier to just delete
them and rebuild them later (when necessary)
* Remove boolean_bitfield crate
* Fix fake_crypto BLS compile errors
* Update ef_tests for new v.8 type params
* Update ef_tests submodule to v0.8.1 tag
* Make fixes to support parsing ssz ef_tests
* `compact_committee...` to `compact_committees...`
* Derive more traits for `CompactCommittee`
* Flip bitfield byte-endianness
* Fix tree_hash for bitfields
* Modify CLI output for ef_tests
* Bump ssz crate version
* Update ssz_types doc comment
* Del cached tree hash tests from ssz_static tests
* Tidy SSZ dependencies
* Rename ssz_types crate to eth2_ssz_types
* validator_client: update for v0.8
* ssz_types: update union/difference for bit order swap
* beacon_node: update for v0.8, EthSpec
* types: disable cached tree hash, update min spec
* state_processing: fix slot bug in committee update
* tests: temporarily disable fork choice harness test
See #447
* committee cache: prevent out-of-bounds access
In the case where we tried to access the committee of a shard that didn't have a committee in the
current epoch, we were accessing elements beyond the end of the shuffling vector and panicking! This
commit adds a check to make the failure safe and explicit.
* fix bug in get_indexed_attestation and simplify
There was a bug in our implementation of get_indexed_attestation whereby
incorrect "committee indices" were used to index into the custody bitfield. The
bug was only observable in the case where some bits of the custody bitfield were
set to 1. The implementation has been simplified to remove the bug, and a test
added.
* state_proc: workaround for compact committees bug
https://github.com/ethereum/eth2.0-specs/issues/1315
* v0.8: updates to make the EF tests pass
* Remove redundant max operation checks.
* Always supply both messages when checking attestation signatures -- allowing
verification of an attestation with no signatures.
* Swap the order of the fork and domain constant in `get_domain`, to match
the spec.
* rustfmt
* ef_tests: add new epoch processing tests
* Integrate v0.8 into master (compiles)
* Remove unused crates, fix clippy lints
* Replace v0.6.3 tags w/ v0.8.1
* Remove old comment
* Ensure lmd ghost tests only run in release
* Update readme
2019-07-30 02:44:51 +00:00
|
|
|
state.finalized_checkpoint.epoch, 0,
|
2019-06-23 04:47:23 +00:00
|
|
|
"no epoch should have been finalized"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn does_not_finalize_without_attestation() {
|
|
|
|
let num_blocks_produced = MinimalEthSpec::slots_per_epoch() * 5;
|
|
|
|
|
|
|
|
let harness = get_harness(VALIDATOR_COUNT);
|
|
|
|
|
|
|
|
harness.extend_chain(
|
|
|
|
num_blocks_produced as usize,
|
|
|
|
BlockStrategy::OnCanonicalHead,
|
|
|
|
AttestationStrategy::SomeValidators(vec![]),
|
|
|
|
);
|
|
|
|
|
2020-01-06 06:30:37 +00:00
|
|
|
let state = &harness.chain.head().expect("should get head").beacon_state;
|
2019-06-23 04:47:23 +00:00
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
state.slot, num_blocks_produced,
|
|
|
|
"head should be at the current slot"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
state.current_epoch(),
|
|
|
|
num_blocks_produced / MinimalEthSpec::slots_per_epoch(),
|
|
|
|
"head should be at the expected epoch"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
Update to frozen spec ❄️ (v0.8.1) (#444)
* types: first updates for v0.8
* state_processing: epoch processing v0.8.0
* state_processing: block processing v0.8.0
* tree_hash_derive: support generics in SignedRoot
* types v0.8: update to use ssz_types
* state_processing v0.8: use ssz_types
* ssz_types: add bitwise methods and from_elem
* types: fix v0.8 FIXMEs
* ssz_types: add bitfield shift_up
* ssz_types: iterators and DerefMut for VariableList
* types,state_processing: use VariableList
* ssz_types: fix BitVector Decode impl
Fixed a typo in the implementation of ssz::Decode for BitVector, which caused it
to be considered variable length!
* types: fix test modules for v0.8 update
* types: remove slow type-level arithmetic
* state_processing: fix tests for v0.8
* op_pool: update for v0.8
* ssz_types: Bitfield difference length-independent
Allow computing the difference of two bitfields of different lengths.
* Implement compact committee support
* epoch_processing: committee & active index roots
* state_processing: genesis state builder v0.8
* state_processing: implement v0.8.1
* Further improve tree_hash
* Strip examples, tests from cached_tree_hash
* Update TreeHash, un-impl CachedTreeHash
* Update bitfield TreeHash, un-impl CachedTreeHash
* Update FixedLenVec TreeHash, unimpl CachedTreeHash
* Update update tree_hash_derive for new TreeHash
* Fix TreeHash, un-impl CachedTreeHash for ssz_types
* Remove fixed_len_vec, ssz benches
SSZ benches relied upon fixed_len_vec -- it is easier to just delete
them and rebuild them later (when necessary)
* Remove boolean_bitfield crate
* Fix fake_crypto BLS compile errors
* Update ef_tests for new v.8 type params
* Update ef_tests submodule to v0.8.1 tag
* Make fixes to support parsing ssz ef_tests
* `compact_committee...` to `compact_committees...`
* Derive more traits for `CompactCommittee`
* Flip bitfield byte-endianness
* Fix tree_hash for bitfields
* Modify CLI output for ef_tests
* Bump ssz crate version
* Update ssz_types doc comment
* Del cached tree hash tests from ssz_static tests
* Tidy SSZ dependencies
* Rename ssz_types crate to eth2_ssz_types
* validator_client: update for v0.8
* ssz_types: update union/difference for bit order swap
* beacon_node: update for v0.8, EthSpec
* types: disable cached tree hash, update min spec
* state_processing: fix slot bug in committee update
* tests: temporarily disable fork choice harness test
See #447
* committee cache: prevent out-of-bounds access
In the case where we tried to access the committee of a shard that didn't have a committee in the
current epoch, we were accessing elements beyond the end of the shuffling vector and panicking! This
commit adds a check to make the failure safe and explicit.
* fix bug in get_indexed_attestation and simplify
There was a bug in our implementation of get_indexed_attestation whereby
incorrect "committee indices" were used to index into the custody bitfield. The
bug was only observable in the case where some bits of the custody bitfield were
set to 1. The implementation has been simplified to remove the bug, and a test
added.
* state_proc: workaround for compact committees bug
https://github.com/ethereum/eth2.0-specs/issues/1315
* v0.8: updates to make the EF tests pass
* Remove redundant max operation checks.
* Always supply both messages when checking attestation signatures -- allowing
verification of an attestation with no signatures.
* Swap the order of the fork and domain constant in `get_domain`, to match
the spec.
* rustfmt
* ef_tests: add new epoch processing tests
* Integrate v0.8 into master (compiles)
* Remove unused crates, fix clippy lints
* Replace v0.6.3 tags w/ v0.8.1
* Remove old comment
* Ensure lmd ghost tests only run in release
* Update readme
2019-07-30 02:44:51 +00:00
|
|
|
state.current_justified_checkpoint.epoch, 0,
|
2019-06-23 04:47:23 +00:00
|
|
|
"no epoch should have been justified"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
Update to frozen spec ❄️ (v0.8.1) (#444)
* types: first updates for v0.8
* state_processing: epoch processing v0.8.0
* state_processing: block processing v0.8.0
* tree_hash_derive: support generics in SignedRoot
* types v0.8: update to use ssz_types
* state_processing v0.8: use ssz_types
* ssz_types: add bitwise methods and from_elem
* types: fix v0.8 FIXMEs
* ssz_types: add bitfield shift_up
* ssz_types: iterators and DerefMut for VariableList
* types,state_processing: use VariableList
* ssz_types: fix BitVector Decode impl
Fixed a typo in the implementation of ssz::Decode for BitVector, which caused it
to be considered variable length!
* types: fix test modules for v0.8 update
* types: remove slow type-level arithmetic
* state_processing: fix tests for v0.8
* op_pool: update for v0.8
* ssz_types: Bitfield difference length-independent
Allow computing the difference of two bitfields of different lengths.
* Implement compact committee support
* epoch_processing: committee & active index roots
* state_processing: genesis state builder v0.8
* state_processing: implement v0.8.1
* Further improve tree_hash
* Strip examples, tests from cached_tree_hash
* Update TreeHash, un-impl CachedTreeHash
* Update bitfield TreeHash, un-impl CachedTreeHash
* Update FixedLenVec TreeHash, unimpl CachedTreeHash
* Update update tree_hash_derive for new TreeHash
* Fix TreeHash, un-impl CachedTreeHash for ssz_types
* Remove fixed_len_vec, ssz benches
SSZ benches relied upon fixed_len_vec -- it is easier to just delete
them and rebuild them later (when necessary)
* Remove boolean_bitfield crate
* Fix fake_crypto BLS compile errors
* Update ef_tests for new v.8 type params
* Update ef_tests submodule to v0.8.1 tag
* Make fixes to support parsing ssz ef_tests
* `compact_committee...` to `compact_committees...`
* Derive more traits for `CompactCommittee`
* Flip bitfield byte-endianness
* Fix tree_hash for bitfields
* Modify CLI output for ef_tests
* Bump ssz crate version
* Update ssz_types doc comment
* Del cached tree hash tests from ssz_static tests
* Tidy SSZ dependencies
* Rename ssz_types crate to eth2_ssz_types
* validator_client: update for v0.8
* ssz_types: update union/difference for bit order swap
* beacon_node: update for v0.8, EthSpec
* types: disable cached tree hash, update min spec
* state_processing: fix slot bug in committee update
* tests: temporarily disable fork choice harness test
See #447
* committee cache: prevent out-of-bounds access
In the case where we tried to access the committee of a shard that didn't have a committee in the
current epoch, we were accessing elements beyond the end of the shuffling vector and panicking! This
commit adds a check to make the failure safe and explicit.
* fix bug in get_indexed_attestation and simplify
There was a bug in our implementation of get_indexed_attestation whereby
incorrect "committee indices" were used to index into the custody bitfield. The
bug was only observable in the case where some bits of the custody bitfield were
set to 1. The implementation has been simplified to remove the bug, and a test
added.
* state_proc: workaround for compact committees bug
https://github.com/ethereum/eth2.0-specs/issues/1315
* v0.8: updates to make the EF tests pass
* Remove redundant max operation checks.
* Always supply both messages when checking attestation signatures -- allowing
verification of an attestation with no signatures.
* Swap the order of the fork and domain constant in `get_domain`, to match
the spec.
* rustfmt
* ef_tests: add new epoch processing tests
* Integrate v0.8 into master (compiles)
* Remove unused crates, fix clippy lints
* Replace v0.6.3 tags w/ v0.8.1
* Remove old comment
* Ensure lmd ghost tests only run in release
* Update readme
2019-07-30 02:44:51 +00:00
|
|
|
state.finalized_checkpoint.epoch, 0,
|
2019-06-23 04:47:23 +00:00
|
|
|
"no epoch should have been finalized"
|
|
|
|
);
|
|
|
|
}
|
2019-06-26 03:06:08 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn roundtrip_operation_pool() {
|
|
|
|
let num_blocks_produced = MinimalEthSpec::slots_per_epoch() * 5;
|
|
|
|
|
|
|
|
let harness = get_harness(VALIDATOR_COUNT);
|
|
|
|
|
|
|
|
// Add some attestations
|
|
|
|
harness.extend_chain(
|
|
|
|
num_blocks_produced as usize,
|
|
|
|
BlockStrategy::OnCanonicalHead,
|
|
|
|
AttestationStrategy::AllValidators,
|
|
|
|
);
|
|
|
|
assert!(harness.chain.op_pool.num_attestations() > 0);
|
|
|
|
|
|
|
|
// TODO: could add some other operations
|
|
|
|
harness.chain.persist().unwrap();
|
|
|
|
|
|
|
|
let key = Hash256::from_slice(&BEACON_CHAIN_DB_KEY.as_bytes());
|
Eth1 Integration (#542)
* Refactor to cache Eth1Data
* Fix merge conflicts and minor refactorings
* Rename Eth1Cache to Eth1DataCache
* Refactor events subscription
* Add deposits module to interface with BeaconChain deposits
* Remove utils
* Rename to types.rs and add trait constraints to Eth1DataFetcher
* Confirm to trait constraints. Make Web3DataFetcher cloneable
* Make fetcher object member of deposit and eth1_data cache and other fixes
* Fix update_cache function
* Move fetch_eth1_data to impl block
* Fix deposit tests
* Create Eth1 object for interfacing with Beacon chain
* Add `run` function for running update_cache and subscribe_deposit_logs tasks
* Add logging
* Run `cargo fmt` and make tests pass
* Convert sync functions to async
* Add timeouts to web3 functions
* Return futures from cache functions
* Add failed chaining of futures
* Working cache updation
* Clean up tests and `update_cache` function
* Refactor `get_eth1_data` functions to work with future returning functions
* Refactor eth1 `run` function to work with modified `update_cache` api
* Minor changes
* Add distance parameter to `update_cache`
* Fix tests and other minor fixes
* Working integration with cache and deposits
* Add merkle_tree construction, proof generation and verification code
* Add function to construct and fetch Deposits for BeaconNode
* Add error handling
* Import ssz
* Add error handling to eth1 cache and fix minor errors
* Run rustfmt
* Fix minor bug
* Rename Eth1Error and change to Result<T>
* Change deposit fetching mechanism from notification based to poll based
* Add deposits from eth1 chain in a given range every `x` blocks
* Modify `run` function to accommodate changes
* Minor fixes
* Fix formatting
* Initial commit. web3 api working.
* Tidied up lib. Add function for fetching logs.
* Refactor with `Eth1DataFetcher` trait
* Add parsing for deposit contract logs and get_eth1_data function
* Add `get_eth1_votes` function
* Refactor to cache Eth1Data
* Fix merge conflicts and minor refactorings
* Rename Eth1Cache to Eth1DataCache
* Refactor events subscription
* Add deposits module to interface with BeaconChain deposits
* Remove utils
* Rename to types.rs and add trait constraints to Eth1DataFetcher
* Confirm to trait constraints. Make Web3DataFetcher cloneable
* Make fetcher object member of deposit and eth1_data cache and other fixes
* Fix update_cache function
* Move fetch_eth1_data to impl block
* Fix deposit tests
* Create Eth1 object for interfacing with Beacon chain
* Add `run` function for running update_cache and subscribe_deposit_logs tasks
* Add logging
* Run `cargo fmt` and make tests pass
* Convert sync functions to async
* Add timeouts to web3 functions
* Return futures from cache functions
* Add failed chaining of futures
* Working cache updation
* Clean up tests and `update_cache` function
* Refactor `get_eth1_data` functions to work with future returning functions
* Refactor eth1 `run` function to work with modified `update_cache` api
* Minor changes
* Add distance parameter to `update_cache`
* Fix tests and other minor fixes
* Working integration with cache and deposits
* Add merkle_tree construction, proof generation and verification code
* Add function to construct and fetch Deposits for BeaconNode
* Add error handling
* Import ssz
* Add error handling to eth1 cache and fix minor errors
* Run rustfmt
* Fix minor bug
* Rename Eth1Error and change to Result<T>
* Change deposit fetching mechanism from notification based to poll based
* Add deposits from eth1 chain in a given range every `x` blocks
* Modify `run` function to accommodate changes
* Minor fixes
* Fix formatting
* Fix merge issue
* Refactor with `Config` struct. Remote `ContractConfig`
* Rename eth1_chain crate to eth1
* Rename files and read abi file using `fs::read`
* Move eth1 to lib
* Remove unnecessary mutability constraint
* Add `Web3Backend` for returning actual eth1 data
* Refactor `get_eth1_votes` to return a Result
* Delete `eth1_chain` crate
* Return `Result` from `get_deposits`
* Fix range of deposits to return to beacon chain
* Add `get_block_height_by_hash` trait function
* Add naive method for getting `previous_eth1_distance`
* Add eth1 config params to main config
* Add instructions for setting up eth1 testing environment
* Add build script to fetch deposit contract abi
* Contract ABI is part of compiled binary
* Fix minor bugs
* Move docs to lib
* Add timeout to config
* Remove print statements
* Change warn to error
* Fix typos
* Removed prints in test and get timeout value from config
* Fixed error types
* Added logging to web3_fetcher
* Refactor for modified web3 api
* Fix minor stuff
* Add build script
* Tidy, hide eth1 integration tests behind flag
* Add http crate
* Add first stages of eth1_test_rig
* Fix deposits on test rig
* Fix bug with deposit count method
* Add block hash getter to http eth1
* Clean eth1 http crate and tests
* Add script to start ganache
* Adds deposit tree to eth1-http
* Extend deposit tree tests
* Tidy tests in eth1-http
* Add more detail to get block request
* Add block cache to eth1-http
* Rename deposit tree to deposit cache
* Add inital updating to eth1-http
* Tidy updater
* Fix compile bugs in tests
* Adds an Eth1DataCache builder
* Reorg eth1-http files
* Add (failing) tests for eth1 updater
* Rename files, fix bug in eth1-http
* Ensure that ganache timestamps are increasing
* Fix bugs with getting eth1data ancestors
* Improve eth1 testing, fix bugs
* Add truncate method to block cache
* Add pruning to block cache update process
* Add tests for block pruning
* Allow for dropping an expired cache.
* Add more comments
* Add first compiling version of deposit updater
* Add common fn for getting range of required blocks
* Add passing deposit update test
* Improve tests
* Fix block pruning bug
* Add tests for running two updates at once
* Add updater services to eth1
* Add deposit collection to beacon chain
* Add incomplete builder experiments
* Add first working version of beacon chain builder
* Update test harness to new beacon chain type
* Rename builder file, tidy
* Add first working client builder
* Progress further on client builder
* Update becaon node binary to use client builder
* Ensure release tests compile
* Remove old eth1 crate
* Add first pass of new lighthouse binary
* Fix websocket server startup
* Remove old binary code from beacon_node crate
* Add first working beacon node tests
* Add genesis crate, new eth1 cache_2
* Add Serivce to Eth1Cache
* Refactor with general eth1 improvements
* Add passing genesis test
* Tidy, add comments
* Add more comments to eth1 service
* Add further eth1 progress
* Fix some bugs with genesis
* Fix eth1 bugs, make eth1 linking more efficient
* Shift logic in genesis service
* Add more comments to genesis service
* Add gzip, max request values, timeouts to http
* Update testnet parameters to suit goerli testnet
* Add ability to vary Fork, fix custom spec
* Be more explicit about deposit fork version
* Start adding beacon chain eth1 option
* Add more flexibility to prod client
* Further runtime refactoring
* Allow for starting from store
* Add bootstrapping to client config
* Add remote_beacon_node crate
* Update eth1 service for more configurability
* Update eth1 tests to use less runtimes
* Patch issues with tests using too many files
* Move dummy eth1 backend flag
* Ensure all tests pass
* Add ganache-cli to Dockerfile
* Use a special docker hub image for testing
* Appease clippy
* Move validator client into lighthouse binary
* Allow starting with dummy eth1 backend
* Improve logging
* Fix dummy eth1 backend from cli
* Add extra testnet command
* Ensure consistent spec in beacon node
* Update eth1 rig to work on goerli
* Tidy lcli, start adding support for yaml config
* Add incomplete YamlConfig struct
* Remove efforts at YamlConfig
* Add incomplete eth1 voting. Blocked on spec issues
* Add (untested) first pass at eth1 vote algo
* Add tests for winning vote
* Add more tests for eth1 chain
* Add more eth1 voting tests
* Added more eth1 voting testing
* Change test name
* Add more tests to eth1 chain
* Tidy eth1 generics, add more tests
* Improve comments
* Tidy beacon_node tests
* Tidy, rename JsonRpc.. to Caching..
* Tidy voting logic
* Tidy builder docs
* Add comments, tidy eth1
* Add more comments to eth1
* Fix bug with winning_vote
* Add doc comments to the `ClientBuilder`
* Remove commented-out code
* Improve `ClientBuilder` docs
* Add comments to client config
* Add decoding test for `ClientConfig`
* Remove unused `DepositSet` struct
* Tidy `block_cache`
* Remove commented out lines
* Remove unused code in `eth1` crate
* Remove old validator binary `main.rs`
* Tidy, fix tests compile error
* Add initial tests for get_deposits
* Remove dead code in eth1_test_rig
* Update TestingDepositBuilder
* Add testing for getting eth1 deposits
* Fix duplicate rand dep
* Remove dead code
* Remove accidentally-added files
* Fix comment in eth1_genesis_service
* Add .gitignore for eth1_test_rig
* Fix bug in eth1_genesis_service
* Remove dead code from eth2_config
* Fix tabs/spaces in root Cargo.toml
* Tidy eth1 crate
* Allow for re-use of eth1 service after genesis
* Update docs for new CLI
* Change README gif
* Tidy eth1 http module
* Tidy eth1 service
* Tidy environment crate
* Remove unused file
* Tidy, add comments
* Remove commented-out code
* Address majority of Michael's comments
* Address other PR comments
* Add link to issue alongside TODO
2019-11-15 03:47:51 +00:00
|
|
|
let p: PersistedBeaconChain<HarnessType<MinimalEthSpec>> =
|
2019-06-26 03:06:08 +00:00
|
|
|
harness.chain.store.get(&key).unwrap().unwrap();
|
|
|
|
|
2019-08-29 09:14:52 +00:00
|
|
|
let restored_op_pool = p
|
|
|
|
.op_pool
|
|
|
|
.into_operation_pool(&p.canonical_head.beacon_state, &harness.spec);
|
2019-06-26 03:06:08 +00:00
|
|
|
|
|
|
|
assert_eq!(harness.chain.op_pool, restored_op_pool);
|
|
|
|
}
|
2019-07-29 20:51:42 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn free_attestations_added_to_fork_choice_some_none() {
|
|
|
|
let num_blocks_produced = MinimalEthSpec::slots_per_epoch() / 2;
|
|
|
|
|
|
|
|
let harness = get_harness(VALIDATOR_COUNT);
|
|
|
|
|
|
|
|
harness.extend_chain(
|
|
|
|
num_blocks_produced as usize,
|
|
|
|
BlockStrategy::OnCanonicalHead,
|
|
|
|
AttestationStrategy::AllValidators,
|
|
|
|
);
|
|
|
|
|
2020-01-06 06:30:37 +00:00
|
|
|
let state = &harness.chain.head().expect("should get head").beacon_state;
|
2019-07-29 20:51:42 +00:00
|
|
|
let fork_choice = &harness.chain.fork_choice;
|
|
|
|
|
2019-08-09 01:54:35 +00:00
|
|
|
let validator_slots: Vec<(usize, Slot)> = (0..VALIDATOR_COUNT)
|
|
|
|
.into_iter()
|
|
|
|
.map(|validator_index| {
|
|
|
|
let slot = state
|
|
|
|
.get_attestation_duties(validator_index, RelativeEpoch::Current)
|
2019-07-29 20:51:42 +00:00
|
|
|
.expect("should get attester duties")
|
|
|
|
.unwrap()
|
2019-08-09 01:54:35 +00:00
|
|
|
.slot;
|
|
|
|
|
|
|
|
(validator_index, slot)
|
2019-08-06 17:17:15 +00:00
|
|
|
})
|
|
|
|
.collect();
|
2019-07-29 20:51:42 +00:00
|
|
|
|
|
|
|
for (validator, slot) in validator_slots.clone() {
|
2019-08-09 01:54:35 +00:00
|
|
|
let latest_message = fork_choice.latest_message(validator);
|
2019-07-29 20:51:42 +00:00
|
|
|
|
2019-08-06 17:17:15 +00:00
|
|
|
if slot <= num_blocks_produced && slot != 0 {
|
2019-07-29 20:51:42 +00:00
|
|
|
assert_eq!(
|
2019-08-06 17:17:15 +00:00
|
|
|
latest_message.unwrap().1,
|
2020-01-29 04:05:00 +00:00
|
|
|
slot.epoch(MinimalEthSpec::slots_per_epoch()),
|
2019-08-09 01:54:35 +00:00
|
|
|
"Latest message slot for {} should be equal to slot {}.",
|
|
|
|
validator,
|
|
|
|
slot
|
2019-07-29 20:51:42 +00:00
|
|
|
)
|
|
|
|
} else {
|
|
|
|
assert!(
|
|
|
|
latest_message.is_none(),
|
|
|
|
"Latest message slot should be None."
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-07 06:02:30 +00:00
|
|
|
#[test]
|
2019-08-07 06:40:49 +00:00
|
|
|
fn attestations_with_increasing_slots() {
|
2019-08-07 06:02:30 +00:00
|
|
|
let num_blocks_produced = MinimalEthSpec::slots_per_epoch() * 5;
|
|
|
|
|
|
|
|
let harness = get_harness(VALIDATOR_COUNT);
|
|
|
|
|
|
|
|
let mut attestations = vec![];
|
|
|
|
|
|
|
|
for _ in 0..num_blocks_produced {
|
|
|
|
harness.extend_chain(
|
|
|
|
2,
|
|
|
|
BlockStrategy::OnCanonicalHead,
|
|
|
|
// Don't produce & include any attestations (we'll collect them later).
|
|
|
|
AttestationStrategy::SomeValidators(vec![]),
|
|
|
|
);
|
|
|
|
|
2020-01-06 06:30:37 +00:00
|
|
|
attestations.append(
|
|
|
|
&mut harness.get_free_attestations(
|
|
|
|
&AttestationStrategy::AllValidators,
|
|
|
|
&harness.chain.head().expect("should get head").beacon_state,
|
|
|
|
harness
|
|
|
|
.chain
|
|
|
|
.head()
|
|
|
|
.expect("should get head")
|
|
|
|
.beacon_block_root,
|
|
|
|
harness
|
|
|
|
.chain
|
|
|
|
.head()
|
|
|
|
.expect("should get head")
|
|
|
|
.beacon_block
|
2020-02-10 23:19:36 +00:00
|
|
|
.slot(),
|
2020-01-06 06:30:37 +00:00
|
|
|
),
|
|
|
|
);
|
2019-08-07 06:02:30 +00:00
|
|
|
|
|
|
|
harness.advance_slot();
|
|
|
|
}
|
|
|
|
|
|
|
|
for attestation in attestations {
|
|
|
|
assert_eq!(
|
|
|
|
harness.chain.process_attestation(attestation),
|
|
|
|
Ok(AttestationProcessingOutcome::Processed)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-29 20:51:42 +00:00
|
|
|
#[test]
|
|
|
|
fn free_attestations_added_to_fork_choice_all_updated() {
|
|
|
|
let num_blocks_produced = MinimalEthSpec::slots_per_epoch() * 2 - 1;
|
|
|
|
|
|
|
|
let harness = get_harness(VALIDATOR_COUNT);
|
|
|
|
|
|
|
|
harness.extend_chain(
|
|
|
|
num_blocks_produced as usize,
|
|
|
|
BlockStrategy::OnCanonicalHead,
|
|
|
|
AttestationStrategy::AllValidators,
|
|
|
|
);
|
|
|
|
|
2020-01-06 06:30:37 +00:00
|
|
|
let state = &harness.chain.head().expect("should get head").beacon_state;
|
2019-07-29 20:51:42 +00:00
|
|
|
let fork_choice = &harness.chain.fork_choice;
|
|
|
|
|
|
|
|
let validators: Vec<usize> = (0..VALIDATOR_COUNT).collect();
|
|
|
|
let slots: Vec<Slot> = validators
|
|
|
|
.iter()
|
2019-08-06 17:17:15 +00:00
|
|
|
.map(|&v| {
|
|
|
|
state
|
|
|
|
.get_attestation_duties(v, RelativeEpoch::Current)
|
2019-07-29 20:51:42 +00:00
|
|
|
.expect("should get attester duties")
|
|
|
|
.unwrap()
|
|
|
|
.slot
|
2019-08-06 17:17:15 +00:00
|
|
|
})
|
|
|
|
.collect();
|
2019-07-29 20:51:42 +00:00
|
|
|
let validator_slots: Vec<(&usize, Slot)> = validators.iter().zip(slots).collect();
|
|
|
|
|
|
|
|
for (validator, slot) in validator_slots {
|
|
|
|
let latest_message = fork_choice.latest_message(*validator);
|
|
|
|
|
|
|
|
assert_eq!(
|
2019-08-06 17:17:15 +00:00
|
|
|
latest_message.unwrap().1,
|
2020-01-29 04:05:00 +00:00
|
|
|
slot.epoch(MinimalEthSpec::slots_per_epoch()),
|
2019-07-29 20:51:42 +00:00
|
|
|
"Latest message slot should be equal to attester duty."
|
|
|
|
);
|
|
|
|
|
|
|
|
if slot != num_blocks_produced {
|
2019-08-06 17:17:15 +00:00
|
|
|
let block_root = state
|
|
|
|
.get_block_root(slot)
|
2019-07-29 20:51:42 +00:00
|
|
|
.expect("Should get block root at slot");
|
|
|
|
|
|
|
|
assert_eq!(
|
2019-08-06 17:17:15 +00:00
|
|
|
latest_message.unwrap().0,
|
|
|
|
*block_root,
|
2019-07-29 20:51:42 +00:00
|
|
|
"Latest message block root should be equal to block at slot."
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2019-08-06 17:17:15 +00:00
|
|
|
}
|
2019-09-04 00:25:30 +00:00
|
|
|
|
2019-09-04 02:04:15 +00:00
|
|
|
fn run_skip_slot_test(skip_slots: u64) {
|
2019-09-04 00:25:30 +00:00
|
|
|
let num_validators = 8;
|
|
|
|
let harness_a = get_harness(num_validators);
|
|
|
|
let harness_b = get_harness(num_validators);
|
|
|
|
|
|
|
|
for _ in 0..skip_slots {
|
|
|
|
harness_a.advance_slot();
|
|
|
|
harness_b.advance_slot();
|
|
|
|
}
|
|
|
|
|
|
|
|
harness_a.extend_chain(
|
|
|
|
1,
|
|
|
|
BlockStrategy::OnCanonicalHead,
|
|
|
|
// No attestation required for test.
|
|
|
|
AttestationStrategy::SomeValidators(vec![]),
|
|
|
|
);
|
|
|
|
|
2019-09-04 02:04:15 +00:00
|
|
|
assert_eq!(
|
2020-01-06 06:30:37 +00:00
|
|
|
harness_a
|
|
|
|
.chain
|
|
|
|
.head()
|
|
|
|
.expect("should get head")
|
|
|
|
.beacon_block
|
2020-02-10 23:19:36 +00:00
|
|
|
.slot(),
|
2019-09-04 02:04:15 +00:00
|
|
|
Slot::new(skip_slots + 1)
|
|
|
|
);
|
2019-09-04 00:25:30 +00:00
|
|
|
assert_eq!(
|
|
|
|
harness_b
|
|
|
|
.chain
|
2020-01-06 06:30:37 +00:00
|
|
|
.head()
|
|
|
|
.expect("should get head")
|
|
|
|
.beacon_block
|
2020-02-10 23:19:36 +00:00
|
|
|
.slot(),
|
2020-01-06 06:30:37 +00:00
|
|
|
Slot::new(0)
|
|
|
|
);
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
harness_b.chain.process_block(
|
|
|
|
harness_a
|
|
|
|
.chain
|
|
|
|
.head()
|
|
|
|
.expect("should get head")
|
|
|
|
.beacon_block
|
|
|
|
.clone()
|
|
|
|
),
|
2019-09-04 00:25:30 +00:00
|
|
|
Ok(BlockProcessingOutcome::Processed {
|
2020-01-06 06:30:37 +00:00
|
|
|
block_root: harness_a
|
|
|
|
.chain
|
|
|
|
.head()
|
|
|
|
.expect("should get head")
|
|
|
|
.beacon_block_root
|
2019-09-04 00:25:30 +00:00
|
|
|
})
|
|
|
|
);
|
2019-09-04 02:04:15 +00:00
|
|
|
|
2019-12-09 07:50:21 +00:00
|
|
|
harness_b
|
|
|
|
.chain
|
|
|
|
.fork_choice()
|
|
|
|
.expect("should run fork choice");
|
|
|
|
|
2019-09-04 02:04:15 +00:00
|
|
|
assert_eq!(
|
2020-01-06 06:30:37 +00:00
|
|
|
harness_b
|
|
|
|
.chain
|
|
|
|
.head()
|
|
|
|
.expect("should get head")
|
|
|
|
.beacon_block
|
2020-02-10 23:19:36 +00:00
|
|
|
.slot(),
|
2019-09-04 02:04:15 +00:00
|
|
|
Slot::new(skip_slots + 1)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn produces_and_processes_with_genesis_skip_slots() {
|
|
|
|
for i in 0..MinimalEthSpec::slots_per_epoch() * 4 {
|
|
|
|
run_skip_slot_test(i)
|
|
|
|
}
|
2019-09-04 00:25:30 +00:00
|
|
|
}
|