nimbus-eth2/tests
Etan Kissling ea97e93e74
accelerate `getShufflingRef` (#4911)
When an uncached `ShufflingRef` is requested, we currently replay state
which can take several seconds. Acceleration is possible by:

1. Start from any state with locked-in `get_active_validator_indices`.
   Any blocks / slots applied to such a state can only affect that
   result for future epochs, so are viable for querying target epoch.
   `compute_activation_exit_epoch(state.slot.epoch) > target.epoch`

2. Determine highest common ancestor among `state` and `target.blck`.
   At the ancestor slot, same rules re `get_active_validator_indices`.
   `compute_activation_exit_epoch(ancestorSlot.epoch) > target.epoch`

3. We now have a `state` that shares history with `target.blck` up
   through a common ancestor slot. Any blocks / slots that the `state`
   contains, which are not part of the `target.blck` history, affect
   `get_active_validator_indices` at epochs _after_ `target.epoch`.

4. Select `state.randao_mixes[N]` that is closest to common ancestor.
   Either direction is fine (above / below ancestor).

5. From that RANDAO mix, mix in / out all RANDAO reveals from blocks
   in-between. This is just an XOR operation, so fully reversible.
   `mix = mix xor SHA256(blck.message.body.randao_reveal)`

6. Compute the attester dependent slot from `target.epoch`.
   `if epoch >= 2: (target.epoch - 1).start_slot - 1 else: GENESIS_SLOT`

7. Trace back from `target.blck` to the attester dependent slot.
   We now have the destination for which we want to obtain RANDAO.

8. Mix in all RANDAO reveals from blocks up through the `dependentBlck`.
   Same method, no special handling necessary for epoch transitions.

9. Combine `get_active_validator_indices` from `state` at `target.epoch`
   with the recovered RANDAO value at `dependentBlck` to obtain the
   requested shuffling, and construct the `ShufflingRef` without replay.

* more tests and simplify logic

* test with different number of deposits per branch

* Update beacon_chain/consensus_object_pools/blockchain_dag.nim

Co-authored-by: Jacek Sieka <jacek@status.im>

* `commonAncestor` tests

* lint

---------

Co-authored-by: Jacek Sieka <jacek@status.im>
2023-05-12 19:36:59 +02:00
..
consensus_spec final portion of trivial v1.3.0 bumps (#4926) 2023-05-11 09:54:29 +00:00
fuzzing test fixture cleanups (#2976) 2021-10-12 13:36:52 +02:00
helpers fix ExecutionPayload(Header) JSON serialization (#3679) 2022-06-01 14:57:28 +02:00
media Add a JWT file that must be present on the file system for the test suite to succeed 2023-03-17 17:49:39 +02:00
mocking fix `attachMerkleProofs` to support multiple deposits (#4932) 2023-05-11 11:45:55 +03:00
simulation fix false positive getopt failure with multiple getopt matches in searched path (#4797) 2023-04-08 00:18:29 +00:00
slashing_protection use ZERO_HASH for default(Eth2Digest)/Eth2Digest() in func calls (#3770) 2022-06-18 04:57:37 +00:00
all_tests.nim embed genesis states using incbin (#4905) 2023-05-11 11:11:00 +00:00
nim.cfg Local sim impovements (#4551) 2023-02-23 02:10:07 +00:00
test_action_tracker.nim Fix VC-based sync subnet subscriptions (#4293) 2022-11-08 12:43:38 +01:00
test_attestation_pool.nim more withdrowls (#4674) 2023-03-02 17:13:35 +01:00
test_beacon_chain_db.nim rename `EIP4844` > `Deneb` in `test_beacon_chain_db` (#4721) 2023-03-11 02:49:17 +01:00
test_beacon_time.nim fix countdown over time period (#4449) 2022-12-30 21:36:31 +01:00
test_block_dag.nim accelerate `getShufflingRef` (#4911) 2023-05-12 19:36:59 +02:00
test_block_processor.nim Quarantine and reassembly of gossiped blobs and blocks (#4808) 2023-04-13 19:11:40 +00:00
test_block_quarantine.nim Simplify block quarantine blobless (#4824) 2023-04-16 08:37:56 +00:00
test_blockchain_dag.nim accelerate `getShufflingRef` (#4911) 2023-05-12 19:36:59 +02:00
test_conf.nim remove Nim 1.2-compatible `push raise`s and update copyright notice years (#4528) 2023-01-20 14:14:37 +00:00
test_datatypes.nim remove false OnBlockAdded dependency on phase0 HashedBeaconState (#2661) 2021-06-21 08:35:24 +00:00
test_deposit_snapshots.nim Support for obtaining deposit snapshots during trustedNodeSync (#4303) 2022-12-07 12:24:51 +02:00
test_discovery.nim detect mismatch of config and binary (#4132) 2022-09-19 12:07:46 +03:00
test_el_conf.nim Add a JWT file that must be present on the file system for the test suite to succeed 2023-03-17 17:49:39 +02:00
test_engine_authentication.nim remove unused imports in tests/ (#3713) 2022-06-07 17:05:06 +00:00
test_eth1_monitor.nim `excess_data_gas` after `withdrawals` cleanup (#4900) 2023-05-05 23:15:47 +00:00
test_eth2_ssz_serialization.nim use isZeroMemory for Eth2Digest comparisons (#3386) 2022-02-14 05:26:19 +00:00
test_exit_pool.nim don't clear validator change subpools after creating each block (#4704) 2023-03-09 18:19:36 +02:00
test_forks.nim test forks.nim capella and deneb block/state ssz serialization (#4772) 2023-03-29 13:22:19 +00:00
test_gossip_transition.nim rename ConsensusFork.EIP4844 to ConsensusFork.Deneb (#4692) 2023-03-04 13:35:39 +00:00
test_gossip_validation.nim accelerate `getShufflingRef` (#4911) 2023-05-12 19:36:59 +02:00
test_helpers.nim remove empty block fallback now that capella's on mainnnet (#4821) 2023-04-18 09:21:15 +00:00
test_honest_validator.nim Add blob sidecar gossip validation (#4785) 2023-04-04 15:12:34 +00:00
test_key_splitting.nim bearssl: split abi (#3755) 2022-06-21 10:29:16 +02:00
test_keymanager_api.nim Support for driving multiple EL nodes from a single Nimbus BN (#4465) 2023-03-05 01:40:21 +00:00
test_keystore.nim Keymanager API for the validator client (#3976) 2022-08-19 13:30:07 +03:00
test_keystore_management.nim Exclusive keystore locking (#3907) 2022-08-08 00:53:20 +03:00
test_light_client.nim accelerate `getShufflingRef` (#4911) 2023-05-12 19:36:59 +02:00
test_light_client_processor.nim accelerate `getShufflingRef` (#4911) 2023-05-12 19:36:59 +02:00
test_message_signatures.nim Implement all sync committee duties in the validator client (#3583) 2022-05-10 10:03:40 +00:00
test_network_metadata.nim embed genesis states using incbin (#4905) 2023-05-11 11:11:00 +00:00
test_peer_pool.nim proc -> func in ncli/, research/, and test/ (#2818) 2021-08-25 14:51:52 +00:00
test_remote_keystore.nim Initial public version of the Verifying Web3Signer functionality (#4912) 2023-05-09 11:16:43 +03:00
test_serialization.nim remove most std/options imports (#4778) 2023-03-31 20:46:47 +00:00
test_signing_node.nim Initial public version of the Verifying Web3Signer functionality (#4912) 2023-05-09 11:16:43 +03:00
test_spec.nim `BeaconStateFork/BeaconBlockFork` -> `ConsensusFork` (#4560) 2023-01-28 19:53:41 +00:00
test_statediff.nim update statediffs to support capella (#4852) 2023-04-23 22:15:14 +03:00
test_sync_committee_pool.nim drop subset sync contributions in gossip (#4490) 2023-01-12 15:08:08 +01:00
test_sync_manager.nim Blob handling sync fixes (#4888) 2023-05-06 08:58:50 +00:00
test_validator_pool.nim restore doppelganger check on connectivity loss (#4616) 2023-02-20 13:28:56 +02:00
test_zero_signature.nim update spec references from eth2.0-specs to consensus-specs and to v1.1.0-beta.2 (#2822) 2021-08-26 10:21:52 +02:00
testblockutil.nim accelerate `getShufflingRef` (#4911) 2023-05-12 19:36:59 +02:00
testdbutil.nim accelerate `getShufflingRef` (#4911) 2023-05-12 19:36:59 +02:00
teststateutil.nim remove most std/options imports (#4778) 2023-03-31 20:46:47 +00:00
testutil.nim remove Nim 1.2-compatible `push raise`s and update copyright notice years (#4528) 2023-01-20 14:14:37 +00:00