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

fix!: remove time.now check from authz #10447

Merged
merged 27 commits into from
Feb 2, 2022
Merged

Conversation

robert-zaremba
Copy link
Collaborator

Description

Backport v0.44.2 fix


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)

@@ -7,7 +7,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/authz/client/cli"
)

func ExecGrant(val *network.Validator, args []string) (testutil.BufferWriter, error) {
func CreateGrant(val *network.Validator, args []string) (testutil.BufferWriter, error) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this function name (in tests) was misleading. It essentially creates a new grant and executes that message (grant creation). It doesn't execute on existing grant.

Copy link
Member

@aaronc aaronc left a comment

Choose a reason for hiding this comment

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

A constructor seems like the wrong place to do validation, instead let's do it in the SaveGrant method

@@ -10,7 +10,10 @@ import (
)

// NewGrant returns new Grant
func NewGrant(a Authorization, expiration time.Time) (Grant, error) {
func NewGrant(blockTime time.Time, a Authorization, expiration time.Time) (Grant, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Why are we putting this in the constructor? Shouldn't we just do this within the MsgServer when creating a grant?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We are validating the grant, here authorization + expiration relation. The motivation to have it in NewGrant is to do it once and make sure it's always validated.

Moving it outside of the NewGrant would make sense if it would be a private method... but then we will need another function because other packages are using NewGrant.

So. what do you think ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

On the other hand NewGrant is used only in one place (not counting tests)

Copy link
Member

Choose a reason for hiding this comment

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

I would rather just do it the correct way and valid block time when we're actually in a block... but not going to block either

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, I reworked the validation... was thinking about creating Grant.Validate(now) method, but it also wasn't perfect.

x/authz/keeper/keeper.go Outdated Show resolved Hide resolved
@robert-zaremba robert-zaremba requested a review from aaronc November 2, 2021 00:31
@tac0turtle
Copy link
Member

@robert-zaremba can we get this merged?

@tac0turtle
Copy link
Member

ping

@robert-zaremba robert-zaremba removed the A:automerge Automatically merge PR once all prerequisites pass. label Jan 27, 2022
suite.Require().Equal(expected[i].opMsgName, operationMsg.Name, "operation Msg name should be the same")
suite.Require().Equal(expected[i].weight, w.Weight(), "test: %d, weight should be the same", i)
suite.Require().Equal(expected[i].opMsgRoute, operationMsg.Route, "test: %d, route should be the same", i)
suite.Require().Equal(expected[i].opMsgName, operationMsg.Name, "test: %d, operation Msg name should be the same", i)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we were not checking the results, all tests were failing , and wrong route was used.... let's solve it in other issue

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@aaronc aaronc added the A:automerge Automatically merge PR once all prerequisites pass. label Jan 27, 2022
x/authz/msgs.go Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@tac0turtle tac0turtle removed the A:automerge Automatically merge PR once all prerequisites pass. label Feb 1, 2022
@tac0turtle tac0turtle added this to the v0.46 milestone Feb 1, 2022
@tac0turtle tac0turtle force-pushed the robert/backport-0.44.2-master branch from f65bd0b to 940e165 Compare February 1, 2022 13:20
@tac0turtle tac0turtle added the A:automerge Automatically merge PR once all prerequisites pass. label Feb 1, 2022
@tac0turtle
Copy link
Member

seems sims are still failing. This is a blocker for 0.46 releases.

@tac0turtle tac0turtle changed the title fix!: backport 0.44.2 fix fix!: remove time.now check from authz Feb 2, 2022
@mergify mergify bot merged commit 077154a into master Feb 2, 2022
@mergify mergify bot deleted the robert/backport-0.44.2-master branch February 2, 2022 11:22
@robert-zaremba robert-zaremba mentioned this pull request Feb 2, 2022
56 tasks
amaury1093 added a commit that referenced this pull request Feb 3, 2022
amaury1093 added a commit that referenced this pull request Feb 3, 2022
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 T:Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants