Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into jeremy-construct-ta…
Browse files Browse the repository at this point in the history
…nssi-runtime-macro
  • Loading branch information
nanocryk committed Feb 19, 2024
2 parents 0063364 + b018910 commit c34ed46
Show file tree
Hide file tree
Showing 65 changed files with 9,870 additions and 1,602 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ jobs:
run: rustup show

- name: Install zepter
run: cargo install --locked -f zepter
run: cargo install --locked -f zepter --version 1.1.0

- name: Run zepter
run: zepter run check
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/version-bump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Create version bump ticket
on:
workflow_dispatch:
inputs:
from:
description: "Polkadot version to bump from (ex: v0.9.40)"
required: true
to:
description: "Polkadot version to bump to (ex: v0.9.42)"
required: true

jobs:
create_bump_ticket:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 20.10.0
- name: Generate version bump issue
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd tools
yarn install
yarn --silent run print-version-bump-info -- --from ${{ github.event.inputs.from }} --to ${{ github.event.inputs.to }} | tee ../version-bump.md
- name: Create version bump issue
uses: peter-evans/create-issue-from-file@v3
with:
title: Update polkadot-sdk from ${{ github.event.inputs.from }} to ${{ github.event.inputs.to }}
content-filepath: ./version-bump.md
labels: |
automated issue
52 changes: 52 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pallet-pooled-staking = { path = "pallets/pooled-staking", default-features = fa
pallet-registrar = { path = "pallets/registrar", default-features = false }
pallet-registrar-runtime-api = { path = "pallets/registrar/rpc/runtime-api", default-features = false }
pallet-services-payment = { path = "pallets/services-payment", default-features = false }
pallet-stream-payment = { path = "pallets/stream-payment", default-features = false }

container-chain-template-frontier-runtime = { path = "container-chains/templates/frontier/runtime", default-features = false }
container-chain-template-simple-runtime = { path = "container-chains/templates/simple/runtime", default-features = false }
Expand All @@ -43,10 +44,12 @@ dancebox-runtime = { path = "runtime/dancebox", default-features = false }
flashbox-runtime = { path = "runtime/flashbox", default-features = false }
manual-xcm-rpc = { path = "client/manual-xcm" }
node-common = { path = "client/node-common" }
runtime-common = { path = "runtime/common", default-features = false }
tc-consensus = { path = "client/consensus" }
tp-author-noting-inherent = { path = "primitives/author-noting-inherent", default-features = false }
tp-consensus = { path = "primitives/consensus", default-features = false }
tp-container-chain-genesis-data = { path = "primitives/container-chain-genesis-data", default-features = false }
tp-fungibles-ext = { path = "primitives/fungibles-ext", default-features = false }
tp-impl-tanssi-pallets-config = { path = "primitives/impl-tanssi-pallets-config", default-features = false }
tp-maths = { path = "primitives/maths", default-features = false }
tp-traits = { path = "primitives/traits", default-features = false }
Expand Down Expand Up @@ -253,6 +256,7 @@ num_enum = { version = "0.7.1", default-features = false }
rand_chacha = { version = "0.3.1", default-features = false }
serde = { version = "1.0.152", default-features = false }
smallvec = "1.10.0"
tap = "1.0.1"

# General (client)
async-io = "1.3"
Expand Down
5 changes: 3 additions & 2 deletions client/consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@
//! slot_author returns the author based on the slot number and authorities provided (aura-like)
//! authorities retrieves the current set of authorities based on the first eligible key found in the keystore
use {sp_consensus_slots::Slot, sp_core::crypto::Pair};

pub mod collators;
mod consensus_orchestrator;
mod manual_seal;

#[cfg(test)]
mod tests;

Expand Down Expand Up @@ -52,6 +51,8 @@ pub use {
tp_consensus::TanssiAuthorityAssignmentApi,
};

use {sp_consensus_slots::Slot, sp_core::crypto::Pair};

const LOG_TARGET: &str = "aura::tanssi";

type AuthorityId<P> = <P as Pair>::Public;
Expand Down
46 changes: 37 additions & 9 deletions client/node-common/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ use {
run_manual_seal, ConsensusDataProvider, EngineCommand, ManualSealParams,
},
sc_executor::{
HeapAllocStrategy, NativeElseWasmExecutor, NativeExecutionDispatch, WasmExecutor,
DEFAULT_HEAP_ALLOC_STRATEGY,
sp_wasm_interface::{ExtendedHostFunctions, HostFunctions},
HeapAllocStrategy, NativeElseWasmExecutor, NativeExecutionDispatch, RuntimeVersionOf,
WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY,
},
sc_network::{config::FullNetworkConfiguration, NetworkBlock, NetworkService},
sc_network_sync::SyncingService,
Expand All @@ -52,6 +53,7 @@ use {
sp_api::ConstructRuntimeApi,
sp_block_builder::BlockBuilder,
sp_consensus::SelectChain,
sp_core::traits::CodeExecutor,
sp_inherents::CreateInherentDataProviders,
sp_offchain::OffchainWorkerApi,
sp_runtime::Percent,
Expand All @@ -64,7 +66,7 @@ use {
pub trait NodeBuilderConfig {
type Block;
type RuntimeApi;
type ParachainNativeExecutor;
type ParachainExecutor;

/// Create a new `NodeBuilder` using the types of this `Config`, along
/// with the parachain `Configuration` and an optional `HwBench`.
Expand All @@ -75,7 +77,8 @@ pub trait NodeBuilderConfig {
where
Self: Sized,
BlockOf<Self>: cumulus_primitives_core::BlockT,
ParachainNativeExecutorOf<Self>: NativeExecutionDispatch + 'static,
ExecutorOf<Self>:
Clone + CodeExecutor + RuntimeVersionOf + TanssiExecutorExt + Sync + Send + 'static,
RuntimeApiOf<Self>:
ConstructRuntimeApi<BlockOf<Self>, ClientOf<Self>> + Sync + Send + 'static,
ConstructedRuntimeApiOf<Self>:
Expand All @@ -89,8 +92,7 @@ pub type BlockOf<T> = <T as NodeBuilderConfig>::Block;
pub type BlockHashOf<T> = <BlockOf<T> as cumulus_primitives_core::BlockT>::Hash;
pub type BlockHeaderOf<T> = <BlockOf<T> as cumulus_primitives_core::BlockT>::Header;
pub type RuntimeApiOf<T> = <T as NodeBuilderConfig>::RuntimeApi;
pub type ParachainNativeExecutorOf<T> = <T as NodeBuilderConfig>::ParachainNativeExecutor;
pub type ExecutorOf<T> = NativeElseWasmExecutor<ParachainNativeExecutorOf<T>>;
pub type ExecutorOf<T> = <T as NodeBuilderConfig>::ParachainExecutor;
pub type ClientOf<T> = TFullClient<BlockOf<T>, RuntimeApiOf<T>, ExecutorOf<T>>;
pub type BackendOf<T> = TFullBackend<BlockOf<T>>;
pub type ConstructedRuntimeApiOf<T> =
Expand Down Expand Up @@ -130,7 +132,7 @@ pub struct NodeBuilder<
SImportQueueService = (),
> where
BlockOf<T>: cumulus_primitives_core::BlockT,
ParachainNativeExecutorOf<T>: NativeExecutionDispatch + 'static,
ExecutorOf<T>: Clone + CodeExecutor + RuntimeVersionOf + Sync + Send + 'static,
RuntimeApiOf<T>: ConstructRuntimeApi<BlockOf<T>, ClientOf<T>> + Sync + Send + 'static,
ConstructedRuntimeApiOf<T>: TaggedTransactionQueue<BlockOf<T>> + BlockBuilder<BlockOf<T>>,
{
Expand All @@ -157,13 +159,39 @@ pub struct Network<Block: cumulus_primitives_core::BlockT> {
pub sync_service: Arc<SyncingService<Block>>,
}

/// Allows to create a parachain-defined executor from a `WasmExecutor`
pub trait TanssiExecutorExt {
type HostFun: HostFunctions;
fn new_with_wasm_executor(wasm_executor: WasmExecutor<Self::HostFun>) -> Self;
}

impl TanssiExecutorExt for WasmExecutor<sp_io::SubstrateHostFunctions> {
type HostFun = sp_io::SubstrateHostFunctions;

fn new_with_wasm_executor(wasm_executor: WasmExecutor<Self::HostFun>) -> Self {
wasm_executor
}
}

impl<D> TanssiExecutorExt for NativeElseWasmExecutor<D>
where
D: NativeExecutionDispatch,
{
type HostFun = ExtendedHostFunctions<sp_io::SubstrateHostFunctions, D::ExtendHostFunctions>;

fn new_with_wasm_executor(wasm_executor: WasmExecutor<Self::HostFun>) -> Self {
NativeElseWasmExecutor::new_with_wasm_executor(wasm_executor)
}
}

// `new` function doesn't take self, and the Rust compiler cannot infer that
// only one type T implements `TypeIdentity`. With thus need a separate impl
// block with concrete types `()`.
impl<T: NodeBuilderConfig> NodeBuilder<T>
where
BlockOf<T>: cumulus_primitives_core::BlockT,
ParachainNativeExecutorOf<T>: NativeExecutionDispatch + 'static,
ExecutorOf<T>:
Clone + CodeExecutor + RuntimeVersionOf + TanssiExecutorExt + Sync + Send + 'static,
RuntimeApiOf<T>: ConstructRuntimeApi<BlockOf<T>, ClientOf<T>> + Sync + Send + 'static,
ConstructedRuntimeApiOf<T>: TaggedTransactionQueue<BlockOf<T>> + BlockBuilder<BlockOf<T>>,
{
Expand Down Expand Up @@ -255,7 +283,7 @@ impl<T: NodeBuilderConfig, SNetwork, STxHandler, SImportQueueService>
NodeBuilder<T, SNetwork, STxHandler, SImportQueueService>
where
BlockOf<T>: cumulus_primitives_core::BlockT,
ParachainNativeExecutorOf<T>: NativeExecutionDispatch + 'static,
ExecutorOf<T>: Clone + CodeExecutor + RuntimeVersionOf + Sync + Send + 'static,
RuntimeApiOf<T>: ConstructRuntimeApi<BlockOf<T>, ClientOf<T>> + Sync + Send + 'static,
ConstructedRuntimeApiOf<T>: TaggedTransactionQueue<BlockOf<T>>
+ BlockBuilder<BlockOf<T>>
Expand Down
2 changes: 1 addition & 1 deletion container-chains/templates/frontier/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub struct NodeConfig;
impl NodeBuilderConfig for NodeConfig {
type Block = Block;
type RuntimeApi = RuntimeApi;
type ParachainNativeExecutor = TemplateRuntimeExecutor;
type ParachainExecutor = ParachainExecutor;
}

pub fn frontier_database_dir(config: &Configuration, path: &str) -> std::path::PathBuf {
Expand Down
2 changes: 1 addition & 1 deletion container-chains/templates/simple/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub struct NodeConfig;
impl NodeBuilderConfig for NodeConfig {
type Block = Block;
type RuntimeApi = RuntimeApi;
type ParachainNativeExecutor = ParachainNativeExecutor;
type ParachainExecutor = ParachainExecutor;
}

thread_local!(static TIMESTAMP: std::cell::RefCell<u64> = std::cell::RefCell::new(0));
Expand Down
3 changes: 2 additions & 1 deletion node/src/chain_spec/dancebox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,10 @@ fn testnet_genesis(
)
.collect();
// Assign 1000 block credits to all container chains registered in genesis
// Assign 100 collator assignment credits to all container chains registered in genesis
let para_id_credits: Vec<_> = para_ids
.iter()
.map(|(para_id, _genesis_data, _boot_nodes)| (*para_id, 1000))
.map(|(para_id, _genesis_data, _boot_nodes)| (*para_id, 1000, 100).into())
.collect();
let para_id_boot_nodes: Vec<_> = para_ids
.iter()
Expand Down
3 changes: 2 additions & 1 deletion node/src/chain_spec/flashbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,10 @@ fn testnet_genesis(
)
.collect();
// Assign 1000 block credits to all container chains registered in genesis
// Assign 100 collator assignment credits to all container chains registered in genesis
let para_id_credits: Vec<_> = para_ids
.iter()
.map(|(para_id, _genesis_data, _boot_nodes)| (*para_id, 1000))
.map(|(para_id, _genesis_data, _boot_nodes)| (*para_id, 1000, 100).into())
.collect();
let para_id_boot_nodes: Vec<_> = para_ids
.iter()
Expand Down
6 changes: 3 additions & 3 deletions node/src/container_chain_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use {
crate::{
container_chain_spawner::{CcSpawnMsg, ContainerChainSpawnerState},
service::{ParachainBackend, ParachainClient},
service::{ContainerChainBackend, ContainerChainClient},
},
cumulus_primitives_core::ParaId,
std::{
Expand Down Expand Up @@ -57,9 +57,9 @@ pub struct SpawnedContainer {
/// This won't be precise because it is checked using polling with a high period.
pub stop_refcount_time: Cell<Option<Instant>>,
/// Used to check the reference count, if it's 0 it means the database has been closed
pub backend: std::sync::Weak<ParachainBackend>,
pub backend: std::sync::Weak<ContainerChainBackend>,
/// Used to check the reference count, if it's 0 it means that the client has been closed.
pub client: std::sync::Weak<ParachainClient>,
pub client: std::sync::Weak<ContainerChainClient>,
}

impl SpawnedContainer {
Expand Down
Loading

0 comments on commit c34ed46

Please sign in to comment.