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

Penumbra support v2 #1144

Merged
merged 11 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from 9 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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ifeq ($(OS),Windows_NT)
@go build -mod=readonly $(BUILD_FLAGS) -o build/rly.exe main.go
else
@echo "building rly binary..."
@go build -mod=readonly $(BUILD_FLAGS) -o build/rly main.go
@go build $(BUILD_FLAGS) -o build/rly main.go
endif

build-zip: go.sum
Expand Down
4 changes: 0 additions & 4 deletions buf.work.yaml

This file was deleted.

6 changes: 5 additions & 1 deletion cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (

"github.com/cosmos/relayer/v2/relayer"
"github.com/cosmos/relayer/v2/relayer/chains/cosmos"
"github.com/cosmos/relayer/v2/relayer/chains/penumbra"
"github.com/cosmos/relayer/v2/relayer/provider"
"github.com/spf13/cobra"
"go.uber.org/zap"
Expand Down Expand Up @@ -340,7 +341,8 @@ type ProviderConfigYAMLWrapper struct {
// NOTE: Add new ProviderConfig types in the map here with the key set equal to the type of ChainProvider (e.g. cosmos, substrate, etc.)
func (pcw *ProviderConfigWrapper) UnmarshalJSON(data []byte) error {
customTypes := map[string]reflect.Type{
"cosmos": reflect.TypeOf(cosmos.CosmosProviderConfig{}),
"cosmos": reflect.TypeOf(cosmos.CosmosProviderConfig{}),
"penumbra": reflect.TypeOf(penumbra.PenumbraProviderConfig{}),
}
val, err := UnmarshalJSONProviderConfig(data, customTypes)
if err != nil {
Expand Down Expand Up @@ -393,6 +395,8 @@ func (iw *ProviderConfigYAMLWrapper) UnmarshalYAML(n *yaml.Node) error {
switch iw.Type {
case "cosmos":
iw.Value = new(cosmos.CosmosProviderConfig)
case "penumbra":
iw.Value = new(penumbra.PenumbraProviderConfig)
default:
return fmt.Errorf("%s is an invalid chain type, check your config file", iw.Type)
}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ require (
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/gogoproto v1.4.6
github.com/cosmos/ibc-go/v7 v7.0.0
github.com/cosmos/ics23/go v0.9.1-0.20221207100636-b1abd8678aab
github.com/ethereum/go-ethereum v1.10.26
github.com/gofrs/flock v0.8.1
github.com/gogo/protobuf v1.3.2
Expand All @@ -34,6 +35,7 @@ require (
golang.org/x/term v0.6.0
golang.org/x/text v0.8.0
google.golang.org/grpc v1.53.0
google.golang.org/protobuf v1.29.1
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
)
Expand Down Expand Up @@ -69,7 +71,6 @@ require (
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/gogogateway v1.2.0 // 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.12.2 // indirect
github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect
github.com/creachadair/taskgroup v0.4.2 // indirect
Expand Down Expand Up @@ -175,7 +176,6 @@ require (
google.golang.org/api v0.110.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230216225411-c8e22ba71e44 // indirect
google.golang.org/protobuf v1.29.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
nhooyr.io/websocket v1.8.6 // indirect
pgregory.net/rapid v0.5.5 // indirect
Expand Down
4 changes: 4 additions & 0 deletions proto/buf.gen.gogo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ version: v1
plugins:
- name: gocosmos
out: .
opt: plugins=grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types
- name: grpc-gateway
out: .
opt: logtostderr=true,allow_colon_final_segments=true
13 changes: 13 additions & 0 deletions proto/buf.gen.penumbra.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: v1
managed:
enabled: true
go_package_prefix:
default: github.com/cosmos/relayer/v2/relayer/chains
except:
- buf.build/cosmos/ibc
- github.com/cometbft/cometbft
- buf.build/cosmos/cosmos-sdk
plugins:
- name: gocosmos
out: .
opt: plugins=grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types
31 changes: 31 additions & 0 deletions proto/buf.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Generated by buf. DO NOT EDIT.
version: v1
deps:
- remote: buf.build
owner: cosmos
repository: cosmos-proto
commit: 1935555c206d4afb9e94615dfd0fad31
- remote: buf.build
owner: cosmos
repository: cosmos-sdk
commit: 7c06e7f6f43c406185136100bfd7b848
- remote: buf.build
owner: cosmos
repository: gogo-proto
commit: 34d970b699f84aa382f3c29773a60836
- remote: buf.build
owner: cosmos
repository: ibc
commit: 6e966f8dba714d108a52ffabbcb0e5c3
- remote: buf.build
owner: cosmos
repository: ics23
commit: 55085f7c710a45f58fa09947208eb70b
- remote: buf.build
owner: googleapis
repository: googleapis
commit: 75b4300737fb4efca0831636be94e517
- remote: buf.build
owner: penumbra-zone
repository: penumbra
commit: 42619f653f4d470291f3d8b68d7ae7ae
7 changes: 7 additions & 0 deletions proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: v1
deps:
- buf.build/penumbra-zone/penumbra
- buf.build/cosmos/cosmos-sdk
- buf.build/cosmos/cosmos-proto
- buf.build/cosmos/gogo-proto
- buf.build/googleapis/googleapis
1 change: 0 additions & 1 deletion relayer/chains/cosmos/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"go.uber.org/zap/zapcore"
)

var _ provider.RelayerMessage = &CosmosMessage{}

type CosmosMessage struct {
Msg sdk.Msg
Expand Down
3 changes: 2 additions & 1 deletion relayer/chains/cosmos/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,6 @@ func (cc *CosmosProvider) GenerateConnHandshakeProof(ctx context.Context, height
func (cc *CosmosProvider) QueryChannel(ctx context.Context, height int64, channelid, portid string) (chanRes *chantypes.QueryChannelResponse, err error) {
res, err := cc.queryChannelABCI(ctx, height, portid, channelid)
if err != nil && strings.Contains(err.Error(), "not found") {

return &chantypes.QueryChannelResponse{
Channel: &chantypes.Channel{
State: chantypes.UNINITIALIZED,
Expand Down Expand Up @@ -728,6 +727,8 @@ func (cc *CosmosProvider) queryChannelABCI(ctx context.Context, height int64, po
return nil, err
}



return &chantypes.QueryChannelResponse{
Channel: &channel,
Proof: proofBz,
Expand Down
100 changes: 100 additions & 0 deletions relayer/chains/penumbra/codec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package penumbra

import (
"github.com/cosmos/cosmos-sdk/client"
"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/tx"
authz "github.com/cosmos/cosmos-sdk/x/authz/module"
"github.com/cosmos/cosmos-sdk/x/bank"
"github.com/cosmos/cosmos-sdk/x/capability"
"github.com/cosmos/cosmos-sdk/x/crisis"
"github.com/cosmos/cosmos-sdk/x/distribution"
feegrant "github.com/cosmos/cosmos-sdk/x/feegrant/module"
"github.com/cosmos/cosmos-sdk/x/gov"
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
"github.com/cosmos/cosmos-sdk/x/mint"
"github.com/cosmos/cosmos-sdk/x/params"
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"
"github.com/cosmos/ibc-go/v7/modules/apps/transfer"
ibc "github.com/cosmos/ibc-go/v7/modules/core"

cosmosmodule "github.com/cosmos/relayer/v2/relayer/chains/cosmos/module"
"github.com/cosmos/relayer/v2/relayer/chains/cosmos/stride"
ethermintcodecs "github.com/cosmos/relayer/v2/relayer/codecs/ethermint"
injectivecodecs "github.com/cosmos/relayer/v2/relayer/codecs/injective"
)

var moduleBasics = []module.AppModuleBasic{
auth.AppModuleBasic{},
authz.AppModuleBasic{},
bank.AppModuleBasic{},
capability.AppModuleBasic{},
gov.NewAppModuleBasic(
[]govclient.ProposalHandler{
paramsclient.ProposalHandler,
upgradeclient.LegacyProposalHandler,
upgradeclient.LegacyCancelProposalHandler,
},
),
crisis.AppModuleBasic{},
distribution.AppModuleBasic{},
feegrant.AppModuleBasic{},
mint.AppModuleBasic{},
params.AppModuleBasic{},
slashing.AppModuleBasic{},
staking.AppModuleBasic{},
upgrade.AppModuleBasic{},
transfer.AppModuleBasic{},
ibc.AppModuleBasic{},
cosmosmodule.AppModuleBasic{},
stride.AppModuleBasic{},
}

type Codec struct {
InterfaceRegistry types.InterfaceRegistry
Marshaler codec.Codec
TxConfig client.TxConfig
Amino *codec.LegacyAmino
}

func makeCodec(moduleBasics []module.AppModuleBasic, extraCodecs []string) Codec {
modBasic := module.NewBasicManager(moduleBasics...)
encodingConfig := makeCodecConfig()
std.RegisterLegacyAminoCodec(encodingConfig.Amino)
std.RegisterInterfaces(encodingConfig.InterfaceRegistry)
modBasic.RegisterLegacyAminoCodec(encodingConfig.Amino)
modBasic.RegisterInterfaces(encodingConfig.InterfaceRegistry)
for _, c := range extraCodecs {
switch c {
case "ethermint":
ethermintcodecs.RegisterInterfaces(encodingConfig.InterfaceRegistry)
encodingConfig.Amino.RegisterConcrete(&ethermintcodecs.PubKey{}, ethermintcodecs.PubKeyName, nil)
encodingConfig.Amino.RegisterConcrete(&ethermintcodecs.PrivKey{}, ethermintcodecs.PrivKeyName, nil)
case "injective":
injectivecodecs.RegisterInterfaces(encodingConfig.InterfaceRegistry)
encodingConfig.Amino.RegisterConcrete(&injectivecodecs.PubKey{}, injectivecodecs.PubKeyName, nil)
encodingConfig.Amino.RegisterConcrete(&injectivecodecs.PrivKey{}, injectivecodecs.PrivKeyName, nil)
}
}

return encodingConfig
}

func makeCodecConfig() Codec {
interfaceRegistry := types.NewInterfaceRegistry()
marshaler := codec.NewProtoCodec(interfaceRegistry)
return Codec{
InterfaceRegistry: interfaceRegistry,
Marshaler: marshaler,
TxConfig: tx.NewTxConfig(marshaler, tx.DefaultSignModes),
Amino: codec.NewLegacyAmino(),
}
}
Loading