diff --git a/bridges/bin/millau/node/Cargo.toml b/bridges/bin/millau/node/Cargo.toml index b022282b3b23c..08661951eed68 100644 --- a/bridges/bin/millau/node/Cargo.toml +++ b/bridges/bin/millau/node/Cargo.toml @@ -10,7 +10,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] clap = { version = "4.0.9", features = ["derive"] } -jsonrpsee = { version = "0.15.1", features = ["server"] } +jsonrpsee = { version = "0.16.2", features = ["server"] } serde_json = "1.0.79" # Bridge dependencies @@ -21,14 +21,14 @@ millau-runtime = { path = "../runtime" } beefy-gadget = { git = "https://github.com/paritytech/substrate", branch = "master" } beefy-gadget-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" } -beefy-primitives = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-beefy = { git = "https://github.com/paritytech/substrate", branch = "master" } frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master" } frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "master" } node-inspect = { git = "https://github.com/paritytech/substrate", branch = "master" } -pallet-mmr-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" } +mmr-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" } pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "master" } -sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master", features = ["wasmtime"] } +sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master"} sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-consensus-aura = { 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 2ded668fdeebc..8b0bc28ed1466 100644 --- a/bridges/bin/millau/node/src/chain_spec.rs +++ b/bridges/bin/millau/node/src/chain_spec.rs @@ -14,12 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -use beefy_primitives::crypto::AuthorityId as BeefyId; use millau_runtime::{ AccountId, AuraConfig, BalancesConfig, BeefyConfig, BridgeRialtoMessagesConfig, BridgeRialtoParachainMessagesConfig, BridgeWestendGrandpaConfig, GenesisConfig, GrandpaConfig, SessionConfig, SessionKeys, Signature, SudoConfig, SystemConfig, WASM_BINARY, }; +use sp_beefy::crypto::AuthorityId as BeefyId; use sp_consensus_aura::sr25519::AuthorityId as AuraId; use sp_core::{sr25519, Pair, Public}; use sp_finality_grandpa::AuthorityId as GrandpaId; diff --git a/bridges/bin/millau/node/src/service.rs b/bridges/bin/millau/node/src/service.rs index e86d9e847a02b..6ad63387da4f2 100644 --- a/bridges/bin/millau/node/src/service.rs +++ b/bridges/bin/millau/node/src/service.rs @@ -272,7 +272,7 @@ pub fn new_full(mut config: Configuration) -> Result use sc_finality_grandpa::FinalityProofProvider as GrandpaFinalityProofProvider; use beefy_gadget_rpc::{Beefy, BeefyApiServer}; - use pallet_mmr_rpc::{Mmr, MmrApiServer}; + use mmr_rpc::{Mmr, MmrApiServer}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; use sc_finality_grandpa_rpc::{Grandpa, GrandpaApiServer}; use sc_rpc::DenyUnsafe; @@ -391,7 +391,7 @@ pub fn new_full(mut config: Configuration) -> Result if role.is_authority() { Some(keystore_container.sync_keystore()) } else { None }; let justifications_protocol_name = beefy_on_demand_justifications_handler.protocol_name(); - let payload_provider = beefy_primitives::mmr::MmrRootProvider::new(client.clone()); + let payload_provider = sp_beefy::mmr::MmrRootProvider::new(client.clone()); let beefy_params = beefy_gadget::BeefyParams { client: client.clone(), backend, diff --git a/bridges/bin/millau/runtime/Cargo.toml b/bridges/bin/millau/runtime/Cargo.toml index cf9b0c24d5606..0e5868f845e78 100644 --- a/bridges/bin/millau/runtime/Cargo.toml +++ b/bridges/bin/millau/runtime/Cargo.toml @@ -31,7 +31,7 @@ pallet-shift-session-manager = { path = "../../../modules/shift-session-manager" # Substrate Dependencies -beefy-primitives = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-beefy = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true } frame-executive = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } @@ -56,7 +56,6 @@ sp-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } -sp-mmr-primitives = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-offchain = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-session = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } @@ -81,7 +80,7 @@ substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", bran [features] default = ["std"] std = [ - "beefy-primitives/std", + "sp-beefy/std", "bp-messages/std", "bp-millau/std", "bp-parachains/std", diff --git a/bridges/bin/millau/runtime/src/lib.rs b/bridges/bin/millau/runtime/src/lib.rs index 7914ac41b5334..dbff7f5940c64 100644 --- a/bridges/bin/millau/runtime/src/lib.rs +++ b/bridges/bin/millau/runtime/src/lib.rs @@ -32,7 +32,6 @@ pub mod rialto_messages; pub mod rialto_parachain_messages; pub mod xcm_config; -use beefy_primitives::{crypto::AuthorityId as BeefyId, mmr::MmrLeafVersion, ValidatorSet}; use bp_parachains::SingleParaStoredHeaderDataBuilder; use bp_runtime::HeaderId; use pallet_grandpa::{ @@ -40,9 +39,9 @@ use pallet_grandpa::{ }; use pallet_transaction_payment::{FeeDetails, Multiplier, RuntimeDispatchInfo}; use sp_api::impl_runtime_apis; +use sp_beefy::{crypto::AuthorityId as BeefyId, mmr::MmrLeafVersion, ValidatorSet}; use sp_consensus_aura::sr25519::AuthorityId as AuraId; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; -use sp_mmr_primitives::{DataOrHash, EncodableOpaqueLeaf, Error as MmrError, Proof as MmrProof}; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{Block as BlockT, IdentityLookup, Keccak256, NumberFor, OpaqueKeys}, @@ -64,7 +63,8 @@ pub use frame_support::{ parameter_types, traits::{ConstU32, ConstU8, Currency, ExistenceRequirement, Imbalance, KeyOwnerProofSystem}, weights::{ - constants::WEIGHT_PER_SECOND, ConstantMultiplier, IdentityFee, RuntimeDbWeight, Weight, + constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, IdentityFee, RuntimeDbWeight, + Weight, }, RuntimeDebug, StorageValue, }; @@ -281,7 +281,7 @@ parameter_types! { pub struct BeefyDummyDataProvider; -impl beefy_primitives::mmr::BeefyDataProvider<()> for BeefyDummyDataProvider { +impl sp_beefy::mmr::BeefyDataProvider<()> for BeefyDummyDataProvider { fn extra_data() {} } @@ -766,62 +766,30 @@ impl_runtime_apis! { } } - impl beefy_primitives::BeefyApi for Runtime { + impl sp_beefy::BeefyApi for Runtime { fn validator_set() -> Option> { Beefy::validator_set() } } - impl sp_mmr_primitives::MmrApi for Runtime { - fn generate_proof(block_number: BlockNumber) - -> Result<(EncodableOpaqueLeaf, MmrProof), MmrError> - { - Mmr::generate_batch_proof(vec![block_number]) - .and_then(|(leaves, proof)| Ok(( - mmr::EncodableOpaqueLeaf::from_leaf(&leaves[0]), - mmr::BatchProof::into_single_leaf_proof(proof)? - ))) - } - - fn verify_proof(leaf: EncodableOpaqueLeaf, proof: MmrProof) - -> Result<(), MmrError> - { - let leaf: mmr::Leaf = leaf - .into_opaque_leaf() - .try_decode() - .ok_or(MmrError::Verify)?; - Mmr::verify_leaves(vec![leaf], mmr::Proof::into_batch_proof(proof)) - } - - fn verify_proof_stateless( - root: mmr::Hash, - leaf: EncodableOpaqueLeaf, - proof: MmrProof - ) -> Result<(), MmrError> { - let node = DataOrHash::Data(leaf.into_opaque_leaf()); - pallet_mmr::verify_leaves_proof::( - root, - vec![node], - pallet_mmr::primitives::Proof::into_batch_proof(proof), - ) - } - - fn mmr_root() -> Result { + impl pallet_mmr::primitives::MmrApi< + Block, + mmr::Hash, + BlockNumber, + > for Runtime { + fn mmr_root() -> Result { Ok(Mmr::mmr_root()) } - fn generate_batch_proof(block_numbers: Vec) - -> Result<(Vec, mmr::BatchProof), mmr::Error> - { - Mmr::generate_batch_proof(block_numbers) - .map(|(leaves, proof)| (leaves.into_iter().map(|leaf| mmr::EncodableOpaqueLeaf::from_leaf(&leaf)).collect(), proof)) + fn mmr_leaf_count() -> Result { + Ok(Mmr::mmr_leaves()) } - fn generate_historical_batch_proof( + fn generate_proof( block_numbers: Vec, - best_known_block_number: BlockNumber - ) -> Result<(Vec, mmr::BatchProof), mmr::Error> { - Mmr::generate_historical_batch_proof(block_numbers, best_known_block_number).map( + best_known_block_number: Option, + ) -> Result<(Vec, mmr::Proof), mmr::Error> { + Mmr::generate_proof(block_numbers, best_known_block_number).map( |(leaves, proof)| { ( leaves @@ -834,7 +802,7 @@ impl_runtime_apis! { ) } - fn verify_batch_proof(leaves: Vec, proof: mmr::BatchProof) + fn verify_proof(leaves: Vec, proof: mmr::Proof) -> Result<(), mmr::Error> { let leaves = leaves.into_iter().map(|leaf| @@ -844,10 +812,10 @@ impl_runtime_apis! { Mmr::verify_leaves(leaves, proof) } - fn verify_batch_proof_stateless( + fn verify_proof_stateless( root: mmr::Hash, leaves: Vec, - proof: mmr::BatchProof + proof: mmr::Proof ) -> Result<(), mmr::Error> { let nodes = leaves.into_iter().map(|leaf|mmr::DataOrHash::Data(leaf.into_opaque_leaf())).collect(); pallet_mmr::verify_leaves_proof::(root, nodes, proof) diff --git a/bridges/bin/millau/runtime/src/xcm_config.rs b/bridges/bin/millau/runtime/src/xcm_config.rs index e353137e8236f..17bdc43da3d66 100644 --- a/bridges/bin/millau/runtime/src/xcm_config.rs +++ b/bridges/bin/millau/runtime/src/xcm_config.rs @@ -32,6 +32,7 @@ use bridge_runtime_common::{ use frame_support::{ parameter_types, traits::{ConstU32, Everything, Nothing}, + weights::Weight, }; use xcm::latest::prelude::*; use xcm_builder::{ @@ -97,7 +98,8 @@ pub const BASE_XCM_WEIGHT: u64 = 1_000_000_000; parameter_types! { /// The amount of weight an XCM operation takes. This is a safe overestimate. - pub const BaseXcmWeight: u64 = BASE_XCM_WEIGHT; + // TODO: https://github.com/paritytech/parity-bridges-common/issues/1543 - check `set_proof_size` 0 or 64*1024 or 1026? + pub const BaseXcmWeight: Weight = Weight::from_parts(BASE_XCM_WEIGHT, 0); /// Maximum number of instructions in a single XCM fragment. A sanity check against weight /// calculations getting too crazy. pub const MaxInstructions: u32 = 100; @@ -150,6 +152,7 @@ impl xcm_executor::Config for XcmConfig { type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; + type SafeCallFilter = Everything; } /// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior @@ -159,6 +162,11 @@ pub type LocalOriginToLocation = ( SignedToAccountId32, ); +#[cfg(feature = "runtime-benchmarks")] +parameter_types! { + pub ReachableDest: Option = todo!("We dont use benchmarks for pallet_xcm, so if you hit this message, you need to remove this and define value instead"); +} + impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; // We don't allow any messages to be sent via the transaction yet. This is basically safe to @@ -188,6 +196,9 @@ impl pallet_xcm::Config for Runtime { type TrustedLockers = (); type SovereignAccountOf = SovereignAccountOf; type MaxLockers = frame_support::traits::ConstU32<8>; + type WeightInfo = pallet_xcm::TestWeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type ReachableDest = ReachableDest; } /// With-Rialto bridge. diff --git a/bridges/bin/rialto-parachain/node/Cargo.toml b/bridges/bin/rialto-parachain/node/Cargo.toml index 4ee6a51fbc610..7b81de4fd3ac3 100644 --- a/bridges/bin/rialto-parachain/node/Cargo.toml +++ b/bridges/bin/rialto-parachain/node/Cargo.toml @@ -23,7 +23,7 @@ codec = { package = 'parity-scale-codec', version = '3.1.5' } serde = { version = '1.0', features = ['derive'] } # RPC related Dependencies -jsonrpsee = { version = "0.15.1", features = ["server"] } +jsonrpsee = { version = "0.16.2", features = ["server"] } # Local Dependencies rialto-parachain-runtime = { path = '../runtime' } @@ -47,8 +47,7 @@ sc-executor = { git = "https://github.com/paritytech/substrate", branch = "maste sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-rpc-api = { git = "https://github.com/paritytech/substrate", branch = "master" } -sc-service = { git = "https://github.com/paritytech/substrate", branch = "master", features = ['wasmtime'] } -sc-sysinfo = { 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-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" } @@ -74,8 +73,6 @@ cumulus-client-service = { git = "https://github.com/paritytech/cumulus", branch cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "master" } cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/cumulus", branch = "master" } cumulus-relay-chain-interface = { git = "https://github.com/paritytech/cumulus", branch = "master" } -cumulus-relay-chain-inprocess-interface = { git = "https://github.com/paritytech/cumulus", branch = "master" } -cumulus-relay-chain-minimal-node = { git = "https://github.com/paritytech/cumulus", branch = "master" } # Polkadot dependencies polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "master" } diff --git a/bridges/bin/rialto-parachain/node/src/cli.rs b/bridges/bin/rialto-parachain/node/src/cli.rs index 51fa1e9776c38..a003c91113c00 100644 --- a/bridges/bin/rialto-parachain/node/src/cli.rs +++ b/bridges/bin/rialto-parachain/node/src/cli.rs @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . +#![allow(clippy::large_enum_variant)] + use crate::chain_spec; use clap::Parser; use std::path::PathBuf; diff --git a/bridges/bin/rialto-parachain/node/src/command.rs b/bridges/bin/rialto-parachain/node/src/command.rs index dd9e95abbe543..2cb08ec4ea283 100644 --- a/bridges/bin/rialto-parachain/node/src/command.rs +++ b/bridges/bin/rialto-parachain/node/src/command.rs @@ -138,7 +138,6 @@ macro_rules! construct_async_run { runner.async_run(|$config| { let $components = new_partial::< RuntimeApi, - ParachainRuntimeExecutor, _ >( &$config, diff --git a/bridges/bin/rialto-parachain/node/src/service.rs b/bridges/bin/rialto-parachain/node/src/service.rs index 7dc25f6550d00..254340a8ad4cc 100644 --- a/bridges/bin/rialto-parachain/node/src/service.rs +++ b/bridges/bin/rialto-parachain/node/src/service.rs @@ -30,17 +30,16 @@ use rialto_parachain_runtime::RuntimeApi; // Cumulus Imports use cumulus_client_cli::CollatorOptions; use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, SlotProportion}; -use cumulus_client_consensus_common::{ParachainBlockImport, ParachainConsensus}; +use cumulus_client_consensus_common::{ + ParachainBlockImport as TParachainBlockImport, ParachainConsensus, +}; use cumulus_client_network::BlockAnnounceValidator; use cumulus_client_service::{ prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams, }; use cumulus_primitives_core::ParaId; -use cumulus_relay_chain_inprocess_interface::build_inprocess_relay_chain; -use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface, RelayChainResult}; -use cumulus_relay_chain_minimal_node::build_minimal_relay_chain_node; -use polkadot_service::CollatorPair; - +use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface}; +use sc_consensus::ImportQueue; // Substrate Imports use sc_executor::{NativeElseWasmExecutor, NativeExecutionDispatch}; use sc_network::{NetworkBlock, NetworkService}; @@ -57,6 +56,12 @@ type Header = sp_runtime::generic::Header; type Hash = sp_core::H256; +type ParachainClient = + TFullClient>; +type ParachainBackend = TFullBackend; +type ParachainBlockImport = + TParachainBlockImport>, ParachainBackend>; + pub type ParachainRuntimeExecutor = ExecutorDispatch; // Our native executor instance. @@ -79,51 +84,39 @@ impl NativeExecutionDispatch for ExecutorDispatch { /// Use this macro if you don't actually need the full service, but just the builder in order to /// be able to perform chain operations. #[allow(clippy::type_complexity)] -pub fn new_partial( +pub fn new_partial( config: &Configuration, build_import_queue: BIQ, ) -> Result< PartialComponents< - TFullClient>, - TFullBackend, + ParachainClient, + ParachainBackend, (), - sc_consensus::DefaultImportQueue< - Block, - TFullClient>, - >, - sc_transaction_pool::FullPool< - Block, - TFullClient>, - >, - (Option, Option), + sc_consensus::DefaultImportQueue>, + sc_transaction_pool::FullPool>, + (ParachainBlockImport, Option, Option), >, sc_service::Error, > where - RuntimeApi: ConstructRuntimeApi>> - + Send - + Sync - + 'static, + RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue + sp_api::Metadata + sp_session::SessionKeys + sp_api::ApiExt< Block, - StateBackend = sc_client_api::StateBackendFor, Block>, + StateBackend = sc_client_api::StateBackendFor, > + sp_offchain::OffchainWorkerApi + sp_block_builder::BlockBuilder, - sc_client_api::StateBackendFor, Block>: sp_api::StateBackend, - Executor: NativeExecutionDispatch + 'static, + sc_client_api::StateBackendFor: sp_api::StateBackend, BIQ: FnOnce( - Arc>>, + Arc>, + ParachainBlockImport, &Configuration, Option, &TaskManager, ) -> Result< - sc_consensus::DefaultImportQueue< - Block, - TFullClient>, - >, + sc_consensus::DefaultImportQueue>, sc_service::Error, >, { @@ -138,7 +131,7 @@ where }) .transpose()?; - let executor = sc_executor::NativeElseWasmExecutor::::new( + let executor = sc_executor::NativeElseWasmExecutor::::new( config.wasm_method, config.default_heap_pages, config.max_runtime_instances, @@ -168,8 +161,11 @@ where client.clone(), ); + let block_import = ParachainBlockImport::new(client.clone(), backend.clone()); + let import_queue = build_import_queue( client.clone(), + block_import.clone(), config, telemetry.as_ref().map(|telemetry| telemetry.handle()), &task_manager, @@ -183,38 +179,17 @@ where task_manager, transaction_pool, select_chain: (), - other: (telemetry, telemetry_worker_handle), + other: (block_import, telemetry, telemetry_worker_handle), }; Ok(params) } -async fn build_relay_chain_interface( - polkadot_config: Configuration, - parachain_config: &Configuration, - telemetry_worker_handle: Option, - task_manager: &mut TaskManager, - collator_options: CollatorOptions, - hwbench: Option, -) -> RelayChainResult<(Arc<(dyn RelayChainInterface + 'static)>, Option)> { - match collator_options.relay_chain_rpc_url { - Some(relay_chain_url) => - build_minimal_relay_chain_node(polkadot_config, task_manager, relay_chain_url).await, - None => build_inprocess_relay_chain( - polkadot_config, - parachain_config, - telemetry_worker_handle, - task_manager, - hwbench, - ), - } -} - /// Start a node with the given parachain `Configuration` and relay chain `Configuration`. /// /// This is the actual implementation that is abstract over the executor and the runtime api. #[sc_tracing::logging::prefix_logs_with("Parachain")] -async fn start_node_impl( +async fn start_node_impl( parachain_config: Configuration, polkadot_config: Configuration, collator_options: CollatorOptions, @@ -222,63 +197,45 @@ async fn start_node_impl( rpc_ext_builder: RB, build_import_queue: BIQ, build_consensus: BIC, -) -> sc_service::error::Result<( - TaskManager, - Arc>>, -)> +) -> sc_service::error::Result<(TaskManager, Arc>)> where - RuntimeApi: ConstructRuntimeApi>> - + Send - + Sync - + 'static, + RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue + sp_api::Metadata + sp_session::SessionKeys + sp_api::ApiExt< Block, - StateBackend = sc_client_api::StateBackendFor, Block>, + StateBackend = sc_client_api::StateBackendFor, > + sp_offchain::OffchainWorkerApi + sp_block_builder::BlockBuilder + cumulus_primitives_core::CollectCollationInfo, - sc_client_api::StateBackendFor, Block>: sp_api::StateBackend, - Executor: NativeExecutionDispatch + 'static, + sc_client_api::StateBackendFor: sp_api::StateBackend, RB: Fn( sc_rpc_api::DenyUnsafe, - Arc>>, - Arc< - sc_transaction_pool::FullPool< - Block, - TFullClient>, - >, - >, + Arc>, + Arc>>, ) -> Result, sc_service::Error> + Send + Clone + 'static, BIQ: FnOnce( - Arc>>, + Arc>, + ParachainBlockImport, &Configuration, Option, &TaskManager, ) -> Result< - sc_consensus::DefaultImportQueue< - Block, - TFullClient>, - >, + sc_consensus::DefaultImportQueue>, sc_service::Error, >, BIC: FnOnce( - Arc>>, + Arc>, + ParachainBlockImport, Option<&Registry>, Option, &TaskManager, Arc, - Arc< - sc_transaction_pool::FullPool< - Block, - TFullClient>, - >, - >, + Arc>>, Arc>, SyncCryptoStorePtr, bool, @@ -286,23 +243,24 @@ where { let parachain_config = prepare_node_config(parachain_config); - let params = new_partial::(¶chain_config, build_import_queue)?; - let (mut telemetry, telemetry_worker_handle) = params.other; + let params = new_partial::(¶chain_config, build_import_queue)?; + let (block_import, mut telemetry, telemetry_worker_handle) = params.other; let mut task_manager = params.task_manager; - let (relay_chain_interface, collator_key) = build_relay_chain_interface( - polkadot_config, - ¶chain_config, - telemetry_worker_handle, - &mut task_manager, - collator_options, - None, - ) - .await - .map_err(|e| match e { - RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x, - s => s.to_string().into(), - })?; + let (relay_chain_interface, collator_key) = + cumulus_client_service::build_relay_chain_interface( + polkadot_config, + ¶chain_config, + telemetry_worker_handle, + &mut task_manager, + collator_options, + None, + ) + .await + .map_err(|e| match e { + RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x, + s => s.to_string().into(), + })?; let client = params.client.clone(); let backend = params.backend.clone(); @@ -312,14 +270,15 @@ where let validator = parachain_config.role.is_authority(); let prometheus_registry = parachain_config.prometheus_registry().cloned(); let transaction_pool = params.transaction_pool.clone(); - let import_queue = cumulus_client_service::SharedImportQueue::new(params.import_queue); + let import_queue_service = params.import_queue.service(); + let (network, system_rpc_tx, tx_handler_controller, start_network) = sc_service::build_network(sc_service::BuildNetworkParams { config: ¶chain_config, client: client.clone(), transaction_pool: transaction_pool.clone(), spawn_handle: task_manager.spawn_handle(), - import_queue: import_queue.clone(), + import_queue: params.import_queue, block_announce_validator_builder: Some(Box::new(|_| { Box::new(block_announce_validator) })), @@ -356,6 +315,7 @@ where if validator { let parachain_consensus = build_consensus( client.clone(), + block_import, prometheus_registry.as_ref(), telemetry.as_ref().map(|t| t.handle()), &task_manager, @@ -377,7 +337,7 @@ where relay_chain_interface, spawner, parachain_consensus, - import_queue, + import_queue: import_queue_service, collator_key: collator_key.expect("Command line arguments do not allow this. qed"), relay_chain_slot_duration, }; @@ -391,7 +351,7 @@ where para_id: id, relay_chain_interface, relay_chain_slot_duration, - import_queue, + import_queue: import_queue_service, }; start_full_node(params)?; @@ -405,17 +365,13 @@ where /// Build the import queue for the the parachain runtime. #[allow(clippy::type_complexity)] pub fn parachain_build_import_queue( - client: Arc>>, + client: Arc>, + block_import: ParachainBlockImport, config: &Configuration, telemetry: Option, task_manager: &TaskManager, -) -> Result< - sc_consensus::DefaultImportQueue< - Block, - TFullClient>, - >, - sc_service::Error, -> { +) -> Result>, sc_service::Error> +{ let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?; cumulus_client_consensus_aura::import_queue::< @@ -426,18 +382,18 @@ pub fn parachain_build_import_queue( _, _, >(cumulus_client_consensus_aura::ImportQueueParams { - block_import: ParachainBlockImport::new(client.clone()), + block_import, client, create_inherent_data_providers: move |_, _| async move { - let time = sp_timestamp::InherentDataProvider::from_system_time(); + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( - *time, + *timestamp, slot_duration, ); - Ok((slot, time)) + Ok((slot, timestamp)) }, registry: config.prometheus_registry(), spawner: &task_manager.spawn_essential_handle(), @@ -452,11 +408,8 @@ pub async fn start_node( polkadot_config: Configuration, collator_options: CollatorOptions, id: ParaId, -) -> sc_service::error::Result<( - TaskManager, - Arc>>, -)> { - start_node_impl::( +) -> sc_service::error::Result<(TaskManager, Arc>)> { + start_node_impl::( parachain_config, polkadot_config, collator_options, @@ -475,6 +428,7 @@ pub async fn start_node( }, parachain_build_import_queue, |client, + block_import, prometheus_registry, telemetry, task_manager, @@ -483,11 +437,13 @@ pub async fn start_node( sync_oracle, keystore, force_authoring| { + let client2 = client.clone(); + let block_import2 = block_import; let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?; let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording( task_manager.spawn_handle(), - client.clone(), + client, transaction_pool, prometheus_registry, telemetry.clone(), @@ -521,8 +477,8 @@ pub async fn start_node( Ok((slot, time, parachain_inherent)) } }, - block_import: ParachainBlockImport::new(client.clone()), - para_client: client, + block_import: block_import2, + para_client: client2, backoff_authoring_blocks: Option::<()>::None, sync_oracle, keystore, diff --git a/bridges/bin/rialto-parachain/runtime/src/lib.rs b/bridges/bin/rialto-parachain/runtime/src/lib.rs index e2e9663510ca0..b9f4c236d861f 100644 --- a/bridges/bin/rialto-parachain/runtime/src/lib.rs +++ b/bridges/bin/rialto-parachain/runtime/src/lib.rs @@ -52,7 +52,9 @@ pub use frame_support::{ match_types, parameter_types, traits::{ConstU32, Everything, IsInVec, Nothing, Randomness}, weights::{ - constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND}, + constants::{ + BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND, + }, IdentityFee, Weight, }, StorageValue, @@ -370,7 +372,9 @@ pub type XcmOriginToTransactDispatchOrigin = ( pub const BASE_XCM_WEIGHT: u64 = 1_000_000_000; parameter_types! { - pub UnitWeightCost: u64 = BASE_XCM_WEIGHT; + /// The amount of weight an XCM operation takes. This is a safe overestimate. + // TODO: https://github.com/paritytech/parity-bridges-common/issues/1543 - check `set_proof_size` 0 or 64*1024 or 1026? + pub UnitWeightCost: Weight = Weight::from_parts(BASE_XCM_WEIGHT, 0); // One UNIT buys 1 second of weight. pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), UNIT); pub const MaxInstructions: u32 = 100; @@ -419,6 +423,7 @@ impl Config for XcmConfig { type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; + type SafeCallFilter = Everything; } /// No local origins on this chain are allowed to dispatch XCM sends/executions. @@ -457,6 +462,11 @@ impl XcmBridge for ToMillauBridge { } } +#[cfg(feature = "runtime-benchmarks")] +parameter_types! { + pub ReachableDest: Option = todo!("We dont use benchmarks for pallet_xcm, so if you hit this message, you need to remove this and define value instead"); +} + impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type SendXcmOrigin = EnsureXcmOrigin; @@ -477,6 +487,9 @@ impl pallet_xcm::Config for Runtime { type SovereignAccountOf = (); type MaxLockers = frame_support::traits::ConstU32<8>; type UniversalLocation = UniversalLocation; + type WeightInfo = pallet_xcm::TestWeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type ReachableDest = ReachableDest; } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/bridges/bin/rialto/node/Cargo.toml b/bridges/bin/rialto/node/Cargo.toml index 82b073896d987..aec1870efd8dc 100644 --- a/bridges/bin/rialto/node/Cargo.toml +++ b/bridges/bin/rialto/node/Cargo.toml @@ -18,12 +18,12 @@ rialto-runtime = { path = "../runtime" } # Substrate Dependencies -beefy-primitives = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-beefy = { git = "https://github.com/paritytech/substrate", branch = "master" } frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master" } frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "master" } frame-support = { git = "https://github.com/paritytech/substrate", branch = "master" } node-inspect = { git = "https://github.com/paritytech/substrate", branch = "master" } -sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master", features = ["wasmtime"] } +sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master"} sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-service = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/bridges/bin/rialto/node/src/chain_spec.rs b/bridges/bin/rialto/node/src/chain_spec.rs index 0e9edb38ac03e..5085c2dc71cbe 100644 --- a/bridges/bin/rialto/node/src/chain_spec.rs +++ b/bridges/bin/rialto/node/src/chain_spec.rs @@ -14,7 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -use beefy_primitives::crypto::AuthorityId as BeefyId; use frame_support::weights::Weight; use polkadot_primitives::v2::{AssignmentId, ValidatorId}; use rialto_runtime::{ @@ -24,6 +23,7 @@ use rialto_runtime::{ }; use serde_json::json; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; +use sp_beefy::crypto::AuthorityId as BeefyId; use sp_consensus_babe::AuthorityId as BabeId; use sp_core::{sr25519, Pair, Public}; use sp_finality_grandpa::AuthorityId as GrandpaId; diff --git a/bridges/bin/rialto/runtime/Cargo.toml b/bridges/bin/rialto/runtime/Cargo.toml index ae8d9cc0d4b5b..b4d387e3829b1 100644 --- a/bridges/bin/rialto/runtime/Cargo.toml +++ b/bridges/bin/rialto/runtime/Cargo.toml @@ -26,7 +26,7 @@ pallet-shift-session-manager = { path = "../../../modules/shift-session-manager" # Substrate Dependencies -beefy-primitives = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-beefy = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true } frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true } frame-executive = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } @@ -51,7 +51,6 @@ sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } -sp-mmr-primitives = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-offchain = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sp-session = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } @@ -79,7 +78,7 @@ substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", bran [features] default = ["std"] std = [ - "beefy-primitives/std", + "sp-beefy/std", "bp-messages/std", "bp-millau/std", "bp-relayers/std", @@ -104,7 +103,6 @@ std = [ "pallet-grandpa/std", "pallet-mmr/std", "pallet-xcm/std", - "sp-mmr-primitives/std", "pallet-shift-session-manager/std", "pallet-sudo/std", "pallet-timestamp/std", diff --git a/bridges/bin/rialto/runtime/src/lib.rs b/bridges/bin/rialto/runtime/src/lib.rs index 355ccc0b00282..123cd477d9786 100644 --- a/bridges/bin/rialto/runtime/src/lib.rs +++ b/bridges/bin/rialto/runtime/src/lib.rs @@ -32,19 +32,15 @@ pub mod millau_messages; pub mod parachains; pub mod xcm_config; -use beefy_primitives::{crypto::AuthorityId as BeefyId, mmr::MmrLeafVersion, ValidatorSet}; use bp_runtime::HeaderId; use pallet_grandpa::{ fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList, }; -use pallet_mmr::primitives as mmr; use pallet_transaction_payment::{FeeDetails, Multiplier, RuntimeDispatchInfo}; use sp_api::impl_runtime_apis; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; +use sp_beefy::{crypto::AuthorityId as BeefyId, mmr::MmrLeafVersion, ValidatorSet}; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; -use sp_mmr_primitives::{ - DataOrHash, EncodableOpaqueLeaf, Error as MmrError, LeafDataProvider, Proof as MmrProof, -}; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{AccountIdLookup, Block as BlockT, Keccak256, NumberFor, OpaqueKeys}, @@ -62,7 +58,7 @@ pub use frame_support::{ dispatch::DispatchClass, parameter_types, traits::{ConstU32, ConstU8, Currency, ExistenceRequirement, Imbalance, KeyOwnerProofSystem}, - weights::{constants::WEIGHT_PER_SECOND, IdentityFee, RuntimeDbWeight, Weight}, + weights::{constants::WEIGHT_REF_TIME_PER_SECOND, IdentityFee, RuntimeDbWeight, Weight}, StorageValue, }; @@ -269,9 +265,6 @@ impl pallet_grandpa::Config for Runtime { type WeightInfo = (); } -type MmrHash = ::Output; -type MmrHashing = ::Hashing; - impl pallet_mmr::Config for Runtime { const INDEXING_PREFIX: &'static [u8] = b"mmr"; type Hashing = Keccak256; @@ -300,7 +293,7 @@ parameter_types! { pub struct BeefyDummyDataProvider; -impl beefy_primitives::mmr::BeefyDataProvider<()> for BeefyDummyDataProvider { +impl sp_beefy::mmr::BeefyDataProvider<()> for BeefyDummyDataProvider { fn extra_data() {} } @@ -574,6 +567,16 @@ pub type Executive = frame_executive::Executive< AllPalletsWithSystem, >; +/// MMR helper types. +mod mmr { + use super::Runtime; + pub use pallet_mmr::primitives::*; + + pub type Leaf = <::LeafData as LeafDataProvider>::LeafData; + pub type Hash = ::Hash; + pub type Hashing = ::Hashing; +} + impl_runtime_apis! { impl sp_api::Core for Runtime { fn version() -> RuntimeVersion { @@ -622,66 +625,30 @@ impl_runtime_apis! { } } - impl beefy_primitives::BeefyApi for Runtime { + impl sp_beefy::BeefyApi for Runtime { fn validator_set() -> Option> { Beefy::validator_set() } } - impl sp_mmr_primitives::MmrApi for Runtime { - fn generate_proof(block_number: BlockNumber) - -> Result<(EncodableOpaqueLeaf, MmrProof), MmrError> - { - Mmr::generate_batch_proof(vec![block_number]) - .and_then(|(leaves, proof)| Ok(( - mmr::EncodableOpaqueLeaf::from_leaf(&leaves[0]), - mmr::BatchProof::into_single_leaf_proof(proof)? - ))) - } - - fn verify_proof(leaf: EncodableOpaqueLeaf, proof: MmrProof) - -> Result<(), MmrError> - { - pub type Leaf = < - ::LeafData as LeafDataProvider - >::LeafData; - - let leaf: Leaf = leaf - .into_opaque_leaf() - .try_decode() - .ok_or(MmrError::Verify)?; - Mmr::verify_leaves(vec![leaf], mmr::Proof::into_batch_proof(proof)) - } - - fn verify_proof_stateless( - root: Hash, - leaf: EncodableOpaqueLeaf, - proof: MmrProof - ) -> Result<(), MmrError> { - let node = DataOrHash::Data(leaf.into_opaque_leaf()); - pallet_mmr::verify_leaves_proof::( - root, - vec![node], - pallet_mmr::primitives::Proof::into_batch_proof(proof), - ) - } - - fn mmr_root() -> Result { + impl pallet_mmr::primitives::MmrApi< + Block, + mmr::Hash, + BlockNumber, + > for Runtime { + fn mmr_root() -> Result { Ok(Mmr::mmr_root()) } - fn generate_batch_proof(block_numbers: Vec) - -> Result<(Vec, mmr::BatchProof), mmr::Error> - { - Mmr::generate_batch_proof(block_numbers) - .map(|(leaves, proof)| (leaves.into_iter().map(|leaf| mmr::EncodableOpaqueLeaf::from_leaf(&leaf)).collect(), proof)) + fn mmr_leaf_count() -> Result { + Ok(Mmr::mmr_leaves()) } - fn generate_historical_batch_proof( + fn generate_proof( block_numbers: Vec, - best_known_block_number: BlockNumber - ) -> Result<(Vec, mmr::BatchProof), mmr::Error> { - Mmr::generate_historical_batch_proof(block_numbers, best_known_block_number).map( + best_known_block_number: Option, + ) -> Result<(Vec, mmr::Proof), mmr::Error> { + Mmr::generate_proof(block_numbers, best_known_block_number).map( |(leaves, proof)| { ( leaves @@ -694,26 +661,23 @@ impl_runtime_apis! { ) } - fn verify_batch_proof(leaves: Vec, proof: mmr::BatchProof) + fn verify_proof(leaves: Vec, proof: mmr::Proof) -> Result<(), mmr::Error> { - type Leaf = < - ::LeafData as LeafDataProvider - >::LeafData; let leaves = leaves.into_iter().map(|leaf| leaf.into_opaque_leaf() .try_decode() - .ok_or(mmr::Error::Verify)).collect::, mmr::Error>>()?; + .ok_or(mmr::Error::Verify)).collect::, mmr::Error>>()?; Mmr::verify_leaves(leaves, proof) } - fn verify_batch_proof_stateless( - root: MmrHash, + fn verify_proof_stateless( + root: mmr::Hash, leaves: Vec, - proof: mmr::BatchProof + proof: mmr::Proof ) -> Result<(), mmr::Error> { let nodes = leaves.into_iter().map(|leaf|mmr::DataOrHash::Data(leaf.into_opaque_leaf())).collect(); - pallet_mmr::verify_leaves_proof::(root, nodes, proof) + pallet_mmr::verify_leaves_proof::(root, nodes, proof) } } diff --git a/bridges/bin/rialto/runtime/src/xcm_config.rs b/bridges/bin/rialto/runtime/src/xcm_config.rs index 02729f7565914..a86593f47f9d3 100644 --- a/bridges/bin/rialto/runtime/src/xcm_config.rs +++ b/bridges/bin/rialto/runtime/src/xcm_config.rs @@ -28,6 +28,7 @@ use bridge_runtime_common::{ use frame_support::{ parameter_types, traits::{ConstU32, Everything, Nothing}, + weights::Weight, }; use xcm::latest::prelude::*; use xcm_builder::{ @@ -91,7 +92,8 @@ pub const BASE_XCM_WEIGHT: u64 = 1_000_000_000; parameter_types! { /// The amount of weight an XCM operation takes. This is a safe overestimate. - pub const BaseXcmWeight: u64 = BASE_XCM_WEIGHT; + // TODO: https://github.com/paritytech/parity-bridges-common/issues/1543 - check `set_proof_size` 0 or 64*1024 or 1026? + pub const BaseXcmWeight: Weight = Weight::from_parts(BASE_XCM_WEIGHT, 0); /// Maximum number of instructions in a single XCM fragment. A sanity check against weight /// calculations getting too crazy. pub const MaxInstructions: u32 = 100; @@ -142,6 +144,7 @@ impl xcm_executor::Config for XcmConfig { type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; + type SafeCallFilter = Everything; } /// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior @@ -151,6 +154,11 @@ pub type LocalOriginToLocation = ( SignedToAccountId32, ); +#[cfg(feature = "runtime-benchmarks")] +parameter_types! { + pub ReachableDest: Option = todo!("We dont use benchmarks for pallet_xcm, so if you hit this message, you need to remove this and define value instead"); +} + impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; // We don't allow any messages to be sent via the transaction yet. This is basically safe to @@ -180,6 +188,9 @@ impl pallet_xcm::Config for Runtime { type TrustedLockers = (); type SovereignAccountOf = SovereignAccountOf; type MaxLockers = frame_support::traits::ConstU32<8>; + type WeightInfo = pallet_xcm::TestWeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type ReachableDest = ReachableDest; } /// With-Millau bridge. diff --git a/bridges/bin/runtime-common/src/messages.rs b/bridges/bin/runtime-common/src/messages.rs index 3e69463480db0..3974966daaddf 100644 --- a/bridges/bin/runtime-common/src/messages.rs +++ b/bridges/bin/runtime-common/src/messages.rs @@ -452,7 +452,7 @@ pub mod target { // I have no idea why this method takes `&mut` reference and there's nothing // about that in documentation. Hope it'll only mutate iff error is returned. let weight = XcmWeigher::weight(&mut payload.xcm.1); - let weight = Weight::from_ref_time(weight.unwrap_or_else(|e| { + let weight = weight.unwrap_or_else(|e| { log::debug!( target: "runtime::bridge-dispatch", "Failed to compute dispatch weight of incoming XCM message {:?}/{}: {:?}", @@ -463,8 +463,8 @@ pub mod target { // we shall return 0 and then the XCM executor will fail to execute XCM // if we'll return something else (e.g. maximal value), the lane may stuck - 0 - })); + Weight::zero() + }); payload.weight = Some(weight); weight @@ -498,8 +498,8 @@ pub mod target { location, xcm, hash, - weight_limit.unwrap_or_else(Weight::zero).ref_time(), - weight_credit.ref_time(), + weight_limit.unwrap_or_else(Weight::zero), + weight_credit, ); Ok(xcm_outcome) }; diff --git a/bridges/bin/runtime-common/src/refund_relayer_extension.rs b/bridges/bin/runtime-common/src/refund_relayer_extension.rs index b4ed3ca58935e..0038af975db75 100644 --- a/bridges/bin/runtime-common/src/refund_relayer_extension.rs +++ b/bridges/bin/runtime-common/src/refund_relayer_extension.rs @@ -648,7 +648,9 @@ mod tests { fn dispatch_info() -> DispatchInfo { DispatchInfo { - weight: frame_support::weights::constants::WEIGHT_PER_SECOND, + weight: Weight::from_ref_time( + frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND, + ), class: frame_support::dispatch::DispatchClass::Normal, pays_fee: frame_support::dispatch::Pays::Yes, } diff --git a/bridges/modules/beefy/Cargo.toml b/bridges/modules/beefy/Cargo.toml index 923b35410888a..2dca89d82e5db 100644 --- a/bridges/modules/beefy/Cargo.toml +++ b/bridges/modules/beefy/Cargo.toml @@ -25,7 +25,7 @@ sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } [dev-dependencies] -beefy-primitives = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-beefy = { git = "https://github.com/paritytech/substrate", branch = "master" } mmr-lib = { package = "ckb-merkle-mountain-range", version = "0.3.2" } pallet-beefy-mmr = { git = "https://github.com/paritytech/substrate", branch = "master" } pallet-mmr = { git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/bridges/modules/beefy/src/lib.rs b/bridges/modules/beefy/src/lib.rs index 5ef58c5a3cbb4..e05a4119463dc 100644 --- a/bridges/modules/beefy/src/lib.rs +++ b/bridges/modules/beefy/src/lib.rs @@ -152,6 +152,7 @@ pub mod pallet { BridgedMmrHashing: 'static + Send + Sync, { /// Initialize pallet with BEEFY authority set and best known finalized block number. + #[pallet::call_index(0)] #[pallet::weight((T::DbWeight::get().reads_writes(2, 3), DispatchClass::Operational))] pub fn initialize( origin: OriginFor, @@ -169,6 +170,7 @@ pub mod pallet { /// Change `PalletOwner`. /// /// May only be called either by root, or by `PalletOwner`. + #[pallet::call_index(1)] #[pallet::weight((T::DbWeight::get().reads_writes(1, 1), DispatchClass::Operational))] pub fn set_owner(origin: OriginFor, new_owner: Option) -> DispatchResult { >::set_owner(origin, new_owner) @@ -177,6 +179,7 @@ pub mod pallet { /// Halt or resume all pallet operations. /// /// May only be called either by root, or by `PalletOwner`. + #[pallet::call_index(2)] #[pallet::weight((T::DbWeight::get().reads_writes(1, 1), DispatchClass::Operational))] pub fn set_operating_mode( origin: OriginFor, @@ -193,6 +196,7 @@ pub mod pallet { /// /// If successful in verification, it will update the underlying storage with the data /// provided in the newly submitted commitment. + #[pallet::call_index(3)] #[pallet::weight(0)] pub fn submit_commitment( origin: OriginFor, @@ -410,12 +414,12 @@ pub mod pallet { #[cfg(test)] mod tests { use super::*; - use beefy_primitives::mmr::BeefyAuthoritySet; use bp_runtime::{BasicOperatingMode, OwnedBridgeModuleError}; use bp_test_utils::generate_owned_bridge_module_tests; use frame_support::{assert_noop, assert_ok, traits::Get}; use mock::*; use mock_chain::*; + use sp_beefy::mmr::BeefyAuthoritySet; use sp_runtime::DispatchError; fn next_block() { diff --git a/bridges/modules/beefy/src/mock.rs b/bridges/modules/beefy/src/mock.rs index a07f7962a44d8..1a028f159343b 100644 --- a/bridges/modules/beefy/src/mock.rs +++ b/bridges/modules/beefy/src/mock.rs @@ -32,7 +32,7 @@ use sp_runtime::{ Perbill, }; -pub use beefy_primitives::crypto::{AuthorityId as BeefyId, Pair as BeefyPair}; +pub use sp_beefy::crypto::{AuthorityId as BeefyId, Pair as BeefyPair}; use sp_core::crypto::Wraps; use sp_runtime::traits::Keccak256; @@ -49,7 +49,7 @@ pub type TestBridgedMmrHashing = BridgedMmrHashing; pub type TestBridgedMmrHash = BridgedMmrHash; pub type TestBridgedBeefyMmrLeafExtra = BridgedBeefyMmrLeafExtra; pub type TestBridgedMmrProof = BridgedMmrProof; -pub type TestBridgedRawMmrLeaf = beefy_primitives::mmr::MmrLeaf< +pub type TestBridgedRawMmrLeaf = sp_beefy::mmr::MmrLeaf< TestBridgedBlockNumber, TestBridgedBlockHash, TestBridgedMmrHash, @@ -138,7 +138,7 @@ impl ChainWithBeefy for TestBridgedChain { type MmrHash = ::Output; type BeefyMmrLeafExtra = (); type AuthorityId = BeefyId; - type Signature = beefy_primitives::crypto::AuthoritySignature; + type Signature = sp_beefy::crypto::AuthoritySignature; type AuthorityIdToMerkleLeaf = pallet_beefy_mmr::BeefyEcdsaToEthereum; } diff --git a/bridges/modules/beefy/src/mock_chain.rs b/bridges/modules/beefy/src/mock_chain.rs index 4896f9bf90925..ca7e84b121a95 100644 --- a/bridges/modules/beefy/src/mock_chain.rs +++ b/bridges/modules/beefy/src/mock_chain.rs @@ -26,11 +26,11 @@ use crate::{ utils::get_authorities_mmr_root, }; -use beefy_primitives::mmr::{BeefyNextAuthoritySet, MmrLeafVersion}; use bp_beefy::{BeefyPayload, Commitment, ValidatorSetId, MMR_ROOT_PAYLOAD_ID}; use codec::Encode; use pallet_mmr::NodeIndex; use rand::Rng; +use sp_beefy::mmr::{BeefyNextAuthoritySet, MmrLeafVersion}; use sp_core::Pair; use sp_runtime::traits::{Hash, Header as HeaderT}; use std::collections::HashMap; @@ -188,7 +188,7 @@ impl HeaderBuilder { next_validator_keys.iter().map(|pair| pair.public()).collect::>(); let next_validators_mmr_root = get_authorities_mmr_root::(next_validators.iter()); - let leaf = beefy_primitives::mmr::MmrLeaf { + let leaf = sp_beefy::mmr::MmrLeaf { version: MmrLeafVersion::new(1, 0), parent_number_and_hash: (header.number().saturating_sub(1), *header.parent_hash()), beefy_next_authority_set: BeefyNextAuthoritySet { @@ -227,7 +227,7 @@ impl HeaderBuilder { let leaf_index = *self.header.number() - 1; let leaf_count = *self.header.number(); self.leaf_proof = Some(f(TestBridgedMmrProof { - leaf_index, + leaf_indices: vec![leaf_index], leaf_count, items: proof.proof_items().iter().map(|i| i.hash()).collect(), })); diff --git a/bridges/modules/beefy/src/utils.rs b/bridges/modules/beefy/src/utils.rs index c8a7d2cee140a..11d601ae8860f 100644 --- a/bridges/modules/beefy/src/utils.rs +++ b/bridges/modules/beefy/src/utils.rs @@ -3,7 +3,7 @@ use crate::{ BridgedBeefyCommitmentHasher, BridgedBeefyMmrLeaf, BridgedBeefySignedCommitment, BridgedChain, BridgedMmrHash, BridgedMmrHashing, BridgedMmrProof, Config, Error, LOG_TARGET, }; -use bp_beefy::{merkle_root, verify_mmr_leaves_proof, BeefyVerify, MmrDataOrHash, MmrProof}; +use bp_beefy::{merkle_root, verify_mmr_leaves_proof, BeefyVerify, MmrDataOrHash}; use codec::Encode; use frame_support::ensure; use sp_runtime::traits::{Convert, Hash}; @@ -131,7 +131,6 @@ pub(crate) fn verify_beefy_mmr_leaf, I: 'static>( mmr_proof: BridgedMmrProof, mmr_root: BridgedMmrHash, ) -> Result<(), Error> { - let mmr_proof_leaf_index = mmr_proof.leaf_index; let mmr_proof_leaf_count = mmr_proof.leaf_count; let mmr_proof_length = mmr_proof.items.len(); @@ -140,16 +139,15 @@ pub(crate) fn verify_beefy_mmr_leaf, I: 'static>( verify_mmr_leaves_proof( mmr_root, vec![BridgedMmrDataOrHash::::Hash(mmr_leaf_hash)], - MmrProof::into_batch_proof(mmr_proof), + mmr_proof, ) .map_err(|e| { log::error!( target: LOG_TARGET, - "MMR proof of leaf {:?} (root: {:?}, leaf: {}, leaf count: {}, len: {}) \ + "MMR proof of leaf {:?} (root: {:?}, leaf count: {}, len: {}) \ verification has failed with error: {:?}", mmr_leaf_hash, mmr_root, - mmr_proof_leaf_index, mmr_proof_leaf_count, mmr_proof_length, e, @@ -163,9 +161,9 @@ pub(crate) fn verify_beefy_mmr_leaf, I: 'static>( mod tests { use super::*; use crate::{mock::*, mock_chain::*, *}; - use beefy_primitives::ValidatorSet; use bp_beefy::{BeefyPayload, MMR_ROOT_PAYLOAD_ID}; use frame_support::{assert_noop, assert_ok}; + use sp_beefy::ValidatorSet; #[test] fn submit_commitment_checks_metadata() { @@ -280,7 +278,7 @@ mod tests { // Fails if mmr proof is incorrect. let mut header = ChainBuilder::new(1).append_finalized_header().to_header(); - header.leaf_proof.leaf_index += 1; + header.leaf_proof.leaf_indices[0] += 1; assert_noop!( import_commitment(header), Error::::MmrProofVerificationFailed, diff --git a/bridges/modules/grandpa/src/lib.rs b/bridges/modules/grandpa/src/lib.rs index 6853bb9cb3bb0..d3335693adfa7 100644 --- a/bridges/modules/grandpa/src/lib.rs +++ b/bridges/modules/grandpa/src/lib.rs @@ -150,6 +150,7 @@ pub mod pallet { /// /// If successful in verification, it will write the target header to the underlying storage /// pallet. + #[pallet::call_index(0)] #[pallet::weight(T::WeightInfo::submit_finality_proof( justification.commit.precommits.len().try_into().unwrap_or(u32::MAX), justification.votes_ancestries.len().try_into().unwrap_or(u32::MAX), @@ -221,6 +222,7 @@ pub mod pallet { /// This function is only allowed to be called from a trusted origin and writes to storage /// with practically no checks in terms of the validity of the data. It is important that /// you ensure that valid data is being passed in. + #[pallet::call_index(1)] #[pallet::weight((T::DbWeight::get().reads_writes(2, 5), DispatchClass::Operational))] pub fn initialize( origin: OriginFor, @@ -244,6 +246,7 @@ pub mod pallet { /// Change `PalletOwner`. /// /// May only be called either by root, or by `PalletOwner`. + #[pallet::call_index(2)] #[pallet::weight((T::DbWeight::get().reads_writes(1, 1), DispatchClass::Operational))] pub fn set_owner(origin: OriginFor, new_owner: Option) -> DispatchResult { >::set_owner(origin, new_owner) @@ -252,6 +255,7 @@ pub mod pallet { /// Halt or resume all pallet operations. /// /// May only be called either by root, or by `PalletOwner`. + #[pallet::call_index(3)] #[pallet::weight((T::DbWeight::get().reads_writes(1, 1), DispatchClass::Operational))] pub fn set_operating_mode( origin: OriginFor, diff --git a/bridges/modules/messages/src/lib.rs b/bridges/modules/messages/src/lib.rs index b8d79b83b4187..680518d9dc8b2 100644 --- a/bridges/modules/messages/src/lib.rs +++ b/bridges/modules/messages/src/lib.rs @@ -226,6 +226,7 @@ pub mod pallet { /// Change `PalletOwner`. /// /// May only be called either by root, or by `PalletOwner`. + #[pallet::call_index(0)] #[pallet::weight((T::DbWeight::get().reads_writes(1, 1), DispatchClass::Operational))] pub fn set_owner(origin: OriginFor, new_owner: Option) -> DispatchResult { >::set_owner(origin, new_owner) @@ -234,6 +235,7 @@ pub mod pallet { /// Halt or resume all/some pallet operations. /// /// May only be called either by root, or by `PalletOwner`. + #[pallet::call_index(1)] #[pallet::weight((T::DbWeight::get().reads_writes(1, 1), DispatchClass::Operational))] pub fn set_operating_mode( origin: OriginFor, @@ -247,6 +249,7 @@ pub mod pallet { /// The weight of the call assumes that the transaction always brings outbound lane /// state update. Because of that, the submitter (relayer) has no benefit of not including /// this data in the transaction, so reward confirmations lags should be minimal. + #[pallet::call_index(2)] #[pallet::weight(T::WeightInfo::receive_messages_proof_weight(proof, *messages_count, *dispatch_weight))] pub fn receive_messages_proof( origin: OriginFor, @@ -399,6 +402,7 @@ pub mod pallet { } /// Receive messages delivery proof from bridged chain. + #[pallet::call_index(3)] #[pallet::weight(T::WeightInfo::receive_messages_delivery_proof_weight( proof, relayers_state, diff --git a/bridges/modules/parachains/src/lib.rs b/bridges/modules/parachains/src/lib.rs index 633b39329a012..47ab91928c7b7 100644 --- a/bridges/modules/parachains/src/lib.rs +++ b/bridges/modules/parachains/src/lib.rs @@ -263,6 +263,7 @@ pub mod pallet { /// `polkadot-runtime-parachains::paras` pallet instance, deployed at the bridged chain. /// The proof is supposed to be crafted at the `relay_header_hash` that must already be /// imported by corresponding GRANDPA pallet at this chain. + #[pallet::call_index(0)] #[pallet::weight(WeightInfoOf::::submit_parachain_heads_weight( T::DbWeight::get(), parachain_heads_proof, @@ -395,6 +396,7 @@ pub mod pallet { /// Change `PalletOwner`. /// /// May only be called either by root, or by `PalletOwner`. + #[pallet::call_index(1)] #[pallet::weight((T::DbWeight::get().reads_writes(1, 1), DispatchClass::Operational))] pub fn set_owner(origin: OriginFor, new_owner: Option) -> DispatchResult { >::set_owner(origin, new_owner) @@ -403,6 +405,7 @@ pub mod pallet { /// Halt or resume all pallet operations. /// /// May only be called either by root, or by `PalletOwner`. + #[pallet::call_index(2)] #[pallet::weight((T::DbWeight::get().reads_writes(1, 1), DispatchClass::Operational))] pub fn set_operating_mode( origin: OriginFor, diff --git a/bridges/modules/relayers/src/lib.rs b/bridges/modules/relayers/src/lib.rs index 27ffcaf1ea523..b28d17cf5a4fd 100644 --- a/bridges/modules/relayers/src/lib.rs +++ b/bridges/modules/relayers/src/lib.rs @@ -65,6 +65,7 @@ pub mod pallet { #[pallet::call] impl Pallet { /// Claim accumulated rewards. + #[pallet::call_index(0)] #[pallet::weight(T::WeightInfo::claim_rewards())] pub fn claim_rewards(origin: OriginFor, lane_id: LaneId) -> DispatchResult { let relayer = ensure_signed(origin)?; diff --git a/bridges/primitives/beefy/Cargo.toml b/bridges/primitives/beefy/Cargo.toml index e619e52cfc22e..cc8360c7106ac 100644 --- a/bridges/primitives/beefy/Cargo.toml +++ b/bridges/primitives/beefy/Cargo.toml @@ -18,7 +18,7 @@ bp-runtime = { path = "../runtime", default-features = false } # Substrate Dependencies beefy-merkle-tree = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } -beefy-primitives = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-beefy = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-beefy-mmr = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } pallet-mmr = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } @@ -28,7 +28,6 @@ sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", d [features] default = ["std"] std = [ - "beefy-primitives/std", "bp-runtime/std", "codec/std", "frame-support/std", @@ -36,6 +35,7 @@ std = [ "pallet-mmr/std", "scale-info/std", "serde", + "sp-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 a0a096bdce17c..f16c10820070d 100644 --- a/bridges/primitives/beefy/src/lib.rs +++ b/bridges/primitives/beefy/src/lib.rs @@ -20,18 +20,18 @@ #![warn(missing_docs)] pub use beefy_merkle_tree::{merkle_root, Keccak256 as BeefyKeccak256}; -pub use beefy_primitives::{ +pub use pallet_beefy_mmr::BeefyEcdsaToEthereum; +pub use pallet_mmr::{ + primitives::{DataOrHash as MmrDataOrHash, Proof as MmrProof}, + verify_leaves_proof as verify_mmr_leaves_proof, +}; +pub use sp_beefy::{ crypto::{AuthorityId as EcdsaValidatorId, AuthoritySignature as EcdsaValidatorSignature}, known_payloads::MMR_ROOT_ID as MMR_ROOT_PAYLOAD_ID, mmr::{BeefyAuthoritySet, MmrLeafVersion}, BeefyAuthorityId, BeefyVerify, Commitment, Payload as BeefyPayload, SignedCommitment, ValidatorSet, ValidatorSetId, BEEFY_ENGINE_ID, }; -pub use pallet_beefy_mmr::BeefyEcdsaToEthereum; -pub use pallet_mmr::{ - primitives::{DataOrHash as MmrDataOrHash, Proof as MmrProof}, - verify_leaves_proof as verify_mmr_leaves_proof, -}; use bp_runtime::{BasicOperatingMode, BlockNumberOf, Chain, HashOf}; use codec::{Decode, Encode}; @@ -99,7 +99,7 @@ pub type BeefyAuthorityIdOf = ::AuthorityId; /// BEEFY validator set, containing both validator identifiers and the numeric set id. pub type BeefyAuthoritySetOf = ValidatorSet>; /// BEEFY authority set, containing both validator identifiers and the numeric set id. -pub type BeefyAuthoritySetInfoOf = beefy_primitives::mmr::BeefyAuthoritySet>; +pub type BeefyAuthoritySetInfoOf = sp_beefy::mmr::BeefyAuthoritySet>; /// BEEFY validator signature used by given Substrate chain. pub type BeefyValidatorSignatureOf = ::Signature; /// Signed BEEFY commitment used by given Substrate chain. @@ -119,12 +119,8 @@ pub type BeefyMmrLeafExtraOf = ::BeefyMmrLeafExtra; /// the given Substrate chain. pub type BeefyAuthorityIdToMerkleLeafOf = ::AuthorityIdToMerkleLeaf; /// Actual type of leafs in the BEEFY MMR. -pub type BeefyMmrLeafOf = beefy_primitives::mmr::MmrLeaf< - BlockNumberOf, - HashOf, - MmrHashOf, - BeefyMmrLeafExtraOf, ->; +pub type BeefyMmrLeafOf = + sp_beefy::mmr::MmrLeaf, HashOf, MmrHashOf, BeefyMmrLeafExtraOf>; /// Data required for initializing the BEEFY pallet. /// diff --git a/bridges/primitives/chain-bridge-hub-cumulus/src/lib.rs b/bridges/primitives/chain-bridge-hub-cumulus/src/lib.rs index 0f5f33087edc7..72faabe43cd98 100644 --- a/bridges/primitives/chain-bridge-hub-cumulus/src/lib.rs +++ b/bridges/primitives/chain-bridge-hub-cumulus/src/lib.rs @@ -39,7 +39,8 @@ pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); /// time. /// /// This is a copy-paste from the cumulus repo's `parachains-common` crate. -pub const MAXIMUM_BLOCK_WEIGHT: Weight = constants::WEIGHT_PER_SECOND +// TODO: https://github.com/paritytech/parity-bridges-common/issues/1543 - remove `set_proof_size` +const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_ref_time(constants::WEIGHT_REF_TIME_PER_SECOND) .saturating_div(2) .set_proof_size(polkadot_primitives::v2::MAX_POV_SIZE as u64); @@ -55,9 +56,9 @@ parameter_types! { NORMAL_DISPATCH_RATIO, ); - pub const BlockExecutionWeight: Weight = constants::WEIGHT_PER_NANOS.saturating_mul(5_000_000); + pub const BlockExecutionWeight: Weight = Weight::from_ref_time(constants::WEIGHT_REF_TIME_PER_NANOS).saturating_mul(5_000_000); - pub const ExtrinsicBaseWeight: Weight = constants::WEIGHT_PER_NANOS.saturating_mul(125_000); + pub const ExtrinsicBaseWeight: Weight = Weight::from_ref_time(constants::WEIGHT_REF_TIME_PER_NANOS).saturating_mul(125_000); pub BlockWeights: limits::BlockWeights = limits::BlockWeights::builder() .base_block(BlockExecutionWeight::get()) diff --git a/bridges/primitives/chain-millau/src/lib.rs b/bridges/primitives/chain-millau/src/lib.rs index 2a4139e07cb99..5c3b7f18ab43f 100644 --- a/bridges/primitives/chain-millau/src/lib.rs +++ b/bridges/primitives/chain-millau/src/lib.rs @@ -27,7 +27,7 @@ use bp_messages::{ use bp_runtime::{decl_bridge_runtime_apis, Chain}; use frame_support::{ dispatch::DispatchClass, - weights::{constants::WEIGHT_PER_SECOND, IdentityFee, Weight}, + weights::{constants::WEIGHT_REF_TIME_PER_SECOND, IdentityFee, Weight}, RuntimeDebug, }; use frame_system::limits; @@ -60,7 +60,9 @@ pub const TX_EXTRA_BYTES: u32 = 103; /// /// This represents 0.5 seconds of compute assuming a target block time of six seconds. // TODO: https://github.com/paritytech/parity-bridges-common/issues/1543 - remove `set_proof_size` -pub const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND.set_proof_size(1_000).saturating_div(2); +pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_ref_time(WEIGHT_REF_TIME_PER_SECOND) + .set_proof_size(1_000) + .saturating_div(2); /// Represents the portion of a block that will be used by Normal extrinsics. pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); diff --git a/bridges/primitives/chain-rialto-parachain/src/lib.rs b/bridges/primitives/chain-rialto-parachain/src/lib.rs index 82b6a12c182a3..8a98ffe70619e 100644 --- a/bridges/primitives/chain-rialto-parachain/src/lib.rs +++ b/bridges/primitives/chain-rialto-parachain/src/lib.rs @@ -24,7 +24,7 @@ use bp_messages::{ use bp_runtime::{decl_bridge_runtime_apis, Chain, Parachain}; use frame_support::{ dispatch::DispatchClass, - weights::{constants::WEIGHT_PER_SECOND, IdentityFee, Weight}, + weights::{constants::WEIGHT_REF_TIME_PER_SECOND, IdentityFee, Weight}, RuntimeDebug, }; use frame_system::limits; @@ -55,7 +55,9 @@ pub const TX_EXTRA_BYTES: u32 = 104; /// /// This represents two seconds of compute assuming a target block time of six seconds. // TODO: https://github.com/paritytech/parity-bridges-common/issues/1543 - remove `set_proof_size` -pub const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND.set_proof_size(1_000).saturating_mul(2); +pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_ref_time(WEIGHT_REF_TIME_PER_SECOND) + .set_proof_size(1_000) + .saturating_mul(2); /// Represents the portion of a block that will be used by Normal extrinsics. pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); diff --git a/bridges/primitives/chain-rialto/src/lib.rs b/bridges/primitives/chain-rialto/src/lib.rs index 0b718ec52158e..5cf4f85f54a53 100644 --- a/bridges/primitives/chain-rialto/src/lib.rs +++ b/bridges/primitives/chain-rialto/src/lib.rs @@ -24,7 +24,7 @@ use bp_messages::{ use bp_runtime::{decl_bridge_runtime_apis, Chain}; use frame_support::{ dispatch::DispatchClass, - weights::{constants::WEIGHT_PER_SECOND, IdentityFee, Weight}, + weights::{constants::WEIGHT_REF_TIME_PER_SECOND, IdentityFee, Weight}, RuntimeDebug, }; use frame_system::limits; @@ -49,7 +49,9 @@ pub const TX_EXTRA_BYTES: u32 = 104; /// /// This represents two seconds of compute assuming a target block time of six seconds. // TODO: https://github.com/paritytech/parity-bridges-common/issues/1543 - remove `set_proof_size` -pub const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND.set_proof_size(1_000).saturating_mul(2); +pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_ref_time(WEIGHT_REF_TIME_PER_SECOND) + .set_proof_size(1_000) + .saturating_mul(2); /// Represents the portion of a block that will be used by Normal extrinsics. pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); diff --git a/bridges/primitives/polkadot-core/src/lib.rs b/bridges/primitives/polkadot-core/src/lib.rs index 8d9932ea58c52..7558ce762d026 100644 --- a/bridges/primitives/polkadot-core/src/lib.rs +++ b/bridges/primitives/polkadot-core/src/lib.rs @@ -23,7 +23,7 @@ use frame_support::{ dispatch::DispatchClass, parameter_types, weights::{ - constants::{BlockExecutionWeight, WEIGHT_PER_SECOND}, + constants::{BlockExecutionWeight, WEIGHT_REF_TIME_PER_SECOND}, Weight, }, Blake2_128Concat, RuntimeDebug, @@ -74,7 +74,9 @@ const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); /// /// This is a copy-paste from the Polkadot repo's `polkadot-runtime-common` crate. // TODO: https://github.com/paritytech/parity-bridges-common/issues/1543 - remove `set_proof_size` -pub const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND.set_proof_size(1_000).saturating_mul(2); +pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_ref_time(WEIGHT_REF_TIME_PER_SECOND) + .set_proof_size(1_000) + .saturating_mul(2); /// All Polkadot-like chains assume that an on-initialize consumes 1 percent of the weight on /// average, hence a single extrinsic will not be allowed to consume more than diff --git a/bridges/primitives/runtime/src/chain.rs b/bridges/primitives/runtime/src/chain.rs index f5771e9fdd57e..94b3a193c5829 100644 --- a/bridges/primitives/runtime/src/chain.rs +++ b/bridges/primitives/runtime/src/chain.rs @@ -21,7 +21,7 @@ use num_traits::{AsPrimitive, Bounded, CheckedSub, Saturating, SaturatingAdd, Ze use sp_runtime::{ traits::{ AtLeast32Bit, AtLeast32BitUnsigned, Hash as HashT, Header as HeaderT, MaybeDisplay, - MaybeMallocSizeOf, MaybeSerialize, MaybeSerializeDeserialize, Member, SimpleBitOps, Verify, + MaybeSerialize, MaybeSerializeDeserialize, Member, SimpleBitOps, Verify, }, FixedPointOperand, }; @@ -107,7 +107,6 @@ pub trait Chain: Send + Sync + 'static { + MaybeDisplay + AtLeast32BitUnsigned + FromStr - + MaybeMallocSizeOf + AsPrimitive + Default + Saturating @@ -128,7 +127,6 @@ pub trait Chain: Send + Sync + 'static { + SimpleBitOps + AsRef<[u8]> + AsMut<[u8]> - + MaybeMallocSizeOf + MaxEncodedLen; /// A type that fulfills the abstract idea of what a Substrate hasher (a type diff --git a/bridges/relays/lib-substrate-relay/src/messages_lane.rs b/bridges/relays/lib-substrate-relay/src/messages_lane.rs index 61ea72853f43c..73d441cfcd381 100644 --- a/bridges/relays/lib-substrate-relay/src/messages_lane.rs +++ b/bridges/relays/lib-substrate-relay/src/messages_lane.rs @@ -495,7 +495,7 @@ mod tests { // Any significant change in this values should attract additional attention. // // TODO: https://github.com/paritytech/parity-bridges-common/issues/1543 - remove `set_proof_size` - (1024, Weight::from_ref_time(216_609_134_667).set_proof_size(217)), + (1024, Weight::from_ref_time(216_600_684_000).set_proof_size(217)), ); } }