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

perf: x/bank create reverse prefix for denom<->address #9611

Merged
merged 32 commits into from Jul 26, 2021

Conversation

alexanderbez
Copy link
Contributor

@alexanderbez alexanderbez commented Jun 29, 2021

  • Add a reverse index x03 | <denom> | <address> -> 0
  • Update DenomOwners to use the new index + an additional query for the balance

closes: #9590


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)

@alexanderbez
Copy link
Contributor Author

@aaronc @AmauryM is this what you had in mind?

@alexanderbez alexanderbez changed the title x/bank: create reverse prefix for denom<->address perf: x/bank create reverse prefix for denom<->address Jun 29, 2021
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.

This looks like the right direction. Thanks @alexanderbez ! We would just need to add a migration (cc @AmauryM)

x/bank/keeper/send.go Outdated Show resolved Hide resolved
@alexanderbez alexanderbez marked this pull request as ready for review June 30, 2021 00:48
@alexanderbez
Copy link
Contributor Author

Since this is going into master, does this need a migration? (apologies if I should already know this)

@aaronc
Copy link
Member

aaronc commented Jun 30, 2021

Yes it does

x/bank/types/key.go Outdated Show resolved Hide resolved
x/bank/types/key.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.

imo there are 3 things missing, which ideally should go in this PR too:

  • migrations as you mentioned. Basically it'll be a x/bank/legacy/v044 new package with a MigrateStore function (see 043 for example). And also bumping the module's ConsensusVersion to 3.
  • I believe InitGenesis doesn't call setBalance anymore, so we need to set this index in InitGenesis too
  • updating the SPEC

x/bank/types/key.go Outdated Show resolved Hide resolved
@amaury1093
Copy link
Contributor

I just had a look at TestSignWithMultiSignersAminoJSON, it's a out of gas error, i solved it by changing the gas limit to 200000

func NewTestGasLimit() uint64 {
return 100000

maybe the staking ones are related?

@alexanderbez
Copy link
Contributor Author

Good catch @AmauryM. I've fixed the gas related tests. However, the only tests failing now are are certain x/staking query related ones.

@cyberbono3 cyberbono3 self-requested a review July 14, 2021 09:42
Copy link
Contributor

@cyberbono3 cyberbono3 left a comment

Choose a reason for hiding this comment

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

lgtm. Please fix the tests.

@alexanderbez
Copy link
Contributor Author

alexanderbez commented Jul 18, 2021

Did some more debugging to no avail. Somehow using the denom prefix store is causing some of these x/staking query tests to fail. My initial guess is that the keyspace was getting collisions, but I don't see how that's possible.

@aaronc
Copy link
Member

aaronc commented Jul 23, 2021

@AmauryM any idea on what's causing the tests to fail here?

@amaury1093
Copy link
Contributor

@AmauryM any idea on what's causing the tests to fail here?

I'm having a look at this

@amaury1093
Copy link
Contributor

@alexanderbez I fixed the test, it was again due to insufficient gas, take a look at 9a851f9.

Before putting automerge on, could you add a state-breaking changelog entry?

@alexanderbez alexanderbez removed the A:automerge Automatically merge PR once all prerequisites pass. label Jul 26, 2021
@alexanderbez
Copy link
Contributor Author

Ohh goodness, how did I not catch this? Curious why this wasn't more obvious. In any case, yes, I'll add a changelog entry.

@alexanderbez alexanderbez merged commit 9ea1fee into master Jul 26, 2021
@alexanderbez alexanderbez deleted the bez/9590-x-bank-denom-reverse-idx branch July 26, 2021 17:51
@ValarDragon ValarDragon mentioned this pull request Dec 21, 2021
4 tasks
larry0x pushed a commit to larry0x/cosmos-sdk that referenced this pull request May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a denom ++ address index in x/bank
4 participants