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

Closed
wants to merge 62 commits into from
Closed
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
e59c32d
proto: remove cdc from ICS05
fedekunze Feb 26, 2020
6ef884f
proto: start ICS07 proto files
fedekunze Feb 26, 2020
85cc953
proto: ICS20 types
fedekunze Feb 26, 2020
d172449
proto: ICS07 messages
fedekunze Feb 26, 2020
796fe70
proto: ICS04 messages
fedekunze Feb 26, 2020
8a38c3e
proto: various ICS proto definitions
fedekunze Feb 26, 2020
a1c9ae0
proto: fixes
fedekunze Feb 26, 2020
fad6b52
godocs for ICS 07 proto file
fedekunze Feb 27, 2020
8b83fb1
proto: generate files
fedekunze Feb 27, 2020
43e38d6
merge ICS23 changes
fedekunze Mar 2, 2020
d574210
merge ibc-alpha changes
fedekunze Mar 23, 2020
5510c34
ibc: protobuf changes
fedekunze Mar 23, 2020
2d251e4
codec: move ibc client proto interfaces
fedekunze Mar 23, 2020
fc70c2e
ibc: fix some msgs and types
fedekunze Mar 23, 2020
8da8960
proto: cycles and other fixes
fedekunze Mar 24, 2020
0db08a3
proto: changes and fixes
fedekunze Mar 24, 2020
5a5816f
update types
fedekunze Mar 24, 2020
fa84a19
merge ibc-alpha changes
fedekunze Mar 24, 2020
ff66afb
fix dep cycle
fedekunze Mar 25, 2020
dfe061d
codec/std: add msgs
fedekunze Mar 25, 2020
3475fca
commitment: proto changes
fedekunze Mar 25, 2020
ee12807
fix dep cycle with Status and Order
fedekunze Mar 25, 2020
daf8f01
add tmtypes proto3 to third party
fedekunze Mar 25, 2020
ccdb13b
fixes fixes fixes
fedekunze Mar 27, 2020
94a62ca
revert GetDestination{Channel.Port}
fedekunze Mar 27, 2020
01d4651
cleanup
fedekunze Mar 27, 2020
934a576
fixes
fedekunze Mar 27, 2020
a4749e3
util funcs for tm <-> proto
fedekunze Mar 27, 2020
ea46b7f
more cleanup
fedekunze Mar 27, 2020
cff3c94
more util funcs
fedekunze Mar 30, 2020
c8229a3
more fixes
fedekunze Mar 30, 2020
610fafc
Merge branch 'ibc-alpha' of https://github.com/cosmos/cosmos-sdk into…
fedekunze Mar 31, 2020
ced1d63
more test fixes
fedekunze Mar 31, 2020
077a13f
fixes
fedekunze Mar 31, 2020
554de2d
remove PacketData and PacketAck interfaces
fedekunze Apr 1, 2020
ba1cb08
FINALLY! build
fedekunze Apr 1, 2020
2ecbb5b
fix some tests
fedekunze Apr 1, 2020
c5d00b5
fix more tests
fedekunze Apr 1, 2020
8b3400f
lint
fedekunze Apr 2, 2020
3c38a61
proto cleanup
fedekunze Apr 2, 2020
048b8d1
Merge branch 'ibc-alpha' of https://github.com/cosmos/cosmos-sdk into…
fedekunze Apr 2, 2020
2614026
try fix ics07 errors
fedekunze Apr 2, 2020
5079c78
lint
fedekunze Apr 2, 2020
80ec515
merge ibc-alpha
fedekunze Apr 3, 2020
cced361
Merge branch 'ibc-alpha' of https://github.com/cosmos/cosmos-sdk into…
fedekunze Apr 3, 2020
48828f0
Merge branch 'ibc-alpha' of github.com:cosmos/cosmos-sdk into fedekun…
fedekunze Apr 3, 2020
773a6ec
merge tm-proto
fedekunze Apr 6, 2020
9bd476f
fixes
fedekunze Apr 6, 2020
99cab85
minor updates
fedekunze Apr 7, 2020
bc0f744
merge ibc-alpha changes
fedekunze Apr 8, 2020
9dd94c0
update proto files
fedekunze Apr 8, 2020
c8669df
build
fedekunze Apr 8, 2020
f8d64c8
updates from downstream
fedekunze Apr 14, 2020
0d62302
update proto deps
fedekunze Apr 14, 2020
524cce4
fix ics07 test
fedekunze Apr 14, 2020
e5d4641
changes from master
fedekunze Apr 16, 2020
dd9df29
fix build
fedekunze Apr 16, 2020
6dac284
test fixes
fedekunze Apr 16, 2020
4d3058a
updates from downstream
fedekunze Apr 21, 2020
1b7b9c8
fixes
fedekunze Apr 21, 2020
e422b08
proto ics09
fedekunze Apr 21, 2020
8d794fa
changes from master
fedekunze Apr 29, 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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ COSMOS_PROTO_URL = https://raw.githubusercontent.com/regen-network/cosmos-proto/
TM_KV_TYPES = third_party/proto/tendermint/libs/kv
TM_MERKLE_TYPES = third_party/proto/tendermint/crypto/merkle
TM_ABCI_TYPES = third_party/proto/tendermint/abci/types
TM_PROTO = third_party/proto/tendermint/proto
TM_PROTO = third_party/proto/tendermint/proto
GOGO_PROTO_TYPES = third_party/proto/gogoproto
COSMOS_PROTO_TYPES = third_party/proto/cosmos-proto
SDK_PROTO_TYPES = third_party/proto/cosmos-sdk/types
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_VALUE_PREFIX
- ENUM_ZERO_VALUE_SUFFIX
ignore:
- third_party
- codec/testdata
Expand Down
1 change: 1 addition & 0 deletions codec/std/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var (
_ supply.Codec = (*Codec)(nil)
_ evidence.Codec = (*Codec)(nil)
_ gov.Codec = (*Codec)(nil)
// _ clienttypes.Codec = (*Codec)(nil)
)

