Skip to content

Commit

Permalink
Merge pull request #74 from hyperledger-labs/ibc-v4
Browse files Browse the repository at this point in the history
Release v0.3: update ibc-go to v4.0.0

Signed-off-by: Jun Kimura <jun.kimura@datachain.jp>
  • Loading branch information
bluele authored Nov 16, 2022
2 parents 04879cc + cffbe7b commit 524e041
Show file tree
Hide file tree
Showing 51 changed files with 2,929 additions and 2,247 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
build/
.vscode/
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ The Relayer uses "vX.Y.Z" as its version format. "v0.Y.Z" will be used until the

In addition, "Y" corresponds to the specific major version of ibc-go (i.e., "X"). The following table shows the Relayer version and its corresponding ibc-go version.

| Relayer | ibc-go |
|---------|--------------|
| v0.2.0 | v1.0.0-beta1 |

| Relayer | ibc-go |
|-------------------------------------------------------------------------------|--------------|
| v0.3.0(current branch) | v4.0.0 |
| [v0.2.0](https://github.com/hyperledger-labs/yui-relayer/releases/tag/v0.2.0) | v1.0.0-beta1 |

## Glossary

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"

sdk "github.com/cosmos/cosmos-sdk/types"
clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types"
commitmenttypes "github.com/cosmos/ibc-go/modules/core/23-commitment/types"
tmclient "github.com/cosmos/ibc-go/modules/light-clients/07-tendermint/types"
clienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types"
commitmenttypes "github.com/cosmos/ibc-go/v4/modules/core/23-commitment/types"
tmclient "github.com/cosmos/ibc-go/v4/modules/light-clients/07-tendermint/types"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/light"
)
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/modules/light-clients/07-tendermint/types"
tmclient "github.com/cosmos/ibc-go/v4/modules/light-clients/07-tendermint/types"
"github.com/hyperledger-labs/yui-relayer/chains/tendermint"
"github.com/hyperledger-labs/yui-relayer/config"
"github.com/spf13/cobra"
Expand Down
10 changes: 2 additions & 8 deletions chains/tendermint/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions chains/tendermint/light.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"path/filepath"

"github.com/avast/retry-go"
tmclient "github.com/cosmos/ibc-go/modules/light-clients/07-tendermint/types"
tmclient "github.com/cosmos/ibc-go/v4/modules/light-clients/07-tendermint/types"
"github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/light"
lightp "github.com/tendermint/tendermint/light/provider"
Expand Down Expand Up @@ -164,10 +164,12 @@ func (pr *Prover) GetLightSignedHeaderAtHeight(height int64) (*tmclient.Header,
return nil, err
}

protoVal, err := tmtypes.NewValidatorSet(sh.ValidatorSet.Validators).ToProto()
valSet := tmtypes.NewValidatorSet(sh.ValidatorSet.Validators)
protoVal, err := valSet.ToProto()
if err != nil {
return nil, err
}
protoVal.TotalVotingPower = valSet.TotalVotingPower()

return &tmclient.Header{SignedHeader: sh.SignedHeader.ToProto(), ValidatorSet: protoVal}, nil
}
Expand Down
8 changes: 4 additions & 4 deletions chains/tendermint/log-chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"strings"

sdk "github.com/cosmos/cosmos-sdk/types"
clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types"
conntypes "github.com/cosmos/ibc-go/modules/core/03-connection/types"
chantypes "github.com/cosmos/ibc-go/modules/core/04-channel/types"
ibcexported "github.com/cosmos/ibc-go/modules/core/exported"
clienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types"
conntypes "github.com/cosmos/ibc-go/v4/modules/core/03-connection/types"
chantypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"
ibcexported "github.com/cosmos/ibc-go/v4/modules/core/exported"
proto "github.com/gogo/protobuf/proto"
)

