From 95b4f128390b19f8cff1854e07242b6ed4e3a885 Mon Sep 17 00:00:00 2001 From: Zaki Manian Date: Sat, 26 Jun 2021 22:01:28 -0700 Subject: [PATCH 1/2] Add support start time to periodic vesting account messages --- docs/core/proto-docs.md | 1 + proto/cosmos/vesting/v1beta1/tx.proto | 3 +- x/auth/vesting/client/cli/tx.go | 16 ++-- x/auth/vesting/msg_server.go | 7 +- x/auth/vesting/types/msgs.go | 7 +- x/auth/vesting/types/tx.pb.go | 103 +++++++++++++++++--------- x/slashing/types/slashing.pb.go | 15 ++-- 7 files changed, 105 insertions(+), 47 deletions(-) diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index 626d13bf6f06..fd931fd95ae8 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -8183,6 +8183,7 @@ account. | ----- | ---- | ----- | ----------- | | `from_address` | [string](#string) | | | | `to_address` | [string](#string) | | | +| `start_time` | [int64](#int64) | | | | `vesting_periods` | [Period](#cosmos.vesting.v1beta1.Period) | repeated | | diff --git a/proto/cosmos/vesting/v1beta1/tx.proto b/proto/cosmos/vesting/v1beta1/tx.proto index 63dc50299278..601ccf8788ca 100644 --- a/proto/cosmos/vesting/v1beta1/tx.proto +++ b/proto/cosmos/vesting/v1beta1/tx.proto @@ -40,5 +40,6 @@ message MsgCreatePeriodicVestingAccount { string from_address = 1 [(gogoproto.moretags) = "yaml:\"from_address\""]; string to_address = 2 [(gogoproto.moretags) = "yaml:\"to_address\""]; - repeated Period vesting_periods = 3 [(gogoproto.nullable) = false]; + int64 start_time = 3 [(gogoproto.moretags) = "yaml:\"start_time\""]; + repeated Period vesting_periods = 4 [(gogoproto.nullable) = false]; } diff --git a/x/auth/vesting/client/cli/tx.go b/x/auth/vesting/client/cli/tx.go index ec3bd26a0f4b..70cf55de4122 100644 --- a/x/auth/vesting/client/cli/tx.go +++ b/x/auth/vesting/client/cli/tx.go @@ -100,7 +100,7 @@ type InputPeriod struct { // MsgCreateVestingAccount transaction. func NewMsgCreatePeriodicVestingAccountCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "create-periodic-vesting-account [to_address] [periods_json_file]", + Use: "create-periodic-vesting-account [start_time_unix] [to_address] [periods_json_file]", Short: "Create a new vesting account funded with an allocation of tokens.", Long: `A sequence of coins and period length in seconds. Periods are sequential, in that the duration of of a period only starts at the end of the previous period. The duration of the first period starts upon account creation. For instance, the following periods.json file shows 20 "test" coins vesting 30 days apart from each other. Where periods.json contains: @@ -124,19 +124,25 @@ func NewMsgCreatePeriodicVestingAccountCmd() *cobra.Command { if err != nil { return err } - toAddr, err := sdk.AccAddressFromBech32(args[0]) + + startTime, err := strconv.ParseInt(args[0], 10, 64) + + if err != nil { + return err + } + toAddr, err := sdk.AccAddressFromBech32(args[1]) if err != nil { return err } - contents, err := ioutil.ReadFile(args[1]) + contents, err := ioutil.ReadFile(args[2]) if err != nil { return err } var inputPeriods []InputPeriod - err = json.Unmarshal(contents, inputPeriods) + err = json.Unmarshal(contents, &inputPeriods) if err != nil { return err } @@ -157,7 +163,7 @@ func NewMsgCreatePeriodicVestingAccountCmd() *cobra.Command { periods = append(periods, period) } - msg := types.NewMsgCreatePeriodicVestingAccount(clientCtx.GetFromAddress(), toAddr, periods) + msg := types.NewMsgCreatePeriodicVestingAccount(clientCtx.GetFromAddress(), toAddr, startTime, periods) if err := msg.ValidateBasic(); err != nil { return err } diff --git a/x/auth/vesting/msg_server.go b/x/auth/vesting/msg_server.go index 8b95213f4b48..fabdd3098d16 100644 --- a/x/auth/vesting/msg_server.go +++ b/x/auth/vesting/msg_server.go @@ -121,6 +121,11 @@ func (s msgServer) CreatePeriodicVestingAccount(goCtx context.Context, msg *type if acc := ak.GetAccount(ctx, to); acc != nil { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "account %s already exists", msg.ToAddress) } + + if msg.StartTime < ctx.BlockTime().Unix() { + return nil, sdkerrors.Wrapf(sdkerrors.ErrLogic, "StartTime must be after the current blocktime", msg.ToAddress) + + } var totalCoins sdk.Coins for _, period := range msg.VestingPeriods { @@ -129,7 +134,7 @@ func (s msgServer) CreatePeriodicVestingAccount(goCtx context.Context, msg *type baseAccount := ak.NewAccountWithAddress(ctx, to) - types.NewPeriodicVestingAccount(baseAccount.(*authtypes.BaseAccount), totalCoins.Sort(), ctx.BlockTime().Unix(), msg.VestingPeriods) + types.NewPeriodicVestingAccount(baseAccount.(*authtypes.BaseAccount), totalCoins.Sort(), msg.StartTime, msg.VestingPeriods) err = bk.SendCoins(ctx, from, to, totalCoins) if err != nil { diff --git a/x/auth/vesting/types/msgs.go b/x/auth/vesting/types/msgs.go index a62dee3f62c1..f4461c01420c 100644 --- a/x/auth/vesting/types/msgs.go +++ b/x/auth/vesting/types/msgs.go @@ -85,10 +85,11 @@ func (msg MsgCreateVestingAccount) GetSigners() []sdk.AccAddress { // NewMsgCreateVestingAccount returns a reference to a new MsgCreateVestingAccount. //nolint:interfacer -func NewMsgCreatePeriodicVestingAccount(fromAddr, toAddr sdk.AccAddress, periods []Period) *MsgCreatePeriodicVestingAccount { +func NewMsgCreatePeriodicVestingAccount(fromAddr, toAddr sdk.AccAddress, startTime int64, periods []Period) *MsgCreatePeriodicVestingAccount { return &MsgCreatePeriodicVestingAccount{ FromAddress: fromAddr.String(), ToAddress: toAddr.String(), + StartTime: startTime, VestingPeriods: periods, } } @@ -132,6 +133,10 @@ func (msg MsgCreatePeriodicVestingAccount) ValidateBasic() error { return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid recipient address: %s", err) } + if msg.StartTime < 1 { + return fmt.Errorf("invalid start time of %d, length must be greater than 0", msg.StartTime) + } + for i, period := range msg.VestingPeriods { if period.Length < 1 { return fmt.Errorf("invalid period length of %d in period %d, length must be greater than 0", period.Length, i) diff --git a/x/auth/vesting/types/tx.pb.go b/x/auth/vesting/types/tx.pb.go index 41719ce8e6d3..2690a04686d6 100644 --- a/x/auth/vesting/types/tx.pb.go +++ b/x/auth/vesting/types/tx.pb.go @@ -150,7 +150,8 @@ var xxx_messageInfo_MsgCreateVestingAccountResponse proto.InternalMessageInfo type MsgCreatePeriodicVestingAccount struct { FromAddress string `protobuf:"bytes,1,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty" yaml:"from_address"` ToAddress string `protobuf:"bytes,2,opt,name=to_address,json=toAddress,proto3" json:"to_address,omitempty" yaml:"to_address"` - VestingPeriods []Period `protobuf:"bytes,3,rep,name=vesting_periods,json=vestingPeriods,proto3" json:"vesting_periods"` + StartTime int64 `protobuf:"varint,3,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty" yaml:"start_time"` + VestingPeriods []Period `protobuf:"bytes,4,rep,name=vesting_periods,json=vestingPeriods,proto3" json:"vesting_periods"` } func (m *MsgCreatePeriodicVestingAccount) Reset() { *m = MsgCreatePeriodicVestingAccount{} } @@ -200,6 +201,13 @@ func (m *MsgCreatePeriodicVestingAccount) GetToAddress() string { return "" } +func (m *MsgCreatePeriodicVestingAccount) GetStartTime() int64 { + if m != nil { + return m.StartTime + } + return 0 +} + func (m *MsgCreatePeriodicVestingAccount) GetVestingPeriods() []Period { if m != nil { return m.VestingPeriods @@ -216,37 +224,39 @@ func init() { func init() { proto.RegisterFile("cosmos/vesting/v1beta1/tx.proto", fileDescriptor_5338ca97811f9792) } var fileDescriptor_5338ca97811f9792 = []byte{ - // 479 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x53, 0x3d, 0x6f, 0xd3, 0x40, - 0x18, 0xf6, 0x25, 0xa1, 0x1f, 0x57, 0x44, 0x85, 0x5b, 0xa8, 0x89, 0x90, 0x1d, 0x2c, 0x06, 0x2f, - 0x9c, 0x49, 0x41, 0x42, 0xca, 0x56, 0x77, 0x44, 0x91, 0x90, 0x85, 0x18, 0x58, 0x22, 0xc7, 0xf7, - 0xe2, 0x9e, 0xa8, 0x7d, 0x91, 0xef, 0x52, 0x35, 0x1b, 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c, 0x52, 0xf4, 0xfa, 0x72, 0xe6, 0xa2, 0xab, 0x99, 0x8b, - 0x7e, 0xce, 0x5c, 0x74, 0x31, 0x77, 0xad, 0xab, 0xb9, 0x6b, 0x7d, 0x9f, 0xbb, 0xd6, 0xfb, 0xee, - 0xad, 0x3d, 0x3e, 0x0f, 0x93, 0xb1, 0x3c, 0x59, 0xbe, 0x65, 0x55, 0xeb, 0xe1, 0x86, 0x7a, 0xc2, - 0x2f, 0x7e, 0x05, 0x00, 0x00, 0xff, 0xff, 0xaa, 0x8b, 0x7b, 0x18, 0x59, 0x04, 0x00, 0x00, + // 503 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x54, 0x3f, 0x6f, 0xd3, 0x40, + 0x14, 0xf7, 0xc5, 0xa1, 0x6d, 0xae, 0x88, 0x0a, 0xb7, 0x50, 0x13, 0x21, 0x3b, 0x58, 0x0c, 0x5e, + 0x38, 0x93, 0x52, 0x09, 0x29, 0x5b, 0xdd, 0x11, 0x45, 0x42, 0x16, 0x62, 0x60, 0x89, 0x2e, 0xf6, + 0xe1, 0x9e, 0xa8, 0x7d, 0x91, 0xef, 0x52, 0x35, 0x1b, 0x1f, 0xa1, 0x3b, 0x12, 0x62, 0xe6, 0x53, + 0x30, 0x76, 0xec, 0xc8, 0x14, 0x50, 0xb2, 0x30, 0xe7, 0x13, 0x20, 0xdf, 0x9d, 0xd3, 0x0c, 0x71, + 0x10, 0x2c, 0x4c, 0xc9, 0xcb, 0xef, 0xcf, 0xdd, 0xfb, 0xbd, 0x77, 0x81, 0x6e, 0xcc, 0x78, 0xc6, + 0x78, 0x70, 0x41, 0xb8, 0xa0, 0x79, 0x1a, 0x5c, 0x74, 0x87, 0x44, 0xe0, 0x6e, 0x20, 0x2e, 0xd1, + 0xa8, 0x60, 0x82, 0x59, 0x0f, 0x15, 0x01, 0x69, 0x02, 0xd2, 0x84, 0xf6, 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 0xc3, 0x7f, 0xf1, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x49, + 0xf6, 0x33, 0xbe, 0x8f, 0x04, 0x00, 0x00, } func (this *MsgCreateVestingAccount) Equal(that interface{}) bool { @@ -531,9 +541,14 @@ func (m *MsgCreatePeriodicVestingAccount) MarshalToSizedBuffer(dAtA []byte) (int i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 } } + if m.StartTime != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.StartTime)) + i-- + dAtA[i] = 0x18 + } if len(m.ToAddress) > 0 { i -= len(m.ToAddress) copy(dAtA[i:], m.ToAddress) @@ -614,6 +629,9 @@ func (m *MsgCreatePeriodicVestingAccount) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } + if m.StartTime != 0 { + n += 1 + sovTx(uint64(m.StartTime)) + } if len(m.VestingPeriods) > 0 { for _, e := range m.VestingPeriods { l = e.Size() @@ -960,6 +978,25 @@ func (m *MsgCreatePeriodicVestingAccount) Unmarshal(dAtA []byte) error { m.ToAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType) + } + m.StartTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.StartTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field VestingPeriods", wireType) } diff --git a/x/slashing/types/slashing.pb.go b/x/slashing/types/slashing.pb.go index 1db4757a95a8..633b4c5bb944 100644 --- a/x/slashing/types/slashing.pb.go +++ b/x/slashing/types/slashing.pb.go @@ -33,16 +33,19 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // liveness activity. type ValidatorSigningInfo struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - // height at which validator was first a candidate OR was unjailed + // Height at which validator was first a candidate OR was unjailed StartHeight int64 `protobuf:"varint,2,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty" yaml:"start_height"` - // index offset into signed block bit array + // Index which is incremented each time the validator was a bonded + // in a block and may have signed a precommit or not. This in conjunction with the + // `SignedBlocksWindow` param determines the index in the `MissedBlocksBitArray`. IndexOffset int64 `protobuf:"varint,3,opt,name=index_offset,json=indexOffset,proto3" json:"index_offset,omitempty" yaml:"index_offset"` - // timestamp validator cannot be unjailed until + // Timestamp until which the validator is jailed due to liveness downtime. JailedUntil time.Time `protobuf:"bytes,4,opt,name=jailed_until,json=jailedUntil,proto3,stdtime" json:"jailed_until" yaml:"jailed_until"` - // whether or not a validator has been tombstoned (killed out of validator - // set) + // Whether or not a validator has been tombstoned (killed out of validator set). It is set + // once the validator commits an equivocation or for any other configured misbehiavor. Tombstoned bool `protobuf:"varint,5,opt,name=tombstoned,proto3" json:"tombstoned,omitempty"` - // missed blocks counter (to avoid scanning the array every time) + // A counter kept to avoid unnecessary array reads. + // Note that `Sum(MissedBlocksBitArray)` always equals `MissedBlocksCounter`. MissedBlocksCounter int64 `protobuf:"varint,6,opt,name=missed_blocks_counter,json=missedBlocksCounter,proto3" json:"missed_blocks_counter,omitempty" yaml:"missed_blocks_counter"` } From 8b0a8c22f7b6ef027158d95c2c64522772c18b3e Mon Sep 17 00:00:00 2001 From: Zaki Manian Date: Sun, 27 Jun 2021 11:12:05 -0700 Subject: [PATCH 2/2] Remove supurious checks per review --- x/auth/vesting/msg_server.go | 4 ---- x/auth/vesting/types/msgs.go | 4 ---- 2 files changed, 8 deletions(-) diff --git a/x/auth/vesting/msg_server.go b/x/auth/vesting/msg_server.go index fabdd3098d16..f902ba882f23 100644 --- a/x/auth/vesting/msg_server.go +++ b/x/auth/vesting/msg_server.go @@ -122,10 +122,6 @@ func (s msgServer) CreatePeriodicVestingAccount(goCtx context.Context, msg *type return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "account %s already exists", msg.ToAddress) } - if msg.StartTime < ctx.BlockTime().Unix() { - return nil, sdkerrors.Wrapf(sdkerrors.ErrLogic, "StartTime must be after the current blocktime", msg.ToAddress) - - } var totalCoins sdk.Coins for _, period := range msg.VestingPeriods { diff --git a/x/auth/vesting/types/msgs.go b/x/auth/vesting/types/msgs.go index f4461c01420c..73737d59abb8 100644 --- a/x/auth/vesting/types/msgs.go +++ b/x/auth/vesting/types/msgs.go @@ -133,10 +133,6 @@ func (msg MsgCreatePeriodicVestingAccount) ValidateBasic() error { return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid recipient address: %s", err) } - if msg.StartTime < 1 { - return fmt.Errorf("invalid start time of %d, length must be greater than 0", msg.StartTime) - } - for i, period := range msg.VestingPeriods { if period.Length < 1 { return fmt.Errorf("invalid period length of %d in period %d, length must be greater than 0", period.Length, i)