Skip to content

Commit

Permalink
feat: upgrade polkadot-v1.9.0 (#32)
Browse files Browse the repository at this point in the history
* feat: upgrade `polkadot-v1.7.0` > `polkadot-v.1.8.0`

* feat: upgrade polkadot-v1.9.0 (clippy failing), runtime module restructure, node modules updated

* fix: import RuntimeBlockWeights

* Merge branch 'main' into feat/upgrade-polkadot-v1.9.0

* remove duplicate deps

---------

Co-authored-by: Facundo Farall <37149322+ffarall@users.noreply.github.com>
  • Loading branch information
snowmead and ffarall authored Apr 9, 2024
1 parent a5b227a commit a88db0a
Show file tree
Hide file tree
Showing 19 changed files with 1,958 additions and 1,337 deletions.
1,629 changes: 1,003 additions & 626 deletions Cargo.lock

Large diffs are not rendered by default.

183 changes: 93 additions & 90 deletions Cargo.toml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ futures = { workspace = true }
serde_json = { workspace = true }

# Substrate
frame-benchmarking = { workspace = true }
frame-benchmarking = { workspace = true, default-features = true }
frame-benchmarking-cli = { workspace = true }
pallet-transaction-payment-rpc = { workspace = true }
sc-basic-authorship = { workspace = true }
Expand Down
11 changes: 6 additions & 5 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use cumulus_primitives_core::ParaId;
use runtime::{AccountId, AuraId, Signature, EXISTENTIAL_DEPOSIT};
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
use sc_service::ChainType;
use serde::{Deserialize, Serialize};
use sp_core::{sr25519, Pair, Public};
use sp_runtime::traits::{IdentifyAccount, Verify};
use storage_hub_runtime::{AccountId, AuraId, Signature, EXISTENTIAL_DEPOSIT};
use storage_hub_runtime as runtime;

/// Specialized `ChainSpec` for the normal parachain runtime.
pub type ChainSpec = sc_service::GenericChainSpec<(), Extensions>;
Expand Down Expand Up @@ -56,8 +57,8 @@ where
/// Generate the session keys from individual elements.
///
/// The input must be a tuple of individual keys (a single arg for now since we have just one key).
pub fn template_session_keys(keys: AuraId) -> storage_hub_runtime::SessionKeys {
storage_hub_runtime::SessionKeys { aura: keys }
pub fn template_session_keys(keys: AuraId) -> runtime::SessionKeys {
runtime::SessionKeys { aura: keys }
}

pub fn development_config() -> ChainSpec {
Expand All @@ -68,7 +69,7 @@ pub fn development_config() -> ChainSpec {
properties.insert("ss58Format".into(), 42.into());

ChainSpec::builder(
storage_hub_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions {
relay_chain: "rococo-local".into(),
// You MUST set this to the correct network!
Expand Down Expand Up @@ -119,7 +120,7 @@ pub fn local_testnet_config() -> ChainSpec {

#[allow(deprecated)]
ChainSpec::builder(
storage_hub_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions {
relay_chain: "rococo-local".into(),
// You MUST set this to the correct network!
Expand Down
9 changes: 6 additions & 3 deletions node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ pub enum Subcommand {
/// Remove the whole chain.
PurgeChain(cumulus_client_cli::PurgeChainCmd),

/// Export the genesis state of the parachain.
ExportGenesisState(cumulus_client_cli::ExportGenesisHeadCommand),
/// Export the genesis head data of the parachain.
///
/// Head data is the encoded block header.
#[command(alias = "export-genesis-state")]
ExportGenesisHead(cumulus_client_cli::ExportGenesisHeadCommand),

/// Export the genesis wasm of the parachain.
ExportGenesisWasm(cumulus_client_cli::ExportGenesisWasmCommand),
Expand All @@ -37,7 +40,7 @@ pub enum Subcommand {

/// Try-runtime has migrated to a standalone
/// [CLI](<https://github.com/paritytech/try-runtime-cli>). The subcommand exists as a stub and
/// deprecation notice. It will be removed entirely some time after Janurary 2024.
/// deprecation notice. It will be removed entirely some time after January 2024.
TryRuntime,
}

Expand Down
5 changes: 3 additions & 2 deletions node/src/command.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::net::SocketAddr;

use cumulus_client_service::storage_proof_size::HostFunctions as ReclaimHostFunctions;
use cumulus_primitives_core::ParaId;
use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
use log::info;
Expand Down Expand Up @@ -164,7 +165,7 @@ pub fn run() -> Result<()> {
cmd.run(config, polkadot_config)
})
},
Some(Subcommand::ExportGenesisState(cmd)) => {
Some(Subcommand::ExportGenesisHead(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| {
let partials = new_partial(&config)?;
Expand All @@ -185,7 +186,7 @@ pub fn run() -> Result<()> {
match cmd {
BenchmarkCmd::Pallet(cmd) =>
if cfg!(feature = "runtime-benchmarks") {
runner.sync_run(|config| cmd.run::<Block, ()>(config))
runner.sync_run(|config| cmd.run::<sp_runtime::traits::HashingFor<Block>, ReclaimHostFunctions>(config))
} else {
Err("Benchmarking wasn't enabled when building the node. \
You can enable it with `--features runtime-benchmarks`."
Expand Down
91 changes: 41 additions & 50 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use std::{sync::Arc, time::Duration};

use cumulus_client_cli::CollatorOptions;
use polkadot_primitives::ValidationCode;
use storage_hub_infra::actor::TaskSpawner;
// Local Runtime Types
use storage_hub_runtime::{
Expand All @@ -13,26 +14,20 @@ use storage_hub_runtime::{

// Cumulus Imports
use cumulus_client_collator::service::CollatorService;
use cumulus_client_consensus_aura::collators::lookahead::{self as aura, Params as AuraParams};
use cumulus_client_consensus_common::ParachainBlockImport as TParachainBlockImport;
use cumulus_client_consensus_proposer::Proposer;
use cumulus_client_service::{
build_network, build_relay_chain_interface, prepare_node_config, start_relay_chain_tasks,
BuildNetworkParams, CollatorSybilResistance, DARecoveryProfile, StartRelayChainTasksParams,
};
use cumulus_primitives_core::{
relay_chain::{CollatorPair, ValidationCode},
ParaId,
};
use cumulus_primitives_core::{relay_chain::CollatorPair, ParaId};
use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface};

// Substrate Imports
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
use sc_client_api::{Backend, BlockBackend};
use sc_consensus::ImportQueue;
use sc_executor::{
HeapAllocStrategy, NativeElseWasmExecutor, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY,
};
use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY};
use sc_network::NetworkBlock;
use sc_network_sync::SyncingService;
use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
Expand All @@ -43,22 +38,22 @@ use substrate_prometheus_endpoint::Registry;

use crate::services::{file_transfer::spawn_file_transfer_service, StorageHubHandler};

/// Native executor type.
pub struct ParachainNativeExecutor;

impl sc_executor::NativeExecutionDispatch for ParachainNativeExecutor {
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;

fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
storage_hub_runtime::api::dispatch(method, data)
}
#[cfg(not(feature = "runtime-benchmarks"))]
type HostFunctions = (
// TODO: change this to `cumulus_client_service::ParachainHostFunctions` once it is part of the next release
sp_io::SubstrateHostFunctions,
cumulus_client_service::storage_proof_size::HostFunctions,
);

fn native_version() -> sc_executor::NativeVersion {
storage_hub_runtime::native_version()
}
}
#[cfg(feature = "runtime-benchmarks")]
type HostFunctions = (
// TODO: change this to `cumulus_client_service::ParachainHostFunctions` once it is part of the next release
sp_io::SubstrateHostFunctions,
cumulus_client_service::storage_proof_size::HostFunctions,
frame_benchmarking::benchmarking::HostFunctions,
);

pub(crate) type ParachainExecutor = NativeElseWasmExecutor<ParachainNativeExecutor>;
type ParachainExecutor = WasmExecutor<HostFunctions>;

pub(crate) type ParachainClient = TFullClient<Block, RuntimeApi, ParachainExecutor>;

Expand All @@ -67,27 +62,25 @@ pub(crate) type ParachainBackend = TFullBackend<Block>;
pub(crate) type ParachainBlockImport =
TParachainBlockImport<Block, Arc<ParachainClient>, ParachainBackend>;

/// Assembly of PartialComponents (enough to run chain ops subcommands)
pub type Service = PartialComponents<
ParachainClient,
ParachainBackend,
(),
sc_consensus::DefaultImportQueue<Block>,
sc_transaction_pool::FullPool<Block, ParachainClient>,
(
ParachainBlockImport,
Option<Telemetry>,
Option<TelemetryWorkerHandle>,
),
>;

/// Starts a `ServiceBuilder` for a full service.
///
/// Use this macro if you don't actually need the full service, but just the builder in order to
/// be able to perform chain operations.
pub fn new_partial(
config: &Configuration,
) -> Result<
PartialComponents<
ParachainClient,
ParachainBackend,
(),
sc_consensus::DefaultImportQueue<Block>,
sc_transaction_pool::FullPool<Block, ParachainClient>,
(
ParachainBlockImport,
Option<Telemetry>,
Option<TelemetryWorkerHandle>,
),
>,
sc_service::Error,
> {
pub fn new_partial(config: &Configuration) -> Result<Service, sc_service::Error> {
let telemetry = config
.telemetry_endpoints
.clone()
Expand All @@ -105,21 +98,20 @@ pub fn new_partial(
extra_pages: h as _,
});

let wasm = WasmExecutor::builder()
let executor = ParachainExecutor::builder()
.with_execution_method(config.wasm_method)
.with_onchain_heap_alloc_strategy(heap_pages)
.with_offchain_heap_alloc_strategy(heap_pages)
.with_max_runtime_instances(config.max_runtime_instances)
.with_runtime_cache_size(config.runtime_cache_size)
.build();

let executor = ParachainExecutor::new_with_wasm_executor(wasm);

let (client, backend, keystore_container, task_manager) =
sc_service::new_full_parts::<Block, RuntimeApi, _>(
sc_service::new_full_parts_record_import::<Block, RuntimeApi, _>(
config,
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
executor,
true,
)?;
let client = Arc::new(client);

Expand Down Expand Up @@ -257,23 +249,23 @@ async fn start_node_impl(
);
}

let rpc_extensions_builder = {
let rpc_builder = {
let client = client.clone();
let transaction_pool = transaction_pool.clone();

move |deny_unsafe, _| {
Box::new(move |deny_unsafe, _| {
let deps = crate::rpc::FullDeps {
client: client.clone(),
pool: transaction_pool.clone(),
deny_unsafe,
};

crate::rpc::create_full(deps).map_err(Into::into)
}
})
};

sc_service::spawn_tasks(sc_service::SpawnTasksParams {
rpc_builder: Box::new(rpc_extensions_builder),
rpc_builder,
client: client.clone(),
transaction_pool: transaction_pool.clone(),
task_manager: &mut task_manager,
Expand Down Expand Up @@ -414,11 +406,11 @@ fn start_consensus(
overseer_handle: OverseerHandle,
announce_block: Arc<dyn Fn(Hash, Option<Vec<u8>>) + Send + Sync>,
) -> Result<(), sc_service::Error> {
use cumulus_client_consensus_aura::collators::lookahead::{self as aura, Params as AuraParams};

// NOTE: because we use Aura here explicitly, we can use `CollatorSybilResistance::Resistant`
// when starting the network.

let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;

let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
task_manager.spawn_handle(),
client.clone(),
Expand Down Expand Up @@ -457,7 +449,6 @@ fn start_consensus(
proposer,
collator_service,
authoring_duration: Duration::from_millis(1500),
slot_duration,
reinitialize: false,
};

Expand Down
44 changes: 22 additions & 22 deletions pallets/file-system/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,31 @@ sp-io = { workspace = true }
pallet-balances = { workspace = true }

[features]
default = [ "std" ]
default = ["std"]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-proofs-dealer/runtime-benchmarks",
"pallet-storage-providers/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-proofs-dealer/runtime-benchmarks",
"pallet-storage-providers/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
std = [
"codec/std",
"frame-benchmarking/std",
"frame-support/std",
"frame-system/std",
"pallet-proofs-dealer/std",
"pallet-storage-providers/std",
"scale-info/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"codec/std",
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"pallet-proofs-dealer/std",
"pallet-storage-providers/std",
"scale-info/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-proofs-dealer/try-runtime",
"pallet-storage-providers/try-runtime",
"sp-runtime/try-runtime",
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-proofs-dealer/try-runtime",
"pallet-storage-providers/try-runtime",
"sp-runtime/try-runtime",
]
2 changes: 1 addition & 1 deletion pallets/file-system/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ parameter_types! {
pub const StorageProvidersHoldReason: RuntimeHoldReason = RuntimeHoldReason::Providers(pallet_storage_providers::HoldReason::StorageProviderDeposit);
}

#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl system::Config for Test {
type BaseCallFilter = Everything;
type BlockWeights = ();
Expand Down
Loading

0 comments on commit a88db0a

Please sign in to comment.