This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
ICMP message-routing gossip #304
Merged
Merged
Changes from 21 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
207e5b6
core logic for ICMP gossip
rphmeier 360c729
refactor gossip to make more extension friendly
rphmeier 9922f02
move files aroun
rphmeier 0125f18
extract attestation-gossip logic to its own module
rphmeier 5e25763
Merge branch 'master' into rh-icmp-gossip-primitives
rphmeier 3a4bd99
message validation and broadcast logic
rphmeier 9e76e36
fix upstream crates' compilation
rphmeier 65bbe33
add a test
rphmeier e9e6032
another test for overlapping
rphmeier a192da1
Some grammar and phrasing tweaks
rphmeier 8d4e67b
Merge branch 'master' into rh-icmp-gossip-primitives
rphmeier 63f26b0
add since parameter to ingress runtime API
rphmeier ec7d9de
broadcast out known unrouted message queues
rphmeier bdc213e
fix compilation of service and collator
rphmeier cfa47b8
Merge branch 'rh-icmp-gossip-primitives' of github.com:paritytech/pol…
rphmeier b38b712
remove useless index_mapping
rphmeier 727b92c
Merge branch 'master' into rh-icmp-gossip-primitives
rphmeier 6a9269d
some tests for icmp propagation
rphmeier ced6186
fix decoding bug and test icmp queue validation
rphmeier a2ea950
simplify engine-id definition
rphmeier 158942e
address some grumbles
rphmeier a5b5591
some cleanup of old circulation code
rphmeier 251cf2f
give network a handle to extrinsic store on startup
rphmeier 14c58fd
an honest collator ensures data available as well
rphmeier 0cec9da
address some grumbles
rphmeier e427fd9
add docs; rename the attestation session to "leaf work"
rphmeier 3d8df1f
module docs
rphmeier 8e6ef2c
move gossip back to gossip.rs
rphmeier 02ecf76
clean up and document attestation-gossip a bit
rphmeier 5ccf536
some more docs on the availability store
rphmeier acc36af
store all outgoing message queues in the availability store
rphmeier d736ea3
filter `Extrinsic` out of validation crate
rphmeier bded179
expunge Extrinsic from network
rphmeier ad31039
expunge Extrinsic from erasure-coding
rphmeier 550c4fd
expunge Extrinsic from collator
rphmeier 7a82f33
expunge from adder-collator
rphmeier e900307
rename ExtrinsicStore to AvailabilityStore everywhere
rphmeier 093a912
annotate and clean up message-routing tests
rphmeier bba4c5a
Merge branch 'master' into rh-icmp-gossip-primitives
rphmeier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,16 @@ pub struct Config { | |
pub path: PathBuf, | ||
} | ||
|
||
/// A record containing information about parachain extrinsic data to store. | ||
pub struct StoredExtrinsic { | ||
/// The actual extrinsic data. | ||
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. Terms highly confusing now; definitely suggest a blanket rename. |
||
pub inner: Extrinsic, | ||
/// The queue root of the `outgoing_messages` member of `inner`. | ||
/// | ||
/// The responsibility is on the creator to set this correctly. | ||
pub message_queue_root: Hash, | ||
} | ||
|
||
/// Some data to keep available. | ||
pub struct Data { | ||
/// The relay chain parent hash this should be localized to. | ||
|
@@ -53,7 +63,7 @@ pub struct Data { | |
/// Block data. | ||
pub block_data: BlockData, | ||
/// Extrinsic data. | ||
pub extrinsic: Option<Extrinsic>, | ||
pub extrinsic: Option<StoredExtrinsic>, | ||
} | ||
|
||
fn block_data_key(relay_parent: &Hash, candidate_hash: &Hash) -> Vec<u8> { | ||
|
@@ -119,10 +129,17 @@ impl Store { | |
); | ||
|
||
if let Some(extrinsic) = data.extrinsic { | ||
let encoded = extrinsic.inner.encode(); | ||
tx.put_vec( | ||
columns::DATA, | ||
extrinsic_key(&data.relay_parent, &data.candidate_hash).as_slice(), | ||
extrinsic.encode(), | ||
encoded.clone(), | ||
); | ||
|
||
tx.put_vec( | ||
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. So this is storing the message data ready for some later recall under some circumstances? If those circumstances are not already documented, maybe put them here. If they are then a pointer to them somewhere near here would be most useful for anyone coming to this code. |
||
columns::DATA, | ||
extrinsic.message_queue_root.as_ref(), | ||
encoded, | ||
); | ||
} | ||
|
||
|
@@ -168,10 +185,8 @@ impl Store { | |
} | ||
} | ||
|
||
/// Query extrinsic data. | ||
pub fn extrinsic(&self, relay_parent: Hash, candidate_hash: Hash) -> Option<Extrinsic> { | ||
let encoded_key = extrinsic_key(&relay_parent, &candidate_hash); | ||
match self.inner.get(columns::DATA, &encoded_key[..]) { | ||
fn extrinsic_with_key(&self, key: &[u8]) -> Option<Extrinsic> { | ||
match self.inner.get(columns::DATA, key) { | ||
Ok(Some(raw)) => Some( | ||
Extrinsic::decode(&mut &raw[..]).expect("all stored data serialized correctly; qed") | ||
), | ||
|
@@ -182,11 +197,23 @@ impl Store { | |
} | ||
} | ||
} | ||
|
||
/// Query extrinsic data by relay parent and candidate hash. | ||
pub fn extrinsic(&self, relay_parent: Hash, candidate_hash: Hash) -> Option<Extrinsic> { | ||
let encoded_key = extrinsic_key(&relay_parent, &candidate_hash); | ||
self.extrinsic_with_key(&encoded_key[..]) | ||
} | ||
|
||
/// Query extrinsic data by message queue root hash. | ||
pub fn extrinsic_by_queue_root(&self, queue_root: &Hash) -> Option<Extrinsic> { | ||
self.extrinsic_with_key(queue_root.as_ref()) | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use polkadot_primitives::parachain::OutgoingMessage; | ||
|
||
#[test] | ||
fn finalization_removes_unneeded() { | ||
|
@@ -207,15 +234,21 @@ mod tests { | |
parachain_id: para_id_1, | ||
candidate_hash: candidate_1, | ||
block_data: block_data_1.clone(), | ||
extrinsic: Some(Extrinsic { outgoing_messages: Vec::new() }), | ||
extrinsic: Some(StoredExtrinsic { | ||
inner: Extrinsic { outgoing_messages: Vec::new() }, | ||
message_queue_root: Default::default(), | ||
}), | ||
}).unwrap(); | ||
|
||
store.make_available(Data { | ||
relay_parent, | ||
parachain_id: para_id_2, | ||
candidate_hash: candidate_2, | ||
block_data: block_data_2.clone(), | ||
extrinsic: Some(Extrinsic { outgoing_messages: Vec::new() }), | ||
extrinsic: Some(StoredExtrinsic { | ||
inner: Extrinsic { outgoing_messages: Vec::new() }, | ||
message_queue_root: Default::default(), | ||
}), | ||
}).unwrap(); | ||
|
||
assert_eq!(store.block_data(relay_parent, candidate_1).unwrap(), block_data_1); | ||
|
@@ -232,4 +265,34 @@ mod tests { | |
assert!(store.extrinsic(relay_parent, candidate_1).is_some()); | ||
assert!(store.extrinsic(relay_parent, candidate_2).is_none()); | ||
} | ||
|
||
#[test] | ||
fn extrinsic_available_by_queue_root() { | ||
let relay_parent = [1; 32].into(); | ||
let para_id = 5.into(); | ||
let candidate = [2; 32].into(); | ||
let block_data = BlockData(vec![1, 2, 3]); | ||
|
||
let outgoing_messages = vec![ | ||
OutgoingMessage { target: 1.into(), data: vec![1, 2, 3, 4] }, | ||
OutgoingMessage { target: 2.into(), data: vec![5, 6, 7, 8] }, | ||
]; | ||
let ex = Extrinsic { outgoing_messages }; | ||
|
||
let message_queue_root = [0x42; 32].into(); | ||
|
||
let store = Store::new_in_memory(); | ||
store.make_available(Data { | ||
relay_parent, | ||
parachain_id: para_id, | ||
candidate_hash: candidate, | ||
block_data: block_data.clone(), | ||
extrinsic: Some(StoredExtrinsic { | ||
inner: ex.clone(), | ||
message_queue_root, | ||
}), | ||
}).unwrap(); | ||
|
||
assert_eq!(store.extrinsic_by_queue_root(&message_queue_root), Some(ex)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
what is "parachain extrinsic data"? a
set_heads
call? a single extrinsic of a parachain? what about parachains that don't have single extrinsics?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.
It's a piece of terminology we had since before Substrate, which essentially refers to the outgoing messages of the parachain, which has to remain available along with the block-data.
After Substrate introduced
Extrinsic
s, this naming became more confusing.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.
Maybe rename to
IntermediateData
or even justMessageData
?