From 33bcc215d4ceb5d29d42732e454fd755ee12e0a6 Mon Sep 17 00:00:00 2001 From: vedhavyas Date: Tue, 11 Jun 2024 18:35:35 +0530 Subject: [PATCH] use constant fee model for XDM channels --- crates/subspace-runtime/src/lib.rs | 5 +- domains/client/domain-operator/src/tests.rs | 6 +- domains/pallets/messenger/src/benchmarking.rs | 12 +-- domains/pallets/messenger/src/lib.rs | 34 ++++++-- domains/pallets/messenger/src/mock.rs | 4 +- domains/pallets/messenger/src/tests.rs | 85 ++++++------------- domains/primitives/messenger/src/messages.rs | 6 +- domains/runtime/auto-id/src/lib.rs | 5 +- domains/runtime/evm/src/lib.rs | 5 +- domains/test/runtime/evm/src/lib.rs | 5 +- test/subspace-test-runtime/src/lib.rs | 5 +- 11 files changed, 85 insertions(+), 87 deletions(-) diff --git a/crates/subspace-runtime/src/lib.rs b/crates/subspace-runtime/src/lib.rs index 99ba044018..76ab73fd12 100644 --- a/crates/subspace-runtime/src/lib.rs +++ b/crates/subspace-runtime/src/lib.rs @@ -74,7 +74,7 @@ use sp_domains_fraud_proof::storage_proof::{ }; use sp_messenger::endpoint::{Endpoint, EndpointHandler as EndpointHandlerT, EndpointId}; use sp_messenger::messages::{ - BlockMessagesWithStorageKey, ChainId, CrossDomainMessage, MessageId, MessageKey, + BlockMessagesWithStorageKey, ChainId, CrossDomainMessage, FeeModel, MessageId, MessageKey, }; use sp_messenger_host_functions::{get_storage_key, StorageKeyRequest}; use sp_mmr_primitives::EncodableOpaqueLeaf; @@ -516,6 +516,8 @@ parameter_types! { // TODO: update value pub const ChannelReserveFee: Balance = 100 * SSC; pub const ChannelInitReservePortion: Perbill = Perbill::from_percent(20); + // TODO update the fee model + pub const ChannelFeeModel: FeeModel = FeeModel{relay_fee: SSC}; } pub struct DomainRegistration; @@ -549,6 +551,7 @@ impl pallet_messenger::Config for Runtime { type ChannelReserveFee = ChannelReserveFee; type ChannelInitReservePortion = ChannelInitReservePortion; type DomainRegistration = DomainRegistration; + type ChannelFeeModel = ChannelFeeModel; } impl frame_system::offchain::SendTransactionTypes for Runtime diff --git a/domains/client/domain-operator/src/tests.rs b/domains/client/domain-operator/src/tests.rs index 237890424d..fcbe3d02b2 100644 --- a/domains/client/domain-operator/src/tests.rs +++ b/domains/client/domain-operator/src/tests.rs @@ -38,7 +38,7 @@ use sp_domains_fraud_proof::fraud_proof::{ InvalidExtrinsicsRootProof, InvalidTransfersProof, }; use sp_domains_fraud_proof::InvalidTransactionCode; -use sp_messenger::messages::{CrossDomainMessage, FeeModel, InitiateChannelParams, Proof}; +use sp_messenger::messages::{CrossDomainMessage, Proof}; use sp_mmr_primitives::{EncodableOpaqueLeaf, Proof as MmrProof}; use sp_runtime::generic::{BlockId, DigestItem}; use sp_runtime::traits::{ @@ -3474,14 +3474,12 @@ async fn test_cross_domains_messages_should_work() { produce_blocks!(ferdie, alice, 1).await.unwrap(); // Open channel between the Consensus chain and EVM domains - let fee_model = FeeModel { relay_fee: 1 }; alice .construct_and_send_extrinsic(evm_domain_test_runtime::RuntimeCall::Messenger( pallet_messenger::Call::initiate_channel { dst_chain_id: ChainId::Consensus, - params: InitiateChannelParams { + params: pallet_messenger::InitiateChannelParams { max_outgoing_messages: 100, - fee_model, }, }, )) diff --git a/domains/pallets/messenger/src/benchmarking.rs b/domains/pallets/messenger/src/benchmarking.rs index 5d5bacd645..c065f60144 100644 --- a/domains/pallets/messenger/src/benchmarking.rs +++ b/domains/pallets/messenger/src/benchmarking.rs @@ -15,7 +15,7 @@ use frame_support::traits::Get; use frame_system::RawOrigin; use sp_messenger::endpoint::{Endpoint, EndpointRequest}; use sp_messenger::messages::{ - CrossDomainMessage, InitiateChannelParams, Message, MessageWeightTag, Payload, Proof, + ChannelOpenParams, CrossDomainMessage, Message, MessageWeightTag, Payload, Proof, RequestResponse, VersionedPayload, }; use sp_mmr_primitives::{EncodableOpaqueLeaf, Proof as MmrProof}; @@ -32,7 +32,9 @@ mod benchmarks { fn initiate_channel() { let dst_chain_id: ChainId = u32::MAX.into(); assert_ne!(T::SelfChainId::get(), dst_chain_id); - let channel_params = dummy_channel_params::(); + let channel_params = InitiateChannelParams { + max_outgoing_messages: 100, + }; let channel_id = NextChannelId::::get(dst_chain_id); let account = account("account", 0, 0); T::Currency::set_balance( @@ -232,11 +234,11 @@ mod benchmarks { ); } - fn dummy_channel_params() -> InitiateChannelParams> { + fn dummy_channel_params() -> ChannelOpenParams> { let fee_model = FeeModel { relay_fee: 1u32.into(), }; - InitiateChannelParams { + ChannelOpenParams { max_outgoing_messages: 100, fee_model, } @@ -244,7 +246,7 @@ mod benchmarks { fn open_channel( dst_chain_id: ChainId, - params: InitiateChannelParams>, + params: ChannelOpenParams>, ) -> ChannelId { let channel_id = NextChannelId::::get(dst_chain_id); let list = BTreeSet::from([dst_chain_id]); diff --git a/domains/pallets/messenger/src/lib.rs b/domains/pallets/messenger/src/lib.rs index 61e8e16552..000a731c8d 100644 --- a/domains/pallets/messenger/src/lib.rs +++ b/domains/pallets/messenger/src/lib.rs @@ -125,6 +125,12 @@ pub(crate) enum CloseChannelBy { Sudo, } +/// Parameters for a new channel between two chains. +#[derive(Default, Debug, Encode, Decode, Clone, Eq, PartialEq, TypeInfo, Copy)] +pub struct InitiateChannelParams { + pub max_outgoing_messages: u32, +} + /// Hold identifier trait for messenger specific balance holds pub trait HoldIdentifier { fn messenger_channel(dst_chain_id: ChainId, channel_id: ChannelId) -> FungibleHoldId; @@ -135,8 +141,8 @@ mod pallet { use crate::weights::WeightInfo; use crate::{ BalanceOf, ChainAllowlistUpdate, Channel, ChannelId, ChannelState, CloseChannelBy, - FeeModel, HoldIdentifier, Nonce, OutboxMessageResult, StateRootOf, ValidatedRelayMessage, - U256, + FeeModel, HoldIdentifier, InitiateChannelParams, Nonce, OutboxMessageResult, StateRootOf, + ValidatedRelayMessage, U256, }; #[cfg(not(feature = "std"))] use alloc::boxed::Box; @@ -155,7 +161,7 @@ mod pallet { use sp_domains::{DomainAllowlistUpdates, DomainId, DomainOwner}; use sp_messenger::endpoint::{Endpoint, EndpointHandler, EndpointRequest, Sender}; use sp_messenger::messages::{ - ChainId, CrossDomainMessage, InitiateChannelParams, Message, MessageId, MessageKey, + ChainId, ChannelOpenParams, CrossDomainMessage, Message, MessageId, MessageKey, MessageWeightTag, Payload, ProtocolMessageRequest, RequestResponse, VersionedPayload, }; use sp_messenger::{ @@ -208,6 +214,8 @@ mod pallet { type ChannelInitReservePortion: Get; /// Type to check if a given domain is registered on Consensus chain. type DomainRegistration: DomainRegistration; + /// Channels fee model + type ChannelFeeModel: Get>>; } /// Pallet messenger used to communicate between chains and other blockchains. @@ -564,13 +572,21 @@ mod pallet { pub fn initiate_channel( origin: OriginFor, dst_chain_id: ChainId, - params: InitiateChannelParams>, + params: InitiateChannelParams, ) -> DispatchResult { let owner = ensure_signed(origin)?; + let channel_open_params = ChannelOpenParams { + max_outgoing_messages: params.max_outgoing_messages, + fee_model: T::ChannelFeeModel::get(), + }; // initiate the channel config - let channel_id = - Self::do_init_channel(dst_chain_id, params, Some(owner.clone()), true)?; + let channel_id = Self::do_init_channel( + dst_chain_id, + channel_open_params, + Some(owner.clone()), + true, + )?; // reserve channel open fees let hold_id = T::HoldIdentifier::messenger_channel(dst_chain_id, channel_id); @@ -590,7 +606,7 @@ mod pallet { dst_chain_id, channel_id, VersionedPayload::V0(Payload::Protocol(RequestResponse::Request( - ProtocolMessageRequest::ChannelOpen(params), + ProtocolMessageRequest::ChannelOpen(channel_open_params), ))), )?; @@ -862,7 +878,7 @@ mod pallet { let fee_model = FeeModel { relay_fee: Default::default(), }; - let init_params = InitiateChannelParams { + let init_params = ChannelOpenParams { max_outgoing_messages: 100, fee_model, }; @@ -992,7 +1008,7 @@ mod pallet { pub(crate) fn do_init_channel( dst_chain_id: ChainId, - init_params: InitiateChannelParams>, + init_params: ChannelOpenParams>, maybe_owner: Option, check_allowlist: bool, ) -> Result { diff --git a/domains/pallets/messenger/src/mock.rs b/domains/pallets/messenger/src/mock.rs index 8e2b9ccbeb..73f458c3b4 100644 --- a/domains/pallets/messenger/src/mock.rs +++ b/domains/pallets/messenger/src/mock.rs @@ -28,7 +28,7 @@ macro_rules! impl_runtime { use pallet_balances::AccountData; use sp_core::H256; use sp_messenger::endpoint::{Endpoint, EndpointHandler, EndpointId}; - use sp_messenger::messages::ChainId; + use sp_messenger::messages::{ChainId, FeeModel}; use sp_runtime::traits::Convert; use sp_runtime::BuildStorage; use crate::HoldIdentifier; @@ -62,6 +62,7 @@ macro_rules! impl_runtime { pub SelfChainId: ChainId = $chain_id.into(); pub const ChannelReserveFee: Balance = 10; pub const ChannelInitReservePortion: Perbill = Perbill::from_percent(20); + pub const ChannelFeeModel: FeeModel = FeeModel{relay_fee: 1}; } #[derive( @@ -103,6 +104,7 @@ macro_rules! impl_runtime { type ChannelInitReservePortion = ChannelInitReservePortion; type HoldIdentifier = MockHoldIdentifer; type DomainRegistration = DomainRegistration; + type ChannelFeeModel = ChannelFeeModel; /// function to fetch endpoint response handler by Endpoint. fn get_endpoint_handler( #[allow(unused_variables)] endpoint: &Endpoint, diff --git a/domains/pallets/messenger/src/tests.rs b/domains/pallets/messenger/src/tests.rs index 00a4939413..1f0c9af46b 100644 --- a/domains/pallets/messenger/src/tests.rs +++ b/domains/pallets/messenger/src/tests.rs @@ -8,8 +8,8 @@ use crate::mock::{ }; use crate::{ BalanceOf, ChainAllowlist, ChainAllowlistUpdate, Channel, ChannelId, ChannelState, Channels, - CloseChannelBy, Error, FeeModel, Inbox, InboxResponses, Nonce, Outbox, OutboxMessageResult, - OutboxResponses, Pallet, U256, + CloseChannelBy, Error, FeeModel, Inbox, InboxResponses, InitiateChannelParams, Nonce, Outbox, + OutboxMessageResult, OutboxResponses, Pallet, U256, }; use frame_support::traits::fungible::Inspect; use frame_support::traits::tokens::{Fortitude, Preservation}; @@ -21,7 +21,7 @@ use sp_domains::proof_provider_and_verifier::{StorageProofVerifier, Verification use sp_domains::DomainAllowlistUpdates; use sp_messenger::endpoint::{Endpoint, EndpointPayload, EndpointRequest, Sender}; use sp_messenger::messages::{ - ChainId, CrossDomainMessage, InitiateChannelParams, MessageWeightTag, Payload, Proof, + ChainId, ChannelOpenParams, CrossDomainMessage, MessageWeightTag, Payload, Proof, ProtocolMessageRequest, RequestResponse, VersionedPayload, }; use sp_mmr_primitives::{EncodableOpaqueLeaf, Proof as MmrProof}; @@ -30,10 +30,9 @@ use sp_subspace_mmr::ConsensusChainMmrLeafProof; use sp_trie::StorageProof; use std::collections::BTreeSet; -fn create_channel(chain_id: ChainId, channel_id: ChannelId, fee_model: FeeModel) { +fn create_channel(chain_id: ChainId, channel_id: ChannelId) { let params = InitiateChannelParams { max_outgoing_messages: 100, - fee_model, }; let list = BTreeSet::from([chain_id]); @@ -67,7 +66,10 @@ fn create_channel(chain_id: ChainId, channel_id: ChannelId, fee_model: FeeModel< assert_eq!( msg.payload, VersionedPayload::V0(Payload::Protocol(RequestResponse::Request( - ProtocolMessageRequest::ChannelOpen(params) + ProtocolMessageRequest::ChannelOpen(ChannelOpenParams { + max_outgoing_messages: params.max_outgoing_messages, + fee_model: ::ChannelFeeModel::get() + }) ))) ); @@ -145,7 +147,7 @@ fn test_initiate_channel() { new_chain_a_ext().execute_with(|| { let chain_id = 2.into(); let channel_id = U256::zero(); - create_channel(chain_id, channel_id, Default::default()) + create_channel(chain_id, channel_id) }); } @@ -166,7 +168,7 @@ fn test_close_open_channel() { new_chain_a_ext().execute_with(|| { let chain_id = 2.into(); let channel_id = U256::zero(); - create_channel(chain_id, channel_id, Default::default()); + create_channel(chain_id, channel_id); // open channel assert_ok!(Messenger::do_open_channel(chain_id, channel_id)); @@ -190,7 +192,7 @@ fn test_storage_proof_verification_invalid() { let chain_id = 2.into(); let channel_id = U256::zero(); t.execute_with(|| { - create_channel(chain_id, channel_id, Default::default()); + create_channel(chain_id, channel_id); assert_ok!(Messenger::do_open_channel(chain_id, channel_id)); }); @@ -211,7 +213,7 @@ fn test_storage_proof_verification_missing_value() { let chain_id = 2.into(); let channel_id = U256::zero(); t.execute_with(|| { - create_channel(chain_id, channel_id, Default::default()); + create_channel(chain_id, channel_id); assert_ok!(Messenger::do_open_channel(chain_id, channel_id)); }); @@ -233,7 +235,7 @@ fn test_storage_proof_verification() { let channel_id = U256::zero(); let mut expected_channel = None; t.execute_with(|| { - create_channel(chain_id, channel_id, Default::default()); + create_channel(chain_id, channel_id); assert_ok!(Messenger::do_open_channel(chain_id, channel_id)); expected_channel = Channels::::get(chain_id, channel_id); }); @@ -254,7 +256,6 @@ fn test_storage_proof_verification() { fn open_channel_between_chains( chain_a_test_ext: &mut TestExternalities, chain_b_test_ext: &mut TestExternalities, - fee_model: FeeModel, ) -> ChannelId { let chain_a_id = chain_a::SelfChainId::get(); let chain_b_id = chain_b::SelfChainId::get(); @@ -262,7 +263,7 @@ fn open_channel_between_chains( // initiate channel open on chain_a let channel_id = chain_a_test_ext.execute_with(|| -> ChannelId { let channel_id = U256::zero(); - create_channel(chain_b_id, channel_id, fee_model); + create_channel(chain_b_id, channel_id); channel_id }); @@ -479,7 +480,7 @@ fn force_toggle_channel_state( let fee_model = FeeModel { relay_fee: Default::default(), }; - let init_params = InitiateChannelParams { + let init_params = ChannelOpenParams { max_outgoing_messages: 100, fee_model, }; @@ -642,11 +643,7 @@ fn test_open_channel_between_chains() { let mut chain_b_test_ext = chain_b::new_test_ext(); // open channel between chain_a and chain_b // chain_a initiates the channel open - open_channel_between_chains( - &mut chain_a_test_ext, - &mut chain_b_test_ext, - Default::default(), - ); + open_channel_between_chains(&mut chain_a_test_ext, &mut chain_b_test_ext); } #[test] @@ -655,11 +652,7 @@ fn test_close_channel_between_chains() { let mut chain_b_test_ext = chain_b::new_test_ext(); // open channel between chain_a and chain_b // chain_a initiates the channel open - let channel_id = open_channel_between_chains( - &mut chain_a_test_ext, - &mut chain_b_test_ext, - Default::default(), - ); + let channel_id = open_channel_between_chains(&mut chain_a_test_ext, &mut chain_b_test_ext); // close open channel close_channel_between_chains(&mut chain_a_test_ext, &mut chain_b_test_ext, channel_id) @@ -673,10 +666,6 @@ fn close_init_channels_between_chains() { let chain_a_id = chain_a::SelfChainId::get(); let chain_b_id = chain_b::SelfChainId::get(); - let fee_model = FeeModel { - relay_fee: Default::default(), - }; - let pre_user_account_balance = chain_a_test_ext.execute_with(|| { >>::reducible_balance( &USER_ACCOUNT, @@ -688,7 +677,7 @@ fn close_init_channels_between_chains() { // initiate channel open on chain_a let channel_id = chain_a_test_ext.execute_with(|| -> ChannelId { let channel_id = U256::zero(); - create_channel(chain_b_id, channel_id, fee_model); + create_channel(chain_b_id, channel_id); channel_id }); @@ -801,11 +790,7 @@ fn test_update_domain_channel_allowlist() { let mut chain_b_test_ext = chain_b::new_test_ext(); // open channel between chain_a and chain_b // chain_a initiates the channel open - let channel_id = open_channel_between_chains( - &mut chain_a_test_ext, - &mut chain_b_test_ext, - Default::default(), - ); + let channel_id = open_channel_between_chains(&mut chain_a_test_ext, &mut chain_b_test_ext); let chain_allowlist = DomainAllowlistUpdates { allow_chains: Default::default(), @@ -830,15 +815,11 @@ fn test_send_message_between_chains() { let mut chain_b_test_ext = chain_b::new_test_ext(); // open channel between chain_a and chain_b // chain_a initiates the channel open - let channel_id = open_channel_between_chains( - &mut chain_a_test_ext, - &mut chain_b_test_ext, - Default::default(), - ); + let channel_id = open_channel_between_chains(&mut chain_a_test_ext, &mut chain_b_test_ext); // send message send_message_between_chains( - &0, + &1, &mut chain_a_test_ext, &mut chain_b_test_ext, vec![1, 2, 3, 4], @@ -932,11 +913,7 @@ fn test_transport_funds_between_chains() { // open channel between chain_a and chain_b // chain_a initiates the channel open - let channel_id = open_channel_between_chains( - &mut chain_a_test_ext, - &mut chain_b_test_ext, - FeeModel { relay_fee: 1 }, - ); + let channel_id = open_channel_between_chains(&mut chain_a_test_ext, &mut chain_b_test_ext); // initiate transfer initiate_transfer_on_chain(&mut chain_a_test_ext); @@ -964,11 +941,7 @@ fn test_transport_funds_between_chains_if_src_chain_disallows_after_message_is_s // open channel between chain_a and chain_b // chain_a initiates the channel open - let channel_id = open_channel_between_chains( - &mut chain_a_test_ext, - &mut chain_b_test_ext, - FeeModel { relay_fee: 1 }, - ); + let channel_id = open_channel_between_chains(&mut chain_a_test_ext, &mut chain_b_test_ext); // initiate transfer initiate_transfer_on_chain(&mut chain_a_test_ext); @@ -1000,11 +973,7 @@ fn test_transport_funds_between_chains_if_dst_chain_disallows_after_message_is_s // open channel between chain_a and chain_b // chain_a initiates the channel open - let channel_id = open_channel_between_chains( - &mut chain_a_test_ext, - &mut chain_b_test_ext, - FeeModel { relay_fee: 1 }, - ); + let channel_id = open_channel_between_chains(&mut chain_a_test_ext, &mut chain_b_test_ext); // initiate transfer let account_id = 1; @@ -1075,11 +1044,7 @@ fn test_transport_funds_between_chains_failed_low_balance() { let mut chain_b_test_ext = chain_b::new_test_ext(); // open channel between chain_a and chain_b // chain_a initiates the channel open - open_channel_between_chains( - &mut chain_a_test_ext, - &mut chain_b_test_ext, - Default::default(), - ); + open_channel_between_chains(&mut chain_a_test_ext, &mut chain_b_test_ext); // initiate transfer let account_id = 100; diff --git a/domains/primitives/messenger/src/messages.rs b/domains/primitives/messenger/src/messages.rs index 9f564167f3..19da8e2728 100644 --- a/domains/primitives/messenger/src/messages.rs +++ b/domains/primitives/messenger/src/messages.rs @@ -29,9 +29,9 @@ pub struct FeeModel { pub relay_fee: Balance, } -/// Parameters for a new channel between two chains. +/// Channel open parameters #[derive(Default, Debug, Encode, Decode, Clone, Eq, PartialEq, TypeInfo, Copy)] -pub struct InitiateChannelParams { +pub struct ChannelOpenParams { pub max_outgoing_messages: u32, pub fee_model: FeeModel, } @@ -40,7 +40,7 @@ pub struct InitiateChannelParams { #[derive(Debug, Encode, Decode, Clone, Eq, PartialEq, TypeInfo)] pub enum ProtocolMessageRequest { /// Request to open a channel with foreign chain. - ChannelOpen(InitiateChannelParams), + ChannelOpen(ChannelOpenParams), /// Request to close an open channel with foreign chain. ChannelClose, } diff --git a/domains/runtime/auto-id/src/lib.rs b/domains/runtime/auto-id/src/lib.rs index 8ab6de76b7..5bac5fc4c3 100644 --- a/domains/runtime/auto-id/src/lib.rs +++ b/domains/runtime/auto-id/src/lib.rs @@ -42,7 +42,7 @@ use sp_core::{Get, OpaqueMetadata}; use sp_domains::{ChannelId, DomainAllowlistUpdates, DomainId, MessengerHoldIdentifier, Transfers}; use sp_messenger::endpoint::{Endpoint, EndpointHandler as EndpointHandlerT, EndpointId}; use sp_messenger::messages::{ - BlockMessagesWithStorageKey, ChainId, CrossDomainMessage, MessageId, MessageKey, + BlockMessagesWithStorageKey, ChainId, CrossDomainMessage, FeeModel, MessageId, MessageKey, }; use sp_messenger_host_functions::{get_storage_key, StorageKeyRequest}; use sp_mmr_primitives::EncodableOpaqueLeaf; @@ -394,6 +394,8 @@ impl pallet_messenger::HoldIdentifier for HoldIdentifier { parameter_types! { pub const ChannelReserveFee: Balance = 100 * SSC; pub const ChannelInitReservePortion: Perbill = Perbill::from_percent(20); + // TODO update the fee model + pub const ChannelFeeModel: FeeModel = FeeModel{relay_fee: SSC}; } impl pallet_messenger::Config for Runtime { @@ -420,6 +422,7 @@ impl pallet_messenger::Config for Runtime { type ChannelReserveFee = ChannelReserveFee; type ChannelInitReservePortion = ChannelInitReservePortion; type DomainRegistration = (); + type ChannelFeeModel = ChannelFeeModel; } impl frame_system::offchain::SendTransactionTypes for Runtime diff --git a/domains/runtime/evm/src/lib.rs b/domains/runtime/evm/src/lib.rs index 8a916331fd..cdaa861583 100644 --- a/domains/runtime/evm/src/lib.rs +++ b/domains/runtime/evm/src/lib.rs @@ -55,7 +55,7 @@ use sp_core::{Get, OpaqueMetadata, H160, H256, U256}; use sp_domains::{ChannelId, DomainAllowlistUpdates, DomainId, MessengerHoldIdentifier, Transfers}; use sp_messenger::endpoint::{Endpoint, EndpointHandler as EndpointHandlerT, EndpointId}; use sp_messenger::messages::{ - BlockMessagesWithStorageKey, ChainId, CrossDomainMessage, MessageId, MessageKey, + BlockMessagesWithStorageKey, ChainId, CrossDomainMessage, FeeModel, MessageId, MessageKey, }; use sp_messenger_host_functions::{get_storage_key, StorageKeyRequest}; use sp_mmr_primitives::EncodableOpaqueLeaf; @@ -524,6 +524,8 @@ impl pallet_messenger::HoldIdentifier for HoldIdentifier { parameter_types! { pub const ChannelReserveFee: Balance = 100 * SSC; pub const ChannelInitReservePortion: Perbill = Perbill::from_percent(20); + // TODO update the fee model + pub const ChannelFeeModel: FeeModel = FeeModel{relay_fee: SSC}; } impl pallet_messenger::Config for Runtime { @@ -550,6 +552,7 @@ impl pallet_messenger::Config for Runtime { type ChannelReserveFee = ChannelReserveFee; type ChannelInitReservePortion = ChannelInitReservePortion; type DomainRegistration = (); + type ChannelFeeModel = ChannelFeeModel; } impl frame_system::offchain::SendTransactionTypes for Runtime diff --git a/domains/test/runtime/evm/src/lib.rs b/domains/test/runtime/evm/src/lib.rs index bc1b06aff1..34e62a02af 100644 --- a/domains/test/runtime/evm/src/lib.rs +++ b/domains/test/runtime/evm/src/lib.rs @@ -53,7 +53,8 @@ use sp_core::{Get, OpaqueMetadata, H160, H256, U256}; use sp_domains::{DomainAllowlistUpdates, DomainId, MessengerHoldIdentifier, Transfers}; use sp_messenger::endpoint::{Endpoint, EndpointHandler as EndpointHandlerT, EndpointId}; use sp_messenger::messages::{ - BlockMessagesWithStorageKey, ChainId, ChannelId, CrossDomainMessage, MessageId, MessageKey, + BlockMessagesWithStorageKey, ChainId, ChannelId, CrossDomainMessage, FeeModel, MessageId, + MessageKey, }; use sp_messenger_host_functions::{get_storage_key, StorageKeyRequest}; use sp_mmr_primitives::EncodableOpaqueLeaf; @@ -483,6 +484,7 @@ impl pallet_messenger::HoldIdentifier for HoldIdentifier { parameter_types! { pub const ChannelReserveFee: Balance = SSC; pub const ChannelInitReservePortion: Perbill = Perbill::from_percent(20); + pub const ChannelFeeModel: FeeModel = FeeModel{relay_fee: SSC}; } pub struct StorageKeys; @@ -531,6 +533,7 @@ impl pallet_messenger::Config for Runtime { type ChannelReserveFee = ChannelReserveFee; type ChannelInitReservePortion = ChannelInitReservePortion; type DomainRegistration = (); + type ChannelFeeModel = ChannelFeeModel; } impl frame_system::offchain::SendTransactionTypes for Runtime diff --git a/test/subspace-test-runtime/src/lib.rs b/test/subspace-test-runtime/src/lib.rs index 2d16d8edab..fbd1fcd3f7 100644 --- a/test/subspace-test-runtime/src/lib.rs +++ b/test/subspace-test-runtime/src/lib.rs @@ -66,7 +66,8 @@ use sp_domains_fraud_proof::storage_proof::{ }; use sp_messenger::endpoint::{Endpoint, EndpointHandler as EndpointHandlerT, EndpointId}; use sp_messenger::messages::{ - BlockMessagesWithStorageKey, ChainId, ChannelId, CrossDomainMessage, MessageId, MessageKey, + BlockMessagesWithStorageKey, ChainId, ChannelId, CrossDomainMessage, FeeModel, MessageId, + MessageKey, }; use sp_messenger_host_functions::{get_storage_key, StorageKeyRequest}; use sp_mmr_primitives::EncodableOpaqueLeaf; @@ -604,6 +605,7 @@ impl sp_messenger::DomainRegistration for DomainRegistration { parameter_types! { pub const ChannelReserveFee: Balance = SSC; pub const ChannelInitReservePortion: Perbill = Perbill::from_percent(20); + pub const ChannelFeeModel: FeeModel = FeeModel{relay_fee: SSC}; } impl pallet_messenger::Config for Runtime { @@ -630,6 +632,7 @@ impl pallet_messenger::Config for Runtime { type ChannelReserveFee = ChannelReserveFee; type ChannelInitReservePortion = ChannelInitReservePortion; type DomainRegistration = DomainRegistration; + type ChannelFeeModel = ChannelFeeModel; } impl frame_system::offchain::SendTransactionTypes for Runtime