From 15b486d19586d2f71601f05a3bd897f47a056fcd Mon Sep 17 00:00:00 2001 From: Gianfranco Date: Fri, 28 Feb 2025 13:00:31 -0300 Subject: [PATCH 1/6] replace NativeElseWasmExecutor type --- Cargo.lock | 30 ++++----- node/src/command.rs | 38 +++-------- node/src/service.rs | 158 ++++++++++++++++---------------------------- 3 files changed, 83 insertions(+), 143 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6ef47ea16..b1672b5ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -118,7 +118,7 @@ checksum = "4436e0292ab1bb631b42973c61205e704475fe8126af845c8d923c0996328127" [[package]] name = "amplitude-runtime" -version = "1.6.0" +version = "1.6.0-a" dependencies = [ "bifrost-farming", "bifrost-farming-rpc-runtime-api", @@ -1649,7 +1649,7 @@ dependencies = [ [[package]] name = "chain-extension-common" -version = "1.6.0" +version = "1.6.0-a" dependencies = [ "frame-support", "frame-system", @@ -3810,7 +3810,7 @@ dependencies = [ [[package]] name = "foucoco-runtime" -version = "1.6.0" +version = "1.6.0-a" dependencies = [ "bifrost-farming", "bifrost-farming-rpc-runtime-api", @@ -6596,7 +6596,7 @@ dependencies = [ [[package]] name = "module-pallet-staking-rpc" -version = "1.6.0" +version = "1.6.0-a" dependencies = [ "jsonrpsee", "module-oracle-rpc-runtime-api", @@ -6609,7 +6609,7 @@ dependencies = [ [[package]] name = "module-pallet-staking-rpc-runtime-api" -version = "1.6.0" +version = "1.6.0-a" dependencies = [ "frame-support", "module-oracle-rpc-runtime-api", @@ -7251,7 +7251,7 @@ dependencies = [ [[package]] name = "orml-currencies-allowance-extension" -version = "1.6.0" +version = "1.6.0-a" dependencies = [ "frame-benchmarking", "frame-support", @@ -7307,7 +7307,7 @@ dependencies = [ [[package]] name = "orml-tokens-management-extension" -version = "1.6.0" +version = "1.6.0-a" dependencies = [ "frame-benchmarking", "frame-support", @@ -8589,7 +8589,7 @@ dependencies = [ [[package]] name = "parachain-staking" -version = "1.6.0" +version = "1.6.0-a" dependencies = [ "frame-benchmarking", "frame-support", @@ -8813,7 +8813,7 @@ dependencies = [ [[package]] name = "pendulum-node" -version = "1.6.0" +version = "1.6.0-a" dependencies = [ "amplitude-runtime", "bifrost-farming-rpc", @@ -8899,7 +8899,7 @@ dependencies = [ [[package]] name = "pendulum-runtime" -version = "1.6.0" +version = "1.6.0-a" dependencies = [ "bifrost-farming", "bifrost-farming-rpc-runtime-api", @@ -10410,7 +10410,7 @@ dependencies = [ [[package]] name = "price-chain-extension" -version = "1.6.0" +version = "1.6.0-a" dependencies = [ "chain-extension-common", "dia-oracle", @@ -11282,7 +11282,7 @@ dependencies = [ [[package]] name = "runtime-common" -version = "1.6.0" +version = "1.6.0-a" dependencies = [ "cumulus-pallet-parachain-system", "cumulus-primitives-core", @@ -15451,7 +15451,7 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "token-chain-extension" -version = "1.6.0" +version = "1.6.0-a" dependencies = [ "chain-extension-common", "frame-support", @@ -15755,7 +15755,7 @@ dependencies = [ [[package]] name = "treasury-buyout-extension" -version = "1.6.0" +version = "1.6.0-a" dependencies = [ "frame-benchmarking", "frame-support", @@ -16097,7 +16097,7 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "vesting-manager" -version = "1.6.0" +version = "1.6.0-a" dependencies = [ "frame-benchmarking", "frame-support", diff --git a/node/src/command.rs b/node/src/command.rs index d079b3828..73ffc6586 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -21,17 +21,13 @@ use sp_runtime::{ StateVersion, }; -use sc_executor::NativeExecutionDispatch; - - use crate::{ chain_spec::{self, ParachainExtensions}, cli::{Cli, RelayChainCli, Subcommand}, - service::{ - new_partial, AmplitudeRuntimeExecutor, FoucocoRuntimeExecutor, PendulumRuntimeExecutor, - }, + service::new_partial, }; +use crate::service::ParachainHostFunctions; #[derive(PartialEq, Eq)] enum ChainIdentity { @@ -195,24 +191,18 @@ macro_rules! construct_sync_run { let is_standalone = false; match runner.config().chain_spec.identify() { ChainIdentity::Amplitude => runner.sync_run(|$config| { - let $components = new_partial::< - amplitude_runtime::RuntimeApi, - AmplitudeRuntimeExecutor, - >(&$config, is_standalone)?; + let $components = new_partial::(&$config, is_standalone)?; $code }), ChainIdentity::Foucoco => runner.sync_run(|$config| { - let $components = new_partial::( + let $components = new_partial::( &$config, is_standalone, )?; $code }), ChainIdentity::Pendulum => runner.sync_run(|$config| { - let $components = new_partial::< - pendulum_runtime::RuntimeApi, - PendulumRuntimeExecutor, - >(&$config, is_standalone)?; + let $components = new_partial::(&$config, is_standalone)?; $code }), // Foucoco standalone is only supported @@ -230,24 +220,18 @@ macro_rules! construct_generic_async_run { let is_standalone = false; match runner.config().chain_spec.identify() { ChainIdentity::Amplitude => runner.async_run(|$config| { - let $components = new_partial::< - amplitude_runtime::RuntimeApi, - AmplitudeRuntimeExecutor, - >(&$config, is_standalone)?; + let $components = new_partial::(&$config, is_standalone)?; $code }), ChainIdentity::Foucoco => runner.async_run(|$config| { - let $components = new_partial::( + let $components = new_partial::( &$config, is_standalone, )?; $code }), ChainIdentity::Pendulum => runner.async_run(|$config| { - let $components = new_partial::< - pendulum_runtime::RuntimeApi, - PendulumRuntimeExecutor, - >(&$config, is_standalone)?; + let $components = new_partial::(&$config, is_standalone)?; $code }), // Foucoco standalone is only supported @@ -337,14 +321,14 @@ pub fn run() -> Result<()> { match runner.config().chain_spec.identify() { ChainIdentity::Amplitude => runner.sync_run(|config| { - cmd.run::::ExtendHostFunctions>(config) + cmd.run::(config) }), ChainIdentity::Foucoco => runner.sync_run(|config| { - cmd.run::::ExtendHostFunctions>(config) + cmd.run::(config) }), ChainIdentity::Pendulum => runner.sync_run(|config| { - cmd.run::::ExtendHostFunctions>(config) + cmd.run::(config) }), ChainIdentity::FoucocoStandalone => unimplemented!(), } diff --git a/node/src/service.rs b/node/src/service.rs index a951ec019..186fce787 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -27,9 +27,7 @@ use cumulus_relay_chain_interface::{RelayChainInterface, RelayChainResult}; use cumulus_relay_chain_minimal_node::build_minimal_relay_chain_node_with_rpc; // Substrate Imports -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; @@ -53,33 +51,38 @@ use sc_client_api::Backend; use futures::{FutureExt, StreamExt, channel::oneshot}; use polkadot_primitives::OccupiedCoreAssumption; +use sc_executor::sp_wasm_interface::ExtendedHostFunctions; use sc_network::config::SyncMode; pub use amplitude_runtime::RuntimeApi as AmplitudeRuntimeApi; pub use foucoco_runtime::RuntimeApi as FoucocoRuntimeApi; pub use pendulum_runtime::RuntimeApi as PendulumRuntimeApi; -pub type AmplitudeClient = - TFullClient>; -pub type FoucocoClient = - TFullClient>; -pub type PendulumClient = - TFullClient>; +#[cfg(feature = "runtime-benchmarks")] +pub type ParachainHostFunctions = ( + frame_benchmarking::benchmarking::HostFunctions, +); +#[cfg(not(feature = "runtime-benchmarks"))] +pub type ParachainHostFunctions = ( + sp_io::SubstrateHostFunctions, +); -type ParachainBlockImport = TParachainBlockImport< +pub type ParachainExecutor = WasmExecutor>; + +type ParachainBlockImport = TParachainBlockImport< Block, - Arc>>, + Arc>, TFullBackend, >; -type FullPool = sc_transaction_pool::FullPool< +type FullPool = sc_transaction_pool::FullPool< Block, - TFullClient>, + TFullClient, >; type DefaultImportQueue = sc_consensus::DefaultImportQueue; -type OtherComponents = - (ParachainBlockImport, Option, Option); +type OtherComponents = + (ParachainBlockImport, Option, Option); pub trait ParachainRuntimeApiImpl: sp_transaction_pool::runtime_api::TaggedTransactionQueue @@ -99,61 +102,22 @@ impl ParachainRuntimeApiImpl for amplitude_runtime::RuntimeApiImpl {} impl ParachainRuntimeApiImpl for foucoco_runtime::RuntimeApiImpl {} -/// Amplitude executor type. -pub struct AmplitudeRuntimeExecutor; - -impl sc_executor::NativeExecutionDispatch for AmplitudeRuntimeExecutor { - type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; - - fn dispatch(method: &str, data: &[u8]) -> Option> { - amplitude_runtime::api::dispatch(method, data) - } - - fn native_version() -> sc_executor::NativeVersion { - amplitude_runtime::native_version() - } -} -/// Foucoco executor type. -pub struct FoucocoRuntimeExecutor; - -impl sc_executor::NativeExecutionDispatch for FoucocoRuntimeExecutor { - type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; - - fn dispatch(method: &str, data: &[u8]) -> Option> { - foucoco_runtime::api::dispatch(method, data) - } - fn native_version() -> sc_executor::NativeVersion { - foucoco_runtime::native_version() - } -} - -/// Pendulum executor type. -pub struct PendulumRuntimeExecutor; - -impl sc_executor::NativeExecutionDispatch for PendulumRuntimeExecutor { - #[cfg(feature = "runtime-benchmarks")] - type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; - #[cfg(not(feature = "runtime-benchmarks"))] - type ExtendHostFunctions = (); - - fn dispatch(method: &str, data: &[u8]) -> Option> { - pendulum_runtime::api::dispatch(method, data) - } - - fn native_version() -> sc_executor::NativeVersion { - pendulum_runtime::native_version() - } -} +pub type AmplitudeClient = +TFullClient; +pub type FoucocoClient = +TFullClient; +pub type PendulumClient = +TFullClient; -type ResultNewPartial = PartialComponents< - TFullClient>, +type ResultNewPartial = PartialComponents< + TFullClient, TFullBackend, (), DefaultImportQueue, - FullPool, - OtherComponents, + FullPool, + OtherComponents, >; /// Starts a `ServiceBuilder` for a full service. @@ -161,17 +125,16 @@ type ResultNewPartial = PartialComponents< /// 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. #[allow(clippy::type_complexity)] -pub fn new_partial( +pub fn new_partial( config: &Configuration, instant_seal: bool, -) -> Result, sc_service::Error> +) -> Result, sc_service::Error> where - RuntimeApi: ConstructRuntimeApi>> + RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, RuntimeApi::RuntimeApi: ParachainRuntimeApiImpl, - Executor: sc_executor::NativeExecutionDispatch + 'static, { let telemetry = config .telemetry_endpoints @@ -188,7 +151,7 @@ where .default_heap_pages .map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| HeapAllocStrategy::Static { 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) @@ -196,8 +159,6 @@ where .with_runtime_cache_size(config.runtime_cache_size) .build(); - let executor = NativeElseWasmExecutor::::new_with_wasm_executor(wasm); - let (client, backend, keystore_container, task_manager) = sc_service::new_full_parts::( config, @@ -283,20 +244,20 @@ async fn build_relay_chain_interface( } } -type FullDepsOf = FullDeps< - TFullClient>, +type FullDepsOf = FullDeps< + TFullClient, sc_transaction_pool::FullPool< Block, - TFullClient>, + TFullClient, >, >; // Define and start the services shared across the standalone implementation of the node and // the full parachain implementation. -async fn setup_common_services( +async fn setup_common_services( parachain_config: Configuration, - params: ResultNewPartial, - create_full_rpc: fn(deps: FullDepsOf) -> ResultRpcExtension, + params: ResultNewPartial, + create_full_rpc: fn(deps: FullDepsOf) -> ResultRpcExtension, block_announce_validator: Option< RequireSecondedInBlockAnnounce>, >, @@ -308,18 +269,17 @@ async fn setup_common_services( Arc>, Option, TaskManager, - ParachainBlockImport, + ParachainBlockImport, Box>, ), sc_service::Error, > where - RuntimeApi: ConstructRuntimeApi>> + RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, RuntimeApi::RuntimeApi: ParachainRuntimeApiImpl, - Executor: sc_executor::NativeExecutionDispatch + 'static, { let client = params.client.clone(); let backend = params.backend.clone(); @@ -413,25 +373,24 @@ where } #[sc_tracing::logging::prefix_logs_with("Parachain")] -async fn start_node_impl( +async fn start_node_impl( parachain_config: Configuration, polkadot_config: Configuration, collator_options: CollatorOptions, id: ParaId, hwbench: Option, - create_full_rpc: fn(deps: FullDepsOf) -> ResultRpcExtension, + create_full_rpc: fn(deps: FullDepsOf) -> ResultRpcExtension, ) -> sc_service::error::Result<( TaskManager, - Arc>>, + Arc>, )> where - RuntimeApi: ConstructRuntimeApi>> + RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, RuntimeApi::RuntimeApi: ParachainRuntimeApiImpl, sc_client_api::StateBackendFor, Block>: sc_client_api::StateBackend, - Executor: sc_executor::NativeExecutionDispatch + 'static, { let is_standalone = false; let mut parachain_config = prepare_node_config(parachain_config); @@ -543,20 +502,19 @@ where } /// Build the import queue for the parachain runtime. -fn build_import_queue( - client: Arc>>, - block_import: ParachainBlockImport, +fn build_import_queue( + client: Arc>, + block_import: ParachainBlockImport, config: &Configuration, telemetry: Option, task_manager: &TaskManager, ) -> Result where - RuntimeApi: ConstructRuntimeApi>> + RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, RuntimeApi::RuntimeApi: ParachainRuntimeApiImpl, - Executor: sc_executor::NativeExecutionDispatch + 'static, { let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?; @@ -589,21 +547,20 @@ where } #[sc_tracing::logging::prefix_logs_with("Parachain")] -async fn start_standalone_node_impl( +async fn start_standalone_node_impl( parachain_config: Configuration, - create_full_rpc: fn(deps: FullDepsOf) -> ResultRpcExtension, + create_full_rpc: fn(deps: FullDepsOf) -> ResultRpcExtension, ) -> sc_service::error::Result<( TaskManager, - Arc>>, + Arc>, )> where - RuntimeApi: ConstructRuntimeApi>> + RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, RuntimeApi::RuntimeApi: ParachainRuntimeApiImpl, sc_client_api::StateBackendFor, Block>: sc_client_api::StateBackend, - Executor: sc_executor::NativeExecutionDispatch + 'static, { let parachain_config = prepare_node_config(parachain_config); @@ -683,14 +640,14 @@ where } #[allow(clippy::too_many_arguments)] -fn start_consensus( - client: Arc>>, - block_import: ParachainBlockImport, +fn start_consensus( + client: Arc>, + block_import: ParachainBlockImport, prometheus_registry: Option<&Registry>, telemetry: Option, task_manager: &TaskManager, relay_chain_interface: Arc, - transaction_pool: Arc>, + transaction_pool: Arc>, sync_oracle: Arc>, keystore: KeystorePtr, overseer_handle: Handle, @@ -700,13 +657,12 @@ fn start_consensus( announce_block: Arc>) + Send + Sync>, ) -> Result<(), sc_service::Error> where - RuntimeApi: ConstructRuntimeApi>> + RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, RuntimeApi::RuntimeApi: ParachainRuntimeApiImpl, sc_client_api::StateBackendFor, Block>: sc_client_api::StateBackend, - Executor: sc_executor::NativeExecutionDispatch + 'static, { let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?; From f0053c80d24826b5b137d7ec2539d36672b5cfd4 Mon Sep 17 00:00:00 2001 From: Gianfranco Date: Mon, 3 Mar 2025 09:42:19 -0300 Subject: [PATCH 2/6] fmt, remove --execution flag from README commands --- README.md | 10 +- chain-extensions/common/src/lib.rs | 12 +- chain-extensions/price/src/lib.rs | 6 +- chain-extensions/token/src/lib.rs | 57 ++++--- node/src/chain_spec.rs | 148 +++++++++--------- node/src/command.rs | 79 +++++----- node/src/service.rs | 97 +++++------- .../src/lib.rs | 1 - .../src/benchmarking.rs | 2 +- .../src/ext.rs | 1 - .../src/lib.rs | 5 +- pallets/parachain-staking/src/inflation.rs | 12 +- pallets/parachain-staking/src/lib.rs | 20 +-- pallets/parachain-staking/src/set.rs | 2 +- pallets/treasury-buyout-extension/src/lib.rs | 14 +- pallets/treasury-buyout-extension/src/mock.rs | 2 +- runtime/amplitude/build.rs | 2 +- runtime/amplitude/src/lib.rs | 31 ++-- runtime/amplitude/src/xcm_config.rs | 15 +- runtime/amplitude/src/zenlink.rs | 8 +- runtime/common/src/custom_transactor.rs | 4 +- runtime/common/src/zenlink.rs | 45 +++--- runtime/foucoco/build.rs | 2 +- runtime/foucoco/src/lib.rs | 132 ++++++++-------- runtime/foucoco/src/xcm_config.rs | 14 +- runtime/foucoco/src/zenlink.rs | 8 +- runtime/pendulum/build.rs | 2 +- runtime/pendulum/src/lib.rs | 130 +++++++-------- runtime/pendulum/src/xcm_config.rs | 14 +- runtime/pendulum/src/zenlink.rs | 8 +- 30 files changed, 440 insertions(+), 443 deletions(-) diff --git a/README.md b/README.md index 01cd56a44..b5b7e8885 100644 --- a/README.md +++ b/README.md @@ -68,11 +68,10 @@ To run the collator, execute: --name \ --ws-port --port --rpc-port \ --chain \ ---execution=Native \ -- \ --port \ --chain \ ---execution=wasm --sync fast --pruning archive +--sync fast --pruning archive ``` where: @@ -97,11 +96,10 @@ An example for Amplitude will look like this: --name amplitude-collator-1 \ --ws-port 9945 --port 30335 --rpc-port 9935 \ --chain res/amplitude-spec-raw.json \ ---execution=Native \ -- \ --port 30334 \ --chain kusama.json \ ---execution=wasm --sync fast --pruning archive +--sync fast --pruning archive ``` You can find the @@ -122,7 +120,6 @@ the `--bootnode`. Here's an example: --ws-port 8844 \ --enable-offchain-indexing TRUE \ -- \ ---execution wasm \ --chain rococo-custom-2-raw.json \ --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/ \ --port 30343 \ @@ -153,7 +150,6 @@ runtimes `lib.rs` file. ```shell ./target/production/pendulum-node benchmark pallet \ --chain pendulum \ - --execution=wasm \ --wasm-execution=compiled \ --pallet "*" \ --extrinsic "*" \ @@ -168,7 +164,6 @@ runtimes `lib.rs` file. ```shell ./target/production/pendulum-node benchmark pallet \ --chain amplitude \ - --execution=wasm \ --wasm-execution=compiled \ --pallet "*" \ --extrinsic "*" \ @@ -183,7 +178,6 @@ runtimes `lib.rs` file. ```shell ./target/production/pendulum-node benchmark pallet \ --chain foucoco \ - --execution=wasm \ --wasm-execution=compiled \ --pallet "*" \ --extrinsic "*" \ diff --git a/chain-extensions/common/src/lib.rs b/chain-extensions/common/src/lib.rs index 84966c602..ab14bfc08 100644 --- a/chain-extensions/common/src/lib.rs +++ b/chain-extensions/common/src/lib.rs @@ -101,8 +101,9 @@ impl From for ChainExtensionOutcome { DispatchError::ConsumerRemaining => ChainExtensionOutcome::ConsumerRemaining, DispatchError::NoProviders => ChainExtensionOutcome::NoProviders, DispatchError::TooManyConsumers => ChainExtensionOutcome::TooManyConsumers, - DispatchError::Token(token_err) => - ChainExtensionOutcome::Token(ChainExtensionTokenError::from(token_err)), + DispatchError::Token(token_err) => { + ChainExtensionOutcome::Token(ChainExtensionTokenError::from(token_err)) + }, DispatchError::Arithmetic(arithmetic_error) => ChainExtensionOutcome::Arithmetic( ChainExtensionArithmeticError::from(arithmetic_error), ), @@ -155,7 +156,7 @@ fn trim_trailing_zeros(slice: &[u8]) -> &[u8] { if *el == 0 { trim_amount += 1; } else { - break + break; } } &slice[..slice.len() - trim_amount] @@ -234,8 +235,9 @@ impl TryFrom for ChainExtensionOutcome { 9 => Ok(ChainExtensionOutcome::WriteError), 10 => Ok(ChainExtensionOutcome::UnimplementedFuncId), 999 => Ok(ChainExtensionOutcome::Unknown), - 1000..=1999 => - Ok(ChainExtensionOutcome::Token(ChainExtensionTokenError::try_from(value - 1000)?)), + 1000..=1999 => { + Ok(ChainExtensionOutcome::Token(ChainExtensionTokenError::try_from(value - 1000)?)) + }, 2000..=2999 => Ok(ChainExtensionOutcome::Arithmetic( ChainExtensionArithmeticError::try_from(value - 2000)?, )), diff --git a/chain-extensions/price/src/lib.rs b/chain-extensions/price/src/lib.rs index b6b59a30b..d5b373734 100644 --- a/chain-extensions/price/src/lib.rs +++ b/chain-extensions/price/src/lib.rs @@ -31,7 +31,7 @@ impl TryFrom for FuncId { 1200 => Self::GetCoinInfo, _ => { error!("Called an unregistered `func_id`: {:}", func_id); - return Err(DispatchError::Other("Unimplemented func_id")) + return Err(DispatchError::Other("Unimplemented func_id")); }, }; Ok(id) @@ -100,9 +100,9 @@ where }; if let Err(_) = env.write(&result.encode(), false, None) { - return Ok(RetVal::Converging(ChainExtensionOutcome::WriteError.as_u32())) + return Ok(RetVal::Converging(ChainExtensionOutcome::WriteError.as_u32())); }; - return Ok(RetVal::Converging(ChainExtensionOutcome::Success.as_u32())) + return Ok(RetVal::Converging(ChainExtensionOutcome::Success.as_u32())); } /// CoinInfo is almost the same as Dia's CoinInfo, but with Encode, Decode, and TypeInfo which are necessary for contract to chain extension communication. Implements From to make conversion. diff --git a/chain-extensions/token/src/lib.rs b/chain-extensions/token/src/lib.rs index 6c4884b43..43ef82e96 100644 --- a/chain-extensions/token/src/lib.rs +++ b/chain-extensions/token/src/lib.rs @@ -3,26 +3,26 @@ use chain_extension_common::{ChainExtensionOutcome, ChainExtensionTokenError}; use codec::Encode; +use frame_support::traits::tokens::{fungible, fungibles, Fortitude, Preservation}; use frame_support::{ pallet_prelude::{Decode, Get, PhantomData}, DefaultNoBound, }; -use frame_support::traits::tokens::{fungibles,fungible, Preservation, Fortitude}; use orml_currencies::WeightInfo; use orml_currencies_allowance_extension::{ default_weights::WeightInfo as AllowanceWeightInfo, Config as AllowanceConfig, }; use orml_traits::MultiCurrency; +use pallet_balances; use pallet_contracts::chain_extension::{ ChainExtension, Environment, Ext, InitState, RetVal, SysConfig, }; use sp_core::crypto::UncheckedFrom; -use sp_std::vec::Vec; use sp_runtime::DispatchError; +use sp_std::vec::Vec; use sp_tracing::{error, trace}; use sp_weights::Weight; -use spacewalk_primitives::{CurrencyId}; -use pallet_balances; +use spacewalk_primitives::CurrencyId; pub(crate) type BalanceOfForChainExt = <::MultiCurrency as orml_traits::MultiCurrency< ::AccountId, @@ -57,7 +57,7 @@ impl TryFrom for FuncId { 1106 => Self::TransferFrom, _ => { error!("Called an unregistered `func_id`: {:}", func_id); - return Err(DispatchError::Other("Unimplemented func_id")) + return Err(DispatchError::Other("Unimplemented func_id")); }, }; Ok(id) @@ -137,16 +137,16 @@ where trace!("Calling totalSupply() for currency {:?}", currency_id); if !orml_currencies_allowance_extension::Pallet::::is_allowed_currency(currency_id) { - return Ok(RetVal::Converging(ChainExtensionTokenError::Unsupported.as_u32())) + return Ok(RetVal::Converging(ChainExtensionTokenError::Unsupported.as_u32())); } let total_supply = as MultiCurrency>::total_issuance(currency_id); if let Err(_) = env.write(&total_supply.encode(), false, None) { - return Ok(RetVal::Converging(ChainExtensionOutcome::WriteError.as_u32())) + return Ok(RetVal::Converging(ChainExtensionOutcome::WriteError.as_u32())); }; - return Ok(RetVal::Converging(ChainExtensionOutcome::Success.as_u32())) + return Ok(RetVal::Converging(ChainExtensionOutcome::Success.as_u32())); } fn balance_of( @@ -157,7 +157,7 @@ where T: SysConfig + orml_tokens::Config + pallet_contracts::Config - + orml_currencies::Config + + orml_currencies::Config + pallet_balances::Config + orml_currencies_allowance_extension::Config, E: Ext, @@ -178,19 +178,30 @@ where trace!("Calling balanceOf() for currency {:?} and account {:?}", currency_id, account_id); if !orml_currencies_allowance_extension::Pallet::::is_allowed_currency(currency_id) { - return Ok(RetVal::Converging(ChainExtensionTokenError::Unsupported.as_u32())) + return Ok(RetVal::Converging(ChainExtensionTokenError::Unsupported.as_u32())); } let balance_encoded: Vec = if currency_id == T::GetNativeCurrencyId::get() { - as fungible::Inspect>::reducible_balance(&account_id, Preservation::Preserve, Fortitude::Polite).encode() + as fungible::Inspect>::reducible_balance( + &account_id, + Preservation::Preserve, + Fortitude::Polite, + ) + .encode() } else { - as fungibles::Inspect>::reducible_balance(currency_id, &account_id, Preservation::Preserve, Fortitude::Polite).encode() + as fungibles::Inspect>::reducible_balance( + currency_id, + &account_id, + Preservation::Preserve, + Fortitude::Polite, + ) + .encode() }; if let Err(_) = env.write(&balance_encoded, false, None) { - return Ok(RetVal::Converging(ChainExtensionOutcome::WriteError.as_u32())) + return Ok(RetVal::Converging(ChainExtensionOutcome::WriteError.as_u32())); }; - return Ok(RetVal::Converging(ChainExtensionOutcome::Success.as_u32())) + return Ok(RetVal::Converging(ChainExtensionOutcome::Success.as_u32())); } fn transfer( @@ -228,7 +239,7 @@ where ); if !orml_currencies_allowance_extension::Pallet::::is_allowed_currency(currency_id) { - return Ok(RetVal::Converging(ChainExtensionTokenError::Unsupported.as_u32())) + return Ok(RetVal::Converging(ChainExtensionTokenError::Unsupported.as_u32())); } as MultiCurrency>::transfer( @@ -237,7 +248,7 @@ where &recipient, amount, )?; - return Ok(RetVal::Converging(ChainExtensionOutcome::Success.as_u32())) + return Ok(RetVal::Converging(ChainExtensionOutcome::Success.as_u32())); } fn allowance( @@ -273,16 +284,16 @@ where ); if !orml_currencies_allowance_extension::Pallet::::is_allowed_currency(currency_id) { - return Ok(RetVal::Converging(ChainExtensionTokenError::Unsupported.as_u32())) + return Ok(RetVal::Converging(ChainExtensionTokenError::Unsupported.as_u32())); } let allowance = orml_currencies_allowance_extension::Pallet::::allowance(currency_id, &owner, &spender); if let Err(_) = env.write(&allowance.encode(), false, None) { - return Ok(RetVal::Converging(ChainExtensionOutcome::WriteError.as_u32())) + return Ok(RetVal::Converging(ChainExtensionOutcome::WriteError.as_u32())); }; - return Ok(RetVal::Converging(ChainExtensionOutcome::Success.as_u32())) + return Ok(RetVal::Converging(ChainExtensionOutcome::Success.as_u32())); } fn approve( @@ -319,7 +330,7 @@ where ); if !orml_currencies_allowance_extension::Pallet::::is_allowed_currency(currency_id) { - return Ok(RetVal::Converging(ChainExtensionTokenError::Unsupported.as_u32())) + return Ok(RetVal::Converging(ChainExtensionTokenError::Unsupported.as_u32())); } orml_currencies_allowance_extension::Pallet::::do_approve_transfer( @@ -328,7 +339,7 @@ where &spender, amount, )?; - return Ok(RetVal::Converging(ChainExtensionOutcome::Success.as_u32())) + return Ok(RetVal::Converging(ChainExtensionOutcome::Success.as_u32())); } fn transfer_from( @@ -370,7 +381,7 @@ where ); if !orml_currencies_allowance_extension::Pallet::::is_allowed_currency(currency_id) { - return Ok(RetVal::Converging(ChainExtensionTokenError::Unsupported.as_u32())) + return Ok(RetVal::Converging(ChainExtensionTokenError::Unsupported.as_u32())); } orml_currencies_allowance_extension::Pallet::::do_transfer_approved( @@ -380,5 +391,5 @@ where &recipient, amount, )?; - return Ok(RetVal::Converging(ChainExtensionOutcome::Success.as_u32())) + return Ok(RetVal::Converging(ChainExtensionOutcome::Success.as_u32())); } diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 077fd8f7b..83d5cfc6a 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -3,11 +3,11 @@ use crate::constants::{amplitude, foucoco, pendulum}; use core::default::Default; use cumulus_primitives_core::ParaId; -use serde_json::{Map, Value}; use runtime_common::{AccountId, AuraId, Balance, Signature, UNIT}; use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup}; use sc_service::ChainType; use serde::{Deserialize, Serialize}; +use serde_json::{Map, Value}; use sp_core::{ crypto::{Ss58Codec, UncheckedInto}, sp_std, sr25519, Pair, Public, @@ -130,13 +130,13 @@ pub fn amplitude_config() -> AmplitudeChainSpec { ); AmplitudeChainSpec::builder( - amplitude_runtime::WASM_BINARY - .expect("WASM binary was not built, please build it!"), + amplitude_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), ParachainExtensions { relay_chain: "kusama".into(), // You MUST set this to the correct network! para_id: amplitude::PARACHAIN_ID, - } - ).with_name("Amplitude") + }, + ) + .with_name("Amplitude") .with_id("amplitude") .with_chain_type(ChainType::Live) .with_properties(get_amplitude_properties()) @@ -173,27 +173,27 @@ pub fn foucoco_config() -> FoucocoChainSpec { AccountId::from_ss58check(foucoco::OFF_CHAIN_WORKER_ADDRESS).unwrap(); FoucocoChainSpec::builder( - foucoco_runtime::WASM_BINARY - .expect("WASM binary was not built, please build it!"), + foucoco_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), ParachainExtensions { relay_chain: "kusama".into(), // You MUST set this to the correct network! para_id: foucoco::PARACHAIN_ID, - } - ).with_name("Foucoco") - .with_id("foucoco") - .with_chain_type(ChainType::Live) - .with_properties(get_amplitude_properties())// Same properties as Amplitude chain. - .with_genesis_config_patch(foucoco_genesis( - // initial collators. - invulnerables.clone(), - signatories.clone(), - vec![sudo_account.clone(), offchain_worker_price_feeder.clone()], - sudo_account.clone(), - foucoco::PARACHAIN_ID.into(), - false, - vec![], - )) - .build() + }, + ) + .with_name("Foucoco") + .with_id("foucoco") + .with_chain_type(ChainType::Live) + .with_properties(get_amplitude_properties()) // Same properties as Amplitude chain. + .with_genesis_config_patch(foucoco_genesis( + // initial collators. + invulnerables.clone(), + signatories.clone(), + vec![sudo_account.clone(), offchain_worker_price_feeder.clone()], + sudo_account.clone(), + foucoco::PARACHAIN_ID.into(), + false, + vec![], + )) + .build() } pub fn foucoco_standalone_config() -> FoucocoChainSpec { @@ -254,27 +254,27 @@ pub fn foucoco_standalone_config() -> FoucocoChainSpec { ]; FoucocoChainSpec::builder( - foucoco_runtime::WASM_BINARY - .expect("WASM binary was not built, please build it!"), + foucoco_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), ParachainExtensions { relay_chain: "kusama".into(), // You MUST set this to the correct network! para_id: foucoco::PARACHAIN_ID, - } - ).with_name("Foucoco-Standalone") - .with_id("foucoco-standalone") - .with_chain_type(ChainType::Live) - .with_properties(get_amplitude_properties()) - .with_genesis_config_patch(foucoco_genesis( - // initial collators. - invulnerables.clone(), - signatories.clone(), - vec![sudo_account.clone(), offchain_worker_price_feeder.clone()], - sudo_account.clone(), - foucoco::PARACHAIN_ID.into(), - false, - allowed_currencies.clone(), - )) - .build() + }, + ) + .with_name("Foucoco-Standalone") + .with_id("foucoco-standalone") + .with_chain_type(ChainType::Live) + .with_properties(get_amplitude_properties()) + .with_genesis_config_patch(foucoco_genesis( + // initial collators. + invulnerables.clone(), + signatories.clone(), + vec![sudo_account.clone(), offchain_worker_price_feeder.clone()], + sudo_account.clone(), + foucoco::PARACHAIN_ID.into(), + false, + allowed_currencies.clone(), + )) + .build() } fn get_pendulum_properties() -> Map { @@ -285,9 +285,7 @@ fn get_pendulum_properties() -> Map { properties } - pub fn pendulum_config() -> PendulumChainSpec { - sp_core::crypto::set_default_ss58_version(pendulum_runtime::SS58Prefix::get().into()); let multisig_genesis = create_pendulum_multisig_account(pendulum::MULTISIG_ID_GENESIS); @@ -340,27 +338,27 @@ pub fn pendulum_config() -> PendulumChainSpec { balances.push((account_id, pendulum::INITIAL_ISSUANCE_PER_SIGNATORY)); } - PendulumChainSpec::builder( - pendulum_runtime::WASM_BINARY - .expect("WASM binary was not built, please build it!"), + PendulumChainSpec::builder( + pendulum_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), ParachainExtensions { relay_chain: "polkadot".into(), // You MUST set this to the correct network! para_id: pendulum::PARACHAIN_ID, - } - ).with_name("Pendulum") - .with_id("pendulum") - .with_chain_type(ChainType::Live) - .with_properties(get_pendulum_properties()) - .with_genesis_config_patch(pendulum_genesis( - // initial collators. - collators.clone(), - balances.clone(), - vec![], - multisig_genesis.clone(), - pendulum::PARACHAIN_ID.into(), - false, - )) - .build() + }, + ) + .with_name("Pendulum") + .with_id("pendulum") + .with_chain_type(ChainType::Live) + .with_properties(get_pendulum_properties()) + .with_genesis_config_patch(pendulum_genesis( + // initial collators. + collators.clone(), + balances.clone(), + vec![], + multisig_genesis.clone(), + pendulum::PARACHAIN_ID.into(), + false, + )) + .build() } fn default_pair(currency_id: CurrencyId, is_public_network: bool) -> VaultCurrencyPair { @@ -392,7 +390,6 @@ fn amplitude_genesis( let mut safe_balances = balances; safe_balances.push((sudo_account.clone(), MAX_SAFE_INTEGER_JSON - 1)); - let token_balances = vec![]; let stakers: Vec<_> = invulnerables @@ -609,9 +606,7 @@ fn foucoco_genesis( let genesis_config = foucoco_runtime::RuntimeGenesisConfig { asset_registry: Default::default(), - system: foucoco_runtime::SystemConfig { - _config: sp_std::marker::PhantomData::default(), - }, + system: foucoco_runtime::SystemConfig { _config: sp_std::marker::PhantomData::default() }, balances: foucoco_runtime::BalancesConfig { balances: safe_balances }, parachain_info: foucoco_runtime::ParachainInfoConfig { parachain_id: id, @@ -799,9 +794,7 @@ fn pendulum_genesis( let genesis_config = pendulum_runtime::RuntimeGenesisConfig { asset_registry: Default::default(), - system: pendulum_runtime::SystemConfig { - _config: sp_std::marker::PhantomData::default(), - }, + system: pendulum_runtime::SystemConfig { _config: sp_std::marker::PhantomData::default() }, balances: pendulum_runtime::BalancesConfig { balances: safe_balances }, parachain_info: pendulum_runtime::ParachainInfoConfig { parachain_id: id, @@ -937,13 +930,18 @@ fn pendulum_genesis( serde_json::to_value(genesis_config).expect("Serialization of genesis config should work") } -fn limit_balance_for_serialization( balances: Vec<(AccountId, Balance)> ) -> Vec<(AccountId,Balance)> { - balances.into_iter().map(|balance| { - if balance.1 >= MAX_SAFE_INTEGER_JSON { - return (balance.0, MAX_SAFE_INTEGER_JSON - 1 ) - } - balance - }).collect::>() +fn limit_balance_for_serialization( + balances: Vec<(AccountId, Balance)>, +) -> Vec<(AccountId, Balance)> { + balances + .into_iter() + .map(|balance| { + if balance.1 >= MAX_SAFE_INTEGER_JSON { + return (balance.0, MAX_SAFE_INTEGER_JSON - 1); + } + balance + }) + .collect::>() } // These tests are useful to verify the conversion of the ChainSpec struct to the serialized json. diff --git a/node/src/command.rs b/node/src/command.rs index 73ffc6586..3cdeac877 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -15,19 +15,16 @@ use sc_service::{ }; use sp_core::hexdisplay::HexDisplay; use sp_runtime::{ - traits::{ - AccountIdConversion, Block as BlockT, Hash as HashT, Header as HeaderT, Zero, - }, + traits::{AccountIdConversion, Block as BlockT, Hash as HashT, Header as HeaderT, Zero}, StateVersion, }; - +use crate::service::ParachainHostFunctions; use crate::{ chain_spec::{self, ParachainExtensions}, cli::{Cli, RelayChainCli, Subcommand}, service::new_partial, }; -use crate::service::ParachainHostFunctions; #[derive(PartialEq, Eq)] enum ChainIdentity { @@ -80,14 +77,18 @@ impl ChainIdentity { path: &str, ) -> std::result::Result, String> { Ok(match self { - ChainIdentity::Amplitude => - Box::new(chain_spec::AmplitudeChainSpec::from_json_file(path.into())?), - ChainIdentity::Foucoco => - Box::new(chain_spec::FoucocoChainSpec::from_json_file(path.into())?), - ChainIdentity::FoucocoStandalone => - Box::new(chain_spec::FoucocoChainSpec::from_json_file(path.into())?), - ChainIdentity::Pendulum => - Box::new(chain_spec::PendulumChainSpec::from_json_file(path.into())?), + ChainIdentity::Amplitude => { + Box::new(chain_spec::AmplitudeChainSpec::from_json_file(path.into())?) + }, + ChainIdentity::Foucoco => { + Box::new(chain_spec::FoucocoChainSpec::from_json_file(path.into())?) + }, + ChainIdentity::FoucocoStandalone => { + Box::new(chain_spec::FoucocoChainSpec::from_json_file(path.into())?) + }, + ChainIdentity::Pendulum => { + Box::new(chain_spec::PendulumChainSpec::from_json_file(path.into())?) + }, }) } } @@ -191,18 +192,18 @@ macro_rules! construct_sync_run { let is_standalone = false; match runner.config().chain_spec.identify() { ChainIdentity::Amplitude => runner.sync_run(|$config| { - let $components = new_partial::(&$config, is_standalone)?; + let $components = + new_partial::(&$config, is_standalone)?; $code }), ChainIdentity::Foucoco => runner.sync_run(|$config| { - let $components = new_partial::( - &$config, - is_standalone, - )?; + let $components = + new_partial::(&$config, is_standalone)?; $code }), ChainIdentity::Pendulum => runner.sync_run(|$config| { - let $components = new_partial::(&$config, is_standalone)?; + let $components = + new_partial::(&$config, is_standalone)?; $code }), // Foucoco standalone is only supported @@ -220,18 +221,18 @@ macro_rules! construct_generic_async_run { let is_standalone = false; match runner.config().chain_spec.identify() { ChainIdentity::Amplitude => runner.async_run(|$config| { - let $components = new_partial::(&$config, is_standalone)?; + let $components = + new_partial::(&$config, is_standalone)?; $code }), ChainIdentity::Foucoco => runner.async_run(|$config| { - let $components = new_partial::( - &$config, - is_standalone, - )?; + let $components = + new_partial::(&$config, is_standalone)?; $code }), ChainIdentity::Pendulum => runner.async_run(|$config| { - let $components = new_partial::(&$config, is_standalone)?; + let $components = + new_partial::(&$config, is_standalone)?; $code }), // Foucoco standalone is only supported @@ -303,10 +304,11 @@ pub fn run() -> Result<()> { cmd.run(config, polkadot_config) }) }, - Some(Subcommand::ExportGenesisState(cmd)) => + Some(Subcommand::ExportGenesisState(cmd)) => { construct_async_run!(|components, cli, cmd, config| { Ok(async move { cmd.run(components.client) }) - }), + }) + }, Some(Subcommand::ExportGenesisWasm(cmd)) => { let runner = cli.create_runner(cmd)?; runner.sync_run(|_config| { @@ -315,28 +317,25 @@ pub fn run() -> Result<()> { }) }, Some(Subcommand::Benchmark(bench_cmd)) => match bench_cmd { - BenchmarkCmd::Pallet(cmd) => + BenchmarkCmd::Pallet(cmd) => { if cfg!(feature = "runtime-benchmarks") { let runner = cli.create_runner(cmd)?; match runner.config().chain_spec.identify() { - ChainIdentity::Amplitude => runner.sync_run(|config| { - cmd.run::(config) - }), - ChainIdentity::Foucoco => - runner.sync_run(|config| { - cmd.run::(config) - }), - ChainIdentity::Pendulum => runner.sync_run(|config| { - cmd.run::(config) - }), + ChainIdentity::Amplitude => runner + .sync_run(|config| cmd.run::(config)), + ChainIdentity::Foucoco => runner + .sync_run(|config| cmd.run::(config)), + ChainIdentity::Pendulum => runner + .sync_run(|config| cmd.run::(config)), ChainIdentity::FoucocoStandalone => unimplemented!(), } } else { Err("Benchmarking wasn't enabled when building the node. \ You can enable it with `--features runtime-benchmarks`." .into()) - }, + } + }, BenchmarkCmd::Block(cmd) => { construct_sync_run!(|components, cli, cmd, config| cmd.run(components.client)) }, @@ -633,4 +632,4 @@ pub fn generate_genesis_block( ), Default::default(), )) -} \ No newline at end of file +} diff --git a/node/src/service.rs b/node/src/service.rs index 186fce787..8b3c5594f 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -1,9 +1,9 @@ //! Service and ServiceFactory implementation. Specialized wrapper over substrate service. // std -use std::{sync::Arc, time::Duration}; use codec::Decode; use cumulus_client_cli::{CollatorOptions, RelayChainMode}; +use std::{sync::Arc, time::Duration}; // Local Runtime Types use runtime_common::{opaque::Block, AccountId, Balance, Index as Nonce}; @@ -15,13 +15,11 @@ use cumulus_client_consensus_aura::collators::basic::{ use cumulus_client_consensus_common::ParachainBlockImport as TParachainBlockImport; use cumulus_client_consensus_proposer::Proposer; use cumulus_client_network::RequireSecondedInBlockAnnounce; +use cumulus_client_parachain_inherent::{MockValidationDataInherentDataProvider, MockXcmConfig}; use cumulus_client_service::{ prepare_node_config, start_relay_chain_tasks, DARecoveryProfile, StartRelayChainTasksParams, }; use cumulus_primitives_core::{relay_chain::Hash, ParaId}; -use cumulus_client_parachain_inherent::{ - MockValidationDataInherentDataProvider, MockXcmConfig, -}; use cumulus_relay_chain_inprocess_interface::build_inprocess_relay_chain; use cumulus_relay_chain_interface::{RelayChainInterface, RelayChainResult}; use cumulus_relay_chain_minimal_node::build_minimal_relay_chain_node_with_rpc; @@ -32,12 +30,15 @@ use sc_network::NetworkBlock; use sc_network_sync::SyncingService; use sc_client_api::HeaderBackend; -use sc_service::{Configuration, NetworkStarter, PartialComponents, TFullBackend, TFullClient, TaskManager, SpawnTaskHandle, WarpSyncParams}; +use sc_service::{ + Configuration, NetworkStarter, PartialComponents, SpawnTaskHandle, TFullBackend, TFullClient, + TaskManager, WarpSyncParams, +}; use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; use sp_api::ConstructRuntimeApi; use sp_consensus_aura::{sr25519::AuthorityId, AuraApi}; use sp_keystore::KeystorePtr; -use sp_runtime::traits::{Block as BlockT, BlakeTwo256}; +use sp_runtime::traits::{BlakeTwo256, Block as BlockT}; use substrate_prometheus_endpoint::Registry; use crate::rpc::{ @@ -49,24 +50,21 @@ use sc_transaction_pool_api::OffchainTransactionPoolFactory; use sc_client_api::Backend; -use futures::{FutureExt, StreamExt, channel::oneshot}; -use polkadot_primitives::OccupiedCoreAssumption; -use sc_executor::sp_wasm_interface::ExtendedHostFunctions; -use sc_network::config::SyncMode; pub use amplitude_runtime::RuntimeApi as AmplitudeRuntimeApi; pub use foucoco_runtime::RuntimeApi as FoucocoRuntimeApi; +use futures::{channel::oneshot, FutureExt, StreamExt}; pub use pendulum_runtime::RuntimeApi as PendulumRuntimeApi; +use polkadot_primitives::OccupiedCoreAssumption; +use sc_network::config::SyncMode; #[cfg(feature = "runtime-benchmarks")] -pub type ParachainHostFunctions = ( - frame_benchmarking::benchmarking::HostFunctions, -); +pub type ParachainHostFunctions = + (sp_io::SubstrateHostFunctions, frame_benchmarking::benchmarking::HostFunctions); + #[cfg(not(feature = "runtime-benchmarks"))] -pub type ParachainHostFunctions = ( - sp_io::SubstrateHostFunctions, -); +pub type ParachainHostFunctions = sp_io::SubstrateHostFunctions; -pub type ParachainExecutor = WasmExecutor>; +pub type ParachainExecutor = WasmExecutor; type ParachainBlockImport = TParachainBlockImport< Block, @@ -74,10 +72,8 @@ type ParachainBlockImport = TParachainBlockImport< TFullBackend, >; -type FullPool = sc_transaction_pool::FullPool< - Block, - TFullClient, ->; +type FullPool = + sc_transaction_pool::FullPool>; type DefaultImportQueue = sc_consensus::DefaultImportQueue; @@ -102,14 +98,9 @@ impl ParachainRuntimeApiImpl for amplitude_runtime::RuntimeApiImpl {} impl ParachainRuntimeApiImpl for foucoco_runtime::RuntimeApiImpl {} - - -pub type AmplitudeClient = -TFullClient; -pub type FoucocoClient = -TFullClient; -pub type PendulumClient = -TFullClient; +pub type AmplitudeClient = TFullClient; +pub type FoucocoClient = TFullClient; +pub type PendulumClient = TFullClient; type ResultNewPartial = PartialComponents< TFullClient, @@ -200,7 +191,7 @@ where transaction_pool, select_chain: (), other: (block_import, telemetry, telemetry_worker_handle), - }) + }); } let import_queue = build_import_queue( @@ -246,10 +237,7 @@ async fn build_relay_chain_interface( type FullDepsOf = FullDeps< TFullClient, - sc_transaction_pool::FullPool< - Block, - TFullClient, - >, + sc_transaction_pool::FullPool>, >; // Define and start the services shared across the standalone implementation of the node and @@ -262,7 +250,7 @@ async fn setup_common_services( RequireSecondedInBlockAnnounce>, >, id: Option, - relay_chain_interface: Option> + relay_chain_interface: Option>, ) -> Result< ( NetworkStarter, @@ -289,13 +277,14 @@ where let net_config = sc_network::config::FullNetworkConfiguration::new(¶chain_config.network); - - let warp_sync_params = match parachain_config.network.sync_mode { SyncMode::Warp if relay_chain_interface.is_some() => { - let relay_chain_interface = relay_chain_interface.clone().expect("already checked as Some"); + let relay_chain_interface = + relay_chain_interface.clone().expect("already checked as Some"); let target_block = warp_sync_get::>( - id.ok_or(sc_service::Error::Other("para_id must be defined to enable warp sync".into()))?, + id.ok_or(sc_service::Error::Other( + "para_id must be defined to enable warp sync".into(), + ))?, relay_chain_interface, task_manager.spawn_handle().clone(), ); @@ -314,8 +303,9 @@ where import_queue: params.import_queue, block_announce_validator_builder: { match block_announce_validator { - Some(block_announce_validator_value) => - Some(Box::new(|_| Box::new(block_announce_validator_value))), + Some(block_announce_validator_value) => { + Some(Box::new(|_| Box::new(block_announce_validator_value))) + }, None => None, } }, @@ -380,17 +370,15 @@ async fn start_node_impl( id: ParaId, hwbench: Option, create_full_rpc: fn(deps: FullDepsOf) -> ResultRpcExtension, -) -> sc_service::error::Result<( - TaskManager, - Arc>, -)> +) -> sc_service::error::Result<(TaskManager, Arc>)> where RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, RuntimeApi::RuntimeApi: ParachainRuntimeApiImpl, - sc_client_api::StateBackendFor, Block>: sc_client_api::StateBackend, + sc_client_api::StateBackendFor, Block>: + sc_client_api::StateBackend, { let is_standalone = false; let mut parachain_config = prepare_node_config(parachain_config); @@ -432,7 +420,7 @@ where create_full_rpc, Some(block_announce_validator), Some(id), - Some(relay_chain_interface.clone()) + Some(relay_chain_interface.clone()), ) .await?; @@ -550,17 +538,15 @@ where async fn start_standalone_node_impl( parachain_config: Configuration, create_full_rpc: fn(deps: FullDepsOf) -> ResultRpcExtension, -) -> sc_service::error::Result<( - TaskManager, - Arc>, -)> +) -> sc_service::error::Result<(TaskManager, Arc>)> where RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, RuntimeApi::RuntimeApi: ParachainRuntimeApiImpl, - sc_client_api::StateBackendFor, Block>: sc_client_api::StateBackend, + sc_client_api::StateBackendFor, Block>: + sc_client_api::StateBackend, { let parachain_config = prepare_node_config(parachain_config); @@ -662,7 +648,8 @@ where + Sync + 'static, RuntimeApi::RuntimeApi: ParachainRuntimeApiImpl, - sc_client_api::StateBackendFor, Block>: sc_client_api::StateBackend, + sc_client_api::StateBackendFor, Block>: + sc_client_api::StateBackend, { let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?; @@ -739,7 +726,7 @@ where ) }); } - .boxed(), + .boxed(), ); receiver @@ -784,7 +771,7 @@ where log::debug!(target: "sync::cumulus", "Target block reached {:?}", target_block); let _ = sender.send(target_block); - return Ok(()) + return Ok(()); } } diff --git a/pallets/orml-currencies-allowance-extension/src/lib.rs b/pallets/orml-currencies-allowance-extension/src/lib.rs index 7f488a0e4..2b9de820a 100644 --- a/pallets/orml-currencies-allowance-extension/src/lib.rs +++ b/pallets/orml-currencies-allowance-extension/src/lib.rs @@ -1,7 +1,6 @@ #![deny(warnings)] #![cfg_attr(not(feature = "std"), no_std)] - use frame_support::{dispatch::DispatchResult, ensure}; use orml_traits::MultiCurrency; diff --git a/pallets/orml-tokens-management-extension/src/benchmarking.rs b/pallets/orml-tokens-management-extension/src/benchmarking.rs index f0c1e6c00..7b5be88f2 100644 --- a/pallets/orml-tokens-management-extension/src/benchmarking.rs +++ b/pallets/orml-tokens-management-extension/src/benchmarking.rs @@ -23,7 +23,7 @@ fn get_test_currency() -> CurrencyOf { // mint some tokens to the account fn set_up_account(account: &AccountIdOf) { let token_currency_id = get_test_currency::(); - let deposit_amount = ::AssetDeposit::get(); + let deposit_amount = ::AssetDeposit::get(); assert_ok!( as MultiCurrency>>::deposit( token_currency_id, &account, diff --git a/pallets/orml-tokens-management-extension/src/ext.rs b/pallets/orml-tokens-management-extension/src/ext.rs index 503caf995..3ef66a1f2 100644 --- a/pallets/orml-tokens-management-extension/src/ext.rs +++ b/pallets/orml-tokens-management-extension/src/ext.rs @@ -1,4 +1,3 @@ - pub(crate) mod orml_currencies_ext { use crate::types::{AccountIdOf, BalanceOf, CurrencyOf}; use frame_support::traits::BalanceStatus; diff --git a/pallets/orml-tokens-management-extension/src/lib.rs b/pallets/orml-tokens-management-extension/src/lib.rs index bcff84c1f..07c273c98 100644 --- a/pallets/orml-tokens-management-extension/src/lib.rs +++ b/pallets/orml-tokens-management-extension/src/lib.rs @@ -1,7 +1,6 @@ #![deny(warnings)] #![cfg_attr(not(feature = "std"), no_std)] - use sp_std::{convert::TryInto, prelude::*, vec}; #[cfg(feature = "runtime-benchmarks")] @@ -231,7 +230,7 @@ pub mod pallet { ensure!(origin == details.owner, Error::::NoPermission); if details.owner == new_owner { - return Ok(()) + return Ok(()); } details.owner = new_owner.clone(); @@ -270,7 +269,7 @@ pub mod pallet { let details = maybe_details.as_mut().ok_or(Error::::NotCreated)?; if details.owner == new_owner { - return Ok(()) + return Ok(()); } ext::orml_currencies_ext::repatriate_reserve::( T::DepositCurrency::get(), diff --git a/pallets/parachain-staking/src/inflation.rs b/pallets/parachain-staking/src/inflation.rs index 5514c4a52..b4ae35b62 100644 --- a/pallets/parachain-staking/src/inflation.rs +++ b/pallets/parachain-staking/src/inflation.rs @@ -147,15 +147,15 @@ impl InflationInfo { /// Check whether the annual reward rate is approx. the per_block reward /// rate multiplied with the number of blocks per year pub fn is_valid(&self, blocks_per_year: u64) -> bool { - self.collator.reward_rate.annual >= - Perquintill::from_parts( + self.collator.reward_rate.annual + >= Perquintill::from_parts( self.collator .reward_rate .per_block .deconstruct() .saturating_mul(blocks_per_year), - ) && self.delegator.reward_rate.annual >= - Perquintill::from_parts( + ) && self.delegator.reward_rate.annual + >= Perquintill::from_parts( self.delegator .reward_rate .per_block @@ -186,8 +186,8 @@ mod tests { assert!(almost_equal( rate * 10_000_000_000u128, Perquintill::from_parts( - annual_to_per_block(::BLOCKS_PER_YEAR, rate).deconstruct() * - ::BLOCKS_PER_YEAR + annual_to_per_block(::BLOCKS_PER_YEAR, rate).deconstruct() + * ::BLOCKS_PER_YEAR ) * 10_000_000_000u128, Perbill::from_perthousand(1) )); diff --git a/pallets/parachain-staking/src/lib.rs b/pallets/parachain-staking/src/lib.rs index d7e8d02e6..89e35f153 100644 --- a/pallets/parachain-staking/src/lib.rs +++ b/pallets/parachain-staking/src/lib.rs @@ -1028,8 +1028,8 @@ pub mod pallet { ensure!(stake >= T::MinCollatorCandidateStake::get(), Error::::ValStakeBelowMin); ensure!(stake <= MaxCollatorCandidateStake::::get(), Error::::ValStakeAboveMax); ensure!( - Unstaking::::get(&sender).len().saturated_into::() < - T::MaxUnstakeRequests::get(), + Unstaking::::get(&sender).len().saturated_into::() + < T::MaxUnstakeRequests::get(), Error::::CannotJoinBeforeUnlocking ); @@ -1400,8 +1400,8 @@ pub mod pallet { // cannot be a collator candidate and delegator with same AccountId ensure!(Self::is_active_candidate(&acc).is_none(), Error::::CandidateExists); ensure!( - Unstaking::::get(&acc).len().saturated_into::() < - T::MaxUnstakeRequests::get(), + Unstaking::::get(&acc).len().saturated_into::() + < T::MaxUnstakeRequests::get(), Error::::CannotJoinBeforeUnlocking ); // cannot delegate if number of delegations in this round exceeds @@ -2202,7 +2202,7 @@ pub mod pallet { unstaking_len = unstaking.len().saturated_into(); for (block_number, locked_balance) in unstaking.clone() { if amt_consuming_unstaking.is_zero() { - break + break; } else if locked_balance > amt_consuming_unstaking { // amount is only reducible by locked_balance - amt_consuming_unstaking let delta = locked_balance.saturating_sub(amt_consuming_unstaking); @@ -2302,8 +2302,8 @@ pub mod pallet { .into_iter() .enumerate() .find_map(|(i, id)| { - if ::ValidatorIdOf::convert(collator.clone()) == - Some(id) + if ::ValidatorIdOf::convert(collator.clone()) + == Some(id) { Some(i) } else { @@ -2406,9 +2406,9 @@ pub mod pallet { /// NetworkRewardRate` fn issue_network_reward() -> NegativeImbalanceOf { // Multiplication with Perquintill cannot overflow - let max_col_rewards = InflationConfig::::get().collator.reward_rate.per_block * - MaxCollatorCandidateStake::::get() * - MaxSelectedCandidates::::get().into(); + let max_col_rewards = InflationConfig::::get().collator.reward_rate.per_block + * MaxCollatorCandidateStake::::get() + * MaxSelectedCandidates::::get().into(); let network_reward = T::NetworkRewardRate::get() * max_col_rewards; T::Currency::issue(network_reward) diff --git a/pallets/parachain-staking/src/set.rs b/pallets/parachain-staking/src/set.rs index 11f999589..4cd00dde8 100644 --- a/pallets/parachain-staking/src/set.rs +++ b/pallets/parachain-staking/src/set.rs @@ -117,7 +117,7 @@ impl> OrderedSet { // the highest allowed index let highest_index: usize = S::get().saturating_sub(1).saturated_into(); if S::get().is_zero() { - return Err(true) + return Err(true); } match self.try_insert(value.clone()) { Err(loc) if loc <= highest_index => { diff --git a/pallets/treasury-buyout-extension/src/lib.rs b/pallets/treasury-buyout-extension/src/lib.rs index a1831fdc6..566f48545 100644 --- a/pallets/treasury-buyout-extension/src/lib.rs +++ b/pallets/treasury-buyout-extension/src/lib.rs @@ -14,9 +14,7 @@ mod tests; mod types; -use crate::{ - types::{AccountIdOf, Amount, BalanceOf, CurrencyIdOf}, -}; +use crate::types::{AccountIdOf, Amount, BalanceOf, CurrencyIdOf}; pub use crate::default_weights::WeightInfo; use codec::{Decode, Encode}; @@ -418,11 +416,11 @@ impl Pallet { // Start exchanging // Check for same accounts if who == treasury_account_id { - return Err(Error::::BuyoutWithTreasuryAccount.into()) + return Err(Error::::BuyoutWithTreasuryAccount.into()); } // Check for exchanging zero values if exchange_amount.is_zero() && buyout_amount.is_zero() { - return Err(Error::::LessThanMinBuyoutAmount.into()) + return Err(Error::::LessThanMinBuyoutAmount.into()); } // Check both balances before transfer @@ -430,10 +428,10 @@ impl Pallet { let treasury_balance = T::Currency::free_balance(basic_asset, &treasury_account_id); if user_balance < exchange_amount { - return Err(Error::::InsufficientAccountBalance.into()) + return Err(Error::::InsufficientAccountBalance.into()); } if treasury_balance < buyout_amount { - return Err(Error::::InsufficientTreasuryBalance.into()) + return Err(Error::::InsufficientTreasuryBalance.into()); } // Transfer from user account to treasury then viceversa @@ -469,7 +467,7 @@ impl Pallet { to_decimals: u32, ) -> Result, DispatchError> { if from_amount.is_zero() { - return Ok(Zero::zero()) + return Ok(Zero::zero()); } let from_amount = FixedU128::from_inner(from_amount.saturated_into::()); diff --git a/pallets/treasury-buyout-extension/src/mock.rs b/pallets/treasury-buyout-extension/src/mock.rs index b79340280..71ae8c46c 100644 --- a/pallets/treasury-buyout-extension/src/mock.rs +++ b/pallets/treasury-buyout-extension/src/mock.rs @@ -157,7 +157,7 @@ impl PriceGetter for OracleMock { { // This simulates price fetching error for testing pre_dispatch validation but only for one specific supported asset if currency_id == 2u64 { - return Err(DispatchError::Other("No price")) + return Err(DispatchError::Other("No price")); } let price: FixedNumber = FixedNumber::one() diff --git a/runtime/amplitude/build.rs b/runtime/amplitude/build.rs index 1aea02521..1d6dbda71 100644 --- a/runtime/amplitude/build.rs +++ b/runtime/amplitude/build.rs @@ -19,4 +19,4 @@ fn main() { } #[cfg(not(feature = "std"))] -fn main() {} \ No newline at end of file +fn main() {} diff --git a/runtime/amplitude/src/lib.rs b/runtime/amplitude/src/lib.rs index d13fcb1cd..82d7246a6 100644 --- a/runtime/amplitude/src/lib.rs +++ b/runtime/amplitude/src/lib.rs @@ -29,7 +29,7 @@ use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{ AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, Convert, ConvertInto, - IdentityLookup + IdentityLookup, }, transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, DispatchError, FixedPointNumber, SaturatedConversion, @@ -43,14 +43,15 @@ use sp_version::RuntimeVersion; use frame_support::{ construct_runtime, - genesis_builder_helper::{build_config, create_default_config}, dispatch::DispatchClass, + genesis_builder_helper::{build_config, create_default_config}, parameter_types, traits::{ - fungible::{HoldConsideration, Credit}, ConstBool, ConstU32, Contains, Currency as FrameCurrency, - EitherOfDiverse, EqualPrivilegeOnly, Imbalance, InstanceFilter, OnUnbalanced, - WithdrawReasons, tokens::{PayFromAccount,UnityAssetBalanceConversion}, LinearStoragePrice - + fungible::{Credit, HoldConsideration}, + tokens::{PayFromAccount, UnityAssetBalanceConversion}, + ConstBool, ConstU32, Contains, Currency as FrameCurrency, EitherOfDiverse, + EqualPrivilegeOnly, Imbalance, InstanceFilter, LinearStoragePrice, OnUnbalanced, + WithdrawReasons, }, weights::{ constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, Weight, WeightToFeeCoefficient, @@ -74,9 +75,9 @@ pub use cumulus_primitives_core::{AggregateMessageOrigin, ParaId}; use dia_oracle::DiaOracle; -use xcm_config::XcmOriginToTransactDispatchOrigin; #[cfg(not(feature = "runtime-benchmarks"))] use xcm_config::XcmConfig; +use xcm_config::XcmOriginToTransactDispatchOrigin; use module_oracle_rpc_runtime_api::BalanceWrapper; use orml_currencies::BasicCurrencyAdapter; @@ -168,8 +169,10 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, - (cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4, - pallet_identity::migration::v1::VersionUncheckedMigrateV0ToV1) + ( + cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4, + pallet_identity::migration::v1::VersionUncheckedMigrateV0ToV1, + ), >; pub struct ConvertPrice; @@ -540,7 +543,8 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type VersionWrapper = (); type ControllerOrigin = EnsureRoot; type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; - type PriceForSiblingDelivery = polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery; + type PriceForSiblingDelivery = + polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery; type WeightInfo = cumulus_pallet_xcmp_queue::weights::SubstrateWeight; type XcmpQueue = frame_support::traits::TransformOrigin< MessageQueue, @@ -549,7 +553,6 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { runtime_common::ParaIdToSibling, >; type MaxInboundSuspended = ConstU32<1_000>; - } parameter_types! { pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent; @@ -1083,8 +1086,8 @@ impl frame_system::offchain::SigningTypes for Runtime { } parameter_types! { - pub MessageQueueServiceWeight: Weight = - Perbill::from_percent(20) * RuntimeBlockWeights::get().max_block; + pub MessageQueueServiceWeight: Weight = + Perbill::from_percent(20) * RuntimeBlockWeights::get().max_block; } use parachains_common::message_queue::NarrowOriginToSibling; @@ -1110,8 +1113,6 @@ impl pallet_message_queue::Config for Runtime { type WeightInfo = (); } - - impl frame_system::offchain::SendTransactionTypes for Runtime where RuntimeCall: From, diff --git a/runtime/amplitude/src/xcm_config.rs b/runtime/amplitude/src/xcm_config.rs index b05b958d1..e456bc49d 100644 --- a/runtime/amplitude/src/xcm_config.rs +++ b/runtime/amplitude/src/xcm_config.rs @@ -14,7 +14,6 @@ use orml_xcm_support::{DepositToAlternative, IsNativeConcrete, MultiCurrencyAdap use pallet_xcm::XcmPassthrough; use polkadot_parachain::primitives::Sibling; use sp_runtime::traits::Convert; -use xcm::latest::{prelude::*, Weight as XCMWeight}; use staging_xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, EnsureXcmOrigin, FixedWeightBounds, @@ -25,6 +24,7 @@ use staging_xcm_executor::{ traits::{Properties, ShouldExecute}, XcmExecutor, }; +use xcm::latest::{prelude::*, Weight as XCMWeight}; use runtime_common::{asset_registry::FixedConversionRateProvider, CurrencyIdConvert}; @@ -71,7 +71,7 @@ where fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool { if let Some(ref reserve) = ReserveProvider::reserve(asset) { if reserve == origin { - return true + return true; } } false @@ -160,19 +160,19 @@ impl ShouldExecute for DenyReserveTransferToRelayChain { InitiateReserveWithdraw { reserve: MultiLocation { parents: 1, interior: Here }, .. - } | DepositReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } | - TransferReserveAsset { + } | DepositReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } + | TransferReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } ) }) { - return Err(ProcessMessageError::Unsupported) // Deny + return Err(ProcessMessageError::Unsupported); // Deny } // allow reserve transfers to arrive from relay chain - if matches!(origin, MultiLocation { parents: 1, interior: Here }) && - instructions.iter().any(|inst| matches!(inst, ReserveAssetDeposited { .. })) + if matches!(origin, MultiLocation { parents: 1, interior: Here }) + && instructions.iter().any(|inst| matches!(inst, ReserveAssetDeposited { .. })) { log::trace!( target: "xcm::barriers", @@ -235,7 +235,6 @@ impl staging_xcm_executor::Config for XcmConfig { type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; type Aliasers = (); - } /// No local origins on this chain are allowed to dispatch XCM sends/executions. diff --git a/runtime/amplitude/src/zenlink.rs b/runtime/amplitude/src/zenlink.rs index 4b3e7b51d..5934eef2e 100644 --- a/runtime/amplitude/src/zenlink.rs +++ b/runtime/amplitude/src/zenlink.rs @@ -54,7 +54,7 @@ where zenlink_id_to_currency_id(asset_id, ParachainInfo::parachain_id().into()) { return TryInto::::try_into(Local::free_balance(currency_id, who)) - .unwrap_or_default() + .unwrap_or_default(); } AssetBalance::default() } @@ -64,7 +64,7 @@ where zenlink_id_to_currency_id(asset_id, ParachainInfo::parachain_id().into()) { return TryInto::::try_into(Local::total_issuance(currency_id)) - .unwrap_or_default() + .unwrap_or_default(); } AssetBalance::default() } @@ -111,7 +111,7 @@ where .map_err(|_| DispatchError::Other("convert amount in local deposit"))?, )?; } else { - return Err(DispatchError::Other("unknown asset in local transfer")) + return Err(DispatchError::Other("unknown asset in local transfer")); } Ok(amount) @@ -133,7 +133,7 @@ where .map_err(|_| DispatchError::Other("convert amount in local withdraw"))?, )?; } else { - return Err(DispatchError::Other("unknown asset in local transfer")) + return Err(DispatchError::Other("unknown asset in local transfer")); } Ok(amount) diff --git a/runtime/common/src/custom_transactor.rs b/runtime/common/src/custom_transactor.rs index 60e50f28d..efa7aa2eb 100644 --- a/runtime/common/src/custom_transactor.rs +++ b/runtime/common/src/custom_transactor.rs @@ -1,7 +1,7 @@ use sp_std::{marker::PhantomData, result}; -use xcm::v3::{prelude::*, Error as XcmError, MultiAsset, MultiLocation, Result}; use staging_xcm_executor::{traits::TransactAsset, Assets}; +use xcm::v3::{prelude::*, Error as XcmError, MultiAsset, MultiLocation, Result}; pub struct AssetData { pub length: u8, @@ -35,7 +35,7 @@ impl Some(CurrencyId::XCM(symbol)), (2, LOCAL) => match symbol { 0 => Some(CurrencyId::Stellar(Asset::StellarNative)), - 1 => - Some(CurrencyId::Stellar(Asset::AlphaNum4 { code: *b"USDC", issuer: USDC_ISSUER })), - 2 => - Some(CurrencyId::Stellar(Asset::AlphaNum4 { code: *b"TZS\0", issuer: TZS_ISSUER })), - 3 => - Some(CurrencyId::Stellar(Asset::AlphaNum4 { code: *b"BRL\0", issuer: BRL_ISSUER })), - 4 => - Some(CurrencyId::Stellar(Asset::AlphaNum4 { code: *b"EURC", issuer: EURC_ISSUER })), - 5 => - Some(CurrencyId::Stellar(Asset::AlphaNum4 { code: *b"AUDD", issuer: AUDD_ISSUER })), - 6 => - Some(CurrencyId::Stellar(Asset::AlphaNum4 { code: *b"NGNC", issuer: NGNC_ISSUER })), + 1 => { + Some(CurrencyId::Stellar(Asset::AlphaNum4 { code: *b"USDC", issuer: USDC_ISSUER })) + }, + 2 => { + Some(CurrencyId::Stellar(Asset::AlphaNum4 { code: *b"TZS\0", issuer: TZS_ISSUER })) + }, + 3 => { + Some(CurrencyId::Stellar(Asset::AlphaNum4 { code: *b"BRL\0", issuer: BRL_ISSUER })) + }, + 4 => { + Some(CurrencyId::Stellar(Asset::AlphaNum4 { code: *b"EURC", issuer: EURC_ISSUER })) + }, + 5 => { + Some(CurrencyId::Stellar(Asset::AlphaNum4 { code: *b"AUDD", issuer: AUDD_ISSUER })) + }, + 6 => { + Some(CurrencyId::Stellar(Asset::AlphaNum4 { code: *b"NGNC", issuer: NGNC_ISSUER })) + }, _ => None, }, (3, LOCAL) => { @@ -75,8 +81,9 @@ pub fn currency_id_to_zenlink_id( ) -> Option { let disc = discriminant(¤cy_id) as u64; match currency_id { - CurrencyId::Native => - Some(ZenlinkAssetId { chain_id: parachain_id, asset_type: NATIVE, asset_index: 0 }), + CurrencyId::Native => { + Some(ZenlinkAssetId { chain_id: parachain_id, asset_type: NATIVE, asset_index: 0 }) + }, CurrencyId::XCM(token_id) => Some(ZenlinkAssetId { chain_id: parachain_id, asset_type: LOCAL, @@ -103,11 +110,11 @@ pub fn currency_id_to_zenlink_id( }) }, CurrencyId::ZenlinkLPToken(token1_id, token1_type, token2_id, token2_type) => { - let index = (disc << 8) + - ((token1_id as u64) << 16) + - ((token1_type as u64) << 24) + - ((token2_id as u64) << 32) + - ((token2_type as u64) << 40); + let index = (disc << 8) + + ((token1_id as u64) << 16) + + ((token1_type as u64) << 24) + + ((token2_id as u64) << 32) + + ((token2_type as u64) << 40); Some(ZenlinkAssetId { chain_id: parachain_id, asset_type: LOCAL, asset_index: index }) }, CurrencyId::Token(_) => None, diff --git a/runtime/foucoco/build.rs b/runtime/foucoco/build.rs index 1aea02521..1d6dbda71 100644 --- a/runtime/foucoco/build.rs +++ b/runtime/foucoco/build.rs @@ -19,4 +19,4 @@ fn main() { } #[cfg(not(feature = "std"))] -fn main() {} \ No newline at end of file +fn main() {} diff --git a/runtime/foucoco/src/lib.rs b/runtime/foucoco/src/lib.rs index 75cb98763..6ba3da480 100644 --- a/runtime/foucoco/src/lib.rs +++ b/runtime/foucoco/src/lib.rs @@ -30,7 +30,7 @@ use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{ AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, Convert, ConvertInto, - IdentityLookup + IdentityLookup, }, transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, DispatchError, FixedPointNumber, SaturatedConversion, @@ -44,13 +44,13 @@ use sp_version::RuntimeVersion; use frame_support::{ construct_runtime, - genesis_builder_helper::{build_config, create_default_config}, dispatch::DispatchClass, + genesis_builder_helper::{build_config, create_default_config}, parameter_types, traits::{ + tokens::{PayFromAccount, UnityAssetBalanceConversion}, ConstBool, ConstU32, Contains, Currency as FrameCurrency, EitherOfDiverse, EqualPrivilegeOnly, Imbalance, OnUnbalanced, WithdrawReasons, - tokens::{PayFromAccount,UnityAssetBalanceConversion}, }, weights::{ constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, Weight, WeightToFeeCoefficient, @@ -80,7 +80,7 @@ pub use cumulus_primitives_core::{AggregateMessageOrigin, ParaId}; use dia_oracle::DiaOracle; -use xcm_config::{XcmOriginToTransactDispatchOrigin}; +use xcm_config::XcmOriginToTransactDispatchOrigin; use orml_currencies::BasicCurrencyAdapter; use orml_traits::{currency::MutationHooks, parameter_type_with_key}; @@ -109,8 +109,8 @@ use spacewalk_primitives::{ use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; -use frame_support::traits::{InstanceFilter, LinearStoragePrice}; use frame_support::traits::fungible::HoldConsideration; +use frame_support::traits::{InstanceFilter, LinearStoragePrice}; use sp_std::vec::Vec; use runtime_common::asset_registry::StringLimit; @@ -170,8 +170,10 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, - (cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4, - pallet_identity::migration::v1::VersionUncheckedMigrateV0ToV1) + ( + cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4, + pallet_identity::migration::v1::VersionUncheckedMigrateV0ToV1, + ), >; pub struct ConvertPrice; @@ -310,57 +312,57 @@ impl Contains for BaseFilter { fn contains(call: &RuntimeCall) -> bool { match call { // These modules are all allowed to be called by transactions: - RuntimeCall::Bounties(_) | - RuntimeCall::ChildBounties(_) | - RuntimeCall::ClientsInfo(_) | - RuntimeCall::Treasury(_) | - RuntimeCall::Tokens(_) | - RuntimeCall::Currencies(_) | - RuntimeCall::ParachainStaking(_) | - RuntimeCall::Democracy(_) | - RuntimeCall::Council(_) | - RuntimeCall::TechnicalCommittee(_) | - RuntimeCall::System(_) | - RuntimeCall::Scheduler(_) | - RuntimeCall::Preimage(_) | - RuntimeCall::Timestamp(_) | - RuntimeCall::Balances(_) | - RuntimeCall::Session(_) | - RuntimeCall::ParachainSystem(_) | - RuntimeCall::Sudo(_) | - RuntimeCall::XcmpQueue(_) | - RuntimeCall::PolkadotXcm(_) | - RuntimeCall::DmpQueue(_) | - RuntimeCall::Utility(_) | - RuntimeCall::Vesting(_) | - RuntimeCall::XTokens(_) | - RuntimeCall::Multisig(_) | - RuntimeCall::Identity(_) | - RuntimeCall::Contracts(_) | - RuntimeCall::ZenlinkProtocol(_) | - RuntimeCall::DiaOracleModule(_) | - RuntimeCall::Fee(_) | - RuntimeCall::Issue(_) | - RuntimeCall::Nomination(_) | - RuntimeCall::Oracle(_) | - RuntimeCall::Redeem(_) | - RuntimeCall::Replace(_) | - RuntimeCall::Security(_) | - RuntimeCall::StellarRelay(_) | - RuntimeCall::VaultRegistry(_) | - RuntimeCall::PooledVaultRewards(_) | - RuntimeCall::Farming(_) | - RuntimeCall::TokenAllowance(_) | - RuntimeCall::AssetRegistry(_) | - RuntimeCall::Proxy(_) | - RuntimeCall::OrmlExtension(_) | - RuntimeCall::TreasuryBuyoutExtension(_) | - RuntimeCall::RewardDistribution(_) | - RuntimeCall::ParachainInfo(_) | - RuntimeCall::CumulusXcm(_) | - RuntimeCall::VaultStaking(_) | - RuntimeCall::MessageQueue(_) => true, // All pallets are allowed, but exhaustive match is defensive - // in the case of adding new pallets. + RuntimeCall::Bounties(_) + | RuntimeCall::ChildBounties(_) + | RuntimeCall::ClientsInfo(_) + | RuntimeCall::Treasury(_) + | RuntimeCall::Tokens(_) + | RuntimeCall::Currencies(_) + | RuntimeCall::ParachainStaking(_) + | RuntimeCall::Democracy(_) + | RuntimeCall::Council(_) + | RuntimeCall::TechnicalCommittee(_) + | RuntimeCall::System(_) + | RuntimeCall::Scheduler(_) + | RuntimeCall::Preimage(_) + | RuntimeCall::Timestamp(_) + | RuntimeCall::Balances(_) + | RuntimeCall::Session(_) + | RuntimeCall::ParachainSystem(_) + | RuntimeCall::Sudo(_) + | RuntimeCall::XcmpQueue(_) + | RuntimeCall::PolkadotXcm(_) + | RuntimeCall::DmpQueue(_) + | RuntimeCall::Utility(_) + | RuntimeCall::Vesting(_) + | RuntimeCall::XTokens(_) + | RuntimeCall::Multisig(_) + | RuntimeCall::Identity(_) + | RuntimeCall::Contracts(_) + | RuntimeCall::ZenlinkProtocol(_) + | RuntimeCall::DiaOracleModule(_) + | RuntimeCall::Fee(_) + | RuntimeCall::Issue(_) + | RuntimeCall::Nomination(_) + | RuntimeCall::Oracle(_) + | RuntimeCall::Redeem(_) + | RuntimeCall::Replace(_) + | RuntimeCall::Security(_) + | RuntimeCall::StellarRelay(_) + | RuntimeCall::VaultRegistry(_) + | RuntimeCall::PooledVaultRewards(_) + | RuntimeCall::Farming(_) + | RuntimeCall::TokenAllowance(_) + | RuntimeCall::AssetRegistry(_) + | RuntimeCall::Proxy(_) + | RuntimeCall::OrmlExtension(_) + | RuntimeCall::TreasuryBuyoutExtension(_) + | RuntimeCall::RewardDistribution(_) + | RuntimeCall::ParachainInfo(_) + | RuntimeCall::CumulusXcm(_) + | RuntimeCall::VaultStaking(_) + | RuntimeCall::MessageQueue(_) => true, // All pallets are allowed, but exhaustive match is defensive + // in the case of adding new pallets. } } } @@ -522,7 +524,8 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type VersionWrapper = (); type ControllerOrigin = EnsureRoot; type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; - type PriceForSiblingDelivery = polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery; + type PriceForSiblingDelivery = + polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery; type WeightInfo = cumulus_pallet_xcmp_queue::weights::SubstrateWeight; type XcmpQueue = frame_support::traits::TransformOrigin< MessageQueue, @@ -531,7 +534,6 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { runtime_common::ParaIdToSibling, >; type MaxInboundSuspended = ConstU32<1_000>; - } parameter_types! { pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent; @@ -541,7 +543,6 @@ impl cumulus_pallet_dmp_queue::Config for Runtime { type RuntimeEvent = RuntimeEvent; type DmpSink = frame_support::traits::EnqueueWithOrigin; type WeightInfo = cumulus_pallet_dmp_queue::weights::SubstrateWeight; - } parameter_types! { @@ -765,7 +766,6 @@ impl pallet_treasury::Config for Runtime { type AssetKind = (); #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = (); - } parameter_types! { @@ -1048,8 +1048,8 @@ const fn deposit(items: u32, bytes: u32) -> Balance { parameter_types! { pub const DepositPerItem: Balance = deposit(1, 0); - pub const DepositPerByte: Balance = deposit(0, 1); - pub const DefaultDepositLimit: Balance = deposit(1024, 1024 * 1024); + pub const DepositPerByte: Balance = deposit(0, 1); + pub const DefaultDepositLimit: Balance = deposit(1024, 1024 * 1024); pub Schedule: pallet_contracts::Schedule = Default::default(); pub const CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(30); pub const MaxDelegateDependencies: u32 = 32; @@ -1143,8 +1143,8 @@ impl frame_system::offchain::SigningTypes for Runtime { } parameter_types! { - pub MessageQueueServiceWeight: Weight = - Perbill::from_percent(20) * RuntimeBlockWeights::get().max_block; + pub MessageQueueServiceWeight: Weight = + Perbill::from_percent(20) * RuntimeBlockWeights::get().max_block; } use parachains_common::message_queue::NarrowOriginToSibling; diff --git a/runtime/foucoco/src/xcm_config.rs b/runtime/foucoco/src/xcm_config.rs index a72947a33..7eebf0949 100644 --- a/runtime/foucoco/src/xcm_config.rs +++ b/runtime/foucoco/src/xcm_config.rs @@ -16,7 +16,6 @@ use pallet_xcm::XcmPassthrough; use polkadot_parachain::primitives::Sibling; use runtime_common::{asset_registry::FixedConversionRateProvider, CurrencyIdConvert}; use sp_runtime::traits::Convert; -use xcm::latest::{prelude::*, Weight as XCMWeight}; use staging_xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, EnsureXcmOrigin, FixedWeightBounds, @@ -27,6 +26,7 @@ use staging_xcm_executor::{ traits::{Properties, ShouldExecute}, XcmExecutor, }; +use xcm::latest::{prelude::*, Weight as XCMWeight}; use super::{ AccountId, AssetRegistry, Balance, Balances, Currencies, CurrencyId, FoucocoTreasuryAccount, @@ -66,7 +66,7 @@ where fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool { if let Some(ref reserve) = ReserveProvider::reserve(asset) { if reserve == origin { - return true + return true; } } false @@ -155,19 +155,19 @@ impl ShouldExecute for DenyReserveTransferToRelayChain { InitiateReserveWithdraw { reserve: MultiLocation { parents: 1, interior: Here }, .. - } | DepositReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } | - TransferReserveAsset { + } | DepositReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } + | TransferReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } ) }) { - return Err(ProcessMessageError::Unsupported) // Deny + return Err(ProcessMessageError::Unsupported); // Deny } // allow reserve transfers to arrive from relay chain - if matches!(origin, MultiLocation { parents: 1, interior: Here }) && - instructions.iter().any(|inst| matches!(inst, ReserveAssetDeposited { .. })) + if matches!(origin, MultiLocation { parents: 1, interior: Here }) + && instructions.iter().any(|inst| matches!(inst, ReserveAssetDeposited { .. })) { log::trace!( target: "xcm::barriers", diff --git a/runtime/foucoco/src/zenlink.rs b/runtime/foucoco/src/zenlink.rs index 4b3e7b51d..5934eef2e 100644 --- a/runtime/foucoco/src/zenlink.rs +++ b/runtime/foucoco/src/zenlink.rs @@ -54,7 +54,7 @@ where zenlink_id_to_currency_id(asset_id, ParachainInfo::parachain_id().into()) { return TryInto::::try_into(Local::free_balance(currency_id, who)) - .unwrap_or_default() + .unwrap_or_default(); } AssetBalance::default() } @@ -64,7 +64,7 @@ where zenlink_id_to_currency_id(asset_id, ParachainInfo::parachain_id().into()) { return TryInto::::try_into(Local::total_issuance(currency_id)) - .unwrap_or_default() + .unwrap_or_default(); } AssetBalance::default() } @@ -111,7 +111,7 @@ where .map_err(|_| DispatchError::Other("convert amount in local deposit"))?, )?; } else { - return Err(DispatchError::Other("unknown asset in local transfer")) + return Err(DispatchError::Other("unknown asset in local transfer")); } Ok(amount) @@ -133,7 +133,7 @@ where .map_err(|_| DispatchError::Other("convert amount in local withdraw"))?, )?; } else { - return Err(DispatchError::Other("unknown asset in local transfer")) + return Err(DispatchError::Other("unknown asset in local transfer")); } Ok(amount) diff --git a/runtime/pendulum/build.rs b/runtime/pendulum/build.rs index a6a9cebeb..ca32568c4 100644 --- a/runtime/pendulum/build.rs +++ b/runtime/pendulum/build.rs @@ -19,4 +19,4 @@ fn main() { } #[cfg(not(feature = "std"))] -fn main() {} \ No newline at end of file +fn main() {} diff --git a/runtime/pendulum/src/lib.rs b/runtime/pendulum/src/lib.rs index 2121ece79..9eea1415d 100644 --- a/runtime/pendulum/src/lib.rs +++ b/runtime/pendulum/src/lib.rs @@ -27,7 +27,7 @@ use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{ AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, Convert, ConvertInto, - IdentityLookup + IdentityLookup, }, transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, DispatchError, FixedPointNumber, MultiAddress, Perbill, Permill, @@ -56,13 +56,14 @@ use sp_version::RuntimeVersion; use frame_support::{ construct_runtime, - genesis_builder_helper::{build_config, create_default_config}, dispatch::DispatchClass, + genesis_builder_helper::{build_config, create_default_config}, parameter_types, traits::{ - fungible::Credit, ConstBool, ConstU32, Contains, Currency as FrameCurrency, - EitherOfDiverse, EqualPrivilegeOnly, Imbalance, InstanceFilter, OnUnbalanced, - WithdrawReasons, tokens::{PayFromAccount,UnityAssetBalanceConversion}, + fungible::Credit, + tokens::{PayFromAccount, UnityAssetBalanceConversion}, + ConstBool, ConstU32, Contains, Currency as FrameCurrency, EitherOfDiverse, + EqualPrivilegeOnly, Imbalance, InstanceFilter, OnUnbalanced, WithdrawReasons, }, weights::{ constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, Weight, WeightToFeeCoefficient, @@ -95,7 +96,7 @@ pub use replace::{Event as ReplaceEvent, ReplaceRequest}; pub use security::StatusCode; pub use stellar_relay::traits::{FieldLength, Organization, Validator}; -use xcm_config::{XcmOriginToTransactDispatchOrigin}; +use xcm_config::XcmOriginToTransactDispatchOrigin; use module_oracle_rpc_runtime_api::BalanceWrapper; use orml_currencies::BasicCurrencyAdapter; @@ -171,8 +172,10 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, - (cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4, - pallet_identity::migration::v1::VersionUncheckedMigrateV0ToV1) + ( + cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4, + pallet_identity::migration::v1::VersionUncheckedMigrateV0ToV1, + ), >; pub struct ConvertPrice; @@ -311,56 +314,56 @@ impl Contains for BaseFilter { fn contains(call: &RuntimeCall) -> bool { match call { // These modules are all allowed to be called by transactions: - RuntimeCall::Bounties(_) | - RuntimeCall::ChildBounties(_) | - RuntimeCall::ClientsInfo(_) | - RuntimeCall::Treasury(_) | - RuntimeCall::Tokens(_) | - RuntimeCall::Currencies(_) | - RuntimeCall::ParachainStaking(_) | - RuntimeCall::Democracy(_) | - RuntimeCall::Council(_) | - RuntimeCall::TechnicalCommittee(_) | - RuntimeCall::System(_) | - RuntimeCall::Scheduler(_) | - RuntimeCall::Preimage(_) | - RuntimeCall::Timestamp(_) | - RuntimeCall::Balances(_) | - RuntimeCall::Session(_) | - RuntimeCall::ParachainSystem(_) | - RuntimeCall::XcmpQueue(_) | - RuntimeCall::PolkadotXcm(_) | - RuntimeCall::DmpQueue(_) | - RuntimeCall::Utility(_) | - RuntimeCall::Vesting(_) | - RuntimeCall::XTokens(_) | - RuntimeCall::Multisig(_) | - RuntimeCall::Identity(_) | - RuntimeCall::Contracts(_) | - RuntimeCall::ZenlinkProtocol(_) | - RuntimeCall::DiaOracleModule(_) | - RuntimeCall::VestingManager(_) | - RuntimeCall::TokenAllowance(_) | - RuntimeCall::AssetRegistry(_) | - RuntimeCall::Fee(_) | - RuntimeCall::Issue(_) | - RuntimeCall::Nomination(_) | - RuntimeCall::Oracle(_) | - RuntimeCall::Redeem(_) | - RuntimeCall::Replace(_) | - RuntimeCall::Security(_) | - RuntimeCall::StellarRelay(_) | - RuntimeCall::VaultRegistry(_) | - RuntimeCall::PooledVaultRewards(_) | - RuntimeCall::RewardDistribution(_) | - RuntimeCall::Farming(_) | - RuntimeCall::Proxy(_) | - RuntimeCall::TreasuryBuyoutExtension(_) | - RuntimeCall::ParachainInfo(_) | - RuntimeCall::CumulusXcm(_) | - RuntimeCall::VaultStaking(_) | - RuntimeCall::MessageQueue(_) => true, // All pallets are allowed, but exhaustive match is defensive - // in the case of adding new pallets. + RuntimeCall::Bounties(_) + | RuntimeCall::ChildBounties(_) + | RuntimeCall::ClientsInfo(_) + | RuntimeCall::Treasury(_) + | RuntimeCall::Tokens(_) + | RuntimeCall::Currencies(_) + | RuntimeCall::ParachainStaking(_) + | RuntimeCall::Democracy(_) + | RuntimeCall::Council(_) + | RuntimeCall::TechnicalCommittee(_) + | RuntimeCall::System(_) + | RuntimeCall::Scheduler(_) + | RuntimeCall::Preimage(_) + | RuntimeCall::Timestamp(_) + | RuntimeCall::Balances(_) + | RuntimeCall::Session(_) + | RuntimeCall::ParachainSystem(_) + | RuntimeCall::XcmpQueue(_) + | RuntimeCall::PolkadotXcm(_) + | RuntimeCall::DmpQueue(_) + | RuntimeCall::Utility(_) + | RuntimeCall::Vesting(_) + | RuntimeCall::XTokens(_) + | RuntimeCall::Multisig(_) + | RuntimeCall::Identity(_) + | RuntimeCall::Contracts(_) + | RuntimeCall::ZenlinkProtocol(_) + | RuntimeCall::DiaOracleModule(_) + | RuntimeCall::VestingManager(_) + | RuntimeCall::TokenAllowance(_) + | RuntimeCall::AssetRegistry(_) + | RuntimeCall::Fee(_) + | RuntimeCall::Issue(_) + | RuntimeCall::Nomination(_) + | RuntimeCall::Oracle(_) + | RuntimeCall::Redeem(_) + | RuntimeCall::Replace(_) + | RuntimeCall::Security(_) + | RuntimeCall::StellarRelay(_) + | RuntimeCall::VaultRegistry(_) + | RuntimeCall::PooledVaultRewards(_) + | RuntimeCall::RewardDistribution(_) + | RuntimeCall::Farming(_) + | RuntimeCall::Proxy(_) + | RuntimeCall::TreasuryBuyoutExtension(_) + | RuntimeCall::ParachainInfo(_) + | RuntimeCall::CumulusXcm(_) + | RuntimeCall::VaultStaking(_) + | RuntimeCall::MessageQueue(_) => true, // All pallets are allowed, but exhaustive match is defensive + // in the case of adding new pallets. } } } @@ -542,7 +545,8 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type VersionWrapper = (); type ControllerOrigin = EnsureRoot; type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; - type PriceForSiblingDelivery = polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery; + type PriceForSiblingDelivery = + polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery; type WeightInfo = cumulus_pallet_xcmp_queue::weights::SubstrateWeight; type XcmpQueue = frame_support::traits::TransformOrigin< MessageQueue, @@ -996,8 +1000,8 @@ const fn deposit(items: u32, bytes: u32) -> Balance { parameter_types! { pub const DepositPerItem: Balance = deposit(1, 0); - pub const DepositPerByte: Balance = deposit(0, 1); - pub const DefaultDepositLimit: Balance = deposit(1024, 1024 * 1024); + pub const DepositPerByte: Balance = deposit(0, 1); + pub const DefaultDepositLimit: Balance = deposit(1024, 1024 * 1024); pub Schedule: pallet_contracts::Schedule = Default::default(); pub const CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(30); pub const MaxDelegateDependencies: u32 = 32; @@ -1073,8 +1077,8 @@ impl pallet_identity::Config for Runtime { } parameter_types! { - pub MessageQueueServiceWeight: Weight = - Perbill::from_percent(20) * RuntimeBlockWeights::get().max_block; + pub MessageQueueServiceWeight: Weight = + Perbill::from_percent(20) * RuntimeBlockWeights::get().max_block; } use parachains_common::message_queue::NarrowOriginToSibling; diff --git a/runtime/pendulum/src/xcm_config.rs b/runtime/pendulum/src/xcm_config.rs index cfd21fbb8..e25f3d0b2 100644 --- a/runtime/pendulum/src/xcm_config.rs +++ b/runtime/pendulum/src/xcm_config.rs @@ -16,7 +16,6 @@ use pallet_xcm::XcmPassthrough; use polkadot_parachain::primitives::Sibling; use sp_runtime::traits::Convert; -use xcm::latest::{prelude::*, Weight as XCMWeight}; use staging_xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, EnsureXcmOrigin, FixedWeightBounds, @@ -27,6 +26,7 @@ use staging_xcm_executor::{ traits::{Properties, ShouldExecute}, XcmExecutor, }; +use xcm::latest::{prelude::*, Weight as XCMWeight}; use runtime_common::{ asset_registry::FixedConversionRateProvider, @@ -76,7 +76,7 @@ where fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool { if let Some(ref reserve) = ReserveProvider::reserve(asset) { if reserve == origin { - return true + return true; } } false @@ -152,19 +152,19 @@ impl ShouldExecute for DenyReserveTransferToRelayChain { InitiateReserveWithdraw { reserve: MultiLocation { parents: 1, interior: Here }, .. - } | DepositReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } | - TransferReserveAsset { + } | DepositReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } + | TransferReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } ) }) { - return Err(ProcessMessageError::Unsupported) // Deny + return Err(ProcessMessageError::Unsupported); // Deny } // allow reserve transfers to arrive from relay chain - if matches!(origin, MultiLocation { parents: 1, interior: Here }) && - instructions.iter().any(|inst| matches!(inst, ReserveAssetDeposited { .. })) + if matches!(origin, MultiLocation { parents: 1, interior: Here }) + && instructions.iter().any(|inst| matches!(inst, ReserveAssetDeposited { .. })) { log::trace!( target: "xcm::barriers", diff --git a/runtime/pendulum/src/zenlink.rs b/runtime/pendulum/src/zenlink.rs index 4b3e7b51d..5934eef2e 100644 --- a/runtime/pendulum/src/zenlink.rs +++ b/runtime/pendulum/src/zenlink.rs @@ -54,7 +54,7 @@ where zenlink_id_to_currency_id(asset_id, ParachainInfo::parachain_id().into()) { return TryInto::::try_into(Local::free_balance(currency_id, who)) - .unwrap_or_default() + .unwrap_or_default(); } AssetBalance::default() } @@ -64,7 +64,7 @@ where zenlink_id_to_currency_id(asset_id, ParachainInfo::parachain_id().into()) { return TryInto::::try_into(Local::total_issuance(currency_id)) - .unwrap_or_default() + .unwrap_or_default(); } AssetBalance::default() } @@ -111,7 +111,7 @@ where .map_err(|_| DispatchError::Other("convert amount in local deposit"))?, )?; } else { - return Err(DispatchError::Other("unknown asset in local transfer")) + return Err(DispatchError::Other("unknown asset in local transfer")); } Ok(amount) @@ -133,7 +133,7 @@ where .map_err(|_| DispatchError::Other("convert amount in local withdraw"))?, )?; } else { - return Err(DispatchError::Other("unknown asset in local transfer")) + return Err(DispatchError::Other("unknown asset in local transfer")); } Ok(amount) From fdeadb4fcd49429399ad7f0c9aa06ece0ceea2a6 Mon Sep 17 00:00:00 2001 From: Gianfranco Date: Mon, 3 Mar 2025 16:32:52 -0300 Subject: [PATCH 3/6] use common ss58 prefix --- runtime/foucoco/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/foucoco/src/lib.rs b/runtime/foucoco/src/lib.rs index 6ba3da480..0a715fc11 100644 --- a/runtime/foucoco/src/lib.rs +++ b/runtime/foucoco/src/lib.rs @@ -303,7 +303,7 @@ parameter_types! { }) .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO) .build_or_panic(); - pub const SS58Prefix: u16 = 57; + pub const SS58Prefix: u16 = 0; } pub struct BaseFilter; From fa32dfaf3b738c43638d8737bdb167d704ebdba9 Mon Sep 17 00:00:00 2001 From: Gianfranco Date: Mon, 3 Mar 2025 16:33:13 -0300 Subject: [PATCH 4/6] use common ss58 prefix --- runtime/foucoco/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/foucoco/src/lib.rs b/runtime/foucoco/src/lib.rs index 0a715fc11..0e30d27f1 100644 --- a/runtime/foucoco/src/lib.rs +++ b/runtime/foucoco/src/lib.rs @@ -410,7 +410,7 @@ impl frame_system::Config for Runtime { type BlockWeights = RuntimeBlockWeights; /// The maximum length of a block (in bytes). type BlockLength = RuntimeBlockLength; - /// This is used as an identifier of the chain. 57 is the prefix for Foucoco + /// Old 57 prefix for Foucoco type SS58Prefix = SS58Prefix; /// The action to take on a Runtime Upgrade type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode; From 5aadea2ff5b9081b7e8d1142966cab69a511d347 Mon Sep 17 00:00:00 2001 From: Gianfranco Date: Mon, 3 Mar 2025 16:57:51 -0300 Subject: [PATCH 5/6] change ss58 prefix on foucoco spec files --- res/foucoco-paseo-spec-raw.json | 2 +- res/foucoco-spec-raw.json | 2 +- res/foucoco-spec.json | 2 +- res/foucoco-standalone-spec-raw.json | 2 +- res/foucoco-standalone-spec.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/res/foucoco-paseo-spec-raw.json b/res/foucoco-paseo-spec-raw.json index 53aa04735..7c7a03a49 100644 --- a/res/foucoco-paseo-spec-raw.json +++ b/res/foucoco-paseo-spec-raw.json @@ -6,7 +6,7 @@ "telemetryEndpoints": null, "protocolId": "foucoco-p", "properties": { - "ss58Format": 57, + "ss58Format": 0, "tokenDecimals": 12, "tokenSymbol": "AMPE" }, diff --git a/res/foucoco-spec-raw.json b/res/foucoco-spec-raw.json index 7b68838ff..a69801b0c 100644 --- a/res/foucoco-spec-raw.json +++ b/res/foucoco-spec-raw.json @@ -6,7 +6,7 @@ "telemetryEndpoints": null, "protocolId": "foucoco", "properties": { - "ss58Format": 57, + "ss58Format": 0, "tokenDecimals": 12, "tokenSymbol": "AMPE" }, diff --git a/res/foucoco-spec.json b/res/foucoco-spec.json index e5fe3dccc..8f78fe7ba 100644 --- a/res/foucoco-spec.json +++ b/res/foucoco-spec.json @@ -6,7 +6,7 @@ "telemetryEndpoints": null, "protocolId": "foucoco", "properties": { - "ss58Format": 57, + "ss58Format": 0, "tokenDecimals": 12, "tokenSymbol": "AMPE" }, diff --git a/res/foucoco-standalone-spec-raw.json b/res/foucoco-standalone-spec-raw.json index 6acdc7caa..60483591f 100644 --- a/res/foucoco-standalone-spec-raw.json +++ b/res/foucoco-standalone-spec-raw.json @@ -6,7 +6,7 @@ "telemetryEndpoints": null, "protocolId": "foucoco", "properties": { - "ss58Format": 57, + "ss58Format": 0, "tokenDecimals": 12, "tokenSymbol": "AMPE" }, diff --git a/res/foucoco-standalone-spec.json b/res/foucoco-standalone-spec.json index 10a592823..82785743e 100644 --- a/res/foucoco-standalone-spec.json +++ b/res/foucoco-standalone-spec.json @@ -6,7 +6,7 @@ "telemetryEndpoints": null, "protocolId": "foucoco", "properties": { - "ss58Format": 57, + "ss58Format": 0, "tokenDecimals": 12, "tokenSymbol": "AMPE" }, From 7ed7ce97fe670b8a43306c949c62ddf4ce5cf4ed Mon Sep 17 00:00:00 2001 From: Gianfranco Date: Tue, 4 Mar 2025 08:42:30 -0300 Subject: [PATCH 6/6] revert ss58 changes --- res/foucoco-paseo-spec-raw.json | 2 +- res/foucoco-spec-raw.json | 2 +- res/foucoco-spec.json | 2 +- res/foucoco-standalone-spec-raw.json | 2 +- res/foucoco-standalone-spec.json | 2 +- runtime/foucoco/src/lib.rs | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/res/foucoco-paseo-spec-raw.json b/res/foucoco-paseo-spec-raw.json index 7c7a03a49..53aa04735 100644 --- a/res/foucoco-paseo-spec-raw.json +++ b/res/foucoco-paseo-spec-raw.json @@ -6,7 +6,7 @@ "telemetryEndpoints": null, "protocolId": "foucoco-p", "properties": { - "ss58Format": 0, + "ss58Format": 57, "tokenDecimals": 12, "tokenSymbol": "AMPE" }, diff --git a/res/foucoco-spec-raw.json b/res/foucoco-spec-raw.json index a69801b0c..7b68838ff 100644 --- a/res/foucoco-spec-raw.json +++ b/res/foucoco-spec-raw.json @@ -6,7 +6,7 @@ "telemetryEndpoints": null, "protocolId": "foucoco", "properties": { - "ss58Format": 0, + "ss58Format": 57, "tokenDecimals": 12, "tokenSymbol": "AMPE" }, diff --git a/res/foucoco-spec.json b/res/foucoco-spec.json index 8f78fe7ba..e5fe3dccc 100644 --- a/res/foucoco-spec.json +++ b/res/foucoco-spec.json @@ -6,7 +6,7 @@ "telemetryEndpoints": null, "protocolId": "foucoco", "properties": { - "ss58Format": 0, + "ss58Format": 57, "tokenDecimals": 12, "tokenSymbol": "AMPE" }, diff --git a/res/foucoco-standalone-spec-raw.json b/res/foucoco-standalone-spec-raw.json index 60483591f..6acdc7caa 100644 --- a/res/foucoco-standalone-spec-raw.json +++ b/res/foucoco-standalone-spec-raw.json @@ -6,7 +6,7 @@ "telemetryEndpoints": null, "protocolId": "foucoco", "properties": { - "ss58Format": 0, + "ss58Format": 57, "tokenDecimals": 12, "tokenSymbol": "AMPE" }, diff --git a/res/foucoco-standalone-spec.json b/res/foucoco-standalone-spec.json index 82785743e..10a592823 100644 --- a/res/foucoco-standalone-spec.json +++ b/res/foucoco-standalone-spec.json @@ -6,7 +6,7 @@ "telemetryEndpoints": null, "protocolId": "foucoco", "properties": { - "ss58Format": 0, + "ss58Format": 57, "tokenDecimals": 12, "tokenSymbol": "AMPE" }, diff --git a/runtime/foucoco/src/lib.rs b/runtime/foucoco/src/lib.rs index 0e30d27f1..6ba3da480 100644 --- a/runtime/foucoco/src/lib.rs +++ b/runtime/foucoco/src/lib.rs @@ -303,7 +303,7 @@ parameter_types! { }) .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO) .build_or_panic(); - pub const SS58Prefix: u16 = 0; + pub const SS58Prefix: u16 = 57; } pub struct BaseFilter; @@ -410,7 +410,7 @@ impl frame_system::Config for Runtime { type BlockWeights = RuntimeBlockWeights; /// The maximum length of a block (in bytes). type BlockLength = RuntimeBlockLength; - /// Old 57 prefix for Foucoco + /// This is used as an identifier of the chain. 57 is the prefix for Foucoco type SS58Prefix = SS58Prefix; /// The action to take on a Runtime Upgrade type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode;