lighthouse/consensus/types/src
Michael Sproul 9c785a9b33 Optimize process_attestation with active balance cache (#2560)
## Proposed Changes

Cache the total active balance for the current epoch in the `BeaconState`. Computing this value takes around 1ms, and this was negatively impacting block processing times on Prater, particularly when reconstructing states.

With a large number of attestations in each block, I saw the `process_attestations` function taking 150ms, which means that reconstructing hot states can take up to 4.65s (31 * 150ms), and reconstructing freezer states can take up to 307s (2047 * 150ms).

I opted to add the cache to the beacon state rather than computing the total active balance at the start of state processing and threading it through. Although this would be simpler in a way, it would waste time, particularly during block replay, as the total active balance doesn't change for the duration of an epoch. So we save ~32ms for hot states, and up to 8.1s for freezer states (using `--slots-per-restore-point 8192`).
2021-09-03 07:50:43 +00:00
..
beacon_state Optimize process_attestation with active balance cache (#2560) 2021-09-03 07:50:43 +00:00
test_utils [Altair] Sync committee pools (#2321) 2021-07-15 00:52:02 +00:00
aggregate_and_proof.rs Updates to make crates publishable (#2472) 2021-09-03 01:10:25 +00:00
attestation_data.rs Updates to make crates publishable (#2472) 2021-09-03 01:10:25 +00:00
attestation_duty.rs Updates to make crates publishable (#2472) 2021-09-03 01:10:25 +00:00
attestation.rs [Altair] Sync committee pools (#2321) 2021-07-15 00:52:02 +00:00
attester_slashing.rs Update for clippy 1.50 (#2193) 2021-02-15 00:09:12 +00:00
beacon_block_body.rs Metrics for sync aggregate fullness (#2439) 2021-07-13 02:22:55 +00:00
beacon_block_header.rs Updates to make crates publishable (#2472) 2021-09-03 01:10:25 +00:00
beacon_block.rs Updates to make crates publishable (#2472) 2021-09-03 01:10:25 +00:00
beacon_committee.rs Directory Restructure (#1163) 2020-05-18 21:24:23 +10:00
beacon_state.rs Optimize process_attestation with active balance cache (#2560) 2021-09-03 07:50:43 +00:00
chain_spec.rs Updates to make crates publishable (#2472) 2021-09-03 01:10:25 +00:00
checkpoint.rs Bump all spec tags to v0.12.1 (#1275) 2020-06-19 11:18:27 +10:00
config_and_preset.rs Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00
consts.rs Update to spec v1.1.0-beta.1 (#2460) 2021-07-27 05:43:35 +00:00
contribution_and_proof.rs Updates to make crates publishable (#2472) 2021-09-03 01:10:25 +00:00
deposit_data.rs Updates to make crates publishable (#2472) 2021-09-03 01:10:25 +00:00
deposit_message.rs Updates to make crates publishable (#2472) 2021-09-03 01:10:25 +00:00
deposit.rs Bump all spec tags to v0.12.1 (#1275) 2020-06-19 11:18:27 +10:00
enr_fork_id.rs Updates to make crates publishable (#2472) 2021-09-03 01:10:25 +00:00
eth1_data.rs Updates to make crates publishable (#2472) 2021-09-03 01:10:25 +00:00
eth_spec.rs Altair networking (#2300) 2021-08-04 01:44:57 +00:00
fork_context.rs Altair networking (#2300) 2021-08-04 01:44:57 +00:00
fork_data.rs Updates to make crates publishable (#2472) 2021-09-03 01:10:25 +00:00
fork_name.rs Altair validator client and HTTP API (#2404) 2021-08-06 00:47:31 +00:00
fork.rs Updates to make crates publishable (#2472) 2021-09-03 01:10:25 +00:00
free_attestation.rs Updates to make crates publishable (#2472) 2021-09-03 01:10:25 +00:00
graffiti.rs Updates to make crates publishable (#2472) 2021-09-03 01:10:25 +00:00
historical_batch.rs Bump all spec tags to v0.12.1 (#1275) 2020-06-19 11:18:27 +10:00
indexed_attestation.rs Updates to make crates publishable (#2472) 2021-09-03 01:10:25 +00:00
lib.rs Altair validator client and HTTP API (#2404) 2021-08-06 00:47:31 +00:00
participation_flags.rs Tree hash caching and optimisations for Altair (#2459) 2021-07-23 00:23:53 +00:00
participation_list.rs Rust 1.54.0 lints (#2483) 2021-07-30 01:11:47 +00:00
pending_attestation.rs Updates to make crates publishable (#2472) 2021-09-03 01:10:25 +00:00
preset.rs Updates to make crates publishable (#2472) 2021-09-03 01:10:25 +00:00
proposer_slashing.rs Implement slasher (#1567) 2020-11-23 03:43:22 +00:00
relative_epoch.rs Remove saturating arith from state_processing (#1644) 2020-09-25 05:18:21 +00:00
selection_proof.rs Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00
shuffling_id.rs Optimize validator duties (#2243) 2021-03-17 05:09:57 +00:00
signed_aggregate_and_proof.rs [Altair] Sync committee pools (#2321) 2021-07-15 00:52:02 +00:00
signed_beacon_block_header.rs Update for clippy 1.50 (#2193) 2021-02-15 00:09:12 +00:00
signed_beacon_block.rs Revert bad blocks on missed fork (#2529) 2021-08-30 06:41:31 +00:00
signed_contribution_and_proof.rs [Altair] Sync committee pools (#2321) 2021-07-15 00:52:02 +00:00
signed_voluntary_exit.rs Bump all spec tags to v0.12.1 (#1275) 2020-06-19 11:18:27 +10:00
signing_data.rs Consensus updates for v0.12 (#1228) 2020-06-03 14:56:54 +10:00
slot_data.rs [Altair] Sync committee pools (#2321) 2021-07-15 00:52:02 +00:00
slot_epoch_macros.rs Updated to comply with new clippy formatting rules (#2336) 2021-05-10 00:53:09 +00:00
slot_epoch.rs Updates to make crates publishable (#2472) 2021-09-03 01:10:25 +00:00
sqlite.rs Directory Restructure (#1163) 2020-05-18 21:24:23 +10:00
subnet_id.rs Updates to make crates publishable (#2472) 2021-09-03 01:10:25 +00:00
sync_aggregate.rs [Altair] Sync committee pools (#2321) 2021-07-15 00:52:02 +00:00
sync_aggregator_selection_data.rs [Altair] Sync committee pools (#2321) 2021-07-15 00:52:02 +00:00
sync_committee_contribution.rs Updates to make crates publishable (#2472) 2021-09-03 01:10:25 +00:00
sync_committee_message.rs Updates to make crates publishable (#2472) 2021-09-03 01:10:25 +00:00
sync_committee_subscription.rs Altair networking (#2300) 2021-08-04 01:44:57 +00:00
sync_committee.rs Validator monitor support for sync committees (#2476) 2021-08-31 23:31:36 +00:00
sync_duty.rs Updates to make crates publishable (#2472) 2021-09-03 01:10:25 +00:00
sync_selection_proof.rs [Altair] Sync committee pools (#2321) 2021-07-15 00:52:02 +00:00
sync_subnet_id.rs Updates to make crates publishable (#2472) 2021-09-03 01:10:25 +00:00
tree_hash_impls.rs Rust 1.54.0 lints (#2483) 2021-07-30 01:11:47 +00:00
validator_subscription.rs Implement standard eth2.0 API (#1569) 2020-10-01 11:12:36 +10:00
validator.rs Updates to make crates publishable (#2472) 2021-09-03 01:10:25 +00:00
voluntary_exit.rs Updates to make crates publishable (#2472) 2021-09-03 01:10:25 +00:00