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: ValidatorStore interface doesn't match StakingKeeper #17164

Merged
merged 10 commits into from
Aug 3, 2023

Conversation

facundomedica
Copy link
Member

@facundomedica facundomedica commented Jul 27, 2023

Description

Closes: #17163

We had to add the necessary functions directly to the Staking Keeper given that when you have an interface with a function that returns another interface, you can't make another interface comply because the returning interface won't be accepted (example: https://go.dev/play/p/tz50jVl0NBw).


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
  • run make lint and make test
  • 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)

@facundomedica facundomedica requested a review from a team as a code owner July 27, 2023 14:34
@github-actions

This comment has been minimized.

@julienrbrt julienrbrt added the backport/v0.50.x PR scheduled for inclusion in the v0.50's next stable release label Jul 27, 2023
@julienrbrt
Copy link
Member

I don't know how we can make sure these interfaces match without creating new dependency, but it would be good to do it somehow (maybe implementing it on Simapp).

We could just have a function call in /integration/ to, it does not pollute simapp.

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

We should update the ADR as well

GetValidatorByConsAddr(sdk.Context, cryptotypes.Address) (cryptotypes.PubKey, error)

baseapp/abci_utils.go Outdated Show resolved Hide resolved
@facundomedica facundomedica marked this pull request as draft July 27, 2023 15:28
@facundomedica
Copy link
Member Author

Moving this to draft as I'm writing an integration test

@tac0turtle
Copy link
Member

I don't know how we can make sure these interfaces match without creating new dependency, but it would be good to do it somehow (maybe implementing it on Simapp).

can we import baseapp for now into staking to make sure it matches, later on we can fix the dependency but for now i think its fine

@alexanderbez
Copy link
Contributor

I don't know how we can make sure these interfaces match without creating new dependency, but it would be good to do it somehow (maybe implementing it on Simapp).

can we import baseapp for now into staking to make sure it matches, later on we can fix the dependency but for now i think its fine

I wanted to avoid this if possible honestly. I think we tweak the API(s) to avoid this but if we cannot, then yes, this is a fallback

@facundomedica
Copy link
Member Author

@tac0turtle @alexanderbez I just saw your comments, in my last commit I've added the necessary APIs to the staking keeper + an integration test. lmk what you think

@facundomedica facundomedica marked this pull request as ready for review July 28, 2023 12:04
Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

lgtm!

@@ -125,12 +107,20 @@ func ValidateVoteExtensions(
return fmt.Errorf("failed to verify validator %X vote extension signature", valConsAddr)
}

sumVP = sumVP.Add(validator.BondedTokens())
bondedTokens, err := valStore.BondedTokensByConsAddr(ctx, valConsAddr)
Copy link
Member

Choose a reason for hiding this comment

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

Curious, isn't it slower now because we get the validator twice? While before only once.
It is probably negligible but just curious. :D

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it will be slower sadly. We could have a specific API that returns both bonded tokens and public key, wdyt?

Copy link
Member

Choose a reason for hiding this comment

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

No objection to that personally.

Copy link
Contributor

Choose a reason for hiding this comment

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

@facundomedica yes let's do that. This will be used in the VE hotpath so we don't want obvious performance slowdowns

Copy link
Member Author

Choose a reason for hiding this comment

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

Added BondedTokensAndPubKeyByConsAddr

x/staking/keeper/validator.go Outdated Show resolved Hide resolved
docs/architecture/adr-064-abci-2.0.md Show resolved Hide resolved
@julienrbrt julienrbrt mentioned this pull request Aug 3, 2023
3 tasks
@alexanderbez alexanderbez added this pull request to the merge queue Aug 3, 2023
Merged via the queue into main with commit c3ae0b0 Aug 3, 2023
48 checks passed
@alexanderbez alexanderbez deleted the facu/fix-valvoteext branch August 3, 2023 22:55
mergify bot pushed a commit that referenced this pull request Aug 3, 2023
Co-authored-by: Aleksandr Bezobchuk <[email protected]>
(cherry picked from commit c3ae0b0)

# Conflicts:
#	CHANGELOG.md
alexanderbez pushed a commit that referenced this pull request Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.50.x PR scheduled for inclusion in the v0.50's next stable release C:x/staking Type: ADR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: ValidateVoteExtensions Expected Interface
4 participants