From 6541a7fe0e06498cfec3796c886111fa3aafc023 Mon Sep 17 00:00:00 2001 From: Cosmin Damian <17934949+cdamian@users.noreply.github.com> Date: Wed, 14 Aug 2024 14:33:44 +0300 Subject: [PATCH] lp-gateway: Drop session ID invalidation (#1965) * lp-gateway: Drop session ID invalidation * lp-gateway: Add test for invalid router --- pallets/liquidity-pools-gateway/src/lib.rs | 92 +++--- .../src/message_processing.rs | 233 +++++++------ pallets/liquidity-pools-gateway/src/mock.rs | 1 + pallets/liquidity-pools-gateway/src/tests.rs | 306 ++++++++++-------- 4 files changed, 328 insertions(+), 304 deletions(-) diff --git a/pallets/liquidity-pools-gateway/src/lib.rs b/pallets/liquidity-pools-gateway/src/lib.rs index c6c5469afb..124fc04aa0 100644 --- a/pallets/liquidity-pools-gateway/src/lib.rs +++ b/pallets/liquidity-pools-gateway/src/lib.rs @@ -35,12 +35,12 @@ use cfg_traits::liquidity_pools::{ }; use cfg_types::domain_address::{Domain, DomainAddress}; use frame_support::{dispatch::DispatchResult, pallet_prelude::*}; -use frame_system::pallet_prelude::{ensure_signed, BlockNumberFor, OriginFor}; +use frame_system::pallet_prelude::{ensure_signed, OriginFor}; use message::GatewayMessage; use orml_traits::GetByKey; pub use pallet::*; use parity_scale_codec::FullCodec; -use sp_arithmetic::traits::{BaseArithmetic, EnsureAdd, EnsureAddAssign, One, Zero}; +use sp_arithmetic::traits::{BaseArithmetic, EnsureAddAssign, One}; use sp_std::convert::TryInto; use crate::{message_processing::InboundEntry, weights::WeightInfo}; @@ -74,13 +74,6 @@ pub mod pallet { #[pallet::origin] pub type Origin = GatewayOrigin; - #[pallet::hooks] - impl Hooks> for Pallet { - fn on_idle(_now: BlockNumberFor, max_weight: Weight) -> Weight { - Self::clear_invalid_session_ids(max_weight) - } - } - #[pallet::config] pub trait Config: frame_system::Config { /// The origin type. @@ -175,7 +168,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn routers)] pub type Routers = - StorageValue<_, BoundedVec, OptionQuery>; + StorageValue<_, BoundedVec, ValueQuery>; /// Storage that contains a limited number of whitelisted instances of /// deployed liquidity pools for a particular domain. @@ -208,23 +201,15 @@ pub mod pallet { pub type PendingInboundEntries = StorageDoubleMap< _, Blake2_128Concat, - T::SessionId, + Proof, Blake2_128Concat, - (Proof, T::RouterId), + T::RouterId, InboundEntry, >; /// Storage for inbound message session IDs. #[pallet::storage] - pub type SessionIdStore = StorageValue<_, T::SessionId, OptionQuery>; - - /// Storage that keeps track of invalid session IDs. - /// - /// Any `PendingInboundEntries` mapped to the invalid IDs are removed from - /// storage during `on_idle`. - #[pallet::storage] - #[pallet::getter(fn invalid_message_sessions)] - pub type InvalidMessageSessions = StorageMap<_, Blake2_128Concat, T::SessionId, ()>; + pub type SessionIdStore = StorageValue<_, T::SessionId, ValueQuery>; #[pallet::error] pub enum Error { @@ -254,11 +239,8 @@ pub mod pallet { /// was not started by `start_batch_message()`. MessagePackingNotStarted, - /// Invalid multi router. - InvalidMultiRouter, - - /// Session ID not found. - SessionIdNotFound, + /// Invalid routers. + InvalidRouters, /// Unknown router. UnknownRouter, @@ -286,9 +268,6 @@ pub mod pallet { /// Not enough routers are stored for a domain. NotEnoughRoutersForDomain, - - /// First router for a domain was not found. - FirstRouterNotFound, } #[pallet::call] @@ -302,22 +281,15 @@ pub mod pallet { ) -> DispatchResult { T::AdminOrigin::ensure_origin(origin)?; - >::set(Some(router_ids.clone())); - - let (old_session_id, new_session_id) = - SessionIdStore::::try_mutate(|storage_entry| { - let old_session_id = storage_entry.unwrap_or(T::SessionId::zero()); - let new_session_id = old_session_id.ensure_add(One::one())?; + ensure!(router_ids.len() > 0, Error::::InvalidRouters); - *storage_entry = Some(new_session_id); + >::set(router_ids.clone()); - Ok::<(T::SessionId, T::SessionId), DispatchError>(( - old_session_id, - new_session_id, - )) - })?; + let new_session_id = SessionIdStore::::try_mutate(|n| { + n.ensure_add_assign(One::one())?; - InvalidMessageSessions::::insert(old_session_id, ()); + Ok::(*n) + })?; Self::deposit_event(Event::RoutersSet { router_ids, @@ -468,27 +440,43 @@ pub mod pallet { Error::::UnknownRouter ); + ensure!( + inbound_processing_info.router_ids.len() > 1, + Error::::NotEnoughRoutersForDomain + ); + weight.saturating_accrue(T::DbWeight::get().writes(1)); - PendingInboundEntries::::try_mutate( - inbound_processing_info.current_session_id, - (proof, router_id.clone()), - |storage_entry| match storage_entry { - Some(entry) => match entry { - InboundEntry::Proof { current_count } => { - current_count.ensure_add_assign(1).map_err(|e| e.into()) + PendingInboundEntries::::try_mutate(proof, router_id.clone(), |storage_entry| { + match storage_entry { + Some(stored_inbound_entry) => match stored_inbound_entry { + InboundEntry::Proof { + session_id, + current_count, + } => { + if *session_id != inbound_processing_info.current_session_id { + *session_id = inbound_processing_info.current_session_id; + *current_count = 1; + } else { + current_count.ensure_add_assign(1)?; + } + + Ok::<(), DispatchError>(()) } InboundEntry::Message { .. } => { Err(Error::::ExpectedMessageProofType.into()) } }, None => { - *storage_entry = Some(InboundEntry::::Proof { current_count: 1 }); + *storage_entry = Some(InboundEntry::::Proof { + session_id: inbound_processing_info.current_session_id, + current_count: 1, + }); Ok::<(), DispatchError>(()) } - }, - )?; + } + })?; Self::execute_if_requirements_are_met(&inbound_processing_info, proof, &mut weight)?; diff --git a/pallets/liquidity-pools-gateway/src/message_processing.rs b/pallets/liquidity-pools-gateway/src/message_processing.rs index be334410a5..045714316c 100644 --- a/pallets/liquidity-pools-gateway/src/message_processing.rs +++ b/pallets/liquidity-pools-gateway/src/message_processing.rs @@ -14,24 +14,21 @@ use sp_arithmetic::traits::{EnsureAddAssign, EnsureSub}; use sp_runtime::DispatchError; use crate::{ - message::GatewayMessage, Config, Error, InvalidMessageSessions, Pallet, PendingInboundEntries, - Routers, SessionIdStore, + message::GatewayMessage, Config, Error, Pallet, PendingInboundEntries, Routers, SessionIdStore, }; -/// The limit used when clearing the `PendingInboundEntries` for invalid -/// session IDs. -const INVALID_ID_REMOVAL_LIMIT: u32 = 100; - /// Type used when storing inbound message information. #[derive(Debug, Encode, Decode, Clone, Eq, MaxEncodedLen, PartialEq, TypeInfo)] #[scale_info(skip_type_params(T))] pub enum InboundEntry { Message { + session_id: T::SessionId, domain_address: DomainAddress, message: T::Message, expected_proof_count: u32, }, Proof { + session_id: T::SessionId, current_count: u32, }, } @@ -51,7 +48,7 @@ impl Pallet { pub fn get_router_ids_for_domain(domain: Domain) -> Result, DispatchError> { let all_routers_for_domain = T::RouterProvider::routers_for_domain(domain); - let stored_routers = Routers::::get().ok_or(Error::::RoutersNotFound)?; + let stored_routers = Routers::::get(); let res = all_routers_for_domain .iter() @@ -91,17 +88,20 @@ impl Pallet { /// Creates an inbound entry based on whether the inbound message is a /// proof or not. fn create_inbound_entry( - domain_address: DomainAddress, + inbound_processing_info: &InboundProcessingInfo, message: T::Message, - expected_proof_count: u32, ) -> InboundEntry { match message.get_message_proof() { None => InboundEntry::Message { - domain_address, + session_id: inbound_processing_info.current_session_id.clone(), + domain_address: inbound_processing_info.domain_address.clone(), message, - expected_proof_count, + expected_proof_count: inbound_processing_info.expected_proof_count_per_message, + }, + Some(_) => InboundEntry::Proof { + session_id: inbound_processing_info.current_session_id, + current_count: 1, }, - Some(_) => InboundEntry::Proof { current_count: 1 }, } } @@ -146,7 +146,6 @@ impl Pallet { /// Upserts an inbound entry for a particular message, increasing the /// relevant counts accordingly. fn upsert_pending_entry( - session_id: T::SessionId, message_proof: Proof, router_id: T::RouterId, inbound_entry: InboundEntry, @@ -154,10 +153,8 @@ impl Pallet { ) -> DispatchResult { weight.saturating_accrue(T::DbWeight::get().writes(1)); - PendingInboundEntries::::try_mutate( - session_id, - (message_proof, router_id), - |storage_entry| match storage_entry { + PendingInboundEntries::::try_mutate(message_proof, router_id, |storage_entry| { + match storage_entry { None => { *storage_entry = Some(inbound_entry); @@ -165,26 +162,51 @@ impl Pallet { } Some(stored_inbound_entry) => match stored_inbound_entry { InboundEntry::Message { - expected_proof_count: old, + session_id: stored_session_id, + expected_proof_count: stored_expected_proof_count, .. } => match inbound_entry { InboundEntry::Message { - expected_proof_count: new, + session_id: new_session_id, + expected_proof_count: new_expected_proof_count, .. - } => old.ensure_add_assign(new).map_err(|e| e.into()), + } => { + if *stored_session_id != new_session_id { + *stored_session_id = new_session_id; + *stored_expected_proof_count = new_expected_proof_count; + } else { + stored_expected_proof_count + .ensure_add_assign(new_expected_proof_count)?; + } + + Ok::<(), DispatchError>(()) + } InboundEntry::Proof { .. } => Err(Error::::ExpectedMessageType.into()), }, - InboundEntry::Proof { current_count: old } => match inbound_entry { - InboundEntry::Proof { current_count: new } => { - old.ensure_add_assign(new).map_err(|e| e.into()) + InboundEntry::Proof { + session_id: stored_session_id, + current_count: stored_current_count, + } => match inbound_entry { + InboundEntry::Proof { + session_id: new_session_id, + current_count: new_current_count, + } => { + if *stored_session_id != new_session_id { + *stored_session_id = new_session_id; + *stored_current_count = new_current_count; + } else { + stored_current_count.ensure_add_assign(new_current_count)?; + } + + Ok::<(), DispatchError>(()) } InboundEntry::Message { .. } => { Err(Error::::ExpectedMessageProofType.into()) } }, }, - }, - ) + } + }) } /// Creates, validates and upserts the inbound entry. @@ -195,21 +217,11 @@ impl Pallet { router_id: T::RouterId, weight: &mut Weight, ) -> DispatchResult { - let inbound_entry = Self::create_inbound_entry( - inbound_processing_info.domain_address.clone(), - message, - inbound_processing_info.expected_proof_count_per_message, - ); + let inbound_entry = Self::create_inbound_entry(inbound_processing_info, message); Self::validate_inbound_entry(&inbound_processing_info, &router_id, &inbound_entry)?; - Self::upsert_pending_entry( - inbound_processing_info.current_session_id, - message_proof, - router_id, - inbound_entry, - weight, - )?; + Self::upsert_pending_entry(message_proof, router_id, inbound_entry, weight)?; Ok(()) } @@ -228,19 +240,24 @@ impl Pallet { for router_id in &inbound_processing_info.router_ids { weight.saturating_accrue(T::DbWeight::get().reads(1)); - match PendingInboundEntries::::get( - inbound_processing_info.current_session_id, - (message_proof, router_id), - ) { + match PendingInboundEntries::::get(message_proof, router_id) { // We expected one InboundEntry for each router, if that's not the case, // we can return. None => return Ok(()), - Some(inbound_entry) => match inbound_entry { + Some(stored_inbound_entry) => match stored_inbound_entry { InboundEntry::Message { message: stored_message, .. } => message = Some(stored_message), - InboundEntry::Proof { current_count } => { + InboundEntry::Proof { + session_id, + current_count, + } => { + if session_id != inbound_processing_info.current_session_id { + // Don't count vote from invalid sessions. + continue; + } + if current_count > 0 { votes += 1; } @@ -281,39 +298,59 @@ impl Pallet { weight.saturating_accrue(T::DbWeight::get().writes(1)); match PendingInboundEntries::::try_mutate( - inbound_processing_info.current_session_id, - (message_proof, router_id), + message_proof, + router_id, |storage_entry| match storage_entry { None => Err(Error::::PendingInboundEntryNotFound.into()), - Some(stored_inbound_entry) => match stored_inbound_entry { - InboundEntry::Message { - expected_proof_count, - .. - } => { - let updated_count = (*expected_proof_count).ensure_sub( - inbound_processing_info.expected_proof_count_per_message, - )?; - - if updated_count == 0 { - *storage_entry = None; - } else { - *expected_proof_count = updated_count; + Some(stored_inbound_entry) => { + match stored_inbound_entry { + InboundEntry::Message { + session_id, + expected_proof_count, + .. + } => { + if *session_id != inbound_processing_info.current_session_id { + // Remove the storage entry completely. + *storage_entry = None; + + return Ok::<(), DispatchError>(()); + } + + let updated_count = (*expected_proof_count).ensure_sub( + inbound_processing_info.expected_proof_count_per_message, + )?; + + if updated_count == 0 { + *storage_entry = None; + } else { + *expected_proof_count = updated_count; + } + + Ok::<(), DispatchError>(()) } - - Ok::<(), DispatchError>(()) - } - InboundEntry::Proof { current_count } => { - let updated_count = (*current_count).ensure_sub(1)?; - - if updated_count == 0 { - *storage_entry = None; - } else { - *current_count = updated_count; + InboundEntry::Proof { + session_id, + current_count, + } => { + if *session_id != inbound_processing_info.current_session_id { + // Remove the storage entry completely. + *storage_entry = None; + + return Ok::<(), DispatchError>(()); + } + + let updated_count = (*current_count).ensure_sub(1)?; + + if updated_count == 0 { + *storage_entry = None; + } else { + *current_count = updated_count; + } + + Ok::<(), DispatchError>(()) } - - Ok::<(), DispatchError>(()) } - }, + } }, ) { Ok(()) => {} @@ -334,7 +371,7 @@ impl Pallet { weight.saturating_accrue(T::DbWeight::get().reads(1)); - let current_session_id = SessionIdStore::::get().ok_or(Error::::SessionIdNotFound)?; + let current_session_id = SessionIdStore::::get(); weight.saturating_accrue(T::DbWeight::get().reads(1)); @@ -373,7 +410,9 @@ impl Pallet { let mut count = 0; for submessage in message.submessages() { - count += 1; + if let Err(e) = count.ensure_add_assign(1) { + return (Err(e.into()), weight); + } let message_proof = Self::get_message_proof(message.clone()); @@ -447,52 +486,4 @@ impl Pallet { Ok(()) } - - /// Clears `PendingInboundEntries` mapped to invalid session IDs as long as - /// there is enough weight available for this operation. - /// - /// The invalid session IDs are removed from storage if all entries mapped - /// to them were cleared. - pub(crate) fn clear_invalid_session_ids(max_weight: Weight) -> Weight { - let invalid_session_ids = InvalidMessageSessions::::iter_keys().collect::>(); - - let mut weight = T::DbWeight::get().reads(1); - - for invalid_session_id in invalid_session_ids { - let mut cursor: Option> = None; - - loop { - let res = PendingInboundEntries::::clear_prefix( - invalid_session_id, - INVALID_ID_REMOVAL_LIMIT, - cursor.as_ref().map(|x| x.as_ref()), - ); - - weight.saturating_accrue( - T::DbWeight::get().reads_writes(res.loops.into(), res.unique.into()), - ); - - if weight.all_gte(max_weight) { - return weight; - } - - cursor = match res.maybe_cursor { - None => { - InvalidMessageSessions::::remove(invalid_session_id); - - weight.saturating_accrue(T::DbWeight::get().writes(1)); - - if weight.all_gte(max_weight) { - return weight; - } - - break; - } - Some(c) => Some(c), - }; - } - } - - weight - } } diff --git a/pallets/liquidity-pools-gateway/src/mock.rs b/pallets/liquidity-pools-gateway/src/mock.rs index a94bf1bc1c..0187e6d8a4 100644 --- a/pallets/liquidity-pools-gateway/src/mock.rs +++ b/pallets/liquidity-pools-gateway/src/mock.rs @@ -15,6 +15,7 @@ use sp_runtime::{traits::IdentityLookup, DispatchError, DispatchResult}; use crate::{pallet as pallet_liquidity_pools_gateway, EnsureLocal, GatewayMessage}; +pub const TEST_SESSION_ID: u32 = 1; pub const TEST_EVM_CHAIN: EVMChainId = 1; pub const TEST_DOMAIN_ADDRESS: DomainAddress = DomainAddress::EVM(TEST_EVM_CHAIN, [1; 20]); diff --git a/pallets/liquidity-pools-gateway/src/tests.rs b/pallets/liquidity-pools-gateway/src/tests.rs index 5904f6c082..89bad351cc 100644 --- a/pallets/liquidity-pools-gateway/src/tests.rs +++ b/pallets/liquidity-pools-gateway/src/tests.rs @@ -62,12 +62,8 @@ mod set_routers { router_ids.clone(), )); - assert_eq!(Routers::::get(), Some(router_ids.clone())); - assert_eq!(SessionIdStore::::get(), Some(session_id)); - assert_eq!( - InvalidMessageSessions::::get(session_id - 1), - Some(()) - ); + assert_eq!(Routers::::get(), router_ids.clone()); + assert_eq!(SessionIdStore::::get(), session_id); event_exists(Event::::RoutersSet { router_ids, @@ -83,12 +79,8 @@ mod set_routers { router_ids.clone(), )); - assert_eq!(Routers::::get(), Some(router_ids.clone())); - assert_eq!(SessionIdStore::::get(), Some(session_id)); - assert_eq!( - InvalidMessageSessions::::get(session_id - 1), - Some(()) - ); + assert_eq!(Routers::::get(), router_ids.clone()); + assert_eq!(SessionIdStore::::get(), session_id); event_exists(Event::::RoutersSet { router_ids, @@ -108,21 +100,33 @@ mod set_routers { BadOrigin ); - assert!(Routers::::get().is_none()); - assert!(SessionIdStore::::get().is_none()); - assert!(InvalidMessageSessions::::get(0).is_none()); + assert!(Routers::::get().is_empty()); + assert_eq!(SessionIdStore::::get(), 0); + }); + } + + #[test] + fn invalid_routers() { + new_test_ext().execute_with(|| { + assert_noop!( + LiquidityPoolsGateway::set_routers( + RuntimeOrigin::root(), + BoundedVec::try_from(vec![]).unwrap(), + ), + Error::::InvalidRouters + ); }); } #[test] fn session_id_overflow() { new_test_ext().execute_with(|| { - SessionIdStore::::set(Some(u32::MAX)); + SessionIdStore::::set(u32::MAX); assert_noop!( LiquidityPoolsGateway::set_routers( RuntimeOrigin::root(), - BoundedVec::try_from(vec![]).unwrap(), + BoundedVec::try_from(vec![ROUTER_ID_1]).unwrap(), ), Arithmetic(Overflow) ); @@ -482,7 +486,7 @@ mod outbound_message_handler_impl { assert_noop!( LiquidityPoolsGateway::handle(sender, domain, msg), - Error::::RoutersNotFound + Error::::NotEnoughRoutersForDomain ); }); } @@ -585,13 +589,13 @@ mod message_processor_impl { println!("Executing test for - {:?}", test.router_messages); new_test_ext().execute_with(|| { - let session_id = 1; + let session_id = TEST_SESSION_ID; Routers::::set( - Some(BoundedVec::try_from(test_routers.clone()).unwrap()), + BoundedVec::try_from(test_routers.clone()).unwrap(), ); SessionIdStore::::set( - Some(session_id), + session_id, ); let handler = MockLiquidityPools::mock_handle(move |_, _| Ok(())); @@ -620,12 +624,11 @@ mod message_processor_impl { for expected_storage_entry in test.expected_test_result.expected_storage_entries { - let expected_storage_entry_router_hash = expected_storage_entry.0; + let expected_storage_entry_router_id = expected_storage_entry.0; let expected_inbound_entry = expected_storage_entry.1; let storage_entry = PendingInboundEntries::::get( - session_id, - (MESSAGE_PROOF, expected_storage_entry_router_hash), + MESSAGE_PROOF, expected_storage_entry_router_id, ); assert_eq!(storage_entry, expected_inbound_entry, "Expected inbound entry {expected_inbound_entry:?}, found {storage_entry:?}"); } @@ -741,10 +744,10 @@ mod message_processor_impl { router_id: router_id.clone(), }; - Routers::::set(Some( + Routers::::set( BoundedVec::<_, _>::try_from(vec![router_id.clone()]).unwrap(), - )); - SessionIdStore::::set(Some(session_id)); + ); + SessionIdStore::::set(session_id); let handler = MockLiquidityPools::mock_handle( move |mock_domain_address, mock_message| { @@ -759,11 +762,9 @@ mod message_processor_impl { assert_ok!(res); assert_eq!(handler.times(), 1); - assert!(PendingInboundEntries::::get( - session_id, - (message_proof, router_id) - ) - .is_none()); + assert!( + PendingInboundEntries::::get(message_proof, router_id).is_none() + ); }); } @@ -780,28 +781,7 @@ mod message_processor_impl { }; let (res, _) = LiquidityPoolsGateway::process(gateway_message); - assert_noop!(res, Error::::RoutersNotFound); - }); - } - - #[test] - fn inbound_domain_session_not_found() { - new_test_ext().execute_with(|| { - let message = Message::Simple; - let domain_address = DomainAddress::EVM(1, [1; 20]); - let router_id = ROUTER_ID_1; - let gateway_message = GatewayMessage::Inbound { - domain_address: domain_address.clone(), - message: message.clone(), - router_id: router_id.clone(), - }; - - Routers::::set(Some( - BoundedVec::<_, _>::try_from(vec![router_id]).unwrap(), - )); - - let (res, _) = LiquidityPoolsGateway::process(gateway_message); - assert_noop!(res, Error::::SessionIdNotFound); + assert_noop!(res, Error::::NotEnoughRoutersForDomain); }); } @@ -820,10 +800,10 @@ mod message_processor_impl { router_id: ROUTER_ID_2, }; - Routers::::set(Some( + Routers::::set( BoundedVec::<_, _>::try_from(vec![router_hash]).unwrap(), - )); - SessionIdStore::::set(Some(session_id)); + ); + SessionIdStore::::set(session_id); let (res, _) = LiquidityPoolsGateway::process(gateway_message); assert_noop!(res, Error::::UnknownRouter); @@ -844,14 +824,17 @@ mod message_processor_impl { router_id: router_id.clone(), }; - Routers::::set(Some( + Routers::::set( BoundedVec::<_, _>::try_from(vec![router_id.clone()]).unwrap(), - )); - SessionIdStore::::set(Some(session_id)); + ); + SessionIdStore::::set(session_id); PendingInboundEntries::::insert( - session_id, - (message_proof, router_id), - InboundEntry::::Proof { current_count: 0 }, + message_proof, + router_id, + InboundEntry::::Proof { + session_id, + current_count: 0, + }, ); let (res, _) = LiquidityPoolsGateway::process(gateway_message); @@ -893,6 +876,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 2, @@ -914,6 +898,7 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 2, }), ), @@ -980,6 +965,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 3, @@ -1002,6 +988,7 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 3, }), ), @@ -1020,6 +1007,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 1, @@ -1041,6 +1029,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 1, @@ -1063,6 +1052,7 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 1, }), ), @@ -1081,6 +1071,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 1, @@ -1103,6 +1094,7 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 1, }), ), @@ -1122,6 +1114,7 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 1, }), ), @@ -1163,6 +1156,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 4, @@ -1186,6 +1180,7 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 4, }), ), @@ -1205,6 +1200,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 2, @@ -1227,6 +1223,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 2, @@ -1249,6 +1246,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 2, @@ -1271,6 +1269,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 2, @@ -1384,6 +1383,7 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 2, }), ), @@ -1404,6 +1404,7 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 2, }), ), @@ -1424,6 +1425,7 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 2, }), ), @@ -1444,6 +1446,7 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 2, }), ), @@ -1472,10 +1475,10 @@ mod message_processor_impl { new_test_ext().execute_with(|| { let session_id = 1; - Routers::::set(Some( + Routers::::set( BoundedVec::<_, _>::try_from(vec![ROUTER_ID_1, ROUTER_ID_2]).unwrap(), - )); - SessionIdStore::::set(Some(session_id)); + ); + SessionIdStore::::set(session_id); let gateway_message = GatewayMessage::Inbound { domain_address: TEST_DOMAIN_ADDRESS, @@ -1493,10 +1496,10 @@ mod message_processor_impl { new_test_ext().execute_with(|| { let session_id = 1; - Routers::::set(Some( + Routers::::set( BoundedVec::<_, _>::try_from(vec![ROUTER_ID_1, ROUTER_ID_2]).unwrap(), - )); - SessionIdStore::::set(Some(session_id)); + ); + SessionIdStore::::set(session_id); let gateway_message = GatewayMessage::Inbound { domain_address: TEST_DOMAIN_ADDRESS, @@ -1542,6 +1545,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 4, @@ -1564,6 +1568,7 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 2, }), ), @@ -1584,6 +1589,7 @@ mod message_processor_impl { ( ROUTER_ID_3, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 2, }), ), @@ -1602,12 +1608,14 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 1, }), ), ( ROUTER_ID_3, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 1, }), ), @@ -1626,12 +1634,14 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 1, }), ), ( ROUTER_ID_3, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 1, }), ), @@ -1649,6 +1659,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 2, @@ -1657,6 +1668,7 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 1, }), ), @@ -1675,6 +1687,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 2, @@ -1684,6 +1697,7 @@ mod message_processor_impl { ( ROUTER_ID_3, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 1, }), ), @@ -1701,6 +1715,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 2, @@ -1710,6 +1725,7 @@ mod message_processor_impl { ( ROUTER_ID_3, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 1, }), ), @@ -1727,6 +1743,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 2, @@ -1735,6 +1752,7 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 1, }), ), @@ -1753,6 +1771,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 2, @@ -1762,6 +1781,7 @@ mod message_processor_impl { ( ROUTER_ID_3, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 1, }), ), @@ -1802,6 +1822,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 6, @@ -1825,6 +1846,7 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 3, }), ), @@ -1846,6 +1868,7 @@ mod message_processor_impl { ( ROUTER_ID_3, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 3, }), ), @@ -1864,6 +1887,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 4, @@ -1872,6 +1896,7 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 1, }), ), @@ -1891,6 +1916,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 4, @@ -1899,6 +1925,7 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 1, }), ), @@ -1918,6 +1945,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 2, @@ -1926,6 +1954,7 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 2, }), ), @@ -1945,6 +1974,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 2, @@ -1954,6 +1984,7 @@ mod message_processor_impl { ( ROUTER_ID_3, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 2, }), ), @@ -1972,6 +2003,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 2, @@ -1981,6 +2013,7 @@ mod message_processor_impl { ( ROUTER_ID_3, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 2, }), ), @@ -1999,6 +2032,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 2, @@ -2008,6 +2042,7 @@ mod message_processor_impl { ( ROUTER_ID_3, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 2, }), ), @@ -2026,6 +2061,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 2, @@ -2034,6 +2070,7 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 2, }), ), @@ -2053,6 +2090,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 2, @@ -2061,6 +2099,7 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 2, }), ), @@ -2080,6 +2119,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 4, @@ -2089,6 +2129,7 @@ mod message_processor_impl { ( ROUTER_ID_3, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 1, }), ), @@ -2107,6 +2148,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 4, @@ -2115,6 +2157,7 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 1, }), ), @@ -2134,6 +2177,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 4, @@ -2143,6 +2187,7 @@ mod message_processor_impl { ( ROUTER_ID_3, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 1, }), ), @@ -2161,6 +2206,7 @@ mod message_processor_impl { ( ROUTER_ID_1, Some(InboundEntry::::Message { + session_id: TEST_SESSION_ID, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 4, @@ -2170,6 +2216,7 @@ mod message_processor_impl { ( ROUTER_ID_3, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 1, }), ), @@ -2279,12 +2326,14 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 2, }), ), ( ROUTER_ID_3, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 1, }), ), @@ -2304,12 +2353,14 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 2, }), ), ( ROUTER_ID_3, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 1, }), ), @@ -2329,12 +2380,14 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 1, }), ), ( ROUTER_ID_3, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 2, }), ), @@ -2354,12 +2407,14 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 1, }), ), ( ROUTER_ID_3, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 2, }), ), @@ -2379,12 +2434,14 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 2, }), ), ( ROUTER_ID_3, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 1, }), ), @@ -2404,12 +2461,14 @@ mod message_processor_impl { ( ROUTER_ID_2, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 1, }), ), ( ROUTER_ID_3, Some(InboundEntry::::Proof { + session_id: TEST_SESSION_ID, current_count: 2, }), ), @@ -2435,10 +2494,8 @@ mod message_processor_impl { new_test_ext().execute_with(|| { let domain_address = DomainAddress::EVM(1, [1; 20]); - Routers::::set(Some( - BoundedVec::try_from(vec![ROUTER_ID_1.clone()]).unwrap(), - )); - SessionIdStore::::set(Some(1)); + Routers::::set(BoundedVec::try_from(vec![ROUTER_ID_1.clone()]).unwrap()); + SessionIdStore::::set(1); let message = Message::Simple; let gateway_message = GatewayMessage::Inbound { @@ -2558,7 +2615,7 @@ mod batches { // Ok Batched assert_ok!(LiquidityPoolsGateway::handle(USER, DOMAIN, Message::Simple)); - Routers::::set(Some(BoundedVec::try_from(vec![ROUTER_ID_1]).unwrap())); + Routers::::set(BoundedVec::try_from(vec![ROUTER_ID_1]).unwrap()); // Not batched, it belongs to OTHER assert_ok!(LiquidityPoolsGateway::handle( @@ -2611,7 +2668,7 @@ mod batches { let router_id_1 = ROUTER_ID_1; - Routers::::set(Some(BoundedVec::try_from(vec![router_id_1]).unwrap())); + Routers::::set(BoundedVec::try_from(vec![router_id_1]).unwrap()); assert_ok!(LiquidityPoolsGateway::end_batch_message( RuntimeOrigin::signed(USER), @@ -2654,8 +2711,8 @@ mod batches { let router_id_1 = ROUTER_ID_1; - Routers::::set(Some(BoundedVec::try_from(vec![router_id_1]).unwrap())); - SessionIdStore::::set(Some(1)); + Routers::::set(BoundedVec::try_from(vec![router_id_1]).unwrap()); + SessionIdStore::::set(1); let handler = MockLiquidityPools::mock_handle(|_, _| Ok(())); @@ -2708,8 +2765,8 @@ mod batches { let router_id_1 = ROUTER_ID_1; - Routers::::set(Some(BoundedVec::try_from(vec![router_id_1]).unwrap())); - SessionIdStore::::set(Some(1)); + Routers::::set(BoundedVec::try_from(vec![router_id_1]).unwrap()); + SessionIdStore::::set(1); let counter = Arc::new(AtomicU32::new(0)); @@ -2741,15 +2798,14 @@ mod execute_message_recovery { new_test_ext().execute_with(|| { let session_id = 1; - Routers::::set(Some( - BoundedVec::try_from(vec![ROUTER_ID_1, ROUTER_ID_2]).unwrap(), - )); - SessionIdStore::::set(Some(session_id)); + Routers::::set(BoundedVec::try_from(vec![ROUTER_ID_1, ROUTER_ID_2]).unwrap()); + SessionIdStore::::set(session_id); PendingInboundEntries::::insert( - session_id, - (MESSAGE_PROOF, ROUTER_ID_1), + MESSAGE_PROOF, + ROUTER_ID_1, InboundEntry::::Message { + session_id, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 1, @@ -2778,17 +2834,8 @@ mod execute_message_recovery { assert_eq!(handler.times(), 1); - assert!(PendingInboundEntries::::get( - session_id, - (MESSAGE_PROOF, ROUTER_ID_1) - ) - .is_none()); - - assert!(PendingInboundEntries::::get( - session_id, - (MESSAGE_PROOF, ROUTER_ID_2) - ) - .is_none()); + assert!(PendingInboundEntries::::get(MESSAGE_PROOF, ROUTER_ID_1).is_none()); + assert!(PendingInboundEntries::::get(MESSAGE_PROOF, ROUTER_ID_2).is_none()); }); } @@ -2797,15 +2844,16 @@ mod execute_message_recovery { new_test_ext().execute_with(|| { let session_id = 1; - Routers::::set(Some( + Routers::::set( BoundedVec::try_from(vec![ROUTER_ID_1, ROUTER_ID_2, ROUTER_ID_3]).unwrap(), - )); - SessionIdStore::::set(Some(session_id)); + ); + SessionIdStore::::set(session_id); PendingInboundEntries::::insert( - session_id, - (MESSAGE_PROOF, ROUTER_ID_1), + MESSAGE_PROOF, + ROUTER_ID_1, InboundEntry::::Message { + session_id, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 2, @@ -2825,26 +2873,27 @@ mod execute_message_recovery { }); assert_eq!( - PendingInboundEntries::::get(session_id, (MESSAGE_PROOF, ROUTER_ID_1)), + PendingInboundEntries::::get(MESSAGE_PROOF, ROUTER_ID_1), Some(InboundEntry::::Message { + session_id, domain_address: TEST_DOMAIN_ADDRESS, message: Message::Simple, expected_proof_count: 2, }) ); assert_eq!( - PendingInboundEntries::::get(session_id, (MESSAGE_PROOF, ROUTER_ID_2)), - Some(InboundEntry::::Proof { current_count: 1 }) + PendingInboundEntries::::get(MESSAGE_PROOF, ROUTER_ID_2), + Some(InboundEntry::::Proof { + session_id, + current_count: 1 + }) ); - assert!( - PendingInboundEntries::::get(session_id, (MESSAGE_PROOF, ROUTER_ID_3)) - .is_none() - ) + assert!(PendingInboundEntries::::get(MESSAGE_PROOF, ROUTER_ID_3).is_none()) }); } #[test] - fn routers_not_found() { + fn not_enough_routers_for_domain() { new_test_ext().execute_with(|| { assert_noop!( LiquidityPoolsGateway::execute_message_recovery( @@ -2853,15 +2902,10 @@ mod execute_message_recovery { MESSAGE_PROOF, ROUTER_ID_1, ), - Error::::RoutersNotFound + Error::::NotEnoughRoutersForDomain ); - }); - } - #[test] - fn session_id_not_found() { - new_test_ext().execute_with(|| { - Routers::::set(Some(BoundedVec::try_from(vec![ROUTER_ID_1]).unwrap())); + Routers::::set(BoundedVec::try_from(vec![ROUTER_ID_1]).unwrap()); assert_noop!( LiquidityPoolsGateway::execute_message_recovery( @@ -2870,7 +2914,7 @@ mod execute_message_recovery { MESSAGE_PROOF, ROUTER_ID_1, ), - Error::::SessionIdNotFound + Error::::NotEnoughRoutersForDomain ); }); } @@ -2878,8 +2922,8 @@ mod execute_message_recovery { #[test] fn unknown_router() { new_test_ext().execute_with(|| { - Routers::::set(Some(BoundedVec::try_from(vec![ROUTER_ID_1]).unwrap())); - SessionIdStore::::set(Some(1)); + Routers::::set(BoundedVec::try_from(vec![ROUTER_ID_1]).unwrap()); + SessionIdStore::::set(1); assert_noop!( LiquidityPoolsGateway::execute_message_recovery( @@ -2896,15 +2940,15 @@ mod execute_message_recovery { #[test] fn proof_count_overflow() { new_test_ext().execute_with(|| { - let router_id = ROUTER_ID_1; let session_id = 1; - Routers::::set(Some(BoundedVec::try_from(vec![router_id.clone()]).unwrap())); - SessionIdStore::::set(Some(session_id)); + Routers::::set(BoundedVec::try_from(vec![ROUTER_ID_1, ROUTER_ID_2]).unwrap()); + SessionIdStore::::set(session_id); PendingInboundEntries::::insert( - session_id, - (MESSAGE_PROOF, router_id.clone()), + MESSAGE_PROOF, + ROUTER_ID_2, InboundEntry::::Proof { + session_id, current_count: u32::MAX, }, ); @@ -2914,7 +2958,7 @@ mod execute_message_recovery { RuntimeOrigin::root(), TEST_DOMAIN_ADDRESS, MESSAGE_PROOF, - router_id + ROUTER_ID_2 ), Arithmetic(Overflow) ); @@ -2925,15 +2969,15 @@ mod execute_message_recovery { fn expected_message_proof_type() { new_test_ext().execute_with(|| { let domain_address = TEST_DOMAIN_ADDRESS; - let router_id = ROUTER_ID_1; let session_id = 1; - Routers::::set(Some(BoundedVec::try_from(vec![router_id.clone()]).unwrap())); - SessionIdStore::::set(Some(session_id)); + Routers::::set(BoundedVec::try_from(vec![ROUTER_ID_1, ROUTER_ID_2]).unwrap()); + SessionIdStore::::set(session_id); PendingInboundEntries::::insert( - session_id, - (MESSAGE_PROOF, router_id.clone()), + MESSAGE_PROOF, + ROUTER_ID_2, InboundEntry::::Message { + session_id, domain_address: domain_address.clone(), message: Message::Simple, expected_proof_count: 2, @@ -2945,7 +2989,7 @@ mod execute_message_recovery { RuntimeOrigin::root(), TEST_DOMAIN_ADDRESS, MESSAGE_PROOF, - router_id + ROUTER_ID_2 ), Error::::ExpectedMessageProofType );