lighthouse/beacon_node
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
..
beacon_chain Fix bad assumption when checking finalized descendant (#1629) 2020-09-18 05:14:31 +00:00
client Eth1 network exit on wrong network id (#1563) 2020-08-31 02:36:17 +00:00
eth1 Eth1 network exit on wrong network id (#1563) 2020-08-31 02:36:17 +00:00
eth2_libp2p Shift gossipsub validation (#1612) 2020-09-18 02:05:36 +00:00
genesis Lighthouse crate v0.2.0 bump (#1450) 2020-08-06 03:43:05 +00:00
network Temporary Sync Work-Around (#1615) 2020-09-13 23:58:49 +00:00
operation_pool Lighthouse crate v0.2.0 bump (#1450) 2020-08-06 03:43:05 +00:00
rest_api Remove rayon from rest_api (#1562) 2020-08-24 07:28:54 +00:00
src Eth1 network exit on wrong network id (#1563) 2020-08-31 02:36:17 +00:00
store Alternative (to BeaconChainHarness) BeaconChain testing API (#1380) 2020-08-26 09:24:55 +00:00
tests Improve tokio task execution (#1181) 2020-06-04 21:48:05 +10:00
timer Lighthouse crate v0.2.0 bump (#1450) 2020-08-06 03:43:05 +00:00
websocket_server Lighthouse crate v0.2.0 bump (#1450) 2020-08-06 03:43:05 +00:00
Cargo.toml Bump version to v0.2.9 (#1598) 2020-09-09 02:28:35 +00:00