diff --git a/bridges/bin/millau/node/Cargo.toml b/bridges/bin/millau/node/Cargo.toml index 6710c6a217f10..a0a0e4ffbd1e0 100644 --- a/bridges/bin/millau/node/Cargo.toml +++ b/bridges/bin/millau/node/Cargo.toml @@ -9,7 +9,8 @@ repository = "https://github.com/paritytech/parity-bridges-common/" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -clap = { version = "4.2.7", features = ["derive"] } +clap = { version = "4.3.12", features = ["derive"] } +futures = "0.3.28" jsonrpsee = { version = "0.16.2", features = ["server"] } serde_json = "1.0.96" @@ -37,10 +38,12 @@ sc-consensus-grandpa = { git = "https://github.com/paritytech/substrate", branch sc-consensus-grandpa-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" } +sc-offchain = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-service = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "master" } +sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-consensus-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/bridges/bin/millau/node/src/chain_spec.rs b/bridges/bin/millau/node/src/chain_spec.rs index 8669ca92cc801..425f5685ae267 100644 --- a/bridges/bin/millau/node/src/chain_spec.rs +++ b/bridges/bin/millau/node/src/chain_spec.rs @@ -16,8 +16,9 @@ use millau_runtime::{ AccountId, AuraConfig, BalancesConfig, BeefyConfig, BridgeRialtoMessagesConfig, - BridgeRialtoParachainMessagesConfig, BridgeWestendGrandpaConfig, GenesisConfig, GrandpaConfig, - SessionConfig, SessionKeys, Signature, SudoConfig, SystemConfig, WASM_BINARY, + BridgeRialtoParachainMessagesConfig, BridgeWestendGrandpaConfig, GrandpaConfig, + RuntimeGenesisConfig, SessionConfig, SessionKeys, Signature, SudoConfig, SystemConfig, + WASM_BINARY, }; use sp_consensus_aura::sr25519::AuthorityId as AuraId; use sp_consensus_beefy::crypto::AuthorityId as BeefyId; @@ -41,7 +42,7 @@ const RIALTO_MESSAGES_PALLET_OWNER: &str = "Rialto.MessagesOwner"; const RIALTO_PARACHAIN_MESSAGES_PALLET_OWNER: &str = "RialtoParachain.MessagesOwner"; /// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type. -pub type ChainSpec = sc_service::GenericChainSpec; +pub type ChainSpec = sc_service::GenericChainSpec; /// The chain specification option. This is expected to come in from the CLI and /// is little more than one of a number of alternatives which can easily be converted @@ -193,17 +194,18 @@ fn testnet_genesis( root_key: AccountId, endowed_accounts: Vec, _enable_println: bool, -) -> GenesisConfig { - GenesisConfig { +) -> RuntimeGenesisConfig { + RuntimeGenesisConfig { system: SystemConfig { code: WASM_BINARY.expect("Millau development WASM not available").to_vec(), + ..Default::default() }, balances: BalancesConfig { balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 50)).collect(), }, aura: AuraConfig { authorities: Vec::new() }, beefy: BeefyConfig::default(), - grandpa: GrandpaConfig { authorities: Vec::new() }, + grandpa: GrandpaConfig { authorities: Vec::new(), ..Default::default() }, sudo: SudoConfig { key: Some(root_key) }, session: SessionConfig { keys: initial_authorities diff --git a/bridges/bin/millau/node/src/command.rs b/bridges/bin/millau/node/src/command.rs index b8dff87f8f244..745b393786e1d 100644 --- a/bridges/bin/millau/node/src/command.rs +++ b/bridges/bin/millau/node/src/command.rs @@ -21,7 +21,7 @@ use crate::{ }; use frame_benchmarking_cli::BenchmarkCmd; use millau_runtime::{Block, RuntimeApi}; -use sc_cli::{ChainSpec, RuntimeVersion, SubstrateCli}; +use sc_cli::SubstrateCli; use sc_service::PartialComponents; impl SubstrateCli for Cli { @@ -53,10 +53,6 @@ impl SubstrateCli for Cli { "millau-bridge-node".into() } - fn native_runtime_version(_: &Box) -> &'static RuntimeVersion { - &millau_runtime::VERSION - } - fn load_spec(&self, id: &str) -> Result, String> { Ok(Box::new( match id { @@ -83,8 +79,7 @@ pub fn run() -> sc_cli::Result<()> { match cmd { BenchmarkCmd::Pallet(cmd) => if cfg!(feature = "runtime-benchmarks") { - runner - .sync_run(|config| cmd.run::(config)) + runner.sync_run(|config| cmd.run::(config)) } else { println!( "Benchmarking wasn't enabled when building the node. \ diff --git a/bridges/bin/millau/node/src/service.rs b/bridges/bin/millau/node/src/service.rs index 3f0bc2536be0a..954b46fe0ceda 100644 --- a/bridges/bin/millau/node/src/service.rs +++ b/bridges/bin/millau/node/src/service.rs @@ -18,13 +18,14 @@ use jsonrpsee::RpcModule; use millau_runtime::{self, opaque::Block, RuntimeApi}; -use sc_client_api::BlockBackend; +use sc_client_api::{Backend, BlockBackend}; use sc_consensus_aura::{CompatibilityMode, ImportQueueParams, SlotProportion, StartAuraParams}; use sc_consensus_grandpa::SharedVoterState; pub use sc_executor::NativeElseWasmExecutor; use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY}; use sc_service::{error::Error as ServiceError, Configuration, TaskManager}; use sc_telemetry::{Telemetry, TelemetryWorker}; +use sc_transaction_pool_api::OffchainTransactionPoolFactory; use sp_consensus_aura::sr25519::AuthorityPair as AuraPair; use std::{sync::Arc, time::Duration}; @@ -127,6 +128,7 @@ pub fn new_partial( let (grandpa_block_import, grandpa_link) = sc_consensus_grandpa::block_import( client.clone(), + 512, &client, select_chain.clone(), telemetry.as_ref().map(|x| x.handle()), @@ -223,6 +225,7 @@ pub fn new_full(config: Configuration) -> Result { ); net_config.add_request_response_protocol(beefy_req_resp_cfg); + let role = config.role.clone(); let warp_sync = Arc::new(sc_consensus_grandpa::warp_proof::NetworkProvider::new( backend.clone(), grandpa_link.shared_authority_set().clone(), @@ -242,15 +245,28 @@ pub fn new_full(config: Configuration) -> Result { })?; if config.offchain_worker.enabled { - sc_service::build_offchain_workers( - &config, - task_manager.spawn_handle(), - client.clone(), - network.clone(), + use futures::FutureExt; + + task_manager.spawn_handle().spawn( + "offchain-workers-runner", + "offchain-work", + sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions { + runtime_api_provider: client.clone(), + keystore: Some(keystore_container.keystore()), + offchain_db: backend.offchain_storage(), + transaction_pool: Some(OffchainTransactionPoolFactory::new( + transaction_pool.clone(), + )), + network_provider: network.clone(), + is_validator: role.is_authority(), + enable_http_requests: false, + custom_extensions: move |_| vec![], + }) + .run(client.clone(), task_manager.spawn_handle()) + .boxed(), ); } - let role = config.role.clone(); let force_authoring = config.force_authoring; let backoff_authoring_blocks: Option<()> = None; let name = config.network.node_name.clone(); @@ -277,7 +293,7 @@ pub fn new_full(config: Configuration) -> Result { let shared_voter_state = shared_voter_state.clone(); let finality_proof_provider = GrandpaFinalityProofProvider::new_for_service( - backend, + backend.clone(), Some(shared_authority_set.clone()), ); @@ -308,7 +324,16 @@ pub fn new_full(config: Configuration) -> Result { .into_rpc(), ) .map_err(map_err)?; - io.merge(Mmr::new(client.clone()).into_rpc()).map_err(map_err)?; + io.merge( + Mmr::new( + client.clone(), + backend + .offchain_storage() + .ok_or("Backend doesn't provide the required offchain storage")?, + ) + .into_rpc(), + ) + .map_err(map_err)?; Ok(io) }) }; @@ -332,7 +357,7 @@ pub fn new_full(config: Configuration) -> Result { let proposer_factory = sc_basic_authorship::ProposerFactory::new( task_manager.spawn_handle(), client.clone(), - transaction_pool, + transaction_pool.clone(), prometheus_registry.as_ref(), telemetry.as_ref().map(|x| x.handle()), ); @@ -411,7 +436,7 @@ pub fn new_full(config: Configuration) -> Result { let grandpa_config = sc_consensus_grandpa::Config { // FIXME #1578 make this available through chainspec gossip_duration: Duration::from_millis(333), - justification_period: 512, + justification_generation_period: 512, name: Some(name), observer_enabled: false, keystore, @@ -436,6 +461,7 @@ pub fn new_full(config: Configuration) -> Result { prometheus_registry, shared_voter_state, telemetry: telemetry.as_ref().map(|x| x.handle()), + offchain_tx_pool_factory: OffchainTransactionPoolFactory::new(transaction_pool), }; // the GRANDPA voter task is considered infallible, i.e. diff --git a/bridges/bin/millau/runtime/src/lib.rs b/bridges/bin/millau/runtime/src/lib.rs index 92dabc9407ce7..daaa9815a8afc 100644 --- a/bridges/bin/millau/runtime/src/lib.rs +++ b/bridges/bin/millau/runtime/src/lib.rs @@ -65,7 +65,8 @@ pub use frame_support::{ dispatch::DispatchClass, parameter_types, traits::{ - ConstU32, ConstU64, ConstU8, Currency, ExistenceRequirement, Imbalance, KeyOwnerProofSystem, + ConstBool, ConstU32, ConstU64, ConstU8, Currency, ExistenceRequirement, Imbalance, + KeyOwnerProofSystem, }, weights::{ constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, IdentityFee, RuntimeDbWeight, @@ -111,8 +112,8 @@ pub type AccountIndex = u32; /// Balance of an account. pub type Balance = bp_millau::Balance; -/// Index of a transaction in the chain. -pub type Index = bp_millau::Index; +/// Nonce of a transaction in the chain. +pub type Nonce = bp_millau::Nonce; /// A hash of some data used by the chain. pub type Hash = bp_millau::Hash; @@ -184,15 +185,13 @@ impl frame_system::Config for Runtime { /// The lookup mechanism to get account ID from whatever is passed in dispatchers. type Lookup = IdentityLookup; /// The index type for storing how many extrinsics an account has signed. - type Index = Index; - /// The index type for blocks. - type BlockNumber = BlockNumber; + type Nonce = Nonce; /// The type for hashing blocks and tries. type Hash = Hash; /// The hashing algorithm used. type Hashing = Hashing; /// The header type. - type Header = generic::Header; + type Block = Block; /// The ubiquitous event type. type RuntimeEvent = RuntimeEvent; /// The ubiquitous origin type. @@ -229,6 +228,7 @@ impl pallet_aura::Config for Runtime { type AuthorityId = AuraId; type MaxAuthorities = ConstU32<10>; type DisabledValidators = (); + type AllowMultipleBlocksPerSlot = ConstBool; } impl pallet_beefy::Config for Runtime { @@ -239,6 +239,7 @@ impl pallet_beefy::Config for Runtime { type WeightInfo = (); type KeyOwnerProof = sp_core::Void; type EquivocationReportSystem = (); + type MaxNominators = ConstU32<256>; } impl pallet_grandpa::Config for Runtime { @@ -249,6 +250,7 @@ impl pallet_grandpa::Config for Runtime { type MaxSetIdSessionEntries = ConstU64<0>; type KeyOwnerProof = sp_core::Void; type EquivocationReportSystem = (); + type MaxNominators = ConstU32<256>; } /// MMR helper types. @@ -542,12 +544,8 @@ impl pallet_utility::Config for Runtime { } construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = opaque::Block, - UncheckedExtrinsic = UncheckedExtrinsic - { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + pub enum Runtime { + System: frame_system::{Pallet, Call, Config, Storage, Event}, Sudo: pallet_sudo::{Pallet, Call, Config, Storage, Event}, Utility: pallet_utility, @@ -560,7 +558,7 @@ construct_runtime!( // Consensus support. Session: pallet_session::{Pallet, Call, Storage, Event, Config}, - Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event}, + Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event}, ShiftSessionManager: pallet_shift_session_manager::{Pallet}, // BEEFY Bridges support. @@ -582,7 +580,7 @@ construct_runtime!( BridgeRialtoParachainMessages: pallet_bridge_messages::::{Pallet, Call, Storage, Event, Config}, // Pallet for sending XCM. - XcmPallet: pallet_xcm::{Pallet, Call, Storage, Event, Origin, Config} = 99, + XcmPallet: pallet_xcm::{Pallet, Call, Storage, Event, Origin, Config} = 99, } ); @@ -708,8 +706,8 @@ impl_runtime_apis! { } } - impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { - fn account_nonce(account: AccountId) -> Index { + impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { + fn account_nonce(account: AccountId) -> Nonce { System::account_nonce(account) } } diff --git a/bridges/bin/millau/runtime/src/xcm_config.rs b/bridges/bin/millau/runtime/src/xcm_config.rs index d6b763b116c29..623c8219016fe 100644 --- a/bridges/bin/millau/runtime/src/xcm_config.rs +++ b/bridges/bin/millau/runtime/src/xcm_config.rs @@ -110,6 +110,7 @@ pub type Barrier = ( pub type OnMillauBlobDispatcher = xcm_builder::BridgeBlobDispatcher< crate::xcm_config::XcmRouter, crate::xcm_config::UniversalLocation, + (), >; /// XCM weigher type. @@ -141,6 +142,7 @@ impl xcm_executor::Config for XcmConfig { type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; + type Aliasers = Nothing; } /// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior @@ -247,11 +249,12 @@ mod tests { use bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatchResult; use codec::Encode; use pallet_bridge_messages::OutboundLanes; + use sp_runtime::BuildStorage; use xcm_executor::XcmExecutor; fn new_test_ext() -> sp_io::TestExternalities { sp_io::TestExternalities::new( - frame_system::GenesisConfig::default().build_storage::().unwrap(), + frame_system::GenesisConfig::::default().build_storage().unwrap(), ) } diff --git a/bridges/bin/rialto-parachain/node/src/chain_spec.rs b/bridges/bin/rialto-parachain/node/src/chain_spec.rs index bfce4f717c679..b42c9a6a8f5ee 100644 --- a/bridges/bin/rialto-parachain/node/src/chain_spec.rs +++ b/bridges/bin/rialto-parachain/node/src/chain_spec.rs @@ -35,7 +35,7 @@ const MILLAU_MESSAGES_PALLET_OWNER: &str = "Millau.MessagesOwner"; /// Specialized `ChainSpec` for the normal parachain runtime. pub type ChainSpec = - sc_service::GenericChainSpec; + sc_service::GenericChainSpec; /// Helper function to generate a crypto pair from seed pub fn get_from_seed(seed: &str) -> ::Public { @@ -176,18 +176,22 @@ fn testnet_genesis( initial_authorities: Vec, endowed_accounts: Vec, id: ParaId, -) -> rialto_parachain_runtime::GenesisConfig { - rialto_parachain_runtime::GenesisConfig { +) -> rialto_parachain_runtime::RuntimeGenesisConfig { + rialto_parachain_runtime::RuntimeGenesisConfig { system: rialto_parachain_runtime::SystemConfig { code: rialto_parachain_runtime::WASM_BINARY .expect("WASM binary was not build, please build it!") .to_vec(), + ..Default::default() }, balances: rialto_parachain_runtime::BalancesConfig { balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(), }, sudo: rialto_parachain_runtime::SudoConfig { key: Some(root_key) }, - parachain_info: rialto_parachain_runtime::ParachainInfoConfig { parachain_id: id }, + parachain_info: rialto_parachain_runtime::ParachainInfoConfig { + parachain_id: id, + ..Default::default() + }, aura: rialto_parachain_runtime::AuraConfig { authorities: initial_authorities }, aura_ext: Default::default(), bridge_millau_messages: BridgeMillauMessagesConfig { diff --git a/bridges/bin/rialto-parachain/node/src/cli.rs b/bridges/bin/rialto-parachain/node/src/cli.rs index 77d5bd1ff948a..c8c457752d600 100644 --- a/bridges/bin/rialto-parachain/node/src/cli.rs +++ b/bridges/bin/rialto-parachain/node/src/cli.rs @@ -18,6 +18,7 @@ use crate::chain_spec; use clap::Parser; +use cumulus_client_cli::{ExportGenesisStateCommand, ExportGenesisWasmCommand}; use std::path::PathBuf; /// Sub-commands supported by the collator. @@ -57,44 +58,6 @@ pub enum Subcommand { Benchmark(frame_benchmarking_cli::BenchmarkCmd), } -/// Command for exporting the genesis state of the parachain -#[derive(Debug, Parser)] -pub struct ExportGenesisStateCommand { - /// Output file name or stdout if unspecified. - #[clap(action)] - pub output: Option, - - /// Id of the parachain this state is for. - /// - /// Default: 100 - #[clap(long, conflicts_with = "chain")] - pub parachain_id: Option, - - /// Write output in binary. Default is to write in hex. - #[clap(short, long)] - pub raw: bool, - - /// The name of the chain for that the genesis state should be exported. - #[clap(long, conflicts_with = "parachain-id")] - pub chain: Option, -} - -/// Command for exporting the genesis wasm file. -#[derive(Debug, Parser)] -pub struct ExportGenesisWasmCommand { - /// Output file name or stdout if unspecified. - #[clap(action)] - pub output: Option, - - /// Write output in binary. Default is to write in hex. - #[clap(short, long)] - pub raw: bool, - - /// The name of the chain for that the genesis wasm file should be exported. - #[clap(long)] - pub chain: Option, -} - #[derive(Debug, Parser)] #[clap( propagate_version = true, diff --git a/bridges/bin/rialto-parachain/node/src/command.rs b/bridges/bin/rialto-parachain/node/src/command.rs index dce14df801b0f..50c1857f1c9c8 100644 --- a/bridges/bin/rialto-parachain/node/src/command.rs +++ b/bridges/bin/rialto-parachain/node/src/command.rs @@ -17,22 +17,18 @@ use crate::{ chain_spec, cli::{Cli, RelayChainCli, Subcommand}, - service::{new_partial, ParachainRuntimeExecutor}, + service::new_partial, }; -use codec::Encode; -use cumulus_client_cli::generate_genesis_block; use cumulus_primitives_core::ParaId; use frame_benchmarking_cli::BenchmarkCmd; use log::info; use rialto_parachain_runtime::{Block, RuntimeApi}; use sc_cli::{ ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, - NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli, + NetworkParams, Result, SharedParams, SubstrateCli, }; use sc_service::config::{BasePath, PrometheusConfig}; -use sp_core::hexdisplay::HexDisplay; -use sp_runtime::traits::{AccountIdConversion, Block as BlockT}; -use std::{io::Write, net::SocketAddr}; +use std::net::SocketAddr; fn load_spec( id: &str, @@ -79,10 +75,6 @@ impl SubstrateCli for Cli { fn load_spec(&self, id: &str) -> std::result::Result, String> { load_spec(id, self.parachain_id.unwrap_or(2000).into()) } - - fn native_runtime_version(_: &Box) -> &'static RuntimeVersion { - &rialto_parachain_runtime::VERSION - } } impl SubstrateCli for RelayChainCli { @@ -117,19 +109,6 @@ impl SubstrateCli for RelayChainCli { fn load_spec(&self, id: &str) -> std::result::Result, String> { polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id) } - - fn native_runtime_version(chain_spec: &Box) -> &'static RuntimeVersion { - polkadot_cli::Cli::native_runtime_version(chain_spec) - } -} - -fn extract_genesis_wasm(chain_spec: &dyn sc_service::ChainSpec) -> Result> { - let mut storage = chain_spec.build_storage()?; - - storage - .top - .remove(sp_core::storage::well_known_keys::CODE) - .ok_or_else(|| "Could not find wasm file in genesis state!".into()) } macro_rules! construct_async_run { @@ -207,59 +186,30 @@ pub fn run() -> Result<()> { None ))) }, - Some(Subcommand::ExportGenesisState(params)) => { - let mut builder = sc_cli::LoggerBuilder::new(""); - builder.with_profiling(sc_tracing::TracingReceiver::Log, ""); - let _ = builder.init(); - - let spec = load_spec( - ¶ms.chain.clone().unwrap_or_default(), - params.parachain_id.expect("Missing ParaId").into(), - )?; - let state_version = Cli::native_runtime_version(&spec).state_version(); - let block: Block = generate_genesis_block(&*spec, state_version)?; - let raw_header = block.header().encode(); - let output_buf = if params.raw { - raw_header - } else { - format!("0x{:?}", HexDisplay::from(&block.header().encode())).into_bytes() - }; - - if let Some(output) = ¶ms.output { - std::fs::write(output, output_buf)?; - } else { - std::io::stdout().write_all(&output_buf)?; - } + Some(Subcommand::ExportGenesisState(cmd)) => { + let runner = cli.create_runner(cmd)?; + runner.sync_run(|config| { + let partials = new_partial::( + &config, + crate::service::parachain_build_import_queue, + )?; - Ok(()) + cmd.run(&*config.chain_spec, &*partials.client) + }) }, - Some(Subcommand::ExportGenesisWasm(params)) => { - let mut builder = sc_cli::LoggerBuilder::new(""); - builder.with_profiling(sc_tracing::TracingReceiver::Log, ""); - let _ = builder.init(); - - let raw_wasm_blob = - extract_genesis_wasm(&*cli.load_spec(¶ms.chain.clone().unwrap_or_default())?)?; - let output_buf = if params.raw { - raw_wasm_blob - } else { - format!("0x{:?}", HexDisplay::from(&raw_wasm_blob)).into_bytes() - }; - - if let Some(output) = ¶ms.output { - std::fs::write(output, output_buf)?; - } else { - std::io::stdout().write_all(&output_buf)?; - } - - Ok(()) + Some(Subcommand::ExportGenesisWasm(cmd)) => { + let runner = cli.create_runner(cmd)?; + runner.sync_run(|_config| { + let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?; + cmd.run(&*spec) + }) }, Some(Subcommand::Benchmark(cmd)) => { let runner = cli.create_runner(cmd)?; match cmd { BenchmarkCmd::Pallet(cmd) => if cfg!(feature = "runtime-benchmarks") { - runner.sync_run(|config| cmd.run::(config)) + runner.sync_run(|config| cmd.run::(config)) } else { println!( "Benchmarking wasn't enabled when building the node. \ @@ -285,15 +235,6 @@ pub fn run() -> Result<()> { let id = ParaId::from(cli.parachain_id.or(para_id).expect("Missing ParaId")); - let parachain_account = - AccountIdConversion::::into_account_truncating(&id); - - let state_version = - RelayChainCli::native_runtime_version(&config.chain_spec).state_version(); - let block: Block = generate_genesis_block(&*config.chain_spec, state_version) - .map_err(|e| format!("{e:?}"))?; - let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode())); - let polkadot_config = SubstrateCli::create_configuration( &polkadot_cli, &polkadot_cli, @@ -302,8 +243,6 @@ pub fn run() -> Result<()> { .map_err(|err| format!("Relay chain argument error: {err}"))?; info!("Parachain id: {:?}", id); - info!("Parachain Account: {}", parachain_account); - info!("Parachain genesis state: {}", genesis_state); info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" }); crate::service::start_node(config, polkadot_config, collator_options, id) diff --git a/bridges/bin/rialto-parachain/node/src/service.rs b/bridges/bin/rialto-parachain/node/src/service.rs index f21a2f65e795b..e244f6018f641 100644 --- a/bridges/bin/rialto-parachain/node/src/service.rs +++ b/bridges/bin/rialto-parachain/node/src/service.rs @@ -33,7 +33,7 @@ use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, Slo use cumulus_client_consensus_common::{ ParachainBlockImport as TParachainBlockImport, ParachainConsensus, }; -use cumulus_client_network::BlockAnnounceValidator; +use cumulus_client_network::RequireSecondedInBlockAnnounce; use cumulus_client_service::{ prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams, }; @@ -271,7 +271,8 @@ where let client = params.client.clone(); let backend = params.backend.clone(); - let block_announce_validator = BlockAnnounceValidator::new(relay_chain_interface.clone(), id); + let block_announce_validator = + RequireSecondedInBlockAnnounce::new(relay_chain_interface.clone(), id); let force_authoring = parachain_config.force_authoring; let validator = parachain_config.role.is_authority(); diff --git a/bridges/bin/rialto-parachain/runtime/src/lib.rs b/bridges/bin/rialto-parachain/runtime/src/lib.rs index 498cdf8a58fde..18c915819d5fb 100644 --- a/bridges/bin/rialto-parachain/runtime/src/lib.rs +++ b/bridges/bin/rialto-parachain/runtime/src/lib.rs @@ -50,7 +50,7 @@ pub use frame_support::{ construct_runtime, dispatch::DispatchClass, match_types, parameter_types, - traits::{ConstU32, Everything, IsInVec, Nothing, Randomness}, + traits::{ConstBool, ConstU32, Everything, IsInVec, Nothing, Randomness}, weights::{ constants::{ BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND, @@ -70,7 +70,7 @@ pub use sp_runtime::{MultiAddress, Perbill, Permill}; pub use bp_rialto_parachain::{ AccountId, Balance, BlockLength, BlockNumber, BlockWeights, Hash, Hasher as Hashing, Header, - Index, Signature, MAXIMUM_BLOCK_WEIGHT, + Nonce, Signature, MAXIMUM_BLOCK_WEIGHT, }; pub use pallet_bridge_grandpa::Call as BridgeGrandpaCall; @@ -231,15 +231,13 @@ impl frame_system::Config for Runtime { /// The lookup mechanism to get account ID from whatever is passed in dispatchers. type Lookup = AccountIdLookup; /// The index type for storing how many extrinsics an account has signed. - type Index = Index; - /// The index type for blocks. - type BlockNumber = BlockNumber; + type Nonce = Nonce; /// The type for hashing blocks and tries. type Hash = Hash; /// The hashing algorithm used. type Hashing = Hashing; /// The header type. - type Header = generic::Header; + type Block = Block; /// The ubiquitous event type. type RuntimeEvent = RuntimeEvent; /// The ubiquitous origin type. @@ -431,7 +429,7 @@ pub type Barrier = TakeWeightCredit; /// Dispatches received XCM messages from other chain. pub type OnRialtoParachainBlobDispatcher = - xcm_builder::BridgeBlobDispatcher; + xcm_builder::BridgeBlobDispatcher; /// XCM weigher type. pub type XcmWeigher = FixedWeightBounds; @@ -461,6 +459,7 @@ impl Config for XcmConfig { type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; + type Aliasers = Nothing; } /// No local origins on this chain are allowed to dispatch XCM sends/executions. @@ -529,6 +528,7 @@ impl pallet_aura::Config for Runtime { type AuthorityId = AuraId; type DisabledValidators = (); type MaxAuthorities = MaxAuthorities; + type AllowMultipleBlocksPerSlot = ConstBool; } impl pallet_bridge_relayers::Config for Runtime { @@ -592,23 +592,19 @@ impl pallet_bridge_messages::Config for Runtime { // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = generic::Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { - System: frame_system::{Pallet, Call, Storage, Config, Event}, + pub enum Runtime { + System: frame_system::{Pallet, Call, Storage, Config, Event}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, Sudo: pallet_sudo::{Pallet, Call, Storage, Config, Event}, TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event}, ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event} = 20, - ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21, + ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event} = 30, Aura: pallet_aura::{Pallet, Config}, - AuraExt: cumulus_pallet_aura_ext::{Pallet, Config}, + AuraExt: cumulus_pallet_aura_ext::{Pallet, Config}, // XCM helpers. XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event} = 50, @@ -719,8 +715,8 @@ impl_runtime_apis! { } } - impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { - fn account_nonce(account: AccountId) -> Index { + impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { + fn account_nonce(account: AccountId) -> Nonce { System::account_nonce(account) } } @@ -866,7 +862,7 @@ mod tests { fn new_test_ext() -> sp_io::TestExternalities { sp_io::TestExternalities::new( - frame_system::GenesisConfig::default().build_storage::().unwrap(), + frame_system::GenesisConfig::::default().build_storage().unwrap(), ) } diff --git a/bridges/bin/rialto/node/src/chain_spec.rs b/bridges/bin/rialto/node/src/chain_spec.rs index c5364019a0e4c..d32dc55296943 100644 --- a/bridges/bin/rialto/node/src/chain_spec.rs +++ b/bridges/bin/rialto/node/src/chain_spec.rs @@ -14,11 +14,11 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -use polkadot_primitives::v4::{AssignmentId, ValidatorId}; +use polkadot_primitives::v5::{AssignmentId, ValidatorId}; use rialto_runtime::{ AccountId, BabeConfig, BalancesConfig, BeefyConfig, BridgeMillauMessagesConfig, - ConfigurationConfig, GenesisConfig, GrandpaConfig, SessionConfig, SessionKeys, Signature, - SudoConfig, SystemConfig, WASM_BINARY, + ConfigurationConfig, GrandpaConfig, RuntimeGenesisConfig, SessionConfig, SessionKeys, + Signature, SudoConfig, SystemConfig, WASM_BINARY, }; use serde_json::json; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; @@ -41,7 +41,7 @@ const MILLAU_MESSAGES_PALLET_OWNER: &str = "Millau.MessagesOwner"; /// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type. pub type ChainSpec = - sc_service::GenericChainSpec; + sc_service::GenericChainSpec; /// The chain specification option. This is expected to come in from the CLI and /// is little more than one of a number of alternatives which can easily be converted @@ -200,10 +200,11 @@ fn testnet_genesis( root_key: AccountId, endowed_accounts: Vec, _enable_println: bool, -) -> GenesisConfig { - GenesisConfig { +) -> RuntimeGenesisConfig { + RuntimeGenesisConfig { system: SystemConfig { code: WASM_BINARY.expect("Rialto development WASM not available").to_vec(), + ..Default::default() }, balances: BalancesConfig { balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 50)).collect(), @@ -211,9 +212,10 @@ fn testnet_genesis( babe: BabeConfig { authorities: Vec::new(), epoch_config: Some(rialto_runtime::BABE_GENESIS_EPOCH_CONFIG), + ..Default::default() }, beefy: BeefyConfig::default(), - grandpa: GrandpaConfig { authorities: Vec::new() }, + grandpa: GrandpaConfig { authorities: Vec::new(), ..Default::default() }, sudo: SudoConfig { key: Some(root_key) }, session: SessionConfig { keys: initial_authorities @@ -243,8 +245,8 @@ fn testnet_genesis( validation_upgrade_cooldown: 2u32, validation_upgrade_delay: 2, code_retention_period: 1200, - max_code_size: polkadot_primitives::v4::MAX_CODE_SIZE, - max_pov_size: polkadot_primitives::v4::MAX_POV_SIZE, + max_code_size: polkadot_primitives::v5::MAX_CODE_SIZE, + max_pov_size: polkadot_primitives::v5::MAX_POV_SIZE, max_head_data_size: 32 * 1024, group_rotation_frequency: 20, chain_availability_period: 4, diff --git a/bridges/bin/rialto/node/src/command.rs b/bridges/bin/rialto/node/src/command.rs index a21b3a88d2c23..156d365c20243 100644 --- a/bridges/bin/rialto/node/src/command.rs +++ b/bridges/bin/rialto/node/src/command.rs @@ -17,7 +17,7 @@ use crate::cli::{Cli, Subcommand}; use frame_benchmarking_cli::BenchmarkCmd; use rialto_runtime::{Block, RuntimeApi}; -use sc_cli::{ChainSpec, RuntimeVersion, SubstrateCli}; +use sc_cli::SubstrateCli; impl SubstrateCli for Cli { fn impl_name() -> String { @@ -48,10 +48,6 @@ impl SubstrateCli for Cli { "rialto-bridge-node".into() } - fn native_runtime_version(_: &Box) -> &'static RuntimeVersion { - &rialto_runtime::VERSION - } - fn load_spec(&self, id: &str) -> Result, String> { Ok(Box::new( match id { @@ -92,7 +88,7 @@ pub fn run() -> sc_cli::Result<()> { match cmd { BenchmarkCmd::Pallet(cmd) => if cfg!(feature = "runtime-benchmarks") { - runner.sync_run(|config| cmd.run::(config)) + runner.sync_run(|config| cmd.run::(config)) } else { println!( "Benchmarking wasn't enabled when building the node. \ @@ -200,7 +196,7 @@ pub fn run() -> sc_cli::Result<()> { let program_path = None; let overseer_enable_anyways = false; - polkadot_service::new_full::( + polkadot_service::new_full( config, is_collator, grandpa_pause, diff --git a/bridges/bin/rialto/runtime/src/lib.rs b/bridges/bin/rialto/runtime/src/lib.rs index 9240314c54430..1d93d24951e91 100644 --- a/bridges/bin/rialto/runtime/src/lib.rs +++ b/bridges/bin/rialto/runtime/src/lib.rs @@ -94,8 +94,8 @@ pub type AccountIndex = u32; /// Balance of an account. pub type Balance = bp_rialto::Balance; -/// Index of a transaction in the chain. -pub type Index = bp_rialto::Index; +/// Nonce of a transaction in the chain. +pub type Nonce = bp_rialto::Nonce; /// A hash of some data used by the chain. pub type Hash = bp_rialto::Hash; @@ -170,15 +170,13 @@ impl frame_system::Config for Runtime { /// The lookup mechanism to get account ID from whatever is passed in dispatchers. type Lookup = AccountIdLookup; /// The index type for storing how many extrinsics an account has signed. - type Index = Index; - /// The index type for blocks. - type BlockNumber = BlockNumber; + type Nonce = Nonce; /// The type for hashing blocks and tries. type Hash = Hash; /// The hashing algorithm used. type Hashing = Hashing; /// The header type. - type Header = generic::Header; + type Block = Block; /// The ubiquitous event type. type RuntimeEvent = RuntimeEvent; /// The ubiquitous origin type. @@ -238,6 +236,8 @@ impl pallet_babe::Config for Runtime { // equivocation related configuration - we don't expect any equivocations in our testnets type KeyOwnerProof = sp_core::Void; type EquivocationReportSystem = (); + + type MaxNominators = ConstU32<256>; } impl pallet_beefy::Config for Runtime { @@ -248,6 +248,7 @@ impl pallet_beefy::Config for Runtime { type WeightInfo = (); type KeyOwnerProof = sp_core::Void; type EquivocationReportSystem = (); + type MaxNominators = ConstU32<256>; } impl pallet_grandpa::Config for Runtime { @@ -258,6 +259,7 @@ impl pallet_grandpa::Config for Runtime { type MaxSetIdSessionEntries = ConstU64<0>; type KeyOwnerProof = sp_core::Void; type EquivocationReportSystem = (); + type MaxNominators = ConstU32<256>; } impl pallet_mmr::Config for Runtime { @@ -454,25 +456,21 @@ impl pallet_bridge_beefy::Config for Runtime { } construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = opaque::Block, - UncheckedExtrinsic = UncheckedExtrinsic - { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + pub enum Runtime { + System: frame_system::{Pallet, Call, Config, Storage, Event}, Sudo: pallet_sudo::{Pallet, Call, Config, Storage, Event}, // Must be before session. - Babe: pallet_babe::{Pallet, Call, Storage, Config, ValidateUnsigned}, + Babe: pallet_babe::{Pallet, Call, Storage, Config, ValidateUnsigned}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event}, // Consensus support. - AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config}, + AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config}, Session: pallet_session::{Pallet, Call, Storage, Event, Config}, - Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event}, + Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event}, ShiftSessionManager: pallet_shift_session_manager::{Pallet}, // BEEFY Bridges support. @@ -495,10 +493,10 @@ construct_runtime!( Inclusion: polkadot_runtime_parachains::inclusion::{Pallet, Call, Storage, Event}, ParasInherent: polkadot_runtime_parachains::paras_inherent::{Pallet, Call, Storage, Inherent}, Scheduler: polkadot_runtime_parachains::scheduler::{Pallet, Storage}, - Paras: polkadot_runtime_parachains::paras::{Pallet, Call, Storage, Event, Config, ValidateUnsigned}, + Paras: polkadot_runtime_parachains::paras::{Pallet, Call, Storage, Event, Config, ValidateUnsigned}, Initializer: polkadot_runtime_parachains::initializer::{Pallet, Call, Storage}, Dmp: polkadot_runtime_parachains::dmp::{Pallet, Storage}, - Hrmp: polkadot_runtime_parachains::hrmp::{Pallet, Call, Storage, Event, Config}, + Hrmp: polkadot_runtime_parachains::hrmp::{Pallet, Call, Storage, Event, Config}, SessionInfo: polkadot_runtime_parachains::session_info::{Pallet, Storage}, ParaSessionInfo: polkadot_runtime_parachains::session_info::{Pallet, Storage}, ParasDisputes: polkadot_runtime_parachains::disputes::{Pallet, Call, Storage, Event}, @@ -511,7 +509,7 @@ construct_runtime!( ParasSudoWrapper: polkadot_runtime_common::paras_sudo_wrapper::{Pallet, Call}, // Pallet for sending XCM. - XcmPallet: pallet_xcm::{Pallet, Call, Storage, Event, Origin, Config} = 99, + XcmPallet: pallet_xcm::{Pallet, Call, Storage, Event, Origin, Config} = 99, } ); @@ -612,8 +610,8 @@ impl_runtime_apis! { } } - impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { - fn account_nonce(account: AccountId) -> Index { + impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { + fn account_nonce(account: AccountId) -> Nonce { System::account_nonce(account) } } @@ -764,55 +762,55 @@ impl_runtime_apis! { } impl polkadot_primitives::runtime_api::ParachainHost for Runtime { - fn validators() -> Vec { - polkadot_runtime_parachains::runtime_api_impl::v4::validators::() + fn validators() -> Vec { + polkadot_runtime_parachains::runtime_api_impl::v5::validators::() } - fn validator_groups() -> (Vec>, polkadot_primitives::v4::GroupRotationInfo) { - polkadot_runtime_parachains::runtime_api_impl::v4::validator_groups::() + fn validator_groups() -> (Vec>, polkadot_primitives::v5::GroupRotationInfo) { + polkadot_runtime_parachains::runtime_api_impl::v5::validator_groups::() } - fn availability_cores() -> Vec> { - polkadot_runtime_parachains::runtime_api_impl::v4::availability_cores::() + fn availability_cores() -> Vec> { + polkadot_runtime_parachains::runtime_api_impl::v5::availability_cores::() } - fn persisted_validation_data(para_id: polkadot_primitives::v4::Id, assumption: polkadot_primitives::v4::OccupiedCoreAssumption) - -> Option> { - polkadot_runtime_parachains::runtime_api_impl::v4::persisted_validation_data::(para_id, assumption) + fn persisted_validation_data(para_id: polkadot_primitives::v5::Id, assumption: polkadot_primitives::v5::OccupiedCoreAssumption) + -> Option> { + polkadot_runtime_parachains::runtime_api_impl::v5::persisted_validation_data::(para_id, assumption) } fn assumed_validation_data( - para_id: polkadot_primitives::v4::Id, + para_id: polkadot_primitives::v5::Id, expected_persisted_validation_data_hash: Hash, - ) -> Option<(polkadot_primitives::v4::PersistedValidationData, polkadot_primitives::v4::ValidationCodeHash)> { - polkadot_runtime_parachains::runtime_api_impl::v4::assumed_validation_data::( + ) -> Option<(polkadot_primitives::v5::PersistedValidationData, polkadot_primitives::v5::ValidationCodeHash)> { + polkadot_runtime_parachains::runtime_api_impl::v5::assumed_validation_data::( para_id, expected_persisted_validation_data_hash, ) } fn check_validation_outputs( - para_id: polkadot_primitives::v4::Id, - outputs: polkadot_primitives::v4::CandidateCommitments, + para_id: polkadot_primitives::v5::Id, + outputs: polkadot_primitives::v5::CandidateCommitments, ) -> bool { - polkadot_runtime_parachains::runtime_api_impl::v4::check_validation_outputs::(para_id, outputs) + polkadot_runtime_parachains::runtime_api_impl::v5::check_validation_outputs::(para_id, outputs) } - fn session_index_for_child() -> polkadot_primitives::v4::SessionIndex { - polkadot_runtime_parachains::runtime_api_impl::v4::session_index_for_child::() + fn session_index_for_child() -> polkadot_primitives::v5::SessionIndex { + polkadot_runtime_parachains::runtime_api_impl::v5::session_index_for_child::() } - fn validation_code(para_id: polkadot_primitives::v4::Id, assumption: polkadot_primitives::v4::OccupiedCoreAssumption) - -> Option { - polkadot_runtime_parachains::runtime_api_impl::v4::validation_code::(para_id, assumption) + fn validation_code(para_id: polkadot_primitives::v5::Id, assumption: polkadot_primitives::v5::OccupiedCoreAssumption) + -> Option { + polkadot_runtime_parachains::runtime_api_impl::v5::validation_code::(para_id, assumption) } - fn candidate_pending_availability(para_id: polkadot_primitives::v4::Id) -> Option> { - polkadot_runtime_parachains::runtime_api_impl::v4::candidate_pending_availability::(para_id) + fn candidate_pending_availability(para_id: polkadot_primitives::v5::Id) -> Option> { + polkadot_runtime_parachains::runtime_api_impl::v5::candidate_pending_availability::(para_id) } - fn candidate_events() -> Vec> { - polkadot_runtime_parachains::runtime_api_impl::v4::candidate_events::(|ev| { + fn candidate_events() -> Vec> { + polkadot_runtime_parachains::runtime_api_impl::v5::candidate_events::(|ev| { match ev { RuntimeEvent::Inclusion(ev) => { Some(ev) @@ -822,54 +820,75 @@ impl_runtime_apis! { }) } - fn session_info(index: polkadot_primitives::v4::SessionIndex) -> Option { - polkadot_runtime_parachains::runtime_api_impl::v4::session_info::(index) + fn session_info(index: polkadot_primitives::v5::SessionIndex) -> Option { + polkadot_runtime_parachains::runtime_api_impl::v5::session_info::(index) } - fn dmq_contents(recipient: polkadot_primitives::v4::Id) -> Vec> { - polkadot_runtime_parachains::runtime_api_impl::v4::dmq_contents::(recipient) + fn dmq_contents(recipient: polkadot_primitives::v5::Id) -> Vec> { + polkadot_runtime_parachains::runtime_api_impl::v5::dmq_contents::(recipient) } fn inbound_hrmp_channels_contents( - recipient: polkadot_primitives::v4::Id - ) -> BTreeMap>> { - polkadot_runtime_parachains::runtime_api_impl::v4::inbound_hrmp_channels_contents::(recipient) + recipient: polkadot_primitives::v5::Id + ) -> BTreeMap>> { + polkadot_runtime_parachains::runtime_api_impl::v5::inbound_hrmp_channels_contents::(recipient) } - fn validation_code_by_hash(hash: polkadot_primitives::v4::ValidationCodeHash) -> Option { - polkadot_runtime_parachains::runtime_api_impl::v4::validation_code_by_hash::(hash) + fn validation_code_by_hash(hash: polkadot_primitives::v5::ValidationCodeHash) -> Option { + polkadot_runtime_parachains::runtime_api_impl::v5::validation_code_by_hash::(hash) } - fn on_chain_votes() -> Option> { - polkadot_runtime_parachains::runtime_api_impl::v4::on_chain_votes::() + fn on_chain_votes() -> Option> { + polkadot_runtime_parachains::runtime_api_impl::v5::on_chain_votes::() } - fn submit_pvf_check_statement(stmt: polkadot_primitives::v4::PvfCheckStatement, signature: polkadot_primitives::v4::ValidatorSignature) { - polkadot_runtime_parachains::runtime_api_impl::v4::submit_pvf_check_statement::(stmt, signature) + fn submit_pvf_check_statement(stmt: polkadot_primitives::v5::PvfCheckStatement, signature: polkadot_primitives::v5::ValidatorSignature) { + polkadot_runtime_parachains::runtime_api_impl::v5::submit_pvf_check_statement::(stmt, signature) } - fn pvfs_require_precheck() -> Vec { - polkadot_runtime_parachains::runtime_api_impl::v4::pvfs_require_precheck::() + fn pvfs_require_precheck() -> Vec { + polkadot_runtime_parachains::runtime_api_impl::v5::pvfs_require_precheck::() } - fn validation_code_hash(para_id: polkadot_primitives::v4::Id, assumption: polkadot_primitives::v4::OccupiedCoreAssumption) - -> Option + fn validation_code_hash(para_id: polkadot_primitives::v5::Id, assumption: polkadot_primitives::v5::OccupiedCoreAssumption) + -> Option { - polkadot_runtime_parachains::runtime_api_impl::v4::validation_code_hash::(para_id, assumption) + polkadot_runtime_parachains::runtime_api_impl::v5::validation_code_hash::(para_id, assumption) + } + + fn disputes() -> Vec<(polkadot_primitives::v5::SessionIndex, polkadot_primitives::v5::CandidateHash, polkadot_primitives::v5::DisputeState)> { + polkadot_runtime_parachains::runtime_api_impl::v5::get_session_disputes::() + } + + fn session_executor_params(session_index: polkadot_primitives::v5::SessionIndex) -> Option { + polkadot_runtime_parachains::runtime_api_impl::v5::session_executor_params::(session_index) } - fn disputes() -> Vec<(polkadot_primitives::v4::SessionIndex, polkadot_primitives::v4::CandidateHash, polkadot_primitives::v4::DisputeState)> { - polkadot_runtime_parachains::runtime_api_impl::v4::get_session_disputes::() + fn unapplied_slashes( + ) -> Vec<(polkadot_primitives::v5::SessionIndex, polkadot_primitives::v5::CandidateHash, polkadot_primitives::v5::slashing::PendingSlashes)> { + polkadot_runtime_parachains::runtime_api_impl::v5::unapplied_slashes::() } - fn session_executor_params(session_index: polkadot_primitives::v4::SessionIndex) -> Option { - polkadot_runtime_parachains::runtime_api_impl::v4::session_executor_params::(session_index) + fn key_ownership_proof( + _validator_id: polkadot_primitives::v5::ValidatorId, + ) -> Option { + unimplemented!("Not used at Rialto") + } + + fn submit_report_dispute_lost( + dispute_proof: polkadot_primitives::v5::slashing::DisputeProof, + key_ownership_proof: polkadot_primitives::v5::slashing::OpaqueKeyOwnershipProof, + ) -> Option<()> { + polkadot_runtime_parachains::runtime_api_impl::v5::submit_unsigned_slashing_report::( + dispute_proof, + key_ownership_proof, + ) } } impl sp_authority_discovery::AuthorityDiscoveryApi for Runtime { fn authorities() -> Vec { - polkadot_runtime_parachains::runtime_api_impl::v4::relevant_authority_ids::() + polkadot_runtime_parachains::runtime_api_impl::v5::relevant_authority_ids::() } } diff --git a/bridges/bin/rialto/runtime/src/parachains.rs b/bridges/bin/rialto/runtime/src/parachains.rs index 587cb4d93404c..63d7dc6d1456a 100644 --- a/bridges/bin/rialto/runtime/src/parachains.rs +++ b/bridges/bin/rialto/runtime/src/parachains.rs @@ -27,7 +27,7 @@ use frame_support::{ weights::{Weight, WeightMeter}, }; use frame_system::EnsureRoot; -use polkadot_primitives::v4::{ValidatorId, ValidatorIndex}; +use polkadot_primitives::v5::{ValidatorId, ValidatorIndex}; use polkadot_runtime_common::{paras_registrar, paras_sudo_wrapper, slots}; use polkadot_runtime_parachains::{ configuration as parachains_configuration, disputes as parachains_disputes, @@ -68,6 +68,7 @@ impl parachains_dmp::Config for Runtime {} impl parachains_hrmp::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeOrigin = RuntimeOrigin; + type ChannelManager = EnsureRoot; type Currency = Balances; type WeightInfo = parachains_hrmp::TestWeightInfo; } @@ -225,6 +226,7 @@ impl pallet_message_queue::Config for Runtime { pallet_message_queue::mock_helpers::NoopMessageProcessor; type QueueChangeHandler = crate::Inclusion; type WeightInfo = (); + type QueuePausedQuery = (); } // required onboarding pallets. We're not going to use auctions or crowdloans, so they're missing diff --git a/bridges/bin/rialto/runtime/src/xcm_config.rs b/bridges/bin/rialto/runtime/src/xcm_config.rs index cee246ad67ad1..caac064f81534 100644 --- a/bridges/bin/rialto/runtime/src/xcm_config.rs +++ b/bridges/bin/rialto/runtime/src/xcm_config.rs @@ -106,6 +106,7 @@ pub type Barrier = ( pub type OnRialtoBlobDispatcher = xcm_builder::BridgeBlobDispatcher< crate::xcm_config::XcmRouter, crate::xcm_config::UniversalLocation, + (), >; /// Incoming XCM weigher type. @@ -137,6 +138,7 @@ impl xcm_executor::Config for XcmConfig { type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; + type Aliasers = Nothing; } /// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior @@ -202,11 +204,12 @@ mod tests { use bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatchResult; use codec::Encode; use pallet_bridge_messages::OutboundLanes; + use sp_runtime::BuildStorage; use xcm_executor::XcmExecutor; fn new_test_ext() -> sp_io::TestExternalities { sp_io::TestExternalities::new( - frame_system::GenesisConfig::default().build_storage::().unwrap(), + frame_system::GenesisConfig::::default().build_storage().unwrap(), ) } diff --git a/bridges/bin/runtime-common/src/integrity.rs b/bridges/bin/runtime-common/src/integrity.rs index aa698b0b95e9d..a0af3b981f307 100644 --- a/bridges/bin/runtime-common/src/integrity.rs +++ b/bridges/bin/runtime-common/src/integrity.rs @@ -30,7 +30,7 @@ use pallet_bridge_messages::WeightInfoExt as _; use sp_runtime::traits::SignedExtension; /// Macro that ensures that the runtime configuration and chain primitives crate are sharing -/// the same types (index, block number, hash, hasher, account id and header). +/// the same types (nonce, block number, hash, hasher, account id and header). #[macro_export] macro_rules! assert_chain_types( ( runtime: $r:path, this_chain: $this:path ) => { @@ -38,15 +38,15 @@ macro_rules! assert_chain_types( // if one of asserts fail, then either bridge isn't configured properly (or alternatively - non-standard // configuration is used), or something has broke existing configuration (meaning that all bridged chains // and relays will stop functioning) - use frame_system::Config as SystemConfig; + use frame_system::{Config as SystemConfig, pallet_prelude::{BlockNumberFor, HeaderFor}}; use static_assertions::assert_type_eq_all; - assert_type_eq_all!(<$r as SystemConfig>::Index, bp_runtime::IndexOf<$this>); - assert_type_eq_all!(<$r as SystemConfig>::BlockNumber, bp_runtime::BlockNumberOf<$this>); + assert_type_eq_all!(<$r as SystemConfig>::Nonce, bp_runtime::NonceOf<$this>); + assert_type_eq_all!(BlockNumberFor<$r>, bp_runtime::BlockNumberOf<$this>); assert_type_eq_all!(<$r as SystemConfig>::Hash, bp_runtime::HashOf<$this>); assert_type_eq_all!(<$r as SystemConfig>::Hashing, bp_runtime::HasherOf<$this>); assert_type_eq_all!(<$r as SystemConfig>::AccountId, bp_runtime::AccountIdOf<$this>); - assert_type_eq_all!(<$r as SystemConfig>::Header, bp_runtime::HeaderOf<$this>); + assert_type_eq_all!(HeaderFor<$r>, bp_runtime::HeaderOf<$this>); } } ); diff --git a/bridges/bin/runtime-common/src/mock.rs b/bridges/bin/runtime-common/src/mock.rs index 4542ad39b6241..6b5edabc886b8 100644 --- a/bridges/bin/runtime-common/src/mock.rs +++ b/bridges/bin/runtime-common/src/mock.rs @@ -66,9 +66,7 @@ pub type ThisChainCallOrigin = RuntimeOrigin; /// Header of `ThisChain`. pub type ThisChainHeader = sp_runtime::generic::Header; /// Block of `ThisChain`. -pub type ThisChainBlock = frame_system::mocking::MockBlock; -/// Unchecked extrinsic of `ThisChain`. -pub type ThisChainUncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; +pub type ThisChainBlock = frame_system::mocking::MockBlockU32; /// Account identifier at the `BridgedChain`. pub type BridgedChainAccountId = u128; @@ -108,12 +106,9 @@ pub const BRIDGED_CHAIN_MAX_EXTRINSIC_WEIGHT: usize = 2048; pub const BRIDGED_CHAIN_MAX_EXTRINSIC_SIZE: u32 = 1024; frame_support::construct_runtime! { - pub enum TestRuntime where - Block = ThisChainBlock, - NodeBlock = ThisChainBlock, - UncheckedExtrinsic = ThisChainUncheckedExtrinsic, + pub enum TestRuntime { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Utility: pallet_utility, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event}, @@ -148,14 +143,13 @@ parameter_types! { impl frame_system::Config for TestRuntime { type RuntimeOrigin = RuntimeOrigin; - type Index = u64; + type Nonce = u64; type RuntimeCall = RuntimeCall; - type BlockNumber = ThisChainBlockNumber; type Hash = ThisChainHash; type Hashing = ThisChainHasher; type AccountId = ThisChainAccountId; type Lookup = IdentityLookup; - type Header = ThisChainHeader; + type Block = ThisChainBlock; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU32<250>; type Version = (); @@ -324,7 +318,7 @@ impl Chain for ThisUnderlyingChain { type Header = ThisChainHeader; type AccountId = ThisChainAccountId; type Balance = ThisChainBalance; - type Index = u32; + type Nonce = u32; type Signature = sp_runtime::MultiSignature; fn max_extrinsic_size() -> u32 { @@ -364,7 +358,7 @@ impl Chain for BridgedUnderlyingChain { type Header = BridgedChainHeader; type AccountId = BridgedChainAccountId; type Balance = BridgedChainBalance; - type Index = u32; + type Nonce = u32; type Signature = sp_runtime::MultiSignature; fn max_extrinsic_size() -> u32 { @@ -390,7 +384,7 @@ impl Chain for BridgedUnderlyingParachain { type Header = BridgedChainHeader; type AccountId = BridgedChainAccountId; type Balance = BridgedChainBalance; - type Index = u32; + type Nonce = u32; type Signature = sp_runtime::MultiSignature; fn max_extrinsic_size() -> u32 { diff --git a/bridges/modules/beefy/src/lib.rs b/bridges/modules/beefy/src/lib.rs index f22d8e488a2b2..4bbe48ca0c6aa 100644 --- a/bridges/modules/beefy/src/lib.rs +++ b/bridges/modules/beefy/src/lib.rs @@ -130,7 +130,7 @@ pub mod pallet { #[pallet::hooks] impl, I: 'static> Hooks> for Pallet { - fn on_initialize(_n: T::BlockNumber) -> frame_support::weights::Weight { + fn on_initialize(_n: BlockNumberFor) -> frame_support::weights::Weight { >::mutate(|count| *count = count.saturating_sub(1)); Weight::from_parts(0, 0) @@ -337,7 +337,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl, I: 'static> GenesisBuild for GenesisConfig { + impl, I: 'static> BuildGenesisConfig for GenesisConfig { fn build(&self) { if let Some(ref owner) = self.owner { >::put(owner); diff --git a/bridges/modules/beefy/src/mock.rs b/bridges/modules/beefy/src/mock.rs index 1ffccc5dfbc5c..3eeabab4be29f 100644 --- a/bridges/modules/beefy/src/mock.rs +++ b/bridges/modules/beefy/src/mock.rs @@ -57,16 +57,12 @@ pub type TestBridgedRawMmrLeaf = sp_consensus_beefy::mmr::MmrLeaf< >; pub type TestBridgedMmrNode = MmrDataOrHash; -type TestBlock = frame_system::mocking::MockBlock; -type TestUncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; +type Block = frame_system::mocking::MockBlock; construct_runtime! { - pub enum TestRuntime where - Block = TestBlock, - NodeBlock = TestBlock, - UncheckedExtrinsic = TestUncheckedExtrinsic, + pub enum TestRuntime { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Beefy: beefy::{Pallet}, } } @@ -79,14 +75,13 @@ parameter_types! { impl frame_system::Config for TestRuntime { type RuntimeOrigin = RuntimeOrigin; - type Index = u64; + type Nonce = u64; type RuntimeCall = RuntimeCall; - type BlockNumber = u64; + type Block = Block; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = TestAccountId; type Lookup = IdentityLookup; - type Header = Header; type RuntimeEvent = (); type BlockHashCount = ConstU64<250>; type Version = (); @@ -117,11 +112,11 @@ impl Chain for TestBridgedChain { type BlockNumber = TestBridgedBlockNumber; type Hash = H256; type Hasher = BlakeTwo256; - type Header = ::Header; + type Header = sp_runtime::testing::Header; type AccountId = TestAccountId; type Balance = u64; - type Index = u64; + type Nonce = u64; type Signature = Signature; fn max_extrinsic_size() -> u32 { diff --git a/bridges/modules/grandpa/src/call_ext.rs b/bridges/modules/grandpa/src/call_ext.rs index b57aebb1ac1e7..c83e88b7b5621 100644 --- a/bridges/modules/grandpa/src/call_ext.rs +++ b/bridges/modules/grandpa/src/call_ext.rs @@ -179,7 +179,9 @@ pub(crate) fn submit_finality_proof_info_from_args, I: 'static>( /// Returns maximal expected size of `submit_finality_proof` call arguments. fn max_expected_call_size, I: 'static>(required_precommits: u32) -> u32 { let max_expected_justification_size = - GrandpaJustification::max_reasonable_size::(required_precommits); + GrandpaJustification::>::max_reasonable_size::( + required_precommits, + ); // call arguments are header and justification T::BridgedChain::MAX_HEADER_SIZE.saturating_add(max_expected_justification_size) diff --git a/bridges/modules/grandpa/src/lib.rs b/bridges/modules/grandpa/src/lib.rs index b789aedef2c8f..eb49849ac881f 100644 --- a/bridges/modules/grandpa/src/lib.rs +++ b/bridges/modules/grandpa/src/lib.rs @@ -379,7 +379,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl, I: 'static> GenesisBuild for GenesisConfig { + impl, I: 'static> BuildGenesisConfig for GenesisConfig { fn build(&self) { if let Some(ref owner) = self.owner { >::put(owner); diff --git a/bridges/modules/grandpa/src/mock.rs b/bridges/modules/grandpa/src/mock.rs index 0ebbc0bccbb7b..bd305dfef9dc0 100644 --- a/bridges/modules/grandpa/src/mock.rs +++ b/bridges/modules/grandpa/src/mock.rs @@ -26,29 +26,25 @@ use frame_support::{ }; use sp_core::sr25519::Signature; use sp_runtime::{ - testing::{Header, H256}, + testing::H256, traits::{BlakeTwo256, IdentityLookup}, Perbill, }; pub type AccountId = u64; -pub type TestHeader = crate::BridgedHeader; -pub type TestNumber = crate::BridgedBlockNumber; +pub type TestHeader = sp_runtime::testing::Header; +pub type TestNumber = u64; type Block = frame_system::mocking::MockBlock; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; pub const MAX_BRIDGED_AUTHORITIES: u32 = 5; use crate as grandpa; construct_runtime! { - pub enum TestRuntime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum TestRuntime { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Grandpa: grandpa::{Pallet, Call, Event}, } } @@ -61,14 +57,13 @@ parameter_types! { impl frame_system::Config for TestRuntime { type RuntimeOrigin = RuntimeOrigin; - type Index = u64; + type Nonce = u64; type RuntimeCall = RuntimeCall; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); @@ -105,14 +100,14 @@ impl grandpa::Config for TestRuntime { pub struct TestBridgedChain; impl Chain for TestBridgedChain { - type BlockNumber = ::BlockNumber; + type BlockNumber = TestNumber; type Hash = ::Hash; type Hasher = ::Hashing; - type Header = ::Header; + type Header = TestHeader; type AccountId = AccountId; type Balance = u64; - type Index = u64; + type Nonce = u64; type Signature = Signature; fn max_extrinsic_size() -> u32 { diff --git a/bridges/modules/messages/src/lib.rs b/bridges/modules/messages/src/lib.rs index 51e6857d7778c..3bfd5bc7e98f7 100644 --- a/bridges/modules/messages/src/lib.rs +++ b/bridges/modules/messages/src/lib.rs @@ -188,9 +188,9 @@ pub mod pallet { #[pallet::hooks] impl, I: 'static> Hooks> for Pallet where - u32: TryFrom<::BlockNumber>, + u32: TryFrom>, { - fn on_idle(_block: T::BlockNumber, remaining_weight: Weight) -> Weight { + fn on_idle(_block: BlockNumberFor, remaining_weight: Weight) -> Weight { // we'll need at least to read outbound lane state, kill a message and update lane state let db_weight = T::DbWeight::get(); if !remaining_weight.all_gte(db_weight.reads_writes(1, 2)) { @@ -597,7 +597,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl, I: 'static> GenesisBuild for GenesisConfig { + impl, I: 'static> BuildGenesisConfig for GenesisConfig { fn build(&self) { PalletOperatingMode::::put(self.operating_mode); if let Some(ref owner) = self.owner { diff --git a/bridges/modules/messages/src/mock.rs b/bridges/modules/messages/src/mock.rs index 8716c5bc3ac7f..62bc76c5e010b 100644 --- a/bridges/modules/messages/src/mock.rs +++ b/bridges/modules/messages/src/mock.rs @@ -39,9 +39,8 @@ use frame_support::{ use scale_info::TypeInfo; use sp_core::H256; use sp_runtime::{ - testing::Header as SubstrateHeader, traits::{BlakeTwo256, ConstU32, IdentityLookup}, - Perbill, + BuildStorage, Perbill, }; use std::{ collections::{BTreeMap, VecDeque}, @@ -71,17 +70,13 @@ pub type TestRelayer = u64; pub type TestDispatchLevelResult = (); type Block = frame_system::mocking::MockBlock; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; use crate as pallet_bridge_messages; frame_support::construct_runtime! { - pub enum TestRuntime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum TestRuntime { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Event}, Messages: pallet_bridge_messages::{Pallet, Call, Event}, } @@ -98,14 +93,13 @@ pub type DbWeight = RocksDbWeight; impl frame_system::Config for TestRuntime { type RuntimeOrigin = RuntimeOrigin; - type Index = u64; + type Nonce = u64; type RuntimeCall = RuntimeCall; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = SubstrateHeader; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); @@ -487,7 +481,7 @@ pub fn inbound_unrewarded_relayers_state(lane: bp_messages::LaneId) -> Unrewarde /// Return test externalities to use in tests. pub fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(ENDOWED_ACCOUNT, 1_000_000)] } .assimilate_storage(&mut t) .unwrap(); diff --git a/bridges/modules/parachains/src/lib.rs b/bridges/modules/parachains/src/lib.rs index 52b436b820712..4f78a45d4b77b 100644 --- a/bridges/modules/parachains/src/lib.rs +++ b/bridges/modules/parachains/src/lib.rs @@ -623,7 +623,7 @@ pub mod pallet { } #[pallet::genesis_build] - impl, I: 'static> GenesisBuild for GenesisConfig { + impl, I: 'static> BuildGenesisConfig for GenesisConfig { fn build(&self) { PalletOperatingMode::::put(self.operating_mode); if let Some(ref owner) = self.owner { diff --git a/bridges/modules/parachains/src/mock.rs b/bridges/modules/parachains/src/mock.rs index 0a61d91d7b2db..a7030f0ae0310 100644 --- a/bridges/modules/parachains/src/mock.rs +++ b/bridges/modules/parachains/src/mock.rs @@ -19,7 +19,7 @@ use bp_polkadot_core::parachains::ParaId; use bp_runtime::{Chain, Parachain}; use frame_support::{construct_runtime, parameter_types, traits::ConstU32, weights::Weight}; use sp_runtime::{ - testing::{Header, H256}, + testing::H256, traits::{BlakeTwo256, Header as HeaderT, IdentityLookup}, MultiSignature, Perbill, }; @@ -33,7 +33,6 @@ pub type RelayBlockHeader = sp_runtime::generic::Header; type Block = frame_system::mocking::MockBlock; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; pub const PARAS_PALLET_NAME: &str = "Paras"; pub const UNTRACKED_PARACHAIN_ID: u32 = 10; @@ -55,7 +54,7 @@ impl Chain for Parachain1 { type Header = RegularParachainHeader; type AccountId = u64; type Balance = u64; - type Index = u64; + type Nonce = u64; type Signature = MultiSignature; fn max_extrinsic_size() -> u32 { @@ -79,7 +78,7 @@ impl Chain for Parachain2 { type Header = RegularParachainHeader; type AccountId = u64; type Balance = u64; - type Index = u64; + type Nonce = u64; type Signature = MultiSignature; fn max_extrinsic_size() -> u32 { @@ -103,7 +102,7 @@ impl Chain for Parachain3 { type Header = RegularParachainHeader; type AccountId = u64; type Balance = u64; - type Index = u64; + type Nonce = u64; type Signature = MultiSignature; fn max_extrinsic_size() -> u32 { @@ -128,7 +127,7 @@ impl Chain for BigParachain { type Header = BigParachainHeader; type AccountId = u64; type Balance = u64; - type Index = u64; + type Nonce = u64; type Signature = MultiSignature; fn max_extrinsic_size() -> u32 { @@ -144,12 +143,9 @@ impl Parachain for BigParachain { } construct_runtime! { - pub enum TestRuntime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum TestRuntime { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Grandpa1: pallet_bridge_grandpa::::{Pallet, Event}, Grandpa2: pallet_bridge_grandpa::::{Pallet, Event}, Parachains: pallet_bridge_parachains::{Call, Pallet, Event}, @@ -165,14 +161,13 @@ parameter_types! { impl frame_system::Config for TestRuntime { type RuntimeOrigin = RuntimeOrigin; - type Index = u64; + type Nonce = u64; type RuntimeCall = RuntimeCall; - type BlockNumber = TestNumber; + type Block = Block; type Hash = H256; type Hashing = RegularParachainHasher; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); @@ -270,7 +265,7 @@ impl Chain for TestBridgedChain { type AccountId = AccountId; type Balance = u32; - type Index = u32; + type Nonce = u32; type Signature = sp_runtime::testing::TestSignature; fn max_extrinsic_size() -> u32 { @@ -301,7 +296,7 @@ impl Chain for OtherBridgedChain { type AccountId = AccountId; type Balance = u32; - type Index = u32; + type Nonce = u32; type Signature = sp_runtime::testing::TestSignature; fn max_extrinsic_size() -> u32 { diff --git a/bridges/modules/relayers/src/lib.rs b/bridges/modules/relayers/src/lib.rs index 54b888cf29dc9..a71c218443b3d 100644 --- a/bridges/modules/relayers/src/lib.rs +++ b/bridges/modules/relayers/src/lib.rs @@ -66,7 +66,7 @@ pub mod pallet { /// Pay rewards scheme. type PaymentProcedure: PaymentProcedure; /// Stake and slash scheme. - type StakeAndSlash: StakeAndSlash; + type StakeAndSlash: StakeAndSlash, Self::Reward>; /// Pallet call weights. type WeightInfo: WeightInfoExt; } @@ -117,7 +117,7 @@ pub mod pallet { /// Registration allows relayer to get priority boost for its message delivery transactions. #[pallet::call_index(1)] #[pallet::weight(T::WeightInfo::register())] - pub fn register(origin: OriginFor, valid_till: T::BlockNumber) -> DispatchResult { + pub fn register(origin: OriginFor, valid_till: BlockNumberFor) -> DispatchResult { let relayer = ensure_signed(origin)?; // valid till must be larger than the current block number and the lease must be larger @@ -330,10 +330,10 @@ pub mod pallet { } /// Return required registration lease. - pub(crate) fn required_registration_lease() -> T::BlockNumber { + pub(crate) fn required_registration_lease() -> BlockNumberFor { , T::Reward, >>::RequiredRegistrationLease::get() } @@ -342,7 +342,7 @@ pub mod pallet { pub(crate) fn required_stake() -> T::Reward { , T::Reward, >>::RequiredStake::get() } @@ -383,7 +383,7 @@ pub mod pallet { /// Relayer account that has been registered. relayer: T::AccountId, /// Relayer registration. - registration: Registration, + registration: Registration, T::Reward>, }, /// Relayer has been `deregistered`. Deregistered { @@ -395,7 +395,7 @@ pub mod pallet { /// Relayer account that has been `deregistered`. relayer: T::AccountId, /// Registration that was removed. - registration: Registration, + registration: Registration, T::Reward>, }, } @@ -445,7 +445,7 @@ pub mod pallet { _, Blake2_128Concat, T::AccountId, - Registration, + Registration, T::Reward>, OptionQuery, >; } diff --git a/bridges/modules/relayers/src/mock.rs b/bridges/modules/relayers/src/mock.rs index d8c5bd9096720..b3fcb24cdd20d 100644 --- a/bridges/modules/relayers/src/mock.rs +++ b/bridges/modules/relayers/src/mock.rs @@ -25,8 +25,8 @@ use bp_relayers::{ use frame_support::{parameter_types, traits::fungible::Mutate, weights::RuntimeDbWeight}; use sp_core::H256; use sp_runtime::{ - testing::Header as SubstrateHeader, traits::{BlakeTwo256, ConstU32, IdentityLookup}, + BuildStorage, }; pub type AccountId = u64; @@ -43,15 +43,11 @@ pub type TestStakeAndSlash = pallet_bridge_relayers::StakeAndSlashNamed< >; type Block = frame_system::mocking::MockBlock; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; frame_support::construct_runtime! { - pub enum TestRuntime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum TestRuntime { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Event}, Relayers: pallet_bridge_relayers::{Pallet, Call, Event}, } @@ -67,14 +63,13 @@ parameter_types! { impl frame_system::Config for TestRuntime { type RuntimeOrigin = RuntimeOrigin; - type Index = u64; + type Nonce = u64; type RuntimeCall = RuntimeCall; - type BlockNumber = BlockNumber; + type Block = Block; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = SubstrateHeader; type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU64<250>; type Version = (); @@ -170,7 +165,7 @@ impl PaymentProcedure for TestPaymentProcedure { /// Return test externalities to use in tests. pub fn new_test_ext() -> sp_io::TestExternalities { - let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::::default().build_storage().unwrap(); sp_io::TestExternalities::new(t) } diff --git a/bridges/modules/shift-session-manager/src/lib.rs b/bridges/modules/shift-session-manager/src/lib.rs index 1c38a52b0c21e..17bbb0a479f18 100644 --- a/bridges/modules/shift-session-manager/src/lib.rs +++ b/bridges/modules/shift-session-manager/src/lib.rs @@ -124,11 +124,10 @@ mod tests { parameter_types, sp_io::TestExternalities, sp_runtime::{ - testing::{Header, UintAuthorityId}, + testing::UintAuthorityId, traits::{BlakeTwo256, ConvertInto, IdentityLookup}, - Perbill, RuntimeAppPublic, + BuildStorage, Perbill, RuntimeAppPublic, }, - traits::GenesisBuild, weights::Weight, BasicExternalities, }; @@ -137,15 +136,10 @@ mod tests { type AccountId = u64; type Block = frame_system::mocking::MockBlock; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; frame_support::construct_runtime! { - pub enum TestRuntime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { - System: frame_system::{Pallet, Call, Config, Storage, Event}, + pub enum TestRuntime { + System: frame_system::{Pallet, Call, Config, Storage, Event}, Session: pallet_session::{Pallet}, } } @@ -158,14 +152,13 @@ mod tests { impl frame_system::Config for TestRuntime { type RuntimeOrigin = RuntimeOrigin; - type Index = u64; + type Nonce = u64; type RuntimeCall = RuntimeCall; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = (); type BlockHashCount = frame_support::traits::ConstU64<250>; type Version = (); @@ -220,7 +213,7 @@ mod tests { } fn new_test_ext() -> TestExternalities { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let keys = vec![ (1, 1, UintAuthorityId(1)), diff --git a/bridges/primitives/beefy/Cargo.toml b/bridges/primitives/beefy/Cargo.toml index 7ddaa6e1eb246..70e0f0f2f4817 100644 --- a/bridges/primitives/beefy/Cargo.toml +++ b/bridges/primitives/beefy/Cargo.toml @@ -9,7 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "bit-vec"] } scale-info = { version = "2.9.0", default-features = false, features = ["bit-vec", "derive"] } -serde = { version = "1.0", optional = true } +serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] } # Bridge Dependencies @@ -34,7 +34,7 @@ std = [ "pallet-beefy-mmr/std", "pallet-mmr/std", "scale-info/std", - "serde", + "serde/std", "sp-consensus-beefy/std", "sp-runtime/std", "sp-std/std" diff --git a/bridges/primitives/beefy/src/lib.rs b/bridges/primitives/beefy/src/lib.rs index de260d45eca68..1daf5a3620796 100644 --- a/bridges/primitives/beefy/src/lib.rs +++ b/bridges/primitives/beefy/src/lib.rs @@ -37,6 +37,7 @@ use bp_runtime::{BasicOperatingMode, BlockNumberOf, Chain, HashOf}; use codec::{Decode, Encode}; use frame_support::Parameter; use scale_info::TypeInfo; +use serde::{Deserialize, Serialize}; use sp_runtime::{ traits::{Convert, MaybeSerializeDeserialize}, RuntimeAppPublic, RuntimeDebug, @@ -127,8 +128,7 @@ pub type BeefyMmrLeafOf = sp_consensus_beefy::mmr::MmrLeaf< /// /// Provides the initial context that the bridge needs in order to know /// where to start the sync process from. -#[derive(Encode, Decode, RuntimeDebug, PartialEq, Clone, TypeInfo)] -#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +#[derive(Encode, Decode, RuntimeDebug, PartialEq, Clone, TypeInfo, Serialize, Deserialize)] pub struct InitializationData { /// Pallet operating mode. pub operating_mode: BasicOperatingMode, diff --git a/bridges/primitives/chain-bridge-hub-cumulus/src/lib.rs b/bridges/primitives/chain-bridge-hub-cumulus/src/lib.rs index b174cd700ed45..525b2e62ceab0 100644 --- a/bridges/primitives/chain-bridge-hub-cumulus/src/lib.rs +++ b/bridges/primitives/chain-bridge-hub-cumulus/src/lib.rs @@ -18,7 +18,7 @@ pub use bp_polkadot_core::{ AccountId, AccountInfoStorageMapKeyProvider, AccountPublic, Balance, BlockNumber, Hash, Hasher, - Hashing, Header, Index, Nonce, Perbill, Signature, SignedBlock, UncheckedExtrinsic, + Hashing, Header, Nonce, Perbill, Signature, SignedBlock, UncheckedExtrinsic, EXTRA_STORAGE_PROOF_SIZE, TX_EXTRA_BYTES, }; @@ -53,7 +53,7 @@ pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); /// This is a copy-paste from the cumulus repo's `parachains-common` crate. const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(constants::WEIGHT_REF_TIME_PER_SECOND, 0) .saturating_div(2) - .set_proof_size(polkadot_primitives::v4::MAX_POV_SIZE as u64); + .set_proof_size(polkadot_primitives::v5::MAX_POV_SIZE as u64); /// All cumulus bridge hubs assume that about 5 percent of the block weight is consumed by /// `on_initialize` handlers. This is used to limit the maximal weight of a single extrinsic. @@ -140,7 +140,7 @@ pub type SignedExtra = ( CheckTxVersion, CheckGenesis, CheckEra, - CheckNonce, + CheckNonce, CheckWeight, ChargeTransactionPayment, BridgeRejectObsoleteHeadersAndMessages, @@ -159,12 +159,12 @@ pub trait BridgeHubSignedExtension { transaction_version: u32, era: bp_runtime::TransactionEra, genesis_hash: Hash, - nonce: Index, + nonce: Nonce, tip: Balance, ) -> Self; /// Return transaction nonce. - fn nonce(&self) -> Index; + fn nonce(&self) -> Nonce; /// Return transaction tip. fn tip(&self) -> Balance; @@ -177,7 +177,7 @@ impl BridgeHubSignedExtension for SignedExtension { transaction_version: u32, era: bp_runtime::TransactionEra, genesis_hash: Hash, - nonce: Index, + nonce: Nonce, tip: Balance, ) -> Self { GenericSignedExtension::new( @@ -209,7 +209,7 @@ impl BridgeHubSignedExtension for SignedExtension { } /// Return transaction nonce. - fn nonce(&self) -> Index { + fn nonce(&self) -> Nonce { self.payload.5 .0 } diff --git a/bridges/primitives/chain-bridge-hub-kusama/src/lib.rs b/bridges/primitives/chain-bridge-hub-kusama/src/lib.rs index 00b6c8301e4c2..7405f561fb2ea 100644 --- a/bridges/primitives/chain-bridge-hub-kusama/src/lib.rs +++ b/bridges/primitives/chain-bridge-hub-kusama/src/lib.rs @@ -43,7 +43,7 @@ impl Chain for BridgeHubKusama { type AccountId = AccountId; type Balance = Balance; - type Index = Index; + type Nonce = Nonce; type Signature = Signature; fn max_extrinsic_size() -> u32 { diff --git a/bridges/primitives/chain-bridge-hub-polkadot/src/lib.rs b/bridges/primitives/chain-bridge-hub-polkadot/src/lib.rs index 8bd9167b618b1..e1fc0d7bc47d9 100644 --- a/bridges/primitives/chain-bridge-hub-polkadot/src/lib.rs +++ b/bridges/primitives/chain-bridge-hub-polkadot/src/lib.rs @@ -39,7 +39,7 @@ impl Chain for BridgeHubPolkadot { type AccountId = AccountId; type Balance = Balance; - type Index = Index; + type Nonce = Nonce; type Signature = Signature; fn max_extrinsic_size() -> u32 { diff --git a/bridges/primitives/chain-bridge-hub-rococo/src/lib.rs b/bridges/primitives/chain-bridge-hub-rococo/src/lib.rs index 936e4d1beb7f8..50206c8e6b383 100644 --- a/bridges/primitives/chain-bridge-hub-rococo/src/lib.rs +++ b/bridges/primitives/chain-bridge-hub-rococo/src/lib.rs @@ -43,7 +43,7 @@ impl Chain for BridgeHubRococo { type AccountId = AccountId; type Balance = Balance; - type Index = Index; + type Nonce = Nonce; type Signature = Signature; fn max_extrinsic_size() -> u32 { diff --git a/bridges/primitives/chain-bridge-hub-wococo/src/lib.rs b/bridges/primitives/chain-bridge-hub-wococo/src/lib.rs index 00704995c5ebf..7d14460c73709 100644 --- a/bridges/primitives/chain-bridge-hub-wococo/src/lib.rs +++ b/bridges/primitives/chain-bridge-hub-wococo/src/lib.rs @@ -39,7 +39,7 @@ impl Chain for BridgeHubWococo { type AccountId = AccountId; type Balance = Balance; - type Index = Index; + type Nonce = Nonce; type Signature = Signature; fn max_extrinsic_size() -> u32 { diff --git a/bridges/primitives/chain-kusama/src/lib.rs b/bridges/primitives/chain-kusama/src/lib.rs index 5cef6ae0ee64b..229905a3d4ac5 100644 --- a/bridges/primitives/chain-kusama/src/lib.rs +++ b/bridges/primitives/chain-kusama/src/lib.rs @@ -35,7 +35,7 @@ impl Chain for Kusama { type AccountId = ::AccountId; type Balance = ::Balance; - type Index = ::Index; + type Nonce = ::Nonce; type Signature = ::Signature; fn max_extrinsic_size() -> u32 { diff --git a/bridges/primitives/chain-millau/Cargo.toml b/bridges/primitives/chain-millau/Cargo.toml index d4b59c2aa9e83..d12e76a8d04e6 100644 --- a/bridges/primitives/chain-millau/Cargo.toml +++ b/bridges/primitives/chain-millau/Cargo.toml @@ -11,10 +11,10 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" fixed-hash = { version = "0.8.0", default-features = false } hash256-std-hasher = { version = "0.15.2", default-features = false } impl-codec = { version = "0.6", default-features = false } -impl-serde = { version = "0.4.0", optional = true } +impl-serde = { version = "0.4.0", default-features = false } parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] } scale-info = { version = "2.9.0", default-features = false, features = ["derive"] } -serde = { version = "1.0", optional = true, features = ["derive"] } +serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] } # Bridge Dependencies @@ -46,10 +46,10 @@ std = [ "frame-system/std", "hash256-std-hasher/std", "impl-codec/std", - "impl-serde", + "impl-serde/std", "parity-util-mem/std", "scale-info/std", - "serde", + "serde/std", "sp-api/std", "sp-core/std", "sp-io/std", diff --git a/bridges/primitives/chain-millau/src/lib.rs b/bridges/primitives/chain-millau/src/lib.rs index b7f67ca07e288..a752b5f7114ae 100644 --- a/bridges/primitives/chain-millau/src/lib.rs +++ b/bridges/primitives/chain-millau/src/lib.rs @@ -33,6 +33,7 @@ use frame_support::{ }; use frame_system::limits; use scale_info::TypeInfo; +use serde::{Deserialize, Serialize}; use sp_core::{storage::StateVersion, Hasher as HasherT}; use sp_runtime::{ traits::{IdentifyAccount, Verify}, @@ -41,8 +42,6 @@ use sp_runtime::{ use sp_std::prelude::*; use sp_trie::{LayoutV0, LayoutV1, TrieConfiguration}; -#[cfg(feature = "std")] -use serde::{Deserialize, Serialize}; use sp_runtime::traits::Keccak256; pub use millau_hash::MillauHash; @@ -145,8 +144,8 @@ pub type AccountSigner = MultiSigner; /// Balance of an account. pub type Balance = u64; -/// Index of a transaction in the chain. -pub type Index = u32; +/// Nonce of a transaction in the chain. +pub type Nonce = u32; /// Weight-to-Fee type used by Millau. pub type WeightToFee = IdentityFee; @@ -163,7 +162,7 @@ impl Chain for Millau { type AccountId = AccountId; type Balance = Balance; - type Index = Index; + type Nonce = Nonce; type Signature = Signature; fn max_extrinsic_size() -> u32 { @@ -197,8 +196,7 @@ impl ChainWithBeefy for Millau { } /// Millau Hasher (Blake2-256 ++ Keccak-256) implementation. -#[derive(PartialEq, Eq, Clone, Copy, RuntimeDebug, TypeInfo)] -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] +#[derive(PartialEq, Eq, Clone, Copy, RuntimeDebug, TypeInfo, Serialize, Deserialize)] pub struct BlakeTwoAndKeccak256; impl sp_core::Hasher for BlakeTwoAndKeccak256 { diff --git a/bridges/primitives/chain-millau/src/millau_hash.rs b/bridges/primitives/chain-millau/src/millau_hash.rs index 11968b2f28267..8851c319dd451 100644 --- a/bridges/primitives/chain-millau/src/millau_hash.rs +++ b/bridges/primitives/chain-millau/src/millau_hash.rs @@ -27,9 +27,7 @@ fixed_hash::construct_fixed_hash! { pub struct MillauHash(64); } -#[cfg(feature = "std")] impl_serde::impl_fixed_hash_serde!(MillauHash, 64); - impl_codec::impl_fixed_hash_codec!(MillauHash, 64); impl CheckEqual for MillauHash { diff --git a/bridges/primitives/chain-polkadot/src/lib.rs b/bridges/primitives/chain-polkadot/src/lib.rs index 51d9f6f0233e3..628634bb46f01 100644 --- a/bridges/primitives/chain-polkadot/src/lib.rs +++ b/bridges/primitives/chain-polkadot/src/lib.rs @@ -35,7 +35,7 @@ impl Chain for Polkadot { type AccountId = ::AccountId; type Balance = ::Balance; - type Index = ::Index; + type Nonce = ::Nonce; type Signature = ::Signature; fn max_extrinsic_size() -> u32 { diff --git a/bridges/primitives/chain-rialto-parachain/src/lib.rs b/bridges/primitives/chain-rialto-parachain/src/lib.rs index 67b1a135f34a9..cc58edba788a6 100644 --- a/bridges/primitives/chain-rialto-parachain/src/lib.rs +++ b/bridges/primitives/chain-rialto-parachain/src/lib.rs @@ -96,8 +96,8 @@ pub type Balance = u128; /// An instant or duration in time. pub type Moment = u64; -/// Index of a transaction in the parachain. -pub type Index = u32; +/// Nonce of a transaction in the parachain. +pub type Nonce = u32; /// Weight-to-Fee type used by Rialto parachain. pub type WeightToFee = IdentityFee; @@ -114,7 +114,7 @@ impl Chain for RialtoParachain { type AccountId = AccountId; type Balance = Balance; - type Index = Index; + type Nonce = Nonce; type Signature = Signature; fn max_extrinsic_size() -> u32 { diff --git a/bridges/primitives/chain-rialto/src/lib.rs b/bridges/primitives/chain-rialto/src/lib.rs index 01349f131be70..d5be78516a21a 100644 --- a/bridges/primitives/chain-rialto/src/lib.rs +++ b/bridges/primitives/chain-rialto/src/lib.rs @@ -149,8 +149,8 @@ pub type Balance = u128; /// An instant or duration in time. pub type Moment = u64; -/// Index of a transaction in the chain. -pub type Index = u32; +/// Nonce of a transaction in the chain. +pub type Nonce = u32; /// Weight-to-Fee type used by Rialto. pub type WeightToFee = IdentityFee; @@ -167,7 +167,7 @@ impl Chain for Rialto { type AccountId = AccountId; type Balance = Balance; - type Index = Index; + type Nonce = Nonce; type Signature = Signature; fn max_extrinsic_size() -> u32 { diff --git a/bridges/primitives/chain-rococo/src/lib.rs b/bridges/primitives/chain-rococo/src/lib.rs index 0cb0b1d41e6dc..a825c8b39787c 100644 --- a/bridges/primitives/chain-rococo/src/lib.rs +++ b/bridges/primitives/chain-rococo/src/lib.rs @@ -35,7 +35,7 @@ impl Chain for Rococo { type AccountId = ::AccountId; type Balance = ::Balance; - type Index = ::Index; + type Nonce = ::Nonce; type Signature = ::Signature; fn max_extrinsic_size() -> u32 { diff --git a/bridges/primitives/chain-westend/src/lib.rs b/bridges/primitives/chain-westend/src/lib.rs index 74e8895aff906..071f3a15a42c3 100644 --- a/bridges/primitives/chain-westend/src/lib.rs +++ b/bridges/primitives/chain-westend/src/lib.rs @@ -35,7 +35,7 @@ impl Chain for Westend { type AccountId = ::AccountId; type Balance = ::Balance; - type Index = ::Index; + type Nonce = ::Nonce; type Signature = ::Signature; fn max_extrinsic_size() -> u32 { @@ -70,7 +70,7 @@ impl Chain for Westmint { type AccountId = AccountId; type Balance = Balance; - type Index = Nonce; + type Nonce = Nonce; type Signature = Signature; fn max_extrinsic_size() -> u32 { diff --git a/bridges/primitives/chain-wococo/src/lib.rs b/bridges/primitives/chain-wococo/src/lib.rs index 2df019496ab14..fb63613427d03 100644 --- a/bridges/primitives/chain-wococo/src/lib.rs +++ b/bridges/primitives/chain-wococo/src/lib.rs @@ -38,7 +38,7 @@ impl Chain for Wococo { type AccountId = ::AccountId; type Balance = ::Balance; - type Index = ::Index; + type Nonce = ::Nonce; type Signature = ::Signature; fn max_extrinsic_size() -> u32 { diff --git a/bridges/primitives/header-chain/src/justification.rs b/bridges/primitives/header-chain/src/justification.rs index b83c697d60875..714546a42ef2d 100644 --- a/bridges/primitives/header-chain/src/justification.rs +++ b/bridges/primitives/header-chain/src/justification.rs @@ -56,7 +56,7 @@ impl GrandpaJustification { /// any precise calculations - that's just an estimation. pub fn max_reasonable_size(required_precommits: u32) -> u32 where - C: Chain
+ ChainWithGrandpa, + C: Chain + ChainWithGrandpa, { // we don't need precise results here - just estimations, so some details // are removed from computations (e.g. bytes required to encode vector length) @@ -144,10 +144,7 @@ pub fn verify_and_optimize_justification( authorities_set_id: SetId, authorities_set: &VoterSet, justification: &mut GrandpaJustification
, -) -> Result<(), Error> -where - Header::Number: finality_grandpa::BlockNumberOps, -{ +) -> Result<(), Error> { let mut optimizer = OptimizationCallbacks { extra_precommits: vec![], redundant_votes_ancestries: Default::default(), @@ -170,10 +167,7 @@ pub fn verify_justification( authorities_set_id: SetId, authorities_set: &VoterSet, justification: &GrandpaJustification
, -) -> Result<(), Error> -where - Header::Number: finality_grandpa::BlockNumberOps, -{ +) -> Result<(), Error> { verify_justification_with_callbacks( finalized_target, authorities_set_id, @@ -295,10 +289,7 @@ fn verify_justification_with_callbacks, justification: &GrandpaJustification
, callbacks: &mut C, -) -> Result<(), Error> -where - Header::Number: finality_grandpa::BlockNumberOps, -{ +) -> Result<(), Error> { // ensure that it is justification for the expected header if (justification.commit.target_hash, justification.commit.target_number) != finalized_target { return Err(Error::InvalidJustificationTarget) diff --git a/bridges/primitives/header-chain/src/lib.rs b/bridges/primitives/header-chain/src/lib.rs index 6b9373cf18798..5268e7d5c5faf 100644 --- a/bridges/primitives/header-chain/src/lib.rs +++ b/bridges/primitives/header-chain/src/lib.rs @@ -27,7 +27,6 @@ use codec::{Codec, Decode, Encode, EncodeLike, MaxEncodedLen}; use core::{clone::Clone, cmp::Eq, default::Default, fmt::Debug}; use frame_support::PalletError; use scale_info::TypeInfo; -#[cfg(feature = "std")] use serde::{Deserialize, Serialize}; use sp_consensus_grandpa::{AuthorityList, ConsensusLog, SetId, GRANDPA_ENGINE_ID}; use sp_runtime::{traits::Header as HeaderT, Digest, RuntimeDebug}; @@ -110,8 +109,9 @@ impl AuthoritySet { /// Data required for initializing the GRANDPA bridge pallet. /// /// The bridge needs to know where to start its sync from, and this provides that initial context. -#[derive(Default, Encode, Decode, RuntimeDebug, PartialEq, Eq, Clone, TypeInfo)] -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] +#[derive( + Default, Encode, Decode, RuntimeDebug, PartialEq, Eq, Clone, TypeInfo, Serialize, Deserialize, +)] pub struct InitializationData { /// The header from which we should start syncing. pub header: Box, diff --git a/bridges/primitives/header-chain/tests/implementation_match.rs b/bridges/primitives/header-chain/tests/implementation_match.rs index 46652dede56ad..d5e42e214976b 100644 --- a/bridges/primitives/header-chain/tests/implementation_match.rs +++ b/bridges/primitives/header-chain/tests/implementation_match.rs @@ -104,8 +104,8 @@ pub fn make_default_justification(header: &TestHeader) -> GrandpaJustification::Out; -/// Account Index (a.k.a. nonce). -pub type Index = u32; - /// Hashing type. pub type Hashing = BlakeTwo256; @@ -205,7 +202,7 @@ pub type AccountId = ::AccountId; /// Address of account on Polkadot-like chains. pub type AccountAddress = MultiAddress; -/// Index of a transaction on the Polkadot-like chains. +/// Nonce of a transaction on the Polkadot-like chains. pub type Nonce = u32; /// Block type of Polkadot-like chains. @@ -236,7 +233,7 @@ impl Chain for PolkadotLike { type AccountId = AccountId; type Balance = Balance; - type Index = Index; + type Nonce = Nonce; type Signature = Signature; fn max_extrinsic_size() -> u32 { diff --git a/bridges/primitives/runtime/src/chain.rs b/bridges/primitives/runtime/src/chain.rs index c79058cea90cf..8c47662a7c13c 100644 --- a/bridges/primitives/runtime/src/chain.rs +++ b/bridges/primitives/runtime/src/chain.rs @@ -170,8 +170,8 @@ pub trait Chain: Send + Sync + 'static { + Zero + TryFrom + MaxEncodedLen; - /// Index of a transaction used by the chain. - type Index: Parameter + /// Nonce of a transaction used by the chain. + type Nonce: Parameter + Member + MaybeSerialize + Debug @@ -206,7 +206,7 @@ where type Header = ::Header; type AccountId = ::AccountId; type Balance = ::Balance; - type Index = ::Index; + type Nonce = ::Nonce; type Signature = ::Signature; fn max_extrinsic_size() -> u32 { @@ -261,8 +261,8 @@ pub type AccountIdOf = ::AccountId; /// Balance type used by the chain. pub type BalanceOf = ::Balance; -/// Transaction index type used by the chain. -pub type IndexOf = ::Index; +/// Transaction nonce type used by the chain. +pub type NonceOf = ::Nonce; /// Signature type used by the chain. pub type SignatureOf = ::Signature; diff --git a/bridges/primitives/runtime/src/lib.rs b/bridges/primitives/runtime/src/lib.rs index 1922a2eb16040..0bfbd1c2ee91b 100644 --- a/bridges/primitives/runtime/src/lib.rs +++ b/bridges/primitives/runtime/src/lib.rs @@ -25,13 +25,14 @@ use frame_support::{ }; use frame_system::RawOrigin; use scale_info::TypeInfo; +use serde::{Deserialize, Serialize}; use sp_core::storage::StorageKey; use sp_runtime::traits::{BadOrigin, Header as HeaderT, UniqueSaturatedInto}; use sp_std::{convert::TryFrom, fmt::Debug, ops::RangeInclusive, vec, vec::Vec}; pub use chain::{ AccountIdOf, AccountPublicOf, BalanceOf, BlockNumberOf, Chain, EncodedOrDecodedCall, HashOf, - HasherOf, HeaderOf, IndexOf, Parachain, ParachainIdOf, SignatureOf, TransactionEraOf, + HasherOf, HeaderOf, NonceOf, Parachain, ParachainIdOf, SignatureOf, TransactionEraOf, UnderlyingChainOf, UnderlyingChainProvider, }; pub use frame_support::storage::storage_prefix as storage_value_final_key; @@ -373,8 +374,19 @@ pub trait OperatingMode: Send + Copy + Debug + FullCodec { } /// Basic operating modes for a bridges module (Normal/Halted). -#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)] -#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +#[derive( + Encode, + Decode, + Clone, + Copy, + PartialEq, + Eq, + RuntimeDebug, + TypeInfo, + MaxEncodedLen, + Serialize, + Deserialize, +)] pub enum BasicOperatingMode { /// Normal mode, when all operations are allowed. Normal, diff --git a/bridges/primitives/runtime/src/messages.rs b/bridges/primitives/runtime/src/messages.rs index 9f7c8ab5ca4e3..d308582957839 100644 --- a/bridges/primitives/runtime/src/messages.rs +++ b/bridges/primitives/runtime/src/messages.rs @@ -26,8 +26,8 @@ pub struct MessageDispatchResult { /// Unspent dispatch weight. This weight that will be deducted from total delivery transaction /// weight, thus reducing the transaction cost. This shall not be zero in (at least) two cases: /// - /// 1) if message has been dispatched successfully, but post-dispatch weight is less than - /// the weight, declared by the message sender; + /// 1) if message has been dispatched successfully, but post-dispatch weight is less than the + /// weight, declared by the message sender; /// 2) if message has not been dispatched at all. pub unspent_weight: Weight, /// Fine-grained result of single message dispatch (for better diagnostic purposes) diff --git a/bridges/relays/bin-substrate/src/cli/register_parachain.rs b/bridges/relays/bin-substrate/src/cli/register_parachain.rs index 320277590bcd0..539366c8dbaf5 100644 --- a/bridges/relays/bin-substrate/src/cli/register_parachain.rs +++ b/bridges/relays/bin-substrate/src/cli/register_parachain.rs @@ -103,8 +103,8 @@ impl RegisterParachain { let para_id: ParaId = relay_client .storage_value(StorageKey(para_id_key.to_vec()), None) .await? - .unwrap_or(polkadot_primitives::v4::LOWEST_PUBLIC_ID) - .max(polkadot_primitives::v4::LOWEST_PUBLIC_ID); + .unwrap_or(polkadot_primitives::v5::LOWEST_PUBLIC_ID) + .max(polkadot_primitives::v5::LOWEST_PUBLIC_ID); log::info!(target: "bridge", "Going to reserve parachain id: {:?}", para_id); // step 1: reserve a parachain id diff --git a/bridges/relays/bin-substrate/src/cli/send_message.rs b/bridges/relays/bin-substrate/src/cli/send_message.rs index 8f76e501f6968..918643faadb69 100644 --- a/bridges/relays/bin-substrate/src/cli/send_message.rs +++ b/bridges/relays/bin-substrate/src/cli/send_message.rs @@ -61,7 +61,7 @@ pub struct SendMessage { #[async_trait] trait MessageSender: MessagesCliBridge where - Self::Source: ChainBase + ChainWithTransactions + CliChain + CliEncodeMessage, + Self::Source: ChainBase + ChainWithTransactions + CliChain + CliEncodeMessage, ::Balance: Display + From + Into, ::Call: Sync, ::SignedTransaction: Sync, diff --git a/bridges/relays/client-millau/src/lib.rs b/bridges/relays/client-millau/src/lib.rs index ce42d004bb807..d6ce47d847dd3 100644 --- a/bridges/relays/client-millau/src/lib.rs +++ b/bridges/relays/client-millau/src/lib.rs @@ -21,7 +21,7 @@ use bp_runtime::ChainId; use codec::{Compact, Decode, Encode}; use relay_substrate_client::{ BalanceOf, Chain, ChainWithBalances, ChainWithMessages, ChainWithTransactions, - ChainWithUtilityPallet, Error as SubstrateError, FullRuntimeUtilityPallet, IndexOf, SignParam, + ChainWithUtilityPallet, Error as SubstrateError, FullRuntimeUtilityPallet, NonceOf, SignParam, UnderlyingChainProvider, UnsignedTransaction, }; use sp_core::{storage::StorageKey, Pair}; @@ -139,7 +139,7 @@ impl ChainWithTransactions for Millau { Some( UnsignedTransaction::new( tx.function.into(), - Compact::>::decode(&mut &extra.5.encode()[..]).ok()?.into(), + Compact::>::decode(&mut &extra.5.encode()[..]).ok()?.into(), ) .tip(Compact::>::decode(&mut &extra.7.encode()[..]).ok()?.into()), ) diff --git a/bridges/relays/client-rialto/src/lib.rs b/bridges/relays/client-rialto/src/lib.rs index f8f696068fe90..97b6c7ee802bf 100644 --- a/bridges/relays/client-rialto/src/lib.rs +++ b/bridges/relays/client-rialto/src/lib.rs @@ -21,7 +21,7 @@ use bp_runtime::ChainId; use codec::{Compact, Decode, Encode}; use relay_substrate_client::{ BalanceOf, Chain, ChainWithBalances, ChainWithMessages, ChainWithTransactions, - Error as SubstrateError, IndexOf, RelayChain, SignParam, UnderlyingChainProvider, + Error as SubstrateError, NonceOf, RelayChain, SignParam, UnderlyingChainProvider, UnsignedTransaction, }; use sp_core::{storage::StorageKey, Pair}; @@ -139,7 +139,7 @@ impl ChainWithTransactions for Rialto { Some( UnsignedTransaction::new( tx.function.into(), - Compact::>::decode(&mut &extra.5.encode()[..]).ok()?.into(), + Compact::>::decode(&mut &extra.5.encode()[..]).ok()?.into(), ) .tip(Compact::>::decode(&mut &extra.7.encode()[..]).ok()?.into()), ) diff --git a/bridges/relays/client-substrate/src/chain.rs b/bridges/relays/client-substrate/src/chain.rs index 54c9ad4f3b68c..f733a10d06b24 100644 --- a/bridges/relays/client-substrate/src/chain.rs +++ b/bridges/relays/client-substrate/src/chain.rs @@ -166,7 +166,7 @@ pub struct UnsignedTransaction { /// Runtime call of this transaction. pub call: EncodedOrDecodedCall, /// Transaction nonce. - pub nonce: C::Index, + pub nonce: C::Nonce, /// Tip included into transaction. pub tip: C::Balance, /// Transaction era used by the chain. @@ -175,7 +175,7 @@ pub struct UnsignedTransaction { impl UnsignedTransaction { /// Create new unsigned transaction with given call, nonce, era and zero tip. - pub fn new(call: EncodedOrDecodedCall, nonce: C::Index) -> Self { + pub fn new(call: EncodedOrDecodedCall, nonce: C::Nonce) -> Self { Self { call, nonce, era: TransactionEra::Immortal, tip: Zero::zero() } } diff --git a/bridges/relays/client-substrate/src/client.rs b/bridges/relays/client-substrate/src/client.rs index 8a0875a89763e..a4001a19aa051 100644 --- a/bridges/relays/client-substrate/src/client.rs +++ b/bridges/relays/client-substrate/src/client.rs @@ -427,7 +427,7 @@ impl Client { /// Get the nonce of the given Substrate account. /// /// Note: It's the caller's responsibility to make sure `account` is a valid SS58 address. - pub async fn next_account_index(&self, account: C::AccountId) -> Result { + pub async fn next_account_index(&self, account: C::AccountId) -> Result { self.jsonrpsee_execute(move |client| async move { Ok(SubstrateFrameSystemClient::::account_next_index(&*client, account).await?) }) @@ -474,7 +474,7 @@ impl Client { pub async fn submit_signed_extrinsic( &self, signer: &AccountKeyPairOf, - prepare_extrinsic: impl FnOnce(HeaderIdOf, C::Index) -> Result> + prepare_extrinsic: impl FnOnce(HeaderIdOf, C::Nonce) -> Result> + Send + 'static, ) -> Result @@ -515,7 +515,7 @@ impl Client { pub async fn submit_and_watch_signed_extrinsic( &self, signer: &AccountKeyPairOf, - prepare_extrinsic: impl FnOnce(HeaderIdOf, C::Index) -> Result> + prepare_extrinsic: impl FnOnce(HeaderIdOf, C::Nonce) -> Result> + Send + 'static, ) -> Result> diff --git a/bridges/relays/client-substrate/src/lib.rs b/bridges/relays/client-substrate/src/lib.rs index c8d8b6f8129f9..84c2ad10cf8f6 100644 --- a/bridges/relays/client-substrate/src/lib.rs +++ b/bridges/relays/client-substrate/src/lib.rs @@ -50,7 +50,7 @@ pub use crate::{ }; pub use bp_runtime::{ AccountIdOf, AccountPublicOf, BalanceOf, BlockNumberOf, Chain as ChainBase, HashOf, HeaderIdOf, - HeaderOf, IndexOf, Parachain as ParachainBase, SignatureOf, TransactionEra, TransactionEraOf, + HeaderOf, NonceOf, Parachain as ParachainBase, SignatureOf, TransactionEra, TransactionEraOf, UnderlyingChainProvider, }; diff --git a/bridges/relays/client-substrate/src/rpc.rs b/bridges/relays/client-substrate/src/rpc.rs index 94726e49187ab..35ab08c0f4151 100644 --- a/bridges/relays/client-substrate/src/rpc.rs +++ b/bridges/relays/client-substrate/src/rpc.rs @@ -154,7 +154,7 @@ impl SubstrateFinalityClient for SubstrateBeefyFinalityClient { pub(crate) trait SubstrateFrameSystem { /// Return index of next account transaction. #[method(name = "accountNextIndex")] - async fn account_next_index(&self, account_id: C::AccountId) -> RpcResult; + async fn account_next_index(&self, account_id: C::AccountId) -> RpcResult; } /// RPC methods of Substrate `pallet_transaction_payment` frame pallet, that we are using. diff --git a/bridges/relays/client-substrate/src/test_chain.rs b/bridges/relays/client-substrate/src/test_chain.rs index 64c7590ee5250..923092b1bcb7b 100644 --- a/bridges/relays/client-substrate/src/test_chain.rs +++ b/bridges/relays/client-substrate/src/test_chain.rs @@ -38,7 +38,7 @@ impl bp_runtime::Chain for TestChain { type AccountId = u32; type Balance = u32; - type Index = u32; + type Nonce = u32; type Signature = sp_runtime::testing::TestSignature; fn max_extrinsic_size() -> u32 { @@ -80,7 +80,7 @@ impl bp_runtime::Chain for TestParachainBase { type AccountId = u32; type Balance = u32; - type Index = u32; + type Nonce = u32; type Signature = sp_runtime::testing::TestSignature; fn max_extrinsic_size() -> u32 { diff --git a/bridges/relays/client-substrate/src/transaction_tracker.rs b/bridges/relays/client-substrate/src/transaction_tracker.rs index 211f7faab0e19..00375768c45c2 100644 --- a/bridges/relays/client-substrate/src/transaction_tracker.rs +++ b/bridges/relays/client-substrate/src/transaction_tracker.rs @@ -54,8 +54,8 @@ impl Environment for Client { /// 2) assume that the transaction is lost and resubmit another transaction instantly; /// /// 3) wait for some time (if transaction is mortal - then until block where it dies; if it is -/// immortal - then for some time that we assume is long enough to mine it) and assume that -/// it is lost. +/// immortal - then for some time that we assume is long enough to mine it) and assume that it is +/// lost. /// /// This struct implements third option as it seems to be the most optimal. pub struct TransactionTracker { diff --git a/bridges/relays/lib-substrate-relay/src/finality/initialize.rs b/bridges/relays/lib-substrate-relay/src/finality/initialize.rs index 87052cf7aa47a..1b990f5dbda3e 100644 --- a/bridges/relays/lib-substrate-relay/src/finality/initialize.rs +++ b/bridges/relays/lib-substrate-relay/src/finality/initialize.rs @@ -46,7 +46,7 @@ pub async fn initialize< dry_run: bool, ) where F: FnOnce( - TargetChain::Index, + TargetChain::Nonce, E::InitializationData, ) -> Result, SubstrateError> + Send @@ -112,7 +112,7 @@ async fn do_initialize< > where F: FnOnce( - TargetChain::Index, + TargetChain::Nonce, E::InitializationData, ) -> Result, SubstrateError> + Send diff --git a/bridges/relays/lib-substrate-relay/src/messages_metrics.rs b/bridges/relays/lib-substrate-relay/src/messages_metrics.rs index 33d855a026318..50972dfc49cb6 100644 --- a/bridges/relays/lib-substrate-relay/src/messages_metrics.rs +++ b/bridges/relays/lib-substrate-relay/src/messages_metrics.rs @@ -27,7 +27,7 @@ use pallet_balances::AccountData; use relay_substrate_client::{ metrics::{FloatStorageValue, FloatStorageValueMetric}, AccountIdOf, BalanceOf, Chain, ChainWithBalances, ChainWithMessages, Client, - Error as SubstrateError, IndexOf, + Error as SubstrateError, NonceOf, }; use relay_utils::metrics::{MetricsParams, StandaloneMetric}; use sp_core::storage::StorageData; @@ -133,7 +133,7 @@ where ) -> Result, SubstrateError> { maybe_raw_value .map(|raw_value| { - AccountInfo::, AccountData>>::decode(&mut &raw_value.0[..]) + AccountInfo::, AccountData>>::decode(&mut &raw_value.0[..]) .map_err(SubstrateError::ResponseParseFailed) .map(|account_data| { convert_to_token_balance(account_data.data.free.into(), self.token_decimals) diff --git a/bridges/relays/lib-substrate-relay/src/on_demand/parachains.rs b/bridges/relays/lib-substrate-relay/src/on_demand/parachains.rs index 4c205770d4acb..f67c002bba7f9 100644 --- a/bridges/relays/lib-substrate-relay/src/on_demand/parachains.rs +++ b/bridges/relays/lib-substrate-relay/src/on_demand/parachains.rs @@ -318,8 +318,8 @@ async fn background_task( // // 7) on-demand parachains relay sets `ParachainsSource::maximal_header_number` to the // `PH'.number()`. - // 8) parachains finality relay sees that the parachain head has been - // updated and relays `PH'` to the target chain. + // 8) parachains finality relay sees that the parachain head has been updated and relays + // `PH'` to the target chain. // select headers to relay let relay_data = read_relay_data( diff --git a/bridges/relays/messages/src/message_race_strategy.rs b/bridges/relays/messages/src/message_race_strategy.rs index 5c8f9a162b4a2..93d178e55b04f 100644 --- a/bridges/relays/messages/src/message_race_strategy.rs +++ b/bridges/relays/messages/src/message_race_strategy.rs @@ -14,8 +14,8 @@ //! Basic delivery strategy. The strategy selects nonces if: //! //! 1) there are more nonces on the source side than on the target side; -//! 2) new nonces may be proved to target node (i.e. they have appeared at the -//! block, which is known to the target node). +//! 2) new nonces may be proved to target node (i.e. they have appeared at the block, which is known +//! to the target node). use crate::message_race_loop::{ NoncesRange, RaceState, RaceStrategy, SourceClientNonces, TargetClientNonces,