Expand Down
34 changes: 20 additions & 14 deletions chains/tendermint/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (

"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types"
conntypes "github.com/cosmos/ibc-go/modules/core/03-connection/types"
chantypes "github.com/cosmos/ibc-go/modules/core/04-channel/types"
"github.com/cosmos/ibc-go/modules/core/exported"
ibcexported "github.com/cosmos/ibc-go/modules/core/exported"
tmclient "github.com/cosmos/ibc-go/modules/light-clients/07-tendermint/types"
clienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types"
conntypes "github.com/cosmos/ibc-go/v4/modules/core/03-connection/types"
chantypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"
"github.com/cosmos/ibc-go/v4/modules/core/exported"
ibcexported "github.com/cosmos/ibc-go/v4/modules/core/exported"
tmclient "github.com/cosmos/ibc-go/v4/modules/light-clients/07-tendermint/types"
"github.com/tendermint/tendermint/light"
tmtypes "github.com/tendermint/tendermint/types"

Expand Down Expand Up @@ -78,13 +78,18 @@ func (pr *Prover) QueryPacketAcknowledgementCommitmentWithProof(height int64, se
return pr.chain.queryPacketAcknowledgementCommitment(height, seq, true)
}

// QueryHeader returns the header corresponding to the height
func (pr *Prover) QueryHeader(height int64) (out core.HeaderI, err error) {
return pr.queryHeaderAtHeight(height)
}

// QueryLatestHeader returns the latest header from the chain
func (pr *Prover) QueryLatestHeader() (out core.HeaderI, err error) {
var h int64
if h, err = pr.chain.GetLatestHeight(); err != nil {
return nil, err
}
return pr.queryHeaderAtHeight(h)
return pr.QueryHeader(h)
}

// GetLatestLightHeight uses the CLI utilities to pull the latest height from a given chain
Expand Down Expand Up @@ -187,20 +192,19 @@ func (pr *Prover) UpdateLightWithHeader() (header core.HeaderI, provableHeight i
}
}

protoVal, err := tmtypes.NewValidatorSet(sh.ValidatorSet.Validators).ToProto()
valSet := tmtypes.NewValidatorSet(sh.ValidatorSet.Validators)
protoVal, err := valSet.ToProto()
if err != nil {
return nil, 0, 0, err
}
protoVal.TotalVotingPower = valSet.TotalVotingPower()

h := &tmclient.Header{
SignedHeader: sh.SignedHeader.ToProto(),
ValidatorSet: protoVal,
}
queryableHeight = int64(h.GetHeight().GetRevisionHeight())
// NOTE: We query connection at height - 1 because of the way tendermint returns
// proofs the commit for height n is contained in the header of height n + 1
provableHeight = queryableHeight - 1
return h, provableHeight, queryableHeight, nil
height := int64(h.GetHeight().GetRevisionHeight())
return h, height, height, nil
}

// TrustOptions returns light.TrustOptions given a height and hash
Expand Down Expand Up @@ -240,10 +244,12 @@ func (c *Prover) queryHeaderAtHeight(height int64) (*tmclient.Header, error) {
return nil, err
}

protoVal, err := tmtypes.NewValidatorSet(val.Validators).ToProto()
valSet := tmtypes.NewValidatorSet(val.Validators)
protoVal, err := valSet.ToProto()
if err != nil {
return nil, err
}
protoVal.TotalVotingPower = valSet.TotalVotingPower()

