diff --git a/bridges/bin/millau/node/src/service.rs b/bridges/bin/millau/node/src/service.rs index ce9cfc10ef101..b8d42f9c7ed34 100644 --- a/bridges/bin/millau/node/src/service.rs +++ b/bridges/bin/millau/node/src/service.rs @@ -210,6 +210,7 @@ pub fn new_full(mut config: Configuration) -> Result let warp_sync = Arc::new(sc_finality_grandpa::warp_proof::NetworkProvider::new( backend.clone(), grandpa_link.shared_authority_set().clone(), + vec![], )); let (network, system_rpc_tx, network_starter) = @@ -470,6 +471,7 @@ pub fn new_light(mut config: Configuration) -> Result let warp_sync = Arc::new(sc_finality_grandpa::warp_proof::NetworkProvider::new( backend.clone(), grandpa_link.shared_authority_set().clone(), + vec![], )); let (network, system_rpc_tx, network_starter) = diff --git a/bridges/bin/millau/runtime/Cargo.toml b/bridges/bin/millau/runtime/Cargo.toml index 7e2a5491f5b15..c8d7f0a159582 100644 --- a/bridges/bin/millau/runtime/Cargo.toml +++ b/bridges/bin/millau/runtime/Cargo.toml @@ -10,6 +10,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] hex-literal = "0.3" codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false, features = ["derive"] } +scale-info = { version = "1.0", default-features = false, features = ["derive"] } serde = { version = "1.0", optional = true, features = ["derive"] } # Bridge dependencies @@ -89,6 +90,7 @@ std = [ "pallet-timestamp/std", "pallet-transaction-payment-rpc-runtime-api/std", "pallet-transaction-payment/std", + "scale-info/std", "serde", "sp-api/std", "sp-block-builder/std", diff --git a/bridges/bin/millau/runtime/src/lib.rs b/bridges/bin/millau/runtime/src/lib.rs index 92d1c8614d23e..4e486c267010d 100644 --- a/bridges/bin/millau/runtime/src/lib.rs +++ b/bridges/bin/millau/runtime/src/lib.rs @@ -240,6 +240,7 @@ impl pallet_grandpa::Config for Runtime { type HandleEquivocation = (); // TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78) type WeightInfo = (); + type MaxAuthorities = MaxAuthorities; } parameter_types! { @@ -281,6 +282,7 @@ impl pallet_balances::Config for Runtime { parameter_types! { pub const TransactionBaseFee: Balance = 0; pub const TransactionByteFee: Balance = 1; + pub const OperationalFeeMultiplier: u8 = 5; // values for following parameters are copied from polkadot repo, but it is fine // not to sync them - we're not going to make Rialto a full copy of one of Polkadot-like chains pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25); @@ -291,6 +293,7 @@ parameter_types! { impl pallet_transaction_payment::Config for Runtime { type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter; type TransactionByteFee = TransactionByteFee; + type OperationalFeeMultiplier = OperationalFeeMultiplier; type WeightToFee = bp_millau::WeightToFee; type FeeMultiplierUpdate = pallet_transaction_payment::TargetedFeeAdjustment< Runtime, @@ -320,7 +323,6 @@ impl pallet_session::Config for Runtime { type SessionManager = pallet_shift_session_manager::Pallet; type SessionHandler = ::KeyTypeIdProviders; type Keys = SessionKeys; - type DisabledValidatorsThreshold = (); // TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78) type WeightInfo = (); } @@ -523,7 +525,7 @@ impl_runtime_apis! { impl sp_api::Metadata for Runtime { fn metadata() -> OpaqueMetadata { - Runtime::metadata().into() + OpaqueMetadata::new(Runtime::metadata().into()) } } diff --git a/bridges/bin/millau/runtime/src/rialto_messages.rs b/bridges/bin/millau/runtime/src/rialto_messages.rs index 37fc7715f989d..6d9677c45cf91 100644 --- a/bridges/bin/millau/runtime/src/rialto_messages.rs +++ b/bridges/bin/millau/runtime/src/rialto_messages.rs @@ -31,6 +31,7 @@ use frame_support::{ weights::{DispatchClass, Weight}, RuntimeDebug, }; +use scale_info::TypeInfo; use sp_runtime::{traits::Saturating, FixedPointNumber, FixedU128}; use sp_std::{convert::TryFrom, ops::RangeInclusive}; @@ -274,7 +275,7 @@ impl SourceHeaderChain for Rialto { } /// Millau -> Rialto message lane pallet parameters. -#[derive(RuntimeDebug, Clone, Encode, Decode, PartialEq, Eq)] +#[derive(RuntimeDebug, Clone, Encode, Decode, PartialEq, Eq, TypeInfo)] pub enum MillauToRialtoMessagesParameter { /// The conversion formula we use is: `MillauTokens = RialtoTokens * conversion_rate`. RialtoToMillauConversionRate(FixedU128), diff --git a/bridges/bin/rialto-parachain/runtime/Cargo.toml b/bridges/bin/rialto-parachain/runtime/Cargo.toml index d12e4326711d9..20ce70aba8f6b 100644 --- a/bridges/bin/rialto-parachain/runtime/Cargo.toml +++ b/bridges/bin/rialto-parachain/runtime/Cargo.toml @@ -13,6 +13,7 @@ substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", bran [dependencies] codec = { package = 'parity-scale-codec', version = '2.0.0', default-features = false, features = ['derive']} log = { version = "0.4.14", default-features = false } +scale-info = { version = "1.0", default-features = false, features = ["derive"] } serde = { version = '1.0', optional = true, features = ['derive'] } # Bridge depedencies @@ -83,8 +84,9 @@ runtime-benchmarks = [ std = [ "bp-rialto-parachain/std", "codec/std", - "serde", "log/std", + "scale-info/std", + "serde", "sp-api/std", "sp-std/std", "sp-io/std", diff --git a/bridges/bin/rialto-parachain/runtime/src/lib.rs b/bridges/bin/rialto-parachain/runtime/src/lib.rs index bf55f08eb4b96..5b71674b7fe9b 100644 --- a/bridges/bin/rialto-parachain/runtime/src/lib.rs +++ b/bridges/bin/rialto-parachain/runtime/src/lib.rs @@ -228,6 +228,7 @@ parameter_types! { pub const TransferFee: u128 = MILLIUNIT; pub const CreationFee: u128 = MILLIUNIT; pub const TransactionByteFee: u128 = MICROUNIT; + pub const OperationalFeeMultiplier: u8 = 5; pub const MaxLocks: u32 = 50; pub const MaxReserves: u32 = 50; } @@ -249,6 +250,7 @@ impl pallet_balances::Config for Runtime { impl pallet_transaction_payment::Config for Runtime { type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter; type TransactionByteFee = TransactionByteFee; + type OperationalFeeMultiplier = OperationalFeeMultiplier; type WeightToFee = IdentityFee; type FeeMultiplierUpdate = (); } @@ -486,7 +488,7 @@ impl_runtime_apis! { impl sp_api::Metadata for Runtime { fn metadata() -> OpaqueMetadata { - Runtime::metadata().into() + OpaqueMetadata::new(Runtime::metadata().into()) } } diff --git a/bridges/bin/rialto/node/Cargo.toml b/bridges/bin/rialto/node/Cargo.toml index 08c72ce67632a..75be9bcd9fb7d 100644 --- a/bridges/bin/rialto/node/Cargo.toml +++ b/bridges/bin/rialto/node/Cargo.toml @@ -14,6 +14,7 @@ futures = "0.3" jsonrpc-core = "18.0" kvdb = "0.10" kvdb-rocksdb = "0.12" +lru = "0.7" structopt = "0.3.21" serde_json = "1.0.59" thiserror = "1.0" diff --git a/bridges/bin/rialto/node/src/chain_spec.rs b/bridges/bin/rialto/node/src/chain_spec.rs index 8c6b147f48204..3ccfa13e74acb 100644 --- a/bridges/bin/rialto/node/src/chain_spec.rs +++ b/bridges/bin/rialto/node/src/chain_spec.rs @@ -264,7 +264,6 @@ fn testnet_genesis( ump_service_total_weight: 4 * 1_000_000_000, max_upward_message_size: 1024 * 1024, max_upward_message_num_per_candidate: 5, - _hrmp_open_request_ttl: 5, hrmp_sender_deposit: 0, hrmp_recipient_deposit: 0, hrmp_channel_max_capacity: 8, diff --git a/bridges/bin/rialto/node/src/overseer.rs b/bridges/bin/rialto/node/src/overseer.rs index 1c381c1df8fdd..0139f3cdf835d 100644 --- a/bridges/bin/rialto/node/src/overseer.rs +++ b/bridges/bin/rialto/node/src/overseer.rs @@ -23,6 +23,7 @@ use crate::service::{AuthorityDiscoveryApi, Error}; use rialto_runtime::{opaque::Block, Hash}; +use lru::LruCache; use polkadot_availability_distribution::IncomingRequestReceivers; use polkadot_node_core_approval_voting::Config as ApprovalVotingConfig; use polkadot_node_core_av_store::Config as AvailabilityConfig; @@ -30,7 +31,10 @@ use polkadot_node_core_candidate_validation::Config as CandidateValidationConfig use polkadot_node_core_chain_selection::Config as ChainSelectionConfig; use polkadot_node_core_dispute_coordinator::Config as DisputeCoordinatorConfig; use polkadot_node_network_protocol::request_response::{v1 as request_v1, IncomingRequestReceiver}; -use polkadot_overseer::{AllSubsystems, BlockInfo, Overseer, OverseerHandle}; +use polkadot_overseer::{ + metrics::Metrics as OverseerMetrics, BlockInfo, MetricsTrait, Overseer, OverseerBuilder, + OverseerConnector, OverseerHandle, +}; use polkadot_primitives::v1::ParachainHost; use sc_authority_discovery::Service as AuthorityDiscoveryService; use sc_client_api::AuxStore; @@ -107,12 +111,11 @@ where pub dispute_coordinator_config: DisputeCoordinatorConfig, } -/// Create a default, unaltered set of subsystems. -/// -/// A convenience for usage with malus, to avoid -/// repetitive code across multiple behavior strain implementations. -pub fn create_default_subsystems( +/// Obtain a prepared `OverseerBuilder`, that is initialized +/// with all default values. +pub fn prepared_overseer_builder<'a, Spawner, RuntimeClient>( OverseerGenArgs { + leaves, keystore, runtime_client, parachains_db, @@ -120,6 +123,7 @@ pub fn create_default_subsystems( authority_discovery_service, pov_req_receiver, chunk_req_receiver, + collation_req_receiver: _, available_data_req_receiver, statement_req_receiver, dispute_req_receiver, @@ -130,10 +134,11 @@ pub fn create_default_subsystems( candidate_validation_config, chain_selection_config, dispute_coordinator_config, - .. - }: OverseerGenArgs<'_, Spawner, RuntimeClient>, + }: OverseerGenArgs<'a, Spawner, RuntimeClient>, ) -> Result< - AllSubsystems< + OverseerBuilder< + Spawner, + Arc, CandidateValidationSubsystem, CandidateBackingSubsystem, StatementDistributionSubsystem, @@ -153,7 +158,7 @@ pub fn create_default_subsystems( CollatorProtocolSubsystem, ApprovalDistributionSubsystem, ApprovalVotingSubsystem, - GossipSupportSubsystem, + GossipSupportSubsystem, DisputeCoordinatorSubsystem, DisputeParticipationSubsystem, DisputeDistributionSubsystem, @@ -167,86 +172,104 @@ where Spawner: 'static + SpawnNamed + Clone + Unpin, { use polkadot_node_subsystem_util::metrics::Metrics; + use std::iter::FromIterator; + + let metrics = ::register(registry)?; - let all_subsystems = AllSubsystems { - availability_distribution: AvailabilityDistributionSubsystem::new( + let builder = Overseer::builder() + .availability_distribution(AvailabilityDistributionSubsystem::new( keystore.clone(), IncomingRequestReceivers { pov_req_receiver, chunk_req_receiver }, Metrics::register(registry)?, - ), - availability_recovery: AvailabilityRecoverySubsystem::with_chunks_only( + )) + .availability_recovery(AvailabilityRecoverySubsystem::with_chunks_only( available_data_req_receiver, Metrics::register(registry)?, - ), - availability_store: AvailabilityStoreSubsystem::new( + )) + .availability_store(AvailabilityStoreSubsystem::new( parachains_db.clone(), availability_config, Metrics::register(registry)?, - ), - bitfield_distribution: BitfieldDistributionSubsystem::new(Metrics::register(registry)?), - bitfield_signing: BitfieldSigningSubsystem::new( + )) + .bitfield_distribution(BitfieldDistributionSubsystem::new(Metrics::register(registry)?)) + .bitfield_signing(BitfieldSigningSubsystem::new( spawner.clone(), keystore.clone(), Metrics::register(registry)?, - ), - candidate_backing: CandidateBackingSubsystem::new( + )) + .candidate_backing(CandidateBackingSubsystem::new( spawner.clone(), keystore.clone(), Metrics::register(registry)?, - ), - candidate_validation: CandidateValidationSubsystem::with_config( + )) + .candidate_validation(CandidateValidationSubsystem::with_config( candidate_validation_config, Metrics::register(registry)?, // candidate-validation metrics Metrics::register(registry)?, // validation host metrics - ), - chain_api: ChainApiSubsystem::new(runtime_client.clone(), Metrics::register(registry)?), - collation_generation: CollationGenerationSubsystem::new(Metrics::register(registry)?), - collator_protocol: CollatorProtocolSubsystem::new(ProtocolSide::Validator { + )) + .chain_api(ChainApiSubsystem::new(runtime_client.clone(), Metrics::register(registry)?)) + .collation_generation(CollationGenerationSubsystem::new(Metrics::register(registry)?)) + .collator_protocol(CollatorProtocolSubsystem::new(ProtocolSide::Validator { keystore: keystore.clone(), eviction_policy: Default::default(), metrics: Metrics::register(registry)?, - }), - network_bridge: NetworkBridgeSubsystem::new( + })) + .network_bridge(NetworkBridgeSubsystem::new( network_service.clone(), authority_discovery_service.clone(), Box::new(network_service.clone()), Metrics::register(registry)?, - ), - provisioner: ProvisionerSubsystem::new(spawner.clone(), (), Metrics::register(registry)?), - runtime_api: RuntimeApiSubsystem::new( - runtime_client, + )) + .provisioner(ProvisionerSubsystem::new(spawner.clone(), (), Metrics::register(registry)?)) + .runtime_api(RuntimeApiSubsystem::new( + runtime_client.clone(), Metrics::register(registry)?, - spawner, - ), - statement_distribution: StatementDistributionSubsystem::new( + spawner.clone(), + )) + .statement_distribution(StatementDistributionSubsystem::new( keystore.clone(), statement_req_receiver, Metrics::register(registry)?, - ), - approval_distribution: ApprovalDistributionSubsystem::new(Metrics::register(registry)?), - approval_voting: ApprovalVotingSubsystem::with_config( + )) + .approval_distribution(ApprovalDistributionSubsystem::new(Metrics::register(registry)?)) + .approval_voting(ApprovalVotingSubsystem::with_config( approval_voting_config, parachains_db.clone(), keystore.clone(), - Box::new(network_service), + Box::new(network_service.clone()), Metrics::register(registry)?, - ), - gossip_support: GossipSupportSubsystem::new(keystore.clone()), - dispute_coordinator: DisputeCoordinatorSubsystem::new( + )) + .gossip_support(GossipSupportSubsystem::new( + keystore.clone(), + authority_discovery_service.clone(), + )) + .dispute_coordinator(DisputeCoordinatorSubsystem::new( parachains_db.clone(), dispute_coordinator_config, keystore.clone(), - ), - dispute_participation: DisputeParticipationSubsystem::new(), - dispute_distribution: DisputeDistributionSubsystem::new( - keystore, + Metrics::register(registry)?, + )) + .dispute_participation(DisputeParticipationSubsystem::new()) + .dispute_distribution(DisputeDistributionSubsystem::new( + keystore.clone(), dispute_req_receiver, - authority_discovery_service, + authority_discovery_service.clone(), Metrics::register(registry)?, - ), - chain_selection: ChainSelectionSubsystem::new(chain_selection_config, parachains_db), - }; - Ok(all_subsystems) + )) + .chain_selection(ChainSelectionSubsystem::new(chain_selection_config, parachains_db)) + .leaves(Vec::from_iter( + leaves + .into_iter() + .map(|BlockInfo { hash, parent_hash: _, number }| (hash, number)), + )) + .activation_external_listeners(Default::default()) + .span_per_active_leaf(Default::default()) + .active_leaves(Default::default()) + .supports_parachains(runtime_client) + .known_leaves(LruCache::new(KNOWN_LEAVES_CACHE_SIZE)) + .metrics(metrics) + .spawner(spawner); + Ok(builder) } /// Trait for the `fn` generating the overseer. @@ -255,9 +278,10 @@ where /// would do. pub trait OverseerGen { /// Overwrite the full generation of the overseer, including the subsystems. - fn generate( + fn generate<'a, Spawner, RuntimeClient>( &self, - args: OverseerGenArgs<'_, Spawner, RuntimeClient>, + connector: OverseerConnector, + args: OverseerGenArgs<'a, Spawner, RuntimeClient>, ) -> Result<(Overseer>, OverseerHandle), Error> where RuntimeClient: 'static + ProvideRuntimeApi + HeaderBackend + AuxStore, @@ -265,34 +289,31 @@ pub trait OverseerGen { Spawner: 'static + SpawnNamed + Clone + Unpin, { let gen = RealOverseerGen; - RealOverseerGen::generate::(&gen, args) + RealOverseerGen::generate::(&gen, connector, args) } // It would be nice to make `create_subsystems` part of this trait, // but the amount of generic arguments that would be required as // as consequence make this rather annoying to implement and use. } +use polkadot_overseer::KNOWN_LEAVES_CACHE_SIZE; + /// The regular set of subsystems. pub struct RealOverseerGen; impl OverseerGen for RealOverseerGen { - fn generate( + fn generate<'a, Spawner, RuntimeClient>( &self, - args: OverseerGenArgs<'_, Spawner, RuntimeClient>, + connector: OverseerConnector, + args: OverseerGenArgs<'a, Spawner, RuntimeClient>, ) -> Result<(Overseer>, OverseerHandle), Error> where RuntimeClient: 'static + ProvideRuntimeApi + HeaderBackend + AuxStore, RuntimeClient::Api: ParachainHost + BabeApi + AuthorityDiscoveryApi, Spawner: 'static + SpawnNamed + Clone + Unpin, { - let spawner = args.spawner.clone(); - let leaves = args.leaves.clone(); - let runtime_client = args.runtime_client.clone(); - let registry = args.registry; - - let all_subsystems = create_default_subsystems::(args)?; - - Overseer::new(leaves, all_subsystems, registry, runtime_client, spawner) + prepared_overseer_builder(args)? + .build_with_connector(connector) .map_err(|e| e.into()) } } diff --git a/bridges/bin/rialto/node/src/service.rs b/bridges/bin/rialto/node/src/service.rs index 8a2a38a59c60b..6e9eb8a62e46f 100644 --- a/bridges/bin/rialto/node/src/service.rs +++ b/bridges/bin/rialto/node/src/service.rs @@ -33,7 +33,7 @@ use polkadot_node_core_candidate_validation::Config as CandidateValidationConfig use polkadot_node_core_chain_selection::Config as ChainSelectionConfig; use polkadot_node_core_dispute_coordinator::Config as DisputeCoordinatorConfig; use polkadot_node_network_protocol::request_response::IncomingRequest; -use polkadot_overseer::BlockInfo; +use polkadot_overseer::{BlockInfo, OverseerConnector}; use polkadot_primitives::v1::BlockId; use rialto_runtime::{self, opaque::Block, RuntimeApi}; use sc_client_api::ExecutorProvider; @@ -47,7 +47,7 @@ use sp_runtime::traits::{BlakeTwo256, Block as BlockT}; use std::{sync::Arc, time::Duration}; use substrate_prometheus_endpoint::Registry; -pub use polkadot_overseer::{Handle, Overseer, OverseerHandle}; +pub use polkadot_overseer::Handle; pub use polkadot_primitives::v1::ParachainHost; pub use sc_client_api::AuxStore; pub use sp_authority_discovery::AuthorityDiscoveryApi; @@ -432,6 +432,8 @@ where let prometheus_registry = config.prometheus_registry().cloned(); + let overseer_connector = OverseerConnector::default(); + let shared_voter_state = rpc_setup; let auth_disc_publish_non_global_ips = config.network.allow_non_globals_in_dht; @@ -462,6 +464,7 @@ where let warp_sync = Arc::new(sc_finality_grandpa::warp_proof::NetworkProvider::new( backend.clone(), import_setup.1.shared_authority_set().clone(), + vec![], )); let (network, system_rpc_tx, network_starter) = @@ -586,50 +589,55 @@ where let overseer_handle = if let Some((authority_discovery_service, keystore)) = maybe_params { let (overseer, overseer_handle) = overseer_gen - .generate::(OverseerGenArgs { - leaves: active_leaves, - keystore, - runtime_client: overseer_client.clone(), - parachains_db, - availability_config, - approval_voting_config, - network_service: network.clone(), - authority_discovery_service, - registry: prometheus_registry.as_ref(), - spawner, - candidate_validation_config, - available_data_req_receiver, - chain_selection_config, - chunk_req_receiver, - collation_req_receiver, - dispute_coordinator_config, - dispute_req_receiver, - pov_req_receiver, - statement_req_receiver, - })?; - let handle = Handle::Connected(overseer_handle); - let handle_clone = handle.clone(); - - task_manager.spawn_essential_handle().spawn_blocking( - "overseer", - Box::pin(async move { - use futures::{pin_mut, select, FutureExt}; - - let forward = polkadot_overseer::forward_events(overseer_client, handle_clone); - - let forward = forward.fuse(); - let overseer_fut = overseer.run().fuse(); - - pin_mut!(overseer_fut); - pin_mut!(forward); - - select! { - _ = forward => (), - _ = overseer_fut => (), - complete => (), - } - }), - ); + .generate::( + overseer_connector, + OverseerGenArgs { + leaves: active_leaves, + keystore, + runtime_client: overseer_client.clone(), + parachains_db, + availability_config, + approval_voting_config, + network_service: network.clone(), + authority_discovery_service, + registry: prometheus_registry.as_ref(), + spawner, + candidate_validation_config, + available_data_req_receiver, + chain_selection_config, + chunk_req_receiver, + collation_req_receiver, + dispute_coordinator_config, + dispute_req_receiver, + pov_req_receiver, + statement_req_receiver, + }, + )?; + let handle = Handle::new(overseer_handle.clone()); + + { + let handle = handle.clone(); + task_manager.spawn_essential_handle().spawn_blocking( + "overseer", + Box::pin(async move { + use futures::{pin_mut, select, FutureExt}; + + let forward = polkadot_overseer::forward_events(overseer_client, handle); + + let forward = forward.fuse(); + let overseer_fut = overseer.run().fuse(); + + pin_mut!(overseer_fut); + pin_mut!(forward); + + select! { + _ = forward => (), + _ = overseer_fut => (), + complete => (), + } + }), + ); + } Some(handle) } else { diff --git a/bridges/bin/rialto/runtime/Cargo.toml b/bridges/bin/rialto/runtime/Cargo.toml index 8f532448d4080..c0be917c2bccc 100644 --- a/bridges/bin/rialto/runtime/Cargo.toml +++ b/bridges/bin/rialto/runtime/Cargo.toml @@ -12,6 +12,7 @@ codec = { package = "parity-scale-codec", version = "2.2.0", default-features = hex-literal = "0.3" libsecp256k1 = { version = "0.7", optional = true, default-features = false, features = ["hmac"] } log = { version = "0.4.14", default-features = false } +scale-info = { version = "1.0", default-features = false, features = ["derive"] } serde = { version = "1.0", optional = true, features = ["derive"] } # Bridge dependencies @@ -112,6 +113,7 @@ std = [ "polkadot-primitives/std", "polkadot-runtime-common/std", "polkadot-runtime-parachains/std", + "scale-info/std", "serde", "sp-api/std", "sp-authority-discovery/std", diff --git a/bridges/bin/rialto/runtime/src/exchange.rs b/bridges/bin/rialto/runtime/src/exchange.rs index f940287ff76a2..4e18053e52e36 100644 --- a/bridges/bin/rialto/runtime/src/exchange.rs +++ b/bridges/bin/rialto/runtime/src/exchange.rs @@ -35,13 +35,14 @@ use bp_eth_poa::{transaction_decode_rlp, RawTransaction, RawTransactionReceipt}; use codec::{Decode, Encode}; use frame_support::RuntimeDebug; use hex_literal::hex; +use scale_info::TypeInfo; use sp_std::vec::Vec; /// Ethereum address where locked PoA funds must be sent to. pub const LOCK_FUNDS_ADDRESS: [u8; 20] = hex!("DEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF"); /// Ethereum transaction inclusion proof. -#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug)] +#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo)] pub struct EthereumTransactionInclusionProof { /// Hash of the block with transaction. pub block: sp_core::H256, @@ -58,7 +59,7 @@ pub struct EthereumTransactionInclusionProof { /// transactions included into finalized blocks. This is obviously true /// for any existing eth-like chain (that keep current TX format), because /// otherwise transaction can be replayed over and over. -#[derive(Encode, Decode, PartialEq, RuntimeDebug)] +#[derive(Encode, Decode, PartialEq, RuntimeDebug, TypeInfo)] pub struct EthereumTransactionTag { /// Account that has locked funds. pub account: [u8; 20], diff --git a/bridges/bin/rialto/runtime/src/lib.rs b/bridges/bin/rialto/runtime/src/lib.rs index 9e70dae32efaa..bf5a8b36ec195 100644 --- a/bridges/bin/rialto/runtime/src/lib.rs +++ b/bridges/bin/rialto/runtime/src/lib.rs @@ -226,11 +226,13 @@ pub const BABE_GENESIS_EPOCH_CONFIG: sp_consensus_babe::BabeEpochConfiguration = parameter_types! { pub const EpochDuration: u64 = bp_rialto::EPOCH_DURATION_IN_SLOTS as u64; pub const ExpectedBlockTime: bp_rialto::Moment = bp_rialto::time_units::MILLISECS_PER_BLOCK; + pub const MaxAuthorities: u32 = 10; } impl pallet_babe::Config for Runtime { type EpochDuration = EpochDuration; type ExpectedBlockTime = ExpectedBlockTime; + type MaxAuthorities = MaxAuthorities; // session module is the trigger type EpochChangeTrigger = pallet_babe::ExternalTrigger; @@ -370,6 +372,7 @@ impl bp_currency_exchange::DepositInto for DepositInto { impl pallet_grandpa::Config for Runtime { type Event = Event; type Call = Call; + type MaxAuthorities = MaxAuthorities; type KeyOwnerProofSystem = (); type KeyOwnerProof = >::Proof; @@ -421,6 +424,7 @@ impl pallet_balances::Config for Runtime { parameter_types! { pub const TransactionBaseFee: Balance = 0; pub const TransactionByteFee: Balance = 1; + pub const OperationalFeeMultiplier: u8 = 5; // values for following parameters are copied from polkadot repo, but it is fine // not to sync them - we're not going to make Rialto a full copy of one of Polkadot-like chains pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25); @@ -431,6 +435,7 @@ parameter_types! { impl pallet_transaction_payment::Config for Runtime { type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter; type TransactionByteFee = TransactionByteFee; + type OperationalFeeMultiplier = OperationalFeeMultiplier; type WeightToFee = bp_rialto::WeightToFee; type FeeMultiplierUpdate = pallet_transaction_payment::TargetedFeeAdjustment< Runtime, @@ -454,15 +459,10 @@ impl pallet_session::Config for Runtime { type SessionManager = pallet_shift_session_manager::Pallet; type SessionHandler = ::KeyTypeIdProviders; type Keys = SessionKeys; - type DisabledValidatorsThreshold = (); // TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78) type WeightInfo = (); } -parameter_types! { - pub const MaxAuthorities: u32 = 10; -} - impl pallet_authority_discovery::Config for Runtime { type MaxAuthorities = MaxAuthorities; } @@ -662,7 +662,7 @@ impl_runtime_apis! { impl sp_api::Metadata for Runtime { fn metadata() -> OpaqueMetadata { - Runtime::metadata().into() + OpaqueMetadata::new(Runtime::metadata().into()) } } @@ -783,7 +783,7 @@ impl_runtime_apis! { slot_duration: Babe::slot_duration(), epoch_length: EpochDuration::get(), c: BABE_GENESIS_EPOCH_CONFIG.c, - genesis_authorities: Babe::authorities(), + genesis_authorities: Babe::authorities().to_vec(), randomness: Babe::randomness(), allowed_slots: BABE_GENESIS_EPOCH_CONFIG.allowed_slots, } @@ -902,6 +902,10 @@ impl_runtime_apis! { ) -> Option { polkadot_runtime_parachains::runtime_api_impl::v1::validation_code_by_hash::(hash) } + + fn on_chain_votes() -> Option> { + polkadot_runtime_parachains::runtime_api_impl::v1::on_chain_votes::() + } } impl sp_authority_discovery::AuthorityDiscoveryApi for Runtime { @@ -1172,7 +1176,7 @@ impl_runtime_apis! { MessagesProofSize::Minimal(ref size) => vec![0u8; *size as _], _ => vec![], }; - let call = Call::System(SystemCall::remark(remark)); + let call = Call::System(SystemCall::remark { remark }); let call_weight = call.get_dispatch_info().weight; let millau_account_id: bp_millau::AccountId = Default::default(); diff --git a/bridges/bin/rialto/runtime/src/millau_messages.rs b/bridges/bin/rialto/runtime/src/millau_messages.rs index 0342f5b48ab39..13a1c6b06ec21 100644 --- a/bridges/bin/rialto/runtime/src/millau_messages.rs +++ b/bridges/bin/rialto/runtime/src/millau_messages.rs @@ -31,6 +31,7 @@ use frame_support::{ weights::{DispatchClass, Weight}, RuntimeDebug, }; +use scale_info::TypeInfo; use sp_runtime::{traits::Saturating, FixedPointNumber, FixedU128}; use sp_std::{convert::TryFrom, ops::RangeInclusive}; @@ -272,7 +273,7 @@ impl SourceHeaderChain for Millau { } /// Rialto -> Millau message lane pallet parameters. -#[derive(RuntimeDebug, Clone, Encode, Decode, PartialEq, Eq)] +#[derive(RuntimeDebug, Clone, Encode, Decode, PartialEq, Eq, TypeInfo)] pub enum RialtoToMillauMessagesParameter { /// The conversion formula we use is: `RialtoTokens = MillauTokens * conversion_rate`. MillauToRialtoConversionRate(FixedU128), @@ -315,7 +316,7 @@ mod tests { SystemConfig::default().build_storage::().unwrap().into(); ext.execute_with(|| { let bridge = MILLAU_CHAIN_ID; - let call: Call = SystemCall::remark(vec![]).into(); + let call: Call = SystemCall::remark { remark: vec![] }.into(); let dispatch_weight = call.get_dispatch_info().weight; let dispatch_fee = ::WeightToFee::calc( &dispatch_weight, diff --git a/bridges/bin/rialto/runtime/src/parachains.rs b/bridges/bin/rialto/runtime/src/parachains.rs index a84723a725770..9a2f85460153c 100644 --- a/bridges/bin/rialto/runtime/src/parachains.rs +++ b/bridges/bin/rialto/runtime/src/parachains.rs @@ -39,7 +39,9 @@ impl polkadot_runtime_parachains::inclusion::RewardValidators for RewardValidato // all required parachain modules from `polkadot-runtime-parachains` crate -impl parachains_configuration::Config for Runtime {} +impl parachains_configuration::Config for Runtime { + type WeightInfo = parachains_configuration::TestWeightInfo; +} impl parachains_dmp::Config for Runtime {} @@ -58,6 +60,7 @@ impl parachains_inclusion::Config for Runtime { impl parachains_initializer::Config for Runtime { type Randomness = pallet_babe::RandomnessFromOneEpochAgo; type ForceOrigin = EnsureRoot; + type WeightInfo = (); } impl parachains_origin::Config for Runtime {} @@ -65,6 +68,7 @@ impl parachains_origin::Config for Runtime {} impl parachains_paras::Config for Runtime { type Origin = Origin; type Event = Event; + type WeightInfo = parachains_paras::TestWeightInfo; } impl parachains_paras_inherent::Config for Runtime {} @@ -83,6 +87,7 @@ impl parachains_ump::Config for Runtime { type Event = Event; type UmpSink = (); type FirstMessageFactorPercent = FirstMessageFactorPercent; + type ExecuteOverweightOrigin = EnsureRoot; } // required onboarding pallets. We're not going to use auctions or crowdloans, so they're missing @@ -112,6 +117,7 @@ impl slots::Config for Runtime { type Registrar = Registrar; type LeasePeriod = LeasePeriod; type WeightInfo = slots::TestWeightInfo; + type LeaseOffset = (); } impl paras_sudo_wrapper::Config for Runtime {} diff --git a/bridges/bin/runtime-common/Cargo.toml b/bridges/bin/runtime-common/Cargo.toml index 9c98e55207d5d..0ae642ba55898 100644 --- a/bridges/bin/runtime-common/Cargo.toml +++ b/bridges/bin/runtime-common/Cargo.toml @@ -11,6 +11,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false, features = ["derive"] } ed25519-dalek = { version = "1.0", default-features = false, optional = true } hash-db = { version = "0.15.2", default-features = false } +scale-info = { version = "1.0", default-features = false, features = ["derive"] } # Bridge dependencies @@ -44,6 +45,7 @@ std = [ "pallet-bridge-grandpa/std", "pallet-bridge-messages/std", "pallet-transaction-payment/std", + "scale-info/std", "sp-core/std", "sp-runtime/std", "sp-state-machine/std", diff --git a/bridges/bin/runtime-common/src/messages.rs b/bridges/bin/runtime-common/src/messages.rs index ecca6e823c699..7c9bb685ae6c1 100644 --- a/bridges/bin/runtime-common/src/messages.rs +++ b/bridges/bin/runtime-common/src/messages.rs @@ -37,6 +37,7 @@ use frame_support::{ RuntimeDebug, }; use hash_db::Hasher; +use scale_info::TypeInfo; use sp_runtime::{ traits::{AtLeast32BitUnsigned, CheckedAdd, CheckedDiv, CheckedMul, Saturating, Zero}, FixedPointNumber, FixedPointOperand, FixedU128, @@ -216,7 +217,7 @@ pub mod source { /// - hash of finalized header; /// - storage proof of inbound lane state; /// - lane id. - #[derive(Clone, Decode, Encode, Eq, PartialEq, RuntimeDebug)] + #[derive(Clone, Decode, Encode, Eq, PartialEq, RuntimeDebug, TypeInfo)] pub struct FromBridgedChainMessagesDeliveryProof { /// Hash of the bridge header the proof is for. pub bridged_header_hash: BridgedHeaderHash, @@ -456,7 +457,7 @@ pub mod target { /// - storage proof of messages and (optionally) outbound lane state; /// - lane id; /// - nonces (inclusive range) of messages which are included in this proof. - #[derive(Clone, Decode, Encode, Eq, PartialEq, RuntimeDebug)] + #[derive(Clone, Decode, Encode, Eq, PartialEq, RuntimeDebug, TypeInfo)] pub struct FromBridgedChainMessagesProof { /// Hash of the finalized bridged header the proof is for. pub bridged_header_hash: BridgedHeaderHash, diff --git a/bridges/modules/currency-exchange/Cargo.toml b/bridges/modules/currency-exchange/Cargo.toml index e842bf10dd533..dc06a342cc8e6 100644 --- a/bridges/modules/currency-exchange/Cargo.toml +++ b/bridges/modules/currency-exchange/Cargo.toml @@ -9,6 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false } log = { version = "0.4.14", default-features = false } +scale-info = { version = "1.0", default-features = false, features = ["derive"] } serde = { version = "1.0", optional = true } # Bridge dependencies @@ -38,6 +39,7 @@ std = [ "frame-support/std", "frame-system/std", "log/std", + "scale-info/std", "serde", "sp-runtime/std", "sp-std/std", diff --git a/bridges/modules/dispatch/Cargo.toml b/bridges/modules/dispatch/Cargo.toml index 94b19305ab3c9..7a8a34ab4c0ea 100644 --- a/bridges/modules/dispatch/Cargo.toml +++ b/bridges/modules/dispatch/Cargo.toml @@ -9,6 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false } log = { version = "0.4.14", default-features = false } +scale-info = { version = "1.0", default-features = false, features = ["derive"] } # Bridge dependencies @@ -34,6 +35,7 @@ std = [ "frame-support/std", "frame-system/std", "log/std", + "scale-info/std", "sp-core/std", "sp-runtime/std", "sp-std/std", diff --git a/bridges/modules/dispatch/src/lib.rs b/bridges/modules/dispatch/src/lib.rs index 3039c6e31654d..f467bab0d9464 100644 --- a/bridges/modules/dispatch/src/lib.rs +++ b/bridges/modules/dispatch/src/lib.rs @@ -22,7 +22,6 @@ //! a successful dispatch an event is emitted. #![cfg_attr(not(feature = "std"), no_std)] -#![warn(missing_docs)] // Generated by `decl_event!` #![allow(clippy::unused_unit)] @@ -111,7 +110,6 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - #[pallet::metadata(::AccountId = "AccountId", BridgeMessageIdOf = "BridgeMessageId")] pub enum Event, I: 'static = ()> { /// Message has been rejected before reaching dispatch. MessageRejected(ChainId, BridgeMessageIdOf), @@ -431,6 +429,7 @@ mod tests { use codec::Decode; use frame_support::{parameter_types, weights::Weight}; use frame_system::{EventRecord, Phase}; + use scale_info::TypeInfo; use sp_core::H256; use sp_runtime::{ testing::Header, @@ -444,7 +443,7 @@ mod tests { const SOURCE_CHAIN_ID: ChainId = *b"srce"; const TARGET_CHAIN_ID: ChainId = *b"trgt"; - #[derive(Debug, Encode, Decode, Clone, PartialEq, Eq)] + #[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo)] pub struct TestAccountPublic(AccountId); impl IdentifyAccount for TestAccountPublic { @@ -455,7 +454,7 @@ mod tests { } } - #[derive(Debug, Encode, Decode, Clone, PartialEq, Eq)] + #[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo)] pub struct TestSignature(AccountId); impl Verify for TestSignature { @@ -548,7 +547,7 @@ mod tests { impl Contains for TestCallFilter { fn contains(call: &Call) -> bool { - !matches!(*call, Call::System(frame_system::Call::fill_block(_))) + !matches!(*call, Call::System(frame_system::Call::fill_block { .. })) } } @@ -611,9 +610,9 @@ mod tests { let id = [0; 4]; const BAD_SPEC_VERSION: SpecVersion = 99; - let mut message = prepare_root_message(Call::System( - >::remark(vec![1, 2, 3]), - )); + let mut message = prepare_root_message(Call::System(frame_system::Call::remark { + remark: vec![1, 2, 3], + })); let weight = message.weight; message.spec_version = BAD_SPEC_VERSION; @@ -650,7 +649,7 @@ mod tests { fn should_fail_on_weight_mismatch() { new_test_ext().execute_with(|| { let id = [0; 4]; - let call = Call::System(>::remark(vec![1, 2, 3])); + let call = Call::System(frame_system::Call::remark { remark: vec![1, 2, 3] }); let call_weight = call.get_dispatch_info().weight; let mut message = prepare_root_message(call); message.weight = 7; @@ -693,7 +692,7 @@ mod tests { let call_origin = CallOrigin::TargetAccount(1, TestAccountPublic(1), TestSignature(99)); let message = prepare_message( call_origin, - Call::System(>::remark(vec![1, 2, 3])), + Call::System(frame_system::Call::remark { remark: vec![1, 2, 3] }), ); let weight = message.weight; @@ -757,9 +756,9 @@ mod tests { new_test_ext().execute_with(|| { let id = [0; 4]; - let mut message = prepare_root_message(Call::System( - >::remark(vec![1, 2, 3]), - )); + let mut message = prepare_root_message(Call::System(frame_system::Call::remark { + remark: vec![1, 2, 3], + })); let weight = message.weight; message.call.0 = vec![]; @@ -795,9 +794,8 @@ mod tests { new_test_ext().execute_with(|| { let id = [0; 4]; - let call = Call::System(>::fill_block( - Perbill::from_percent(75), - )); + let call = + Call::System(frame_system::Call::fill_block { ratio: Perbill::from_percent(75) }); let weight = call.get_dispatch_info().weight; let mut message = prepare_root_message(call); message.weight = weight; @@ -834,9 +832,9 @@ mod tests { new_test_ext().execute_with(|| { let id = [0; 4]; - let mut message = prepare_root_message(Call::System( - >::remark(vec![1, 2, 3]), - )); + let mut message = prepare_root_message(Call::System(frame_system::Call::remark { + remark: vec![1, 2, 3], + })); let weight = message.weight; message.dispatch_fee_payment = DispatchFeePayment::AtTargetChain; @@ -874,9 +872,9 @@ mod tests { new_test_ext().execute_with(|| { let id = [0; 4]; - let mut message = prepare_root_message(Call::System( - >::remark(vec![1, 2, 3]), - )); + let mut message = prepare_root_message(Call::System(frame_system::Call::remark { + remark: vec![1, 2, 3], + })); message.dispatch_fee_payment = DispatchFeePayment::AtTargetChain; System::set_block_number(1); @@ -910,7 +908,7 @@ mod tests { new_test_ext().execute_with(|| { let id = [0; 4]; - let call = Call::System(>::set_heap_pages(1)); + let call = Call::System(frame_system::Call::set_heap_pages { pages: 1 }); let message = prepare_target_message(call); System::set_block_number(1); @@ -943,9 +941,9 @@ mod tests { fn should_dispatch_bridge_message_from_root_origin() { new_test_ext().execute_with(|| { let id = [0; 4]; - let message = prepare_root_message(Call::System( - >::remark(vec![1, 2, 3]), - )); + let message = prepare_root_message(Call::System(frame_system::Call::remark { + remark: vec![1, 2, 3], + })); System::set_block_number(1); let result = Dispatch::dispatch( @@ -978,7 +976,7 @@ mod tests { new_test_ext().execute_with(|| { let id = [0; 4]; - let call = Call::System(>::remark(vec![])); + let call = Call::System(frame_system::Call::remark { remark: vec![] }); let message = prepare_target_message(call); System::set_block_number(1); @@ -1012,7 +1010,7 @@ mod tests { new_test_ext().execute_with(|| { let id = [0; 4]; - let call = Call::System(>::remark(vec![])); + let call = Call::System(frame_system::Call::remark { remark: vec![] }); let message = prepare_source_message(call); System::set_block_number(1); @@ -1043,7 +1041,7 @@ mod tests { #[test] fn origin_is_checked_when_verifying_sending_message_using_source_root_account() { - let call = Call::System(>::remark(vec![])); + let call = Call::System(frame_system::Call::remark { remark: vec![] }); let message = prepare_root_message(call); // When message is sent by Root, CallOrigin::SourceRoot is allowed @@ -1055,7 +1053,7 @@ mod tests { #[test] fn origin_is_checked_when_verifying_sending_message_using_target_account() { - let call = Call::System(>::remark(vec![])); + let call = Call::System(frame_system::Call::remark { remark: vec![] }); let message = prepare_target_message(call); // When message is sent by Root, CallOrigin::TargetAccount is not allowed @@ -1071,7 +1069,7 @@ mod tests { #[test] fn origin_is_checked_when_verifying_sending_message_using_source_account() { - let call = Call::System(>::remark(vec![])); + let call = Call::System(frame_system::Call::remark { remark: vec![] }); let message = prepare_source_message(call); // Sending a message from the expected origin account works diff --git a/bridges/modules/ethereum/Cargo.toml b/bridges/modules/ethereum/Cargo.toml index ce890fa2abb78..baa9336118079 100644 --- a/bridges/modules/ethereum/Cargo.toml +++ b/bridges/modules/ethereum/Cargo.toml @@ -10,6 +10,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false } libsecp256k1 = { version = "0.7", default-features = false, features = ["hmac"], optional = true } log = { version = "0.4.14", default-features = false } +scale-info = { version = "1.0", default-features = false, features = ["derive"] } serde = { version = "1.0", optional = true } # Bridge dependencies @@ -38,6 +39,7 @@ std = [ "frame-support/std", "frame-system/std", "log/std", + "scale-info/std", "serde", "sp-io/std", "sp-runtime/std", diff --git a/bridges/modules/ethereum/src/finality.rs b/bridges/modules/ethereum/src/finality.rs index 34b766f7e0219..fe8841fcc044f 100644 --- a/bridges/modules/ethereum/src/finality.rs +++ b/bridges/modules/ethereum/src/finality.rs @@ -17,6 +17,7 @@ use crate::{error::Error, Storage}; use bp_eth_poa::{public_to_address, Address, AuraHeader, HeaderId, SealedEmptyStep, H256}; use codec::{Decode, Encode}; +use scale_info::TypeInfo; use sp_io::crypto::secp256k1_ecdsa_recover; use sp_runtime::RuntimeDebug; use sp_std::{ @@ -55,7 +56,7 @@ pub struct FinalityEffects { } /// Finality votes for given block. -#[derive(RuntimeDebug, Decode, Encode)] +#[derive(RuntimeDebug, Decode, Encode, TypeInfo)] #[cfg_attr(test, derive(Clone, PartialEq))] pub struct FinalityVotes { /// Number of votes per each validator. @@ -66,7 +67,7 @@ pub struct FinalityVotes { } /// Information about block ancestor that is used in computations. -#[derive(RuntimeDebug, Decode, Encode)] +#[derive(RuntimeDebug, Decode, Encode, TypeInfo)] #[cfg_attr(test, derive(Clone, Default, PartialEq))] pub struct FinalityAncestor { /// Bock id. diff --git a/bridges/modules/ethereum/src/lib.rs b/bridges/modules/ethereum/src/lib.rs index ad2382a949001..4224818ad96c6 100644 --- a/bridges/modules/ethereum/src/lib.rs +++ b/bridges/modules/ethereum/src/lib.rs @@ -24,6 +24,7 @@ use bp_eth_poa::{ }; use codec::{Decode, Encode}; use frame_support::traits::Get; +use scale_info::TypeInfo; use sp_runtime::RuntimeDebug; use sp_std::{boxed::Box, cmp::Ord, collections::btree_map::BTreeMap, prelude::*}; @@ -81,7 +82,7 @@ pub struct PoolConfiguration { } /// Block header as it is stored in the runtime storage. -#[derive(Clone, Encode, Decode, PartialEq, RuntimeDebug)] +#[derive(Clone, Encode, Decode, PartialEq, RuntimeDebug, TypeInfo)] pub struct StoredHeader { /// Submitter of this header. May be `None` if header has been submitted /// using unsigned transaction. @@ -102,7 +103,7 @@ pub struct StoredHeader { } /// Validators set as it is stored in the runtime storage. -#[derive(Encode, Decode, PartialEq, RuntimeDebug)] +#[derive(Encode, Decode, PartialEq, RuntimeDebug, TypeInfo)] #[cfg_attr(test, derive(Clone))] pub struct ValidatorsSet { /// Validators of this set. @@ -114,7 +115,7 @@ pub struct ValidatorsSet { } /// Validators set change as it is stored in the runtime storage. -#[derive(Encode, Decode, PartialEq, RuntimeDebug)] +#[derive(Encode, Decode, PartialEq, RuntimeDebug, TypeInfo)] #[cfg_attr(test, derive(Clone))] pub struct AuraScheduledChange { /// Validators of this set. @@ -158,7 +159,7 @@ pub struct ChangeToEnact { } /// Blocks range that we want to prune. -#[derive(Encode, Decode, Default, RuntimeDebug, Clone, PartialEq)] +#[derive(Encode, Decode, Default, RuntimeDebug, Clone, PartialEq, TypeInfo)] struct PruningRange { /// Number of the oldest unpruned block(s). This might be the block that we do not /// want to prune now (then it is equal to `oldest_block_to_keep`), or block that we @@ -478,7 +479,7 @@ pub mod pallet { fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity { match *call { - Self::Call::import_unsigned_header(ref header, ref receipts) => { + Self::Call::import_unsigned_header { ref header, ref receipts } => { let accept_result = verification::accept_aura_header_into_pool( &BridgeStorage::::new(), &T::AuraConfiguration::get(), diff --git a/bridges/modules/grandpa/Cargo.toml b/bridges/modules/grandpa/Cargo.toml index 020d24766dee1..e36b43585b9b6 100644 --- a/bridges/modules/grandpa/Cargo.toml +++ b/bridges/modules/grandpa/Cargo.toml @@ -12,6 +12,7 @@ codec = { package = "parity-scale-codec", version = "2.2.0", default-features = finality-grandpa = { version = "0.14.0", default-features = false } log = { version = "0.4.14", default-features = false } num-traits = { version = "0.2", default-features = false } +scale-info = { version = "1.0", default-features = false, features = ["derive"] } serde = { version = "1.0", optional = true } # Bridge Dependencies @@ -33,6 +34,7 @@ bp-test-utils = { path = "../../primitives/test-utils", default-features = false frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true } [dev-dependencies] +sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" } [features] @@ -47,6 +49,7 @@ std = [ "frame-system/std", "log/std", "num-traits/std", + "scale-info/std", "serde", "sp-finality-grandpa/std", "sp-runtime/std", diff --git a/bridges/modules/grandpa/src/mock.rs b/bridges/modules/grandpa/src/mock.rs index dcbae4e60f9bc..183a567791563 100644 --- a/bridges/modules/grandpa/src/mock.rs +++ b/bridges/modules/grandpa/src/mock.rs @@ -19,10 +19,11 @@ use bp_runtime::Chain; use frame_support::{construct_runtime, parameter_types, weights::Weight}; +use sp_core::sr25519::Signature; use sp_runtime::{ testing::{Header, H256}, traits::{BlakeTwo256, IdentityLookup}, - AnySignature, Perbill, + Perbill, }; pub type AccountId = u64; @@ -105,7 +106,7 @@ impl Chain for TestBridgedChain { type AccountId = AccountId; type Balance = u64; type Index = u64; - type Signature = AnySignature; + type Signature = Signature; } pub fn run_test(test: impl FnOnce() -> T) -> T { diff --git a/bridges/modules/messages/Cargo.toml b/bridges/modules/messages/Cargo.toml index cc0be45406556..6d52b899ea2bc 100644 --- a/bridges/modules/messages/Cargo.toml +++ b/bridges/modules/messages/Cargo.toml @@ -11,6 +11,7 @@ bitvec = { version = "0.20", default-features = false, features = ["alloc"] } codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false } log = { version = "0.4.14", default-features = false } num-traits = { version = "0.2", default-features = false } +scale-info = { version = "1.0", default-features = false, features = ["derive"] } serde = { version = "1.0.101", optional = true, features = ["derive"] } # Bridge dependencies @@ -45,6 +46,7 @@ std = [ "frame-system/std", "log/std", "num-traits/std", + "scale-info/std", "serde", "sp-core/std", "sp-runtime/std", diff --git a/bridges/modules/messages/src/lib.rs b/bridges/modules/messages/src/lib.rs index 8d2e239781cbb..119869d81e982 100644 --- a/bridges/modules/messages/src/lib.rs +++ b/bridges/modules/messages/src/lib.rs @@ -652,7 +652,6 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - #[pallet::metadata(T::Parameter = "Parameter")] pub enum Event, I: 'static = ()> { /// Pallet parameter has been updated. ParameterUpdated(T::Parameter), diff --git a/bridges/modules/messages/src/mock.rs b/bridges/modules/messages/src/mock.rs index 5cc905d912124..a333c95bb58b8 100644 --- a/bridges/modules/messages/src/mock.rs +++ b/bridges/modules/messages/src/mock.rs @@ -37,6 +37,7 @@ use frame_support::{ parameter_types, weights::{RuntimeDbWeight, Weight}, }; +use scale_info::TypeInfo; use sp_core::H256; use sp_runtime::{ testing::Header as SubstrateHeader, @@ -50,7 +51,7 @@ use std::{ pub type AccountId = u64; pub type Balance = u64; -#[derive(Decode, Encode, Clone, Debug, PartialEq, Eq)] +#[derive(Decode, Encode, Clone, Debug, PartialEq, Eq, TypeInfo)] pub struct TestPayload { /// Field that may be used to identify messages. pub id: u64, @@ -150,7 +151,7 @@ parameter_types! { pub const TestBridgedChainId: bp_runtime::ChainId = *b"test"; } -#[derive(Debug, Clone, Encode, Decode, PartialEq, Eq)] +#[derive(Debug, Clone, Encode, Decode, PartialEq, Eq, TypeInfo)] pub enum TestMessagesParameter { TokenConversionRate(FixedU128), } @@ -226,7 +227,7 @@ pub const PAYLOAD_REJECTED_BY_TARGET_CHAIN: TestPayload = message_payload(1, 50) pub type MessagesByLaneVec = Vec<(LaneId, ProvedLaneMessages>)>; /// Test messages proof. -#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq)] +#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo)] pub struct TestMessagesProof { pub result: Result, } @@ -255,7 +256,7 @@ impl From>, ()>> for TestMessagesProof { } /// Messages delivery proof used in tests. -#[derive(Debug, Encode, Decode, Eq, Clone, PartialEq)] +#[derive(Debug, Encode, Decode, Eq, Clone, PartialEq, TypeInfo)] pub struct TestMessagesDeliveryProof(pub Result<(LaneId, InboundLaneData), ()>); impl Size for TestMessagesDeliveryProof { diff --git a/bridges/modules/shift-session-manager/Cargo.toml b/bridges/modules/shift-session-manager/Cargo.toml index d42cb4341a616..9e3e15fddf897 100644 --- a/bridges/modules/shift-session-manager/Cargo.toml +++ b/bridges/modules/shift-session-manager/Cargo.toml @@ -8,6 +8,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false } +scale-info = { version = "1.0", default-features = false, features = ["derive"] } # Substrate Dependencies @@ -28,6 +29,7 @@ std = [ "frame-support/std", "frame-system/std", "pallet-session/std", + "scale-info/std", "sp-staking/std", "sp-std/std", ] diff --git a/bridges/modules/shift-session-manager/src/lib.rs b/bridges/modules/shift-session-manager/src/lib.rs index 511cbaa1cbeb6..06d0b3fb0f8d4 100644 --- a/bridges/modules/shift-session-manager/src/lib.rs +++ b/bridges/modules/shift-session-manager/src/lib.rs @@ -109,6 +109,7 @@ mod tests { traits::{BlakeTwo256, ConvertInto, IdentityLookup}, Perbill, RuntimeAppPublic, }, + traits::GenesisBuild, weights::Weight, BasicExternalities, }; @@ -177,7 +178,6 @@ mod tests { type SessionManager = (); type SessionHandler = TestSessionHandler; type Keys = UintAuthorityId; - type DisabledValidatorsThreshold = (); type WeightInfo = (); } @@ -197,7 +197,7 @@ mod tests { ) { } - fn on_disabled(_: usize) {} + fn on_disabled(_: u32) {} } fn new_test_ext() -> TestExternalities { diff --git a/bridges/modules/token-swap/Cargo.toml b/bridges/modules/token-swap/Cargo.toml index b68eed6d59e08..a6103f688c424 100644 --- a/bridges/modules/token-swap/Cargo.toml +++ b/bridges/modules/token-swap/Cargo.toml @@ -9,6 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false } log = { version = "0.4.14", default-features = false } +scale-info = { version = "1.0", default-features = false, features = ["derive"] } serde = { version = "1.0", optional = true } # Bridge dependencies @@ -46,6 +47,7 @@ std = [ "log/std", "pallet-bridge-dispatch/std", "pallet-bridge-messages/std", + "scale-info/std", "serde", "sp-core/std", "sp-io/std", diff --git a/bridges/primitives/chain-kusama/Cargo.toml b/bridges/primitives/chain-kusama/Cargo.toml index 061a89a7d877f..6ff860357c7c4 100644 --- a/bridges/primitives/chain-kusama/Cargo.toml +++ b/bridges/primitives/chain-kusama/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -smallvec = "1.6" +smallvec = "1.7" # Bridge Dependencies diff --git a/bridges/primitives/chain-millau/Cargo.toml b/bridges/primitives/chain-millau/Cargo.toml index a0630fa8a9ff0..f1e17fe96f5ac 100644 --- a/bridges/primitives/chain-millau/Cargo.toml +++ b/bridges/primitives/chain-millau/Cargo.toml @@ -17,6 +17,7 @@ hash256-std-hasher = { version = "0.15.2", default-features = false } impl-codec = { version = "0.5.1", default-features = false } impl-serde = { version = "0.3.1", optional = true } parity-util-mem = { version = "0.10", default-features = false, features = ["primitive-types"] } +scale-info = { version = "1.0", default-features = false, features = ["derive"] } serde = { version = "1.0", optional = true, features = ["derive"] } # Substrate Based Dependencies @@ -42,6 +43,7 @@ std = [ "impl-codec/std", "impl-serde", "parity-util-mem/std", + "scale-info/std", "serde", "sp-api/std", "sp-core/std", diff --git a/bridges/primitives/chain-millau/src/lib.rs b/bridges/primitives/chain-millau/src/lib.rs index 950c82d5224bb..0092f7092bc0d 100644 --- a/bridges/primitives/chain-millau/src/lib.rs +++ b/bridges/primitives/chain-millau/src/lib.rs @@ -29,6 +29,7 @@ use frame_support::{ Parameter, RuntimeDebug, }; use frame_system::limits; +use scale_info::TypeInfo; use sp_core::Hasher as HasherT; use sp_runtime::{ traits::{Convert, IdentifyAccount, Verify}, @@ -174,7 +175,7 @@ impl Chain for Millau { } /// Millau Hasher (Blake2-256 ++ Keccak-256) implementation. -#[derive(PartialEq, Eq, Clone, Copy, RuntimeDebug)] +#[derive(PartialEq, Eq, Clone, Copy, RuntimeDebug, TypeInfo)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub struct BlakeTwoAndKeccak256; diff --git a/bridges/primitives/chain-millau/src/millau_hash.rs b/bridges/primitives/chain-millau/src/millau_hash.rs index 936791217af18..11968b2f28267 100644 --- a/bridges/primitives/chain-millau/src/millau_hash.rs +++ b/bridges/primitives/chain-millau/src/millau_hash.rs @@ -15,6 +15,7 @@ // along with Parity Bridges Common. If not, see . use parity_util_mem::MallocSizeOf; +use scale_info::TypeInfo; use sp_runtime::traits::CheckEqual; // `sp_core::H512` can't be used, because it doesn't implement `CheckEqual`, which is required @@ -22,7 +23,7 @@ use sp_runtime::traits::CheckEqual; fixed_hash::construct_fixed_hash! { /// Hash type used in Millau chain. - #[derive(MallocSizeOf)] + #[derive(MallocSizeOf, TypeInfo)] pub struct MillauHash(64); } diff --git a/bridges/primitives/chain-polkadot/Cargo.toml b/bridges/primitives/chain-polkadot/Cargo.toml index 181b230d61dd6..917c7f9747839 100644 --- a/bridges/primitives/chain-polkadot/Cargo.toml +++ b/bridges/primitives/chain-polkadot/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -smallvec = "1.6" +smallvec = "1.7" # Bridge Dependencies diff --git a/bridges/primitives/chain-rococo/Cargo.toml b/bridges/primitives/chain-rococo/Cargo.toml index dd0d9b37e42cd..6e1189b05f363 100644 --- a/bridges/primitives/chain-rococo/Cargo.toml +++ b/bridges/primitives/chain-rococo/Cargo.toml @@ -8,7 +8,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] parity-scale-codec = { version = "2.2.0", default-features = false, features = ["derive"] } -smallvec = "1.6" +smallvec = "1.7" # Bridge Dependencies bp-messages = { path = "../messages", default-features = false } diff --git a/bridges/primitives/chain-westend/Cargo.toml b/bridges/primitives/chain-westend/Cargo.toml index 7230ba359c420..4fd1652744ed6 100644 --- a/bridges/primitives/chain-westend/Cargo.toml +++ b/bridges/primitives/chain-westend/Cargo.toml @@ -8,7 +8,8 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] parity-scale-codec = { version = "2.2.0", default-features = false, features = ["derive"] } -smallvec = "1.6" +scale-info = { version = "1.0", default-features = false, features = ["derive"] } +smallvec = "1.7" # Bridge Dependencies @@ -34,6 +35,7 @@ std = [ "bp-runtime/std", "frame-support/std", "parity-scale-codec/std", + "scale-info/std", "sp-api/std", "sp-runtime/std", "sp-std/std", diff --git a/bridges/primitives/chain-westend/src/lib.rs b/bridges/primitives/chain-westend/src/lib.rs index 480a5e56dd4c8..8beb897f59a15 100644 --- a/bridges/primitives/chain-westend/src/lib.rs +++ b/bridges/primitives/chain-westend/src/lib.rs @@ -21,10 +21,10 @@ #![allow(clippy::unnecessary_mut_passed)] use bp_messages::{LaneId, MessageDetails, MessageNonce, UnrewardedRelayersState}; -use bp_runtime::Chain; use frame_support::weights::{ WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, }; +use scale_info::TypeInfo; use sp_std::prelude::*; use sp_version::RuntimeVersion; @@ -51,8 +51,6 @@ impl WeightToFeePolynomial for WeightToFee { } } -pub type UncheckedExtrinsic = bp_polkadot_core::UncheckedExtrinsic; - // NOTE: This needs to be kept up to date with the Westend runtime found in the Polkadot repo. pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: sp_version::create_runtime_str!("westend"), @@ -66,32 +64,11 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { /// Westend Runtime `Call` enum. /// -/// The enum represents a subset of possible `Call`s we can send to Westend chain. -/// Ideally this code would be auto-generated from metadata, because we want to -/// avoid depending directly on the ENTIRE runtime just to get the encoding of `Dispatchable`s. -/// -/// All entries here (like pretty much in the entire file) must be kept in sync with Westend -/// `construct_runtime`, so that we maintain SCALE-compatibility. -/// -/// See: [link](https://github.com/paritytech/polkadot/blob/master/runtime/westend/src/lib.rs) -#[derive(parity_scale_codec::Encode, parity_scale_codec::Decode, Debug, PartialEq, Eq, Clone)] -pub enum Call { - /// Rococo bridge pallet. - #[codec(index = 40)] - BridgeGrandpaRococo(BridgeGrandpaRococoCall), -} - -#[derive(parity_scale_codec::Encode, parity_scale_codec::Decode, Debug, PartialEq, Eq, Clone)] -#[allow(non_camel_case_types)] -pub enum BridgeGrandpaRococoCall { - #[codec(index = 0)] - submit_finality_proof( - ::Header, - bp_header_chain::justification::GrandpaJustification<::Header>, - ), - #[codec(index = 1)] - initialize(bp_header_chain::InitializationData<::Header>), -} +/// We are not currently submitting any Westend transactions => it is empty. +#[derive( + parity_scale_codec::Encode, parity_scale_codec::Decode, Debug, PartialEq, Eq, Clone, TypeInfo, +)] +pub enum Call {} impl sp_runtime::traits::Dispatchable for Call { type Origin = (); diff --git a/bridges/primitives/currency-exchange/Cargo.toml b/bridges/primitives/currency-exchange/Cargo.toml index f47ab6e61b7a3..165891f0c6b1d 100644 --- a/bridges/primitives/currency-exchange/Cargo.toml +++ b/bridges/primitives/currency-exchange/Cargo.toml @@ -8,6 +8,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false } +scale-info = { version = "1.0", default-features = false, features = ["derive"] } # Substrate Dependencies @@ -20,6 +21,7 @@ default = ["std"] std = [ "codec/std", "frame-support/std", + "scale-info/std", "sp-api/std", "sp-std/std", ] diff --git a/bridges/primitives/currency-exchange/src/lib.rs b/bridges/primitives/currency-exchange/src/lib.rs index a3bdbbb2f42fb..1a30915b1cbfa 100644 --- a/bridges/primitives/currency-exchange/src/lib.rs +++ b/bridges/primitives/currency-exchange/src/lib.rs @@ -22,6 +22,7 @@ use codec::{Decode, Encode, EncodeLike}; use frame_support::{Parameter, RuntimeDebug}; +use scale_info::TypeInfo; use sp_api::decl_runtime_apis; use sp_std::marker::PhantomData; @@ -48,7 +49,7 @@ pub enum Error { pub type Result = sp_std::result::Result; /// Peer blockchain lock funds transaction. -#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq)] +#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq, TypeInfo)] pub struct LockFundsTransaction { /// Something that uniquely identifies this transfer. pub id: TransferId, @@ -63,7 +64,7 @@ pub trait MaybeLockFundsTransaction { /// Transaction type. type Transaction; /// Identifier that uniquely identifies this transfer. - type Id: Decode + Encode + EncodeLike + sp_std::fmt::Debug; + type Id: Decode + Encode + TypeInfo + EncodeLike + sp_std::fmt::Debug; /// Peer recipient type. type Recipient; /// Peer currency amount type. diff --git a/bridges/primitives/ethereum-poa/Cargo.toml b/bridges/primitives/ethereum-poa/Cargo.toml index e7acd80eff23d..71f071bbf0e6d 100644 --- a/bridges/primitives/ethereum-poa/Cargo.toml +++ b/bridges/primitives/ethereum-poa/Cargo.toml @@ -18,6 +18,7 @@ parity-bytes = { version = "0.1", default-features = false } plain_hasher = { version = "0.2.2", default-features = false } primitive-types = { version = "0.10", default-features = false, features = ["codec", "rlp"] } rlp = { version = "0.5", default-features = false } +scale-info = { version = "1.0", default-features = false, features = ["derive"] } serde = { version = "1.0", optional = true } serde-big-array = { version = "0.2", optional = true } triehash = { version = "0.8.2", default-features = false } @@ -47,6 +48,7 @@ std = [ "primitive-types/std", "primitive-types/serde", "rlp/std", + "scale-info/std", "serde/std", "serde-big-array", "sp-api/std", diff --git a/bridges/primitives/ethereum-poa/src/lib.rs b/bridges/primitives/ethereum-poa/src/lib.rs index c63cf2b8f65c9..58f5731e52222 100644 --- a/bridges/primitives/ethereum-poa/src/lib.rs +++ b/bridges/primitives/ethereum-poa/src/lib.rs @@ -28,6 +28,7 @@ use codec::{Decode, Encode}; use ethbloom::{Bloom as EthBloom, Input as BloomInput}; use fixed_hash::construct_fixed_hash; use rlp::{Decodable, DecoderError, Rlp, RlpStream}; +use scale_info::TypeInfo; use sp_io::hashing::keccak_256; use sp_runtime::RuntimeDebug; use sp_std::prelude::*; @@ -57,7 +58,7 @@ pub type Address = H160; pub mod signatures; /// Complete header id. -#[derive(Encode, Decode, Default, RuntimeDebug, PartialEq, Clone, Copy)] +#[derive(Encode, Decode, Default, RuntimeDebug, PartialEq, Clone, Copy, TypeInfo)] pub struct HeaderId { /// Header number. pub number: u64, @@ -66,7 +67,7 @@ pub struct HeaderId { } /// An Aura header. -#[derive(Clone, Default, Encode, Decode, PartialEq, RuntimeDebug)] +#[derive(Clone, Default, Encode, Decode, PartialEq, RuntimeDebug, TypeInfo)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub struct AuraHeader { /// Parent block hash. @@ -129,7 +130,7 @@ pub struct UnsignedTransaction { } /// Information describing execution of a transaction. -#[derive(Clone, Encode, Decode, PartialEq, RuntimeDebug)] +#[derive(Clone, Encode, Decode, PartialEq, RuntimeDebug, TypeInfo)] pub struct Receipt { /// The total gas used in the block following execution of the transaction. pub gas_used: U256, @@ -142,7 +143,7 @@ pub struct Receipt { } /// Transaction outcome store in the receipt. -#[derive(Clone, Encode, Decode, PartialEq, RuntimeDebug)] +#[derive(Clone, Encode, Decode, PartialEq, RuntimeDebug, TypeInfo)] pub enum TransactionOutcome { /// Status and state root are unknown under EIP-98 rules. Unknown, @@ -153,7 +154,7 @@ pub enum TransactionOutcome { } /// A record of execution for a `LOG` operation. -#[derive(Clone, Encode, Decode, PartialEq, RuntimeDebug)] +#[derive(Clone, Encode, Decode, PartialEq, RuntimeDebug, TypeInfo)] pub struct LogEntry { /// The address of the contract executing at the point of the `LOG` operation. pub address: Address, @@ -164,7 +165,7 @@ pub struct LogEntry { } /// Logs bloom. -#[derive(Clone, Encode, Decode)] +#[derive(Clone, Encode, Decode, TypeInfo)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub struct Bloom(#[cfg_attr(feature = "std", serde(with = "BigArray"))] [u8; 256]); diff --git a/bridges/primitives/header-chain/Cargo.toml b/bridges/primitives/header-chain/Cargo.toml index ecd7c17341a14..b75a41a4b2e59 100644 --- a/bridges/primitives/header-chain/Cargo.toml +++ b/bridges/primitives/header-chain/Cargo.toml @@ -9,6 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false } finality-grandpa = { version = "0.14.0", default-features = false } +scale-info = { version = "1.0", default-features = false, features = ["derive"] } serde = { version = "1.0", optional = true } # Substrate Dependencies @@ -30,6 +31,7 @@ std = [ "finality-grandpa/std", "serde/std", "frame-support/std", + "scale-info/std", "sp-core/std", "sp-finality-grandpa/std", "sp-runtime/std", diff --git a/bridges/primitives/header-chain/src/justification.rs b/bridges/primitives/header-chain/src/justification.rs index 2d092496e8d54..9f8e9662ea0f0 100644 --- a/bridges/primitives/header-chain/src/justification.rs +++ b/bridges/primitives/header-chain/src/justification.rs @@ -22,6 +22,7 @@ use codec::{Decode, Encode}; use finality_grandpa::voter_set::VoterSet; use frame_support::RuntimeDebug; +use scale_info::TypeInfo; use sp_finality_grandpa::{AuthorityId, AuthoritySignature, SetId}; use sp_runtime::traits::Header as HeaderT; use sp_std::{ @@ -34,7 +35,7 @@ use sp_std::{ /// /// This particular proof is used to prove that headers on a bridged chain /// (so not our chain) have been finalized correctly. -#[derive(Encode, Decode, RuntimeDebug, Clone, PartialEq, Eq)] +#[derive(Encode, Decode, RuntimeDebug, Clone, PartialEq, Eq, TypeInfo)] pub struct GrandpaJustification { /// The round (voting period) this justification is valid for. pub round: u64, diff --git a/bridges/primitives/header-chain/src/lib.rs b/bridges/primitives/header-chain/src/lib.rs index 66dd42e148298..5feb30aec3eee 100644 --- a/bridges/primitives/header-chain/src/lib.rs +++ b/bridges/primitives/header-chain/src/lib.rs @@ -21,6 +21,7 @@ use codec::{Codec, Decode, Encode, EncodeLike}; use core::{clone::Clone, cmp::Eq, default::Default, fmt::Debug}; +use scale_info::TypeInfo; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; use sp_finality_grandpa::{AuthorityList, ConsensusLog, SetId, GRANDPA_ENGINE_ID}; @@ -32,11 +33,11 @@ pub mod justification; /// A type that can be used as a parameter in a dispatchable function. /// /// When using `decl_module` all arguments for call functions must implement this trait. -pub trait Parameter: Codec + EncodeLike + Clone + Eq + Debug {} -impl Parameter for T where T: Codec + EncodeLike + Clone + Eq + Debug {} +pub trait Parameter: Codec + EncodeLike + Clone + Eq + Debug + TypeInfo {} +impl Parameter for T where T: Codec + EncodeLike + Clone + Eq + Debug + TypeInfo {} /// A GRANDPA Authority List and ID. -#[derive(Default, Encode, Decode, RuntimeDebug, PartialEq, Clone)] +#[derive(Default, Encode, Decode, RuntimeDebug, PartialEq, Clone, TypeInfo)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub struct AuthoritySet { /// List of GRANDPA authorities for the current round. @@ -55,7 +56,7 @@ impl AuthoritySet { /// Data required for initializing the 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)] +#[derive(Default, Encode, Decode, RuntimeDebug, PartialEq, Eq, Clone, TypeInfo)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub struct InitializationData { /// The header from which we should start syncing. diff --git a/bridges/primitives/message-dispatch/Cargo.toml b/bridges/primitives/message-dispatch/Cargo.toml index 9553b50d99d7c..9897b3199781d 100644 --- a/bridges/primitives/message-dispatch/Cargo.toml +++ b/bridges/primitives/message-dispatch/Cargo.toml @@ -9,6 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] bp-runtime = { path = "../runtime", default-features = false } codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false } +scale-info = { version = "1.0", default-features = false, features = ["derive"] } # Substrate Dependencies @@ -21,5 +22,6 @@ std = [ "bp-runtime/std", "codec/std", "frame-support/std", + "scale-info/std", "sp-std/std", ] diff --git a/bridges/primitives/message-dispatch/src/lib.rs b/bridges/primitives/message-dispatch/src/lib.rs index 5f39197b11751..07e448ee7ae62 100644 --- a/bridges/primitives/message-dispatch/src/lib.rs +++ b/bridges/primitives/message-dispatch/src/lib.rs @@ -25,6 +25,7 @@ use bp_runtime::{ }; use codec::{Decode, Encode}; use frame_support::RuntimeDebug; +use scale_info::TypeInfo; use sp_std::prelude::*; /// Message dispatch weight. @@ -71,7 +72,7 @@ pub trait MessageDispatch { /// The source chain can (and should) verify that the message can be dispatched on the target chain /// with a particular origin given the source chain's origin. This can be done with the /// `verify_message_origin()` function. -#[derive(RuntimeDebug, Encode, Decode, Clone, PartialEq, Eq)] +#[derive(RuntimeDebug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo)] pub enum CallOrigin { /// Call is sent by the Root origin on the source chain. On the target chain it is dispatched /// from a derived account. @@ -111,7 +112,7 @@ pub enum CallOrigin; /// Message key (unique message identifier) as it is stored in the storage. -#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)] +#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)] pub struct MessageKey { /// ID of the message lane. pub lane_id: LaneId, @@ -90,7 +91,7 @@ pub struct MessageKey { } /// Message data as it is stored in the storage. -#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)] +#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)] pub struct MessageData { /// Message payload. pub payload: MessagePayload, @@ -99,7 +100,7 @@ pub struct MessageData { } /// Message as it is stored in the storage. -#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)] +#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)] pub struct Message { /// Message key. pub key: MessageKey, @@ -108,7 +109,7 @@ pub struct Message { } /// Inbound lane data. -#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq)] +#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq, TypeInfo)] pub struct InboundLaneData { /// Identifiers of relayers and messages that they have delivered to this lane (ordered by /// message nonce). @@ -198,7 +199,7 @@ pub type DispatchResultsBitVec = BitVec; /// /// This struct represents a continuous range of messages that have been delivered by the same /// relayer and whose confirmations are still pending. -#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq)] +#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq, TypeInfo)] pub struct UnrewardedRelayer { /// Identifier of the relayer. pub relayer: RelayerId, @@ -207,7 +208,7 @@ pub struct UnrewardedRelayer { } /// Delivered messages with their dispatch result. -#[derive(Clone, Default, Encode, Decode, RuntimeDebug, PartialEq, Eq)] +#[derive(Clone, Default, Encode, Decode, RuntimeDebug, PartialEq, Eq, TypeInfo)] pub struct DeliveredMessages { /// Nonce of the first message that has been delivered (inclusive). pub begin: MessageNonce, @@ -267,7 +268,7 @@ impl DeliveredMessages { } /// Gist of `InboundLaneData::relayers` field used by runtime APIs. -#[derive(Clone, Default, Encode, Decode, RuntimeDebug, PartialEq, Eq)] +#[derive(Clone, Default, Encode, Decode, RuntimeDebug, PartialEq, Eq, TypeInfo)] pub struct UnrewardedRelayersState { /// Number of entries in the `InboundLaneData::relayers` set. pub unrewarded_relayer_entries: MessageNonce, @@ -279,7 +280,7 @@ pub struct UnrewardedRelayersState { } /// Outbound lane data. -#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq)] +#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq, TypeInfo)] pub struct OutboundLaneData { /// Nonce of the oldest message that we haven't yet pruned. May point to not-yet-generated /// message if all sent messages are already pruned. diff --git a/bridges/primitives/messages/src/target_chain.rs b/bridges/primitives/messages/src/target_chain.rs index e3f458ac8fce5..a84ea7af907de 100644 --- a/bridges/primitives/messages/src/target_chain.rs +++ b/bridges/primitives/messages/src/target_chain.rs @@ -21,13 +21,14 @@ use crate::{LaneId, Message, MessageData, MessageKey, OutboundLaneData}; use bp_runtime::{messages::MessageDispatchResult, Size}; use codec::{Decode, Encode, Error as CodecError}; use frame_support::{weights::Weight, Parameter, RuntimeDebug}; +use scale_info::TypeInfo; use sp_std::{collections::btree_map::BTreeMap, fmt::Debug, prelude::*}; /// Proved messages from the source chain. pub type ProvedMessages = BTreeMap>; /// Proved messages from single lane of the source chain. -#[derive(RuntimeDebug, Encode, Decode, Clone, PartialEq, Eq)] +#[derive(RuntimeDebug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo)] pub struct ProvedLaneMessages { /// Optional outbound lane state. pub lane_state: Option, diff --git a/bridges/primitives/polkadot-core/Cargo.toml b/bridges/primitives/polkadot-core/Cargo.toml index 7801112c6ddab..f05edd0d91ba3 100644 --- a/bridges/primitives/polkadot-core/Cargo.toml +++ b/bridges/primitives/polkadot-core/Cargo.toml @@ -8,6 +8,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] parity-scale-codec = { version = "2.2.0", default-features = false, features = ["derive"] } +scale-info = { version = "1.0", default-features = false, features = ["derive"] } # Bridge Dependencies @@ -35,6 +36,7 @@ std = [ "frame-support/std", "frame-system/std", "parity-scale-codec/std", + "scale-info/std", "sp-api/std", "sp-core/std", "sp-runtime/std", diff --git a/bridges/primitives/polkadot-core/src/lib.rs b/bridges/primitives/polkadot-core/src/lib.rs index 8f5fab60ab3ff..38e43d312b5d4 100644 --- a/bridges/primitives/polkadot-core/src/lib.rs +++ b/bridges/primitives/polkadot-core/src/lib.rs @@ -29,6 +29,7 @@ use frame_support::{ }; use frame_system::limits; use parity_scale_codec::Compact; +use scale_info::{StaticTypeInfo, TypeInfo}; use sp_core::Hasher as HasherT; use sp_runtime::{ generic, @@ -255,7 +256,7 @@ pub type AdditionalSigned = (u32, u32, Hash, Hash, (), (), ()); /// A simplified version of signed extensions meant for producing signed transactions /// and signed payload in the client code. -#[derive(PartialEq, Eq, Clone, RuntimeDebug)] +#[derive(PartialEq, Eq, Clone, RuntimeDebug, TypeInfo)] pub struct SignedExtensions { encode_payload: SignedExtra, additional_signed: AdditionalSigned, @@ -322,7 +323,14 @@ impl SignedExtensions { impl sp_runtime::traits::SignedExtension for SignedExtensions where - Call: parity_scale_codec::Codec + sp_std::fmt::Debug + Sync + Send + Clone + Eq + PartialEq, + Call: parity_scale_codec::Codec + + sp_std::fmt::Debug + + Sync + + Send + + Clone + + Eq + + PartialEq + + StaticTypeInfo, Call: Dispatchable, { const IDENTIFIER: &'static str = "Not needed."; diff --git a/bridges/primitives/runtime/Cargo.toml b/bridges/primitives/runtime/Cargo.toml index f27235a1b20b3..944f84a6c6835 100644 --- a/bridges/primitives/runtime/Cargo.toml +++ b/bridges/primitives/runtime/Cargo.toml @@ -10,6 +10,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false } hash-db = { version = "0.15.2", default-features = false } num-traits = { version = "0.2", default-features = false } +scale-info = { version = "1.0", default-features = false, features = ["derive"] } # Substrate Dependencies @@ -28,6 +29,7 @@ std = [ "frame-support/std", "hash-db/std", "num-traits/std", + "scale-info/std", "sp-core/std", "sp-io/std", "sp-runtime/std", diff --git a/bridges/primitives/runtime/src/messages.rs b/bridges/primitives/runtime/src/messages.rs index c351d771cf871..7a6687c18b776 100644 --- a/bridges/primitives/runtime/src/messages.rs +++ b/bridges/primitives/runtime/src/messages.rs @@ -18,9 +18,10 @@ use codec::{Decode, Encode}; use frame_support::{weights::Weight, RuntimeDebug}; +use scale_info::TypeInfo; /// Where message dispatch fee is paid? -#[derive(Encode, Decode, RuntimeDebug, Clone, Copy, PartialEq, Eq)] +#[derive(Encode, Decode, RuntimeDebug, Clone, Copy, PartialEq, Eq, TypeInfo)] pub enum DispatchFeePayment { /// The dispatch fee is paid at the source chain. AtSourceChain, @@ -34,7 +35,7 @@ pub enum DispatchFeePayment { } /// Message dispatch result. -#[derive(Encode, Decode, RuntimeDebug, Clone, PartialEq, Eq)] +#[derive(Encode, Decode, RuntimeDebug, Clone, PartialEq, Eq, TypeInfo)] pub struct MessageDispatchResult { /// Dispatch result flag. This flag is relayed back to the source chain and, generally /// speaking, may bring any (that fits in single bit) information from the dispatcher at diff --git a/bridges/primitives/token-swap/Cargo.toml b/bridges/primitives/token-swap/Cargo.toml index dd42f4e4a0c91..4b16c3567ea6e 100644 --- a/bridges/primitives/token-swap/Cargo.toml +++ b/bridges/primitives/token-swap/Cargo.toml @@ -8,6 +8,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false } +scale-info = { version = "1.0", default-features = false, features = ["derive"] } # Substrate Dependencies @@ -20,6 +21,7 @@ default = ["std"] std = [ "codec/std", "frame-support/std", + "scale-info/std", "sp-core/std", "sp-std/std", ] diff --git a/bridges/primitives/token-swap/src/lib.rs b/bridges/primitives/token-swap/src/lib.rs index 48aaeb38c3b4b..d46389e86891d 100644 --- a/bridges/primitives/token-swap/src/lib.rs +++ b/bridges/primitives/token-swap/src/lib.rs @@ -18,11 +18,12 @@ use codec::{Decode, Encode}; use frame_support::{weights::Weight, RuntimeDebug}; +use scale_info::TypeInfo; use sp_core::U256; use sp_std::vec::Vec; /// Pending token swap state. -#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq)] +#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq, TypeInfo)] pub enum TokenSwapState { /// The swap has been started using the `start_claim` call, but we have no proof that it has /// happened at the Bridged chain. @@ -39,7 +40,7 @@ pub enum TokenSwapState { /// /// Different swap types give a different guarantees regarding possible swap /// replay protection. -#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq)] +#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq, TypeInfo)] pub enum TokenSwapType { /// The `target_account_at_bridged_chain` is temporary and only have funds for single swap. /// @@ -68,7 +69,7 @@ pub enum TokenSwapType { /// when chain changes, the meaning of This and Bridged are still used to point to the same chains. /// This chain is always the chain where swap has been started. And the Bridged chain is the other /// chain. -#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq)] +#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq, TypeInfo)] pub struct TokenSwap { /// The type of the swap. @@ -88,7 +89,7 @@ pub struct TokenSwap; /// Token swap creation parameters. -#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq)] +#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq, TypeInfo)] pub struct TokenSwapCreation { /// Public key of the `target_account_at_bridged_chain` account used to verify /// `bridged_currency_transfer_signature`. diff --git a/bridges/relays/bin-ethereum/src/instances.rs b/bridges/relays/bin-ethereum/src/instances.rs index 3f2ebf825be77..74feb1da320d4 100644 --- a/bridges/relays/bin-ethereum/src/instances.rs +++ b/bridges/relays/bin-ethereum/src/instances.rs @@ -50,8 +50,8 @@ pub struct RialtoPoA; impl BridgeInstance for RialtoPoA { fn build_signed_header_call(&self, headers: Vec) -> Call { - let pallet_call = rialto_runtime::BridgeEthPoACall::import_signed_headers( - headers + let pallet_call = rialto_runtime::BridgeEthPoACall::import_signed_headers { + headers_with_receipts: headers .into_iter() .map(|header| { ( @@ -60,23 +60,23 @@ impl BridgeInstance for RialtoPoA { ) }) .collect(), - ); + }; rialto_runtime::Call::BridgeRialtoPoa(pallet_call) } fn build_unsigned_header_call(&self, header: QueuedEthereumHeader) -> Call { - let pallet_call = rialto_runtime::BridgeEthPoACall::import_unsigned_header( - Box::new(into_substrate_ethereum_header(header.header())), - into_substrate_ethereum_receipts(header.extra()), - ); + let pallet_call = rialto_runtime::BridgeEthPoACall::import_unsigned_header { + header: Box::new(into_substrate_ethereum_header(header.header())), + receipts: into_substrate_ethereum_receipts(header.extra()), + }; rialto_runtime::Call::BridgeRialtoPoa(pallet_call) } fn build_currency_exchange_call(&self, proof: Proof) -> Call { let pallet_call = - rialto_runtime::BridgeCurrencyExchangeCall::import_peer_transaction(proof); + rialto_runtime::BridgeCurrencyExchangeCall::import_peer_transaction { proof }; rialto_runtime::Call::BridgeRialtoCurrencyExchange(pallet_call) } } @@ -87,8 +87,8 @@ pub struct Kovan; impl BridgeInstance for Kovan { fn build_signed_header_call(&self, headers: Vec) -> Call { - let pallet_call = rialto_runtime::BridgeEthPoACall::import_signed_headers( - headers + let pallet_call = rialto_runtime::BridgeEthPoACall::import_signed_headers { + headers_with_receipts: headers .into_iter() .map(|header| { ( @@ -97,23 +97,23 @@ impl BridgeInstance for Kovan { ) }) .collect(), - ); + }; rialto_runtime::Call::BridgeKovan(pallet_call) } fn build_unsigned_header_call(&self, header: QueuedEthereumHeader) -> Call { - let pallet_call = rialto_runtime::BridgeEthPoACall::import_unsigned_header( - Box::new(into_substrate_ethereum_header(header.header())), - into_substrate_ethereum_receipts(header.extra()), - ); + let pallet_call = rialto_runtime::BridgeEthPoACall::import_unsigned_header { + header: Box::new(into_substrate_ethereum_header(header.header())), + receipts: into_substrate_ethereum_receipts(header.extra()), + }; rialto_runtime::Call::BridgeKovan(pallet_call) } fn build_currency_exchange_call(&self, proof: Proof) -> Call { let pallet_call = - rialto_runtime::BridgeCurrencyExchangeCall::import_peer_transaction(proof); + rialto_runtime::BridgeCurrencyExchangeCall::import_peer_transaction { proof }; rialto_runtime::Call::BridgeKovanCurrencyExchange(pallet_call) } } diff --git a/bridges/relays/bin-substrate/src/chains/millau.rs b/bridges/relays/bin-substrate/src/chains/millau.rs index 55b16b7786b73..1dbeab9a90498 100644 --- a/bridges/relays/bin-substrate/src/chains/millau.rs +++ b/bridges/relays/bin-substrate/src/chains/millau.rs @@ -39,18 +39,24 @@ impl CliEncodeCall for Millau { Ok(match call { Call::Raw { data } => Decode::decode(&mut &*data.0)?, Call::Remark { remark_payload, .. } => - millau_runtime::Call::System(millau_runtime::SystemCall::remark( - remark_payload.as_ref().map(|x| x.0.clone()).unwrap_or_default(), - )), - Call::Transfer { recipient, amount } => millau_runtime::Call::Balances( - millau_runtime::BalancesCall::transfer(recipient.raw_id(), amount.cast()), - ), + millau_runtime::Call::System(millau_runtime::SystemCall::remark { + remark: remark_payload.as_ref().map(|x| x.0.clone()).unwrap_or_default(), + }), + Call::Transfer { recipient, amount } => + millau_runtime::Call::Balances(millau_runtime::BalancesCall::transfer { + dest: recipient.raw_id(), + value: amount.cast(), + }), Call::BridgeSendMessage { lane, payload, fee, bridge_instance_index } => match *bridge_instance_index { bridge::MILLAU_TO_RIALTO_INDEX => { let payload = Decode::decode(&mut &*payload.0)?; millau_runtime::Call::BridgeRialtoMessages( - millau_runtime::MessagesCall::send_message(lane.0, payload, fee.cast()), + millau_runtime::MessagesCall::send_message { + lane_id: lane.0, + payload, + delivery_and_dispatch_fee: fee.cast(), + }, ) }, _ => anyhow::bail!( diff --git a/bridges/relays/bin-substrate/src/chains/millau_headers_to_rialto.rs b/bridges/relays/bin-substrate/src/chains/millau_headers_to_rialto.rs index e1dc19594f4f2..14a0430f6a918 100644 --- a/bridges/relays/bin-substrate/src/chains/millau_headers_to_rialto.rs +++ b/bridges/relays/bin-substrate/src/chains/millau_headers_to_rialto.rs @@ -61,10 +61,10 @@ impl SubstrateFinalitySyncPipeline for MillauFinalityToRialto { header: MillauSyncHeader, proof: GrandpaJustification, ) -> Bytes { - let call = rialto_runtime::BridgeGrandpaMillauCall::submit_finality_proof( - Box::new(header.into_inner()), - proof, - ) + let call = rialto_runtime::BridgeGrandpaMillauCall::submit_finality_proof { + finality_target: Box::new(header.into_inner()), + justification: proof, + } .into(); let genesis_hash = *self.finality_pipeline.target_client.genesis_hash(); diff --git a/bridges/relays/bin-substrate/src/chains/millau_messages_to_rialto.rs b/bridges/relays/bin-substrate/src/chains/millau_messages_to_rialto.rs index 9c56e8bd3d404..612fd96d0fcaa 100644 --- a/bridges/relays/bin-substrate/src/chains/millau_messages_to_rialto.rs +++ b/bridges/relays/bin-substrate/src/chains/millau_messages_to_rialto.rs @@ -95,7 +95,7 @@ impl SubstrateMessageLane for MillauMessagesToRialto { ) -> Bytes { let (relayers_state, proof) = proof; let call: millau_runtime::Call = - millau_runtime::MessagesCall::receive_messages_delivery_proof(proof, relayers_state) + millau_runtime::MessagesCall::receive_messages_delivery_proof { proof, relayers_state } .into(); let call_weight = call.get_dispatch_info().weight; let genesis_hash = *self.message_lane.source_client.genesis_hash(); @@ -130,12 +130,12 @@ impl SubstrateMessageLane for MillauMessagesToRialto { let (dispatch_weight, proof) = proof; let FromBridgedChainMessagesProof { ref nonces_start, ref nonces_end, .. } = proof; let messages_count = nonces_end - nonces_start + 1; - let call: rialto_runtime::Call = rialto_runtime::MessagesCall::receive_messages_proof( - self.message_lane.relayer_id_at_source.clone(), + let call: rialto_runtime::Call = rialto_runtime::MessagesCall::receive_messages_proof { + relayer_id_at_bridged_chain: self.message_lane.relayer_id_at_source.clone(), proof, - messages_count as _, + messages_count: messages_count as _, dispatch_weight, - ) + } .into(); let call_weight = call.get_dispatch_info().weight; let genesis_hash = *self.message_lane.target_client.genesis_hash(); @@ -290,11 +290,11 @@ pub(crate) async fn update_rialto_to_millau_conversion_rate( &signer, relay_substrate_client::TransactionEra::immortal(), UnsignedTransaction::new( - millau_runtime::MessagesCall::update_pallet_parameter( - millau_runtime::rialto_messages::MillauToRialtoMessagesParameter::RialtoToMillauConversionRate( + millau_runtime::MessagesCall::update_pallet_parameter { + parameter: millau_runtime::rialto_messages::MillauToRialtoMessagesParameter::RialtoToMillauConversionRate( sp_runtime::FixedU128::from_float(updated_rate), ), - ) + } .into(), transaction_nonce, ), diff --git a/bridges/relays/bin-substrate/src/chains/mod.rs b/bridges/relays/bin-substrate/src/chains/mod.rs index 2cbe3fe614622..a96d46d9ecc8d 100644 --- a/bridges/relays/bin-substrate/src/chains/mod.rs +++ b/bridges/relays/bin-substrate/src/chains/mod.rs @@ -82,7 +82,8 @@ mod tests { fn millau_signature_is_valid_on_rialto() { let millau_sign = relay_millau_client::SigningParams::from_string("//Dave", None).unwrap(); - let call = rialto_runtime::Call::System(rialto_runtime::SystemCall::remark(vec![])); + let call = + rialto_runtime::Call::System(rialto_runtime::SystemCall::remark { remark: vec![] }); let millau_public: bp_millau::AccountSigner = millau_sign.public().into(); let millau_account_id: bp_millau::AccountId = millau_public.into_account(); @@ -104,7 +105,8 @@ mod tests { fn rialto_signature_is_valid_on_millau() { let rialto_sign = relay_rialto_client::SigningParams::from_string("//Dave", None).unwrap(); - let call = millau_runtime::Call::System(millau_runtime::SystemCall::remark(vec![])); + let call = + millau_runtime::Call::System(millau_runtime::SystemCall::remark { remark: vec![] }); let rialto_public: bp_rialto::AccountSigner = rialto_sign.public().into(); let rialto_account_id: bp_rialto::AccountId = rialto_public.into_account(); @@ -132,7 +134,8 @@ mod tests { ); let call: millau_runtime::Call = - millau_runtime::SystemCall::remark(vec![42; maximal_remark_size as _]).into(); + millau_runtime::SystemCall::remark { remark: vec![42; maximal_remark_size as _] } + .into(); let payload = send_message::message_payload( Default::default(), call.get_dispatch_info().weight, @@ -143,7 +146,8 @@ mod tests { assert_eq!(Millau::verify_message(&payload), Ok(())); let call: millau_runtime::Call = - millau_runtime::SystemCall::remark(vec![42; (maximal_remark_size + 1) as _]).into(); + millau_runtime::SystemCall::remark { remark: vec![42; (maximal_remark_size + 1) as _] } + .into(); let payload = send_message::message_payload( Default::default(), call.get_dispatch_info().weight, @@ -171,7 +175,8 @@ mod tests { let maximal_dispatch_weight = send_message::compute_maximal_message_dispatch_weight( bp_millau::max_extrinsic_weight(), ); - let call: millau_runtime::Call = rialto_runtime::SystemCall::remark(vec![]).into(); + let call: millau_runtime::Call = + rialto_runtime::SystemCall::remark { remark: vec![] }.into(); let payload = send_message::message_payload( Default::default(), @@ -199,7 +204,8 @@ mod tests { let maximal_dispatch_weight = send_message::compute_maximal_message_dispatch_weight( bp_rialto::max_extrinsic_weight(), ); - let call: rialto_runtime::Call = millau_runtime::SystemCall::remark(vec![]).into(); + let call: rialto_runtime::Call = + millau_runtime::SystemCall::remark { remark: vec![] }.into(); let payload = send_message::message_payload( Default::default(), @@ -222,7 +228,8 @@ mod tests { #[test] fn rialto_tx_extra_bytes_constant_is_correct() { - let rialto_call = rialto_runtime::Call::System(rialto_runtime::SystemCall::remark(vec![])); + let rialto_call = + rialto_runtime::Call::System(rialto_runtime::SystemCall::remark { remark: vec![] }); let rialto_tx = Rialto::sign_transaction( Default::default(), &sp_keyring::AccountKeyring::Alice.pair(), @@ -240,7 +247,8 @@ mod tests { #[test] fn millau_tx_extra_bytes_constant_is_correct() { - let millau_call = millau_runtime::Call::System(millau_runtime::SystemCall::remark(vec![])); + let millau_call = + millau_runtime::Call::System(millau_runtime::SystemCall::remark { remark: vec![] }); let millau_tx = Millau::sign_transaction( Default::default(), &sp_keyring::AccountKeyring::Alice.pair(), @@ -288,10 +296,10 @@ mod rococo_tests { justification.clone(), ); let expected = - millau_runtime::BridgeGrandpaCall::::submit_finality_proof( - Box::new(header), + millau_runtime::BridgeGrandpaCall::::submit_finality_proof { + finality_target: Box::new(header), justification, - ); + }; // when let actual_encoded = actual.encode(); @@ -332,15 +340,15 @@ mod westend_tests { votes_ancestries: vec![], }; - let actual = bp_westend::BridgeGrandpaRococoCall::submit_finality_proof( - header.clone(), + let actual = relay_kusama_client::runtime::BridgePolkadotGrandpaCall::submit_finality_proof( + Box::new(header.clone()), justification.clone(), ); let expected = - millau_runtime::BridgeGrandpaCall::::submit_finality_proof( - Box::new(header), + millau_runtime::BridgeGrandpaCall::::submit_finality_proof { + finality_target: Box::new(header), justification, - ); + }; // when let actual_encoded = actual.encode(); diff --git a/bridges/relays/bin-substrate/src/chains/rialto.rs b/bridges/relays/bin-substrate/src/chains/rialto.rs index 837957bb87a1b..4c1a0166ed3b2 100644 --- a/bridges/relays/bin-substrate/src/chains/rialto.rs +++ b/bridges/relays/bin-substrate/src/chains/rialto.rs @@ -39,18 +39,24 @@ impl CliEncodeCall for Rialto { Ok(match call { Call::Raw { data } => Decode::decode(&mut &*data.0)?, Call::Remark { remark_payload, .. } => - rialto_runtime::Call::System(rialto_runtime::SystemCall::remark( - remark_payload.as_ref().map(|x| x.0.clone()).unwrap_or_default(), - )), - Call::Transfer { recipient, amount } => rialto_runtime::Call::Balances( - rialto_runtime::BalancesCall::transfer(recipient.raw_id().into(), amount.0), - ), + rialto_runtime::Call::System(rialto_runtime::SystemCall::remark { + remark: remark_payload.as_ref().map(|x| x.0.clone()).unwrap_or_default(), + }), + Call::Transfer { recipient, amount } => + rialto_runtime::Call::Balances(rialto_runtime::BalancesCall::transfer { + dest: recipient.raw_id().into(), + value: amount.0, + }), Call::BridgeSendMessage { lane, payload, fee, bridge_instance_index } => match *bridge_instance_index { bridge::RIALTO_TO_MILLAU_INDEX => { let payload = Decode::decode(&mut &*payload.0)?; rialto_runtime::Call::BridgeMillauMessages( - rialto_runtime::MessagesCall::send_message(lane.0, payload, fee.0), + rialto_runtime::MessagesCall::send_message { + lane_id: lane.0, + payload, + delivery_and_dispatch_fee: fee.0, + }, ) }, _ => anyhow::bail!( diff --git a/bridges/relays/bin-substrate/src/chains/rialto_headers_to_millau.rs b/bridges/relays/bin-substrate/src/chains/rialto_headers_to_millau.rs index f4a2f1efe781a..7e76f403c55aa 100644 --- a/bridges/relays/bin-substrate/src/chains/rialto_headers_to_millau.rs +++ b/bridges/relays/bin-substrate/src/chains/rialto_headers_to_millau.rs @@ -69,7 +69,10 @@ impl SubstrateFinalitySyncPipeline for RialtoFinalityToMillau { let call = millau_runtime::BridgeGrandpaCall::< millau_runtime::Runtime, millau_runtime::RialtoGrandpaInstance, - >::submit_finality_proof(Box::new(header.into_inner()), proof) + >::submit_finality_proof { + finality_target: Box::new(header.into_inner()), + justification: proof, + } .into(); let genesis_hash = *self.finality_pipeline.target_client.genesis_hash(); diff --git a/bridges/relays/bin-substrate/src/chains/rialto_messages_to_millau.rs b/bridges/relays/bin-substrate/src/chains/rialto_messages_to_millau.rs index 99960cd00f5a0..35f0852dcb67d 100644 --- a/bridges/relays/bin-substrate/src/chains/rialto_messages_to_millau.rs +++ b/bridges/relays/bin-substrate/src/chains/rialto_messages_to_millau.rs @@ -95,7 +95,7 @@ impl SubstrateMessageLane for RialtoMessagesToMillau { ) -> Bytes { let (relayers_state, proof) = proof; let call: rialto_runtime::Call = - rialto_runtime::MessagesCall::receive_messages_delivery_proof(proof, relayers_state) + rialto_runtime::MessagesCall::receive_messages_delivery_proof { proof, relayers_state } .into(); let call_weight = call.get_dispatch_info().weight; let genesis_hash = *self.message_lane.source_client.genesis_hash(); @@ -130,12 +130,12 @@ impl SubstrateMessageLane for RialtoMessagesToMillau { let (dispatch_weight, proof) = proof; let FromBridgedChainMessagesProof { ref nonces_start, ref nonces_end, .. } = proof; let messages_count = nonces_end - nonces_start + 1; - let call: millau_runtime::Call = millau_runtime::MessagesCall::receive_messages_proof( - self.message_lane.relayer_id_at_source.clone(), + let call: millau_runtime::Call = millau_runtime::MessagesCall::receive_messages_proof { + relayer_id_at_bridged_chain: self.message_lane.relayer_id_at_source.clone(), proof, - messages_count as _, + messages_count: messages_count as _, dispatch_weight, - ) + } .into(); let call_weight = call.get_dispatch_info().weight; let genesis_hash = *self.message_lane.target_client.genesis_hash(); @@ -289,11 +289,11 @@ pub(crate) async fn update_millau_to_rialto_conversion_rate( &signer, relay_substrate_client::TransactionEra::immortal(), UnsignedTransaction::new( - rialto_runtime::MessagesCall::update_pallet_parameter( - rialto_runtime::millau_messages::RialtoToMillauMessagesParameter::MillauToRialtoConversionRate( + rialto_runtime::MessagesCall::update_pallet_parameter { + parameter: rialto_runtime::millau_messages::RialtoToMillauMessagesParameter::MillauToRialtoConversionRate( sp_runtime::FixedU128::from_float(updated_rate), ), - ) + } .into(), transaction_nonce, ), diff --git a/bridges/relays/bin-substrate/src/chains/rialto_parachain.rs b/bridges/relays/bin-substrate/src/chains/rialto_parachain.rs index 4c9f63bbe41f6..edd4ca3628540 100644 --- a/bridges/relays/bin-substrate/src/chains/rialto_parachain.rs +++ b/bridges/relays/bin-substrate/src/chains/rialto_parachain.rs @@ -35,15 +35,15 @@ impl CliEncodeCall for RialtoParachain { Ok(match call { Call::Raw { data } => Decode::decode(&mut &*data.0)?, Call::Remark { remark_payload, .. } => rialto_parachain_runtime::Call::System( - rialto_parachain_runtime::SystemCall::remark( - remark_payload.as_ref().map(|x| x.0.clone()).unwrap_or_default(), - ), + rialto_parachain_runtime::SystemCall::remark { + remark: remark_payload.as_ref().map(|x| x.0.clone()).unwrap_or_default(), + }, ), Call::Transfer { recipient, amount } => rialto_parachain_runtime::Call::Balances( - rialto_parachain_runtime::BalancesCall::transfer( - recipient.raw_id().into(), - amount.0, - ), + rialto_parachain_runtime::BalancesCall::transfer { + dest: recipient.raw_id().into(), + value: amount.0, + }, ), Call::BridgeSendMessage { .. } => anyhow::bail!("Bridge messages are not (yet) supported here",), diff --git a/bridges/relays/bin-substrate/src/chains/westend_headers_to_millau.rs b/bridges/relays/bin-substrate/src/chains/westend_headers_to_millau.rs index 41b76283e2024..64d8ba4d889d7 100644 --- a/bridges/relays/bin-substrate/src/chains/westend_headers_to_millau.rs +++ b/bridges/relays/bin-substrate/src/chains/westend_headers_to_millau.rs @@ -77,7 +77,10 @@ impl SubstrateFinalitySyncPipeline for WestendFinalityToMillau { let call = millau_runtime::BridgeGrandpaCall::< millau_runtime::Runtime, millau_runtime::WestendGrandpaInstance, - >::submit_finality_proof(Box::new(header.into_inner()), proof) + >::submit_finality_proof { + finality_target: Box::new(header.into_inner()), + justification: proof, + } .into(); let genesis_hash = *self.finality_pipeline.target_client.genesis_hash(); diff --git a/bridges/relays/bin-substrate/src/cli/init_bridge.rs b/bridges/relays/bin-substrate/src/cli/init_bridge.rs index bdabc0177d990..ffda0b1200884 100644 --- a/bridges/relays/bin-substrate/src/cli/init_bridge.rs +++ b/bridges/relays/bin-substrate/src/cli/init_bridge.rs @@ -60,9 +60,12 @@ macro_rules! select_bridge { fn encode_init_bridge( init_data: InitializationData<::Header>, ) -> ::Call { - rialto_runtime::SudoCall::sudo(Box::new( - rialto_runtime::BridgeGrandpaMillauCall::initialize(init_data).into(), - )) + rialto_runtime::SudoCall::sudo { + call: Box::new( + rialto_runtime::BridgeGrandpaMillauCall::initialize { init_data } + .into(), + ), + } .into() } @@ -78,8 +81,10 @@ macro_rules! select_bridge { let initialize_call = millau_runtime::BridgeGrandpaCall::< millau_runtime::Runtime, millau_runtime::RialtoGrandpaInstance, - >::initialize(init_data); - millau_runtime::SudoCall::sudo(Box::new(initialize_call.into())).into() + >::initialize { + init_data, + }; + millau_runtime::SudoCall::sudo { call: Box::new(initialize_call.into()) }.into() } $generic @@ -98,7 +103,9 @@ macro_rules! select_bridge { millau_runtime::BridgeGrandpaCall::< millau_runtime::Runtime, millau_runtime::WestendGrandpaInstance, - >::initialize(init_data) + >::initialize { + init_data, + } .into() } diff --git a/bridges/relays/bin-substrate/src/cli/register_parachain.rs b/bridges/relays/bin-substrate/src/cli/register_parachain.rs index 7d7622ef488ea..fecc431148ebd 100644 --- a/bridges/relays/bin-substrate/src/cli/register_parachain.rs +++ b/bridges/relays/bin-substrate/src/cli/register_parachain.rs @@ -113,7 +113,8 @@ impl RegisterParachain { // step 1: reserve a parachain id let relay_genesis_hash = *relay_client.genesis_hash(); let relay_sudo_account: AccountIdOf = relay_sign.public().into(); - let reserve_parachain_id_call: CallOf = ParaRegistrarCall::reserve().into(); + let reserve_parachain_id_call: CallOf = + ParaRegistrarCall::reserve {}.into(); let reserve_parachain_signer = relay_sign.clone(); wait_until_transaction_is_finalized::( relay_client @@ -155,11 +156,11 @@ impl RegisterParachain { para_genesis_header.encode().len(), para_code.len(), ); - let register_parathread_call: CallOf = ParaRegistrarCall::register( - para_id, - ParaHeadData(para_genesis_header.encode()), - ParaValidationCode(para_code), - ) + let register_parathread_call: CallOf = ParaRegistrarCall::register { + id: para_id, + genesis_head: ParaHeadData(para_genesis_header.encode()), + validation_code: ParaValidationCode(para_code), + } .into(); let register_parathread_signer = relay_sign.clone(); wait_until_transaction_is_finalized::( @@ -211,16 +212,18 @@ impl RegisterParachain { lease_begin, lease_end, ); - let force_lease_call: CallOf = SudoCall::sudo(Box::new( - ParaSlotsCall::force_lease( - para_id, - relay_sudo_account.clone(), - para_deposit, - lease_begin, - lease_end, - ) - .into(), - )) + let force_lease_call: CallOf = SudoCall::sudo { + call: Box::new( + ParaSlotsCall::force_lease { + para: para_id, + leaser: relay_sudo_account.clone(), + amount: para_deposit, + period_begin: lease_begin, + period_count: lease_end.saturating_sub(lease_begin).saturating_add(1), + } + .into(), + ), + } .into(); let force_lease_signer = relay_sign.clone(); relay_client diff --git a/bridges/relays/bin-substrate/src/cli/swap_tokens.rs b/bridges/relays/bin-substrate/src/cli/swap_tokens.rs index 9f4b3ba698fd7..aa3996aa41364 100644 --- a/bridges/relays/bin-substrate/src/cli/swap_tokens.rs +++ b/bridges/relays/bin-substrate/src/cli/swap_tokens.rs @@ -176,10 +176,10 @@ impl SwapTokens { // // prepare `Currency::transfer` call that will happen at the target chain - let bridged_currency_transfer: CallOf = pallet_balances::Call::transfer( - accounts.source_account_at_bridged_chain.clone().into(), - token_swap.target_balance_at_bridged_chain, - ) + let bridged_currency_transfer: CallOf = pallet_balances::Call::transfer { + dest: accounts.source_account_at_bridged_chain.clone().into(), + value: token_swap.target_balance_at_bridged_chain, + } .into(); let bridged_currency_transfer_weight = bridged_currency_transfer.get_dispatch_info().weight; @@ -218,9 +218,9 @@ impl SwapTokens { }, ) .await?; - let create_swap_call: CallOf = pallet_bridge_token_swap::Call::create_swap( - token_swap.clone(), - Box::new(bp_token_swap::TokenSwapCreation { + let create_swap_call: CallOf = pallet_bridge_token_swap::Call::create_swap { + swap: token_swap.clone(), + swap_creation_params: Box::new(bp_token_swap::TokenSwapCreation { target_public_at_bridged_chain, swap_delivery_and_dispatch_fee, bridged_chain_spec_version, @@ -228,7 +228,7 @@ impl SwapTokens { bridged_currency_transfer_weight, bridged_currency_transfer_signature, }), - ) + } .into(); // start tokens swap @@ -341,7 +341,7 @@ impl SwapTokens { // prepare `claim_swap` message that will be sent over the bridge let claim_swap_call: CallOf = - pallet_bridge_token_swap::Call::claim_swap(token_swap).into(); + pallet_bridge_token_swap::Call::claim_swap { swap: token_swap }.into(); let claim_swap_message = bp_message_dispatch::MessagePayload { spec_version: SOURCE_SPEC_VERSION, weight: claim_swap_call.get_dispatch_info().weight, @@ -359,12 +359,13 @@ impl SwapTokens { claim_swap_message.clone(), ) .await?; - let send_message_call: CallOf = pallet_bridge_messages::Call::send_message( - TARGET_TO_SOURCE_LANE_ID, - claim_swap_message, - claim_swap_delivery_and_dispatch_fee, - ) - .into(); + let send_message_call: CallOf = + pallet_bridge_messages::Call::send_message { + lane_id: TARGET_TO_SOURCE_LANE_ID, + payload: claim_swap_message, + delivery_and_dispatch_fee: claim_swap_delivery_and_dispatch_fee, + } + .into(); // send `claim_swap` message let target_genesis_hash = *target_client.genesis_hash(); @@ -406,7 +407,7 @@ impl SwapTokens { } else { log::info!(target: "bridge", "Cancelling the swap"); let cancel_swap_call: CallOf = - pallet_bridge_token_swap::Call::cancel_swap(token_swap.clone()).into(); + pallet_bridge_token_swap::Call::cancel_swap { swap: token_swap.clone() }.into(); let _ = wait_until_transaction_is_finalized::( source_client .submit_and_watch_signed_extrinsic( diff --git a/bridges/relays/client-kusama/Cargo.toml b/bridges/relays/client-kusama/Cargo.toml index 33bbbeeacd99a..a48d82f641b70 100644 --- a/bridges/relays/client-kusama/Cargo.toml +++ b/bridges/relays/client-kusama/Cargo.toml @@ -9,6 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" codec = { package = "parity-scale-codec", version = "2.2.0" } relay-substrate-client = { path = "../client-substrate" } relay-utils = { path = "../utils" } +scale-info = { version = "1.0", features = ["derive"] } # Bridge dependencies diff --git a/bridges/relays/client-kusama/src/runtime.rs b/bridges/relays/client-kusama/src/runtime.rs index 702ce3d385466..6d0ab5462d7c8 100644 --- a/bridges/relays/client-kusama/src/runtime.rs +++ b/bridges/relays/client-kusama/src/runtime.rs @@ -21,6 +21,7 @@ use bp_polkadot_core::{AccountAddress, Balance, PolkadotLike}; use bp_runtime::Chain; use codec::{Compact, Decode, Encode}; use frame_support::weights::Weight; +use scale_info::TypeInfo; use sp_runtime::FixedU128; /// Unchecked Kusama extrinsic. @@ -61,7 +62,7 @@ where /// /// See: [link](https://github.com/paritytech/polkadot/blob/master/runtime/kusama/src/lib.rs) #[allow(clippy::large_enum_variant)] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone)] +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] pub enum Call { /// System pallet. #[codec(index = 0)] @@ -77,21 +78,21 @@ pub enum Call { BridgePolkadotMessages(BridgePolkadotMessagesCall), } -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone)] +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] #[allow(non_camel_case_types)] pub enum SystemCall { #[codec(index = 1)] remark(Vec), } -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone)] +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] #[allow(non_camel_case_types)] pub enum BalancesCall { #[codec(index = 0)] transfer(AccountAddress, Compact), } -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone)] +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] #[allow(non_camel_case_types)] pub enum BridgePolkadotGrandpaCall { #[codec(index = 0)] @@ -103,7 +104,7 @@ pub enum BridgePolkadotGrandpaCall { initialize(bp_header_chain::InitializationData<::Header>), } -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone)] +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] #[allow(non_camel_case_types)] pub enum BridgePolkadotMessagesCall { #[codec(index = 2)] @@ -135,7 +136,7 @@ pub enum BridgePolkadotMessagesCall { ), } -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone)] +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] pub enum BridgePolkadotMessagesParameter { #[codec(index = 0)] PolkadotToKusamaConversionRate(FixedU128), diff --git a/bridges/relays/client-polkadot/Cargo.toml b/bridges/relays/client-polkadot/Cargo.toml index 663969da66a4c..ff77486579411 100644 --- a/bridges/relays/client-polkadot/Cargo.toml +++ b/bridges/relays/client-polkadot/Cargo.toml @@ -9,6 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" codec = { package = "parity-scale-codec", version = "2.2.0" } relay-substrate-client = { path = "../client-substrate" } relay-utils = { path = "../utils" } +scale-info = { version = "1.0", features = ["derive"] } # Bridge dependencies diff --git a/bridges/relays/client-polkadot/src/runtime.rs b/bridges/relays/client-polkadot/src/runtime.rs index e21b27f6d3dea..8b125a37843c8 100644 --- a/bridges/relays/client-polkadot/src/runtime.rs +++ b/bridges/relays/client-polkadot/src/runtime.rs @@ -21,6 +21,7 @@ use bp_polkadot_core::{AccountAddress, Balance, PolkadotLike}; use bp_runtime::Chain; use codec::{Compact, Decode, Encode}; use frame_support::weights::Weight; +use scale_info::TypeInfo; use sp_runtime::FixedU128; /// Unchecked Polkadot extrinsic. @@ -61,7 +62,7 @@ where /// /// See: [link](https://github.com/paritytech/kusama/blob/master/runtime/kusam/src/lib.rs) #[allow(clippy::large_enum_variant)] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone)] +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] pub enum Call { /// System pallet. #[codec(index = 0)] @@ -77,21 +78,21 @@ pub enum Call { BridgeKusamaMessages(BridgeKusamaMessagesCall), } -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone)] +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] #[allow(non_camel_case_types)] pub enum SystemCall { #[codec(index = 1)] remark(Vec), } -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone)] +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] #[allow(non_camel_case_types)] pub enum BalancesCall { #[codec(index = 0)] transfer(AccountAddress, Compact), } -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone)] +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] #[allow(non_camel_case_types)] pub enum BridgeKusamaGrandpaCall { #[codec(index = 0)] @@ -103,7 +104,7 @@ pub enum BridgeKusamaGrandpaCall { initialize(bp_header_chain::InitializationData<::Header>), } -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone)] +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] #[allow(non_camel_case_types)] pub enum BridgeKusamaMessagesCall { #[codec(index = 2)] @@ -135,7 +136,7 @@ pub enum BridgeKusamaMessagesCall { ), } -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone)] +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] pub enum BridgeKusamaMessagesParameter { #[codec(index = 0)] KusamaToPolkadotConversionRate(FixedU128), diff --git a/bridges/relays/client-rococo/Cargo.toml b/bridges/relays/client-rococo/Cargo.toml index 38ec9eb1887c0..28e97d3bf0cec 100644 --- a/bridges/relays/client-rococo/Cargo.toml +++ b/bridges/relays/client-rococo/Cargo.toml @@ -9,6 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" codec = { package = "parity-scale-codec", version = "2.2.0" } relay-substrate-client = { path = "../client-substrate" } relay-utils = { path = "../utils" } +scale-info = { version = "1.0", features = ["derive"] } # Bridge dependencies diff --git a/bridges/relays/client-rococo/src/runtime.rs b/bridges/relays/client-rococo/src/runtime.rs index a82aa81a792cc..effe6e5c60a9d 100644 --- a/bridges/relays/client-rococo/src/runtime.rs +++ b/bridges/relays/client-rococo/src/runtime.rs @@ -21,6 +21,7 @@ use bp_polkadot_core::PolkadotLike; use bp_runtime::Chain; use codec::{Decode, Encode}; use frame_support::weights::Weight; +use scale_info::TypeInfo; /// Unchecked Rococo extrinsic. pub type UncheckedExtrinsic = bp_polkadot_core::UncheckedExtrinsic; @@ -60,7 +61,7 @@ where /// /// See: [link](https://github.com/paritytech/polkadot/blob/master/runtime/rococo/src/lib.rs) #[allow(clippy::large_enum_variant)] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone)] +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] pub enum Call { /// System pallet. #[codec(index = 0)] @@ -73,14 +74,14 @@ pub enum Call { BridgeMessagesWococo(BridgeMessagesWococoCall), } -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone)] +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] #[allow(non_camel_case_types)] pub enum SystemCall { #[codec(index = 1)] remark(Vec), } -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone)] +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] #[allow(non_camel_case_types)] pub enum BridgeGrandpaWococoCall { #[codec(index = 0)] @@ -92,7 +93,7 @@ pub enum BridgeGrandpaWococoCall { initialize(bp_header_chain::InitializationData<::Header>), } -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone)] +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] #[allow(non_camel_case_types)] pub enum BridgeMessagesWococoCall { #[codec(index = 3)] diff --git a/bridges/relays/client-wococo/Cargo.toml b/bridges/relays/client-wococo/Cargo.toml index 13786c0247f80..ea46c3c898bbb 100644 --- a/bridges/relays/client-wococo/Cargo.toml +++ b/bridges/relays/client-wococo/Cargo.toml @@ -9,6 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" codec = { package = "parity-scale-codec", version = "2.2.0" } relay-substrate-client = { path = "../client-substrate" } relay-utils = { path = "../utils" } +scale-info = { version = "1.0", default-features = false, features = ["derive"] } # Bridge dependencies bridge-runtime-common = { path = "../../bin/runtime-common" } diff --git a/bridges/relays/client-wococo/src/runtime.rs b/bridges/relays/client-wococo/src/runtime.rs index c4835372306e5..91d32d1aa76f7 100644 --- a/bridges/relays/client-wococo/src/runtime.rs +++ b/bridges/relays/client-wococo/src/runtime.rs @@ -21,6 +21,7 @@ use bp_polkadot_core::PolkadotLike; use bp_runtime::Chain; use codec::{Decode, Encode}; use frame_support::weights::Weight; +use scale_info::TypeInfo; /// Unchecked Wococo extrinsic. pub type UncheckedExtrinsic = bp_polkadot_core::UncheckedExtrinsic; @@ -60,7 +61,7 @@ where /// /// See: [link](https://github.com/paritytech/polkadot/blob/master/runtime/rococo/src/lib.rs) #[allow(clippy::large_enum_variant)] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone)] +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] pub enum Call { /// System pallet. #[codec(index = 0)] @@ -73,14 +74,14 @@ pub enum Call { BridgeMessagesRococo(BridgeMessagesRococoCall), } -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone)] +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] #[allow(non_camel_case_types)] pub enum SystemCall { #[codec(index = 1)] remark(Vec), } -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone)] +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] #[allow(non_camel_case_types)] pub enum BridgeGrandpaRococoCall { #[codec(index = 0)] @@ -92,7 +93,7 @@ pub enum BridgeGrandpaRococoCall { initialize(bp_header_chain::InitializationData<::Header>), } -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone)] +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] #[allow(non_camel_case_types)] pub enum BridgeMessagesRococoCall { #[codec(index = 3)]