Skip to content

Commit

Permalink
ICS 03 Implementation (#4517)
Browse files Browse the repository at this point in the history
* add test

* in progres

* fin rebase

* in progress

* fin rebase

* add CLIObject in progress

* cli in progress

* add CLIObject

* separate testing from tendermint

* add key to node

* add root and storekey to tests/node, add codec

* rm cli/query.go

* fix test

* fix lint

* fix lint

* add handler/msgs/client

* rm relay

* finalize rebase on 23 root/path sep

* fix lint, fix syntax

* fix querying

* extract out context withstore

* fix 02-client test

* fix 23-commitment test

* add query in progress

* rm freebase, reformat query

* add cli/handler/msg in progress

* add cli/msg/handler

* add CLIQuery, fix tests

* fix golangci

* add docs in progre

* add comments

* add comments

* Apply suggestions from code review

Co-Authored-By: Federico Kunze <31522760+fedekunze@users.noreply.github.com>

* add comments in progress

* add comments

* fix comment

* add comments in progress

* recover IntEncoding scheme for integer

* add uint tests, don't use codec in custom types

* finalize merge

* add godoc

* add godoc in progress

* reformat test

* rm XXX

* add godoc

* modify store

* add query

* update query.go

* update query.go

* cli refactor in progress

* cli refactor in progress

* add Query to boolean.go

* fix key

* fix cli / merkle test

* godoc cleanup

* godoc cleanup

* godoc cleanup

* godoc cleanup

* godoc cleanup

* fix test

* fix client

* merge from ics04 branch

* merge from ics04 branch

* merge from ics04 branch

* merge from ics04 branch

* fix lint

* Apply suggestions from code review

Co-Authored-By: Federico Kunze <31522760+fedekunze@users.noreply.github.com>

* applying review in progress

* apply review - make querier interface

* fix dependency

* fix dependency

* revise querier interface to work both on cli & store

* revise querier interface to work both on cli & store

* reflect downstream change

* fix cli

* reflect downstream changes

* rm commented lines

* address review in progress

* address review, rm cleanup/closing

* rename Path -> Prefix

* Store accessor upstream changes (#5119)

* Store accessor upstream changes (#5119)

* add comments, reformat merkle querier

* rm merkle/utils

* ICS 23 upstream changes (#5120)

* ICS 23 upstream changes (#5120)

* update Value

* update test

* fix

* ICS 02 upstream changes (#5122)

* ICS 02 upstream changes (#5122)

* ICS 03 upstream changes (#5123)

* ICS 03 upstream changes (#5123)

* cleanup types and submodule

* more cleanup and godocs

* remove counterPartyManager/State and cleanup

* implement SubmitMisbehaviour and refactor

* errors

* events

* fix test

* refactors

* WIP refactor ICS03

* remove Mapping

* remove store accessors

* proposed refactor

* remove store accessors from ICS02

* refactor queriers, handler and clean keeper

* logger and tx long description

* ineffassign

* Apply suggestions from code review

Co-Authored-By: Jack Zampolin <jack.zampolin@gmail.com>

* Apply suggestions from code review

Co-Authored-By: Jack Zampolin <jack.zampolin@gmail.com>

* remove store accessors

* refactor handshake to update it to the latest ICS03 spec

* update handler and msgs

* add verification functions

* update verification

* ICS02 module.go

* top level x/ibc structure

* update connection queries

* update connection tx

* remove extra files

* update expected client keeper and export verification funcs

* Update x/ibc/02-client/client/cli/query.go

Co-Authored-By: Jack Zampolin <jack.zampolin@gmail.com>

* Update x/ibc/02-client/types/tendermint/consensus_state.go

Co-Authored-By: Jack Zampolin <jack.zampolin@gmail.com>

* address some of the review comments

* resolve some TODOs and address comments from review

* update connection versioning

* minor error updates

* minor UX improvements

* rename pkg

* fixes

* refactor ICS23

* cleanup types

* rename pkg and fix import

* implement batch verification

* gosimple suggestion

* various fixes; remove legacy tests; remove commitment path query

* alias

* minor updates from ICS23

* renaming

* update verification and rename root funcs

* move querier to x/ibc

* update query.go to use 'custom/...' query path

* add tests

* ICS 24 Implementation (#5229)

* add validation functions

* validate path in ics-23

* address @fede comments

* move errors into host package

* flatten ICS23 structure

* fix ApplyPrefix

* updates from ICS23 and ICS24

* msg.ValidateBasic and ADR09 evidence interface

* complete types testing

* delete empty test file

* remove ibc errors from core error package

* custom JSON marshaling; msg.ValidateBasic; renaming of variables

* minor update

* custom JSON marshaling

* start batch-verify tests

* minor changes on commitment types

* R4R - Store consensus state correctly (#5242)

* store consensus state correctly

* fix client example

* update alias

* update alias

* use testsuite

* Integrate Evidence Implementation into ICS-02 (#5258)

* implement evidence in ics-02

* fix build errors and import cycles

* address fede comments

* remove unnecessary pubkey and fix init

* add tests

* finish tendermint tests

* complete merge

* Add tests for msgs

* upstream changes

* fix

* upstream changes

* fix cons state

* context changes

* fix cli tx

* upstream changes

* fix
  • Loading branch information
mossid authored and jackzampolin committed Jan 15, 2020
1 parent 35e0428 commit e9f3385
Show file tree
Hide file tree
Showing 23 changed files with 2,265 additions and 10 deletions.
1 change: 1 addition & 0 deletions client/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const (
FlagOutputDocument = "output-document" // inspired by wget -O
FlagSkipConfirmation = "yes"
FlagKeyringBackend = "keyring-backend"
FlagProve = "prove"
)

// LineBreak can be included in a command list to provide a blank line
Expand Down
102 changes: 102 additions & 0 deletions x/ibc/03-connection/alias.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package connection

// nolint
// autogenerated code using github.com/rigelrozanski/multitool
// aliases generated for the following subdirectories:
// ALIASGEN: github.com/cosmos/cosmos-sdk/x/ibc/03-connection/keeper
// ALIASGEN: github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types

import (
"github.com/cosmos/cosmos-sdk/x/ibc/03-connection/keeper"
"github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
)

const (
NONE = types.NONE
INIT = types.INIT
TRYOPEN = types.TRYOPEN
OPEN = types.OPEN
StateNone = types.StateNone
StateInit = types.StateInit
StateTryOpen = types.StateTryOpen
StateOpen = types.StateOpen
DefaultCodespace = types.DefaultCodespace
CodeConnectionExists = types.CodeConnectionExists
CodeConnectionNotFound = types.CodeConnectionNotFound
CodeClientConnectionPathsNotFound = types.CodeClientConnectionPathsNotFound
CodeConnectionPath = types.CodeConnectionPath
CodeInvalidCounterpartyConnection = types.CodeInvalidCounterpartyConnection
CodeInvalidVersion = types.CodeInvalidVersion
CodeInvalidHeight = types.CodeInvalidHeight
CodeInvalidConnectionState = types.CodeInvalidConnectionState
CodeInvalidProof = types.CodeInvalidProof
CodeInvalidCounterparty = types.CodeInvalidCounterparty
AttributeKeyConnectionID = types.AttributeKeyConnectionID
AttributeKeyCounterpartyClientID = types.AttributeKeyCounterpartyClientID
SubModuleName = types.SubModuleName
StoreKey = types.StoreKey
RouterKey = types.RouterKey
QuerierRoute = types.QuerierRoute
QueryConnection = types.QueryConnection
QueryClientConnections = types.QueryClientConnections
)

var (
// functions aliases
NewKeeper = keeper.NewKeeper
QuerierConnection = keeper.QuerierConnection
QuerierClientConnections = keeper.QuerierClientConnections
RegisterCodec = types.RegisterCodec
NewConnectionEnd = types.NewConnectionEnd
NewCounterparty = types.NewCounterparty
StateFromString = types.StateFromString
ErrConnectionExists = types.ErrConnectionExists
ErrConnectionNotFound = types.ErrConnectionNotFound
ErrClientConnectionPathsNotFound = types.ErrClientConnectionPathsNotFound
ErrConnectionPath = types.ErrConnectionPath
ErrInvalidCounterpartyConnection = types.ErrInvalidCounterpartyConnection
ErrInvalidVersion = types.ErrInvalidVersion
ErrInvalidHeight = types.ErrInvalidHeight
ErrInvalidConnectionState = types.ErrInvalidConnectionState
ErrInvalidConnectionProof = types.ErrInvalidConnectionProof
ErrInvalidCounterparty = types.ErrInvalidCounterparty
ConnectionPath = types.ConnectionPath
ClientConnectionsPath = types.ClientConnectionsPath
KeyConnection = types.KeyConnection
KeyClientConnections = types.KeyClientConnections
NewMsgConnectionOpenInit = types.NewMsgConnectionOpenInit
NewMsgConnectionOpenTry = types.NewMsgConnectionOpenTry
NewMsgConnectionOpenAck = types.NewMsgConnectionOpenAck
NewMsgConnectionOpenConfirm = types.NewMsgConnectionOpenConfirm
NewConnectionResponse = types.NewConnectionResponse
NewQueryConnectionParams = types.NewQueryConnectionParams
NewClientConnectionsResponse = types.NewClientConnectionsResponse
NewQueryClientConnectionsParams = types.NewQueryClientConnectionsParams
GetCompatibleVersions = types.GetCompatibleVersions
LatestVersion = types.LatestVersion
PickVersion = types.PickVersion

// variable aliases
SubModuleCdc = types.SubModuleCdc
EventTypeConnectionOpenInit = types.EventTypeConnectionOpenInit
EventTypeConnectionOpenTry = types.EventTypeConnectionOpenTry
EventTypeConnectionOpenAck = types.EventTypeConnectionOpenAck
EventTypeConnectionOpenConfirm = types.EventTypeConnectionOpenConfirm
AttributeValueCategory = types.AttributeValueCategory
)

type (
Keeper = keeper.Keeper
ConnectionEnd = types.ConnectionEnd
Counterparty = types.Counterparty
State = types.State
ClientKeeper = types.ClientKeeper
MsgConnectionOpenInit = types.MsgConnectionOpenInit
MsgConnectionOpenTry = types.MsgConnectionOpenTry
MsgConnectionOpenAck = types.MsgConnectionOpenAck
MsgConnectionOpenConfirm = types.MsgConnectionOpenConfirm
ConnectionResponse = types.ConnectionResponse
QueryConnectionParams = types.QueryConnectionParams
ClientConnectionsResponse = types.ClientConnectionsResponse
QueryClientConnectionsParams = types.QueryClientConnectionsParams
)
130 changes: 130 additions & 0 deletions x/ibc/03-connection/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package cli

import (
"fmt"
"strings"

"github.com/spf13/cobra"
"github.com/spf13/viper"

abci "github.com/tendermint/tendermint/abci/types"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
)

// GetQueryCmd returns the query commands for IBC connections
func GetQueryCmd(queryRoute string, cdc *codec.Codec) *cobra.Command {
ics03ConnectionQueryCmd := &cobra.Command{
Use: "connection",
Short: "IBC connection query subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
}

ics03ConnectionQueryCmd.AddCommand(client.GetCommands(
GetCmdQueryConnection(queryRoute, cdc),
)...)
return ics03ConnectionQueryCmd
}

// GetCmdQueryConnection defines the command to query a connection end
func GetCmdQueryConnection(queryRoute string, cdc *codec.Codec) *cobra.Command {
cmd := &cobra.Command{
Use: "end [connection-id]",
Short: "Query stored connection end",
Long: strings.TrimSpace(fmt.Sprintf(`Query stored connection end
Example:
$ %s query ibc connection end [connection-id]
`, version.ClientName),
),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
cliCtx := context.NewCLIContext().WithCodec(cdc)
connectionID := args[0]

bz, err := cdc.MarshalJSON(types.NewQueryConnectionParams(connectionID))
if err != nil {
return err
}

req := abci.RequestQuery{
Path: fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryConnection),
Data: bz,
Prove: viper.GetBool(flags.FlagProve),
}

res, err := cliCtx.QueryABCI(req)
if err != nil {
return err
}

var connection types.ConnectionEnd
if err := cdc.UnmarshalJSON(res.Value, &connection); err != nil {
return err
}

if res.Proof == nil {
return cliCtx.PrintOutput(connection)
}

connRes := types.NewConnectionResponse(connectionID, connection, res.Proof, res.Height)
return cliCtx.PrintOutput(connRes)
},
}
cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results")

return cmd
}

// GetCmdQueryClientConnections defines the command to query a client connections
func GetCmdQueryClientConnections(queryRoute string, cdc *codec.Codec) *cobra.Command {
return &cobra.Command{
Use: "client [client-id]",
Short: "Query stored client connection paths",
Long: strings.TrimSpace(fmt.Sprintf(`Query stored client connection paths
Example:
$ %s query ibc connection client [client-id]
`, version.ClientName),
),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
cliCtx := context.NewCLIContext().WithCodec(cdc)
clientID := args[0]

bz, err := cdc.MarshalJSON(types.NewQueryClientConnectionsParams(clientID))
if err != nil {
return err
}

req := abci.RequestQuery{
Path: fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryClientConnections),
Data: bz,
Prove: viper.GetBool(flags.FlagProve),
}

res, err := cliCtx.QueryABCI(req)
if err != nil {
return err
}

var connectionPaths []string
if err := cdc.UnmarshalJSON(res.Value, &connectionPaths); err != nil {
return err
}

if res.Proof == nil {
return cliCtx.PrintOutput(connectionPaths)
}

connPathsRes := types.NewClientConnectionsResponse(clientID, connectionPaths, res.Proof, res.Height)
return cliCtx.PrintOutput(connPathsRes)
},
}
}
Loading

0 comments on commit e9f3385

Please sign in to comment.