// Codec defines the application-level codec. This codec contains all the
Expand Down
6,316 changes: 4,755 additions & 1,561 deletions codec/std/codec.pb.go

Large diffs are not rendered by default.

129 changes: 104 additions & 25 deletions codec/std/codec.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ 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/07-tendermint/types/types.proto";
import "x/ibc/20-transfer/types/types.proto";

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

Expand Down Expand Up @@ -51,7 +55,8 @@ message Evidence {

// sum defines a set of all acceptable concrete Evidence implementations.
oneof sum {
cosmos_sdk.x.evidence.v1.Equivocation equivocation = 1;
cosmos_sdk.x.evidence.v1.Equivocation equivocation = 1;
cosmos_sdk.x.ibc.tendermint.v1.Evidence client_misbehaviour = 2;
}
}

Expand All @@ -75,8 +80,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 +95,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 All @@ -100,14 +106,68 @@ message Content {
}
}

message ClientState {
option (cosmos_proto.interface_type) = "*github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported.ClientState";
// sum defines a set of all acceptable concrete ClientState implementations.
oneof sum {
cosmos_sdk.x.ibc.tendermint.v1.ClientState tendermint = 1;
}
}

message ConsensusState {
option (cosmos_proto.interface_type) = "*github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported.ConsensusState";
// sum defines a set of all acceptable concrete ConsensusState
// implementations.
oneof sum {
cosmos_sdk.x.ibc.tendermint.v1.ConsensusState tendermint = 1;
}
}

message Misbehaviour {
option (cosmos_proto.interface_type) = "*github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported.Misbehaviour";
// sum defines a set of all acceptable concrete Misbehaviour implementations.
oneof sum {
cosmos_sdk.x.ibc.tendermint.v1.Evidence tendermint = 1;
}
}

message Header {
option (cosmos_proto.interface_type) = "*github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported.Header";
// sum defines a set of all acceptable concrete Header implementations.
oneof sum {
cosmos_sdk.x.ibc.tendermint.v1.Header tendermint = 1;
}
}

message MsgCreateClient {
option (cosmos_proto.interface_type) = "*github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported.MsgCreateClient";
oneof sum {
// sum defines a set of all acceptable concrete MsgCreateClient
// implementations.
cosmos_sdk.x.ibc.tendermint.v1.MsgCreateClient tendermint = 1;
}
}

message MsgUpdateClient {
option (cosmos_proto.interface_type) = "*github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported.MsgUpdateClient";
// sum defines a set of all acceptable concrete MsgUpdateClient
// implementations.
oneof sum {
cosmos_sdk.x.ibc.tendermint.v1.MsgUpdateClient tendermint = 1;
}
}

// Transaction defines the application-level transaction that can be signed and
// processed by the state-machine. It contains a base of common fields and
// repeated set of Message types.
message Transaction {
option (gogoproto.goproto_getters) = false;

cosmos_sdk.x.auth.v1.StdTxBase base = 1
[(gogoproto.jsontag) = "", (gogoproto.embed) = true, (gogoproto.nullable) = false];
cosmos_sdk.x.auth.v1.StdTxBase base = 1 [
(gogoproto.jsontag) = "",
(gogoproto.embed) = true,
(gogoproto.nullable) = false
];
repeated Message msgs = 2 [(gogoproto.nullable) = false];
}

