Skip to content

Commit

Permalink
routers: Drop LP contract call from Axelar message (#1545)
Browse files Browse the repository at this point in the history
* routers: Drop LP contract call from Axelar message

* development: Update spec version to 1024

* routers: Use correct formatting for H160 addresses
  • Loading branch information
cdamian authored Sep 13, 2023
1 parent c779524 commit 597eb77
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 42 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

47 changes: 8 additions & 39 deletions pallets/liquidity-pools-gateway/routers/src/routers/axelar_evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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.
Expand Down Expand Up @@ -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:
/// <https://github.com/axelarnetwork/axelar-cgp-solidity/blob/v4.3.2/contracts/AxelarGateway.sol#L78>
Expand All @@ -90,36 +87,6 @@ pub(crate) fn get_axelar_encoded_msg(
target_chain: Vec<u8>,
target_contract: H160,
) -> Result<Vec<u8>, &'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::<String, Vec<Function>>::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,
Expand Down Expand Up @@ -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")?;

Expand Down
2 changes: 1 addition & 1 deletion runtime/development/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "development-runtime"
version = "0.10.23"
version = "0.10.24"
authors = ["Centrifuge <[email protected]>"]
edition = "2021"
build = "build.rs"
Expand Down
2 changes: 1 addition & 1 deletion runtime/development/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 597eb77

Please sign in to comment.