Update Substrate & Polkadot (#428)

This commit is contained in:
Bastian Köcher
2021-05-04 22:32:06 +02:00
committed by GitHub
parent 530c95d2df
commit 5847e78fd9
6 changed files with 217 additions and 230 deletions
+209 -210
View File
File diff suppressed because it is too large Load Diff
+7 -7
View File
@@ -37,7 +37,7 @@ use polkadot_node_primitives::{SignedFullStatement, Statement};
use polkadot_parachain::primitives::HeadData; use polkadot_parachain::primitives::HeadData;
use polkadot_primitives::v1::{ use polkadot_primitives::v1::{
Block as PBlock, Hash as PHash, CandidateReceipt, CompactStatement, Id as ParaId, Block as PBlock, Hash as PHash, CandidateReceipt, CompactStatement, Id as ParaId,
OccupiedCoreAssumption, ParachainHost, SignedStatement, SigningContext, OccupiedCoreAssumption, ParachainHost, UncheckedSigned, SigningContext,
}; };
use polkadot_service::ClientHandle; use polkadot_service::ClientHandle;
@@ -77,7 +77,7 @@ impl fmt::Display for BlockAnnounceError {
#[derive(Encode, Decode, Debug)] #[derive(Encode, Decode, Debug)]
pub struct BlockAnnounceData { pub struct BlockAnnounceData {
receipt: CandidateReceipt, receipt: CandidateReceipt,
statement: SignedStatement, statement: UncheckedSigned<CompactStatement>,
} }
impl BlockAnnounceData { impl BlockAnnounceData {
@@ -85,7 +85,7 @@ impl BlockAnnounceData {
/// ///
/// This will not check the signature, for this you should use [`BlockAnnounceData::check_signature`]. /// This will not check the signature, for this you should use [`BlockAnnounceData::check_signature`].
fn validate(&self, encoded_header: Vec<u8>) -> Result<(), Validation> { fn validate(&self, encoded_header: Vec<u8>) -> Result<(), Validation> {
let candidate_hash = if let CompactStatement::Seconded(h) = self.statement.payload() { let candidate_hash = if let CompactStatement::Seconded(h) = self.statement.unchecked_payload() {
h h
} else { } else {
tracing::debug!( tracing::debug!(
@@ -118,7 +118,7 @@ impl BlockAnnounceData {
/// ///
/// Returns an `Err(_)` if it failed. /// Returns an `Err(_)` if it failed.
fn check_signature<P>( fn check_signature<P>(
&self, self,
relay_chain_client: &Arc<P>, relay_chain_client: &Arc<P>,
) -> Result<Validation, BlockAnnounceError> ) -> Result<Validation, BlockAnnounceError>
where where
@@ -126,7 +126,7 @@ impl BlockAnnounceData {
P::Api: ParachainHost<PBlock>, P::Api: ParachainHost<PBlock>,
{ {
let runtime_api = relay_chain_client.runtime_api(); let runtime_api = relay_chain_client.runtime_api();
let validator_index = self.statement.validator_index(); let validator_index = self.statement.unchecked_validator_index();
let runtime_api_block_id = BlockId::Hash(self.receipt.descriptor.relay_parent); let runtime_api_block_id = BlockId::Hash(self.receipt.descriptor.relay_parent);
let session_index = match runtime_api.session_index_for_child(&runtime_api_block_id) { let session_index = match runtime_api.session_index_for_child(&runtime_api_block_id) {
@@ -163,7 +163,7 @@ impl BlockAnnounceData {
// Check statement is correctly signed. // Check statement is correctly signed.
if self if self
.statement .statement
.check_signature(&signing_context, &signer) .try_into_checked(&signing_context, &signer)
.is_err() .is_err()
{ {
tracing::debug!( tracing::debug!(
@@ -190,7 +190,7 @@ impl TryFrom<&'_ SignedFullStatement> for BlockAnnounceData {
Ok(BlockAnnounceData { Ok(BlockAnnounceData {
receipt, receipt,
statement: stmt.convert_payload(), statement: stmt.convert_payload().into(),
}) })
} }
} }
+1 -1
View File
@@ -282,7 +282,7 @@ fn check_statement_seconded() {
let data = BlockAnnounceData { let data = BlockAnnounceData {
receipt: Default::default(), receipt: Default::default(),
statement: signed_statement.convert_payload(), statement: signed_statement.convert_payload().into(),
} }
.encode(); .encode();
@@ -528,10 +528,6 @@ impl_runtime_apis! {
fn check_inherents(block: Block, data: sp_inherents::InherentData) -> sp_inherents::CheckInherentsResult { fn check_inherents(block: Block, data: sp_inherents::InherentData) -> sp_inherents::CheckInherentsResult {
data.check_extrinsics(&block) data.check_extrinsics(&block)
} }
fn random_seed() -> <Block as BlockT>::Hash {
RandomnessCollectiveFlip::random_seed().0
}
} }
impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime { impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
@@ -334,10 +334,6 @@ impl_runtime_apis! {
fn check_inherents(block: Block, data: sp_inherents::InherentData) -> sp_inherents::CheckInherentsResult { fn check_inherents(block: Block, data: sp_inherents::InherentData) -> sp_inherents::CheckInherentsResult {
data.check_extrinsics(&block) data.check_extrinsics(&block)
} }
fn random_seed() -> <Block as BlockT>::Hash {
System::parent_hash()
}
} }
impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime { impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
-4
View File
@@ -355,10 +355,6 @@ impl_runtime_apis! {
fn check_inherents(block: Block, data: sp_inherents::InherentData) -> sp_inherents::CheckInherentsResult { fn check_inherents(block: Block, data: sp_inherents::InherentData) -> sp_inherents::CheckInherentsResult {
data.check_extrinsics(&block) data.check_extrinsics(&block)
} }
fn random_seed() -> <Block as BlockT>::Hash {
RandomnessCollectiveFlip::random_seed().0
}
} }
impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime { impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {