Update to latest Substrate & Polkadot (#341)

This commit is contained in:
Bastian Köcher
2021-02-24 20:15:52 +01:00
committed by GitHub
parent d8126cdc13
commit fc8c690cf8
6 changed files with 417 additions and 258 deletions
Generated
+382 -247
View File
File diff suppressed because it is too large Load Diff
@@ -106,7 +106,7 @@ pub fn import_queue<Client, Block: BlockT, I>(
client: Arc<Client>,
block_import: I,
inherent_data_providers: InherentDataProviders,
spawner: &impl sp_core::traits::SpawnNamed,
spawner: &impl sp_core::traits::SpawnEssentialNamed,
registry: Option<&substrate_prometheus_endpoint::Registry>,
) -> ClientResult<BasicQueue<Block, I::Transaction>>
where
+19 -5
View File
@@ -145,6 +145,8 @@ async fn make_gossip_message_and_header(
&alice_public.into(),
)
.await
.ok()
.flatten()
.expect("Signing statement");
(signed, header)
@@ -203,7 +205,9 @@ fn check_signer_is_legit_validator() {
let (mut validator, api) = make_validator_and_api();
let (signed_statement, header) = block_on(make_gossip_message_and_header_using_genesis(api, 1));
let data = BlockAnnounceData::try_from(signed_statement).unwrap().encode();
let data = BlockAnnounceData::try_from(signed_statement)
.unwrap()
.encode();
let res = block_on(validator.validate(&header, &data));
assert_eq!(Validation::Failure { disconnect: true }, res.unwrap());
@@ -215,7 +219,9 @@ fn check_statement_is_correctly_signed() {
let (signed_statement, header) = block_on(make_gossip_message_and_header_using_genesis(api, 0));
let mut data = BlockAnnounceData::try_from(signed_statement).unwrap().encode();
let mut data = BlockAnnounceData::try_from(signed_statement)
.unwrap()
.encode();
// The signature comes at the end of the type, so change a bit to make the signature invalid.
let last = data.len() - 1;
@@ -256,11 +262,15 @@ fn check_statement_seconded() {
0,
&alice_public.into(),
))
.ok()
.flatten()
.expect("Signs statement");
let data = BlockAnnounceData {
receipt: Default::default(),
statement: signed_statement.convert_payload(),
}.encode();
}
.encode();
let res = block_on(validator.validate(&header, &data));
assert_eq!(Validation::Failure { disconnect: true }, res.unwrap());
@@ -272,7 +282,9 @@ fn check_header_match_candidate_receipt_header() {
let (signed_statement, mut header) =
block_on(make_gossip_message_and_header_using_genesis(api, 0));
let data = BlockAnnounceData::try_from(signed_statement).unwrap().encode();
let data = BlockAnnounceData::try_from(signed_statement)
.unwrap()
.encode();
header.number = 300;
let res = block_on(validator.validate(&header, &data));
@@ -297,7 +309,9 @@ fn relay_parent_not_imported_when_block_announce_is_processed() {
let (signed_statement, header) = make_gossip_message_and_header(api, block.hash(), 0).await;
let data = BlockAnnounceData::try_from(signed_statement).unwrap().encode();
let data = BlockAnnounceData::try_from(signed_statement)
.unwrap()
.encode();
let mut validation = validator.validate(&header, &data);
@@ -20,6 +20,7 @@ use frame_executive::ExecuteBlock;
use sp_runtime::traits::{Block as BlockT, HashFor, Header as HeaderT, NumberFor};
use sp_std::{boxed::Box, vec::Vec};
use sp_io::KillChildStorageResult;
use hash_db::{HashDB, EMPTY_PREFIX};
@@ -277,7 +278,7 @@ impl<'a, B: BlockT> Externalities for WitnessExt<'a, B> {
self.inner.place_child_storage(child_info, key, value)
}
fn kill_child_storage(&mut self, child_info: &ChildInfo, limit: Option<u32>) -> bool {
fn kill_child_storage(&mut self, child_info: &ChildInfo, limit: Option<u32>) -> (bool, u32) {
self.inner.kill_child_storage(child_info, limit)
}
@@ -460,9 +461,18 @@ fn host_default_child_storage_clear(storage_key: &[u8], key: &[u8]) {
with_externalities(|ext| ext.place_child_storage(&child_info, key.to_vec(), None))
}
fn host_default_child_storage_storage_kill(storage_key: &[u8], limit: Option<u32>) -> bool {
fn host_default_child_storage_storage_kill(
storage_key: &[u8],
limit: Option<u32>,
) -> KillChildStorageResult {
let child_info = ChildInfo::new_default(storage_key);
with_externalities(|ext| ext.kill_child_storage(&child_info, limit))
with_externalities(|ext| {
let (all_removed, num_removed) = ext.kill_child_storage(&child_info, limit);
match all_removed {
true => KillChildStorageResult::AllRemoved(num_removed),
false => KillChildStorageResult::SomeRemaining(num_removed),
}
})
}
fn host_default_child_storage_exists(storage_key: &[u8], key: &[u8]) -> bool {
+1 -1
View File
@@ -78,7 +78,7 @@ pub fn new_partial(
client.clone(),
client.clone(),
inherent_data_providers.clone(),
&task_manager.spawn_handle(),
&task_manager.spawn_essential_handle(),
registry.clone(),
)?;
+1 -1
View File
@@ -97,7 +97,7 @@ pub fn new_partial(
client.clone(),
client.clone(),
inherent_data_providers.clone(),
&task_manager.spawn_handle(),
&task_manager.spawn_essential_handle(),
registry.clone(),
)?;