Skip to content

Commit

Permalink
ICS 04 Implementation (#4548)
Browse files Browse the repository at this point in the history
* merge from ics04 branch

* merge from ics04 branch

* fix lint

* add port

* fix test

* add mocks

* fix connid -> portid in handshake.go

* add mock

* add ibc module.go, finalize mock

* add keeper

* add StoreKey const

* fix test

* 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 cli errors

* fix dependency

* fix dependency

* reflect method name change

* revise querier interface to work both on cli & store

* 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

* reflect downstream changes

* fix from address in tx cli

* fix cli in progress(squash later)

* fix cli

* remove timeout, add channel cli

* fix golangci

* fix cli

* Clean up

* fix mock cli in progress

* finalize cleanup, mock cli wip

* add cli for mocksend

* fix handler

* rm commented lines

* address review in progress

* address review, rm cleanup/closing

* rename mock packages

* fix interface for gaia

* 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)

* update test

* 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

* refactor: remove store accessors, update keeper and types to match spec (WIP)

* update handshake and packet

* implement packet timeouts

* implement send and receive packet

* implement packet ACK

* update handler

* add channel errors

* channel querier

* update expected client keeper and export verification funcs

* ICS 05 Implementation

* release port and godocs

* 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

* update ICS04 with downstream changes

* Implement tx cli actions

* add MsgSendPacket handler; msg validation, errors and events

* update errors and add port Keeper to ibc Keeper

* minor UX improvements

* rename pkg

* fixes

* refactor ICS23

* cleanup types