return &tmclient.Header{
// NOTE: This is not a SignedHeader
Expand Down
25 changes: 15 additions & 10 deletions chains/tendermint/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,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/modules/apps/transfer/types"
clientutils "github.com/cosmos/ibc-go/modules/core/02-client/client/utils"
clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types"
connutils "github.com/cosmos/ibc-go/modules/core/03-connection/client/utils"
conntypes "github.com/cosmos/ibc-go/modules/core/03-connection/types"
chanutils "github.com/cosmos/ibc-go/modules/core/04-channel/client/utils"
chantypes "github.com/cosmos/ibc-go/modules/core/04-channel/types"
committypes "github.com/cosmos/ibc-go/modules/core/23-commitment/types"
ibcexported "github.com/cosmos/ibc-go/modules/core/exported"
transfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"
clientutils "github.com/cosmos/ibc-go/v4/modules/core/02-client/client/utils"
clienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types"
connutils "github.com/cosmos/ibc-go/v4/modules/core/03-connection/client/utils"
conntypes "github.com/cosmos/ibc-go/v4/modules/core/03-connection/types"
chanutils "github.com/cosmos/ibc-go/v4/modules/core/04-channel/client/utils"
chantypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"
committypes "github.com/cosmos/ibc-go/v4/modules/core/23-commitment/types"
ibcexported "github.com/cosmos/ibc-go/v4/modules/core/exported"
"github.com/hyperledger-labs/yui-relayer/core"
abci "github.com/tendermint/tendermint/abci/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
Expand Down Expand Up @@ -323,7 +323,12 @@ func (c *Chain) QueryValsetAtHeight(height clienttypes.Height) (*tmproto.Validat
}
tmValSet.GetProposer()

return tmValSet.ToProto()
protoValSet, err := tmValSet.ToProto()
if err != nil {
return nil, err
}
protoValSet.TotalVotingPower = tmValSet.TotalVotingPower()
return protoValSet, err
}

func (c *Chain) toTmValidators(vals stakingtypes.Validators) ([]*tmtypes.Validator, error) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/cosmos/cosmos-sdk/client/flags"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/ibc-go/modules/core/exported"
"github.com/cosmos/ibc-go/v4/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
5 changes: 3 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ func Execute(modules ...config.ModuleI) error {

cobra.EnableCommandSorting = false
rootCmd.SilenceUsage = true
rootCmd.SilenceErrors = true

// Register top level flags --home and --debug
rootCmd.PersistentFlags().StringVar(&homePath, flags.FlagHome, defaultHome, "set home directory")
rootCmd.PersistentFlags().BoolVarP(&debug, "debug", "d", false, "debug output")
if err := viper.BindPFlag(flags.FlagHome, rootCmd.Flags().Lookup(flags.FlagHome)); err != nil {
if err := viper.BindPFlag(flags.FlagHome, rootCmd.PersistentFlags().Lookup(flags.FlagHome)); err != nil {
return err
}
if err := viper.BindPFlag("debug", rootCmd.Flags().Lookup("debug")); err != nil {
if err := viper.BindPFlag("debug", rootCmd.PersistentFlags().Lookup("debug")); err != nil {
return err
}

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/modules/apps/transfer/types"
transfertypes "github.com/cosmos/ibc-go/v4/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/modules/apps/transfer/types"
clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types"
conntypes "github.com/cosmos/ibc-go/modules/core/03-connection/types"
chantypes "github.com/cosmos/ibc-go/modules/core/04-channel/types"
ibcexported "github.com/cosmos/ibc-go/modules/core/exported"
transfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"
clienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types"
conntypes "github.com/cosmos/ibc-go/v4/modules/core/03-connection/types"
chantypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"
ibcexported "github.com/cosmos/ibc-go/v4/modules/core/exported"
)

// ProvableChain represents a chain that is supported by the relayer
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/modules/core/04-channel/types"
chantypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"
)

// CreateChannel runs the channel creation messages on timeout until they pass
Expand Down
4 changes: 2 additions & 2 deletions core/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"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/modules/apps/transfer"
ibc "github.com/cosmos/ibc-go/modules/core"
transfer "github.com/cosmos/ibc-go/v4/modules/apps/transfer"
ibc "github.com/cosmos/ibc-go/v4/modules/core"
)

