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

Update ibc-go to v8 #134

Merged
merged 19 commits into from
Apr 2, 2024
Merged
21 changes: 9 additions & 12 deletions chains/tendermint/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authTypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/go-bip39"
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"

"github.com/hyperledger-labs/yui-relayer/core"
"github.com/hyperledger-labs/yui-relayer/log"
Expand Down Expand Up @@ -230,7 +230,7 @@ func (c *Chain) rawSendMsgs(msgs []sdk.Msg) (*sdk.TxResponse, bool, error) {
}

// Attach the signature to the transaction
err = tx.Sign(txf, c.config.Key, txb, false)
err = tx.Sign(context.TODO(), txf, c.config.Key, txb, false)
if err != nil {
return nil, false, err
}
Expand Down Expand Up @@ -447,14 +447,8 @@ func (c *Chain) GetMsgResult(id core.MsgID) (core.MsgResult, error) {
}, nil
}

// parse the log into ABCI logs
abciLogs, err := sdk.ParseABCILogs(resTx.TxResult.Log)
if err != nil {
return nil, fmt.Errorf("failed to parse ABCI logs: %v", err)
}

// parse the ABCI logs into core.MsgEventLog's
events, err := parseMsgEventLogs(abciLogs, msgID.MsgIndex)
// parse the abci.types.Events into core.MsgEventLog's
events, err := parseMsgEventLogs(resTx.TxResult.Events, msgID.MsgIndex)
if err != nil {
return nil, fmt.Errorf("failed to parse msg event log: %v", err)
}
Expand Down Expand Up @@ -514,11 +508,14 @@ func (c *Chain) UseSDKContext() func() {

// CLIContext returns an instance of client.Context derived from Chain
func (c *Chain) CLIContext(height int64) sdkCtx.Context {
unlock := c.UseSDKContext()
txConfig := authtx.NewTxConfig(c.codec, authtx.DefaultSignModes)
unlock()
return sdkCtx.Context{}.
WithChainID(c.config.ChainId).
WithCodec(c.codec).
WithInterfaceRegistry(c.codec.InterfaceRegistry()).
WithTxConfig(authtx.NewTxConfig(c.codec, authtx.DefaultSignModes)).
WithTxConfig(txConfig).
WithInput(os.Stdin).
WithNodeURI(c.config.RpcAddr).
WithClient(c.Client).
Expand Down
6 changes: 3 additions & 3 deletions chains/tendermint/client-tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"time"

"github.com/cometbft/cometbft/light"
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
commitmenttypes "github.com/cosmos/ibc-go/v7/modules/core/23-commitment/types"
tmclient "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types"
tmclient "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
)

func createClient(
Expand Down
2 changes: 1 addition & 1 deletion chains/tendermint/cmd/light.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strconv"

"github.com/cosmos/cosmos-sdk/client/flags"
tmclient "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
tmclient "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
"github.com/hyperledger-labs/yui-relayer/chains/tendermint"
"github.com/hyperledger-labs/yui-relayer/config"
"github.com/spf13/cobra"
Expand Down
2 changes: 1 addition & 1 deletion chains/tendermint/light.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
lighthttp "github.com/cometbft/cometbft/light/provider/http"
dbs "github.com/cometbft/cometbft/light/store/db"
tmtypes "github.com/cometbft/cometbft/types"
tmclient "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
tmclient "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
)

// NOTE: currently we are discarding the very noisy light client logs
Expand Down
54 changes: 35 additions & 19 deletions chains/tendermint/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"strconv"
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
conntypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types"
chantypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
abcitypes "github.com/cometbft/cometbft/abci/types"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
conntypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types"
chantypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
"github.com/hyperledger-labs/yui-relayer/core"
)

Expand All @@ -19,6 +19,10 @@ var (
_ core.MsgResult = (*MsgResult)(nil)
)

const (
MsgIndexAttributeKey = "msg_index"
)

func (*MsgID) Is_MsgID() {}

