Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion bridges/snowbridge/pallets/outbound-queue-v2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ use sp_runtime::{
DigestItem,
};
use sp_std::prelude::*;
pub use types::{PendingOrder, ProcessMessageOriginOf};
pub use types::{OnNewCommitment, PendingOrder, ProcessMessageOriginOf};
pub use weights::WeightInfo;
use xcm::prelude::NetworkId;

Expand Down Expand Up @@ -137,6 +137,9 @@ pub mod pallet {
#[pallet::constant]
type MaxMessagesPerBlock: Get<u32>;

/// Hook that is called whenever there is a new commitment.
type OnNewCommitment: OnNewCommitment;

/// Convert a weight value into a deductible fee based.
type WeightToFee: WeightToFee<Balance = Self::Balance>;

Expand Down Expand Up @@ -321,6 +324,8 @@ pub mod pallet {
// Insert merkle root into the header digest
<frame_system::Pallet<T>>::deposit_log(digest_item);

T::OnNewCommitment::on_new_commitment(root);

Self::deposit_event(Event::MessagesCommitted { root, count });
}

Expand Down
1 change: 1 addition & 0 deletions bridges/snowbridge/pallets/outbound-queue-v2/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ impl crate::Config for Test {
type EthereumNetwork = EthereumNetwork;
type RewardKind = BridgeReward;
type DefaultRewardKind = DefaultMyRewardKind;
type OnNewCommitment = ();
#[cfg(feature = "runtime-benchmarks")]
type Helper = Test;
}
Expand Down
10 changes: 10 additions & 0 deletions bridges/snowbridge/pallets/outbound-queue-v2/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::traits::ProcessMessage;
use scale_info::TypeInfo;
pub use snowbridge_merkle_tree::MerkleProof;
use sp_core::H256;
use sp_runtime::RuntimeDebug;
use sp_std::prelude::*;

Expand All @@ -21,3 +22,12 @@ pub struct PendingOrder<BlockNumber> {
#[codec(compact)]
pub fee: u128,
}

/// Hook that will be called when a new message commitment is constructed.
pub trait OnNewCommitment {
fn on_new_commitment(commitment: H256);
}

impl OnNewCommitment for () {
fn on_new_commitment(_commitment: H256) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ impl snowbridge_pallet_outbound_queue_v2::Config for Runtime {
type RewardKind = BridgeReward;
type DefaultRewardKind = SnowbridgeReward;
type RewardPayment = BridgeRelayers;
// No consumers of this notifier on Bridge Hub.
type OnNewCommitment = ();
Comment thread
Agusrodri marked this conversation as resolved.
#[cfg(feature = "runtime-benchmarks")]
type Helper = Runtime;
}
Expand Down
10 changes: 10 additions & 0 deletions prdoc/pr_8053.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: Add `OnNewCommitment` hook to outbound-queue pallet
doc:
- audience: Runtime Dev
description: |-
Add a simple hook to outbound-queue-v2 pallet which allows to perform actions whenever there is a new commitment.
crates:
- name: snowbridge-pallet-outbound-queue-v2
bump: major
- name: bridge-hub-westend-runtime
bump: major
Loading