Skip to content

Commit

Permalink
set origin signer
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Oct 24, 2024
1 parent 4a0f383 commit 64876e2
Show file tree
Hide file tree
Showing 7 changed files with 254 additions and 539 deletions.
2 changes: 1 addition & 1 deletion integration_tests/ibc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def get_balances(chain, addr):

def ibc_multi_transfer(ibc):
chains = [ibc.cronos.cosmos_cli(), ibc.chainmain.cosmos_cli()]
users = [f"user{i}" for i in range(1, 51)]
users = [f"user{i}" for i in range(1, 1)]
addrs0 = [chains[0].address(user) for user in users]
addrs1 = [chains[1].address(user) for user in users]
denom0 = "basetcro"
Expand Down
5 changes: 3 additions & 2 deletions integration_tests/test_ibc_rly.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
ibc_multi_transfer,
ibc_transfer,
prepare_network,
rly_transfer,
)
from .utils import (
ADDRS,
Expand Down Expand Up @@ -51,7 +52,7 @@ def ibc(request, tmp_path_factory):
yield from prepare_network(
path,
name,
relayer=cluster.Relayer.HERMES.value,
relayer=cluster.Relayer.RLY.value,
)


Expand Down Expand Up @@ -235,7 +236,7 @@ def test_ibc(ibc):
w3 = ibc.cronos.w3
wait_for_new_blocks(ibc.cronos.cosmos_cli(), 1)
start = w3.eth.get_block_number()
ibc_transfer(ibc)
ibc_transfer(ibc, rly_transfer)
denom = ibc_denom(channel, src_denom)
logs = get_logs_since(w3, CONTRACT, start)
chainmain_cli = ibc.chainmain.cosmos_cli()
Expand Down
5 changes: 3 additions & 2 deletions integration_tests/test_ibc_rly_gas.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
ibc_transfer,
log_gas_records,
prepare_network,
rly_transfer,
)
from .utils import wait_for_new_blocks

Expand All @@ -18,7 +19,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, relayer=cluster.Relayer.RLY.value)


records = []
Expand All @@ -28,7 +29,7 @@ def test_ibc(ibc):
# chainmain-1 relayer -> cronos_777-1 signer2
cli = ibc.cronos.cosmos_cli()
wait_for_new_blocks(cli, 1)
ibc_transfer(ibc)
ibc_transfer(ibc, rly_transfer)
ibc_incentivized_transfer(ibc)
ibc_multi_transfer(ibc)
diff = 0.1
Expand Down
6 changes: 3 additions & 3 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@
"homepage": "https://github.com/crypto-org-chain/relayer",
"owner": "crypto-org-chain",
"repo": "relayer",
"rev": "fe5722292a9961e80818e3ef5c987330b538bc05",
"sha256": "0jv4pkrqhckbabxxxbr0bcil0fakbnc7sf22k2wa5q6v6921ci0y",
"rev": "a7139118e7204a80e5c277a84a91be2bb8884147",
"sha256": "sha256:1ps8lyh3v0zbwb6dilrn009iwkyck73p17mc0a75w806f1wsxzmn",
"type": "tarball",
"url": "https://github.com/crypto-org-chain/relayer/archive/fe5722292a9961e80818e3ef5c987330b538bc05.tar.gz",
"url": "https://github.com/mmsqe/relayer/archive/a7139118e7204a80e5c277a84a91be2bb8884147.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}

Large diffs are not rendered by default.

49 changes: 18 additions & 31 deletions x/cronos/events/bindings/src/RelayerFunctions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,22 @@
pragma solidity ^0.8.4;

