lighthouse/beacon_node/beacon_chain/src
Paul Hauner a17f74896a Fix bad assumption when checking finalized descendant (#1629)
## Issue Addressed

- Resolves #1616

## Proposed Changes

Fixes a bug where we are unable to read the finalized block from fork choice.

## Detail

I had made an assumption that the finalized block always has a parent root of `None`:

e5fc6bab48/consensus/fork_choice/src/fork_choice.rs (L749-L752)

This was a faulty assumption, we don't set parent *roots* to `None`. Instead we *sometimes* set parent *indices* to `None`, depending if this pruning condition is satisfied: 

e5fc6bab48/consensus/proto_array/src/proto_array.rs (L229-L232) 

The bug manifested itself like this:

1. We attempt to get the finalized block from fork choice
1. We try to check that the block is descendant of the finalized block (note: they're the same block).
1. We expect the parent root to be `None`, but it's actually the parent root of the finalized root.
1. We therefore end up checking if the parent of the finalized root is a descendant of itself. (note: it's an *ancestor* not a *descendant*).
1. We therefore declare that the finalized block is not a descendant of (or eq to) the finalized block. Bad.

## Additional Info

In reflection, I made a poor assumption in the quest to obtain a probably negligible performance gain. The performance gain wasn't worth the risk and we got burnt.
2020-09-18 05:14:31 +00:00
..
attestation_verification.rs Fix mistake with attestation skip slots (#1539) 2020-08-18 06:28:26 +00:00
beacon_chain.rs Update state before producing attestation (#1596) 2020-09-08 11:25:43 +00:00
beacon_fork_choice_store.rs Apply store refactor to new fork choice 2020-06-17 15:20:44 +10:00
beacon_snapshot.rs Add no-copy block processing cache (#863) 2020-04-06 10:53:33 +10:00
block_verification.rs Fix bad assumption when checking finalized descendant (#1629) 2020-09-18 05:14:31 +00:00
builder.rs Ignore blocks that skip a large distance from their parent (#1530) 2020-08-17 10:54:58 +00:00
chain_config.rs Set default max skips to 700 (#1542) 2020-08-18 09:27:04 +00:00
errors.rs Fix bug in database pruning (#1564) 2020-08-26 00:01:06 +00:00
eth1_chain.rs Fix clippy warnings (#1385) 2020-07-23 14:18:00 +00:00
events.rs Fix clippy warnings (#1385) 2020-07-23 14:18:00 +00:00
head_tracker.rs Race condition fix + Reliability improvements around forks pruning (#1132) 2020-05-16 13:23:32 +10:00
lib.rs Alternative (to BeaconChainHarness) BeaconChain testing API (#1380) 2020-08-26 09:24:55 +00:00
metrics.rs v0.12 fork choice update (#1229) 2020-06-17 11:10:22 +10:00
migrate.rs Alternative (to BeaconChainHarness) BeaconChain testing API (#1380) 2020-08-26 09:24:55 +00:00
naive_aggregation_pool.rs Push naive attestations into op pool (#1466) 2020-08-06 07:26:46 +00:00
observed_attestations.rs Move long-running tests to dbg (#1137) 2020-05-13 10:55:02 +10:00
observed_attesters.rs Fix clippy warnings (#1385) 2020-07-23 14:18:00 +00:00
observed_block_producers.rs Add attestation gossip pre-verification (#983) 2020-05-06 21:42:56 +10:00
observed_operations.rs Process exits and slashings off the network (#1253) 2020-06-18 21:06:34 +10:00
persisted_beacon_chain.rs Clean up database abstractions (#1200) 2020-06-01 08:13:49 +10:00
persisted_fork_choice.rs v0.12 fork choice update (#1229) 2020-06-17 11:10:22 +10:00
shuffling_cache.rs Optimize attestation processing (#841) 2020-03-05 17:19:35 +11:00
snapshot_cache.rs Support multiple BLS implementations (#1335) 2020-07-25 02:03:18 +00:00
test_utils.rs Alternative (to BeaconChainHarness) BeaconChain testing API (#1380) 2020-08-26 09:24:55 +00:00
timeout_rw_lock.rs Add timeouts to canonical head rwlock (#759) 2020-01-06 17:30:37 +11:00
validator_pubkey_cache.rs Support multiple BLS implementations (#1335) 2020-07-25 02:03:18 +00:00