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