Expand All @@ -118,30 +178,49 @@ message Message {

// sum defines the set of all allowed valid messages defined in modules.
oneof sum {
cosmos_sdk.x.bank.v1.MsgSend msg_send = 1;
cosmos_sdk.x.bank.v1.MsgMultiSend msg_multi_send = 2;
cosmos_sdk.x.crisis.v1.MsgVerifyInvariant msg_verify_invariant = 3;
cosmos_sdk.x.distribution.v1.MsgSetWithdrawAddress msg_set_withdraw_address = 4;
cosmos_sdk.x.distribution.v1.MsgWithdrawDelegatorReward msg_withdraw_delegator_reward = 5;
cosmos_sdk.x.distribution.v1.MsgWithdrawValidatorCommission msg_withdraw_validator_commission = 6;
cosmos_sdk.x.distribution.v1.MsgFundCommunityPool msg_fund_community_pool = 7;
MsgSubmitEvidence msg_submit_evidence = 8;
MsgSubmitProposal msg_submit_proposal = 9;
cosmos_sdk.x.gov.v1.MsgVote msg_vote = 10;
cosmos_sdk.x.gov.v1.MsgDeposit msg_deposit = 11;
cosmos_sdk.x.slashing.v1.MsgUnjail msg_unjail = 12;
cosmos_sdk.x.staking.v1.MsgCreateValidator msg_create_validator = 13;
cosmos_sdk.x.staking.v1.MsgEditValidator msg_edit_validator = 14;
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.bank.v1.MsgSend msg_send = 1;
cosmos_sdk.x.bank.v1.MsgMultiSend msg_multi_send = 2;
cosmos_sdk.x.crisis.v1.MsgVerifyInvariant msg_verify_invariant = 3;
cosmos_sdk.x.distribution.v1.MsgSetWithdrawAddress msg_set_withdraw_address = 4;
cosmos_sdk.x.distribution.v1.MsgWithdrawDelegatorReward msg_withdraw_delegator_reward = 5;
cosmos_sdk.x.distribution.v1.MsgWithdrawValidatorCommission msg_withdraw_validator_commission = 6;
cosmos_sdk.x.distribution.v1.MsgFundCommunityPool msg_fund_community_pool = 7;
MsgSubmitEvidence msg_submit_evidence = 8;
MsgSubmitProposal msg_submit_proposal = 9;
cosmos_sdk.x.gov.v1.MsgVote msg_vote = 10;
cosmos_sdk.x.gov.v1.MsgDeposit msg_deposit = 11;
cosmos_sdk.x.slashing.v1.MsgUnjail msg_unjail = 12;
cosmos_sdk.x.staking.v1.MsgCreateValidator msg_create_validator = 13;
cosmos_sdk.x.staking.v1.MsgEditValidator msg_edit_validator = 14;
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.tendermint.v1.MsgCreateClient msg_create_client_tendermint = 30; // TODO: should I use the interface defined above instead?
cosmos_sdk.x.ibc.tendermint.v1.MsgUpdateClient msg_update_client_tendermint = 31; // TODO: ditto
cosmos_sdk.x.ibc.tendermint.v1.MsgSubmitClientMisbehaviour msg_submit_client_misbehaviour_tendermint = 32; // FIXME: use submit evidence msg?
cosmos_sdk.x.ibc.transfer.v1.MsgTransfer msg_transfer = 33;
}
}

