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

Rosetta/fix/ibc dependency #635

Merged
merged 11 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions simapp/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/cosmos/cosmos-db v1.0.0-rc.1
// this version is not used as it is always replaced by the latest Cosmos SDK version
github.com/cosmos/cosmos-sdk v0.48.0
github.com/cosmos/gogoproto v1.4.9
github.com/cosmos/gogoproto v1.4.10
github.com/golang/mock v1.6.0
github.com/spf13/cast v1.5.0
github.com/spf13/cobra v1.7.0
Expand Down Expand Up @@ -168,7 +168,7 @@ require (
github.com/ulikunitz/xz v0.5.11 // indirect
github.com/zondax/hid v0.9.1 // indirect
github.com/zondax/ledger-go v0.14.1 // indirect
go.etcd.io/bbolt v1.3.6 // indirect
go.etcd.io/bbolt v1.3.7 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/crypto v0.9.0 // indirect
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect
Expand Down
2 changes: 2 additions & 0 deletions simapp/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ
github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU=
github.com/cosmos/gogoproto v1.4.9 h1:MjVmV6F1yk1rJLWtKeYdGQcTbE880t+VlRcayEBqUKQ=
github.com/cosmos/gogoproto v1.4.9/go.mod h1:c0ysUnwvnlR+RmCUvqqii7pp8kHBB/DBcp/5VLA/nQk=
github.com/cosmos/gogoproto v1.4.10/go.mod h1:3aAZzeRWpAwr+SS/LLkICX2/kDFyaYVzckBDzygIxek=
github.com/cosmos/iavl v0.21.0 h1:E39qwHl45PaQUe/mRA8lY4kOqaunOorVQufpv5JPgXk=
github.com/cosmos/iavl v0.21.0/go.mod h1:ejCWRfxvfmQTcligmeRcoQeB8VgHGxkVlIqKSKG7YaI=
github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM=
Expand Down Expand Up @@ -1069,6 +1070,7 @@ github.com/zondax/ledger-go v0.14.1/go.mod h1:fZ3Dqg6qcdXWSOJFKMG8GCTnD7slO/RL2f
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU=
go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4=
go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw=
go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg=
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
Expand Down
4 changes: 2 additions & 2 deletions tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
github.com/cosmos/cosmos-proto v1.0.0-beta.3
// this version is not used as it is always replaced by the latest Cosmos SDK version
github.com/cosmos/cosmos-sdk v0.48.0
github.com/cosmos/gogoproto v1.4.9
github.com/cosmos/gogoproto v1.4.10
github.com/golang/mock v1.6.0
github.com/google/uuid v1.3.0 // indirect
github.com/spf13/cobra v1.7.0
Expand Down Expand Up @@ -165,7 +165,7 @@ require (
github.com/ulikunitz/xz v0.5.11 // indirect
github.com/zondax/hid v0.9.1 // indirect
github.com/zondax/ledger-go v0.14.1 // indirect
go.etcd.io/bbolt v1.3.6 // indirect
go.etcd.io/bbolt v1.3.7 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/crypto v0.9.0 // indirect
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect
Expand Down
2 changes: 2 additions & 0 deletions tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ
github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU=
github.com/cosmos/gogoproto v1.4.9 h1:MjVmV6F1yk1rJLWtKeYdGQcTbE880t+VlRcayEBqUKQ=
github.com/cosmos/gogoproto v1.4.9/go.mod h1:c0ysUnwvnlR+RmCUvqqii7pp8kHBB/DBcp/5VLA/nQk=
github.com/cosmos/gogoproto v1.4.10/go.mod h1:3aAZzeRWpAwr+SS/LLkICX2/kDFyaYVzckBDzygIxek=
github.com/cosmos/iavl v0.21.0 h1:E39qwHl45PaQUe/mRA8lY4kOqaunOorVQufpv5JPgXk=
github.com/cosmos/iavl v0.21.0/go.mod h1:ejCWRfxvfmQTcligmeRcoQeB8VgHGxkVlIqKSKG7YaI=
github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM=
Expand Down Expand Up @@ -1071,6 +1072,7 @@ github.com/zondax/ledger-go v0.14.1/go.mod h1:fZ3Dqg6qcdXWSOJFKMG8GCTnD7slO/RL2f
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU=
go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4=
go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw=
go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg=
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
Expand Down
4 changes: 4 additions & 0 deletions tools/rosetta/cmd/rosetta/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package main
import (
"os"

"cosmossdk.io/tools/rosetta"

"cosmossdk.io/log"
rosettaCmd "cosmossdk.io/tools/rosetta/cmd"
"github.com/cosmos/cosmos-sdk/codec"
Expand All @@ -16,6 +18,8 @@ func main() {
cdc = codec.NewProtoCodec(interfaceRegistry)
)

rosetta.RegisterInterfaces(interfaceRegistry)

if err := rosettaCmd.RosettaCommand(interfaceRegistry, cdc).Execute(); err != nil {
logger.Error("failed to run rosetta", "error", err)
os.Exit(1)
Expand Down
16 changes: 16 additions & 0 deletions tools/rosetta/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ import (
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
authcodec "github.com/cosmos/cosmos-sdk/x/auth/types"
bankcodec "github.com/cosmos/cosmos-sdk/x/bank/types"

ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
// "github.com/cosmos/ibc-go/v7/modules/core/exported"
ibcLightClient "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"

sdk "github.com/cosmos/cosmos-sdk/types"
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
)

// MakeCodec generates the codec required to interact
Expand All @@ -20,3 +27,12 @@ func MakeCodec() (*codec.ProtoCodec, codectypes.InterfaceRegistry) {

return cdc, ir
}

// RegisterInterfaces registers rosetta related implementations and interfaces.
func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
ibcclienttypes.RegisterInterfaces(registry)
ibcLightClient.RegisterInterfaces(registry)
sdk.RegisterInterfaces(registry)
txtypes.RegisterInterfaces(registry)
cryptocodec.RegisterInterfaces(registry)
}
56 changes: 56 additions & 0 deletions tools/rosetta/codec_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package rosetta_test

import (
"testing"

"cosmossdk.io/tools/rosetta"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/stretchr/testify/suite"

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
)

type CodecTestSuite struct {
suite.Suite

ir codectypes.InterfaceRegistry
cdc *codec.ProtoCodec

requiredInterfaces []string
}

func (s *CodecTestSuite) SetupTest() {
s.ir = codectypes.NewInterfaceRegistry()
s.cdc = codec.NewProtoCodec(s.ir)
s.requiredInterfaces = []string{
"cosmos.base.v1beta1.Msg",
"cosmos.tx.v1beta1.Tx",
"cosmos.crypto.PubKey",
"cosmos.crypto.PrivKey",
"ibc.core.client.v1.ClientState",
"ibc.core.client.v1.Height",
"cosmos.tx.v1beta1.MsgResponse",
"ibc.core.client.v1.Header",
}
}

func (s *CodecTestSuite) TestInterfaceRegistry() {
s.Run("Required interfaces", func() {
rosetta.RegisterInterfaces(s.ir)
interfaceList := s.ir.ListAllInterfaces()

interfaceListMap := make(map[string]bool)
for _, interfaceTypeUrl := range interfaceList {
interfaceListMap[interfaceTypeUrl] = true
}

for _, requiredInterfaceTypeUrl := range s.requiredInterfaces {
s.Require().True(interfaceListMap[requiredInterfaceTypeUrl])
}
})
}

func TestCodecTestSuite(t *testing.T) {
suite.Run(t, new(CodecTestSuite))
}
9 changes: 6 additions & 3 deletions tools/rosetta/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/coinbase/rosetta-sdk-go/types v1.0.0
github.com/cometbft/cometbft v0.37.1
github.com/cosmos/cosmos-sdk v0.47.2
github.com/cosmos/ibc-go/v7 v7.0.0
github.com/cosmos/rosetta-sdk-go v0.10.0
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0
github.com/spf13/cobra v1.7.0
Expand All @@ -17,8 +18,8 @@ require (
)

require (
cosmossdk.io/api v0.4.1 // indirect
cosmossdk.io/core v0.7.0 // indirect
cosmossdk.io/api v0.3.1 // indirect
cosmossdk.io/core v0.6.1 // indirect
cosmossdk.io/depinject v1.0.0-alpha.3 // indirect
cosmossdk.io/errors v1.0.0-beta.7.0.20230429155654-3ee8242364e4 // indirect
filippo.io/edwards25519 v1.0.0 // indirect
Expand All @@ -38,6 +39,7 @@ require (
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gogoproto v1.4.10 // indirect
github.com/cosmos/iavl v0.20.0 // indirect
github.com/cosmos/ics23/go v0.9.1-0.20221207100636-b1abd8678aab // indirect
github.com/cosmos/ledger-cosmos-go v0.13.0 // indirect
github.com/danieljoos/wincred v1.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand Down Expand Up @@ -90,7 +92,6 @@ require (
github.com/prometheus/common v0.43.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rs/cors v1.8.3 // indirect
github.com/rs/zerolog v1.29.1 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/spf13/afero v1.9.3 // indirect
Expand Down Expand Up @@ -119,3 +120,5 @@ require (
pgregory.net/rapid v0.5.7 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace cosmossdk.io/api => cosmossdk.io/api v0.3.1
Loading