mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-01 10:07:56 +00:00
Integrate HRMP (#258)
* HRMP message ingestion * Plumb hrmp_watermark to build_collation * Plumb hrmp_watermark to ValidationResult * Plumb hrmp outbound messages * Implement message-broker part of HRMP * Kill UPWARD_MESSAGES as well Otherwise, they will get resent each block * Add sudo versions for easier testing * Remove the xcmp module Not useful for the moment * Doc for HRMP message handler * Estimate the weight upper bound for on_finalize * Remove a redundant type annotation * fix spelling of a method * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Deabbreviate dmp and hrmp in the message ingestion type * Don't use binary_search since it's broken by a following rotate Instead use the linear search. We can afford linear search here since due to limited scalability of HRMP we can only have at most a couple of dozens of channels. * Fix the watermark Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -30,8 +30,9 @@ use codec::{Decode, Encode};
|
||||
use cumulus_primitives::{
|
||||
well_known_keys::{
|
||||
NEW_VALIDATION_CODE, PROCESSED_DOWNWARD_MESSAGES, UPWARD_MESSAGES, VALIDATION_DATA,
|
||||
HRMP_WATERMARK, HRMP_OUTBOUND_MESSAGES,
|
||||
},
|
||||
UpwardMessage, ValidationData,
|
||||
UpwardMessage, ValidationData, OutboundHrmpMessage,
|
||||
};
|
||||
use sp_core::storage::{ChildInfo, TrackedStorageKey};
|
||||
use sp_externalities::{
|
||||
@@ -165,15 +166,28 @@ pub fn validate_block<B: BlockT, E: ExecuteBlock<B>>(params: ValidationParams) -
|
||||
.and_then(|v| Decode::decode(&mut &v[..]).ok())
|
||||
.expect("`ValidationData` is required to be placed into the storage!");
|
||||
|
||||
let horizontal_messages = match overlay.storage(HRMP_OUTBOUND_MESSAGES).flatten() {
|
||||
Some(encoded) => Vec::<OutboundHrmpMessage>::decode(&mut &encoded[..])
|
||||
.expect("Outbound HRMP messages vec is not correctly encoded in the storage!"),
|
||||
None => Vec::new(),
|
||||
};
|
||||
|
||||
let hrmp_watermark = overlay
|
||||
.storage(HRMP_WATERMARK)
|
||||
.flatten()
|
||||
.map(|v| {
|
||||
Decode::decode(&mut &v[..])
|
||||
.expect("HRMP watermark is not encoded correctly")
|
||||
})
|
||||
.unwrap_or(validation_data.persisted.block_number);
|
||||
|
||||
ValidationResult {
|
||||
head_data,
|
||||
new_validation_code,
|
||||
upward_messages,
|
||||
processed_downward_messages,
|
||||
//TODO!
|
||||
horizontal_messages: Vec::new(),
|
||||
//TODO!
|
||||
hrmp_watermark: validation_data.persisted.block_number,
|
||||
horizontal_messages,
|
||||
hrmp_watermark,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user