// SignDoc defines a standard application-level signing document to compose
// signatures for a Transaction.
message SignDoc {
cosmos_sdk.x.auth.v1.StdSignDocBase base = 1
[(gogoproto.jsontag) = "", (gogoproto.embed) = true, (gogoproto.nullable) = false];
cosmos_sdk.x.auth.v1.StdSignDocBase base = 1 [
(gogoproto.jsontag) = "",
(gogoproto.embed) = true,
(gogoproto.nullable) = false
];
repeated Message msgs = 2 [(gogoproto.nullable) = false];
}
4 changes: 2 additions & 2 deletions crypto/hd/fundraiser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestFundraiserCompatibility(t *testing.T) {
master, ch := hd.ComputeMastersFromSeed(seed)
priv, err := hd.DerivePrivateKeyForPath(master, ch, "44'/118'/0'/0/0")
require.NoError(t, err)
pub := secp256k1.PrivKey(priv).PubKey()
pub := secp256k1.PrivKey(priv[:]).PubKey()

t.Log("\tNODEJS GOLANG\n")
t.Logf("SEED \t%X %X\n", seedB, seed)
Expand All @@ -78,7 +78,7 @@ func TestFundraiserCompatibility(t *testing.T) {
require.Equal(t, priv[:], privB, "Expected priv keys to match")
var pubBFixed [33]byte
copy(pubBFixed[:], pubB)
require.Equal(t, pub, secp256k1.PubKey(pubBFixed), fmt.Sprintf("Expected pub keys to match for %d", i))
require.Equal(t, pub, secp256k1.PubKey(pubBFixed[:]), fmt.Sprintf("Expected pub keys to match for %d", i))

addr := pub.Address()
t.Logf("ADDR \t%X %X\n", addrB, addr)
Expand Down
4 changes: 2 additions & 2 deletions docs/architecture/adr-015-ibc-packet-receiver.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func handleMsgTransfer(ctx Context, k Keeper, msg MsgTransfer) Result {
}

func handlePacketDataTransfer(ctx Context, k Keeper, packet Packet, data PacketDataTransfer) Result {
err := k.ReceiveTransfer(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetDestinationPort(), packet.GetDestinationChannel(), data)
err := k.ReceiveTransfer(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetDestPort(), packet.GetDestChannel(), data)
if err != nil {
// TODO: Source chain sent invalid packet, shutdown channel
}
Expand All @@ -257,7 +257,7 @@ func handlePacketDataTransfer(ctx Context, k Keeper, packet Packet, data PacketD
}

func handleCustomTimeoutPacket(ctx Context, k Keeper, packet CustomPacket) Result {
err := k.RecoverTransfer(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetDestinationPort(), packet.GetDestinationChannel(), data)
err := k.RecoverTransfer(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetDestPort(), packet.GetDestChannel(), data)
if err != nil {
// This chain sent invalid packet or cannot recover the funds
panic(err)
Expand Down
55 changes: 55 additions & 0 deletions third_party/proto/tendermint/types/types.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
syntax = "proto3";

package tendermint.types.proto3;
option go_package = "github.com/tendermint/tendermint/types/proto3";

message PartSetHeader {
int32 Total = 1;
bytes Hash = 2;
}

message BlockID {
bytes Hash = 1;
PartSetHeader PartsHeader = 2;
}

message Header {
// basic block info
Version Version = 1;
string ChainID = 2;
int64 Height = 3;
Timestamp Time = 4;

// prev block info
BlockID LastBlockID = 5;

// hashes of block data
bytes LastCommitHash = 6; // commit from validators from the last block
bytes DataHash = 7; // transactions

// hashes from the app output from the prev block
bytes ValidatorsHash = 8; // validators for the current block
bytes NextValidatorsHash = 9; // validators for the next block
bytes ConsensusHash = 10; // consensus params for current block
bytes AppHash = 11; // state after txs from the previous block
bytes LastResultsHash = 12; // root hash of all results from the txs from the previous block

// consensus info
bytes EvidenceHash = 13; // evidence included in the block
bytes ProposerAddress = 14; // original proposer of the block
}

message Version {
uint64 Block = 1;
uint64 App = 2;
}

// Timestamp wraps how amino encodes time.
// This is the protobuf well-known type protobuf/timestamp.proto
// See:
// https://github.com/google/protobuf/blob/d2980062c859649523d5fd51d6b55ab310e47482/src/google/protobuf/timestamp.proto#L123-L135
// NOTE/XXX: nanos do not get skipped if they are zero in amino.
message Timestamp {
int64 seconds = 1;
int32 nanos = 2;
}
25 changes: 22 additions & 3 deletions x/ibc/02-client/client/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,19 @@ func QueryTendermintHeader(cliCtx context.CLIContext) (ibctmtypes.Header, int64,
return ibctmtypes.Header{}, 0, err
}

tmValset := tmtypes.NewValidatorSet(validators.Validators)
tmValset.TotalVotingPower() // update voting power

// migrate to protobuf
protoSignedHeader := commit.SignedHeader.ToProto()
protoValSet, err := tmValset.ToProto()
if err != nil {
return ibctmtypes.Header{}, 0, err
}

header := ibctmtypes.Header{
SignedHeader: commit.SignedHeader,
ValidatorSet: tmtypes.NewValidatorSet(validators.Validators),
SignedHeader: protoSignedHeader,
ValidatorSet: protoValSet,
}

return header, height, nil
Expand Down Expand Up @@ -147,10 +157,19 @@ func QueryNodeConsensusState(cliCtx context.CLIContext) (ibctmtypes.ConsensusSta
return ibctmtypes.ConsensusState{}, 0, err
}

tmValset := tmtypes.NewValidatorSet(validators.Validators)
tmValset.TotalVotingPower() // update voting power

protoValSet, err := tmValset.ToProto()
if err != nil {
return ibctmtypes.ConsensusState{}, 0, err
}

state := ibctmtypes.ConsensusState{
Timestamp: commit.Time,
Root: commitmenttypes.NewMerkleRoot(commit.AppHash),
ValidatorSet: tmtypes.NewValidatorSet(validators.Validators),
Height: uint64(height),
ValidatorSet: protoValSet,
}

return state, height, nil
Expand Down
Loading