Gitcoin is GDPR complaint. Learn more in
Gitcoin's Terms & Conditions.
Check out the Issue Explorer
Looking to fund some work? You can submit a new Funded Issue here.
This issue is an extension of #524.
Blocks and attestations need to be validated before being propagated over the gossipsub network. The [networking specification](https://github.com/ethereum/eth2.0-specs/blob/dev/specs/networking/p2p-interface.md#global-topics) provides details on the validation of blocks and attestations.
This issue deals with the naive interop case for attestations, where we can ignore the `beacon_aggregate_and_proof` topic along with its validation. This is left for #580.
Specifically we need to add functionality that correctly validates blocks and attestations before propagation.
For block propagation, this issue ignores the case when a block's parent is unknown. For this case, the block is sent to the `sync_manager` which will handle searching for the blocks parents and propagation.
In the case that a parent is known, one can use the `CommitteeCaches` attached to the `BeaconState` to lookup block proposer and shard attester shufflings in order to validate the signature of the block. Note: The entire block must be deserialized in order to obtain the `hash_tree_root` that the signature is taken over.
Each `BeaconState` only has committee caches for the `Previous`, `Current` and `Next` epochs (3 epochs worth of shuffling, in total). If you need to advance a `BeaconState` to a future slot to obtain some future `CommitteeCache`, use `state_processing::per_slot_processing` (see `BeaconChain::process_block_internal` for an example). This may occur if a block is obtained whose slot is >3 epochs from it's parent (skipped a number of slots) and a new shuffling is required to validate the signature.
This is an expensive task and we would like to apply some heuristics to prevent DOS attacks. In this event, leave a TODO stub such that we can decrease the reputation of the peer that sent this block and also decide whether we propagate these blocks or not.