* ICS 5 updates (#5222)

* Validate port identifiers

* Refactor to static bind

* Add comments

* Add 'GetPorts' query function

* 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

* rm legacy tests; add query proofs support

* remove capability key generation and authentication logic

* 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

* use host validation for port ids

* downstream changes; custom marshal JSON; msg validation, and update errors

* update errors and aliases

* start batch-verify tests

* update msg validation and CLI UX

* minor changes on commitment types

* fix channel and packet check (#5243)

* R4R - Store consensus state correctly (#5242)

* store consensus state correctly

* fix client example

* update alias

* update alias

* update alias and keeper.GetPort()

* authenticate port ID; remove send packet msg from CLI

* comment out handlers

* 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

* upstream changes

* upstream changes
  • Loading branch information
mossid authored and fedekunze committed Nov 5, 2019
1 parent 4282412 commit 87d09fd
Show file tree
Hide file tree
Showing 25 changed files with 3,181 additions and 0 deletions.
123 changes: 123 additions & 0 deletions x/ibc/04-channel/alias.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
package channel

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

import (
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/keeper"
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
)

const (
NONE = types.NONE
UNORDERED = types.UNORDERED
ORDERED = types.ORDERED
OrderNone = types.OrderNone
OrderUnordered = types.OrderUnordered
OrderOrdered = types.OrderOrdered
CLOSED = types.CLOSED
INIT = types.INIT
OPENTRY = types.OPENTRY
OPEN = types.OPEN
StateClosed = types.StateClosed
StateInit = types.StateInit
StateOpenTry = types.StateOpenTry
StateOpen = types.StateOpen
DefaultCodespace = types.DefaultCodespace
CodeChannelExists = types.CodeChannelExists
CodeChannelNotFound = types.CodeChannelNotFound
CodeInvalidCounterpartyChannel = types.CodeInvalidCounterpartyChannel
CodeChannelCapabilityNotFound = types.CodeChannelCapabilityNotFound
CodeInvalidPacket = types.CodeInvalidPacket
CodeSequenceNotFound = types.CodeSequenceNotFound
CodePacketTimeout = types.CodePacketTimeout
CodeInvalidChannel = types.CodeInvalidChannel
CodeInvalidChannelState = types.CodeInvalidChannelState
CodeInvalidChannelProof = types.CodeInvalidChannelProof
AttributeKeySenderPort = types.AttributeKeySenderPort
AttributeKeyReceiverPort = types.AttributeKeyReceiverPort
AttributeKeyChannelID = types.AttributeKeyChannelID
AttributeKeySequence = types.AttributeKeySequence
SubModuleName = types.SubModuleName
StoreKey = types.StoreKey
RouterKey = types.RouterKey
QuerierRoute = types.QuerierRoute
QueryChannel = types.QueryChannel
)

var (
// functions aliases
NewKeeper = keeper.NewKeeper
QuerierChannel = keeper.QuerierChannel
NewChannel = types.NewChannel
NewCounterparty = types.NewCounterparty
OrderFromString = types.OrderFromString
StateFromString = types.StateFromString
RegisterCodec = types.RegisterCodec
ErrChannelExists = types.ErrChannelExists
ErrChannelNotFound = types.ErrChannelNotFound
ErrInvalidCounterpartyChannel = types.ErrInvalidCounterpartyChannel
ErrChannelCapabilityNotFound = types.ErrChannelCapabilityNotFound
ErrInvalidPacket = types.ErrInvalidPacket
ErrSequenceNotFound = types.ErrSequenceNotFound
ErrPacketTimeout = types.ErrPacketTimeout
ErrInvalidChannel = types.ErrInvalidChannel
ErrInvalidChannelState = types.ErrInvalidChannelState
ErrInvalidChannelProof = types.ErrInvalidChannelProof
ChannelPath = types.ChannelPath
ChannelCapabilityPath = types.ChannelCapabilityPath
NextSequenceSendPath = types.NextSequenceSendPath
NextSequenceRecvPath = types.NextSequenceRecvPath
PacketCommitmentPath = types.PacketCommitmentPath
PacketAcknowledgementPath = types.PacketAcknowledgementPath
KeyChannel = types.KeyChannel
KeyChannelCapabilityPath = types.KeyChannelCapabilityPath
KeyNextSequenceSend = types.KeyNextSequenceSend
KeyNextSequenceRecv = types.KeyNextSequenceRecv
KeyPacketCommitment = types.KeyPacketCommitment
KeyPacketAcknowledgement = types.KeyPacketAcknowledgement
NewMsgChannelOpenInit = types.NewMsgChannelOpenInit
NewMsgChannelOpenTry = types.NewMsgChannelOpenTry
NewMsgChannelOpenAck = types.NewMsgChannelOpenAck
NewMsgChannelOpenConfirm = types.NewMsgChannelOpenConfirm
NewMsgChannelCloseInit = types.NewMsgChannelCloseInit
NewMsgChannelCloseConfirm = types.NewMsgChannelCloseConfirm
NewPacket = types.NewPacket
NewOpaquePacket = types.NewOpaquePacket
NewChannelResponse = types.NewChannelResponse
NewQueryChannelParams = types.NewQueryChannelParams

// variable aliases
SubModuleCdc = types.SubModuleCdc
EventTypeChannelOpenInit = types.EventTypeChannelOpenInit
EventTypeChannelOpenTry = types.EventTypeChannelOpenTry
EventTypeChannelOpenAck = types.EventTypeChannelOpenAck
EventTypeChannelOpenConfirm = types.EventTypeChannelOpenConfirm
EventTypeChannelCloseInit = types.EventTypeChannelCloseInit
EventTypeChannelCloseConfirm = types.EventTypeChannelCloseConfirm
AttributeValueCategory = types.AttributeValueCategory
)

type (
Keeper = keeper.Keeper
Channel = types.Channel
Counterparty = types.Counterparty
Order = types.Order
State = types.State
ClientKeeper = types.ClientKeeper
ConnectionKeeper = types.ConnectionKeeper
PortKeeper = types.PortKeeper
MsgChannelOpenInit = types.MsgChannelOpenInit
MsgChannelOpenTry = types.MsgChannelOpenTry
MsgChannelOpenAck = types.MsgChannelOpenAck
MsgChannelOpenConfirm = types.MsgChannelOpenConfirm
MsgChannelCloseInit = types.MsgChannelCloseInit
MsgChannelCloseConfirm = types.MsgChannelCloseConfirm
Packet = types.Packet
OpaquePacket = types.OpaquePacket
ChannelResponse = types.ChannelResponse
QueryChannelParams = types.QueryChannelParams
)
55 changes: 55 additions & 0 deletions x/ibc/04-channel/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package cli

import (
"fmt"
"strings"

"github.com/spf13/cobra"

cli "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/client/utils"
)

// GetQueryCmd returns the query commands for IBC channels
func GetQueryCmd(storeKey string, cdc *codec.Codec) *cobra.Command {
ics04ChannelQueryCmd := &cobra.Command{
Use: "channel",
Short: "IBC channel query subcommands",
DisableFlagParsing: true,
}

ics04ChannelQueryCmd.AddCommand(cli.GetCommands(
GetCmdQueryChannel(storeKey, cdc),
)...)

return ics04ChannelQueryCmd
}

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

ch, err := utils.QueryChannel(cliCtx, args[0], args[1], queryRoute)
if err != nil {
return err
}

return cliCtx.PrintOutput(ch)
},
}
return cmd
}
Loading

0 comments on commit 87d09fd

Please sign in to comment.