mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-06 04:28:01 +00:00
Move benchmarks from Rialto to Millau (#1277)
* move brnchmarks from Rialto to Millau * fix limits test
This commit is contained in:
committed by
Bastian Köcher
parent
eb5a3eecd2
commit
00f68e7722
@@ -10,12 +10,14 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
[dependencies]
|
||||
hex-literal = "0.3"
|
||||
codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false, features = ["derive"] }
|
||||
libsecp256k1 = { version = "0.7", optional = true, default-features = false, features = ["hmac"] }
|
||||
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
|
||||
serde = { version = "1.0", optional = true, features = ["derive"] }
|
||||
|
||||
# Bridge dependencies
|
||||
|
||||
bp-header-chain = { path = "../../../primitives/header-chain", default-features = false }
|
||||
bp-message-dispatch = { path = "../../../primitives/message-dispatch", default-features = false }
|
||||
bp-messages = { path = "../../../primitives/messages", default-features = false }
|
||||
bp-millau = { path = "../../../primitives/chain-millau", default-features = false }
|
||||
bp-rialto = { path = "../../../primitives/chain-rialto", default-features = false }
|
||||
@@ -71,6 +73,7 @@ default = ["std"]
|
||||
std = [
|
||||
"beefy-primitives/std",
|
||||
"bp-header-chain/std",
|
||||
"bp-message-dispatch/std",
|
||||
"bp-messages/std",
|
||||
"bp-millau/std",
|
||||
"bp-rialto/std",
|
||||
@@ -116,8 +119,12 @@ std = [
|
||||
"sp-version/std",
|
||||
]
|
||||
runtime-benchmarks = [
|
||||
"bridge-runtime-common/runtime-benchmarks",
|
||||
"frame-benchmarking",
|
||||
"frame-support/runtime-benchmarks",
|
||||
"frame-system/runtime-benchmarks",
|
||||
"libsecp256k1",
|
||||
"pallet-bridge-messages/runtime-benchmarks",
|
||||
"pallet-bridge-token-swap/runtime-benchmarks",
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
]
|
||||
|
||||
@@ -374,12 +374,26 @@ parameter_types! {
|
||||
// Note that once this is hit the pallet will essentially throttle incoming requests down to one
|
||||
// call per block.
|
||||
pub const MaxRequests: u32 = 50;
|
||||
}
|
||||
|
||||
// Number of headers to keep.
|
||||
//
|
||||
// Assuming the worst case of every header being finalized, we will keep headers for at least a
|
||||
// week.
|
||||
pub const HeadersToKeep: u32 = 7 * bp_millau::DAYS as u32;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
parameter_types! {
|
||||
/// Number of headers to keep in benchmarks.
|
||||
///
|
||||
/// In benchmarks we always populate with full number of `HeadersToKeep` to make sure that
|
||||
/// pruning is taken into account.
|
||||
///
|
||||
/// Note: This is lower than regular value, to speed up benchmarking setup.
|
||||
pub const HeadersToKeep: u32 = 1024;
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "runtime-benchmarks"))]
|
||||
parameter_types! {
|
||||
/// Number of headers to keep.
|
||||
///
|
||||
/// Assuming the worst case of every header being finalized, we will keep headers at least for a
|
||||
/// week.
|
||||
pub const HeadersToKeep: u32 = 7 * bp_rialto::DAYS as u32;
|
||||
}
|
||||
|
||||
pub type RialtoGrandpaInstance = ();
|
||||
@@ -388,8 +402,7 @@ impl pallet_bridge_grandpa::Config for Runtime {
|
||||
type MaxRequests = MaxRequests;
|
||||
type HeadersToKeep = HeadersToKeep;
|
||||
|
||||
// TODO [#391]: Use weights generated for the Millau runtime instead of Rialto ones.
|
||||
type WeightInfo = pallet_bridge_grandpa::weights::RialtoWeight<Runtime>;
|
||||
type WeightInfo = pallet_bridge_grandpa::weights::MillauWeight<Runtime>;
|
||||
}
|
||||
|
||||
pub type WestendGrandpaInstance = pallet_bridge_grandpa::Instance1;
|
||||
@@ -398,8 +411,7 @@ impl pallet_bridge_grandpa::Config<WestendGrandpaInstance> for Runtime {
|
||||
type MaxRequests = MaxRequests;
|
||||
type HeadersToKeep = HeadersToKeep;
|
||||
|
||||
// TODO [#391]: Use weights generated for the Millau runtime instead of Rialto ones.
|
||||
type WeightInfo = pallet_bridge_grandpa::weights::RialtoWeight<Runtime>;
|
||||
type WeightInfo = pallet_bridge_grandpa::weights::MillauWeight<Runtime>;
|
||||
}
|
||||
|
||||
impl pallet_shift_session_manager::Config for Runtime {}
|
||||
@@ -422,8 +434,7 @@ pub type WithRialtoMessagesInstance = ();
|
||||
|
||||
impl pallet_bridge_messages::Config<WithRialtoMessagesInstance> for Runtime {
|
||||
type Event = Event;
|
||||
// TODO: https://github.com/paritytech/parity-bridges-common/issues/390
|
||||
type WeightInfo = pallet_bridge_messages::weights::RialtoWeight<Runtime>;
|
||||
type WeightInfo = pallet_bridge_messages::weights::MillauWeight<Runtime>;
|
||||
type Parameter = rialto_messages::MillauToRialtoMessagesParameter;
|
||||
type MaxMessagesToPruneAtOnce = MaxMessagesToPruneAtOnce;
|
||||
type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane;
|
||||
@@ -783,9 +794,13 @@ impl_runtime_apis! {
|
||||
use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};
|
||||
use frame_support::traits::StorageInfoTrait;
|
||||
|
||||
use pallet_bridge_messages::benchmarking::Pallet as MessagesBench;
|
||||
|
||||
let mut list = Vec::<BenchmarkList>::new();
|
||||
|
||||
list_benchmark!(list, extra, pallet_bridge_token_swap, BridgeRialtoTokenSwap);
|
||||
list_benchmark!(list, extra, pallet_bridge_messages, MessagesBench::<Runtime, WithRialtoMessagesInstance>);
|
||||
list_benchmark!(list, extra, pallet_bridge_grandpa, BridgeRialtoGrandpa);
|
||||
|
||||
let storage_info = AllPalletsWithSystem::storage_info();
|
||||
|
||||
@@ -813,6 +828,171 @@ impl_runtime_apis! {
|
||||
let mut batches = Vec::<BenchmarkBatch>::new();
|
||||
let params = (&config, &whitelist);
|
||||
|
||||
use bp_runtime::messages::DispatchFeePayment;
|
||||
use bridge_runtime_common::messages;
|
||||
use pallet_bridge_messages::benchmarking::{
|
||||
Pallet as MessagesBench,
|
||||
Config as MessagesConfig,
|
||||
MessageDeliveryProofParams,
|
||||
MessageParams,
|
||||
MessageProofParams,
|
||||
ProofSize as MessagesProofSize,
|
||||
};
|
||||
use rialto_messages::{ToRialtoMessagePayload, WithRialtoMessageBridge};
|
||||
|
||||
impl MessagesConfig<WithRialtoMessagesInstance> for Runtime {
|
||||
fn maximal_message_size() -> u32 {
|
||||
messages::source::maximal_message_size::<WithRialtoMessageBridge>()
|
||||
}
|
||||
|
||||
fn bridged_relayer_id() -> Self::InboundRelayer {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
fn account_balance(account: &Self::AccountId) -> Self::OutboundMessageFee {
|
||||
pallet_balances::Pallet::<Runtime>::free_balance(account)
|
||||
}
|
||||
|
||||
fn endow_account(account: &Self::AccountId) {
|
||||
pallet_balances::Pallet::<Runtime>::make_free_balance_be(
|
||||
account,
|
||||
Balance::MAX / 100,
|
||||
);
|
||||
}
|
||||
|
||||
fn prepare_outbound_message(
|
||||
params: MessageParams<Self::AccountId>,
|
||||
) -> (rialto_messages::ToRialtoMessagePayload, Balance) {
|
||||
let message_payload = vec![0; params.size as usize];
|
||||
let dispatch_origin = bp_message_dispatch::CallOrigin::SourceAccount(
|
||||
params.sender_account,
|
||||
);
|
||||
|
||||
let message = ToRialtoMessagePayload {
|
||||
spec_version: 0,
|
||||
weight: params.size as _,
|
||||
origin: dispatch_origin,
|
||||
call: message_payload,
|
||||
dispatch_fee_payment: DispatchFeePayment::AtSourceChain,
|
||||
};
|
||||
(message, pallet_bridge_messages::benchmarking::MESSAGE_FEE.into())
|
||||
}
|
||||
|
||||
fn prepare_message_proof(
|
||||
params: MessageProofParams,
|
||||
) -> (rialto_messages::FromRialtoMessagesProof, Weight) {
|
||||
use bp_messages::{MessageKey, storage_keys};
|
||||
use bridge_runtime_common::{
|
||||
messages::MessageBridge,
|
||||
messages_benchmarking::{ed25519_sign, prepare_message_proof},
|
||||
};
|
||||
use codec::Encode;
|
||||
use frame_support::weights::GetDispatchInfo;
|
||||
use rialto_messages::WithRialtoMessageBridge;
|
||||
use sp_runtime::traits::{Header, IdentifyAccount};
|
||||
|
||||
let remark = match params.size {
|
||||
MessagesProofSize::Minimal(ref size) => vec![0u8; *size as _],
|
||||
_ => vec![],
|
||||
};
|
||||
let call = Call::System(SystemCall::remark { remark });
|
||||
let call_weight = call.get_dispatch_info().weight;
|
||||
|
||||
let rialto_account_id: bp_rialto::AccountId = Default::default();
|
||||
let (millau_raw_public, millau_raw_signature) = ed25519_sign(
|
||||
&call,
|
||||
&rialto_account_id,
|
||||
VERSION.spec_version,
|
||||
bp_runtime::RIALTO_CHAIN_ID,
|
||||
bp_runtime::MILLAU_CHAIN_ID,
|
||||
);
|
||||
let millau_public = MultiSigner::Ed25519(sp_core::ed25519::Public::from_raw(millau_raw_public));
|
||||
let millau_signature = MultiSignature::Ed25519(sp_core::ed25519::Signature::from_raw(
|
||||
millau_raw_signature,
|
||||
));
|
||||
|
||||
if params.dispatch_fee_payment == DispatchFeePayment::AtTargetChain {
|
||||
Self::endow_account(&millau_public.clone().into_account());
|
||||
}
|
||||
|
||||
let make_rialto_message_key = |message_key: MessageKey| storage_keys::message_key(
|
||||
<WithRialtoMessageBridge as MessageBridge>::BRIDGED_MESSAGES_PALLET_NAME,
|
||||
&message_key.lane_id, message_key.nonce,
|
||||
).0;
|
||||
let make_rialto_outbound_lane_data_key = |lane_id| storage_keys::outbound_lane_data_key(
|
||||
<WithRialtoMessageBridge as MessageBridge>::BRIDGED_MESSAGES_PALLET_NAME,
|
||||
&lane_id,
|
||||
).0;
|
||||
|
||||
let make_rialto_header = |state_root| bp_rialto::Header::new(
|
||||
0,
|
||||
Default::default(),
|
||||
state_root,
|
||||
Default::default(),
|
||||
Default::default(),
|
||||
);
|
||||
|
||||
let dispatch_fee_payment = params.dispatch_fee_payment.clone();
|
||||
prepare_message_proof::<WithRialtoMessageBridge, bp_rialto::Hasher, Runtime, (), _, _, _>(
|
||||
params,
|
||||
make_rialto_message_key,
|
||||
make_rialto_outbound_lane_data_key,
|
||||
make_rialto_header,
|
||||
call_weight,
|
||||
bp_message_dispatch::MessagePayload {
|
||||
spec_version: VERSION.spec_version,
|
||||
weight: call_weight,
|
||||
origin: bp_message_dispatch::CallOrigin::<
|
||||
bp_rialto::AccountId,
|
||||
MultiSigner,
|
||||
Signature,
|
||||
>::TargetAccount(
|
||||
rialto_account_id,
|
||||
millau_public,
|
||||
millau_signature,
|
||||
),
|
||||
dispatch_fee_payment,
|
||||
call: call.encode(),
|
||||
}.encode(),
|
||||
)
|
||||
}
|
||||
|
||||
fn prepare_message_delivery_proof(
|
||||
params: MessageDeliveryProofParams<Self::AccountId>,
|
||||
) -> rialto_messages::ToRialtoMessagesDeliveryProof {
|
||||
use bridge_runtime_common::messages_benchmarking::prepare_message_delivery_proof;
|
||||
use rialto_messages::WithRialtoMessageBridge;
|
||||
use sp_runtime::traits::Header;
|
||||
|
||||
prepare_message_delivery_proof::<WithRialtoMessageBridge, bp_rialto::Hasher, Runtime, (), _, _>(
|
||||
params,
|
||||
|lane_id| bp_messages::storage_keys::inbound_lane_data_key(
|
||||
<WithRialtoMessageBridge as MessageBridge>::BRIDGED_MESSAGES_PALLET_NAME,
|
||||
&lane_id,
|
||||
).0,
|
||||
|state_root| bp_rialto::Header::new(
|
||||
0,
|
||||
Default::default(),
|
||||
state_root,
|
||||
Default::default(),
|
||||
Default::default(),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
fn is_message_dispatched(nonce: bp_messages::MessageNonce) -> bool {
|
||||
frame_system::Pallet::<Runtime>::events()
|
||||
.into_iter()
|
||||
.map(|event_record| event_record.event)
|
||||
.any(|event| matches!(
|
||||
event,
|
||||
Event::BridgeDispatch(pallet_bridge_dispatch::Event::<Runtime, _>::MessageDispatched(
|
||||
_, ([0, 0, 0, 0], nonce_from_event), _,
|
||||
)) if nonce_from_event == nonce
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
use pallet_bridge_token_swap::benchmarking::Config as TokenSwapConfig;
|
||||
|
||||
impl TokenSwapConfig<WithRialtoTokenSwapInstance> for Runtime {
|
||||
@@ -828,6 +1008,13 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
add_benchmark!(
|
||||
params,
|
||||
batches,
|
||||
pallet_bridge_messages,
|
||||
MessagesBench::<Runtime, WithRialtoMessagesInstance>
|
||||
);
|
||||
add_benchmark!(params, batches, pallet_bridge_grandpa, BridgeRialtoGrandpa);
|
||||
add_benchmark!(params, batches, pallet_bridge_token_swap, BridgeRialtoTokenSwap);
|
||||
|
||||
if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
|
||||
@@ -868,8 +1055,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn ensure_millau_message_lane_weights_are_correct() {
|
||||
// TODO: https://github.com/paritytech/parity-bridges-common/issues/390
|
||||
type Weights = pallet_bridge_messages::weights::RialtoWeight<Runtime>;
|
||||
type Weights = pallet_bridge_messages::weights::MillauWeight<Runtime>;
|
||||
|
||||
pallet_bridge_messages::ensure_weights_are_correct::<Weights>(
|
||||
bp_millau::DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT,
|
||||
|
||||
@@ -64,10 +64,10 @@ pub type FromRialtoMessagePayload =
|
||||
pub type FromRialtoEncodedCall = messages::target::FromBridgedChainEncodedMessageCall<crate::Call>;
|
||||
|
||||
/// Messages proof for Rialto -> Millau messages.
|
||||
type FromRialtoMessagesProof = messages::target::FromBridgedChainMessagesProof<bp_rialto::Hash>;
|
||||
pub type FromRialtoMessagesProof = messages::target::FromBridgedChainMessagesProof<bp_rialto::Hash>;
|
||||
|
||||
/// Messages delivery proof for Millau -> Rialto messages.
|
||||
type ToRialtoMessagesDeliveryProof =
|
||||
pub type ToRialtoMessagesDeliveryProof =
|
||||
messages::source::FromBridgedChainMessagesDeliveryProof<bp_rialto::Hash>;
|
||||
|
||||
/// Call-dispatch based message dispatch for Rialto -> Millau messages.
|
||||
|
||||
@@ -399,21 +399,7 @@ parameter_types! {
|
||||
/// Note that once this is hit the pallet will essentially throttle incoming requests down to one
|
||||
/// call per block.
|
||||
pub const MaxRequests: u32 = 50;
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
parameter_types! {
|
||||
/// Number of headers to keep in benchmarks.
|
||||
///
|
||||
/// In benchmarks we always populate with full number of `HeadersToKeep` to make sure that
|
||||
/// pruning is taken into account.
|
||||
///
|
||||
/// Note: This is lower than regular value, to speed up benchmarking setup.
|
||||
pub const HeadersToKeep: u32 = 1024;
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "runtime-benchmarks"))]
|
||||
parameter_types! {
|
||||
/// Number of headers to keep.
|
||||
///
|
||||
/// Assuming the worst case of every header being finalized, we will keep headers at least for a
|
||||
@@ -426,7 +412,7 @@ impl pallet_bridge_grandpa::Config for Runtime {
|
||||
type BridgedChain = bp_millau::Millau;
|
||||
type MaxRequests = MaxRequests;
|
||||
type HeadersToKeep = HeadersToKeep;
|
||||
type WeightInfo = pallet_bridge_grandpa::weights::RialtoWeight<Runtime>;
|
||||
type WeightInfo = pallet_bridge_grandpa::weights::MillauWeight<Runtime>;
|
||||
}
|
||||
|
||||
impl pallet_shift_session_manager::Config for Runtime {}
|
||||
@@ -449,7 +435,7 @@ pub type WithMillauMessagesInstance = ();
|
||||
|
||||
impl pallet_bridge_messages::Config<WithMillauMessagesInstance> for Runtime {
|
||||
type Event = Event;
|
||||
type WeightInfo = pallet_bridge_messages::weights::RialtoWeight<Runtime>;
|
||||
type WeightInfo = pallet_bridge_messages::weights::MillauWeight<Runtime>;
|
||||
type Parameter = millau_messages::RialtoToMillauMessagesParameter;
|
||||
type MaxMessagesToPruneAtOnce = MaxMessagesToPruneAtOnce;
|
||||
type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane;
|
||||
@@ -921,226 +907,6 @@ impl_runtime_apis! {
|
||||
BridgeMillauMessages::inbound_unrewarded_relayers_state(lane)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
impl frame_benchmarking::Benchmark<Block> for Runtime {
|
||||
fn benchmark_metadata(extra: bool) -> (
|
||||
Vec<frame_benchmarking::BenchmarkList>,
|
||||
Vec<frame_support::traits::StorageInfo>,
|
||||
) {
|
||||
use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};
|
||||
use frame_support::traits::StorageInfoTrait;
|
||||
|
||||
use pallet_bridge_messages::benchmarking::Pallet as MessagesBench;
|
||||
|
||||
let mut list = Vec::<BenchmarkList>::new();
|
||||
|
||||
list_benchmark!(list, extra, pallet_bridge_messages, MessagesBench::<Runtime, WithMillauMessagesInstance>);
|
||||
list_benchmark!(list, extra, pallet_bridge_grandpa, BridgeMillauGrandpa);
|
||||
|
||||
let storage_info = AllPalletsWithSystem::storage_info();
|
||||
|
||||
return (list, storage_info)
|
||||
}
|
||||
|
||||
fn dispatch_benchmark(
|
||||
config: frame_benchmarking::BenchmarkConfig,
|
||||
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
|
||||
use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey, add_benchmark};
|
||||
|
||||
let whitelist: Vec<TrackedStorageKey> = vec![
|
||||
// Block Number
|
||||
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),
|
||||
// Execution Phase
|
||||
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),
|
||||
// Event Count
|
||||
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),
|
||||
// System Events
|
||||
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),
|
||||
// Caller 0 Account
|
||||
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da946c154ffd9992e395af90b5b13cc6f295c77033fce8a9045824a6690bbf99c6db269502f0a8d1d2a008542d5690a0749").to_vec().into(),
|
||||
];
|
||||
|
||||
let mut batches = Vec::<BenchmarkBatch>::new();
|
||||
let params = (&config, &whitelist);
|
||||
|
||||
use crate::millau_messages::{ToMillauMessagePayload, WithMillauMessageBridge};
|
||||
use bp_runtime::messages::DispatchFeePayment;
|
||||
use bridge_runtime_common::messages;
|
||||
use pallet_bridge_messages::benchmarking::{
|
||||
Pallet as MessagesBench,
|
||||
Config as MessagesConfig,
|
||||
MessageDeliveryProofParams,
|
||||
MessageParams,
|
||||
MessageProofParams,
|
||||
ProofSize as MessagesProofSize,
|
||||
};
|
||||
|
||||
impl MessagesConfig<WithMillauMessagesInstance> for Runtime {
|
||||
fn maximal_message_size() -> u32 {
|
||||
messages::source::maximal_message_size::<WithMillauMessageBridge>()
|
||||
}
|
||||
|
||||
fn bridged_relayer_id() -> Self::InboundRelayer {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
fn account_balance(account: &Self::AccountId) -> Self::OutboundMessageFee {
|
||||
pallet_balances::Pallet::<Runtime>::free_balance(account)
|
||||
}
|
||||
|
||||
fn endow_account(account: &Self::AccountId) {
|
||||
pallet_balances::Pallet::<Runtime>::make_free_balance_be(
|
||||
account,
|
||||
Balance::MAX / 100,
|
||||
);
|
||||
}
|
||||
|
||||
fn prepare_outbound_message(
|
||||
params: MessageParams<Self::AccountId>,
|
||||
) -> (millau_messages::ToMillauMessagePayload, Balance) {
|
||||
let message_payload = vec![0; params.size as usize];
|
||||
let dispatch_origin = bp_message_dispatch::CallOrigin::SourceAccount(
|
||||
params.sender_account,
|
||||
);
|
||||
|
||||
let message = ToMillauMessagePayload {
|
||||
spec_version: 0,
|
||||
weight: params.size as _,
|
||||
origin: dispatch_origin,
|
||||
call: message_payload,
|
||||
dispatch_fee_payment: DispatchFeePayment::AtSourceChain,
|
||||
};
|
||||
(message, pallet_bridge_messages::benchmarking::MESSAGE_FEE.into())
|
||||
}
|
||||
|
||||
fn prepare_message_proof(
|
||||
params: MessageProofParams,
|
||||
) -> (millau_messages::FromMillauMessagesProof, Weight) {
|
||||
use crate::millau_messages::WithMillauMessageBridge;
|
||||
use bp_messages::{MessageKey, storage_keys};
|
||||
use bridge_runtime_common::{
|
||||
messages::MessageBridge,
|
||||
messages_benchmarking::{ed25519_sign, prepare_message_proof},
|
||||
};
|
||||
use codec::Encode;
|
||||
use frame_support::weights::GetDispatchInfo;
|
||||
use sp_runtime::traits::{Header, IdentifyAccount};
|
||||
|
||||
let remark = match params.size {
|
||||
MessagesProofSize::Minimal(ref size) => vec![0u8; *size as _],
|
||||
_ => vec![],
|
||||
};
|
||||
let call = Call::System(SystemCall::remark { remark });
|
||||
let call_weight = call.get_dispatch_info().weight;
|
||||
|
||||
let millau_account_id: bp_millau::AccountId = Default::default();
|
||||
let (rialto_raw_public, rialto_raw_signature) = ed25519_sign(
|
||||
&call,
|
||||
&millau_account_id,
|
||||
VERSION.spec_version,
|
||||
bp_runtime::MILLAU_CHAIN_ID,
|
||||
bp_runtime::RIALTO_CHAIN_ID,
|
||||
);
|
||||
let rialto_public = MultiSigner::Ed25519(sp_core::ed25519::Public::from_raw(rialto_raw_public));
|
||||
let rialto_signature = MultiSignature::Ed25519(sp_core::ed25519::Signature::from_raw(
|
||||
rialto_raw_signature,
|
||||
));
|
||||
|
||||
if params.dispatch_fee_payment == DispatchFeePayment::AtTargetChain {
|
||||
Self::endow_account(&rialto_public.clone().into_account());
|
||||
}
|
||||
|
||||
let make_millau_message_key = |message_key: MessageKey| storage_keys::message_key(
|
||||
<WithMillauMessageBridge as MessageBridge>::BRIDGED_MESSAGES_PALLET_NAME,
|
||||
&message_key.lane_id, message_key.nonce,
|
||||
).0;
|
||||
let make_millau_outbound_lane_data_key = |lane_id| storage_keys::outbound_lane_data_key(
|
||||
<WithMillauMessageBridge as MessageBridge>::BRIDGED_MESSAGES_PALLET_NAME,
|
||||
&lane_id,
|
||||
).0;
|
||||
|
||||
let make_millau_header = |state_root| bp_millau::Header::new(
|
||||
0,
|
||||
Default::default(),
|
||||
state_root,
|
||||
Default::default(),
|
||||
Default::default(),
|
||||
);
|
||||
|
||||
let dispatch_fee_payment = params.dispatch_fee_payment.clone();
|
||||
prepare_message_proof::<WithMillauMessageBridge, bp_millau::Hasher, Runtime, (), _, _, _>(
|
||||
params,
|
||||
make_millau_message_key,
|
||||
make_millau_outbound_lane_data_key,
|
||||
make_millau_header,
|
||||
call_weight,
|
||||
bp_message_dispatch::MessagePayload {
|
||||
spec_version: VERSION.spec_version,
|
||||
weight: call_weight,
|
||||
origin: bp_message_dispatch::CallOrigin::<
|
||||
bp_millau::AccountId,
|
||||
MultiSigner,
|
||||
Signature,
|
||||
>::TargetAccount(
|
||||
millau_account_id,
|
||||
rialto_public,
|
||||
rialto_signature,
|
||||
),
|
||||
dispatch_fee_payment,
|
||||
call: call.encode(),
|
||||
}.encode(),
|
||||
)
|
||||
}
|
||||
|
||||
fn prepare_message_delivery_proof(
|
||||
params: MessageDeliveryProofParams<Self::AccountId>,
|
||||
) -> millau_messages::ToMillauMessagesDeliveryProof {
|
||||
use crate::millau_messages::WithMillauMessageBridge;
|
||||
use bridge_runtime_common::{messages_benchmarking::prepare_message_delivery_proof};
|
||||
use sp_runtime::traits::Header;
|
||||
|
||||
prepare_message_delivery_proof::<WithMillauMessageBridge, bp_millau::Hasher, Runtime, (), _, _>(
|
||||
params,
|
||||
|lane_id| bp_messages::storage_keys::inbound_lane_data_key(
|
||||
<WithMillauMessageBridge as MessageBridge>::BRIDGED_MESSAGES_PALLET_NAME,
|
||||
&lane_id,
|
||||
).0,
|
||||
|state_root| bp_millau::Header::new(
|
||||
0,
|
||||
Default::default(),
|
||||
state_root,
|
||||
Default::default(),
|
||||
Default::default(),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
fn is_message_dispatched(nonce: bp_messages::MessageNonce) -> bool {
|
||||
frame_system::Pallet::<Runtime>::events()
|
||||
.into_iter()
|
||||
.map(|event_record| event_record.event)
|
||||
.any(|event| matches!(
|
||||
event,
|
||||
Event::BridgeDispatch(pallet_bridge_dispatch::Event::<Runtime, _>::MessageDispatched(
|
||||
_, ([0, 0, 0, 0], nonce_from_event), _,
|
||||
)) if nonce_from_event == nonce
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
add_benchmark!(
|
||||
params,
|
||||
batches,
|
||||
pallet_bridge_messages,
|
||||
MessagesBench::<Runtime, WithMillauMessagesInstance>
|
||||
);
|
||||
add_benchmark!(params, batches, pallet_bridge_grandpa, BridgeMillauGrandpa);
|
||||
|
||||
if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
|
||||
Ok(batches)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Millau account ownership digest from Rialto.
|
||||
@@ -1175,7 +941,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn ensure_rialto_message_lane_weights_are_correct() {
|
||||
type Weights = pallet_bridge_messages::weights::RialtoWeight<Runtime>;
|
||||
type Weights = pallet_bridge_messages::weights::MillauWeight<Runtime>;
|
||||
|
||||
pallet_bridge_messages::ensure_weights_are_correct::<Weights>(
|
||||
bp_rialto::DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT,
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
|
||||
//! Autogenerated weights for `pallet_bridge_grandpa`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
|
||||
//! DATE: 2021-06-03, STEPS: [50, ], REPEAT: 20
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2021-12-28, STEPS: 50, REPEAT: 20
|
||||
//! LOW RANGE: [], HIGH RANGE: []
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled
|
||||
//! CHAIN: Some("dev"), DB CACHE: 128
|
||||
|
||||
// Executed Command:
|
||||
// target/release/rialto-bridge-node
|
||||
// target/release/millau-bridge-node
|
||||
// benchmark
|
||||
// --chain=dev
|
||||
// --steps=50
|
||||
@@ -34,7 +34,7 @@
|
||||
// --wasm-execution=Compiled
|
||||
// --heap-pages=4096
|
||||
// --output=./modules/grandpa/src/weights.rs
|
||||
// --template=./.maintain/rialto-weight-template.hbs
|
||||
// --template=./.maintain/millau-weight-template.hbs
|
||||
|
||||
#![allow(clippy::all)]
|
||||
#![allow(unused_parens)]
|
||||
@@ -51,13 +51,13 @@ pub trait WeightInfo {
|
||||
fn submit_finality_proof(p: u32, v: u32) -> Weight;
|
||||
}
|
||||
|
||||
/// Weights for `pallet_bridge_grandpa` using the Rialto node and recommended hardware.
|
||||
pub struct RialtoWeight<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> WeightInfo for RialtoWeight<T> {
|
||||
/// Weights for `pallet_bridge_grandpa` using the Millau node and recommended hardware.
|
||||
pub struct MillauWeight<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> WeightInfo for MillauWeight<T> {
|
||||
fn submit_finality_proof(p: u32, v: u32) -> Weight {
|
||||
(0 as Weight)
|
||||
.saturating_add((59_692_000 as Weight).saturating_mul(p as Weight))
|
||||
.saturating_add((6_876_000 as Weight).saturating_mul(v as Weight))
|
||||
(115_651_000 as Weight)
|
||||
.saturating_add((61_465_000 as Weight).saturating_mul(p as Weight))
|
||||
.saturating_add((3_438_000 as Weight).saturating_mul(v as Weight))
|
||||
.saturating_add(T::DbWeight::get().reads(7 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(6 as Weight))
|
||||
}
|
||||
@@ -66,9 +66,9 @@ impl<T: frame_system::Config> WeightInfo for RialtoWeight<T> {
|
||||
// For backwards compatibility and tests
|
||||
impl WeightInfo for () {
|
||||
fn submit_finality_proof(p: u32, v: u32) -> Weight {
|
||||
(0 as Weight)
|
||||
.saturating_add((59_692_000 as Weight).saturating_mul(p as Weight))
|
||||
.saturating_add((6_876_000 as Weight).saturating_mul(v as Weight))
|
||||
(115_651_000 as Weight)
|
||||
.saturating_add((61_465_000 as Weight).saturating_mul(p as Weight))
|
||||
.saturating_add((3_438_000 as Weight).saturating_mul(v as Weight))
|
||||
.saturating_add(RocksDbWeight::get().reads(7 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(6 as Weight))
|
||||
}
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
|
||||
//! Autogenerated weights for `pallet_bridge_messages`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
|
||||
//! DATE: 2021-06-18, STEPS: [50, ], REPEAT: 20
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2021-12-28, STEPS: 50, REPEAT: 20
|
||||
//! LOW RANGE: [], HIGH RANGE: []
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled
|
||||
//! CHAIN: Some("dev"), DB CACHE: 128
|
||||
|
||||
// Executed Command:
|
||||
// target/release/rialto-bridge-node
|
||||
// target/release/millau-bridge-node
|
||||
// benchmark
|
||||
// --chain=dev
|
||||
// --steps=50
|
||||
@@ -34,7 +34,7 @@
|
||||
// --wasm-execution=Compiled
|
||||
// --heap-pages=4096
|
||||
// --output=./modules/messages/src/weights.rs
|
||||
// --template=./.maintain/rialto-weight-template.hbs
|
||||
// --template=./.maintain/millau-weight-template.hbs
|
||||
|
||||
#![allow(clippy::all)]
|
||||
#![allow(unused_parens)]
|
||||
@@ -71,120 +71,120 @@ pub trait WeightInfo {
|
||||
fn receive_delivery_proof_for_multiple_messages_by_multiple_relayers(i: u32) -> Weight;
|
||||
}
|
||||
|
||||
/// Weights for `pallet_bridge_messages` using the Rialto node and recommended hardware.
|
||||
pub struct RialtoWeight<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> WeightInfo for RialtoWeight<T> {
|
||||
/// Weights for `pallet_bridge_messages` using the Millau node and recommended hardware.
|
||||
pub struct MillauWeight<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> WeightInfo for MillauWeight<T> {
|
||||
fn send_minimal_message_worst_case() -> Weight {
|
||||
(159_305_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
||||
(117_480_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(7 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(12 as Weight))
|
||||
}
|
||||
fn send_1_kb_message_worst_case() -> Weight {
|
||||
(164_394_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
||||
(128_391_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(7 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(12 as Weight))
|
||||
}
|
||||
fn send_16_kb_message_worst_case() -> Weight {
|
||||
(223_521_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
||||
(149_149_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(7 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(12 as Weight))
|
||||
}
|
||||
fn maximal_increase_message_fee() -> Weight {
|
||||
(6_781_470_000 as Weight)
|
||||
(6_015_058_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn increase_message_fee(i: u32) -> Weight {
|
||||
(114_963_000 as Weight)
|
||||
.saturating_add((6_000 as Weight).saturating_mul(i as Weight))
|
||||
(0 as Weight)
|
||||
.saturating_add((2_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn receive_single_message_proof() -> Weight {
|
||||
(206_769_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
||||
(179_892_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn receive_two_messages_proof() -> Weight {
|
||||
(343_982_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
||||
(291_793_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn receive_single_message_proof_with_outbound_lane_state() -> Weight {
|
||||
(223_738_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
||||
(192_191_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn receive_single_message_proof_1_kb() -> Weight {
|
||||
(235_369_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
||||
(202_104_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn receive_single_message_proof_16_kb() -> Weight {
|
||||
(510_338_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
||||
(357_144_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn receive_single_prepaid_message_proof() -> Weight {
|
||||
(141_536_000 as Weight)
|
||||
(122_648_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
fn receive_delivery_proof_for_single_message() -> Weight {
|
||||
(128_805_000 as Weight)
|
||||
(107_631_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight {
|
||||
(137_143_000 as Weight)
|
||||
(113_885_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(7 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight {
|
||||
(193_108_000 as Weight)
|
||||
(155_151_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(8 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(4 as Weight))
|
||||
}
|
||||
fn send_messages_of_various_lengths(i: u32) -> Weight {
|
||||
(133_632_000 as Weight)
|
||||
.saturating_add((4_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
||||
(0 as Weight)
|
||||
.saturating_add((2_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(T::DbWeight::get().reads(7 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(12 as Weight))
|
||||
}
|
||||
fn receive_multiple_messages_proof(i: u32) -> Weight {
|
||||
(0 as Weight)
|
||||
.saturating_add((145_006_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
||||
(56_209_000 as Weight)
|
||||
.saturating_add((109_502_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(T::DbWeight::get().reads(6 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn receive_message_proofs_with_extra_nodes(i: u32) -> Weight {
|
||||
(486_301_000 as Weight)
|
||||
.saturating_add((10_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
||||
(0 as Weight)
|
||||
.saturating_add((5_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(T::DbWeight::get().reads(6 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn receive_message_proofs_with_large_leaf(i: u32) -> Weight {
|
||||
(178_139_000 as Weight)
|
||||
.saturating_add((7_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
||||
(50_281_000 as Weight)
|
||||
.saturating_add((2_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(T::DbWeight::get().reads(6 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn receive_multiple_messages_proof_with_outbound_lane_state(i: u32) -> Weight {
|
||||
(0 as Weight)
|
||||
.saturating_add((150_844_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
||||
(70_297_000 as Weight)
|
||||
.saturating_add((110_892_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(T::DbWeight::get().reads(6 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn receive_delivery_proof_for_multiple_messages_by_single_relayer(i: u32) -> Weight {
|
||||
(113_140_000 as Weight)
|
||||
.saturating_add((7_656_000 as Weight).saturating_mul(i as Weight))
|
||||
(0 as Weight)
|
||||
.saturating_add((8_016_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
||||
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(i as Weight)))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn receive_delivery_proof_for_multiple_messages_by_multiple_relayers(i: u32) -> Weight {
|
||||
(97_424_000 as Weight)
|
||||
.saturating_add((63_128_000 as Weight).saturating_mul(i as Weight))
|
||||
(0 as Weight)
|
||||
.saturating_add((50_981_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
||||
.saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(i as Weight)))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
@@ -195,116 +195,116 @@ impl<T: frame_system::Config> WeightInfo for RialtoWeight<T> {
|
||||
// For backwards compatibility and tests
|
||||
impl WeightInfo for () {
|
||||
fn send_minimal_message_worst_case() -> Weight {
|
||||
(159_305_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
||||
(117_480_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(7 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(12 as Weight))
|
||||
}
|
||||
fn send_1_kb_message_worst_case() -> Weight {
|
||||
(164_394_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
||||
(128_391_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(7 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(12 as Weight))
|
||||
}
|
||||
fn send_16_kb_message_worst_case() -> Weight {
|
||||
(223_521_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
||||
(149_149_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(7 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(12 as Weight))
|
||||
}
|
||||
fn maximal_increase_message_fee() -> Weight {
|
||||
(6_781_470_000 as Weight)
|
||||
(6_015_058_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn increase_message_fee(i: u32) -> Weight {
|
||||
(114_963_000 as Weight)
|
||||
.saturating_add((6_000 as Weight).saturating_mul(i as Weight))
|
||||
(0 as Weight)
|
||||
.saturating_add((2_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn receive_single_message_proof() -> Weight {
|
||||
(206_769_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
||||
(179_892_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn receive_two_messages_proof() -> Weight {
|
||||
(343_982_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
||||
(291_793_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn receive_single_message_proof_with_outbound_lane_state() -> Weight {
|
||||
(223_738_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
||||
(192_191_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn receive_single_message_proof_1_kb() -> Weight {
|
||||
(235_369_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
||||
(202_104_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn receive_single_message_proof_16_kb() -> Weight {
|
||||
(510_338_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
||||
(357_144_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn receive_single_prepaid_message_proof() -> Weight {
|
||||
(141_536_000 as Weight)
|
||||
(122_648_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
fn receive_delivery_proof_for_single_message() -> Weight {
|
||||
(128_805_000 as Weight)
|
||||
(107_631_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight {
|
||||
(137_143_000 as Weight)
|
||||
(113_885_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(7 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight {
|
||||
(193_108_000 as Weight)
|
||||
(155_151_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(8 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(4 as Weight))
|
||||
}
|
||||
fn send_messages_of_various_lengths(i: u32) -> Weight {
|
||||
(133_632_000 as Weight)
|
||||
.saturating_add((4_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
||||
(0 as Weight)
|
||||
.saturating_add((2_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(RocksDbWeight::get().reads(7 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(12 as Weight))
|
||||
}
|
||||
fn receive_multiple_messages_proof(i: u32) -> Weight {
|
||||
(0 as Weight)
|
||||
.saturating_add((145_006_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
||||
(56_209_000 as Weight)
|
||||
.saturating_add((109_502_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn receive_message_proofs_with_extra_nodes(i: u32) -> Weight {
|
||||
(486_301_000 as Weight)
|
||||
.saturating_add((10_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
||||
(0 as Weight)
|
||||
.saturating_add((5_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn receive_message_proofs_with_large_leaf(i: u32) -> Weight {
|
||||
(178_139_000 as Weight)
|
||||
.saturating_add((7_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
||||
(50_281_000 as Weight)
|
||||
.saturating_add((2_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn receive_multiple_messages_proof_with_outbound_lane_state(i: u32) -> Weight {
|
||||
(0 as Weight)
|
||||
.saturating_add((150_844_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
||||
(70_297_000 as Weight)
|
||||
.saturating_add((110_892_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn receive_delivery_proof_for_multiple_messages_by_single_relayer(i: u32) -> Weight {
|
||||
(113_140_000 as Weight)
|
||||
.saturating_add((7_656_000 as Weight).saturating_mul(i as Weight))
|
||||
(0 as Weight)
|
||||
.saturating_add((8_016_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(i as Weight)))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn receive_delivery_proof_for_multiple_messages_by_multiple_relayers(i: u32) -> Weight {
|
||||
(97_424_000 as Weight)
|
||||
.saturating_add((63_128_000 as Weight).saturating_mul(i as Weight))
|
||||
(0 as Weight)
|
||||
.saturating_add((50_981_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().reads((2 as Weight).saturating_mul(i as Weight)))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||
|
||||
@@ -390,7 +390,7 @@ impl WeightInfoExt for () {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: frame_system::Config> WeightInfoExt for crate::weights::RialtoWeight<T> {
|
||||
impl<T: frame_system::Config> WeightInfoExt for crate::weights::MillauWeight<T> {
|
||||
fn expected_extra_storage_proof_size() -> u32 {
|
||||
EXTRA_STORAGE_PROOF_SIZE
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ use frame_system::RawOrigin;
|
||||
use sp_core::H256;
|
||||
use sp_io::hashing::blake2_256;
|
||||
use sp_runtime::traits::Bounded;
|
||||
use sp_std::vec::Vec;
|
||||
use sp_std::{boxed::Box, vec::Vec};
|
||||
|
||||
const SEED: u32 = 0;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
//! Autogenerated weights for `pallet_bridge_token_swap`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2021-10-06, STEPS: 50, REPEAT: 20
|
||||
//! DATE: 2021-12-28, STEPS: 50, REPEAT: 20
|
||||
//! LOW RANGE: [], HIGH RANGE: []
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled
|
||||
//! CHAIN: Some("dev"), DB CACHE: 128
|
||||
@@ -57,17 +57,17 @@ pub trait WeightInfo {
|
||||
pub struct MillauWeight<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> WeightInfo for MillauWeight<T> {
|
||||
fn create_swap() -> Weight {
|
||||
(116_040_000 as Weight)
|
||||
(90_368_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(4 as Weight))
|
||||
}
|
||||
fn claim_swap() -> Weight {
|
||||
(102_882_000 as Weight)
|
||||
(88_397_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn cancel_swap() -> Weight {
|
||||
(99_434_000 as Weight)
|
||||
(91_253_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
@@ -76,17 +76,17 @@ impl<T: frame_system::Config> WeightInfo for MillauWeight<T> {
|
||||
// For backwards compatibility and tests
|
||||
impl WeightInfo for () {
|
||||
fn create_swap() -> Weight {
|
||||
(116_040_000 as Weight)
|
||||
(90_368_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(4 as Weight))
|
||||
}
|
||||
fn claim_swap() -> Weight {
|
||||
(102_882_000 as Weight)
|
||||
(88_397_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
fn cancel_swap() -> Weight {
|
||||
(99_434_000 as Weight)
|
||||
(91_253_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ pub const MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT: Weight = 2_000_000
|
||||
/// chain. Don't put too much reserve there, because it is used to **decrease**
|
||||
/// `DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT` cost. So putting large reserve would make delivery
|
||||
/// transactions cheaper.
|
||||
pub const PAY_INBOUND_DISPATCH_FEE_WEIGHT: Weight = 600_000_000;
|
||||
pub const PAY_INBOUND_DISPATCH_FEE_WEIGHT: Weight = 700_000_000;
|
||||
|
||||
/// The target length of a session (how often authorities change) on Millau measured in of number of
|
||||
/// blocks.
|
||||
|
||||
@@ -94,7 +94,7 @@ pub const MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT: Weight = 2_000_000
|
||||
/// chain. Don't put too much reserve there, because it is used to **decrease**
|
||||
/// `DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT` cost. So putting large reserve would make delivery
|
||||
/// transactions cheaper.
|
||||
pub const PAY_INBOUND_DISPATCH_FEE_WEIGHT: Weight = 600_000_000;
|
||||
pub const PAY_INBOUND_DISPATCH_FEE_WEIGHT: Weight = 700_000_000;
|
||||
|
||||
/// The target length of a session (how often authorities change) on Rialto measured in of number of
|
||||
/// blocks.
|
||||
|
||||
@@ -83,7 +83,7 @@ pub(crate) mod tests {
|
||||
// differ from the `DbWeight` of Rialto runtime. But now (and most probably forever) it is
|
||||
// the same.
|
||||
type GrandpaPalletWeights =
|
||||
pallet_bridge_grandpa::weights::RialtoWeight<rialto_runtime::Runtime>;
|
||||
pallet_bridge_grandpa::weights::MillauWeight<rialto_runtime::Runtime>;
|
||||
|
||||
// The following formula shall not be treated as super-accurate - guard is to protect from
|
||||
// mad relays, not to protect from over-average loses.
|
||||
|
||||
@@ -453,7 +453,7 @@ mod tests {
|
||||
use bp_runtime::Chain;
|
||||
|
||||
type RialtoToMillauMessagesWeights =
|
||||
pallet_bridge_messages::weights::RialtoWeight<rialto_runtime::Runtime>;
|
||||
pallet_bridge_messages::weights::MillauWeight<rialto_runtime::Runtime>;
|
||||
|
||||
#[test]
|
||||
fn select_delivery_transaction_limits_works() {
|
||||
@@ -469,7 +469,7 @@ mod tests {
|
||||
// i.e. weight reserved for messages dispatch allows dispatch of non-trivial messages.
|
||||
//
|
||||
// Any significant change in this values should attract additional attention.
|
||||
(782, 216_583_333_334),
|
||||
(958, 216_583_333_334),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user