Skip to content

Commit

Permalink
x/ibc: proto migration pt 1 (cosmos#6097)
Browse files Browse the repository at this point in the history
* x/ibc: proto migration pt 1

* fix tests

* fixes and godoc

* yaml tags

* rm changelog

* address comments from review

* fix some tests

* fix tests

* add _UNSPECIFIED suffix for default enums

* Update app

* protobuf Any fixes

* use gogoproto

* fix tests

* wrap all messages

* address @alexanderbez comments

* update proto files

Co-authored-by: Alexander Bezobchuk <[email protected]>
Co-authored-by: Aleksandr Bezobchuk <[email protected]>
Co-authored-by: Aaron Craelius <[email protected]>
  • Loading branch information
4 people authored May 6, 2020
1 parent bb0a1ed commit d7ebee7
Show file tree
Hide file tree
Showing 84 changed files with 11,009 additions and 1,441 deletions.
6 changes: 4 additions & 2 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,15 @@ func NewSimApp(
)

// Create IBC Keeper
// TODO: remove amino codec dependency once Tendermint version is upgraded with
// protobuf changes
app.IBCKeeper = ibc.NewKeeper(
app.cdc, keys[ibc.StoreKey], app.StakingKeeper, scopedIBCKeeper,
app.cdc, appCodec, keys[ibc.StoreKey], app.StakingKeeper, scopedIBCKeeper,
)

// Create Transfer Keepers
app.TransferKeeper = transfer.NewKeeper(
app.cdc, keys[transfer.StoreKey],
appCodec, keys[transfer.StoreKey],
app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper,
app.AccountKeeper, app.BankKeeper, scopedTransferKeeper,
)
Expand Down
7 changes: 4 additions & 3 deletions std/codec.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions std/codec.proto
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ message MsgSubmitProposal {
Content content = 2;
}

// Proposal defines the application-level concrete proposal type used in governance
// proposals.
// Proposal defines the application-level concrete proposal type used in
// governance proposals.
message Proposal {
option (gogoproto.equal) = true;

Expand All @@ -67,7 +67,8 @@ message Content {
option (gogoproto.equal) = true;
option (cosmos_proto.interface_type) = "*github.com/cosmos/cosmos-sdk/x/gov/types.Content";

// sum defines a set of all acceptable concrete governance proposal Content types.
// sum defines a set of all acceptable concrete governance proposal Content
// types.
oneof sum {
cosmos_sdk.x.gov.v1.TextProposal text = 1;
cosmos_sdk.x.params.v1.ParameterChangeProposal parameter_change = 2;
Expand Down
4 changes: 2 additions & 2 deletions x/evidence/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package types
import (
"time"

"github.com/tendermint/tendermint/crypto"

sdk "github.com/cosmos/cosmos-sdk/types"
stakingexported "github.com/cosmos/cosmos-sdk/x/staking/exported"

"github.com/tendermint/tendermint/crypto"
)

type (
Expand Down
4 changes: 2 additions & 2 deletions x/ibc/02-client/exported/exported.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type ClientState interface {
consensusState ConsensusState,
) error
VerifyConnectionState(
cdc *codec.Codec,
cdc codec.Marshaler,
height uint64,
prefix commitmentexported.Prefix,
proof commitmentexported.Proof,
Expand All @@ -44,7 +44,7 @@ type ClientState interface {
consensusState ConsensusState,
) error
VerifyChannelState(
cdc *codec.Codec,
cdc codec.Marshaler,
height uint64,
prefix commitmentexported.Prefix,
proof commitmentexported.Proof,
Expand Down
1 change: 1 addition & 0 deletions x/ibc/03-connection/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var (
QuerierConnections = keeper.QuerierConnections
QuerierClientConnections = keeper.QuerierClientConnections
RegisterCodec = types.RegisterCodec
RegisterInterfaces = types.RegisterInterfaces
NewConnectionEnd = types.NewConnectionEnd
NewCounterparty = types.NewCounterparty
ErrConnectionExists = types.ErrConnectionExists
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"
commitmentexported "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/exported"
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
)

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 commitmentexported.Prefix `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 commitmenttypes.MerklePrefix `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 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"`
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 commitmenttypes.MerklePrefix `json:"counterparty_prefix" yaml:"counterparty_prefix"`
CounterpartyVersions []string `json:"counterparty_versions" yaml:"counterparty_versions"`
ProofInit commitmenttypes.MerkleProof `json:"proof_init" yaml:"proof_init"`
ProofConsensus commitmenttypes.MerkleProof `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 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"`
BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
ProofTry commitmenttypes.MerkleProof `json:"proof_try" yaml:"proof_try"`
ProofConsensus commitmenttypes.MerkleProof `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 commitmentexported.Proof `json:"proof_ack" yaml:"proof_ack"`
ProofHeight uint64 `json:"proof_height" yaml:"proof_height"`
BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
ProofAck commitmenttypes.MerkleProof `json:"proof_ack" yaml:"proof_ack"`
ProofHeight uint64 `json:"proof_height" yaml:"proof_height"`
}
70 changes: 2 additions & 68 deletions x/ibc/03-connection/exported/exported.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package exported

import (
"encoding/json"

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

// ConnectionI describes the required methods for a connection.
type ConnectionI interface {
GetState() State
GetState() ibctypes.State
GetID() string
GetClientID() string
GetCounterparty() CounterpartyI
Expand All @@ -23,68 +22,3 @@ type CounterpartyI interface {
GetPrefix() commitmentexported.Prefix
ValidateBasic() error
}

// State defines the state of a connection between two disctinct
// chains
type State byte

// available connection states
const (
UNINITIALIZED State = iota // default State
INIT
TRYOPEN
OPEN
)

// string representation of the connection states
const (
StateUninitialized string = "UNINITIALIZED"
StateInit string = "INIT"
StateTryOpen string = "TRYOPEN"
StateOpen string = "OPEN"
)

// String implements the Stringer interface
func (s State) String() string {
switch s {
case INIT:
return StateInit
case TRYOPEN:
return StateTryOpen
case OPEN:
return StateOpen
default:
return StateUninitialized
}
}

// StateFromString parses a string into a connection state
func StateFromString(state string) State {
switch state {
case StateInit:
return INIT
case StateTryOpen:
return TRYOPEN
case StateOpen:
return OPEN
default:
return UNINITIALIZED
}
}

// MarshalJSON marshal to JSON using string.
func (s State) MarshalJSON() ([]byte, error) {
return json.Marshal(s.String())
}

// UnmarshalJSON decodes from JSON assuming Bech32 encoding.
func (s *State) UnmarshalJSON(data []byte) error {
var str string
err := json.Unmarshal(data, &str)
if err != nil {
return err
}

*s = StateFromString(str)
return nil
}
46 changes: 0 additions & 46 deletions x/ibc/03-connection/exported/exported_test.go

This file was deleted.

Loading

0 comments on commit d7ebee7

Please sign in to comment.