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

feat!: Add start time for continuous vesting accounts #342

Merged
merged 8 commits into from
Aug 31, 2023

Conversation

liamsi
Copy link
Member

@liamsi liamsi commented Aug 31, 2023

Minimal changes required for: #341

Note:

  • I had to regenerate proto files and was surprised that this changed a bunch generated code where the proto source wasn't modified 🤔 fixed
  • only modified the existing tests slightly with a start-date in the "future"
  • I would also submit this as a PR to upstream 0.46, 0.47, and main
  • It would be ideal to have this tested in e2e tests as well
  • Ideally, the added command-line flag would also be tested in some fashion (see: 3176583 thanks @evan-forbes )

Description

Closes: #341


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@codecov-commenter
Copy link

codecov-commenter commented Aug 31, 2023

Codecov Report

Merging #342 (1fb01d7) into release/v0.46.x-celestia (c09602f) will increase coverage by 0.00%.
The diff coverage is 88.23%.

❗ Current head 1fb01d7 differs from pull request most recent head d33df0b. Consider uploading reports for the commit d33df0b to get more accurate results

Impacted file tree graph

@@                    Coverage Diff                    @@
##           release/v0.46.x-celestia     #342   +/-   ##
=========================================================
  Coverage                     65.54%   65.55%           
=========================================================
  Files                           666      666           
  Lines                         71161    71177   +16     
=========================================================
+ Hits                          46644    46659   +15     
- Misses                        21934    21935    +1     
  Partials                       2583     2583           
Files Changed Coverage Δ
x/auth/vesting/types/msgs.go 0.00% <0.00%> (ø)
x/auth/vesting/client/testutil/suite.go 97.02% <100.00%> (+0.23%) ⬆️

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

cmd.Flags().Bool(FlagDelayed, false, "Create a delayed vesting account if true")
cmd.Flags().Int64(FlagStartTime, 0, "Optional start time (as a UNIX epoch timestamp) for continuous vesting accounts. If 0 (default), the block's time of the block this tx is committed to will be used.")
Copy link
Member Author

Choose a reason for hiding this comment

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

Comment for reviewer:

It's a bit odd that end_time is passed as a mandatory arg but start-time as an optional flag:
create-vesting-account [to_address] [amount] [end_time] --start-time ...

@liamsi liamsi marked this pull request as ready for review August 31, 2023 10:40
@liamsi liamsi changed the title add start date for vesting accounts Add start date for continuous vesting accounts Aug 31, 2023
@evan-forbes evan-forbes changed the title Add start date for continuous vesting accounts feat!: Add start date for continuous vesting accounts Aug 31, 2023
@evan-forbes evan-forbes added this to the Mainnet milestone Aug 31, 2023
Copy link
Member

@evan-forbes evan-forbes left a comment

Choose a reason for hiding this comment

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

LGTM

x/auth/vesting/msg_server.go Show resolved Hide resolved
Comment on lines +66 to +80
"create a continuous vesting account with start time": {
args: []string{
sdk.AccAddress("addr2_______________").String(),
sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String(),
"4070908800",
fmt.Sprintf("--%s=%d", cli.FlagStartTime, 4070808800),
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
},
expectErr: false,
expectedCode: 0,
respType: &sdk.TxResponse{},
},
Copy link
Member

Choose a reason for hiding this comment

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

added a quick test here, but we're not checking that the state really functioned as intented

@liamsi
Copy link
Member Author

liamsi commented Aug 31, 2023

looking into this now: #342 (comment)

Copy link
Collaborator

@rootulp rootulp left a comment

Choose a reason for hiding this comment

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

[nit] the PR title could use "start time" instead of "start date".

I think this line needs to be updated in the specs:

All vesting accouts created will have their start time set by the committed block's time.

Comment on lines 55 to 59
ctx = sdk.UnwrapSDKContext(goCtx)
if err := s.BankKeeper.IsSendEnabledCoins(ctx, msg.Amount...); err != nil {
return nil, err
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

[question] why is this check needed? It appears unrelated.

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably a rebase/merge glitch. This check is done much earlier in this function already!
d33df0b

x/auth/vesting/types/vesting_account_test.go Outdated Show resolved Hide resolved
@liamsi liamsi changed the title feat!: Add start date for continuous vesting accounts feat!: Add start time for continuous vesting accounts Aug 31, 2023
Copy link
Collaborator

@rootulp rootulp left a comment

Choose a reason for hiding this comment

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

LGTM!

@liamsi liamsi merged commit 7babe18 into release/v0.46.x-celestia Aug 31, 2023
41 of 43 checks passed
@liamsi liamsi deleted the ismail-draft-vesting-start-time-2 branch August 31, 2023 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add the ability to creating a vesting account that begins vesting in the future
5 participants