Skip to content

Commit

Permalink
Set OnXDMRewards for the consensus test runtime to keep consistency w…
Browse files Browse the repository at this point in the history
…ith the production runtime

Signed-off-by: linning <linningde25@gmail.com>
  • Loading branch information
NingLin-P committed Oct 16, 2024
1 parent 0200fce commit 004c454
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion test/subspace-test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,24 @@ parameter_types! {
pub const ChannelFeeModel: FeeModel<Balance> = FeeModel{relay_fee: SSC};
}

pub struct OnXDMRewards;

impl sp_messenger::OnXDMRewards<Balance> 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;
Expand All @@ -618,7 +636,7 @@ impl pallet_messenger::Config for Runtime {
type Currency = Balances;
type WeightInfo = pallet_messenger::weights::SubstrateWeight<Runtime>;
type WeightToFee = ConstantMultiplier<Balance, TransactionWeightFee>;
type OnXDMRewards = ();
type OnXDMRewards = OnXDMRewards;
type MmrHash = mmr::Hash;
type MmrProofVerifier = MmrProofVerifier;
type StorageKeys = StorageKeys;
Expand Down

0 comments on commit 004c454

Please sign in to comment.