From d3b24c51ab41a6e26516bdeedb51ca0ef89d9339 Mon Sep 17 00:00:00 2001 From: nhpd Date: Wed, 7 Aug 2024 14:16:19 +0400 Subject: [PATCH 1/3] feat: use neutron with ordering in MsgRegisterICA --- .../neutron_interchain_txs/src/contract.rs | 17 ++++++++++------- contracts/neutron_interchain_txs/src/msg.rs | 2 ++ packages/neutron-sdk/src/bindings/msg.rs | 17 ++++++++++++++++- .../neutron-sdk/src/proto_types/NEUTRON_COMMIT | 2 +- .../src/proto_types/ibc/core/channel/v1.rs | 8 ++++---- .../src/proto_types/neutron/interchaintxs/v1.rs | 9 +++++++++ proto-build/src/main.rs | 2 +- 7 files changed, 43 insertions(+), 14 deletions(-) diff --git a/contracts/neutron_interchain_txs/src/contract.rs b/contracts/neutron_interchain_txs/src/contract.rs index 14ac5056..a23cb4b5 100644 --- a/contracts/neutron_interchain_txs/src/contract.rs +++ b/contracts/neutron_interchain_txs/src/contract.rs @@ -12,7 +12,12 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; -use neutron_sdk::bindings::msg::IbcFee; +use crate::storage::{ + add_error_to_queue, read_errors_from_queue, read_reply_payload, read_sudo_payload, + save_reply_payload, save_sudo_payload, AcknowledgementResult, SudoPayload, + ACKNOWLEDGEMENT_RESULTS, INTERCHAIN_ACCOUNTS, SUDO_PAYLOAD_REPLY_ID, +}; +use neutron_sdk::bindings::msg::{ChannelOrdering, IbcFee}; use neutron_sdk::proto_types::neutron::interchaintxs::v1::MsgSubmitTxResponse; use neutron_sdk::{ bindings::{ @@ -27,12 +32,6 @@ use neutron_sdk::{ NeutronError, NeutronResult, }; -use crate::storage::{ - add_error_to_queue, read_errors_from_queue, read_reply_payload, read_sudo_payload, - save_reply_payload, save_sudo_payload, AcknowledgementResult, SudoPayload, - ACKNOWLEDGEMENT_RESULTS, INTERCHAIN_ACCOUNTS, SUDO_PAYLOAD_REPLY_ID, -}; - // Default timeout for SubmitTX is two weeks const DEFAULT_TIMEOUT_SECONDS: u64 = 60 * 60 * 24 * 7 * 2; const FEE_DENOM: &str = "untrn"; @@ -77,12 +76,14 @@ pub fn execute( connection_id, interchain_account_id, register_fee, + ordering, } => execute_register_ica( deps, env, connection_id, interchain_account_id, register_fee, + ordering, ), ExecuteMsg::Delegate { validator, @@ -198,11 +199,13 @@ fn execute_register_ica( connection_id: String, interchain_account_id: String, register_fee: Vec, + ordering: Option, ) -> NeutronResult> { let register = NeutronMsg::register_interchain_account( connection_id, interchain_account_id.clone(), Some(register_fee), + ordering, ); let key = get_port_id(env.contract.address.as_str(), &interchain_account_id); // we are saving empty data here because we handle response of registering ICA in sudo_open_ack method diff --git a/contracts/neutron_interchain_txs/src/msg.rs b/contracts/neutron_interchain_txs/src/msg.rs index e75bffe7..d4f44823 100644 --- a/contracts/neutron_interchain_txs/src/msg.rs +++ b/contracts/neutron_interchain_txs/src/msg.rs @@ -1,4 +1,5 @@ use cosmwasm_std::Coin; +use neutron_sdk::bindings::msg::ChannelOrdering; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -36,6 +37,7 @@ pub enum ExecuteMsg { connection_id: String, interchain_account_id: String, register_fee: Vec, + ordering: Option, }, Delegate { interchain_account_id: String, diff --git a/packages/neutron-sdk/src/bindings/msg.rs b/packages/neutron-sdk/src/bindings/msg.rs index 5b8daf9c..278e9528 100644 --- a/packages/neutron-sdk/src/bindings/msg.rs +++ b/packages/neutron-sdk/src/bindings/msg.rs @@ -27,6 +27,14 @@ pub struct IbcFee { pub timeout_fee: Vec, } +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[serde(rename_all = "SCREAMING_SNAKE_CASE")] +pub enum ChannelOrdering { + None, + OrderOrdered, + OrderUnordered, +} + #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] #[serde(rename_all = "snake_case")] /// A number of Custom messages that can call into the Neutron bindings. @@ -42,6 +50,10 @@ pub enum NeutronMsg { /// **register_fee** is a fees required to be payed to register interchain account register_fee: Option>, + + /// **ordering** is an order of channel. Can be ordered or unordered. + /// Set to ordered if not specified. + ordering: Option, }, /// SubmitTx starts the process of executing any Cosmos-SDK *msgs* on remote chain. @@ -88,7 +100,7 @@ pub enum NeutronMsg { /// **query_id** is the ID of the query we want to update. query_id: u64, - /// **new_keys** is the new query keys to retrive. + /// **new_keys** is the new query keys to retrieve. new_keys: Option>, /// **new_update_period** is a new update period of the query. @@ -237,15 +249,18 @@ impl NeutronMsg { /// Basic helper to define a register interchain account message: /// * **connection_id** is an IBC connection identifier between Neutron and remote chain; /// * **interchain_account_id** is an identifier of your new interchain account. Can be any string. + /// * **ordering** is an ordering of ICA channel. Set to ORDERED if not specified pub fn register_interchain_account( connection_id: String, interchain_account_id: String, register_fee: Option>, + ordering: Option, ) -> Self { NeutronMsg::RegisterInterchainAccount { connection_id, interchain_account_id, register_fee, + ordering, } } diff --git a/packages/neutron-sdk/src/proto_types/NEUTRON_COMMIT b/packages/neutron-sdk/src/proto_types/NEUTRON_COMMIT index 5469c48c..007a1cae 100644 --- a/packages/neutron-sdk/src/proto_types/NEUTRON_COMMIT +++ b/packages/neutron-sdk/src/proto_types/NEUTRON_COMMIT @@ -1 +1 @@ -v4.1.0 \ No newline at end of file +ba1b1d6dc91370d81e7125962e02aee01274eac \ No newline at end of file diff --git a/packages/neutron-sdk/src/proto_types/ibc/core/channel/v1.rs b/packages/neutron-sdk/src/proto_types/ibc/core/channel/v1.rs index 5b5f0c9b..3802ad84 100644 --- a/packages/neutron-sdk/src/proto_types/ibc/core/channel/v1.rs +++ b/packages/neutron-sdk/src/proto_types/ibc/core/channel/v1.rs @@ -415,16 +415,16 @@ impl Order { pub fn as_str_name(&self) -> &'static str { match self { Order::NoneUnspecified => "ORDER_NONE_UNSPECIFIED", - Order::Unordered => "ORDER_UNORDERED", - Order::Ordered => "ORDER_ORDERED", + Order::Unordered => "OrderUnordered", + Order::Ordered => "OrderOrdered", } } /// Creates an enum from field names used in the ProtoBuf definition. pub fn from_str_name(value: &str) -> ::core::option::Option { match value { "ORDER_NONE_UNSPECIFIED" => Some(Self::NoneUnspecified), - "ORDER_UNORDERED" => Some(Self::Unordered), - "ORDER_ORDERED" => Some(Self::Ordered), + "OrderUnordered" => Some(Self::Unordered), + "OrderOrdered" => Some(Self::Ordered), _ => None, } } diff --git a/packages/neutron-sdk/src/proto_types/neutron/interchaintxs/v1.rs b/packages/neutron-sdk/src/proto_types/neutron/interchaintxs/v1.rs index f34f90ca..63d5b3b3 100644 --- a/packages/neutron-sdk/src/proto_types/neutron/interchaintxs/v1.rs +++ b/packages/neutron-sdk/src/proto_types/neutron/interchaintxs/v1.rs @@ -151,6 +151,15 @@ pub struct MsgRegisterInterchainAccount { pub interchain_account_id: ::prost::alloc::string::String, #[prost(message, repeated, tag = "4")] pub register_fee: ::prost::alloc::vec::Vec, + #[prost( + enumeration = "super::super::super::ibc::core::channel::v1::Order", + tag = "5" + )] + #[serde( + serialize_with = "crate::serde::as_str::serialize", + deserialize_with = "crate::serde::as_str::deserialize" + )] + pub ordering: i32, } /// MsgRegisterInterchainAccountResponse is the response type for /// MsgRegisterInterchainAccount. diff --git a/proto-build/src/main.rs b/proto-build/src/main.rs index 52f00d8c..aef0f71c 100644 --- a/proto-build/src/main.rs +++ b/proto-build/src/main.rs @@ -23,7 +23,7 @@ const SLINKY_REPO: &str = "https://github.com/skip-mev/slinky.git"; const COSMOS_SDK_REV: &str = "v0.50.8-neutron"; /// The Neutron commit or tag to be cloned and used to build the proto files -const NEUTRON_REV: &str = "v4.1.0"; +const NEUTRON_REV: &str = "ba1b1d6dc91370d81e7125962e02aee01274eac"; /// The wasmd commit or tag to be cloned and used to build the proto files const WASMD_REV: &str = "v0.51.0"; From 3d71caa8a27c0cb8b38661efeb9bb36ed4e33920 Mon Sep 17 00:00:00 2001 From: nhpd Date: Fri, 30 Aug 2024 17:51:25 +0400 Subject: [PATCH 2/3] remove None ordering to avoid misguiding the user - it would lead to unordered channel created --- packages/neutron-sdk/src/bindings/msg.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/neutron-sdk/src/bindings/msg.rs b/packages/neutron-sdk/src/bindings/msg.rs index 916e3e3d..ec9ee5a8 100644 --- a/packages/neutron-sdk/src/bindings/msg.rs +++ b/packages/neutron-sdk/src/bindings/msg.rs @@ -30,7 +30,6 @@ pub struct IbcFee { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] pub enum ChannelOrdering { - None, OrderOrdered, OrderUnordered, } From d99b7c21d16de9d8967f2501a95980d52cc59df5 Mon Sep 17 00:00:00 2001 From: nhpd Date: Mon, 2 Sep 2024 17:24:08 +0400 Subject: [PATCH 3/3] regen types --- .../neutron-sdk/src/proto_types/ibc/core/channel/v1.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/neutron-sdk/src/proto_types/ibc/core/channel/v1.rs b/packages/neutron-sdk/src/proto_types/ibc/core/channel/v1.rs index 3802ad84..5b5f0c9b 100644 --- a/packages/neutron-sdk/src/proto_types/ibc/core/channel/v1.rs +++ b/packages/neutron-sdk/src/proto_types/ibc/core/channel/v1.rs @@ -415,16 +415,16 @@ impl Order { pub fn as_str_name(&self) -> &'static str { match self { Order::NoneUnspecified => "ORDER_NONE_UNSPECIFIED", - Order::Unordered => "OrderUnordered", - Order::Ordered => "OrderOrdered", + Order::Unordered => "ORDER_UNORDERED", + Order::Ordered => "ORDER_ORDERED", } } /// Creates an enum from field names used in the ProtoBuf definition. pub fn from_str_name(value: &str) -> ::core::option::Option { match value { "ORDER_NONE_UNSPECIFIED" => Some(Self::NoneUnspecified), - "OrderUnordered" => Some(Self::Unordered), - "OrderOrdered" => Some(Self::Ordered), + "ORDER_UNORDERED" => Some(Self::Unordered), + "ORDER_ORDERED" => Some(Self::Ordered), _ => None, } }