mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 23:21:02 +00:00
Polkadot <> Kusama relayers (#1122)
* relay headers between Kusama and Polkadot * relay messages between Kusama and Polkadot * complex Kusama <> Polkadot relayer * expose relayer_fund_account_id from messages pallet * create relayers fund accounts on Kusama/Polkadot + some more fixes * fmt * fix compilation * compilation + clippy * compilation * MAXIMAL_BALANCE_DECREASE_PER_DAY for K<>P header relays * fmt * deduplicate tests * Update modules/messages/src/lib.rs Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * extract storage_parameter_key function * other grumbles * fix * fmt Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
This commit is contained in:
committed by
Bastian Köcher
parent
417903f9e7
commit
2db84b74cc
@@ -20,6 +20,7 @@ bp-runtime = { path = "../runtime", default-features = false }
|
||||
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
sp-version = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
@@ -30,4 +31,5 @@ std = [
|
||||
"frame-support/std",
|
||||
"sp-api/std",
|
||||
"sp-std/std",
|
||||
"sp-version/std",
|
||||
]
|
||||
|
||||
@@ -23,12 +23,24 @@
|
||||
use bp_messages::{LaneId, MessageDetails, MessageNonce, UnrewardedRelayersState};
|
||||
use frame_support::weights::{WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial};
|
||||
use sp_std::prelude::*;
|
||||
use sp_version::RuntimeVersion;
|
||||
|
||||
pub use bp_polkadot_core::*;
|
||||
|
||||
/// Kusama Chain
|
||||
pub type Kusama = PolkadotLike;
|
||||
|
||||
// NOTE: This needs to be kept up to date with the Kusama runtime found in the Polkadot repo.
|
||||
pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
spec_name: sp_version::create_runtime_str!("kusama"),
|
||||
impl_name: sp_version::create_runtime_str!("parity-kusama"),
|
||||
authoring_version: 2,
|
||||
spec_version: 9100,
|
||||
impl_version: 0,
|
||||
apis: sp_version::create_apis_vec![[]],
|
||||
transaction_version: 5,
|
||||
};
|
||||
|
||||
// NOTE: This needs to be kept up to date with the Kusama runtime found in the Polkadot repo.
|
||||
pub struct WeightToFee;
|
||||
impl WeightToFeePolynomial for WeightToFee {
|
||||
@@ -57,9 +69,22 @@ pub fn derive_account_from_polkadot_id(id: bp_runtime::SourceAccount<AccountId>)
|
||||
/// Per-byte fee for Kusama transactions.
|
||||
pub const TRANSACTION_BYTE_FEE: Balance = 10 * 1_000_000_000_000 / 30_000 / 1_000;
|
||||
|
||||
/// Existential deposit on Kusama.
|
||||
pub const EXISTENTIAL_DEPOSIT: Balance = 1_000_000_000_000 / 30_000;
|
||||
|
||||
/// The target length of a session (how often authorities change) on Kusama measured in of number of
|
||||
/// blocks.
|
||||
///
|
||||
/// Note that since this is a target sessions may change before/after this time depending on network
|
||||
/// conditions.
|
||||
pub const SESSION_LENGTH: BlockNumber = 1 * time_units::HOURS;
|
||||
|
||||
/// Name of the With-Polkadot messages pallet instance in the Kusama runtime.
|
||||
pub const WITH_POLKADOT_MESSAGES_PALLET_NAME: &str = "BridgePolkadotMessages";
|
||||
|
||||
/// Name of the DOT->KSM conversion rate stored in the Kusama runtime.
|
||||
pub const POLKADOT_TO_KUSAMA_CONVERSION_RATE_PARAMETER_NAME: &str = "PolkadotToKusamaConversionRate";
|
||||
|
||||
/// Name of the `KusamaFinalityApi::best_finalized` runtime method.
|
||||
pub const BEST_FINALIZED_KUSAMA_HEADER_METHOD: &str = "KusamaFinalityApi_best_finalized";
|
||||
/// Name of the `KusamaFinalityApi::is_known_header` runtime method.
|
||||
|
||||
@@ -20,6 +20,7 @@ bp-runtime = { path = "../runtime", default-features = false }
|
||||
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
sp-version = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
@@ -30,4 +31,5 @@ std = [
|
||||
"frame-support/std",
|
||||
"sp-api/std",
|
||||
"sp-std/std",
|
||||
"sp-version/std",
|
||||
]
|
||||
|
||||
@@ -23,12 +23,24 @@
|
||||
use bp_messages::{LaneId, MessageDetails, MessageNonce, UnrewardedRelayersState};
|
||||
use frame_support::weights::{WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial};
|
||||
use sp_std::prelude::*;
|
||||
use sp_version::RuntimeVersion;
|
||||
|
||||
pub use bp_polkadot_core::*;
|
||||
|
||||
/// Polkadot Chain
|
||||
pub type Polkadot = PolkadotLike;
|
||||
|
||||
// NOTE: This needs to be kept up to date with the Polkadot runtime found in the Polkadot repo.
|
||||
pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
spec_name: sp_version::create_runtime_str!("polkadot"),
|
||||
impl_name: sp_version::create_runtime_str!("parity-polkadot"),
|
||||
authoring_version: 0,
|
||||
spec_version: 9100,
|
||||
impl_version: 0,
|
||||
apis: sp_version::create_apis_vec![[]],
|
||||
transaction_version: 7,
|
||||
};
|
||||
|
||||
// NOTE: This needs to be kept up to date with the Polkadot runtime found in the Polkadot repo.
|
||||
pub struct WeightToFee;
|
||||
impl WeightToFeePolynomial for WeightToFee {
|
||||
@@ -57,9 +69,22 @@ pub fn derive_account_from_kusama_id(id: bp_runtime::SourceAccount<AccountId>) -
|
||||
/// Per-byte fee for Polkadot transactions.
|
||||
pub const TRANSACTION_BYTE_FEE: Balance = 10 * 10_000_000_000 / 100 / 1_000;
|
||||
|
||||
/// Existential deposit on Polkadot.
|
||||
pub const EXISTENTIAL_DEPOSIT: Balance = 10_000_000_000;
|
||||
|
||||
/// The target length of a session (how often authorities change) on Polkadot measured in of number of
|
||||
/// blocks.
|
||||
///
|
||||
/// Note that since this is a target sessions may change before/after this time depending on network
|
||||
/// conditions.
|
||||
pub const SESSION_LENGTH: BlockNumber = 4 * time_units::HOURS;
|
||||
|
||||
/// Name of the With-Kusama messages pallet instance in the Polkadot runtime.
|
||||
pub const WITH_KUSAMA_MESSAGES_PALLET_NAME: &str = "BridgeKusamaMessages";
|
||||
|
||||
/// Name of the KSM->DOT conversion rate stored in the Polkadot runtime.
|
||||
pub const KUSAMA_TO_POLKADOT_CONVERSION_RATE_PARAMETER_NAME: &str = "KusamaToPolkadotConversionRate";
|
||||
|
||||
/// Name of the `PolkadotFinalityApi::best_finalized` runtime method.
|
||||
pub const BEST_FINALIZED_POLKADOT_HEADER_METHOD: &str = "PolkadotFinalityApi_best_finalized";
|
||||
/// Name of the `PolkadotFinalityApi::is_known_header` runtime method.
|
||||
|
||||
@@ -217,6 +217,9 @@ pub type AccountPublic = <Signature as Verify>::Signer;
|
||||
/// Id of account on Polkadot-like chains.
|
||||
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.
|
||||
pub type Nonce = u32;
|
||||
|
||||
@@ -231,7 +234,7 @@ pub type Balance = u128;
|
||||
|
||||
/// Unchecked Extrinsic type.
|
||||
pub type UncheckedExtrinsic<Call> =
|
||||
generic::UncheckedExtrinsic<MultiAddress<AccountId, ()>, Call, Signature, SignedExtensions<Call>>;
|
||||
generic::UncheckedExtrinsic<AccountAddress, Call, Signature, SignedExtensions<Call>>;
|
||||
|
||||
/// Account address, used by the Polkadot-like chain.
|
||||
pub type Address = MultiAddress<AccountId, ()>;
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
|
||||
use codec::Encode;
|
||||
use frame_support::RuntimeDebug;
|
||||
use sp_core::hash::H256;
|
||||
use sp_core::{hash::H256, storage::StorageKey};
|
||||
use sp_io::hashing::blake2_256;
|
||||
use sp_std::convert::TryFrom;
|
||||
use sp_std::{convert::TryFrom, vec::Vec};
|
||||
|
||||
pub use chain::{
|
||||
AccountIdOf, AccountPublicOf, BalanceOf, BlockNumberOf, Chain, HashOf, HasherOf, HeaderOf, IndexOf, SignatureOf,
|
||||
@@ -183,3 +183,15 @@ impl<BlockNumber: Copy + Into<u64>, BlockHash: Copy> TransactionEra<BlockNumber,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// This is how a storage key of storage parameter (`parameter_types! { storage Param: bool = false; }`) is computed.
|
||||
///
|
||||
/// Copypaste from `frame_support::parameter_types` macro
|
||||
pub fn storage_parameter_key(parameter_name: &str) -> StorageKey {
|
||||
let mut buffer = Vec::with_capacity(1 + parameter_name.len() + 1 + 1);
|
||||
buffer.push(':' as u8);
|
||||
buffer.extend_from_slice(parameter_name.as_bytes());
|
||||
buffer.push(':' as u8);
|
||||
buffer.push(0);
|
||||
StorageKey(sp_io::hashing::twox_128(&buffer).to_vec())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user