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

ICS23 refactor #5710

Merged
merged 4 commits into from
Feb 27, 2020
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 x/ibc/02-client/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/client/utils"
commitment "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment"
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
)

// GetCmdQueryClientStates defines the command to query all the light clients
Expand Down Expand Up @@ -173,7 +173,7 @@ func GetCmdQueryPath(storeName string, cdc *codec.Codec) *cobra.Command {
Short: "Query the commitment path of the running chain",
RunE: func(cmd *cobra.Command, args []string) error {
ctx := context.NewCLIContext().WithCodec(cdc)
path := commitment.NewPrefix([]byte("ibc"))
path := commitmenttypes.NewMerklePrefix([]byte("ibc"))
return ctx.PrintOutput(path)
},
}
Expand Down
6 changes: 3 additions & 3 deletions x/ibc/02-client/client/rest/swagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package rest
import (
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
commitment "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment"
commitmentexported "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/exported"
)

// nolint
Expand All @@ -29,7 +29,7 @@ type (
}

QueryPath struct {
Height int64 `json:"height"`
Result commitment.Prefix `json:"result"`
Height int64 `json:"height"`
Result commitmentexported.Prefix `json:"result"`
}
)
4 changes: 2 additions & 2 deletions x/ibc/02-client/client/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
commitment "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment"
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types"
)

Expand Down Expand Up @@ -149,7 +149,7 @@ func QueryNodeConsensusState(cliCtx context.CLIContext) (ibctmtypes.ConsensusSta

state := ibctmtypes.ConsensusState{
Timestamp: commit.Time,
Root: commitment.NewRoot(commit.AppHash),
Root: commitmenttypes.NewMerkleRoot(commit.AppHash),
ValidatorSet: tmtypes.NewValidatorSet(validators.Validators),
}

Expand Down
32 changes: 16 additions & 16 deletions x/ibc/02-client/exported/exported.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
evidenceexported "github.com/cosmos/cosmos-sdk/x/evidence/exported"
connectionexported "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/exported"
channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported"
commitment "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment"
commitmentexported "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/exported"
)

