mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 23:21:02 +00:00
Update Substrate Dependency (#566)
* Update `sp-io` dependency * Rename Trait to Config * RustFmt * Bump `sp-io` again * Use new frame_system weight types in Rialto and Millau runtimes * Update test Runtimes to use new weight types * Bump `sp-io` again * Update to not-the latest first. * Update benchmarks. * Another Trai. * Move new weight types into runtime primitive crates This allows us to check limits for extrinsics from other parts of the codebase without pulling in the entire chain runtime. * Remove leftover comments * Move new functions to a better location * Small formatting fixes * Add actual documentation to new weight config types * Decrease maximum block weight of Millau chain * Decreease maximum block length of Millau chain Co-authored-by: Tomasz Drwięga <tomasz@parity.io>
This commit is contained in:
committed by
Bastian Köcher
parent
8a5b51a944
commit
ee655b1057
@@ -317,8 +317,6 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
|
||||
task_manager
|
||||
.spawn_essential_handle()
|
||||
.spawn_blocking("grandpa-voter", sc_finality_grandpa::run_grandpa_voter(grandpa_config)?);
|
||||
} else {
|
||||
sc_finality_grandpa::setup_disabled_grandpa(network)?;
|
||||
}
|
||||
|
||||
network_starter.start_network();
|
||||
|
||||
@@ -128,7 +128,7 @@ impl MaybeLockFundsTransaction for EthTransaction {
|
||||
|
||||
/// Prepares everything required to bench claim of funds locked by given transaction.
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
pub(crate) fn prepare_environment_for_claim<T: pallet_bridge_eth_poa::Trait<I>, I: frame_support::traits::Instance>(
|
||||
pub(crate) fn prepare_environment_for_claim<T: pallet_bridge_eth_poa::Config<I>, I: frame_support::traits::Instance>(
|
||||
transactions: &[(RawTransaction, RawTransactionReceipt)],
|
||||
) -> bp_eth_poa::H256 {
|
||||
use bp_eth_poa::compute_merkle_root;
|
||||
|
||||
@@ -37,6 +37,7 @@ pub mod millau_messages;
|
||||
pub mod rialto_poa;
|
||||
|
||||
use codec::Decode;
|
||||
use frame_system::limits;
|
||||
use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
|
||||
use sp_api::impl_runtime_apis;
|
||||
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
||||
@@ -56,7 +57,7 @@ use sp_version::RuntimeVersion;
|
||||
pub use frame_support::{
|
||||
construct_runtime, parameter_types,
|
||||
traits::{Currency, ExistenceRequirement, Imbalance, KeyOwnerProofSystem, Randomness},
|
||||
weights::{IdentityFee, RuntimeDbWeight, Weight},
|
||||
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, RuntimeDbWeight, Weight},
|
||||
StorageValue,
|
||||
};
|
||||
|
||||
@@ -157,19 +158,17 @@ pub fn native_version() -> NativeVersion {
|
||||
|
||||
parameter_types! {
|
||||
pub const BlockHashCount: BlockNumber = 250;
|
||||
pub const MaximumBlockWeight: Weight = bp_rialto::MAXIMUM_BLOCK_WEIGHT;
|
||||
pub const ExtrinsicBaseWeight: Weight = 10_000_000;
|
||||
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(bp_rialto::AVAILABLE_BLOCK_RATIO);
|
||||
pub MaximumExtrinsicWeight: Weight = bp_rialto::MAXIMUM_EXTRINSIC_WEIGHT;
|
||||
pub const MaximumBlockLength: u32 = bp_rialto::MAXIMUM_BLOCK_SIZE;
|
||||
pub const Version: RuntimeVersion = VERSION;
|
||||
pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight {
|
||||
read: 60_000_000, // ~0.06 ms = ~60 µs
|
||||
write: 200_000_000, // ~0.2 ms = 200 µs
|
||||
};
|
||||
|
||||
pub RuntimeBlockLength: limits::BlockLength = bp_rialto::runtime_block_length();
|
||||
pub RuntimeBlockWeights: limits::BlockWeights = bp_rialto::runtime_block_weights();
|
||||
}
|
||||
|
||||
impl frame_system::Trait for Runtime {
|
||||
impl frame_system::Config for Runtime {
|
||||
/// The basic call filter to use in dispatchable.
|
||||
type BaseCallFilter = ();
|
||||
/// The identifier used to distinguish between accounts.
|
||||
@@ -194,24 +193,6 @@ impl frame_system::Trait for Runtime {
|
||||
type Origin = Origin;
|
||||
/// Maximum number of block number to block hash mappings to keep (oldest pruned first).
|
||||
type BlockHashCount = BlockHashCount;
|
||||
/// Maximum weight of each block.
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
/// The weight of database operations that the runtime can invoke.
|
||||
type DbWeight = DbWeight;
|
||||
/// The weight of the overhead invoked on the block import process, independent of the
|
||||
/// extrinsics included in that block.
|
||||
type BlockExecutionWeight = ();
|
||||
/// The base weight of any extrinsic processed by the runtime, independent of the
|
||||
/// logic of that extrinsic. (Signature verification, nonce increment, fee, etc...)
|
||||
type ExtrinsicBaseWeight = ExtrinsicBaseWeight;
|
||||
/// The maximum weight that a single extrinsic of `Normal` dispatch class can have,
|
||||
/// idependent of the logic of that extrinsics. (Roughly max block weight - average on
|
||||
/// initialize cost).
|
||||
type MaximumExtrinsicWeight = MaximumExtrinsicWeight;
|
||||
/// Maximum size of all encoded transactions (in bytes) that are allowed in one block.
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
/// Portion of the block weight that is available to all normal transactions.
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
/// Version of the runtime.
|
||||
type Version = Version;
|
||||
/// Provides information about the pallet setup in the runtime.
|
||||
@@ -225,14 +206,20 @@ impl frame_system::Trait for Runtime {
|
||||
// TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78)
|
||||
/// Weight information for the extrinsics of this pallet.
|
||||
type SystemWeightInfo = ();
|
||||
/// Block and extrinsics weights: base values and limits.
|
||||
type BlockWeights = RuntimeBlockWeights;
|
||||
/// The maximum length of a block (in bytes).
|
||||
type BlockLength = RuntimeBlockLength;
|
||||
/// The weight of database operations that the runtime can invoke.
|
||||
type DbWeight = DbWeight;
|
||||
}
|
||||
|
||||
impl pallet_aura::Trait for Runtime {
|
||||
impl pallet_aura::Config for Runtime {
|
||||
type AuthorityId = AuraId;
|
||||
}
|
||||
|
||||
type RialtoPoA = pallet_bridge_eth_poa::Instance1;
|
||||
impl pallet_bridge_eth_poa::Trait<RialtoPoA> for Runtime {
|
||||
impl pallet_bridge_eth_poa::Config<RialtoPoA> for Runtime {
|
||||
type AuraConfiguration = rialto_poa::BridgeAuraConfiguration;
|
||||
type FinalityVotesCachingInterval = rialto_poa::FinalityVotesCachingInterval;
|
||||
type ValidatorsConfiguration = rialto_poa::BridgeValidatorsConfiguration;
|
||||
@@ -242,7 +229,7 @@ impl pallet_bridge_eth_poa::Trait<RialtoPoA> for Runtime {
|
||||
}
|
||||
|
||||
type Kovan = pallet_bridge_eth_poa::Instance2;
|
||||
impl pallet_bridge_eth_poa::Trait<Kovan> for Runtime {
|
||||
impl pallet_bridge_eth_poa::Config<Kovan> for Runtime {
|
||||
type AuraConfiguration = kovan::BridgeAuraConfiguration;
|
||||
type FinalityVotesCachingInterval = kovan::FinalityVotesCachingInterval;
|
||||
type ValidatorsConfiguration = kovan::BridgeValidatorsConfiguration;
|
||||
@@ -252,7 +239,7 @@ impl pallet_bridge_eth_poa::Trait<Kovan> for Runtime {
|
||||
}
|
||||
|
||||
type RialtoCurrencyExchange = pallet_bridge_currency_exchange::Instance1;
|
||||
impl pallet_bridge_currency_exchange::Trait<RialtoCurrencyExchange> for Runtime {
|
||||
impl pallet_bridge_currency_exchange::Config<RialtoCurrencyExchange> for Runtime {
|
||||
type OnTransactionSubmitted = ();
|
||||
type PeerBlockchain = rialto_poa::RialtoBlockchain;
|
||||
type PeerMaybeLockFundsTransaction = exchange::EthTransaction;
|
||||
@@ -263,7 +250,7 @@ impl pallet_bridge_currency_exchange::Trait<RialtoCurrencyExchange> for Runtime
|
||||
}
|
||||
|
||||
type KovanCurrencyExchange = pallet_bridge_currency_exchange::Instance2;
|
||||
impl pallet_bridge_currency_exchange::Trait<KovanCurrencyExchange> for Runtime {
|
||||
impl pallet_bridge_currency_exchange::Config<KovanCurrencyExchange> for Runtime {
|
||||
type OnTransactionSubmitted = ();
|
||||
type PeerBlockchain = kovan::KovanBlockchain;
|
||||
type PeerMaybeLockFundsTransaction = exchange::EthTransaction;
|
||||
@@ -273,7 +260,7 @@ impl pallet_bridge_currency_exchange::Trait<KovanCurrencyExchange> for Runtime {
|
||||
type DepositInto = DepositInto;
|
||||
}
|
||||
|
||||
impl pallet_bridge_call_dispatch::Trait for Runtime {
|
||||
impl pallet_bridge_call_dispatch::Config for Runtime {
|
||||
type Event = Event;
|
||||
type MessageId = (bp_message_lane::LaneId, bp_message_lane::MessageNonce);
|
||||
type Call = Call;
|
||||
@@ -340,7 +327,7 @@ impl bp_currency_exchange::DepositInto for DepositInto {
|
||||
}
|
||||
}
|
||||
|
||||
impl pallet_grandpa::Trait for Runtime {
|
||||
impl pallet_grandpa::Config for Runtime {
|
||||
type Event = Event;
|
||||
type Call = Call;
|
||||
type KeyOwnerProofSystem = ();
|
||||
@@ -356,7 +343,7 @@ parameter_types! {
|
||||
pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
|
||||
}
|
||||
|
||||
impl pallet_timestamp::Trait for Runtime {
|
||||
impl pallet_timestamp::Config for Runtime {
|
||||
/// A timestamp: milliseconds since the unix epoch.
|
||||
type Moment = u64;
|
||||
type OnTimestampSet = Aura;
|
||||
@@ -372,7 +359,7 @@ parameter_types! {
|
||||
pub const MaxLocks: u32 = 50;
|
||||
}
|
||||
|
||||
impl pallet_balances::Trait for Runtime {
|
||||
impl pallet_balances::Config for Runtime {
|
||||
/// The type for recording an account's balance.
|
||||
type Balance = Balance;
|
||||
/// The ubiquitous event type.
|
||||
@@ -390,14 +377,14 @@ parameter_types! {
|
||||
pub const TransactionByteFee: Balance = 1;
|
||||
}
|
||||
|
||||
impl pallet_transaction_payment::Trait for Runtime {
|
||||
impl pallet_transaction_payment::Config for Runtime {
|
||||
type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;
|
||||
type TransactionByteFee = TransactionByteFee;
|
||||
type WeightToFee = IdentityFee<Balance>;
|
||||
type FeeMultiplierUpdate = ();
|
||||
}
|
||||
|
||||
impl pallet_sudo::Trait for Runtime {
|
||||
impl pallet_sudo::Config for Runtime {
|
||||
type Event = Event;
|
||||
type Call = Call;
|
||||
}
|
||||
@@ -407,9 +394,9 @@ parameter_types! {
|
||||
pub const Offset: BlockNumber = 0;
|
||||
}
|
||||
|
||||
impl pallet_session::Trait for Runtime {
|
||||
impl pallet_session::Config for Runtime {
|
||||
type Event = Event;
|
||||
type ValidatorId = <Self as frame_system::Trait>::AccountId;
|
||||
type ValidatorId = <Self as frame_system::Config>::AccountId;
|
||||
type ValidatorIdOf = ();
|
||||
type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;
|
||||
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
|
||||
@@ -421,11 +408,11 @@ impl pallet_session::Trait for Runtime {
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
impl pallet_substrate_bridge::Trait for Runtime {
|
||||
impl pallet_substrate_bridge::Config for Runtime {
|
||||
type BridgedChain = bp_millau::Millau;
|
||||
}
|
||||
|
||||
impl pallet_shift_session_manager::Trait for Runtime {}
|
||||
impl pallet_shift_session_manager::Config for Runtime {}
|
||||
|
||||
parameter_types! {
|
||||
pub const MaxMessagesToPruneAtOnce: bp_message_lane::MessageNonce = 8;
|
||||
@@ -438,7 +425,7 @@ parameter_types! {
|
||||
}
|
||||
|
||||
pub(crate) type WithMillauMessageLaneInstance = pallet_message_lane::DefaultInstance;
|
||||
impl pallet_message_lane::Trait for Runtime {
|
||||
impl pallet_message_lane::Config for Runtime {
|
||||
type Event = Event;
|
||||
type MaxMessagesToPruneAtOnce = MaxMessagesToPruneAtOnce;
|
||||
type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane;
|
||||
@@ -777,18 +764,18 @@ impl_runtime_apis! {
|
||||
|
||||
use pallet_bridge_currency_exchange::benchmarking::{
|
||||
Module as BridgeCurrencyExchangeBench,
|
||||
Trait as BridgeCurrencyExchangeTrait,
|
||||
Config as BridgeCurrencyExchangeConfig,
|
||||
ProofParams as BridgeCurrencyExchangeProofParams,
|
||||
};
|
||||
|
||||
impl BridgeCurrencyExchangeTrait<KovanCurrencyExchange> for Runtime {
|
||||
impl BridgeCurrencyExchangeConfig<KovanCurrencyExchange> for Runtime {
|
||||
fn make_proof(
|
||||
proof_params: BridgeCurrencyExchangeProofParams<AccountId>,
|
||||
) -> crate::exchange::EthereumTransactionInclusionProof {
|
||||
use bp_currency_exchange::DepositInto;
|
||||
|
||||
if proof_params.recipient_exists {
|
||||
<Runtime as pallet_bridge_currency_exchange::Trait<KovanCurrencyExchange>>::DepositInto::deposit_into(
|
||||
<Runtime as pallet_bridge_currency_exchange::Config<KovanCurrencyExchange>>::DepositInto::deposit_into(
|
||||
proof_params.recipient.clone(),
|
||||
ExistentialDeposit::get(),
|
||||
).unwrap();
|
||||
@@ -817,11 +804,11 @@ impl_runtime_apis! {
|
||||
|
||||
use pallet_message_lane::benchmarking::{
|
||||
Module as MessageLaneBench,
|
||||
Trait as MessageLaneTrait,
|
||||
Config as MessageLaneConfig,
|
||||
MessageParams as MessageLaneMessageParams,
|
||||
};
|
||||
|
||||
impl MessageLaneTrait<WithMillauMessageLaneInstance> for Runtime {
|
||||
impl MessageLaneConfig<WithMillauMessageLaneInstance> for Runtime {
|
||||
fn endow_account(account: &Self::AccountId) {
|
||||
pallet_balances::Module::<Runtime>::make_free_balance_be(
|
||||
account,
|
||||
@@ -923,7 +910,7 @@ mod tests {
|
||||
let initial_amount =
|
||||
<pallet_balances::Module<Runtime> as Currency<AccountId>>::free_balance(&existing_account);
|
||||
let additional_amount = 10_000;
|
||||
<Runtime as pallet_bridge_currency_exchange::Trait<KovanCurrencyExchange>>::DepositInto::deposit_into(
|
||||
<Runtime as pallet_bridge_currency_exchange::Config<KovanCurrencyExchange>>::DepositInto::deposit_into(
|
||||
existing_account.clone(),
|
||||
additional_amount,
|
||||
)
|
||||
@@ -942,7 +929,7 @@ mod tests {
|
||||
let initial_amount = 0;
|
||||
let additional_amount = ExistentialDeposit::get() + 10_000;
|
||||
let new_account: AccountId = [42u8; 32].into();
|
||||
<Runtime as pallet_bridge_currency_exchange::Trait<KovanCurrencyExchange>>::DepositInto::deposit_into(
|
||||
<Runtime as pallet_bridge_currency_exchange::Config<KovanCurrencyExchange>>::DepositInto::deposit_into(
|
||||
new_account.clone(),
|
||||
additional_amount,
|
||||
)
|
||||
|
||||
@@ -89,12 +89,12 @@ impl MessageBridge for WithMillauMessageBridge {
|
||||
type BridgedChain = Millau;
|
||||
|
||||
fn maximal_extrinsic_size_on_target_chain() -> u32 {
|
||||
bp_millau::MAXIMUM_EXTRINSIC_SIZE
|
||||
bp_millau::max_extrinsic_size()
|
||||
}
|
||||
|
||||
fn weight_limits_of_message_on_bridged_chain(message_payload: &[u8]) -> RangeInclusive<Weight> {
|
||||
// we don't want to relay too large messages + keep reserve for future upgrades
|
||||
let upper_limit = bp_millau::MAXIMUM_EXTRINSIC_WEIGHT / 2;
|
||||
let upper_limit = bp_millau::max_extrinsic_weight() / 2;
|
||||
|
||||
// given Millau chain parameters (`TransactionByteFee`, `WeightToFee`, `FeeMultiplierUpdate`),
|
||||
// the minimal weight of the message may be computed as message.length()
|
||||
@@ -116,12 +116,12 @@ impl MessageBridge for WithMillauMessageBridge {
|
||||
}
|
||||
|
||||
fn this_weight_to_this_balance(weight: Weight) -> bp_rialto::Balance {
|
||||
<crate::Runtime as pallet_transaction_payment::Trait>::WeightToFee::calc(&weight)
|
||||
<crate::Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(&weight)
|
||||
}
|
||||
|
||||
fn bridged_weight_to_bridged_balance(weight: Weight) -> bp_millau::Balance {
|
||||
// we're using the same weights in both chains now
|
||||
<crate::Runtime as pallet_transaction_payment::Trait>::WeightToFee::calc(&weight) as _
|
||||
<crate::Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(&weight) as _
|
||||
}
|
||||
|
||||
fn this_balance_to_bridged_balance(this_balance: bp_rialto::Balance) -> bp_millau::Balance {
|
||||
|
||||
Reference in New Issue
Block a user