Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: ibc keeper interface is not used in relayer precompile #1219

Merged
merged 2 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integration_tests/configs/ibc_rly.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local ibc = import 'ibc.jsonnet';
ibc {
relayer+: {
chains: [super.chains[0] {
'precompiled_contract_address': '0x0000000000000000000000000000000000000065',
precompiled_contract_address: '0x0000000000000000000000000000000000000065',
}] + super.chains[1:],
},
}
17 changes: 3 additions & 14 deletions integration_tests/ibc_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import hashlib
import json
import os
import subprocess
from contextlib import contextmanager
from pathlib import Path
Expand Down Expand Up @@ -83,12 +82,12 @@ def call_hermes_cmd(
)


def call_rly_cmd(path, connection_only, version):
def call_rly_cmd(path, connection_only, version, hostchain="chainmain-1"):
cmd = [
"rly",
"pth",
"new",
"chainmain-1",
hostchain,
"cronos_777-1",
"chainmain-cronos",
"--home",
Expand Down Expand Up @@ -179,20 +178,10 @@ def prepare_network(

port = None
if is_relay:
cronos.supervisorctl("start", "relayer-demo")
if is_hermes:
cronos.supervisorctl("start", "relayer-demo")
port = hermes.port
else:
subprocess.Popen(
[
"rly",
"start",
"chainmain-cronos",
"--home",
str(path),
],
preexec_fn=os.setsid,
)
port = 5183
yield IBCNetwork(cronos, chainmain, hermes, incentivized)
if port:
Expand Down
6 changes: 3 additions & 3 deletions x/cronos/keeper/precompiles/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/vm"

ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
cronosevents "github.com/crypto-org-chain/cronos/v2/x/cronos/events"
"github.com/crypto-org-chain/cronos/v2/x/cronos/types"
)

var (
Expand Down Expand Up @@ -42,11 +42,11 @@ type RelayerContract struct {
BaseContract

cdc codec.Codec
ibcKeeper *ibckeeper.Keeper
ibcKeeper types.IbcKeeper
kvGasConfig storetypes.GasConfig
}

func NewRelayerContract(ibcKeeper *ibckeeper.Keeper, cdc codec.Codec, kvGasConfig storetypes.GasConfig) vm.PrecompiledContract {
func NewRelayerContract(ibcKeeper types.IbcKeeper, cdc codec.Codec, kvGasConfig storetypes.GasConfig) vm.PrecompiledContract {
return &RelayerContract{
BaseContract: NewBaseContract(relayerContractAddress),
ibcKeeper: ibcKeeper,
Expand Down
24 changes: 24 additions & 0 deletions x/cronos/types/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import (
"github.com/ethereum/go-ethereum/params"
evmtypes "github.com/evmos/ethermint/x/evm/types"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v2/x/gravity/types"

clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types"
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
)

// BankKeeper defines the expected interface needed to retrieve account balances.
Expand Down Expand Up @@ -90,3 +94,23 @@ type Icaauthkeeper interface {
type CronosKeeper interface {
CallEVM(ctx sdk.Context, to *common.Address, data []byte, value *big.Int, gasLimit uint64) (*ethtypes.Message, *evmtypes.MsgEthereumTxResponse, error)
}

// IbcKeeper defines the interface for ibc keeper
type IbcKeeper interface {
CreateClient(goCtx context.Context, msg *clienttypes.MsgCreateClient) (*clienttypes.MsgCreateClientResponse, error)
UpdateClient(goCtx context.Context, msg *clienttypes.MsgUpdateClient) (*clienttypes.MsgUpdateClientResponse, error)
UpgradeClient(goCtx context.Context, msg *clienttypes.MsgUpgradeClient) (*clienttypes.MsgUpgradeClientResponse, error)
SubmitMisbehaviour(goCtx context.Context, msg *clienttypes.MsgSubmitMisbehaviour) (*clienttypes.MsgSubmitMisbehaviourResponse, error)
ConnectionOpenInit(goCtx context.Context, msg *connectiontypes.MsgConnectionOpenInit) (*connectiontypes.MsgConnectionOpenInitResponse, error)
ConnectionOpenTry(goCtx context.Context, msg *connectiontypes.MsgConnectionOpenTry) (*connectiontypes.MsgConnectionOpenTryResponse, error)
ConnectionOpenAck(goCtx context.Context, msg *connectiontypes.MsgConnectionOpenAck) (*connectiontypes.MsgConnectionOpenAckResponse, error)
ConnectionOpenConfirm(goCtx context.Context, msg *connectiontypes.MsgConnectionOpenConfirm) (*connectiontypes.MsgConnectionOpenConfirmResponse, error)
ChannelOpenInit(goCtx context.Context, msg *channeltypes.MsgChannelOpenInit) (*channeltypes.MsgChannelOpenInitResponse, error)
ChannelOpenTry(goCtx context.Context, msg *channeltypes.MsgChannelOpenTry) (*channeltypes.MsgChannelOpenTryResponse, error)
ChannelOpenAck(goCtx context.Context, msg *channeltypes.MsgChannelOpenAck) (*channeltypes.MsgChannelOpenAckResponse, error)
ChannelOpenConfirm(goCtx context.Context, msg *channeltypes.MsgChannelOpenConfirm) (*channeltypes.MsgChannelOpenConfirmResponse, error)
RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPacket) (*channeltypes.MsgRecvPacketResponse, error)
Acknowledgement(goCtx context.Context, msg *channeltypes.MsgAcknowledgement) (*channeltypes.MsgAcknowledgementResponse, error)
Timeout(goCtx context.Context, msg *channeltypes.MsgTimeout) (*channeltypes.MsgTimeoutResponse, error)
TimeoutOnClose(goCtx context.Context, msg *channeltypes.MsgTimeoutOnClose) (*channeltypes.MsgTimeoutOnCloseResponse, error)
}