Benchmark for message delivery confirmation transaction (#570)

* receive_delivery_proof benchmarks

* fix compilation

* Update modules/message-lane/src/benchmarking.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* Update modules/message-lane/src/benchmarking.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* Update modules/message-lane/src/benchmarking.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* Update modules/message-lane/src/benchmarking.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* Update modules/message-lane/src/benchmarking.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
This commit is contained in:
Svyatoslav Nikolsky
2020-12-18 13:59:59 +03:00
committed by Bastian Köcher
parent b45d65f330
commit 9deea5d251
6 changed files with 308 additions and 15 deletions
+33
View File
@@ -802,6 +802,7 @@ impl_runtime_apis! {
use pallet_message_lane::benchmarking::{
Module as MessageLaneBench,
Config as MessageLaneConfig,
MessageDeliveryProofParams as MessageLaneMessageDeliveryProofParams,
MessageParams as MessageLaneMessageParams,
MessageProofParams as MessageLaneMessageProofParams,
};
@@ -811,6 +812,10 @@ impl_runtime_apis! {
Default::default()
}
fn account_balance(account: &Self::AccountId) -> Self::OutboundMessageFee {
pallet_balances::Module::<Runtime>::free_balance(account)
}
fn endow_account(account: &Self::AccountId) {
pallet_balances::Module::<Runtime>::make_free_balance_be(
account,
@@ -913,6 +918,34 @@ impl_runtime_apis! {
}.encode(),
)
}
fn prepare_message_delivery_proof(
params: MessageLaneMessageDeliveryProofParams<Self::AccountId>,
) -> millau_messages::FromMillauMessagesDeliveryProof {
use crate::millau_messages::{Millau, WithMillauMessageBridge};
use bridge_runtime_common::{
messages::ChainWithMessageLanes,
messages_benchmarking::prepare_message_delivery_proof,
};
use sp_runtime::traits::Header;
prepare_message_delivery_proof::<WithMillauMessageBridge, bp_millau::Hasher, Runtime, _, _>(
params,
|lane_id| pallet_message_lane::storage_keys::inbound_lane_data_key::<
Runtime,
<Millau as ChainWithMessageLanes>::MessageLaneInstance,
>(
&lane_id,
).0,
|state_root| bp_millau::Header::new(
0,
Default::default(),
state_root,
Default::default(),
Default::default(),
),
)
}
}
add_benchmark!(params, batches, pallet_bridge_eth_poa, BridgeKovan);
@@ -74,7 +74,8 @@ pub type FromMillauMessageDispatch = messages::target::FromBridgedChainMessageDi
pub type FromMillauMessagesProof = messages::target::FromBridgedChainMessagesProof<WithMillauMessageBridge>;
/// Messages delivery proof for Rialto -> Millau messages.
type ToMillauMessagesDeliveryProof = messages::source::FromBridgedChainMessagesDeliveryProof<WithMillauMessageBridge>;
pub type FromMillauMessagesDeliveryProof =
messages::source::FromBridgedChainMessagesDeliveryProof<WithMillauMessageBridge>;
/// Millau <-> Rialto message bridge.
#[derive(RuntimeDebug, Clone, Copy)]
@@ -168,7 +169,7 @@ impl TargetHeaderChain<ToMillauMessagePayload, bp_millau::AccountId> for Millau
// - hash of the header this proof has been created with;
// - the storage proof of one or several keys;
// - id of the lane we prove state of.
type MessagesDeliveryProof = ToMillauMessagesDeliveryProof;
type MessagesDeliveryProof = FromMillauMessagesDeliveryProof;
fn verify_message(payload: &ToMillauMessagePayload) -> Result<(), Self::Error> {
messages::source::verify_chain_message::<WithMillauMessageBridge>(payload)