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!: make grant expiration optional #11060

Merged
merged 32 commits into from
Mar 24, 2022
Merged

feat!: make grant expiration optional #11060

merged 32 commits into from
Mar 24, 2022

Conversation

robert-zaremba
Copy link
Collaborator

@robert-zaremba robert-zaremba commented Jan 28, 2022

Description

Closes: #11095


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)

@robert-zaremba robert-zaremba added this to the v0.46 milestone Jan 28, 2022
@robert-zaremba robert-zaremba force-pushed the robert/authz-expiration branch from 932bb6d to ecc83c1 Compare February 24, 2022 11:34
@codecov
Copy link

codecov bot commented Mar 17, 2022

Codecov Report

Merging #11060 (0bce508) into master (20735e7) will increase coverage by 0.03%.
The diff coverage is 75.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #11060      +/-   ##
==========================================
+ Coverage   65.86%   65.89%   +0.03%     
==========================================
  Files         675      675              
  Lines       69773    69789      +16     
==========================================
+ Hits        45955    45988      +33     
+ Misses      21118    21100      -18     
- Partials     2700     2701       +1     
Impacted Files Coverage Δ
x/authz/keeper/keys.go 95.08% <ø> (ø)
x/authz/simulation/operations.go 66.97% <57.89%> (+1.53%) ⬆️
x/authz/keeper/keeper.go 69.75% <65.51%> (-0.44%) ⬇️
types/coin.go 93.47% <100.00%> (+0.06%) ⬆️
types/query/filtered_pagination.go 81.57% <100.00%> (+0.24%) ⬆️
x/authz/authorization_grant.go 65.71% <100.00%> (-1.86%) ⬇️
x/authz/migrations/v046/store.go 70.45% <100.00%> (+1.40%) ⬆️
x/authz/msgs.go 62.09% <100.00%> (ø)
x/authz/simulation/genesis.go 94.44% <100.00%> (+0.69%) ⬆️
crypto/keys/internal/ecdsa/privkey.go 82.45% <0.00%> (-1.76%) ⬇️
... and 5 more

@@ -173,10 +173,22 @@ Examples:
cmd.Flags().String(FlagSpendLimit, "", "SpendLimit for Send Authorization, an array of Coins allowed spend")
cmd.Flags().StringSlice(FlagAllowedValidators, []string{}, "Allowed validators addresses separated by ,")
cmd.Flags().StringSlice(FlagDenyValidators, []string{}, "Deny validators addresses separated by ,")
cmd.Flags().Int64(FlagExpiration, time.Now().AddDate(1, 0, 0).Unix(), "The Unix timestamp. Default is one year.")
cmd.Flags().Int64(FlagExpiration, 0, "Expire time as Unix timestamp. Set zero (0) for no expiry. Default is 0.")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've changed the default here to zero = no expiration time.
Maybe we would like to explicitly require the value? In that case:

  • 0 would be not allowed
  • -1 = no expire date

Copy link
Contributor

Choose a reason for hiding this comment

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

I think 0 == no expiration time makes the most sense.

Alternatively we can do:

  • 0 == no expiry
  • default is -1
  • all negative values are not allowed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Alternatively we can do: 0 == no expiry; default is -1

If we want to make the CLI param required, the I prefer -1 as no expire, this is because 0 would mean "default", and we don't want default (from the user perspective).

all negative values are not allowed

Now, all values < blocktime().unix() are not allowed , except zero.

Copy link
Contributor

Choose a reason for hiding this comment

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

i was thinking:

Suggested change
cmd.Flags().Int64(FlagExpiration, 0, "Expire time as Unix timestamp. Set zero (0) for no expiry. Default is 0.")
cmd.Flags().Int64(FlagExpiration, -1, "Expire time as Unix timestamp. Set zero (0) for no expiry.")

But tbh -1 = no expire date sounds good to me too, if there's a help message.

@robert-zaremba robert-zaremba marked this pull request as ready for review March 18, 2022 01:08
@robert-zaremba robert-zaremba force-pushed the robert/authz-expiration branch from 79649a3 to 2c4025b Compare March 18, 2022 11:23
return simtypes.NoOpMsg(authz.ModuleName, TypeMsgGrant, "past time"), nil, nil
var expiration *time.Time
t1 := simtypes.RandTimestamp(r)
if !t1.Before(ctx.BlockTime()) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

bummer! calling a rand here will cause sim tests to fail :( This is because our simulation tests don't simulate much - they are almost 'pre defined': we have one grant message, one exec and one revoke. it's basically one premade scenario with lot of boilerplate.

@robert-zaremba robert-zaremba force-pushed the robert/authz-expiration branch from f8284d0 to cf7ab0d Compare March 18, 2022 12:43
Copy link
Contributor

@blushi blushi left a comment

Choose a reason for hiding this comment

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

Implementation looks good to me, pending simulations

x/authz/keeper/genesis_test.go Show resolved Hide resolved
x/authz/simulation/operations.go Outdated Show resolved Hide resolved
Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

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

Approving pending sims test fix, I suppose related to #11060 (comment)

Copy link
Contributor

@atheeshp atheeshp left a comment

Choose a reason for hiding this comment

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

lgtm, except sims & few nits.

proto/cosmos/authz/v1beta1/authz.proto Show resolved Hide resolved
x/authz/keeper/grpc_query_test.go Outdated Show resolved Hide resolved
@robert-zaremba
Copy link
Collaborator Author

Wow, there is a weird convolution, no idea why this test is failing:

    validator_test.go:476: 
                Error Trace:    validator_test.go:476
                Error:          Not equal: 
                                expected: 2
                                actual  : 3
                Test:           TestGetValidatorSortingMixed

@robert-zaremba
Copy link
Collaborator Author

It is also failing in master

@amaury1093
Copy link
Contributor

@robert-zaremba It's fixed on master now

@robert-zaremba robert-zaremba added the A:automerge Automatically merge PR once all prerequisites pass. label Mar 24, 2022
@mergify mergify bot merged commit c1b6ace into master Mar 24, 2022
@mergify mergify bot deleted the robert/authz-expiration branch March 24, 2022 18:27
@amaury1093 amaury1093 mentioned this pull request May 20, 2022
72 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass. C:CLI C:Simulations C:x/authz
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update authz expire to make it optional
5 participants