Skip to content

Commit

Permalink
Problem: not payee set for relayer caller (#1654)
Browse files Browse the repository at this point in the history
* Problem: not payee set for relayer caller

* rm timeout

* reset signer

* set origin signer

* Revert "set origin signer"

This reverts commit 64876e2.

* set back origin signer

* cleanup
  • Loading branch information
mmsqe authored Oct 25, 2024
1 parent b17faf9 commit 7dd3362
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* (testground)[1649](https://github.com/crypto-org-chain/cronos/pull/1649) Fix running single validator benchmark locally.
* (cli)[#1647](https://github.com/crypto-org-chain/cronos/pull/1647) Fix node can't shutdown by signal.
* (testground)[#1652](https://github.com/crypto-org-chain/cronos/pull/1652) Remove unexpected conflicts in benchmark transactions.
* [#1654](https://github.com/crypto-org-chain/cronos/pull/1654) Set relayer as payee for relayer caller when enabled incentivized packet.
* [#1655](https://github.com/crypto-org-chain/cronos/pull/1655) Fix state overwrite in debug trace APIs.
* [#1663](https://github.com/crypto-org-chain/cronos/pull/1663) Align attributes for ibc timeout event.

Expand Down
22 changes: 12 additions & 10 deletions integration_tests/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,9 +601,12 @@ def combine_batch_multisig_tx(
def broadcast_tx(self, tx_file, **kwargs):
kwargs.setdefault("broadcast_mode", "sync")
kwargs.setdefault("output", "json")
return json.loads(
rsp = json.loads(
self.raw("tx", "broadcast", tx_file, node=self.node_rpc, **kwargs)
)
if rsp["code"] == 0:
rsp = self.event_query_tx_for(rsp["txhash"])
return rsp

def broadcast_tx_json(self, tx, **kwargs):
with tempfile.NamedTemporaryFile("w") as fp:
Expand Down Expand Up @@ -1612,10 +1615,7 @@ def register_counterparty_payee(
return rsp

def register_payee(self, port_id, channel_id, relayer, payee, **kwargs):
default_kwargs = {
"home": self.data_dir,
}
return json.loads(
rsp = json.loads(
self.raw(
"tx",
"ibc-fee",
Expand All @@ -1625,14 +1625,15 @@ def register_payee(self, port_id, channel_id, relayer, payee, **kwargs):
relayer,
payee,
"-y",
**(default_kwargs | kwargs),
home=self.data_dir,
**kwargs,
)
)
if rsp["code"] == 0:
rsp = self.event_query_tx_for(rsp["txhash"])
return rsp

def pay_packet_fee(self, port_id, channel_id, packet_seq, **kwargs):
default_kwargs = {
"home": self.data_dir,
}
rsp = json.loads(
self.raw(
"tx",
Expand All @@ -1642,7 +1643,8 @@ def pay_packet_fee(self, port_id, channel_id, packet_seq, **kwargs):
channel_id,
str(packet_seq),
"-y",
**(default_kwargs | kwargs),
home=self.data_dir,
**kwargs,
)
)
if rsp["code"] == 0:
Expand Down
5 changes: 2 additions & 3 deletions integration_tests/test_ibc_rly.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from .ibc_utils import (
RATIO,
RELAYER_CALLER,
assert_duplicate,
cronos_transfer_source_tokens,
cronos_transfer_source_tokens_with_proxy,
Expand Down Expand Up @@ -293,8 +292,8 @@ def test_ibc_incentivized_transfer(ibc):
acknowledge_packet(seq0),
distribute_fee(src_relayer, fee),
*send_coins(feeibc_addr, src_relayer, src_amount, fee_denom),
distribute_fee(RELAYER_CALLER, fee),
*send_coins(feeibc_addr, RELAYER_CALLER, src_amount, fee_denom),
distribute_fee(src_relayer, fee),
*send_coins(feeibc_addr, src_relayer, src_amount, fee_denom),
distribute_fee(cronos_signer2, ""),
*send_coins(feeibc_addr, cronos_signer2, 0, fee_denom),
fungible(checksum_dst_adr, cronos_signer2, amount, dst_denom),
Expand Down
13 changes: 10 additions & 3 deletions x/cronos/keeper/precompiles/relayer.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package precompiles

import (
"context"
"errors"
"fmt"

"cosmossdk.io/log"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
Expand Down Expand Up @@ -183,7 +185,6 @@ func (bc *RelayerContract) Run(evm *vm.EVM, contract *vm.Contract, readonly bool
return nil, err
}
stateDB := evm.StateDB.(ExtStateDB)

var res []byte
precompileAddr := bc.Address()
args, err := method.Inputs.Unpack(contract.Input[4:])
Expand Down Expand Up @@ -230,9 +231,15 @@ 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, bc.ibcKeeper.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)
})
case Timeout:
res, err = exec(e, bc.ibcKeeper.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)
})
case TimeoutOnClose:
res, err = exec(e, bc.ibcKeeper.TimeoutOnClose)
default:
Expand Down

0 comments on commit 7dd3362

Please sign in to comment.