-
Notifications
You must be signed in to change notification settings - Fork 1.6k
implement bitfield distribution subsystem #1368
Changes from 1 commit
31cb1ad
ddb6228
6ac2c62
4b100df
a3bd8c0
7909d47
e3c8248
86f4fdb
3cf0878
6a6d7bc
1aa1842
ad0555b
7966769
e8c901a
e33dafe
6594dee
4c6f9b4
af2849b
977102b
92431f3
23c050e
a431601
a5077ee
be2533e
64b6ec1
52d9800
df8fe1d
38661f7
f1f7cab
f94b8c5
7a4bd5e
b299ad3
09766c1
df7a6f0
2398681
8ed8aba
65e8edb
087784a
d91bcbd
c957bf9
36a6672
5b7c963
794c6c3
f3a718e
e33e943
b8d3941
99f574e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -142,10 +142,10 @@ impl BitfieldDistribution { | |
| signed_availability, | ||
| ) => { | ||
| trace!(target: "bitd", "Processing DistributeBitfield"); | ||
| let per_job = &mut tracker.per_relay_parent.get_mut(&hash).expect("Overseer does not send work items related to relay parents that are not part of our workset. qed"); | ||
| let job_data = &mut tracker.per_relay_parent.get_mut(&hash).expect("Overseer does not send work items related to relay parents that are not part of our workset. qed"); | ||
|
|
||
| let validator = { | ||
| per_job | ||
| job_data | ||
| .validator_set | ||
| .get(signed_availability.validator_index() as usize) | ||
| .expect("Our own validation index exists. qed") | ||
|
||
|
|
@@ -158,7 +158,7 @@ impl BitfieldDistribution { | |
| signed_availability, | ||
| }; | ||
|
|
||
| relay_message(&mut ctx, per_job, peer_views, validator, msg) | ||
| relay_message(&mut ctx, job_data, peer_views, validator, msg) | ||
| .await?; | ||
| } | ||
| BitfieldDistributionMessage::NetworkBridgeUpdate(event) => { | ||
|
|
@@ -226,7 +226,7 @@ where | |
| /// Can be originated by another subsystem or received via network from another peer. | ||
| async fn relay_message<Context>( | ||
| ctx: &mut Context, | ||
| per_job: &mut PerRelayParentData, | ||
| job_data: &mut PerRelayParentData, | ||
| peer_views: &mut HashMap<PeerId, View>, | ||
| validator: ValidatorId, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant yes, but from where the message is used, the validator is already extracted and hence error handling is externalised from this |
||
| message: BitfieldGossipMessage, | ||
|
|
@@ -247,7 +247,7 @@ where | |
| ) | ||
| ).await; | ||
|
|
||
| let message_sent_to_peer = &mut (per_job.message_sent_to_peer); | ||
| let message_sent_to_peer = &mut (job_data.message_sent_to_peer); | ||
|
|
||
| // concurrently pass on the bitfield distribution to all interested peers | ||
drahnr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| let interested_peers = peer_views | ||
|
|
@@ -403,17 +403,17 @@ where | |
| let delta_set: HashMap<ValidatorId, BitfieldGossipMessage> = delta_vec | ||
drahnr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| .into_iter() | ||
| .filter_map(|new_relay_parent_interest| { | ||
| if let Some(per_job) = (&*tracker).per_relay_parent.get(&new_relay_parent_interest) { | ||
| if let Some(job_data) = (&*tracker).per_relay_parent.get(&new_relay_parent_interest) { | ||
| // send all messages | ||
| let one_per_validator = per_job.one_per_validator.clone(); | ||
| let one_per_validator = job_data.one_per_validator.clone(); | ||
| let origin = origin.clone(); | ||
| Some( | ||
| one_per_validator | ||
| .into_iter() | ||
| .filter(move |(validator, _message)| { | ||
| // except for the ones the peer already has | ||
| // let validator = validator.clone(); | ||
drahnr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| per_job.message_from_validator_needed_by_peer(&origin, validator) | ||
| job_data.message_from_validator_needed_by_peer(&origin, validator) | ||
drahnr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }), | ||
| ) | ||
| } else { | ||
|
|
@@ -442,14 +442,14 @@ async fn send_tracked_gossip_message<Context>( | |
| where | ||
| Context: SubsystemContext<Message = BitfieldDistributionMessage>, | ||
| { | ||
| let per_job = if let Some(per_job) = tracker.per_relay_parent.get_mut(&message.relay_parent) { | ||
| per_job | ||
| let job_data = if let Some(job_data) = tracker.per_relay_parent.get_mut(&message.relay_parent) { | ||
| job_data | ||
| } else { | ||
| // @todo punishing here seems unreasonable | ||
| return Ok(()); | ||
drahnr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
|
|
||
| let message_sent_to_peer = &mut (per_job.message_sent_to_peer); | ||
| let message_sent_to_peer = &mut (job_data.message_sent_to_peer); | ||
| message_sent_to_peer | ||
| .entry(dest.clone()) | ||
| .or_default() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to be defensive here. The overseer doesn't do deep inspection of messages sent, so a "rogue" or buggy subsystem implementation might send a message with bad or outdated relay-parent hash. Better to just ignore.