var moduleBasics = module.NewBasicManager(
Expand Down
6 changes: 3 additions & 3 deletions core/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (

retry "github.com/avast/retry-go"
sdk "github.com/cosmos/cosmos-sdk/types"
clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types"
conntypes "github.com/cosmos/ibc-go/modules/core/03-connection/types"
ibcexported "github.com/cosmos/ibc-go/modules/core/exported"
clienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types"
conntypes "github.com/cosmos/ibc-go/v4/modules/core/03-connection/types"
ibcexported "github.com/cosmos/ibc-go/v4/modules/core/exported"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion core/headers.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package core

import (
"github.com/cosmos/ibc-go/modules/core/exported"
"github.com/cosmos/ibc-go/v4/modules/core/exported"
)

type HeaderI interface {
Expand Down
2 changes: 1 addition & 1 deletion core/ics24.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"strings"

host "github.com/cosmos/ibc-go/modules/core/24-host"
host "github.com/cosmos/ibc-go/v4/modules/core/24-host"
)

// Vclient validates the client identifier in the path
Expand Down
2 changes: 1 addition & 1 deletion core/naive-strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

retry "github.com/avast/retry-go"
sdk "github.com/cosmos/cosmos-sdk/types"
chantypes "github.com/cosmos/ibc-go/modules/core/04-channel/types"
chantypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"
"golang.org/x/sync/errgroup"
)

Expand Down
6 changes: 3 additions & 3 deletions core/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"golang.org/x/sync/errgroup"
"gopkg.in/yaml.v2"

clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types"
conntypes "github.com/cosmos/ibc-go/modules/core/03-connection/types"
chantypes "github.com/cosmos/ibc-go/modules/core/04-channel/types"
clienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types"
conntypes "github.com/cosmos/ibc-go/v4/modules/core/03-connection/types"
chantypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"
)

const (
Expand Down
20 changes: 9 additions & 11 deletions core/pathEnd.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
transfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types"
clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types"
conntypes "github.com/cosmos/ibc-go/modules/core/03-connection/types"
chantypes "github.com/cosmos/ibc-go/modules/core/04-channel/types"
commitmenttypes "github.com/cosmos/ibc-go/modules/core/23-commitment/types"
commitmentypes "github.com/cosmos/ibc-go/modules/core/23-commitment/types"
ibcexported "github.com/cosmos/ibc-go/modules/core/exported"
tmclient "github.com/cosmos/ibc-go/modules/light-clients/07-tendermint/types"
transfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"
clienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types"
conntypes "github.com/cosmos/ibc-go/v4/modules/core/03-connection/types"
chantypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"
commitmenttypes "github.com/cosmos/ibc-go/v4/modules/core/23-commitment/types"
commitmentypes "github.com/cosmos/ibc-go/v4/modules/core/23-commitment/types"
ibcexported "github.com/cosmos/ibc-go/v4/modules/core/exported"
tmclient "github.com/cosmos/ibc-go/v4/modules/light-clients/07-tendermint/types"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/light"
)
Expand Down Expand Up @@ -136,7 +136,6 @@ func (pe *PathEnd) ConnTry(
panic(err)
}
msg := conntypes.NewMsgConnectionOpenTry(
"",
pe.ClientID,
dst.ConnectionID,
dst.ClientID,
Expand Down Expand Up @@ -211,7 +210,6 @@ func (pe *PathEnd) ChanInit(dst *PathEnd, signer sdk.AccAddress) sdk.Msg {
func (pe *PathEnd) ChanTry(dst *PathEnd, dstChanState *chantypes.QueryChannelResponse, signer sdk.AccAddress) sdk.Msg {
return chantypes.NewMsgChannelOpenTry(
pe.PortID,
"",
pe.Version,
dstChanState.Channel.Ordering,
[]string{pe.ConnectionID},
Expand Down Expand Up @@ -304,7 +302,7 @@ func (pe *PathEnd) NewPacket(dst *PathEnd, sequence uint64, packetData []byte,
func (pe *PathEnd) XferPacket(amount sdk.Coin, sender, receiver string) []byte {
return transfertypes.NewFungibleTokenPacketData(
amount.Denom,
amount.Amount.Uint64(),
amount.Amount.String(),
sender,
receiver,
).GetBytes()
Expand Down
Loading

0 comments on commit 524e041

Please sign in to comment.