interface IRelayerFunctions {
function createClient(bytes calldata data) external payable returns (bytes calldata);
function updateClient(bytes calldata data) external payable returns (bytes calldata);
function upgradeClient(bytes calldata data) external payable returns (bytes calldata);
function submitMisbehaviour(bytes calldata data) external payable returns (bytes calldata);
function connectionOpenInit(bytes calldata data) external payable returns (bytes calldata);
function connectionOpenTry(bytes calldata data) external payable returns (bytes calldata);
function connectionOpenAck(bytes calldata data) external payable returns (bytes calldata);
function connectionOpenConfirm(bytes calldata data) external payable returns (bytes calldata);
function channelOpenInit(bytes calldata data) external payable returns (bytes calldata);
function channelOpenTry(bytes calldata data) external payable returns (bytes calldata);
function channelOpenAck(bytes calldata data) external payable returns (bytes calldata);
function channelOpenConfirm(bytes calldata data) external payable returns (bytes calldata);
function channelCloseInit(bytes calldata data) external payable returns (bytes calldata);
function channelCloseConfirm(bytes calldata data) external payable returns (bytes calldata);
function recvPacket(bytes calldata data) external payable returns (bytes calldata);
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 createClient(address signer, bytes calldata data) external payable returns (bytes calldata);
function updateClient(address signer, bytes calldata data) external payable returns (bytes calldata);
function upgradeClient(address signer, bytes calldata data) external payable returns (bytes calldata);
function submitMisbehaviour(address signer, bytes calldata data) external payable returns (bytes calldata);
function connectionOpenInit(address signer, bytes calldata data) external payable returns (bytes calldata);
function connectionOpenTry(address signer, bytes calldata data) external payable returns (bytes calldata);
function connectionOpenAck(address signer, bytes calldata data) external payable returns (bytes calldata);
function connectionOpenConfirm(address signer, bytes calldata data) external payable returns (bytes calldata);
function channelOpenInit(address signer, bytes calldata data) external payable returns (bytes calldata);
function channelOpenTry(address signer, bytes calldata data) external payable returns (bytes calldata);
function channelOpenAck(address signer, bytes calldata data) external payable returns (bytes calldata);
function channelOpenConfirm(address signer, bytes calldata data) external payable returns (bytes calldata);
function channelCloseInit(address signer, bytes calldata data) external payable returns (bytes calldata);
function channelCloseConfirm(address signer, bytes calldata data) external payable returns (bytes calldata);
function recvPacket(address signer, bytes calldata data) external payable returns (bytes calldata);
function acknowledgement(address signer, bytes calldata data) external payable returns (bytes calldata);
function timeout(address signer, bytes calldata data) external payable returns (bytes calldata);
function timeoutOnClose(address signer, bytes calldata data) external payable returns (bytes calldata);
}
19 changes: 9 additions & 10 deletions x/cronos/keeper/precompiles/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ import (

"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"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/params"

errorsmod "cosmossdk.io/errors"
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"
Expand Down Expand Up @@ -144,7 +143,7 @@ func (bc *RelayerContract) RequiredGas(input []byte) (gas uint64) {
if err != nil {
panic(err)
}
i := args[0].([]byte)
i := args[1].([]byte)
var msg channeltypes.MsgRecvPacket
if err = bc.cdc.Unmarshal(i, &msg); err != nil {
panic(err)
Expand Down Expand Up @@ -193,7 +192,8 @@ 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)
signer := args[0].(common.Address)
input := args[1].([]byte)
converter := cronosevents.RelayerConvertEvent
e := &Executor{
cdc: bc.cdc,
Expand Down Expand Up @@ -234,15 +234,14 @@ func (bc *RelayerContract) Run(evm *vm.EVM, contract *vm.Contract, readonly bool
res, err = exec(e, bc.ibcKeeper.RecvPacket)
case Acknowledgement:
res, err = exec(e, func(goCtx context.Context, msg *channeltypes.MsgAcknowledgement) (*channeltypes.MsgAcknowledgementResponse, error) {
var ack ibcfeetypes.IncentivizedAcknowledgement
if err := ibcfeetypes.ModuleCdc.UnmarshalJSON(msg.Acknowledgement, &ack); err != nil {
return nil, errorsmod.Wrapf(err, "cannot unmarshal ICS-29 incentivized packet acknowledgement: %v", ack)
}
msg.Signer = ack.ForwardRelayerAddress
msg.Signer = sdk.AccAddress(signer.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(signer.Bytes()).String()
return bc.ibcKeeper.Timeout(goCtx, msg)
})
case TimeoutOnClose:
res, err = exec(e, bc.ibcKeeper.TimeoutOnClose)
default:
Expand Down

0 comments on commit 64876e2

Please sign in to comment.