diff --git a/libs/traits/src/liquidity_pools.rs b/libs/traits/src/liquidity_pools.rs index f0af312b94..1baede4c3e 100644 --- a/libs/traits/src/liquidity_pools.rs +++ b/libs/traits/src/liquidity_pools.rs @@ -45,13 +45,13 @@ pub trait LPMessage: Sized { /// /// Hash - hash of the message that should be recovered. /// Router - the address of the recovery router. - fn initiate_recovery_message(hash: [u8; 32], router: [u8; 20]) -> Self; + fn initiate_recovery_message(hash: [u8; 32], router: [u8; 32]) -> Self; /// Creates a message used for disputing message recovery. /// /// Hash - hash of the message that should be disputed. /// Router - the address of the recovery router. - fn dispute_recovery_message(hash: [u8; 32], router: [u8; 20]) -> Self; + fn dispute_recovery_message(hash: [u8; 32], router: [u8; 32]) -> Self; } pub trait RouterProvider: Sized { diff --git a/pallets/liquidity-pools-gateway/src/lib.rs b/pallets/liquidity-pools-gateway/src/lib.rs index 55360a59db..9f39bfc4e2 100644 --- a/pallets/liquidity-pools-gateway/src/lib.rs +++ b/pallets/liquidity-pools-gateway/src/lib.rs @@ -172,7 +172,7 @@ pub mod pallet { MessageRecoveryInitiated { domain: Domain, message_hash: MessageHash, - recovery_router: [u8; 20], + recovery_router: [u8; 32], messaging_router: T::RouterId, }, @@ -180,7 +180,7 @@ pub mod pallet { MessageRecoveryDisputed { domain: Domain, message_hash: MessageHash, - recovery_router: [u8; 20], + recovery_router: [u8; 32], messaging_router: T::RouterId, }, } @@ -513,14 +513,14 @@ pub mod pallet { origin: OriginFor, domain: Domain, message_hash: MessageHash, - recovery_router: [u8; 20], + recovery_router: [u8; 32], messaging_router: T::RouterId, ) -> DispatchResult { T::AdminOrigin::ensure_origin(origin)?; let message = T::Message::initiate_recovery_message(message_hash, recovery_router); - Self::send_recovery_message(domain.clone(), message, messaging_router.clone())?; + Self::send_recovery_message(domain, message, messaging_router.clone())?; Self::deposit_event(Event::::MessageRecoveryInitiated { domain, @@ -542,14 +542,14 @@ pub mod pallet { origin: OriginFor, domain: Domain, message_hash: MessageHash, - recovery_router: [u8; 20], + recovery_router: [u8; 32], messaging_router: T::RouterId, ) -> DispatchResult { T::AdminOrigin::ensure_origin(origin)?; let message = T::Message::dispute_recovery_message(message_hash, recovery_router); - Self::send_recovery_message(domain.clone(), message, messaging_router.clone())?; + Self::send_recovery_message(domain, message, messaging_router.clone())?; Self::deposit_event(Event::::MessageRecoveryDisputed { domain, diff --git a/pallets/liquidity-pools-gateway/src/mock.rs b/pallets/liquidity-pools-gateway/src/mock.rs index 9c3cb842bc..8f5c2db475 100644 --- a/pallets/liquidity-pools-gateway/src/mock.rs +++ b/pallets/liquidity-pools-gateway/src/mock.rs @@ -17,7 +17,7 @@ use crate::{pallet as pallet_liquidity_pools_gateway, EnsureLocal, GatewayMessag pub const TEST_SESSION_ID: u32 = 1; pub const TEST_EVM_CHAIN: EVMChainId = 1; -pub const TEST_DOMAIN: Domain = Domain::EVM(TEST_EVM_CHAIN); +pub const TEST_DOMAIN: Domain = Domain::Evm(TEST_EVM_CHAIN); pub const TEST_DOMAIN_ADDRESS: DomainAddress = DomainAddress::Evm(TEST_EVM_CHAIN, H160::repeat_byte(1)); @@ -37,8 +37,8 @@ pub enum Message { Simple, Pack(Vec), Proof([u8; 32]), - InitiateMessageRecovery(([u8; 32], [u8; 20])), - DisputeMessageRecovery(([u8; 32], [u8; 20])), + InitiateMessageRecovery(([u8; 32], [u8; 32])), + DisputeMessageRecovery(([u8; 32], [u8; 32])), } impl Debug for Message { @@ -116,11 +116,11 @@ impl LPMessage for Message { } } - fn initiate_recovery_message(hash: [u8; 32], router: [u8; 20]) -> Self { + fn initiate_recovery_message(hash: [u8; 32], router: [u8; 32]) -> Self { Self::InitiateMessageRecovery((hash, router)) } - fn dispute_recovery_message(hash: [u8; 32], router: [u8; 20]) -> Self { + fn dispute_recovery_message(hash: [u8; 32], router: [u8; 32]) -> Self { Self::DisputeMessageRecovery((hash, router)) } } diff --git a/pallets/liquidity-pools-gateway/src/tests.rs b/pallets/liquidity-pools-gateway/src/tests.rs index 9ff5dd394c..455b5bdb32 100644 --- a/pallets/liquidity-pools-gateway/src/tests.rs +++ b/pallets/liquidity-pools-gateway/src/tests.rs @@ -875,7 +875,7 @@ mod extrinsics { #[test] fn success() { new_test_ext().execute_with(|| { - let recovery_router = [1u8; 20]; + let recovery_router = [1u8; 32]; Routers::::set(BoundedVec::try_from(vec![ROUTER_ID_1]).unwrap()); @@ -911,7 +911,7 @@ mod extrinsics { #[test] fn bad_origin() { new_test_ext().execute_with(|| { - let recovery_router = [1u8; 20]; + let recovery_router = [1u8; 32]; assert_noop!( LiquidityPoolsGateway::initiate_message_recovery( @@ -929,7 +929,7 @@ mod extrinsics { #[test] fn not_enough_routers_for_domain() { new_test_ext().execute_with(|| { - let recovery_router = [1u8; 20]; + let recovery_router = [1u8; 32]; assert_noop!( LiquidityPoolsGateway::initiate_message_recovery( @@ -947,7 +947,7 @@ mod extrinsics { #[test] fn messaging_router_not_found() { new_test_ext().execute_with(|| { - let recovery_router = [1u8; 20]; + let recovery_router = [1u8; 32]; Routers::::set(BoundedVec::try_from(vec![ROUTER_ID_1]).unwrap()); @@ -979,7 +979,7 @@ mod extrinsics { #[test] fn message_sender_error() { new_test_ext().execute_with(|| { - let recovery_router = [1u8; 20]; + let recovery_router = [1u8; 32]; Routers::::set(BoundedVec::try_from(vec![ROUTER_ID_1]).unwrap()); @@ -1017,7 +1017,7 @@ mod extrinsics { #[test] fn success() { new_test_ext().execute_with(|| { - let recovery_router = [1u8; 20]; + let recovery_router = [1u8; 32]; Routers::::set(BoundedVec::try_from(vec![ROUTER_ID_1]).unwrap()); @@ -1053,7 +1053,7 @@ mod extrinsics { #[test] fn bad_origin() { new_test_ext().execute_with(|| { - let recovery_router = [1u8; 20]; + let recovery_router = [1u8; 32]; assert_noop!( LiquidityPoolsGateway::dispute_message_recovery( @@ -1071,7 +1071,7 @@ mod extrinsics { #[test] fn not_enough_routers_for_domain() { new_test_ext().execute_with(|| { - let recovery_router = [1u8; 20]; + let recovery_router = [1u8; 32]; assert_noop!( LiquidityPoolsGateway::dispute_message_recovery( @@ -1089,7 +1089,7 @@ mod extrinsics { #[test] fn messaging_router_not_found() { new_test_ext().execute_with(|| { - let recovery_router = [1u8; 20]; + let recovery_router = [1u8; 32]; Routers::::set(BoundedVec::try_from(vec![ROUTER_ID_1]).unwrap()); @@ -1121,7 +1121,7 @@ mod extrinsics { #[test] fn message_sender_error() { new_test_ext().execute_with(|| { - let recovery_router = [1u8; 20]; + let recovery_router = [1u8; 32]; Routers::::set(BoundedVec::try_from(vec![ROUTER_ID_1]).unwrap()); diff --git a/pallets/liquidity-pools/src/message.rs b/pallets/liquidity-pools/src/message.rs index 49380e882b..3017e96800 100644 --- a/pallets/liquidity-pools/src/message.rs +++ b/pallets/liquidity-pools/src/message.rs @@ -226,7 +226,7 @@ pub enum Message { /// The hash of the message which shall be recovered hash: [u8; 32], /// The address of the router - router: [u8; 20], + router: [u8; 32], }, /// Dispute the recovery of a message. /// @@ -237,7 +237,7 @@ pub enum Message { /// The hash of the message which shall be disputed hash: [u8; 32], /// The address of the router - router: [u8; 20], + router: [u8; 32], }, /// A batch of ordered messages. /// Don't allow nested batch messages. @@ -575,11 +575,11 @@ impl LPMessage for Message { Message::MessageProof { hash } } - fn initiate_recovery_message(hash: [u8; 32], router: [u8; 20]) -> Self { + fn initiate_recovery_message(hash: [u8; 32], router: [u8; 32]) -> Self { Message::InitiateMessageRecovery { hash, router } } - fn dispute_recovery_message(hash: [u8; 32], router: [u8; 20]) -> Self { + fn dispute_recovery_message(hash: [u8; 32], router: [u8; 32]) -> Self { Message::DisputeMessageRecovery { hash, router } } } diff --git a/runtime/integration-tests/src/cases/liquidity_pools.rs b/runtime/integration-tests/src/cases/liquidity_pools.rs index 604d382670..328bb305e4 100644 --- a/runtime/integration-tests/src/cases/liquidity_pools.rs +++ b/runtime/integration-tests/src/cases/liquidity_pools.rs @@ -1026,15 +1026,12 @@ mod foreign_investments { let nonce = MessageNonceStore::::get(); - let sender = T::Sender::get(); - // Clearing of foreign InvestState should be dispatched assert!(frame_system::Pallet::::events().iter().any(|e| { e.event == pallet_liquidity_pools_gateway_queue::Event::MessageSubmitted { nonce, message: GatewayMessage::Outbound { - sender: sender.clone(), router_id: DEFAULT_ROUTER_ID, message: LiquidityPoolMessage::FulfilledDepositRequest { pool_id, @@ -1130,14 +1127,11 @@ mod foreign_investments { let nonce = MessageNonceStore::::get(); - let sender = T::Sender::get(); - assert!(frame_system::Pallet::::events().iter().any(|e| { e.event == pallet_liquidity_pools_gateway_queue::Event::::MessageSubmitted { nonce, message: GatewayMessage::Outbound { - sender: sender.clone(), router_id: DEFAULT_ROUTER_ID, message: Message::FulfilledDepositRequest { pool_id, @@ -1230,7 +1224,6 @@ mod foreign_investments { == pallet_liquidity_pools_gateway_queue::Event::::MessageSubmitted { nonce, message: GatewayMessage::Outbound { - sender: sender.clone(), router_id: DEFAULT_ROUTER_ID, message: LiquidityPoolMessage::FulfilledDepositRequest { pool_id, @@ -1265,12 +1258,11 @@ mod foreign_investments { pallet_liquidity_pools_gateway_queue::Event::MessageSubmitted { message: GatewayMessage::Outbound { - sender: event_sender, router_id: event_router_id, message: Message::FulfilledDepositRequest { .. }, }, .. - } => event_sender == sender && event_router_id == DEFAULT_ROUTER_ID, + } => event_router_id == DEFAULT_ROUTER_ID, _ => false, } } else { @@ -1502,14 +1494,11 @@ mod foreign_investments { let nonce = MessageNonceStore::::get(); - let sender = T::Sender::get(); - assert!(frame_system::Pallet::::events().iter().any(|e| { e.event == pallet_liquidity_pools_gateway_queue::Event::::MessageSubmitted { nonce, message: GatewayMessage::Outbound { - sender: sender.clone(), router_id: DEFAULT_ROUTER_ID, message: LiquidityPoolMessage::FulfilledRedeemRequest { pool_id, @@ -1599,7 +1588,6 @@ mod foreign_investments { == pallet_liquidity_pools_gateway_queue::Event::::MessageSubmitted { nonce, message: GatewayMessage::Outbound { - sender: sender.clone(), router_id: DEFAULT_ROUTER_ID, message: LiquidityPoolMessage::FulfilledRedeemRequest { pool_id, @@ -1940,14 +1928,11 @@ mod foreign_investments { let nonce = MessageNonceStore::::get(); - let sender = T::Sender::get(); - assert!(frame_system::Pallet::::events().iter().any(|e| { e.event == pallet_liquidity_pools_gateway_queue::Event::::MessageSubmitted { nonce, message: GatewayMessage::Outbound { - sender: sender.clone(), router_id: DEFAULT_ROUTER_ID, message: LiquidityPoolMessage::FulfilledDepositRequest { pool_id, @@ -2091,14 +2076,11 @@ mod foreign_investments { let nonce = MessageNonceStore::::get(); - let sender = ::Sender::get(); - assert!(frame_system::Pallet::::events().iter().any(|e| { e.event == pallet_liquidity_pools_gateway_queue::Event::::MessageSubmitted { nonce, message: GatewayMessage::Outbound { - sender: sender.clone(), router_id: DEFAULT_ROUTER_ID, message: LiquidityPoolMessage::FulfilledCancelDepositRequest { pool_id, @@ -2202,14 +2184,11 @@ mod foreign_investments { let nonce = MessageNonceStore::::get(); - let sender = ::Sender::get(); - assert!(frame_system::Pallet::::events().iter().any(|e| { e.event == pallet_liquidity_pools_gateway_queue::Event::::MessageSubmitted { nonce, message: GatewayMessage::Outbound { - sender: sender.clone(), router_id: DEFAULT_ROUTER_ID, message: LiquidityPoolMessage::FulfilledCancelDepositRequest { pool_id, diff --git a/runtime/integration-tests/src/cases/liquidity_pools_gateway_queue.rs b/runtime/integration-tests/src/cases/liquidity_pools_gateway_queue.rs index 7699fb7052..85573a4581 100644 --- a/runtime/integration-tests/src/cases/liquidity_pools_gateway_queue.rs +++ b/runtime/integration-tests/src/cases/liquidity_pools_gateway_queue.rs @@ -1,4 +1,3 @@ -use cfg_primitives::AccountId; use cfg_traits::liquidity_pools::MessageQueue; use cfg_types::domain_address::DomainAddress; use frame_support::{assert_ok, traits::OriginTrait}; @@ -72,7 +71,6 @@ fn outbound() { let nonce = ::MessageNonce::one(); let message = GatewayMessage::Outbound { - sender: DomainAddress::Centrifuge(AccountId::new([1; 32])), router_id: DEFAULT_ROUTER_ID, message: Message::Invalid, }; diff --git a/runtime/integration-tests/src/cases/lp/utils.rs b/runtime/integration-tests/src/cases/lp/utils.rs index 8188118c1b..c7d5c72121 100644 --- a/runtime/integration-tests/src/cases/lp/utils.rs +++ b/runtime/integration-tests/src/cases/lp/utils.rs @@ -139,15 +139,7 @@ pub fn process_gateway_message( match msg { GatewayMessage::Inbound { message, .. } => verifier(message), - GatewayMessage::Outbound { - sender, - router_id, - message, - } => { - assert_eq!( - sender, - ::Sender::get() - ); + GatewayMessage::Outbound { router_id, message } => { assert_eq!(router_id, EVM_ROUTER_ID); verifier(message) } diff --git a/runtime/integration-tests/src/cases/routers.rs b/runtime/integration-tests/src/cases/routers.rs index e892296c9b..9394b18b1b 100644 --- a/runtime/integration-tests/src/cases/routers.rs +++ b/runtime/integration-tests/src/cases/routers.rs @@ -14,7 +14,7 @@ use runtime_common::{ account_conversion::AccountConverter, evm::precompile::LP_AXELAR_GATEWAY, gateway::get_gateway_domain_address, routing::RouterId, }; -use sp_core::{Get, H160, H256, U256}; +use sp_core::{H160, H256, U256}; use sp_runtime::traits::{BlakeTwo256, Hash}; use crate::{ @@ -139,7 +139,6 @@ mod axelar_evm { )); let gateway_message = GatewayMessage::Outbound { - sender: T::Sender::get(), router_id: TEST_ROUTER_ID, message: Message::Invalid, };