From 5a42afb70250109271dc7f7aa296af69b2089c9e Mon Sep 17 00:00:00 2001 From: mmsqe Date: Fri, 25 Oct 2024 16:12:59 +0800 Subject: [PATCH 1/4] Problem: no register support for payee and counterpartyPayee --- CHANGELOG.md | 6 + app/app.go | 2 +- .../contracts/contracts/TestRelayer.sol | 23 +- integration_tests/ibc_utils.py | 21 +- .../relayer/i_relayer_functions.abigen.go | 317 +++--------------- .../events/bindings/src/RelayerFunctions.sol | 15 +- x/cronos/keeper/precompiles/relayer.go | 59 +++- x/cronos/types/interfaces.go | 6 + 8 files changed, 136 insertions(+), 313 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8734ce4c5e..616ed782f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## UNRELEASED + +### Features + +* [#1665](https://github.com/crypto-org-chain/cronos/pull/1665) Support register for payee and counterpartyPayee in relayer precompile. + *Oct 24, 2024* ## v1.4.0-rc2 diff --git a/app/app.go b/app/app.go index 2ef656b0d5..14a2cad6df 100644 --- a/app/app.go +++ b/app/app.go @@ -680,7 +680,7 @@ func New( evmS, []evmkeeper.CustomContractFn{ func(_ sdk.Context, rules ethparams.Rules) vm.PrecompiledContract { - return cronosprecompiles.NewRelayerContract(app.IBCKeeper, appCodec, rules, app.Logger()) + return cronosprecompiles.NewRelayerContract(app.IBCKeeper, app.IBCFeeKeeper, appCodec, rules, app.Logger()) }, func(ctx sdk.Context, rules ethparams.Rules) vm.PrecompiledContract { return cronosprecompiles.NewIcaContract(ctx, app.ICAControllerKeeper, &app.CronosKeeper, appCodec, gasConfig) diff --git a/integration_tests/contracts/contracts/TestRelayer.sol b/integration_tests/contracts/contracts/TestRelayer.sol index 663b02e65f..c6188a3c19 100644 --- a/integration_tests/contracts/contracts/TestRelayer.sol +++ b/integration_tests/contracts/contracts/TestRelayer.sol @@ -1,13 +1,32 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.4; +import {IRelayerFunctions} from "./src/RelayerFunctions.sol"; + contract TestRelayer { - address constant relayer = 0x0000000000000000000000000000000000000065; + address constant relayerContract = 0x0000000000000000000000000000000000000065; + IRelayerFunctions relayer = IRelayerFunctions(relayerContract); + address payee; + address counterpartyPayee; function batchCall(bytes[] memory payloads) public { for (uint256 i = 0; i < payloads.length; i++) { - (bool success,) = relayer.call(payloads[i]); + (bool success,) = relayerContract.call(payloads[i]); require(success); } } + + function callRegisterPayee(string calldata portID, string calldata channelID, address relayerAddr) public returns (bool) { + require(payee == address(0) || payee == msg.sender, "register fail"); + bool result = relayer.registerPayee(portID, channelID, relayerAddr); + require(result, "call failed"); + payee = msg.sender; + } + + function callRegisterCounterpartyPayee(string calldata portID, string calldata channelID, address relayerAddr) public returns (bool) { + require(counterpartyPayee == address(0) || counterpartyPayee == msg.sender, "register fail"); + bool result = relayer.registerCounterpartyPayee(portID, channelID, relayerAddr); + require(result, "call failed"); + counterpartyPayee = msg.sender; + } } diff --git a/integration_tests/ibc_utils.py b/integration_tests/ibc_utils.py index bd88269006..478204753b 100644 --- a/integration_tests/ibc_utils.py +++ b/integration_tests/ibc_utils.py @@ -189,7 +189,8 @@ def prepare_network( tx = {"to": sender, "value": fund, "gasPrice": w3.eth.gas_price} send_transaction(w3, tx) assert w3.eth.get_balance(sender, "latest") == fund - caller = deploy_contract(w3, CONTRACTS["TestRelayer"], key=acc.key).address + contract = deploy_contract(w3, CONTRACTS["TestRelayer"], key=acc.key) + caller = contract.address assert caller == RELAYER_CALLER, caller if is_hermes: hermes = Hermes(path.with_suffix(".toml")) @@ -203,7 +204,17 @@ def prepare_network( call_rly_cmd(path, connection_only, version) if incentivized: - register_fee_payee(cronos.cosmos_cli(), chainmain.cosmos_cli()) + port_id = "transfer" + channel_id = "channel-0" + register_fee_payee( + cronos.cosmos_cli(), chainmain.cosmos_cli(), port_id, channel_id + ) + data = {"from": acc.address} + tx = contract.functions.callRegisterPayee( + port_id, channel_id, ADDRS["signer1"] + ).build_transaction(data) + receipt = send_transaction(w3, tx, acc.key) + assert receipt.status == 1, receipt port = None if is_relay: @@ -217,10 +228,10 @@ def prepare_network( wait_for_port(port) -def register_fee_payee(src_chain, dst_chain): +def register_fee_payee(src_chain, dst_chain, port_id, channel_id): rsp = dst_chain.register_counterparty_payee( - "transfer", - "channel-0", + port_id, + channel_id, dst_chain.address("relayer"), src_chain.address("signer1"), from_="relayer", diff --git a/x/cronos/events/bindings/cosmos/precompile/relayer/i_relayer_functions.abigen.go b/x/cronos/events/bindings/cosmos/precompile/relayer/i_relayer_functions.abigen.go index eb1cd85583..e7ae987b1b 100644 --- a/x/cronos/events/bindings/cosmos/precompile/relayer/i_relayer_functions.abigen.go +++ b/x/cronos/events/bindings/cosmos/precompile/relayer/i_relayer_functions.abigen.go @@ -31,7 +31,7 @@ var ( // RelayerFunctionsMetaData contains all meta data concerning the RelayerFunctions contract. var RelayerFunctionsMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"acknowledgement\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"channelCloseConfirm\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"channelCloseInit\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"channelOpenAck\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"channelOpenConfirm\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"channelOpenInit\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"channelOpenTry\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"connectionOpenAck\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"connectionOpenConfirm\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"connectionOpenInit\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"connectionOpenTry\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"createClient\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"recvPacket\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"submitMisbehaviour\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"timeout\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"timeoutOnClose\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"updateClient\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data1\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"data2\",\"type\":\"bytes\"}],\"name\":\"updateClientAndAcknowledgement\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data1\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"data2\",\"type\":\"bytes\"}],\"name\":\"updateClientAndChannelCloseConfirm\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data1\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"data2\",\"type\":\"bytes\"}],\"name\":\"updateClientAndChannelCloseInit\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data1\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"data2\",\"type\":\"bytes\"}],\"name\":\"updateClientAndChannelOpenAck\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data1\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"data2\",\"type\":\"bytes\"}],\"name\":\"updateClientAndChannelOpenConfirm\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data1\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"data2\",\"type\":\"bytes\"}],\"name\":\"updateClientAndChannelOpenInit\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data1\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"data2\",\"type\":\"bytes\"}],\"name\":\"updateClientAndChannelOpenTry\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data1\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"data2\",\"type\":\"bytes\"}],\"name\":\"updateClientAndConnectionOpenAck\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data1\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"data2\",\"type\":\"bytes\"}],\"name\":\"updateClientAndConnectionOpenConfirm\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data1\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"data2\",\"type\":\"bytes\"}],\"name\":\"updateClientAndConnectionOpenInit\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data1\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"data2\",\"type\":\"bytes\"}],\"name\":\"updateClientAndConnectionOpenTry\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data1\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"data2\",\"type\":\"bytes\"}],\"name\":\"updateClientAndRecvPacket\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data1\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"data2\",\"type\":\"bytes\"}],\"name\":\"updateClientAndTimeout\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeClient\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"acknowledgement\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"channelCloseConfirm\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"channelCloseInit\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"channelOpenAck\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"channelOpenConfirm\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"channelOpenInit\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"channelOpenTry\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"connectionOpenAck\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"connectionOpenConfirm\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"connectionOpenInit\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"connectionOpenTry\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"createClient\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"recvPacket\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"portID\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"channelID\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"relayerAddr\",\"type\":\"address\"}],\"name\":\"registerCounterpartyPayee\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"portID\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"channelID\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"relayerAddr\",\"type\":\"address\"}],\"name\":\"registerPayee\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"submitMisbehaviour\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"timeout\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"timeoutOnClose\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"updateClient\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeClient\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"}]", } // RelayerFunctionsABI is the input ABI used to generate the binding from. @@ -453,6 +453,48 @@ func (_RelayerFunctions *RelayerFunctionsTransactorSession) RecvPacket(data []by return _RelayerFunctions.Contract.RecvPacket(&_RelayerFunctions.TransactOpts, data) } +// RegisterCounterpartyPayee is a paid mutator transaction binding the contract method 0x5d3db16c. +// +// Solidity: function registerCounterpartyPayee(string portID, string channelID, address relayerAddr) payable returns(bool) +func (_RelayerFunctions *RelayerFunctionsTransactor) RegisterCounterpartyPayee(opts *bind.TransactOpts, portID string, channelID string, relayerAddr common.Address) (*types.Transaction, error) { + return _RelayerFunctions.contract.Transact(opts, "registerCounterpartyPayee", portID, channelID, relayerAddr) +} + +// RegisterCounterpartyPayee is a paid mutator transaction binding the contract method 0x5d3db16c. +// +// Solidity: function registerCounterpartyPayee(string portID, string channelID, address relayerAddr) payable returns(bool) +func (_RelayerFunctions *RelayerFunctionsSession) RegisterCounterpartyPayee(portID string, channelID string, relayerAddr common.Address) (*types.Transaction, error) { + return _RelayerFunctions.Contract.RegisterCounterpartyPayee(&_RelayerFunctions.TransactOpts, portID, channelID, relayerAddr) +} + +// RegisterCounterpartyPayee is a paid mutator transaction binding the contract method 0x5d3db16c. +// +// Solidity: function registerCounterpartyPayee(string portID, string channelID, address relayerAddr) payable returns(bool) +func (_RelayerFunctions *RelayerFunctionsTransactorSession) RegisterCounterpartyPayee(portID string, channelID string, relayerAddr common.Address) (*types.Transaction, error) { + return _RelayerFunctions.Contract.RegisterCounterpartyPayee(&_RelayerFunctions.TransactOpts, portID, channelID, relayerAddr) +} + +// RegisterPayee is a paid mutator transaction binding the contract method 0xb0dff939. +// +// Solidity: function registerPayee(string portID, string channelID, address relayerAddr) payable returns(bool) +func (_RelayerFunctions *RelayerFunctionsTransactor) RegisterPayee(opts *bind.TransactOpts, portID string, channelID string, relayerAddr common.Address) (*types.Transaction, error) { + return _RelayerFunctions.contract.Transact(opts, "registerPayee", portID, channelID, relayerAddr) +} + +// RegisterPayee is a paid mutator transaction binding the contract method 0xb0dff939. +// +// Solidity: function registerPayee(string portID, string channelID, address relayerAddr) payable returns(bool) +func (_RelayerFunctions *RelayerFunctionsSession) RegisterPayee(portID string, channelID string, relayerAddr common.Address) (*types.Transaction, error) { + return _RelayerFunctions.Contract.RegisterPayee(&_RelayerFunctions.TransactOpts, portID, channelID, relayerAddr) +} + +// RegisterPayee is a paid mutator transaction binding the contract method 0xb0dff939. +// +// Solidity: function registerPayee(string portID, string channelID, address relayerAddr) payable returns(bool) +func (_RelayerFunctions *RelayerFunctionsTransactorSession) RegisterPayee(portID string, channelID string, relayerAddr common.Address) (*types.Transaction, error) { + return _RelayerFunctions.Contract.RegisterPayee(&_RelayerFunctions.TransactOpts, portID, channelID, relayerAddr) +} + // SubmitMisbehaviour is a paid mutator transaction binding the contract method 0xa53b1c82. // // Solidity: function submitMisbehaviour(bytes data) payable returns(bytes) @@ -537,279 +579,6 @@ func (_RelayerFunctions *RelayerFunctionsTransactorSession) UpdateClient(data [] return _RelayerFunctions.Contract.UpdateClient(&_RelayerFunctions.TransactOpts, data) } -// UpdateClientAndAcknowledgement is a paid mutator transaction binding the contract method 0x65a939c6. -// -// Solidity: function updateClientAndAcknowledgement(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactor) UpdateClientAndAcknowledgement(opts *bind.TransactOpts, data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.contract.Transact(opts, "updateClientAndAcknowledgement", data1, data2) -} - -// UpdateClientAndAcknowledgement is a paid mutator transaction binding the contract method 0x65a939c6. -// -// Solidity: function updateClientAndAcknowledgement(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsSession) UpdateClientAndAcknowledgement(data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.Contract.UpdateClientAndAcknowledgement(&_RelayerFunctions.TransactOpts, data1, data2) -} - -// UpdateClientAndAcknowledgement is a paid mutator transaction binding the contract method 0x65a939c6. -// -// Solidity: function updateClientAndAcknowledgement(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactorSession) UpdateClientAndAcknowledgement(data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.Contract.UpdateClientAndAcknowledgement(&_RelayerFunctions.TransactOpts, data1, data2) -} - -// UpdateClientAndChannelCloseConfirm is a paid mutator transaction binding the contract method 0x9bbcbfd2. -// -// Solidity: function updateClientAndChannelCloseConfirm(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactor) UpdateClientAndChannelCloseConfirm(opts *bind.TransactOpts, data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.contract.Transact(opts, "updateClientAndChannelCloseConfirm", data1, data2) -} - -// UpdateClientAndChannelCloseConfirm is a paid mutator transaction binding the contract method 0x9bbcbfd2. -// -// Solidity: function updateClientAndChannelCloseConfirm(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsSession) UpdateClientAndChannelCloseConfirm(data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.Contract.UpdateClientAndChannelCloseConfirm(&_RelayerFunctions.TransactOpts, data1, data2) -} - -// UpdateClientAndChannelCloseConfirm is a paid mutator transaction binding the contract method 0x9bbcbfd2. -// -// Solidity: function updateClientAndChannelCloseConfirm(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactorSession) UpdateClientAndChannelCloseConfirm(data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.Contract.UpdateClientAndChannelCloseConfirm(&_RelayerFunctions.TransactOpts, data1, data2) -} - -// UpdateClientAndChannelCloseInit is a paid mutator transaction binding the contract method 0x5447448d. -// -// Solidity: function updateClientAndChannelCloseInit(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactor) UpdateClientAndChannelCloseInit(opts *bind.TransactOpts, data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.contract.Transact(opts, "updateClientAndChannelCloseInit", data1, data2) -} - -// UpdateClientAndChannelCloseInit is a paid mutator transaction binding the contract method 0x5447448d. -// -// Solidity: function updateClientAndChannelCloseInit(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsSession) UpdateClientAndChannelCloseInit(data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.Contract.UpdateClientAndChannelCloseInit(&_RelayerFunctions.TransactOpts, data1, data2) -} - -// UpdateClientAndChannelCloseInit is a paid mutator transaction binding the contract method 0x5447448d. -// -// Solidity: function updateClientAndChannelCloseInit(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactorSession) UpdateClientAndChannelCloseInit(data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.Contract.UpdateClientAndChannelCloseInit(&_RelayerFunctions.TransactOpts, data1, data2) -} - -// UpdateClientAndChannelOpenAck is a paid mutator transaction binding the contract method 0xc518ffc8. -// -// Solidity: function updateClientAndChannelOpenAck(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactor) UpdateClientAndChannelOpenAck(opts *bind.TransactOpts, data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.contract.Transact(opts, "updateClientAndChannelOpenAck", data1, data2) -} - -// UpdateClientAndChannelOpenAck is a paid mutator transaction binding the contract method 0xc518ffc8. -// -// Solidity: function updateClientAndChannelOpenAck(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsSession) UpdateClientAndChannelOpenAck(data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.Contract.UpdateClientAndChannelOpenAck(&_RelayerFunctions.TransactOpts, data1, data2) -} - -// UpdateClientAndChannelOpenAck is a paid mutator transaction binding the contract method 0xc518ffc8. -// -// Solidity: function updateClientAndChannelOpenAck(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactorSession) UpdateClientAndChannelOpenAck(data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.Contract.UpdateClientAndChannelOpenAck(&_RelayerFunctions.TransactOpts, data1, data2) -} - -// UpdateClientAndChannelOpenConfirm is a paid mutator transaction binding the contract method 0x0982b806. -// -// Solidity: function updateClientAndChannelOpenConfirm(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactor) UpdateClientAndChannelOpenConfirm(opts *bind.TransactOpts, data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.contract.Transact(opts, "updateClientAndChannelOpenConfirm", data1, data2) -} - -// UpdateClientAndChannelOpenConfirm is a paid mutator transaction binding the contract method 0x0982b806. -// -// Solidity: function updateClientAndChannelOpenConfirm(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsSession) UpdateClientAndChannelOpenConfirm(data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.Contract.UpdateClientAndChannelOpenConfirm(&_RelayerFunctions.TransactOpts, data1, data2) -} - -// UpdateClientAndChannelOpenConfirm is a paid mutator transaction binding the contract method 0x0982b806. -// -// Solidity: function updateClientAndChannelOpenConfirm(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactorSession) UpdateClientAndChannelOpenConfirm(data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.Contract.UpdateClientAndChannelOpenConfirm(&_RelayerFunctions.TransactOpts, data1, data2) -} - -// UpdateClientAndChannelOpenInit is a paid mutator transaction binding the contract method 0x66365fc4. -// -// Solidity: function updateClientAndChannelOpenInit(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactor) UpdateClientAndChannelOpenInit(opts *bind.TransactOpts, data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.contract.Transact(opts, "updateClientAndChannelOpenInit", data1, data2) -} - -// UpdateClientAndChannelOpenInit is a paid mutator transaction binding the contract method 0x66365fc4. -// -// Solidity: function updateClientAndChannelOpenInit(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsSession) UpdateClientAndChannelOpenInit(data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.Contract.UpdateClientAndChannelOpenInit(&_RelayerFunctions.TransactOpts, data1, data2) -} - -// UpdateClientAndChannelOpenInit is a paid mutator transaction binding the contract method 0x66365fc4. -// -// Solidity: function updateClientAndChannelOpenInit(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactorSession) UpdateClientAndChannelOpenInit(data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.Contract.UpdateClientAndChannelOpenInit(&_RelayerFunctions.TransactOpts, data1, data2) -} - -// UpdateClientAndChannelOpenTry is a paid mutator transaction binding the contract method 0x33978088. -// -// Solidity: function updateClientAndChannelOpenTry(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactor) UpdateClientAndChannelOpenTry(opts *bind.TransactOpts, data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.contract.Transact(opts, "updateClientAndChannelOpenTry", data1, data2) -} - -// UpdateClientAndChannelOpenTry is a paid mutator transaction binding the contract method 0x33978088. -// -// Solidity: function updateClientAndChannelOpenTry(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsSession) UpdateClientAndChannelOpenTry(data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.Contract.UpdateClientAndChannelOpenTry(&_RelayerFunctions.TransactOpts, data1, data2) -} - -// UpdateClientAndChannelOpenTry is a paid mutator transaction binding the contract method 0x33978088. -// -// Solidity: function updateClientAndChannelOpenTry(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactorSession) UpdateClientAndChannelOpenTry(data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.Contract.UpdateClientAndChannelOpenTry(&_RelayerFunctions.TransactOpts, data1, data2) -} - -// UpdateClientAndConnectionOpenAck is a paid mutator transaction binding the contract method 0xfedb9353. -// -// Solidity: function updateClientAndConnectionOpenAck(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactor) UpdateClientAndConnectionOpenAck(opts *bind.TransactOpts, data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.contract.Transact(opts, "updateClientAndConnectionOpenAck", data1, data2) -} - -// UpdateClientAndConnectionOpenAck is a paid mutator transaction binding the contract method 0xfedb9353. -// -// Solidity: function updateClientAndConnectionOpenAck(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsSession) UpdateClientAndConnectionOpenAck(data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.Contract.UpdateClientAndConnectionOpenAck(&_RelayerFunctions.TransactOpts, data1, data2) -} - -// UpdateClientAndConnectionOpenAck is a paid mutator transaction binding the contract method 0xfedb9353. -// -// Solidity: function updateClientAndConnectionOpenAck(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactorSession) UpdateClientAndConnectionOpenAck(data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.Contract.UpdateClientAndConnectionOpenAck(&_RelayerFunctions.TransactOpts, data1, data2) -} - -// UpdateClientAndConnectionOpenConfirm is a paid mutator transaction binding the contract method 0x70009dfc. -// -// Solidity: function updateClientAndConnectionOpenConfirm(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactor) UpdateClientAndConnectionOpenConfirm(opts *bind.TransactOpts, data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.contract.Transact(opts, "updateClientAndConnectionOpenConfirm", data1, data2) -} - -// UpdateClientAndConnectionOpenConfirm is a paid mutator transaction binding the contract method 0x70009dfc. -// -// Solidity: function updateClientAndConnectionOpenConfirm(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsSession) UpdateClientAndConnectionOpenConfirm(data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.Contract.UpdateClientAndConnectionOpenConfirm(&_RelayerFunctions.TransactOpts, data1, data2) -} - -// UpdateClientAndConnectionOpenConfirm is a paid mutator transaction binding the contract method 0x70009dfc. -// -// Solidity: function updateClientAndConnectionOpenConfirm(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactorSession) UpdateClientAndConnectionOpenConfirm(data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.Contract.UpdateClientAndConnectionOpenConfirm(&_RelayerFunctions.TransactOpts, data1, data2) -} - -// UpdateClientAndConnectionOpenInit is a paid mutator transaction binding the contract method 0x491e69c7. -// -// Solidity: function updateClientAndConnectionOpenInit(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactor) UpdateClientAndConnectionOpenInit(opts *bind.TransactOpts, data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.contract.Transact(opts, "updateClientAndConnectionOpenInit", data1, data2) -} - -// UpdateClientAndConnectionOpenInit is a paid mutator transaction binding the contract method 0x491e69c7. -// -// Solidity: function updateClientAndConnectionOpenInit(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsSession) UpdateClientAndConnectionOpenInit(data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.Contract.UpdateClientAndConnectionOpenInit(&_RelayerFunctions.TransactOpts, data1, data2) -} - -// UpdateClientAndConnectionOpenInit is a paid mutator transaction binding the contract method 0x491e69c7. -// -// Solidity: function updateClientAndConnectionOpenInit(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactorSession) UpdateClientAndConnectionOpenInit(data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.Contract.UpdateClientAndConnectionOpenInit(&_RelayerFunctions.TransactOpts, data1, data2) -} - -// UpdateClientAndConnectionOpenTry is a paid mutator transaction binding the contract method 0x5f3a7169. -// -// Solidity: function updateClientAndConnectionOpenTry(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactor) UpdateClientAndConnectionOpenTry(opts *bind.TransactOpts, data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.contract.Transact(opts, "updateClientAndConnectionOpenTry", data1, data2) -} - -// UpdateClientAndConnectionOpenTry is a paid mutator transaction binding the contract method 0x5f3a7169. -// -// Solidity: function updateClientAndConnectionOpenTry(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsSession) UpdateClientAndConnectionOpenTry(data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.Contract.UpdateClientAndConnectionOpenTry(&_RelayerFunctions.TransactOpts, data1, data2) -} - -// UpdateClientAndConnectionOpenTry is a paid mutator transaction binding the contract method 0x5f3a7169. -// -// Solidity: function updateClientAndConnectionOpenTry(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactorSession) UpdateClientAndConnectionOpenTry(data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.Contract.UpdateClientAndConnectionOpenTry(&_RelayerFunctions.TransactOpts, data1, data2) -} - -// UpdateClientAndRecvPacket is a paid mutator transaction binding the contract method 0xd3cffc28. -// -// Solidity: function updateClientAndRecvPacket(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactor) UpdateClientAndRecvPacket(opts *bind.TransactOpts, data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.contract.Transact(opts, "updateClientAndRecvPacket", data1, data2) -} - -// UpdateClientAndRecvPacket is a paid mutator transaction binding the contract method 0xd3cffc28. -// -// Solidity: function updateClientAndRecvPacket(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsSession) UpdateClientAndRecvPacket(data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.Contract.UpdateClientAndRecvPacket(&_RelayerFunctions.TransactOpts, data1, data2) -} - -// UpdateClientAndRecvPacket is a paid mutator transaction binding the contract method 0xd3cffc28. -// -// Solidity: function updateClientAndRecvPacket(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactorSession) UpdateClientAndRecvPacket(data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.Contract.UpdateClientAndRecvPacket(&_RelayerFunctions.TransactOpts, data1, data2) -} - -// UpdateClientAndTimeout is a paid mutator transaction binding the contract method 0xca4c72a0. -// -// Solidity: function updateClientAndTimeout(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactor) UpdateClientAndTimeout(opts *bind.TransactOpts, data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.contract.Transact(opts, "updateClientAndTimeout", data1, data2) -} - -// UpdateClientAndTimeout is a paid mutator transaction binding the contract method 0xca4c72a0. -// -// Solidity: function updateClientAndTimeout(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsSession) UpdateClientAndTimeout(data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.Contract.UpdateClientAndTimeout(&_RelayerFunctions.TransactOpts, data1, data2) -} - -// UpdateClientAndTimeout is a paid mutator transaction binding the contract method 0xca4c72a0. -// -// Solidity: function updateClientAndTimeout(bytes data1, bytes data2) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactorSession) UpdateClientAndTimeout(data1 []byte, data2 []byte) (*types.Transaction, error) { - return _RelayerFunctions.Contract.UpdateClientAndTimeout(&_RelayerFunctions.TransactOpts, data1, data2) -} - // UpgradeClient is a paid mutator transaction binding the contract method 0x8a8e4c5d. // // Solidity: function upgradeClient(bytes data) payable returns(bytes) diff --git a/x/cronos/events/bindings/src/RelayerFunctions.sol b/x/cronos/events/bindings/src/RelayerFunctions.sol index f580fe5ccb..d3c76dda70 100644 --- a/x/cronos/events/bindings/src/RelayerFunctions.sol +++ b/x/cronos/events/bindings/src/RelayerFunctions.sol @@ -20,17 +20,6 @@ interface IRelayerFunctions { function acknowledgement(bytes calldata data) external payable returns (bytes calldata); function timeout(bytes calldata data) external payable returns (bytes calldata); function timeoutOnClose(bytes calldata data) external payable returns (bytes calldata); - function updateClientAndConnectionOpenInit(bytes calldata data1, bytes calldata data2) external payable returns (bool); - function updateClientAndConnectionOpenTry(bytes calldata data1, bytes calldata data2) external payable returns (bool); - function updateClientAndConnectionOpenAck(bytes calldata data1, bytes calldata data2) external payable returns (bool); - function updateClientAndConnectionOpenConfirm(bytes calldata data1, bytes calldata data2) external payable returns (bool); - function updateClientAndChannelOpenInit(bytes calldata data1, bytes calldata data2) external payable returns (bool); - function updateClientAndChannelOpenTry(bytes calldata data1, bytes calldata data2) external payable returns (bool); - function updateClientAndChannelOpenAck(bytes calldata data1, bytes calldata data2) external payable returns (bool); - function updateClientAndChannelOpenConfirm(bytes calldata data1, bytes calldata data2) external payable returns (bool); - function updateClientAndRecvPacket(bytes calldata data1, bytes calldata data2) external payable returns (bool); - function updateClientAndAcknowledgement(bytes calldata data1, bytes calldata data2) external payable returns (bool); - function updateClientAndTimeout(bytes calldata data1, bytes calldata data2) external payable returns (bool); - function updateClientAndChannelCloseInit(bytes calldata data1, bytes calldata data2) external payable returns (bool); - function updateClientAndChannelCloseConfirm(bytes calldata data1, bytes calldata data2) external payable returns (bool); + function registerPayee(string calldata portID, string calldata channelID, address relayerAddr) external payable returns (bool); + function registerCounterpartyPayee(string calldata portID, string calldata channelID, address relayerAddr) external payable returns (bool); } diff --git a/x/cronos/keeper/precompiles/relayer.go b/x/cronos/keeper/precompiles/relayer.go index a16c90df71..964b43f3ac 100644 --- a/x/cronos/keeper/precompiles/relayer.go +++ b/x/cronos/keeper/precompiles/relayer.go @@ -1,7 +1,6 @@ package precompiles import ( - "context" "errors" "fmt" @@ -15,6 +14,7 @@ import ( "github.com/ethereum/go-ethereum/params" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + ibcfeetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" cronosevents "github.com/crypto-org-chain/cronos/v2/x/cronos/events" @@ -48,7 +48,9 @@ const ( Acknowledgement = "acknowledgement" Timeout = "timeout" TimeoutOnClose = "timeoutOnClose" - + // ibc fee + RegisterPayee = "registerPayee" + RsegisterCounterpartyPayee = "registerCounterpartyPayee" GasWhenReceiverChainIsSource = 51705 GasWhenReceiverChainIsNotSource = 144025 ) @@ -101,18 +103,20 @@ func init() { type RelayerContract struct { BaseContract - cdc codec.Codec - ibcKeeper types.IbcKeeper - logger log.Logger - isHomestead bool - isIstanbul bool - isShanghai bool + cdc codec.Codec + ibcKeeper types.IbcKeeper + ibcFeeKeeper types.IbcFeeKeeper + logger log.Logger + isHomestead bool + isIstanbul bool + isShanghai bool } -func NewRelayerContract(ibcKeeper types.IbcKeeper, cdc codec.Codec, rules params.Rules, logger log.Logger) vm.PrecompiledContract { +func NewRelayerContract(ibcKeeper types.IbcKeeper, ibcFeeKeeper types.IbcFeeKeeper, cdc codec.Codec, rules params.Rules, logger log.Logger) vm.PrecompiledContract { return &RelayerContract{ BaseContract: NewBaseContract(relayerContractAddress), ibcKeeper: ibcKeeper, + ibcFeeKeeper: ibcFeeKeeper, cdc: cdc, isHomestead: rules.IsHomestead, isIstanbul: rules.IsIstanbul, @@ -191,8 +195,33 @@ func (bc *RelayerContract) Run(evm *vm.EVM, contract *vm.Contract, readonly bool if err != nil { return nil, errors.New("fail to unpack input arguments") } - input := args[0].([]byte) converter := cronosevents.RelayerConvertEvent + if method.Name == RegisterPayee || method.Name == RsegisterCounterpartyPayee { + execErr := stateDB.ExecuteNativeAction(precompileAddr, converter, func(ctx sdk.Context) error { + portID := args[0].(string) + channelID := args[1].(string) + relayerAddr := sdk.AccAddress(args[2].(common.Address).Bytes()).String() + caller := sdk.AccAddress(contract.CallerAddress.Bytes()).String() + if method.Name == RegisterPayee { + _, err := bc.ibcFeeKeeper.RegisterPayee( + ctx, + ibcfeetypes.NewMsgRegisterPayee(portID, channelID, caller, relayerAddr), + ) + return err + } else { + _, err = bc.ibcFeeKeeper.RegisterCounterpartyPayee( + ctx, + ibcfeetypes.NewMsgRegisterCounterpartyPayee(portID, channelID, caller, relayerAddr), + ) + return err + } + }) + if execErr != nil { + return nil, execErr + } + return method.Outputs.Pack(true) + } + input := args[0].([]byte) e := &Executor{ cdc: bc.cdc, stateDB: stateDB, @@ -231,15 +260,9 @@ func (bc *RelayerContract) Run(evm *vm.EVM, contract *vm.Contract, readonly bool case RecvPacket: res, err = exec(e, bc.ibcKeeper.RecvPacket) case Acknowledgement: - res, err = exec(e, func(goCtx context.Context, msg *channeltypes.MsgAcknowledgement) (*channeltypes.MsgAcknowledgementResponse, error) { - msg.Signer = sdk.AccAddress(evm.TxContext.Origin.Bytes()).String() - return bc.ibcKeeper.Acknowledgement(goCtx, msg) - }) + res, err = exec(e, bc.ibcKeeper.Acknowledgement) case Timeout: - res, err = exec(e, func(goCtx context.Context, msg *channeltypes.MsgTimeout) (*channeltypes.MsgTimeoutResponse, error) { - msg.Signer = sdk.AccAddress(evm.TxContext.Origin.Bytes()).String() - return bc.ibcKeeper.Timeout(goCtx, msg) - }) + res, err = exec(e, bc.ibcKeeper.Timeout) case TimeoutOnClose: res, err = exec(e, bc.ibcKeeper.TimeoutOnClose) default: diff --git a/x/cronos/types/interfaces.go b/x/cronos/types/interfaces.go index 25becabe1f..b303c4128c 100644 --- a/x/cronos/types/interfaces.go +++ b/x/cronos/types/interfaces.go @@ -15,6 +15,7 @@ import ( "github.com/ethereum/go-ethereum/params" evmtypes "github.com/evmos/ethermint/x/evm/types" + ibcfeetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" @@ -94,3 +95,8 @@ type IbcKeeper interface { Timeout(goCtx context.Context, msg *channeltypes.MsgTimeout) (*channeltypes.MsgTimeoutResponse, error) TimeoutOnClose(goCtx context.Context, msg *channeltypes.MsgTimeoutOnClose) (*channeltypes.MsgTimeoutOnCloseResponse, error) } + +type IbcFeeKeeper interface { + RegisterPayee(goCtx context.Context, msg *ibcfeetypes.MsgRegisterPayee) (*ibcfeetypes.MsgRegisterPayeeResponse, error) + RegisterCounterpartyPayee(goCtx context.Context, msg *ibcfeetypes.MsgRegisterCounterpartyPayee) (*ibcfeetypes.MsgRegisterCounterpartyPayeeResponse, error) +} From 20d2b28a11488a28ff4ec87667653c1c61647e26 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Fri, 25 Oct 2024 18:04:55 +0800 Subject: [PATCH 2/4] Update integration_tests/ibc_utils.py Signed-off-by: mmsqe --- integration_tests/ibc_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_tests/ibc_utils.py b/integration_tests/ibc_utils.py index 478204753b..ffd382b88f 100644 --- a/integration_tests/ibc_utils.py +++ b/integration_tests/ibc_utils.py @@ -228,7 +228,7 @@ def prepare_network( wait_for_port(port) -def register_fee_payee(src_chain, dst_chain, port_id, channel_id): +def register_fee_payee(src_chain, dst_chain, port_id="transfer", channel_id="channel-0"): rsp = dst_chain.register_counterparty_payee( port_id, channel_id, From 57dfff69c26dce62e88ee82e1f3b547e058e86f8 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Mon, 28 Oct 2024 09:20:15 +0800 Subject: [PATCH 3/4] counterpartyPayee --- integration_tests/configs/ibc.jsonnet | 4 +- .../contracts/contracts/TestRelayer.sol | 8 +- integration_tests/cosmoscli.py | 2 +- integration_tests/ibc_utils.py | 239 +++++++++++------- integration_tests/test_ibc.py | 3 +- integration_tests/test_ibc_rly.py | 3 +- integration_tests/test_ibc_rly_gas.py | 3 +- integration_tests/test_ica_precompile.py | 1 + .../relayer/i_relayer_functions.abigen.go | 44 ++-- .../events/bindings/src/RelayerFunctions.sol | 4 +- x/cronos/keeper/precompiles/relayer.go | 15 +- 11 files changed, 185 insertions(+), 141 deletions(-) diff --git a/integration_tests/configs/ibc.jsonnet b/integration_tests/configs/ibc.jsonnet index 09e2b05359..eafeb430a1 100644 --- a/integration_tests/configs/ibc.jsonnet +++ b/integration_tests/configs/ibc.jsonnet @@ -39,7 +39,7 @@ config { 'account-prefix': 'cro', 'coin-type': 394, 'app-config': { - 'minimum-gas-prices': '500basecro', + 'minimum-gas-prices': '0basecro', }, validators: [ { @@ -68,7 +68,7 @@ config { }, { name: 'signer2', - coins: '10000000000000cro', + coins: '10000000000000cro,100000000000ibcfee', mnemonic: '${SIGNER2_MNEMONIC}', }, ] + [ diff --git a/integration_tests/contracts/contracts/TestRelayer.sol b/integration_tests/contracts/contracts/TestRelayer.sol index c6188a3c19..ba930f1ae7 100644 --- a/integration_tests/contracts/contracts/TestRelayer.sol +++ b/integration_tests/contracts/contracts/TestRelayer.sol @@ -16,16 +16,16 @@ contract TestRelayer { } } - function callRegisterPayee(string calldata portID, string calldata channelID, address relayerAddr) public returns (bool) { + function callRegisterPayee(string calldata portID, string calldata channelID, address payeeAddr) public returns (bool) { require(payee == address(0) || payee == msg.sender, "register fail"); - bool result = relayer.registerPayee(portID, channelID, relayerAddr); + bool result = relayer.registerPayee(portID, channelID, payeeAddr); require(result, "call failed"); payee = msg.sender; } - function callRegisterCounterpartyPayee(string calldata portID, string calldata channelID, address relayerAddr) public returns (bool) { + function callRegisterCounterpartyPayee(string calldata portID, string calldata channelID, string calldata counterpartyPayeeAddr) public returns (bool) { require(counterpartyPayee == address(0) || counterpartyPayee == msg.sender, "register fail"); - bool result = relayer.registerCounterpartyPayee(portID, channelID, relayerAddr); + bool result = relayer.registerCounterpartyPayee(portID, channelID, counterpartyPayeeAddr); require(result, "call failed"); counterpartyPayee = msg.sender; } diff --git a/integration_tests/cosmoscli.py b/integration_tests/cosmoscli.py index 4b6aca5746..a81eeebc01 100644 --- a/integration_tests/cosmoscli.py +++ b/integration_tests/cosmoscli.py @@ -888,7 +888,7 @@ def ibc_transfer( to, amount, channel, # src channel - target_version, # chain version number of target chain + target_version=1, # chain version number of target chain event_query_tx_for=False, **kwargs, ): diff --git a/integration_tests/ibc_utils.py b/integration_tests/ibc_utils.py index ffd382b88f..e86f7c4500 100644 --- a/integration_tests/ibc_utils.py +++ b/integration_tests/ibc_utils.py @@ -9,12 +9,14 @@ import requests from cprotobuf import Field, ProtoEntity +from eth_utils import to_checksum_address from pystarport import cluster, ports from .network import Chainmain, Cronos, Hermes, setup_custom_cronos from .utils import ( ADDRS, CONTRACTS, + bech32_to_eth, deploy_contract, derive_new_account, eth_to_bech32, @@ -97,7 +99,7 @@ def call_hermes_cmd( ) -def call_rly_cmd(path, connection_only, version, hostchain="chainmain-1"): +def call_rly_cmd(path, connection_only, incentivized, version, hostchain="chainmain-1"): cmd = [ "rly", "pth", @@ -130,11 +132,11 @@ def call_rly_cmd(path, connection_only, version, hostchain="chainmain-1"): "transfer", "--order", "unordered", - "--version", - json.dumps(version), "--home", str(path), ] + if incentivized: + cmd.extend(["--version", json.dumps(version)]) subprocess.check_call(cmd) @@ -145,12 +147,14 @@ def prepare_network( is_relay=True, connection_only=False, grantee=None, + need_relayer_caller=False, relayer=cluster.Relayer.HERMES.value, ): print("incentivized", incentivized) print("is_relay", is_relay) print("connection_only", connection_only) print("relayer", relayer) + print("need_relayer_caller", need_relayer_caller) is_hermes = relayer == cluster.Relayer.HERMES.value hermes = None file = f"configs/{file}.jsonnet" @@ -181,17 +185,20 @@ def prepare_network( version = {"fee_version": "ics29-1", "app_version": "ics20-1"} path = cronos.base_dir.parent / "relayer" w3 = cronos.w3 - acc = derive_new_account(2) - sender = acc.address - # fund new sender to deploy contract with same address - if w3.eth.get_balance(sender, "latest") == 0: - fund = 3000000000000000000 - tx = {"to": sender, "value": fund, "gasPrice": w3.eth.gas_price} - send_transaction(w3, tx) - assert w3.eth.get_balance(sender, "latest") == fund - contract = deploy_contract(w3, CONTRACTS["TestRelayer"], key=acc.key) - caller = contract.address - assert caller == RELAYER_CALLER, caller + contract = None + acc = None + if need_relayer_caller: + acc = derive_new_account(2) + sender = acc.address + # fund new sender to deploy contract with same address + if w3.eth.get_balance(sender, "latest") == 0: + fund = 3000000000000000000 + tx = {"to": sender, "value": fund, "gasPrice": w3.eth.gas_price} + send_transaction(w3, tx) + assert w3.eth.get_balance(sender, "latest") == fund + contract = deploy_contract(w3, CONTRACTS["TestRelayer"], key=acc.key) + caller = contract.address + assert caller == RELAYER_CALLER, caller if is_hermes: hermes = Hermes(path.with_suffix(".toml")) call_hermes_cmd( @@ -201,20 +208,10 @@ def prepare_network( version, ) else: - call_rly_cmd(path, connection_only, version) + call_rly_cmd(path, connection_only, incentivized, version) if incentivized: - port_id = "transfer" - channel_id = "channel-0" - register_fee_payee( - cronos.cosmos_cli(), chainmain.cosmos_cli(), port_id, channel_id - ) - data = {"from": acc.address} - tx = contract.functions.callRegisterPayee( - port_id, channel_id, ADDRS["signer1"] - ).build_transaction(data) - receipt = send_transaction(w3, tx, acc.key) - assert receipt.status == 1, receipt + register_fee_payee(cronos, chainmain, contract, acc) port = None if is_relay: @@ -228,16 +225,43 @@ def prepare_network( wait_for_port(port) -def register_fee_payee(src_chain, dst_chain, port_id="transfer", channel_id="channel-0"): - rsp = dst_chain.register_counterparty_payee( +def register_fee_payee(src_chain, dst_chain, contract=None, acc=None): + port_id = "transfer" + channel_id = "channel-0" + chains = [src_chain.cosmos_cli(), dst_chain.cosmos_cli()] + relayer0 = chains[0].address("signer1") + relayer1 = chains[1].address("relayer") + rsp = chains[1].register_counterparty_payee( port_id, channel_id, - dst_chain.address("relayer"), - src_chain.address("signer1"), - from_="relayer", + relayer1, + relayer0, + from_=relayer1, fees="100000000basecro", ) assert rsp["code"] == 0, rsp["raw_log"] + if contract is None: + rsp = chains[0].register_counterparty_payee( + port_id, + channel_id, + relayer0, + relayer1, + from_=relayer0, + fees="100000000basetcro", + ) + assert rsp["code"] == 0, rsp["raw_log"] + else: + data = {"from": acc.address} + tx = contract.functions.callRegisterPayee( + port_id, channel_id, to_checksum_address(bech32_to_eth(relayer0)) + ).build_transaction(data) + receipt = send_transaction(src_chain.w3, tx, acc.key) + assert receipt.status == 1, receipt + tx = contract.functions.callRegisterCounterpartyPayee( + port_id, channel_id, relayer1 + ).build_transaction(data) + receipt = send_transaction(src_chain.w3, tx, acc.key) + assert receipt.status == 1, receipt def assert_ready(ibc): @@ -371,7 +395,6 @@ def ibc_multi_transfer(ibc): addrs1[i], f"{amount}{denom0}", channel0, - 1, fees=f"1000{denom1}", event_query_tx_for=True, ) @@ -412,7 +435,6 @@ def assert_balance(addr): addrs0[i], f"{amt}ibc/{denom_hash}", channel1, - 1, fees=f"100000000{denom1}", ) assert rsp["code"] == 0, rsp["raw_log"] @@ -425,66 +447,61 @@ def assert_balance(addr): def ibc_incentivized_transfer(ibc): chains = [ibc.cronos.cosmos_cli(), ibc.chainmain.cosmos_cli()] - receiver = chains[1].address("signer2") - sender = chains[0].address("signer2") - relayer = chains[0].address("signer1") - relayer_caller = eth_to_bech32(RELAYER_CALLER) + user0 = chains[0].address("signer2") + relayer0 = chains[0].address("signer1") + user1 = chains[1].address("signer2") + relayer1 = chains[1].address("relayer") amount = 1000 fee_denom = "ibcfee" - base_denom = "basetcro" - old_amt_fee = chains[0].balance(relayer, fee_denom) - old_amt_fee_caller = chains[0].balance(relayer_caller, fee_denom) - old_amt_sender_fee = chains[0].balance(sender, fee_denom) - old_amt_sender_base = chains[0].balance(sender, base_denom) - old_amt_receiver_base = chains[1].balance(receiver, "basecro") - assert old_amt_sender_base == 30000000000100000000000 - assert old_amt_receiver_base == 1000000000000000000000 + base_denom0 = "basetcro" + base_denom1 = "basecro" + old_relayer0_fee = chains[0].balance(relayer0, fee_denom) + old_user0_fee = chains[0].balance(user0, fee_denom) + old_user0_base = chains[0].balance(user0, base_denom0) + old_relayer1_fee = chains[1].balance(relayer1, fee_denom) + old_user1_fee = chains[1].balance(user1, fee_denom) + old_user1_base = chains[1].balance(user1, base_denom1) + assert old_user0_base == 30000000000100000000000 + assert old_user1_base == 1000000000000000000000 src_channel = "channel-0" dst_channel = "channel-0" rsp = chains[0].ibc_transfer( - sender, - receiver, - f"{amount}{base_denom}", + user0, + user1, + f"{amount}{base_denom0}", src_channel, - 1, - fees="0basecro", + fees=f"0{base_denom0}", ) assert rsp["code"] == 0, rsp["raw_log"] - src_chain = ibc.cronos.cosmos_cli() - rsp = src_chain.event_query_tx_for(rsp["txhash"]) - - def cb(attrs): - return "packet_sequence" in attrs - - evt = find_log_event_attrs(rsp["events"], "send_packet", cb) + rsp = chains[0].event_query_tx_for(rsp["txhash"]) + evt = find_log_event_attrs( + rsp["events"], "send_packet", lambda attrs: "packet_sequence" in attrs + ) print("packet event", evt) packet_seq = int(evt["packet_sequence"]) - fee = f"10{fee_denom}" + recv_fee = 10 + ack_fee = 11 + timeout_fee = 12 rsp = chains[0].pay_packet_fee( "transfer", src_channel, packet_seq, - recv_fee=fee, - ack_fee=fee, - timeout_fee=fee, - from_=sender, + recv_fee=f"{recv_fee}{fee_denom}", + ack_fee=f"{ack_fee}{fee_denom}", + timeout_fee=f"{timeout_fee}{fee_denom}", + from_=user0, ) assert rsp["code"] == 0, rsp["raw_log"] # fee is locked - current = chains[0].balance(sender, fee_denom) + user0_fee = chains[0].balance(user0, fee_denom) # https://github.com/cosmos/ibc-go/pull/5571 - assert current == old_amt_sender_fee - 20, current + assert user0_fee == old_user0_fee - recv_fee - ack_fee, user0_fee # wait for relayer receive the fee def check_fee(): - amount = chains[0].balance(relayer, fee_denom) - if amount > old_amt_fee: - amount_caller = chains[0].balance(relayer_caller, fee_denom) - if amount_caller > 0: - assert amount_caller == old_amt_fee_caller + 10, amount_caller - assert amount == old_amt_fee + 10, amount - else: - assert amount == old_amt_fee + 20, amount + relayer0_fee = chains[0].balance(relayer0, fee_denom) + if relayer0_fee > old_relayer0_fee: + assert relayer0_fee == old_relayer0_fee + recv_fee + ack_fee, relayer0_fee return True else: return False @@ -492,40 +509,66 @@ def check_fee(): wait_for_fn("wait for relayer to receive the fee", check_fee) # timeout fee is refunded - actual = get_balances(ibc.cronos, sender) - assert actual == [ - {"denom": base_denom, "amount": f"{old_amt_sender_base - amount}"}, - {"denom": fee_denom, "amount": f"{old_amt_sender_fee - 20}"}, - ], actual - path = f"transfer/{dst_channel}/{base_denom}" - denom_hash = hashlib.sha256(path.encode()).hexdigest().upper() + user0_balances = get_balances(ibc.cronos, user0) + expected = [ + {"denom": base_denom0, "amount": f"{old_user0_base - amount}"}, + {"denom": fee_denom, "amount": f"{old_user0_fee - recv_fee - ack_fee}"}, + ] + assert user0_balances == expected, user0_balances + path = f"transfer/{dst_channel}/{base_denom0}" + denom_hash = ibc_denom(dst_channel, base_denom0) denom_trace = chains[0].ibc_denom_trace(path, ibc.chainmain.node_rpc(0)) - assert denom_trace == {"path": f"transfer/{dst_channel}", "base_denom": base_denom} - current = get_balances(ibc.chainmain, receiver) - assert current == [ - {"denom": "basecro", "amount": f"{old_amt_receiver_base}"}, - {"denom": f"ibc/{denom_hash}", "amount": f"{amount}"}, - ], current + assert denom_trace == {"path": f"transfer/{dst_channel}", "base_denom": base_denom0} + user1_balances = get_balances(ibc.chainmain, user1) + expected = [ + {"denom": base_denom1, "amount": f"{old_user1_base}"}, + {"denom": f"{denom_hash}", "amount": f"{amount}"}, + {"denom": f"{fee_denom}", "amount": f"{old_user1_fee}"}, + ] + assert user1_balances == expected, user1_balances # transfer back - fee_amount = 100000000 rsp = chains[1].ibc_transfer( - receiver, - sender, - f"{amount}ibc/{denom_hash}", + user1, + user0, + f"{amount}{denom_hash}", dst_channel, - 1, - fees=f"{fee_amount}basecro", + fees=f"0{base_denom1}", ) assert rsp["code"] == 0, rsp["raw_log"] + rsp = chains[1].event_query_tx_for(rsp["txhash"]) + evt = find_log_event_attrs( + rsp["events"], "send_packet", lambda attrs: "packet_sequence" in attrs + ) + print("packet event", evt) + rsp = chains[1].pay_packet_fee( + "transfer", + dst_channel, + int(evt["packet_sequence"]), + recv_fee=f"{recv_fee}{fee_denom}", + ack_fee=f"{ack_fee}{fee_denom}", + timeout_fee=f"{timeout_fee}{fee_denom}", + from_=user1, + ) + assert rsp["code"] == 0, rsp["raw_log"] + # fee is locked + user1_fee = chains[1].balance(user1, fee_denom) + assert user1_fee == old_user1_fee - recv_fee - ack_fee, user1_fee + + # wait for relayer receive the fee + def check_fee(): + relayer1_fee = chains[1].balance(relayer1, fee_denom) + if relayer1_fee > old_relayer1_fee: + assert relayer1_fee == old_relayer1_fee + recv_fee + ack_fee, relayer1_fee + return True + else: + return False + + wait_for_fn("wait for relayer to receive the fee", check_fee) def check_balance_change(): - return chains[0].balance(sender, base_denom) != old_amt_sender_base - amount + return chains[0].balance(user0, base_denom0) != old_user0_base - amount wait_for_fn("balance change", check_balance_change) - actual = chains[0].balance(sender, base_denom) - assert actual == old_amt_sender_base, actual - current = chains[1].balance(receiver, "basecro") - assert current == old_amt_receiver_base - fee_amount return amount, packet_seq @@ -592,7 +635,7 @@ def check_chainmain_balance_change(): coin = "1000" + dest_denom fees = "100000000basecro" rsp = chainmain_cli.ibc_transfer( - chainmain_receiver, cronos_receiver, coin, "channel-0", 1, fees=fees + chainmain_receiver, cronos_receiver, coin, "channel-0", fees=fees ) assert rsp["code"] == 0, rsp["raw_log"] @@ -694,7 +737,7 @@ def check_chainmain_balance_change(): coin = f"{amount}{dest_denom}" fees = "100000000basecro" rsp = chainmain_cli.ibc_transfer( - chainmain_receiver, cronos_receiver, coin, "channel-0", 1, fees=fees + chainmain_receiver, cronos_receiver, coin, "channel-0", fees=fees ) assert rsp["code"] == 0, rsp["raw_log"] diff --git a/integration_tests/test_ibc.py b/integration_tests/test_ibc.py index 56edf919c3..7c60039475 100644 --- a/integration_tests/test_ibc.py +++ b/integration_tests/test_ibc.py @@ -68,7 +68,6 @@ def test_ibc_incentivized_transfer(ibc, tmp_path): if not ibc.incentivized: # upgrade to incentivized src_chain = ibc.cronos.cosmos_cli() - dst_chain = ibc.chainmain.cosmos_cli() version = {"fee_version": "ics29-1", "app_version": "ics20-1"} community = "community" authority = module_address("gov") @@ -96,7 +95,7 @@ def test_ibc_incentivized_transfer(ibc, tmp_path): src_chain, connid, channel_id, "STATE_FLUSHCOMPLETE" ) wait_for_check_channel_ready(src_chain, connid, channel_id) - register_fee_payee(src_chain, dst_chain) + register_fee_payee(ibc.cronos, ibc.chainmain) ibc_incentivized_transfer(ibc) diff --git a/integration_tests/test_ibc_rly.py b/integration_tests/test_ibc_rly.py index 0e8e23ee91..9697a1fa70 100644 --- a/integration_tests/test_ibc_rly.py +++ b/integration_tests/test_ibc_rly.py @@ -2,7 +2,6 @@ import pytest from eth_utils import keccak, to_checksum_address -from pystarport import cluster from web3.datastructures import AttributeDict from .ibc_utils import ( @@ -51,7 +50,7 @@ def ibc(request, tmp_path_factory): yield from prepare_network( path, name, - relayer=cluster.Relayer.HERMES.value, + need_relayer_caller=True, ) diff --git a/integration_tests/test_ibc_rly_gas.py b/integration_tests/test_ibc_rly_gas.py index ce1f206895..24ba5b89f4 100644 --- a/integration_tests/test_ibc_rly_gas.py +++ b/integration_tests/test_ibc_rly_gas.py @@ -1,5 +1,4 @@ import pytest -from pystarport import cluster from .ibc_utils import ( ibc_incentivized_transfer, @@ -18,7 +17,7 @@ def ibc(request, tmp_path_factory): "prepare-network" name = request.param path = tmp_path_factory.mktemp(name) - yield from prepare_network(path, name, relayer=cluster.Relayer.HERMES.value) + yield from prepare_network(path, name, need_relayer_caller=name == "ibc_rly_evm") records = [] diff --git a/integration_tests/test_ica_precompile.py b/integration_tests/test_ica_precompile.py index d3ddba1078..067bf1f671 100644 --- a/integration_tests/test_ica_precompile.py +++ b/integration_tests/test_ica_precompile.py @@ -56,6 +56,7 @@ def ibc(request, tmp_path_factory): incentivized=False, connection_only=True, relayer=cluster.Relayer.RLY.value, + need_relayer_caller=True, ) diff --git a/x/cronos/events/bindings/cosmos/precompile/relayer/i_relayer_functions.abigen.go b/x/cronos/events/bindings/cosmos/precompile/relayer/i_relayer_functions.abigen.go index e7ae987b1b..520abd2896 100644 --- a/x/cronos/events/bindings/cosmos/precompile/relayer/i_relayer_functions.abigen.go +++ b/x/cronos/events/bindings/cosmos/precompile/relayer/i_relayer_functions.abigen.go @@ -31,7 +31,7 @@ var ( // RelayerFunctionsMetaData contains all meta data concerning the RelayerFunctions contract. var RelayerFunctionsMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"acknowledgement\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"channelCloseConfirm\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"channelCloseInit\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"channelOpenAck\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"channelOpenConfirm\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"channelOpenInit\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"channelOpenTry\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"connectionOpenAck\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"connectionOpenConfirm\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"connectionOpenInit\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"connectionOpenTry\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"createClient\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"recvPacket\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"portID\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"channelID\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"relayerAddr\",\"type\":\"address\"}],\"name\":\"registerCounterpartyPayee\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"portID\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"channelID\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"relayerAddr\",\"type\":\"address\"}],\"name\":\"registerPayee\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"submitMisbehaviour\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"timeout\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"timeoutOnClose\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"updateClient\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeClient\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"acknowledgement\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"channelCloseConfirm\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"channelCloseInit\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"channelOpenAck\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"channelOpenConfirm\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"channelOpenInit\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"channelOpenTry\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"connectionOpenAck\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"connectionOpenConfirm\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"connectionOpenInit\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"connectionOpenTry\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"createClient\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"recvPacket\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"portID\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"channelID\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"counterpartyPayeeAddr\",\"type\":\"string\"}],\"name\":\"registerCounterpartyPayee\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"portID\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"channelID\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"payeeAddr\",\"type\":\"address\"}],\"name\":\"registerPayee\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"submitMisbehaviour\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"timeout\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"timeoutOnClose\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"updateClient\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeClient\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"function\"}]", } // RelayerFunctionsABI is the input ABI used to generate the binding from. @@ -453,46 +453,46 @@ func (_RelayerFunctions *RelayerFunctionsTransactorSession) RecvPacket(data []by return _RelayerFunctions.Contract.RecvPacket(&_RelayerFunctions.TransactOpts, data) } -// RegisterCounterpartyPayee is a paid mutator transaction binding the contract method 0x5d3db16c. +// RegisterCounterpartyPayee is a paid mutator transaction binding the contract method 0x8e0bf32e. // -// Solidity: function registerCounterpartyPayee(string portID, string channelID, address relayerAddr) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactor) RegisterCounterpartyPayee(opts *bind.TransactOpts, portID string, channelID string, relayerAddr common.Address) (*types.Transaction, error) { - return _RelayerFunctions.contract.Transact(opts, "registerCounterpartyPayee", portID, channelID, relayerAddr) +// Solidity: function registerCounterpartyPayee(string portID, string channelID, string counterpartyPayeeAddr) payable returns(bool) +func (_RelayerFunctions *RelayerFunctionsTransactor) RegisterCounterpartyPayee(opts *bind.TransactOpts, portID string, channelID string, counterpartyPayeeAddr string) (*types.Transaction, error) { + return _RelayerFunctions.contract.Transact(opts, "registerCounterpartyPayee", portID, channelID, counterpartyPayeeAddr) } -// RegisterCounterpartyPayee is a paid mutator transaction binding the contract method 0x5d3db16c. +// RegisterCounterpartyPayee is a paid mutator transaction binding the contract method 0x8e0bf32e. // -// Solidity: function registerCounterpartyPayee(string portID, string channelID, address relayerAddr) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsSession) RegisterCounterpartyPayee(portID string, channelID string, relayerAddr common.Address) (*types.Transaction, error) { - return _RelayerFunctions.Contract.RegisterCounterpartyPayee(&_RelayerFunctions.TransactOpts, portID, channelID, relayerAddr) +// Solidity: function registerCounterpartyPayee(string portID, string channelID, string counterpartyPayeeAddr) payable returns(bool) +func (_RelayerFunctions *RelayerFunctionsSession) RegisterCounterpartyPayee(portID string, channelID string, counterpartyPayeeAddr string) (*types.Transaction, error) { + return _RelayerFunctions.Contract.RegisterCounterpartyPayee(&_RelayerFunctions.TransactOpts, portID, channelID, counterpartyPayeeAddr) } -// RegisterCounterpartyPayee is a paid mutator transaction binding the contract method 0x5d3db16c. +// RegisterCounterpartyPayee is a paid mutator transaction binding the contract method 0x8e0bf32e. // -// Solidity: function registerCounterpartyPayee(string portID, string channelID, address relayerAddr) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactorSession) RegisterCounterpartyPayee(portID string, channelID string, relayerAddr common.Address) (*types.Transaction, error) { - return _RelayerFunctions.Contract.RegisterCounterpartyPayee(&_RelayerFunctions.TransactOpts, portID, channelID, relayerAddr) +// Solidity: function registerCounterpartyPayee(string portID, string channelID, string counterpartyPayeeAddr) payable returns(bool) +func (_RelayerFunctions *RelayerFunctionsTransactorSession) RegisterCounterpartyPayee(portID string, channelID string, counterpartyPayeeAddr string) (*types.Transaction, error) { + return _RelayerFunctions.Contract.RegisterCounterpartyPayee(&_RelayerFunctions.TransactOpts, portID, channelID, counterpartyPayeeAddr) } // RegisterPayee is a paid mutator transaction binding the contract method 0xb0dff939. // -// Solidity: function registerPayee(string portID, string channelID, address relayerAddr) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactor) RegisterPayee(opts *bind.TransactOpts, portID string, channelID string, relayerAddr common.Address) (*types.Transaction, error) { - return _RelayerFunctions.contract.Transact(opts, "registerPayee", portID, channelID, relayerAddr) +// Solidity: function registerPayee(string portID, string channelID, address payeeAddr) payable returns(bool) +func (_RelayerFunctions *RelayerFunctionsTransactor) RegisterPayee(opts *bind.TransactOpts, portID string, channelID string, payeeAddr common.Address) (*types.Transaction, error) { + return _RelayerFunctions.contract.Transact(opts, "registerPayee", portID, channelID, payeeAddr) } // RegisterPayee is a paid mutator transaction binding the contract method 0xb0dff939. // -// Solidity: function registerPayee(string portID, string channelID, address relayerAddr) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsSession) RegisterPayee(portID string, channelID string, relayerAddr common.Address) (*types.Transaction, error) { - return _RelayerFunctions.Contract.RegisterPayee(&_RelayerFunctions.TransactOpts, portID, channelID, relayerAddr) +// Solidity: function registerPayee(string portID, string channelID, address payeeAddr) payable returns(bool) +func (_RelayerFunctions *RelayerFunctionsSession) RegisterPayee(portID string, channelID string, payeeAddr common.Address) (*types.Transaction, error) { + return _RelayerFunctions.Contract.RegisterPayee(&_RelayerFunctions.TransactOpts, portID, channelID, payeeAddr) } // RegisterPayee is a paid mutator transaction binding the contract method 0xb0dff939. // -// Solidity: function registerPayee(string portID, string channelID, address relayerAddr) payable returns(bool) -func (_RelayerFunctions *RelayerFunctionsTransactorSession) RegisterPayee(portID string, channelID string, relayerAddr common.Address) (*types.Transaction, error) { - return _RelayerFunctions.Contract.RegisterPayee(&_RelayerFunctions.TransactOpts, portID, channelID, relayerAddr) +// Solidity: function registerPayee(string portID, string channelID, address payeeAddr) payable returns(bool) +func (_RelayerFunctions *RelayerFunctionsTransactorSession) RegisterPayee(portID string, channelID string, payeeAddr common.Address) (*types.Transaction, error) { + return _RelayerFunctions.Contract.RegisterPayee(&_RelayerFunctions.TransactOpts, portID, channelID, payeeAddr) } // SubmitMisbehaviour is a paid mutator transaction binding the contract method 0xa53b1c82. diff --git a/x/cronos/events/bindings/src/RelayerFunctions.sol b/x/cronos/events/bindings/src/RelayerFunctions.sol index d3c76dda70..c413852aed 100644 --- a/x/cronos/events/bindings/src/RelayerFunctions.sol +++ b/x/cronos/events/bindings/src/RelayerFunctions.sol @@ -20,6 +20,6 @@ interface IRelayerFunctions { function acknowledgement(bytes calldata data) external payable returns (bytes calldata); function timeout(bytes calldata data) external payable returns (bytes calldata); function timeoutOnClose(bytes calldata data) external payable returns (bytes calldata); - function registerPayee(string calldata portID, string calldata channelID, address relayerAddr) external payable returns (bool); - function registerCounterpartyPayee(string calldata portID, string calldata channelID, address relayerAddr) external payable returns (bool); + function registerPayee(string calldata portID, string calldata channelID, address payeeAddr) external payable returns (bool); + function registerCounterpartyPayee(string calldata portID, string calldata channelID, string calldata counterpartyPayeeAddr) external payable returns (bool); } diff --git a/x/cronos/keeper/precompiles/relayer.go b/x/cronos/keeper/precompiles/relayer.go index 964b43f3ac..d946f13de2 100644 --- a/x/cronos/keeper/precompiles/relayer.go +++ b/x/cronos/keeper/precompiles/relayer.go @@ -50,7 +50,7 @@ const ( TimeoutOnClose = "timeoutOnClose" // ibc fee RegisterPayee = "registerPayee" - RsegisterCounterpartyPayee = "registerCounterpartyPayee" + RegisterCounterpartyPayee = "registerCounterpartyPayee" GasWhenReceiverChainIsSource = 51705 GasWhenReceiverChainIsNotSource = 144025 ) @@ -93,6 +93,8 @@ func init() { relayerGasRequiredByMethod[methodID] = 61781 case Timeout: relayerGasRequiredByMethod[methodID] = 104283 + case RegisterPayee, RegisterCounterpartyPayee: + relayerGasRequiredByMethod[methodID] = 40000 default: relayerGasRequiredByMethod[methodID] = 100000 } @@ -196,22 +198,23 @@ func (bc *RelayerContract) Run(evm *vm.EVM, contract *vm.Contract, readonly bool return nil, errors.New("fail to unpack input arguments") } converter := cronosevents.RelayerConvertEvent - if method.Name == RegisterPayee || method.Name == RsegisterCounterpartyPayee { + if method.Name == RegisterPayee || method.Name == RegisterCounterpartyPayee { execErr := stateDB.ExecuteNativeAction(precompileAddr, converter, func(ctx sdk.Context) error { portID := args[0].(string) channelID := args[1].(string) - relayerAddr := sdk.AccAddress(args[2].(common.Address).Bytes()).String() caller := sdk.AccAddress(contract.CallerAddress.Bytes()).String() if method.Name == RegisterPayee { + payeeAddr := sdk.AccAddress(args[2].(common.Address).Bytes()).String() _, err := bc.ibcFeeKeeper.RegisterPayee( ctx, - ibcfeetypes.NewMsgRegisterPayee(portID, channelID, caller, relayerAddr), + ibcfeetypes.NewMsgRegisterPayee(portID, channelID, caller, payeeAddr), ) return err } else { - _, err = bc.ibcFeeKeeper.RegisterCounterpartyPayee( + counterpartyPayeeAddr := args[2].(string) + _, err := bc.ibcFeeKeeper.RegisterCounterpartyPayee( ctx, - ibcfeetypes.NewMsgRegisterCounterpartyPayee(portID, channelID, caller, relayerAddr), + ibcfeetypes.NewMsgRegisterCounterpartyPayee(portID, channelID, caller, counterpartyPayeeAddr), ) return err } From fd25c0bc29f0a2a94cc8b0b1403ee7650ea1ea18 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Mon, 28 Oct 2024 10:05:43 +0800 Subject: [PATCH 4/4] fix test --- integration_tests/ibc_utils.py | 11 ++++++++++- integration_tests/test_ibc_rly.py | 11 +++++------ integration_tests/test_ibc_rly_gas.py | 2 +- x/cronos/keeper/precompiles/relayer.go | 6 ++++-- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/integration_tests/ibc_utils.py b/integration_tests/ibc_utils.py index e86f7c4500..fcb68c42f9 100644 --- a/integration_tests/ibc_utils.py +++ b/integration_tests/ibc_utils.py @@ -241,6 +241,15 @@ def register_fee_payee(src_chain, dst_chain, contract=None, acc=None): ) assert rsp["code"] == 0, rsp["raw_log"] if contract is None: + rsp = chains[0].register_payee( + port_id, + channel_id, + relayer0, + relayer0, + from_="signer1", + fees="100000000basetcro", + ) + assert rsp["code"] == 0, rsp["raw_log"] rsp = chains[0].register_counterparty_payee( port_id, channel_id, @@ -569,7 +578,7 @@ def check_balance_change(): return chains[0].balance(user0, base_denom0) != old_user0_base - amount wait_for_fn("balance change", check_balance_change) - return amount, packet_seq + return amount, packet_seq, recv_fee, ack_fee def ibc_denom(channel, denom): diff --git a/integration_tests/test_ibc_rly.py b/integration_tests/test_ibc_rly.py index 9697a1fa70..f40263a271 100644 --- a/integration_tests/test_ibc_rly.py +++ b/integration_tests/test_ibc_rly.py @@ -276,10 +276,9 @@ def test_ibc_incentivized_transfer(ibc): cli = ibc.cronos.cosmos_cli() wait_for_new_blocks(cli, 1) start = w3.eth.get_block_number() - amount, seq0 = ibc_incentivized_transfer(ibc) + amount, seq0, recv_fee, ack_fee = ibc_incentivized_transfer(ibc) logs = get_logs_since(w3, CONTRACT, start) fee_denom = "ibcfee" - fee = f"{src_amount}{fee_denom}" transfer_denom = "transfer/channel-0/basetcro" dst_adr = ibc.chainmain.cosmos_cli().address("signer2") src_relayer = ADDRS["signer1"] @@ -289,10 +288,10 @@ def test_ibc_incentivized_transfer(ibc): seq1 = get_send_packet_seq(ibc.chainmain.cosmos_cli()) expected = [ acknowledge_packet(seq0), - distribute_fee(src_relayer, fee), - *send_coins(feeibc_addr, src_relayer, src_amount, fee_denom), - distribute_fee(src_relayer, fee), - *send_coins(feeibc_addr, src_relayer, src_amount, fee_denom), + distribute_fee(src_relayer, f"{recv_fee}{fee_denom}"), + *send_coins(feeibc_addr, src_relayer, recv_fee, fee_denom), + distribute_fee(src_relayer, f"{ack_fee}{fee_denom}"), + *send_coins(feeibc_addr, src_relayer, ack_fee, fee_denom), distribute_fee(cronos_signer2, ""), *send_coins(feeibc_addr, cronos_signer2, 0, fee_denom), fungible(checksum_dst_adr, cronos_signer2, amount, dst_denom), diff --git a/integration_tests/test_ibc_rly_gas.py b/integration_tests/test_ibc_rly_gas.py index 24ba5b89f4..8b3c7486c4 100644 --- a/integration_tests/test_ibc_rly_gas.py +++ b/integration_tests/test_ibc_rly_gas.py @@ -30,7 +30,7 @@ def test_ibc(ibc): ibc_transfer(ibc) ibc_incentivized_transfer(ibc) ibc_multi_transfer(ibc) - diff = 0.1 + diff = 0.15 record = log_gas_records(cli) if record: records.append(record) diff --git a/x/cronos/keeper/precompiles/relayer.go b/x/cronos/keeper/precompiles/relayer.go index d946f13de2..84413057b7 100644 --- a/x/cronos/keeper/precompiles/relayer.go +++ b/x/cronos/keeper/precompiles/relayer.go @@ -93,8 +93,10 @@ func init() { relayerGasRequiredByMethod[methodID] = 61781 case Timeout: relayerGasRequiredByMethod[methodID] = 104283 - case RegisterPayee, RegisterCounterpartyPayee: - relayerGasRequiredByMethod[methodID] = 40000 + case RegisterPayee: + relayerGasRequiredByMethod[methodID] = 38000 + case RegisterCounterpartyPayee: + relayerGasRequiredByMethod[methodID] = 37000 default: relayerGasRequiredByMethod[methodID] = 100000 }