Skip to content

Commit

Permalink
feat: proof generation code using endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Giuseppe Valente committed Apr 18, 2023
1 parent 85c0cd8 commit 128ede3
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 273 deletions.
5 changes: 3 additions & 2 deletions relayer/chains/cosmos/multihop.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
commitmenttypes "github.com/cosmos/ibc-go/v7/modules/core/23-commitment/types"
"github.com/cosmos/ibc-go/v7/modules/core/exported"
"github.com/cosmos/ibc-go/v7/modules/core/multihop"
"github.com/cosmos/relayer/v2/relayer/provider"
)

var _ multihop.Endpoint = (*endpoint)(nil)
Expand Down Expand Up @@ -147,9 +148,9 @@ func (e endpoint) Counterparty() multihop.Endpoint {
return e.counterparty
}

func newEndpoint(provider *CosmosProvider, clientID, connectionID string) multihop.Endpoint {
func newEndpoint(provider provider.ChainProvider, clientID, connectionID string) multihop.Endpoint {
return &endpoint{
provider: provider,
provider: provider.(*CosmosProvider),
clientID: clientID,
connectionID: connectionID,
}
Expand Down
16 changes: 11 additions & 5 deletions relayer/chains/cosmos/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package cosmos
import (
"context"
"fmt"
chantypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
"github.com/cosmos/ibc-go/v7/modules/core/multihop"
"io"
"os"
"path"
Expand Down Expand Up @@ -92,7 +94,7 @@ func (pc CosmosProviderConfig) NewProvider(log *zap.Logger, homepath string, deb
// TODO: this is a bit of a hack, we should probably have a better way to inject modules
Cdc: MakeCodec(pc.Modules, pc.ExtraCodecs),

queryProviders: map[string]*CosmosProvider{},
chanPaths: map[string]*multihop.ChanPath{},
}

return cp, nil
Expand Down Expand Up @@ -123,12 +125,16 @@ type CosmosProvider struct {
// for comet < v0.37, decode tm events as base64
cometLegacyEncoding bool

// queryProviders allows to query other chains for multi-hop proofs
queryProviders map[string]*CosmosProvider
// chanPaths tracks paths for multi-hop proofs
chanPaths map[string]*multihop.ChanPath
}

func (cc *CosmosProvider) AddQueryProvider(chainID string, queryProvider provider.QueryProvider) {
cc.queryProviders[chainID] = queryProvider.(*CosmosProvider)
func (cc *CosmosProvider) AddChanPath(connectionHops []string, chanPath *multihop.ChanPath) {
cc.chanPaths[chantypes.FormatConnectionID(connectionHops)] = chanPath
}

func (cc *CosmosProvider) GetChanPath(connectionHops []string) *multihop.ChanPath {
return cc.chanPaths[chantypes.FormatConnectionID(connectionHops)]
}

func (cc *CosmosProvider) ProviderConfig() provider.ProviderConfig {
Expand Down
Loading

0 comments on commit 128ede3

Please sign in to comment.