// ClientState defines the required common functions for light clients.
Expand All @@ -25,33 +25,33 @@ type ClientState interface {
VerifyClientConsensusState(
cdc *codec.Codec,
height uint64,
prefix commitment.PrefixI,
proof commitment.ProofI,
prefix commitmentexported.Prefix,
proof commitmentexported.Proof,
consensusState ConsensusState,
) error
VerifyConnectionState(
cdc *codec.Codec,
height uint64,
prefix commitment.PrefixI,
proof commitment.ProofI,
prefix commitmentexported.Prefix,
proof commitmentexported.Proof,
connectionID string,
connectionEnd connectionexported.ConnectionI,
consensusState ConsensusState,
) error
VerifyChannelState(
cdc *codec.Codec,
height uint64,
prefix commitment.PrefixI,
proof commitment.ProofI,
prefix commitmentexported.Prefix,
proof commitmentexported.Proof,
portID,
channelID string,
channel channelexported.ChannelI,
consensusState ConsensusState,
) error
VerifyPacketCommitment(
height uint64,
prefix commitment.PrefixI,
proof commitment.ProofI,
prefix commitmentexported.Prefix,
proof commitmentexported.Proof,
portID,
channelID string,
sequence uint64,
Expand All @@ -60,8 +60,8 @@ type ClientState interface {
) error
VerifyPacketAcknowledgement(
height uint64,
prefix commitment.PrefixI,
proof commitment.ProofI,
prefix commitmentexported.Prefix,
proof commitmentexported.Proof,
portID,
channelID string,
sequence uint64,
Expand All @@ -70,17 +70,17 @@ type ClientState interface {
) error
VerifyPacketAcknowledgementAbsence(
height uint64,
prefix commitment.PrefixI,
proof commitment.ProofI,
prefix commitmentexported.Prefix,
proof commitmentexported.Proof,
portID,
channelID string,
sequence uint64,
consensusState ConsensusState,
) error
VerifyNextSequenceRecv(
height uint64,
prefix commitment.PrefixI,
proof commitment.ProofI,
prefix commitmentexported.Prefix,
proof commitmentexported.Proof,
portID,
channelID string,
nextSequenceRecv uint64,
Expand All @@ -97,7 +97,7 @@ type ConsensusState interface {

// GetRoot returns the commitment root of the consensus state,
// which is used for key-value pair verification.
GetRoot() commitment.RootI
GetRoot() commitmentexported.Root

ValidateBasic() error
}
Expand Down
4 changes: 2 additions & 2 deletions x/ibc/02-client/keeper/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported"
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"

commitment "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment"
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
)

const (
Expand Down Expand Up @@ -149,7 +149,7 @@ func (suite *KeeperTestSuite) TestUpdateClient() {
expConsensusState := ibctmtypes.ConsensusState{
Height: uint64(updateHeader.Height),
Timestamp: updateHeader.Time,
Root: commitment.NewRoot(updateHeader.AppHash),
Root: commitmenttypes.NewMerkleRoot(updateHeader.AppHash),
ValidatorSet: updateHeader.ValidatorSet,
}

Expand Down
4 changes: 2 additions & 2 deletions x/ibc/02-client/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
commitment "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment"
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
Expand Down Expand Up @@ -137,7 +137,7 @@ func (k Keeper) GetSelfConsensusState(ctx sdk.Context, height uint64) (exported.
consensusState := ibctmtypes.ConsensusState{
Height: height,
Timestamp: ctx.BlockTime(),
Root: commitment.NewRoot(histInfo.Header.AppHash),
Root: commitmenttypes.NewMerkleRoot(histInfo.Header.AppHash),
ValidatorSet: tmtypes.NewValidatorSet(valSet.ToTmValidators()),
}
return consensusState, true
Expand Down
6 changes: 3 additions & 3 deletions x/ibc/02-client/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/keeper"
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
commitment "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment"
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
"github.com/cosmos/cosmos-sdk/x/staking"
)

Expand Down Expand Up @@ -60,7 +60,7 @@ func (suite *KeeperTestSuite) SetupTest() {
suite.consensusState = ibctmtypes.ConsensusState{
Height: testClientHeight,
Timestamp: suite.now,
Root: commitment.NewRoot([]byte("hash")),
Root: commitmenttypes.NewMerkleRoot([]byte("hash")),
ValidatorSet: suite.valSet,
}

Expand Down Expand Up @@ -162,7 +162,7 @@ func (suite KeeperTestSuite) TestConsensusStateHelpers() {
nextState := ibctmtypes.ConsensusState{
Height: testClientHeight + 5,
Timestamp: suite.now,
Root: commitment.NewRoot([]byte("next")),
Root: commitmenttypes.NewMerkleRoot([]byte("next")),
ValidatorSet: suite.valSet,
}

Expand Down
26 changes: 13 additions & 13 deletions x/ibc/02-client/types/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/tendermint/tendermint/crypto/merkle"

"github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported"
commitment "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment"
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types"
)

Expand Down Expand Up @@ -35,10 +35,10 @@ func NewQueryAllClientsParams(page, limit int) QueryAllClientsParams {
// StateResponse defines the client response for a client state query.
// It includes the commitment proof and the height of the proof.
type StateResponse struct {
ClientState exported.ClientState `json:"client_state" yaml:"client_state"`
Proof commitment.Proof `json:"proof,omitempty" yaml:"proof,omitempty"`
ProofPath commitment.Path `json:"proof_path,omitempty" yaml:"proof_path,omitempty"`
ProofHeight uint64 `json:"proof_height,omitempty" yaml:"proof_height,omitempty"`
ClientState exported.ClientState `json:"client_state" yaml:"client_state"`
Proof commitmenttypes.MerkleProof `json:"proof,omitempty" yaml:"proof,omitempty"`
ProofPath commitmenttypes.MerklePath `json:"proof_path,omitempty" yaml:"proof_path,omitempty"`
ProofHeight uint64 `json:"proof_height,omitempty" yaml:"proof_height,omitempty"`
}

// NewClientStateResponse creates a new StateResponse instance.
Expand All @@ -47,19 +47,19 @@ func NewClientStateResponse(
) StateResponse {
return StateResponse{
ClientState: clientState,
Proof: commitment.Proof{Proof: proof},
ProofPath: commitment.NewPath(strings.Split(ibctypes.ClientStatePath(clientID), "/")),
Proof: commitmenttypes.MerkleProof{Proof: proof},
ProofPath: commitmenttypes.NewMerklePath(strings.Split(ibctypes.ClientStatePath(clientID), "/")),
ProofHeight: uint64(height),
}
}

// ConsensusStateResponse defines the client response for a Consensus state query.
// It includes the commitment proof and the height of the proof.
type ConsensusStateResponse struct {
ConsensusState exported.ConsensusState `json:"consensus_state" yaml:"consensus_state"`
Proof commitment.Proof `json:"proof,omitempty" yaml:"proof,omitempty"`
ProofPath commitment.Path `json:"proof_path,omitempty" yaml:"proof_path,omitempty"`
ProofHeight uint64 `json:"proof_height,omitempty" yaml:"proof_height,omitempty"`
ConsensusState exported.ConsensusState `json:"consensus_state" yaml:"consensus_state"`
Proof commitmenttypes.MerkleProof `json:"proof,omitempty" yaml:"proof,omitempty"`
ProofPath commitmenttypes.MerklePath `json:"proof_path,omitempty" yaml:"proof_path,omitempty"`
ProofHeight uint64 `json:"proof_height,omitempty" yaml:"proof_height,omitempty"`
}

// NewConsensusStateResponse creates a new ConsensusStateResponse instance.
Expand All @@ -68,8 +68,8 @@ func NewConsensusStateResponse(
) ConsensusStateResponse {
return ConsensusStateResponse{
ConsensusState: cs,
Proof: commitment.Proof{Proof: proof},
ProofPath: commitment.NewPath(strings.Split(ibctypes.ConsensusStatePath(clientID, uint64(height)), "/")),
Proof: commitmenttypes.MerkleProof{Proof: proof},
ProofPath: commitmenttypes.NewMerklePath(strings.Split(ibctypes.ConsensusStatePath(clientID, uint64(height)), "/")),
ProofHeight: uint64(height),
}
}
2 changes: 1 addition & 1 deletion x/ibc/03-connection/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/ibc/03-connection/client/utils"
"github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
)
Expand Down
54 changes: 27 additions & 27 deletions x/ibc/03-connection/client/rest/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/types/rest"
commitment "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment"
commitmentexported "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/exported"
)

const (
Expand All @@ -21,42 +21,42 @@ func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, queryRoute string)

// ConnectionOpenInitReq defines the properties of a connection open init request's body.
type ConnectionOpenInitReq struct {
BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
ConnectionID string `json:"connection_id" yaml:"connection_id"`
ClientID string `json:"client_id" yaml:"client_id"`
CounterpartyClientID string `json:"counterparty_client_id" yaml:"counterparty_client_id"`
CounterpartyConnectionID string `json:"counterparty_connection_id" yaml:"counterparty_connection_id"`
CounterpartyPrefix commitment.PrefixI `json:"counterparty_prefix" yaml:"counterparty_prefix"`
BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
ConnectionID string `json:"connection_id" yaml:"connection_id"`
ClientID string `json:"client_id" yaml:"client_id"`
CounterpartyClientID string `json:"counterparty_client_id" yaml:"counterparty_client_id"`
CounterpartyConnectionID string `json:"counterparty_connection_id" yaml:"counterparty_connection_id"`
CounterpartyPrefix commitmentexported.Prefix `json:"counterparty_prefix" yaml:"counterparty_prefix"`
}

// ConnectionOpenTryReq defines the properties of a connection open try request's body.
type ConnectionOpenTryReq struct {
BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
ConnectionID string `json:"connection_id" yaml:"connection_id"`
ClientID string `json:"client_id" yaml:"client_id"`
CounterpartyClientID string `json:"counterparty_client_id" yaml:"counterparty_client_id"`
CounterpartyConnectionID string `json:"counterparty_connection_id" yaml:"counterparty_connection_id"`
CounterpartyPrefix commitment.PrefixI `json:"counterparty_prefix" yaml:"counterparty_prefix"`
CounterpartyVersions []string `json:"counterparty_versions" yaml:"counterparty_versions"`
ProofInit commitment.ProofI `json:"proof_init" yaml:"proof_init"`
ProofConsensus commitment.ProofI `json:"proof_consensus" yaml:"proof_consensus"`
ProofHeight uint64 `json:"proof_height" yaml:"proof_height"`
ConsensusHeight uint64 `json:"consensus_height" yaml:"consensus_height"`
BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
ConnectionID string `json:"connection_id" yaml:"connection_id"`
ClientID string `json:"client_id" yaml:"client_id"`
CounterpartyClientID string `json:"counterparty_client_id" yaml:"counterparty_client_id"`
CounterpartyConnectionID string `json:"counterparty_connection_id" yaml:"counterparty_connection_id"`
CounterpartyPrefix commitmentexported.Prefix `json:"counterparty_prefix" yaml:"counterparty_prefix"`
CounterpartyVersions []string `json:"counterparty_versions" yaml:"counterparty_versions"`
ProofInit commitmentexported.Proof `json:"proof_init" yaml:"proof_init"`
ProofConsensus commitmentexported.Proof `json:"proof_consensus" yaml:"proof_consensus"`
ProofHeight uint64 `json:"proof_height" yaml:"proof_height"`
ConsensusHeight uint64 `json:"consensus_height" yaml:"consensus_height"`
}

// ConnectionOpenAckReq defines the properties of a connection open ack request's body.
type ConnectionOpenAckReq struct {
BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
ProofTry commitment.ProofI `json:"proof_try" yaml:"proof_try"`
ProofConsensus commitment.ProofI `json:"proof_consensus" yaml:"proof_consensus"`
ProofHeight uint64 `json:"proof_height" yaml:"proof_height"`
ConsensusHeight uint64 `json:"consensus_height" yaml:"consensus_height"`
Version string `json:"version" yaml:"version"`
BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
ProofTry commitmentexported.Proof `json:"proof_try" yaml:"proof_try"`
ProofConsensus commitmentexported.Proof `json:"proof_consensus" yaml:"proof_consensus"`
ProofHeight uint64 `json:"proof_height" yaml:"proof_height"`
ConsensusHeight uint64 `json:"consensus_height" yaml:"consensus_height"`
Version string `json:"version" yaml:"version"`
}

// ConnectionOpenConfirmReq defines the properties of a connection open confirm request's body.
type ConnectionOpenConfirmReq struct {
BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
ProofAck commitment.ProofI `json:"proof_ack" yaml:"proof_ack"`
ProofHeight uint64 `json:"proof_height" yaml:"proof_height"`
BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
ProofAck commitmentexported.Proof `json:"proof_ack" yaml:"proof_ack"`
ProofHeight uint64 `json:"proof_height" yaml:"proof_height"`
}
16 changes: 8 additions & 8 deletions x/ibc/03-connection/client/rest/swagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,29 @@ type (

PostConnectionOpenInit struct {
Msgs []types.MsgConnectionOpenInit `json:"msg" yaml:"msg"`
Fee authtypes.StdFee `json:"fee" yaml:"fee"`
Signatures []authtypes.StdSignature `json:"signatures" yaml:"signatures"`
Fee authtypes.StdFee `json:"fee" yaml:"fee"`
Signatures []authtypes.StdSignature `json:"signatures" yaml:"signatures"`
Memo string `json:"memo" yaml:"memo"`
}

PostConnectionOpenTry struct {
Msgs []types.MsgConnectionOpenTry `json:"msg" yaml:"msg"`
Fee authtypes.StdFee `json:"fee" yaml:"fee"`
Signatures []authtypes.StdSignature `json:"signatures" yaml:"signatures"`
Fee authtypes.StdFee `json:"fee" yaml:"fee"`
Signatures []authtypes.StdSignature `json:"signatures" yaml:"signatures"`
Memo string `json:"memo" yaml:"memo"`
}

PostConnectionOpenAck struct {
Msgs []types.MsgConnectionOpenAck `json:"msg" yaml:"msg"`
Fee authtypes.StdFee `json:"fee" yaml:"fee"`
Signatures []authtypes.StdSignature `json:"signatures" yaml:"signatures"`
Fee authtypes.StdFee `json:"fee" yaml:"fee"`
Signatures []authtypes.StdSignature `json:"signatures" yaml:"signatures"`
Memo string `json:"memo" yaml:"memo"`
}

PostConnectionOpenConfirm struct {
Msgs []types.MsgConnectionOpenConfirm `json:"msg" yaml:"msg"`
Fee authtypes.StdFee `json:"fee" yaml:"fee"`
Signatures []authtypes.StdSignature `json:"signatures" yaml:"signatures"`
Fee authtypes.StdFee `json:"fee" yaml:"fee"`
Signatures []authtypes.StdSignature `json:"signatures" yaml:"signatures"`
Memo string `json:"memo" yaml:"memo"`
}
)
Loading