Skip to content

Commit

Permalink
Make finality verifier pallet instantiable (paritytech#825)
Browse files Browse the repository at this point in the history
* make finality verifier pallet instantiable

* try to fix benchmarks

* fix benchmarks compilation
  • Loading branch information
svyatonik authored and serban300 committed Apr 8, 2024
1 parent 1d1745e commit 9d725a1
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 93 deletions.
4 changes: 2 additions & 2 deletions bridges/bin/rialto/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ impl_runtime_apis! {
Default::default(),
);

prepare_message_proof::<WithMillauMessageBridge, bp_millau::Hasher, Runtime, _, _, _>(
prepare_message_proof::<WithMillauMessageBridge, bp_millau::Hasher, Runtime, (), _, _, _>(
params,
make_millau_message_key,
make_millau_outbound_lane_data_key,
Expand Down Expand Up @@ -986,7 +986,7 @@ impl_runtime_apis! {
};
use sp_runtime::traits::Header;

prepare_message_delivery_proof::<WithMillauMessageBridge, bp_millau::Hasher, Runtime, _, _>(
prepare_message_delivery_proof::<WithMillauMessageBridge, bp_millau::Hasher, Runtime, (), _, _>(
params,
|lane_id| pallet_message_lane::storage_keys::inbound_lane_data_key::<
Runtime,
Expand Down
14 changes: 8 additions & 6 deletions bridges/bin/runtime-common/src/messages_benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub fn ed25519_sign(target_call: &impl Encode, source_account_id: &impl Encode)
}

/// Prepare proof of messages for the `receive_messages_proof` call.
pub fn prepare_message_proof<B, H, R, MM, ML, MH>(
pub fn prepare_message_proof<B, H, R, FI, MM, ML, MH>(
params: MessageProofParams,
make_bridged_message_storage_key: MM,
make_bridged_outbound_lane_data_key: ML,
Expand All @@ -73,7 +73,8 @@ pub fn prepare_message_proof<B, H, R, MM, ML, MH>(
where
B: MessageBridge,
H: Hasher,
R: pallet_finality_verifier::Config,
R: pallet_finality_verifier::Config<FI>,
FI: 'static,
<R::BridgedChain as bp_runtime::Chain>::Hash: Into<HashOf<BridgedChain<B>>>,
MM: Fn(MessageKey) -> Vec<u8>,
ML: Fn(LaneId) -> Vec<u8>,
Expand Down Expand Up @@ -129,7 +130,7 @@ where
// prepare Bridged chain header and insert it into the Substrate pallet
let bridged_header = make_bridged_header(root);
let bridged_header_hash = bridged_header.hash();
pallet_finality_verifier::initialize_for_benchmarks::<R>(bridged_header);
pallet_finality_verifier::initialize_for_benchmarks::<R, FI>(bridged_header);

(
FromBridgedChainMessagesProof {
Expand All @@ -146,15 +147,16 @@ where
}

/// Prepare proof of messages delivery for the `receive_messages_delivery_proof` call.
pub fn prepare_message_delivery_proof<B, H, R, ML, MH>(
pub fn prepare_message_delivery_proof<B, H, R, FI, ML, MH>(
params: MessageDeliveryProofParams<AccountIdOf<ThisChain<B>>>,
make_bridged_inbound_lane_data_key: ML,
make_bridged_header: MH,
) -> FromBridgedChainMessagesDeliveryProof<HashOf<BridgedChain<B>>>
where
B: MessageBridge,
H: Hasher,
R: pallet_finality_verifier::Config,
R: pallet_finality_verifier::Config<FI>,
FI: 'static,
<R::BridgedChain as bp_runtime::Chain>::Hash: Into<HashOf<BridgedChain<B>>>,
ML: Fn(LaneId) -> Vec<u8>,
MH: Fn(H::Out) -> <R::BridgedChain as bp_runtime::Chain>::Header,
Expand All @@ -181,7 +183,7 @@ where
// prepare Bridged chain header and insert it into the Substrate pallet
let bridged_header = make_bridged_header(root);
let bridged_header_hash = bridged_header.hash();
pallet_finality_verifier::initialize_for_benchmarks::<R>(bridged_header);
pallet_finality_verifier::initialize_for_benchmarks::<R, FI>(bridged_header);

FromBridgedChainMessagesDeliveryProof {
bridged_header_hash: bridged_header_hash.into(),
Expand Down
Loading

0 comments on commit 9d725a1

Please sign in to comment.