lighthouse/beacon_node
Pawan Dhananjay 88063398f6 Prevent double import of blocks (#2647)
## Issue Addressed

Resolves #2611 

## Proposed Changes

Adds a duplicate block root cache to the `BeaconProcessor`. Adds the block root to the cache before calling `process_gossip_block` and `process_rpc_block`. Since `process_rpc_block` is called only for single block lookups, we don't have to worry about batched block imports.

The block is imported from the source(gossip/rpc) that arrives first. The block that arrives second is not imported to avoid the db access issue.
There are 2 cases:
1. Block that arrives second is from rpc: In this case, we return an optimistic `BlockError::BlockIsAlreadyKnown` to sync.
2. Block that arrives second is from gossip: In this case, we only do gossip verification and forwarding but don't import the block into the the beacon chain.

## Additional info
Splits up `process_gossip_block` function to `process_gossip_unverified_block` and `process_gossip_verified_block`.
2021-10-28 03:36:14 +00:00
..
beacon_chain Add flag to disable lock timeouts (#2714) 2021-10-19 00:30:40 +00:00
client Rename eth2_libp2p to lighthouse_network (#2702) 2021-10-19 00:30:39 +00:00
eth1 Remove unused deps (#2592) 2021-09-30 04:31:42 +00:00
genesis Remove unused deps (#2592) 2021-09-30 04:31:42 +00:00
http_api Add API version headers and map_fork_name! (#2745) 2021-10-28 01:18:04 +00:00
http_metrics Rename eth2_libp2p to lighthouse_network (#2702) 2021-10-19 00:30:39 +00:00
lighthouse_network Add a waker to the RPC handler (#2721) 2021-10-21 06:14:36 +00:00
network Prevent double import of blocks (#2647) 2021-10-28 03:36:14 +00:00
operation_pool Add Altair tests to op pool (#2723) 2021-10-16 05:07:23 +00:00
src Fix purge-db edge case (#2747) 2021-10-25 22:11:28 +00:00
store Add API version headers and map_fork_name! (#2745) 2021-10-28 01:18:04 +00:00
tests Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00
timer Remove unused deps (#2592) 2021-09-30 04:31:42 +00:00
websocket_server Server sent events (#1920) 2020-12-04 00:18:58 +00:00
Cargo.toml Rename eth2_libp2p to lighthouse_network (#2702) 2021-10-19 00:30:39 +00:00