Adds support for the step parameter in BlocksByRange request (#737)

* Add duplication prevention to gossipsub

* Clean up topic logs

* Add content addressed messages for gossip

* Support BlocksByRange step parameter
This commit is contained in:
Age Manning 2019-12-20 17:12:16 +11:00 committed by GitHub
parent 45271abc16
commit 41d6d5fafd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -310,12 +310,22 @@ impl<T: BeaconChainTypes> MessageProcessor<T> {
"peer" => format!("{:?}", peer_id),
"count" => req.count,
"start_slot" => req.start_slot,
"step" => req.step,
);
if req.step == 0 {
warn!(self.log,
"Peer sent invalid range request";
"error" => "Step sent was 0");
self.network.disconnect(peer_id, GoodbyeReason::Fault);
return;
}
let mut block_roots = self
.chain
.forwards_iter_block_roots(Slot::from(req.start_slot))
.take_while(|(_root, slot)| slot.as_u64() < req.start_slot + req.count)
.take_while(|(_root, slot)| slot.as_u64() < req.start_slot + req.count * req.step)
.step_by(req.step as usize)
.map(|(root, _slot)| root)
.collect::<Vec<_>>();
@ -326,7 +336,9 @@ impl<T: BeaconChainTypes> MessageProcessor<T> {
if let Ok(Some(block)) = self.chain.store.get::<BeaconBlock<T::EthSpec>>(&root) {
// Due to skip slots, blocks could be out of the range, we ensure they are in the
// range before sending
if block.slot >= req.start_slot && block.slot < req.start_slot + req.count {
if block.slot >= req.start_slot
&& block.slot < req.start_slot + req.count * req.step
{
blocks_sent += 1;
self.network.send_rpc_response(
peer_id.clone(),