type MsgResult struct {
Expand All @@ -44,23 +48,35 @@ func (r *MsgResult) Events() []core.MsgEventLog {
return r.events
}

func parseMsgEventLogs(logs sdk.ABCIMessageLogs, msgIndex uint32) ([]core.MsgEventLog, error) {
func parseMsgEventLogs(events []abcitypes.Event, msgIndex uint32) ([]core.MsgEventLog, error) {
var msgEventLogs []core.MsgEventLog
for _, log := range logs {
if msgIndex == log.MsgIndex {
for _, ev := range log.Events {
event, err := parseMsgEventLog(ev)
if err != nil {
return nil, fmt.Errorf("failed to parse msg event log: %v", err)
}
msgEventLogs = append(msgEventLogs, event)
for _, ev := range events {
index, err := msgIndexOf(ev)
if err == nil && index == msgIndex {
event, err := parseMsgEventLog(ev)
if err != nil {
return nil, fmt.Errorf("failed to parse msg event log: %v", err)
}
msgEventLogs = append(msgEventLogs, event)
}
}
return msgEventLogs, nil
}

func parseMsgEventLog(ev sdk.StringEvent) (core.MsgEventLog, error) {
func msgIndexOf(event abcitypes.Event) (uint32, error) {
for _, attr := range event.Attributes {
if attr.Key == MsgIndexAttributeKey {
intValue, err := strconv.ParseUint(attr.Value, 10, 32)
if err != nil {
return 0, fmt.Errorf("failed to parse value: %v", err)
}
return uint32(intValue), nil
}
}
return 0, fmt.Errorf("failed to find attribute of key %q", MsgIndexAttributeKey)
}

func parseMsgEventLog(ev abcitypes.Event) (core.MsgEventLog, error) {
switch ev.Type {
case clienttypes.EventTypeCreateClient:
clientID, err := getAttributeString(ev, clienttypes.AttributeKeyClientID)
Expand Down Expand Up @@ -134,7 +150,7 @@ func parseMsgEventLog(ev sdk.StringEvent) (core.MsgEventLog, error) {
}
}

func getAttributeString(ev sdk.StringEvent, key string) (string, error) {
func getAttributeString(ev abcitypes.Event, key string) (string, error) {
for _, attr := range ev.Attributes {
if attr.Key == key {
return attr.Value, nil
Expand All @@ -143,7 +159,7 @@ func getAttributeString(ev sdk.StringEvent, key string) (string, error) {
return "", fmt.Errorf("failed to find attribute of key %q", key)
}

func getAttributeBytes(ev sdk.StringEvent, key string) ([]byte, error) {
func getAttributeBytes(ev abcitypes.Event, key string) ([]byte, error) {
v, err := getAttributeString(ev, key)
if err != nil {
return nil, err
Expand All @@ -155,7 +171,7 @@ func getAttributeBytes(ev sdk.StringEvent, key string) ([]byte, error) {
return bz, nil
}

func getAttributeHeight(ev sdk.StringEvent, key string) (clienttypes.Height, error) {
func getAttributeHeight(ev abcitypes.Event, key string) (clienttypes.Height, error) {
v, err := getAttributeString(ev, key)
if err != nil {
return clienttypes.Height{}, err
Expand All @@ -167,7 +183,7 @@ func getAttributeHeight(ev sdk.StringEvent, key string) (clienttypes.Height, err
return height, nil
}

func getAttributeUint64(ev sdk.StringEvent, key string) (uint64, error) {
func getAttributeUint64(ev abcitypes.Event, key string) (uint64, error) {
v, err := getAttributeString(ev, key)
if err != nil {
return 0, err
Expand All @@ -179,7 +195,7 @@ func getAttributeUint64(ev sdk.StringEvent, key string) (uint64, error) {
return d, nil
}

func getAttributeTimestamp(ev sdk.StringEvent, key string) (time.Time, error) {
func getAttributeTimestamp(ev abcitypes.Event, key string) (time.Time, error) {
d, err := getAttributeUint64(ev, key)
if err != nil {
return time.Time{}, err
Expand Down
8 changes: 4 additions & 4 deletions chains/tendermint/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
"github.com/cometbft/cometbft/types"
tmtypes "github.com/cometbft/cometbft/types"
"github.com/cosmos/cosmos-sdk/codec"
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
ibcclient "github.com/cosmos/ibc-go/v7/modules/core/client"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
tmclient "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
ibcclient "github.com/cosmos/ibc-go/v8/modules/core/client"
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
tmclient "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"

"github.com/hyperledger-labs/yui-relayer/core"
)
Expand Down
22 changes: 11 additions & 11 deletions chains/tendermint/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ import (
querytypes "github.com/cosmos/cosmos-sdk/types/query"
bankTypes "github.com/cosmos/cosmos-sdk/x/bank/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
clientutils "github.com/cosmos/ibc-go/v7/modules/core/02-client/client/utils"
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
connutils "github.com/cosmos/ibc-go/v7/modules/core/03-connection/client/utils"
conntypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types"
chanutils "github.com/cosmos/ibc-go/v7/modules/core/04-channel/client/utils"
chantypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
committypes "github.com/cosmos/ibc-go/v7/modules/core/23-commitment/types"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
clientutils "github.com/cosmos/ibc-go/v8/modules/core/02-client/client/utils"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
connutils "github.com/cosmos/ibc-go/v8/modules/core/03-connection/client/utils"
conntypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types"
chanutils "github.com/cosmos/ibc-go/v8/modules/core/04-channel/client/utils"
chantypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
committypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types"
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
"github.com/hyperledger-labs/yui-relayer/core"
)

Expand Down Expand Up @@ -121,7 +121,7 @@ func (c *Chain) QueryBalance(ctx core.QueryContext, addr sdk.AccAddress) (sdk.Co
Offset: 0,
Limit: 1000,
CountTotal: true,
})
}, true)

queryClient := bankTypes.NewQueryClient(c.CLIContext(0))

Expand Down Expand Up @@ -414,7 +414,7 @@ func (c *Chain) QueryValsetAtHeight(height clienttypes.Height) (*tmproto.Validat
return protoValSet, err
}

func (c *Chain) toTmValidators(vals stakingtypes.Validators) ([]*tmtypes.Validator, error) {
func (c *Chain) toTmValidators(vals []stakingtypes.Validator) ([]*tmtypes.Validator, error) {
validators := make([]*tmtypes.Validator, len(vals))
var err error
for i, val := range vals {
Expand Down
4 changes: 2 additions & 2 deletions cmd/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

"github.com/cosmos/cosmos-sdk/client/flags"
sdk "github.com/cosmos/cosmos-sdk/types"
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
"github.com/hyperledger-labs/yui-relayer/config"
"github.com/hyperledger-labs/yui-relayer/core"
"github.com/hyperledger-labs/yui-relayer/helpers"
Expand Down
4 changes: 2 additions & 2 deletions cmd/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"strings"

"github.com/cosmos/cosmos-sdk/client/flags"
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
"github.com/cosmos/ibc-go/v7/modules/core/exported"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
"github.com/cosmos/ibc-go/v8/modules/core/exported"
"github.com/hyperledger-labs/yui-relayer/config"
"github.com/hyperledger-labs/yui-relayer/core"
"github.com/spf13/cobra"
Expand Down
2 changes: 1 addition & 1 deletion cmd/xfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
"github.com/hyperledger-labs/yui-relayer/config"
"github.com/hyperledger-labs/yui-relayer/core"
"github.com/spf13/cobra"
Expand Down
10 changes: 5 additions & 5 deletions core/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (

"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
conntypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types"
chantypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
conntypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types"
chantypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
"github.com/hyperledger-labs/yui-relayer/log"
)

Expand Down
2 changes: 1 addition & 1 deletion core/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"

retry "github.com/avast/retry-go"
chantypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
chantypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
"github.com/hyperledger-labs/yui-relayer/log"
"golang.org/x/exp/slog"
)
Expand Down
4 changes: 2 additions & 2 deletions core/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
"github.com/cosmos/ibc-go/v7/modules/core/exported"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
"github.com/cosmos/ibc-go/v8/modules/core/exported"
"github.com/hyperledger-labs/yui-relayer/log"
)

Expand Down
15 changes: 6 additions & 9 deletions core/codec.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package core

import (
"cosmossdk.io/x/evidence"
"cosmossdk.io/x/upgrade"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/std"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
"github.com/cosmos/cosmos-sdk/x/bank"
"github.com/cosmos/cosmos-sdk/x/capability"
"github.com/cosmos/cosmos-sdk/x/crisis"
distr "github.com/cosmos/cosmos-sdk/x/distribution"
"github.com/cosmos/cosmos-sdk/x/evidence"
"github.com/cosmos/cosmos-sdk/x/genutil"
"github.com/cosmos/cosmos-sdk/x/gov"
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
Expand All @@ -20,11 +20,10 @@ import (
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
"github.com/cosmos/cosmos-sdk/x/slashing"
"github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/cosmos-sdk/x/upgrade"
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
transfer "github.com/cosmos/ibc-go/v7/modules/apps/transfer"
ibc "github.com/cosmos/ibc-go/v7/modules/core"
tmclient "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
"github.com/cosmos/ibc-go/modules/capability"
transfer "github.com/cosmos/ibc-go/v8/modules/apps/transfer"
ibc "github.com/cosmos/ibc-go/v8/modules/core"
tmclient "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
)

var moduleBasics = module.NewBasicManager(
Expand All @@ -38,8 +37,6 @@ var moduleBasics = module.NewBasicManager(
gov.NewAppModuleBasic(
[]govclient.ProposalHandler{
paramsclient.ProposalHandler,
upgradeclient.LegacyProposalHandler,
upgradeclient.LegacyCancelProposalHandler,
},
),
params.AppModuleBasic{},
Expand Down
6 changes: 3 additions & 3 deletions core/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (

retry "github.com/avast/retry-go"
sdk "github.com/cosmos/cosmos-sdk/types"
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
conntypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
conntypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types"
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
"github.com/hyperledger-labs/yui-relayer/log"
"golang.org/x/exp/slog"
)
Expand Down
2 changes: 1 addition & 1 deletion core/headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

"github.com/cosmos/ibc-go/v7/modules/core/exported"
"github.com/cosmos/ibc-go/v8/modules/core/exported"
"github.com/hyperledger-labs/yui-relayer/metrics"
"go.opentelemetry.io/otel/attribute"
)
Expand Down
Loading
Loading