Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/lp v2 gateway multi router #1961

Merged
merged 38 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
446e29a
wip
cdamian Aug 8, 2024
38fed75
lp-gateway: Add router hash for inbound messages, extrinsic to set in…
cdamian Aug 8, 2024
6cad799
lp-gateway: Add router hash for inbound messages, extrinsic to set in…
cdamian Aug 8, 2024
52f60e3
lp-gateway: Use router hashes for inbound, use session ID, update inb…
cdamian Aug 9, 2024
5226748
lp-gateway: Add and use InboundProcessingInfo
cdamian Aug 9, 2024
656e392
lp-gateway: Unit tests WIP
cdamian Aug 9, 2024
3584953
lp-gateway: Unit tests WIP 2
cdamian Aug 10, 2024
2dda7f0
docs: Improve comments
cdamian Aug 10, 2024
02340e3
lp-gateway: Move message processing logic to a new file
cdamian Aug 10, 2024
57a10a0
lp-gateway: Merge inbound/outbound routers extrinsics into one, add l…
cdamian Aug 12, 2024
d1d032e
lp-gateway: Unit tests WIP
cdamian Aug 12, 2024
1215fe0
lp-gateway: Add extrinsic for executing message recovery
cdamian Aug 12, 2024
743d153
rebase: WIP
cdamian Aug 13, 2024
e04c300
Don't use domain when storing routers (#1962)
cdamian Aug 13, 2024
a0115d7
wip
cdamian Aug 13, 2024
a4dfd56
lp-gateway: Unit test WIP
cdamian Aug 13, 2024
5a10a02
lp-gateway: Rename RouterSupport to RouterProvider, add separate enti…
cdamian Aug 13, 2024
8a1230f
lp-gateway: Add more asserts in unit tests
cdamian Aug 13, 2024
58c5d9b
lp-gateway: Attempt to execute message during recovery
cdamian Aug 13, 2024
207c43f
lp-gateway: Remove extra constraints from SessionId
cdamian Aug 14, 2024
a5e943f
lp-gateway: Drop session ID invalidation (#1965)
cdamian Aug 14, 2024
877dc51
lp-gateway: Add more unit tests
cdamian Aug 14, 2024
5739aef
lp-gateway: Move InboundEntry logic to implementation
cdamian Aug 14, 2024
5d21ccb
lp-gateway: Use safe math
cdamian Aug 14, 2024
ab28067
lp-gateway: Add more unit tests
cdamian Aug 14, 2024
c950614
checks: Fix clippy, taplo, formatting
cdamian Aug 15, 2024
e767481
review: Remove mock-builder dep, rename LP encoding proof methods
cdamian Aug 15, 2024
8af5c43
lp-gateway: Remove Default impls for RouterId and GatewayMessage
cdamian Aug 15, 2024
9293341
lp-gateway: Allow empty list of routers
cdamian Aug 15, 2024
c510b9d
lp-gateway: Drop InboundProcessingInfo
cdamian Aug 15, 2024
6c45d5b
lp-gateway: Rename LP encoding methods to get_proof and to_proof_message
cdamian Aug 15, 2024
88bdad7
lp-gateway: Move outbound processing logic back to pallet
cdamian Aug 15, 2024
9f6d684
review: Small fixes
cdamian Aug 15, 2024
d990f5f
lp-gateway: Add comment for post voting dispatch error case
cdamian Aug 15, 2024
603e24c
lp-gatway: Drop session ID check in create_post_voting_entry
cdamian Aug 15, 2024
584e7e8
lp: Remove unused import
cdamian Aug 15, 2024
e59f1ed
integration-tests: Register routers during setup (#1968)
cdamian Aug 15, 2024
89ffd0e
integration-tests: Set routers in all setup funcs and tests
cdamian Aug 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ impl-trait-for-tuples = "0.2.2"
num-traits = { version = "0.2.17", default-features = false }
num_enum = { version = "0.5.3", default-features = false }
chrono = { version = "0.4", default-features = false }
itertools = { version = "0.13.0", default-features = false }

# Cumulus
cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" }
Expand Down
8 changes: 5 additions & 3 deletions libs/mocks/src/liquidity_pools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pub mod pallet {
use cfg_traits::liquidity_pools::InboundMessageHandler;
use frame_support::pallet_prelude::*;
use mock_builder::{execute_call, register_call};
use mock_builder::{execute_call, register_call, CallHandler};

#[pallet::config]
pub trait Config: frame_system::Config {
Expand All @@ -17,8 +17,10 @@ pub mod pallet {
type CallIds<T: Config> = StorageMap<_, _, String, mock_builder::CallId>;

impl<T: Config> Pallet<T> {
pub fn mock_handle(f: impl Fn(T::DomainAddress, T::Message) -> DispatchResult + 'static) {
register_call!(move |(sender, msg)| f(sender, msg));
pub fn mock_handle(
f: impl Fn(T::DomainAddress, T::Message) -> DispatchResult + 'static,
) -> CallHandler {
register_call!(move |(sender, msg)| f(sender, msg))
}
}

Expand Down
6 changes: 3 additions & 3 deletions libs/mocks/src/router_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pub mod pallet {
use cfg_traits::liquidity_pools::{MessageReceiver, MessageSender};
use frame_support::pallet_prelude::*;
use mock_builder::{execute_call, register_call};
use mock_builder::{execute_call, register_call, CallHandler};

#[pallet::config]
pub trait Config: frame_system::Config {
Expand All @@ -25,8 +25,8 @@ pub mod pallet {

pub fn mock_send(
f: impl Fn(T::Middleware, T::Origin, Vec<u8>) -> DispatchResult + 'static,
) {
register_call!(move |(a, b, c)| f(a, b, c));
) -> CallHandler {
register_call!(move |(a, b, c)| f(a, b, c))
}
}

Expand Down
3 changes: 3 additions & 0 deletions libs/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ pub mod types {

/// The type for LP gateway message nonces.
pub type LPGatewayQueueMessageNonce = u64;

/// The type for LP gateway session IDs.
pub type LPGatewaySessionId = u64;
}

/// Common constants for all runtimes
Expand Down
15 changes: 13 additions & 2 deletions libs/traits/src/liquidity_pools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ use frame_support::{dispatch::DispatchResult, weights::Weight};
use sp_runtime::DispatchError;
use sp_std::vec::Vec;

pub type Proof = [u8; 32];

/// An encoding & decoding trait for the purpose of meeting the
/// LiquidityPools General Message Passing Format
pub trait LPEncoding: Sized {
Expand All @@ -31,11 +33,20 @@ pub trait LPEncoding: Sized {
/// Creates an empty message.
/// It's the identity message for composing messages with pack_with
fn empty() -> Self;

/// Retrieves the message proof hash, if the message is a proof type.
fn get_proof(&self) -> Option<Proof>;

/// Converts the message into a message proof type.
fn to_proof_message(&self) -> Self;
}

pub trait RouterSupport<Domain>: Sized {
pub trait RouterProvider<Domain>: Sized {
/// The router identifier.
type RouterId;

/// Returns a list of routers supported for the given domain.
fn for_domain(domain: Domain) -> Vec<Self>;
fn routers_for_domain(domain: Domain) -> Vec<Self::RouterId>;
}

/// The behavior of an entity that can send messages
Expand Down
6 changes: 6 additions & 0 deletions pallets/axelar-router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ pub enum AxelarId {
Evm(EVMChainId),
}

impl Default for AxelarId {
fn default() -> Self {
Self::Evm(1)
}
}

/// Configuration for outbound messages though axelar
#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)]
pub struct AxelarConfig {
Expand Down
4 changes: 4 additions & 0 deletions pallets/liquidity-pools-gateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ hex = { workspace = true }
orml-traits = { workspace = true }
parity-scale-codec = { workspace = true }
scale-info = { workspace = true }
sp-arithmetic = { workspace = true }
sp-core = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }
Expand All @@ -34,6 +35,8 @@ cfg-utils = { workspace = true }

[dev-dependencies]
cfg-mocks = { workspace = true, default-features = true }
itertools = { workspace = true, default-features = true }
lazy_static = { workspace = true, default-features = true }
sp-io = { workspace = true, default-features = true }

[features]
Expand All @@ -53,6 +56,7 @@ std = [
"cfg-utils/std",
"hex/std",
"cfg-primitives/std",
"sp-arithmetic/std",
]
try-runtime = [
"cfg-traits/try-runtime",
Expand Down
2 changes: 1 addition & 1 deletion pallets/liquidity-pools-gateway/queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub mod pallet {
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;

/// The message type.
type Message: Clone + Debug + PartialEq + MaxEncodedLen + TypeInfo + FullCodec + Default;
type Message: Clone + Debug + PartialEq + MaxEncodedLen + TypeInfo + FullCodec;

/// Type used for message identification.
type MessageNonce: Parameter
Expand Down
Loading
Loading