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

x/ibc: proto migration pt 1 #6097

Merged
merged 33 commits into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
31a4670
x/ibc: proto migration pt 1
fedekunze Apr 29, 2020
7524bf7
fix tests
fedekunze Apr 29, 2020
5596dd3
fixes and godoc
fedekunze Apr 29, 2020
b911032
yaml tags
fedekunze Apr 29, 2020
68cc932
rm changelog
fedekunze Apr 29, 2020
22bc941
fix conflicts
fedekunze May 4, 2020
ad022fa
address comments from review
fedekunze May 4, 2020
0ccb4e1
fix some tests
fedekunze May 4, 2020
7d5d0c6
fix tests
fedekunze May 4, 2020
b8b04c6
Merge branch 'master' into ibc-proto-1
fedekunze May 4, 2020
50eab5a
Merge branch 'master' of github.com:cosmos/cosmos-sdk into ibc-proto-1
fedekunze May 4, 2020
2fd640b
add _UNSPECIFIED suffix for default enums
fedekunze May 4, 2020
6650381
Merge branch 'ibc-proto-1' of github.com:cosmos/cosmos-sdk into ibc-p…
fedekunze May 4, 2020
87fdf2d
Merge branch 'master' into ibc-proto-1
fedekunze May 4, 2020
568a95b
Merge branch 'master' into ibc-proto-1
alexanderbez May 4, 2020
baf0601
Merge branch 'master' into ibc-proto-1
fedekunze May 5, 2020
4f584f7
Merge branch 'master' into ibc-proto-1
alexanderbez May 5, 2020
6a6a482
Update app
alexanderbez May 5, 2020
8c94311
protobuf Any fixes
fedekunze May 5, 2020
e8b8a6a
use gogoproto
fedekunze May 5, 2020
41e1d06
fix conflicts
fedekunze May 5, 2020
4b96586
fix tests
fedekunze May 5, 2020
3a43058
Merge branch 'master' into ibc-proto-1
alexanderbez May 5, 2020
1018479
Merge branch 'master' into ibc-proto-1
aaronc May 5, 2020
0416af2
Merge branch 'master' into ibc-proto-1
fedekunze May 5, 2020
79e6f0a
wrap all messages
fedekunze May 5, 2020
1ac2173
Merge branch 'ibc-proto-1' of github.com:cosmos/cosmos-sdk into ibc-p…
fedekunze May 5, 2020
8a62f8a
address @alexanderbez comments
fedekunze May 6, 2020
eb8f67a
update proto files
fedekunze May 6, 2020
0ae4ccf
Merge branch 'master' into ibc-proto-1
fedekunze May 6, 2020
2e6048b
Merge branch 'master' into ibc-proto-1
fedekunze May 6, 2020
660269b
Merge branch 'master' into ibc-proto-1
fedekunze May 6, 2020
8b3261e
Merge branch 'master' into ibc-proto-1
fedekunze May 6, 2020
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ functionality that requires an online connection.
* (simulation) [\#6002](https://github.com/cosmos/cosmos-sdk/pull/6002) Add randomized consensus params into simulation.
* (x/staking) [\#6059](https://github.com/cosmos/cosmos-sdk/pull/6059) Updated `HistoricalEntries` parameter default to 100.
* (x/ibc) [\#5948](https://github.com/cosmos/cosmos-sdk/issues/5948) Add `InitGenesis` and `ExportGenesis` functions for `ibc` module.
* (x/ibc) [\#6097](https://github.com/cosmos/cosmos-sdk/pull/6097) Migrate `x/ibc` state to protobuf.
fedekunze marked this conversation as resolved.
Show resolved Hide resolved

## [v0.38.3] - 2020-04-09

Expand Down
2 changes: 2 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ lint:
- UNARY_RPC
- COMMENT_FIELD
- PACKAGE_DIRECTORY_MATCH
- ENUM_ZERO_VALUE_SUFFIX
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- ENUM_ZERO_VALUE_SUFFIX
enum_zero_value_suffix: _DEFAULT

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexanderbez what do you think of using the _DEFAULT suffix rather than just disabling ENUM_ZERO_VALUE_SUFFIX? We would then need to change all our existing enum's to end in _DEFAULT though

- ENUM_VALUE_PREFIX
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
ignore:
- third_party
- codec/testdata
Expand Down
4 changes: 2 additions & 2 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,12 @@ func NewSimApp(

// Create IBC Keeper
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
2,745 changes: 1,983 additions & 762 deletions std/codec.pb.go

Large diffs are not rendered by default.

23 changes: 20 additions & 3 deletions std/codec.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import "x/slashing/types/types.proto";
import "x/staking/types/types.proto";
import "x/params/types/proposal/types.proto";
import "x/upgrade/types/types.proto";
import "x/ibc/03-connection/types/types.proto";
import "x/ibc/04-channel/types/types.proto";
import "x/ibc/20-transfer/types/types.proto";

option go_package = "github.com/cosmos/cosmos-sdk/std";

Expand Down Expand Up @@ -75,8 +78,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 @@ -90,7 +93,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 Expand Up @@ -134,6 +138,19 @@ message Message {
cosmos_sdk.x.staking.v1.MsgDelegate msg_delegate = 15;
cosmos_sdk.x.staking.v1.MsgBeginRedelegate msg_begin_redelegate = 16;
cosmos_sdk.x.staking.v1.MsgUndelegate msg_undelegate = 17;
cosmos_sdk.x.ibc.connection.v1.MsgConnectionOpenInit msg_connection_open_init = 18;
cosmos_sdk.x.ibc.connection.v1.MsgConnectionOpenTry msg_connection_open_try = 19;
cosmos_sdk.x.ibc.connection.v1.MsgConnectionOpenAck msg_connection_open_ack = 20;
cosmos_sdk.x.ibc.connection.v1.MsgConnectionOpenConfirm msg_connection_open_confirm = 21;
cosmos_sdk.x.ibc.channel.v1.MsgChannelOpenInit msg_channel_open_init = 22;
cosmos_sdk.x.ibc.channel.v1.MsgChannelOpenTry msg_channel_open_try = 23;
cosmos_sdk.x.ibc.channel.v1.MsgChannelOpenAck msg_channel_open_ack = 24;
cosmos_sdk.x.ibc.channel.v1.MsgChannelOpenConfirm msg_channel_open_confirm = 25;
cosmos_sdk.x.ibc.channel.v1.MsgChannelCloseInit msg_channel_close_init = 26;
cosmos_sdk.x.ibc.channel.v1.MsgChannelCloseConfirm msg_channel_close_confirm = 27;
cosmos_sdk.x.ibc.channel.v1.MsgPacket msg_packet = 28;
cosmos_sdk.x.ibc.channel.v1.MsgAcknowledgement msg_acknowledgement = 29;
cosmos_sdk.x.ibc.transfer.v1.MsgTransfer msg_transfer = 30;
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
}
}

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