From 597eb77218161805736430cb40c399d16f03fc8f Mon Sep 17 00:00:00 2001 From: Cosmin Damian <17934949+cdamian@users.noreply.github.com> Date: Wed, 13 Sep 2023 11:00:08 +0300 Subject: [PATCH] routers: Drop LP contract call from Axelar message (#1545) * routers: Drop LP contract call from Axelar message * development: Update spec version to 1024 * routers: Use correct formatting for H160 addresses --- Cargo.lock | 2 +- .../routers/src/routers/axelar_evm.rs | 47 ++++--------------- runtime/development/Cargo.toml | 2 +- runtime/development/src/lib.rs | 2 +- 4 files changed, 11 insertions(+), 42 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0e05e881ab..99c5985b4a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2682,7 +2682,7 @@ dependencies = [ [[package]] name = "development-runtime" -version = "0.10.23" +version = "0.10.24" dependencies = [ "axelar-gateway-precompile", "cfg-primitives", diff --git a/pallets/liquidity-pools-gateway/routers/src/routers/axelar_evm.rs b/pallets/liquidity-pools-gateway/routers/src/routers/axelar_evm.rs index a5912166fd..6e7e7bfc9b 100644 --- a/pallets/liquidity-pools-gateway/routers/src/routers/axelar_evm.rs +++ b/pallets/liquidity-pools-gateway/routers/src/routers/axelar_evm.rs @@ -15,10 +15,7 @@ use ethabi::{Contract, Function, Param, ParamType, Token}; use frame_support::dispatch::{DispatchError, DispatchResult}; use frame_system::pallet_prelude::OriginFor; use scale_info::{ - prelude::{ - format, - string::{String, ToString}, - }, + prelude::{format, string::String}, TypeInfo, }; use sp_core::{bounded::BoundedVec, ConstU32, H160}; @@ -27,7 +24,7 @@ use sp_std::{collections::btree_map::BTreeMap, marker::PhantomData, vec, vec::Ve use crate::{ AccountIdOf, EVMRouter, MessageOf, AXELAR_DESTINATION_CHAIN_PARAM, AXELAR_DESTINATION_CONTRACT_ADDRESS_PARAM, AXELAR_FUNCTION_NAME, AXELAR_PAYLOAD_PARAM, - FUNCTION_NAME, MAX_AXELAR_EVM_CHAIN_SIZE, MESSAGE_PARAM, + MAX_AXELAR_EVM_CHAIN_SIZE, }; /// The router used for executing the LiquidityPools contract via Axelar. @@ -77,8 +74,8 @@ where } /// Encodes the provided message into the format required for submitting it -/// to the Axelar contract which in turn submits it to the LiquidityPools -/// contract. +/// to the Axelar contract which in turn calls the LiquidityPools +/// contract with the serialized LP message as `payload`. /// /// Axelar contract call: /// @@ -90,36 +87,6 @@ pub(crate) fn get_axelar_encoded_msg( target_chain: Vec, target_contract: H160, ) -> Result, &'static str> { - let target_chain_string = - String::from_utf8(target_chain).map_err(|_| "target chain conversion error")?; - - #[allow(deprecated)] - let encoded_liquidity_pools_contract = Contract { - constructor: None, - functions: BTreeMap::>::from([( - FUNCTION_NAME.to_string(), - vec![Function { - name: FUNCTION_NAME.into(), - inputs: vec![Param { - name: MESSAGE_PARAM.into(), - kind: ParamType::Bytes, - internal_type: None, - }], - outputs: vec![], - constant: false, - state_mutability: Default::default(), - }], - )]), - events: Default::default(), - errors: Default::default(), - receive: false, - fallback: false, - } - .function(FUNCTION_NAME) - .map_err(|_| "cannot retrieve LiquidityPools contract function")? - .encode_input(&[Token::Bytes(serialized_msg)]) - .map_err(|_| "cannot encode input for LiquidityPools contract function")?; - #[allow(deprecated)] let encoded_axelar_contract = Contract { constructor: None, @@ -157,13 +124,15 @@ pub(crate) fn get_axelar_encoded_msg( .function(AXELAR_FUNCTION_NAME) .map_err(|_| "cannot retrieve Axelar contract function")? .encode_input(&[ - Token::String(target_chain_string), + Token::String( + String::from_utf8(target_chain).map_err(|_| "target chain conversion error")?, + ), // Ensure that the target contract is correctly converted to hex. // // The `to_string` method on the H160 is returning a string containing an ellipsis, such // as: 0x1234…7890 Token::String(format!("0x{}", hex::encode(target_contract.0))), - Token::Bytes(encoded_liquidity_pools_contract), + Token::Bytes(serialized_msg), ]) .map_err(|_| "cannot encode input for Axelar contract function")?; diff --git a/runtime/development/Cargo.toml b/runtime/development/Cargo.toml index 775a798b35..25b0d79658 100644 --- a/runtime/development/Cargo.toml +++ b/runtime/development/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "development-runtime" -version = "0.10.23" +version = "0.10.24" authors = ["Centrifuge "] edition = "2021" build = "build.rs" diff --git a/runtime/development/src/lib.rs b/runtime/development/src/lib.rs index 145a8dfe3f..7f57cd2725 100644 --- a/runtime/development/src/lib.rs +++ b/runtime/development/src/lib.rs @@ -138,7 +138,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("centrifuge-devel"), impl_name: create_runtime_str!("centrifuge-devel"), authoring_version: 1, - spec_version: 1023, + spec_version: 1024, impl_version: 1, #[cfg(not(feature = "disable-runtime-api"))] apis: RUNTIME_API_VERSIONS,