46be05f728
## Issue Addressed #4118 ## Proposed Changes This PR introduces a "progressive balances" cache on the `BeaconState`, which keeps track of the accumulated target attestation balance for the current & previous epochs. The cached values are utilised by fork choice to calculate unrealized justification and finalization (instead of converting epoch participation arrays to balances for each block we receive). This optimization will be rolled out gradually to allow for more testing. A new `--progressive-balances disabled|checked|strict|fast` flag is introduced to support this: - `checked`: enabled with checks against participation cache, and falls back to the existing epoch processing calculation if there is a total target attester balance mismatch. There is no performance gain from this as the participation cache still needs to be computed. **This is the default mode for now.** - `strict`: enabled with checks against participation cache, returns error if there is a mismatch. **Used for testing only**. - `fast`: enabled with no comparative checks and without computing the participation cache. This mode gives us the performance gains from the optimization. This is still experimental and not currently recommended for production usage, but will become the default mode in a future release. - `disabled`: disable the usage of progressive cache, and use the existing method for FFG progression calculation. This mode may be useful if we find a bug and want to stop the frequent error logs. ### Tasks - [x] Initial cache implementation in `BeaconState` - [x] Perform checks in fork choice to compare the progressive balances cache against results from `ParticipationCache` - [x] Add CLI flag, and disable the optimization by default - [x] Testing on Goerli & Benchmarking - [x] Move caching logic from state processing to the `ProgressiveBalancesCache` (see [this comment](https://github.com/sigp/lighthouse/pull/4362#discussion_r1230877001)) - [x] Add attesting balance metrics Co-authored-by: Jimmy Chen <jimmy@sigmaprime.io> |
||
---|---|---|
.. | ||
src | ||
tests | ||
.gitignore | ||
Cargo.toml | ||
check_all_files_accessed.py | ||
Makefile | ||
README.md |
Consensus Specification Tests
This crate parses and executes the test vectors at ethereum/consensus-spec-tests.
Functionality is achieved only via the $ cargo test --features ef_tests
command.
Running the Tests
Because the test vectors are very large, we do not download or run them by default. To download them, run (in this directory):
$ make
Note: this may download hundreds of MB of compressed archives from the ethereum/consensus-spec-tests, which may expand into several GB of files.
If successful, you should now have the extracted tests in ./consensus-spec-tests
.
Run them with:
$ cargo test --features ef_tests
The tests won't run without the ef_tests
feature enabled (this is to ensure that a top-level
cargo test --all
won't fail on missing files).
Saving Space
When you download the tests, the downloaded archives will be kept in addition to the extracted files. You have several options for saving space:
- Delete the archives (
make clean-archives
), and keep the extracted files. Suitable for everyday use, just don't re-runmake
or it will redownload the archives. - Delete the extracted files (
make clean-test-files
), and keep the archives. Suitable for CI, or temporarily saving space. If you re-runmake
it will extract the archives rather than redownloading them. - Delete everything (
make clean
). Good for updating to a new version, or if you no longer wish to run the EF tests.