Skip to content

Commit

Permalink
Polkadot v1.6.0 upgrade (#413)
Browse files Browse the repository at this point in the history
* Simple template compiles

* Simple template cleanup

* Simple template chainspec

* Complete build green

* fmt

* Fix deps

* Tests builds

* impl GenesisBuilder

* Updated polkadot-sdk commit

* Missing deps

* Unit tests ok!

* bring serde regardless of std feature

* api-augment

* Fix container chain chain spec using set_storage

* Merge branch 'master' into fg/polkadot-v1.6.0

* Fix frontier node and identity tests

* Fix xcm tests for message queue

* use build_storage from emulated_integration_tests

* fmt

* Update moonkit ref

* try-runtime builds

* Ts lint

* toml maid

* merge

* fix runtime-benchmarks compilation

* try-runtime to pallet-balances

* XcmpQueue migrations

* Migrations

* try-runtime

* zepter

* toml-maid

* Review

* try runtime subcommand

* MessageQueueServiceWeight to 25%

* Unused import

* Fix clippy

* increase sleep time for first block in parathread

* be a bit more mindful about times in parachains

* increment even more timeout

* Formatting and API augment

* Update forks refs

* Increase grcov version in coverage

* Remove ignores from coverage

* Remove ignores from coverage

* Revert coverage changes

---------

Co-authored-by: girazoki <[email protected]>
Co-authored-by: Tomasz Polaczyk <[email protected]>
  • Loading branch information
3 people authored Feb 22, 2024
1 parent 3627c47 commit c427348
Show file tree
Hide file tree
Showing 108 changed files with 5,758 additions and 4,820 deletions.
2,811 changes: 1,695 additions & 1,116 deletions Cargo.lock

Large diffs are not rendered by default.

335 changes: 169 additions & 166 deletions Cargo.toml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ cumulus-client-collator = { workspace = true }
cumulus-client-consensus-aura = { workspace = true }
cumulus-client-consensus-common = { workspace = true }
cumulus-client-consensus-proposer = { workspace = true }
cumulus-client-parachain-inherent = { workspace = true }
cumulus-primitives-core = { workspace = true }
cumulus-primitives-parachain-inherent = { workspace = true }
cumulus-relay-chain-interface = { workspace = true }

# Polkadot
Expand Down
19 changes: 13 additions & 6 deletions client/consensus/src/collators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ use {
cumulus_client_collator::service::ServiceInterface as CollatorServiceInterface,
cumulus_client_consensus_common::ParachainCandidate,
cumulus_client_consensus_proposer::ProposerInterface,
cumulus_client_parachain_inherent::{ParachainInherentData, ParachainInherentDataProvider},
cumulus_primitives_core::{
relay_chain::Hash as PHash, DigestItem, ParachainBlockData, PersistedValidationData,
},
cumulus_primitives_parachain_inherent::ParachainInherentData,
cumulus_relay_chain_interface::RelayChainInterface,
futures::prelude::*,
nimbus_primitives::{CompatibleDigestItem as NimbusCompatibleDigestItem, NIMBUS_KEY_ID},
Expand Down Expand Up @@ -113,7 +113,7 @@ where
parent_hash: Block::Hash,
_timestamp: impl Into<Option<Timestamp>>,
) -> Result<(ParachainInherentData, InherentData), Box<dyn Error + Send + Sync + 'static>> {
let paras_inherent_data = ParachainInherentData::create_at(
let paras_inherent_data = ParachainInherentDataProvider::create_at(
relay_parent,
&self.relay_client,
validation_data,
Expand Down Expand Up @@ -158,12 +158,14 @@ where
inherent_data: (ParachainInherentData, InherentData),
proposal_duration: Duration,
max_pov_size: usize,
) -> Result<(Collation, ParachainBlockData<Block>, Block::Hash), Box<dyn Error + Send + 'static>>
{
) -> Result<
Option<(Collation, ParachainBlockData<Block>, Block::Hash)>,
Box<dyn Error + Send + 'static>,
> {
let mut digest = additional_pre_digest.into().unwrap_or_default();
digest.append(&mut slot_claim.pre_digest);

let proposal = self
let maybe_proposal = self
.proposer
.propose(
&parent_header,
Expand All @@ -176,6 +178,11 @@ where
.await
.map_err(|e| Box::new(e) as Box<dyn Error + Send>)?;

let proposal = match maybe_proposal {
None => return Ok(None),
Some(p) => p,
};

let sealed_importable = seal_tanssi::<_, P>(
proposal.block,
proposal.storage_changes,
Expand Down Expand Up @@ -223,7 +230,7 @@ where
);
}

Ok((collation, block_data, post_hash))
Ok(Some((collation, block_data, post_hash)))
} else {
Err(
Box::<dyn Error + Send + Sync>::from("Unable to produce collation")
Expand Down
18 changes: 12 additions & 6 deletions client/consensus/src/collators/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ where
.await
);

let (collation, _, post_hash) = try_request!(
let maybe_collation = try_request!(
collator
.collate(
&parent_header,
Expand All @@ -241,11 +241,17 @@ where
.await
);

let result_sender = Some(collator.collator_service().announce_with_barrier(post_hash));
request.complete(Some(CollationResult {
collation,
result_sender,
}));
if let Some((collation, _, post_hash)) = maybe_collation {
let result_sender =
Some(collator.collator_service().announce_with_barrier(post_hash));
request.complete(Some(CollationResult {
collation,
result_sender,
}));
} else {
request.complete(None);
tracing::debug!(target: crate::LOG_TARGET, "No block proposal");
}
}
}
}
5 changes: 0 additions & 5 deletions client/consensus/src/consensus_orchestrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ use {
sp_runtime::traits::Block as BlockT,
};

pub use {
sc_consensus_aura::{slot_duration, AuraVerifier, BuildAuraWorkerParams, SlotProportion},
sc_consensus_slots::InherentDataProviderExt,
};

#[async_trait::async_trait]
pub trait RetrieveAuthoritiesFromOrchestrator<Block: BlockT, ExtraArgs, A>: Send + Sync {
/// Create the inherent data providers at the given `parent` block using the given `extra_args`.
Expand Down
7 changes: 5 additions & 2 deletions client/consensus/src/manual_seal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ use {
sc_client_api::{AuxStore, UsageProvider},
sc_consensus::BlockImportParams,
sc_consensus_manual_seal::{ConsensusDataProvider, Error},
sp_api::{HeaderT, ProvideRuntimeApi},
sp_api::ProvideRuntimeApi,
sp_blockchain::{HeaderBackend, HeaderMetadata},
sp_consensus_aura::{digests::CompatibleDigestItem, AuraApi, Slot, SlotDuration},
sp_core::Pair,
sp_inherents::InherentData,
sp_keystore::KeystorePtr,
sp_runtime::{traits::Block as BlockT, Digest, DigestItem},
sp_runtime::{
traits::{Block as BlockT, Header as HeaderT},
Digest, DigestItem,
},
sp_timestamp::TimestampInherentData,
std::{marker::PhantomData, sync::Arc},
tp_consensus::TanssiAuthorityAssignmentApi,
Expand Down
12 changes: 10 additions & 2 deletions client/consensus/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use {
polkadot_primitives::{
Hash as PHash, OccupiedCoreAssumption, PersistedValidationData, ValidatorId,
},
sc_block_builder::BlockBuilderProvider,
sc_block_builder::BlockBuilderBuilder,
sc_client_api::HeaderBackend,
sc_consensus::{BoxJustificationImport, ForkChoiceStrategy},
sc_keystore::LocalKeystore,
Expand Down Expand Up @@ -373,7 +373,14 @@ impl Proposer<TestBlock> for DummyProposer {
_: Duration,
_: Option<usize>,
) -> Self::Proposal {
let r = self.1.new_block(digests).unwrap().build();
let r = BlockBuilderBuilder::new(&*self.1)
.on_parent_block(self.1.chain_info().best_hash)
.fetch_parent_block_number(&*self.1)
.unwrap()
.with_inherent_digests(digests)
.build()
.unwrap()
.build();
let (_relay_parent_storage_root, proof) =
RelayStateSproofBuilder::default().into_state_root_and_proof();

Expand Down Expand Up @@ -636,6 +643,7 @@ async fn collate_returns_correct_block() {
)
.await
.unwrap()
.unwrap()
.1;

// The returned block should be imported and we should be able to get its header by now.
Expand Down
58 changes: 58 additions & 0 deletions client/node-common/src/command.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright (C) Moondance Labs Ltd.
// This file is part of Tanssi.

// Tanssi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Tanssi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Tanssi. If not, see <http://www.gnu.org/licenses/>.

use parity_scale_codec::Encode;
use sc_chain_spec::ChainSpec;
use sp_runtime::{
traits::{Block as BlockT, Hash as HashT, Header as HeaderT, Zero},
StateVersion,
};

/// Generate the genesis block from a given ChainSpec.
pub fn generate_genesis_block<Block: BlockT>(
chain_spec: &dyn ChainSpec,
genesis_state_version: StateVersion,
) -> Result<Block, String> {
let storage = chain_spec.build_storage()?;

let child_roots = storage.children_default.iter().map(|(sk, child_content)| {
let state_root = <<<Block as BlockT>::Header as HeaderT>::Hashing as HashT>::trie_root(
child_content.data.clone().into_iter().collect(),
genesis_state_version,
);
(sk.clone(), state_root.encode())
});
let state_root = <<<Block as BlockT>::Header as HeaderT>::Hashing as HashT>::trie_root(
storage.top.clone().into_iter().chain(child_roots).collect(),
genesis_state_version,
);

let extrinsics_root = <<<Block as BlockT>::Header as HeaderT>::Hashing as HashT>::trie_root(
Vec::new(),
genesis_state_version,
);

Ok(Block::new(
<<Block as BlockT>::Header as HeaderT>::new(
Zero::zero(),
extrinsics_root,
state_root,
Default::default(),
Default::default(),
),
Default::default(),
))
}
2 changes: 2 additions & 0 deletions client/node-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
// along with Tanssi. If not, see <http://www.gnu.org/licenses/>.

pub mod service;

pub mod command;
11 changes: 7 additions & 4 deletions client/node-common/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,10 +549,13 @@ where
// Here you can check whether the hardware meets your chains' requirements. Putting a link
// in there and swapping out the requirements for your own are probably a good idea. The
// requirements for a para-chain are dictated by its relay-chain.
if collator && !SUBSTRATE_REFERENCE_HARDWARE.check_hardware(hwbench) {
log::warn!(
"⚠️ The hardware does not meet the minimal requirements for role 'Authority'."
);
if collator {
if let Err(err) = SUBSTRATE_REFERENCE_HARDWARE.check_hardware(&hwbench) {
log::warn!(
"⚠️ The hardware does not meet the minimal requirements {} for role 'Authority'.",
err
);
}
}

if let Some(ref mut telemetry) = telemetry {
Expand Down
4 changes: 3 additions & 1 deletion container-chains/templates/frontier/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jsonrpsee = { workspace = true, features = [ "server" ] }
log = { workspace = true }
parity-scale-codec = { workspace = true }
serde = { workspace = true, features = [ "derive" ] }
serde_json = { workspace = true, features = [ "arbitrary_precision" ] }
url = { workspace = true }

# Local
Expand Down Expand Up @@ -88,9 +89,9 @@ cumulus-client-cli = { workspace = true }
cumulus-client-consensus-aura = { workspace = true }
cumulus-client-consensus-common = { workspace = true }
cumulus-client-network = { workspace = true }
cumulus-client-parachain-inherent = { workspace = true }
cumulus-client-service = { workspace = true }
cumulus-primitives-core = { workspace = true }
cumulus-primitives-parachain-inherent = { workspace = true }
cumulus-relay-chain-interface = { workspace = true }
cumulus-test-relay-sproof-builder = { workspace = true }

Expand All @@ -113,6 +114,7 @@ substrate-build-script-utils = { workspace = true }
default = []
runtime-benchmarks = [
"container-chain-template-frontier-runtime/runtime-benchmarks",
"cumulus-primitives-core/runtime-benchmarks",
"frame-benchmarking-cli/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
"nimbus-primitives/runtime-benchmarks",
Expand Down
Loading

0 comments on commit c427348

Please sign in to comment.