From 004c45432e757d16f064945b4a7a3d3c8fecfd6b Mon Sep 17 00:00:00 2001 From: linning Date: Wed, 16 Oct 2024 20:17:59 +0800 Subject: [PATCH] Set OnXDMRewards for the consensus test runtime to keep consistency with the production runtime Signed-off-by: linning --- test/subspace-test-runtime/src/lib.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/test/subspace-test-runtime/src/lib.rs b/test/subspace-test-runtime/src/lib.rs index 4fe29aaf00..6d2c2f25e6 100644 --- a/test/subspace-test-runtime/src/lib.rs +++ b/test/subspace-test-runtime/src/lib.rs @@ -603,6 +603,24 @@ parameter_types! { pub const ChannelFeeModel: FeeModel = FeeModel{relay_fee: SSC}; } +pub struct OnXDMRewards; + +impl sp_messenger::OnXDMRewards for OnXDMRewards { + fn on_xdm_rewards(reward: Balance) { + if let Some(block_author) = Subspace::find_block_reward_address() { + let _ = Balances::deposit_creating(&block_author, reward); + } + } + + fn on_chain_protocol_fees(chain_id: ChainId, fees: Balance) { + // on consensus chain, reward the domain operators + // balance is already on this consensus runtime + if let ChainId::Domain(domain_id) = chain_id { + Domains::reward_domain_operators(domain_id, OperatorRewardSource::XDMProtocolFees, fees) + } + } +} + impl pallet_messenger::Config for Runtime { type RuntimeEvent = RuntimeEvent; type SelfChainId = SelfChainId; @@ -618,7 +636,7 @@ impl pallet_messenger::Config for Runtime { type Currency = Balances; type WeightInfo = pallet_messenger::weights::SubstrateWeight; type WeightToFee = ConstantMultiplier; - type OnXDMRewards = (); + type OnXDMRewards = OnXDMRewards; type MmrHash = mmr::Hash; type MmrProofVerifier = MmrProofVerifier; type StorageKeys = StorageKeys;