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

Refactor store keys for variable-length addresses #8363

Merged
merged 54 commits into from
Feb 1, 2021
Merged

Conversation

amaury1093
Copy link
Contributor

@amaury1093 amaury1093 commented Jan 18, 2021

Description

ref: #8345


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

@amaury1093 amaury1093 added the T: State Machine Breaking State machine breaking changes (impacts consensus). label Jan 18, 2021
x/staking/types/keys.go Outdated Show resolved Hide resolved
type validatorsByAddr map[[sdk.AddrLen]byte][]byte
// map of operator bech32-addresses to serialized power
// We use bech32 strings here, because we can't have slices as keys: map[[]byte][]byte
type validatorsByAddr map[string][]byte
Copy link
Contributor Author

Choose a reason for hiding this comment

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

most changes in this file are related to this change: since we use variable-length addresses, we cannot have map[[]byte][]byte. I'm using the bech32-string as map key here.

x/bank/types/key.go Show resolved Hide resolved
types/address.go Outdated Show resolved Hide resolved
types/address.go Outdated Show resolved Hide resolved
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 generally looks good to me. It would be great if we had someone else who's worked with staking take a look as it's a pretty significant change... If not, I can approve

@amaury1093 amaury1093 added the A:automerge Automatically merge PR once all prerequisites pass. label Feb 1, 2021
@amaury1093
Copy link
Contributor Author

Putting automerge on as to unblock other pieces depending on this PR

@mergify mergify bot merged commit c1b567f into master Feb 1, 2021
@mergify mergify bot deleted the am-8345-store-keys branch February 1, 2021 13:17
This was referenced Feb 4, 2021
tony-iqlusion pushed a commit to cosmos/cosmos-rust that referenced this pull request Apr 19, 2022
This Cosmos SDK change allows variable-sized addresses:

cosmos/cosmos-sdk#8363

This commit changes the validation logic to support addresses
whose lengths are `1..=255`.
tony-iqlusion added a commit to cosmos/cosmos-rust that referenced this pull request Apr 20, 2022
This commit changes the constructor and `to_bytes` methods to fully
support variable-width account IDs, as added in cosmos/cosmos-sdk#8363.

This is a breaking change.
tony-iqlusion added a commit to cosmos/cosmos-rust that referenced this pull request Apr 21, 2022
This commit changes the constructor and `to_bytes` methods to fully
support variable-width account IDs, as added in cosmos/cosmos-sdk#8363.

This is a breaking change.
larry0x pushed a commit to larry0x/cosmos-sdk that referenced this pull request May 22, 2023
* Change account store key in x/bank

* Fix pagination test

* Fix merge master

* Fix staking keys.go

* Use bech32 in val state change map

* Fix sortNoLongerBonded

* Use length-prefix function

* Use length prefix function

* Fix test accountStore

* Fix ExamplePaginate

* Fix staking keys

* Use shorter balances prefix

* Do slashing keys

* Fix gov keys

* Fix x/gov tests

* Fix x/distrib

* Address reviews

* add change log entry

* Add changelog

* Fix failing tests

* Fix sim tests

* fix after-export sim

* Fix lint

* Address review

* Fix x/authz

* Fix global config in test

* Update x/staking/keeper/val_state_change.go

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* Address comments

* Fix comments

* Address review

* Fix authz test

* Update comment

* Rename to LengthPrefixedAddressStoreKey

* Use variable

* Rename function

* Fix test build

* chore: update rosetta CI (cosmos#8453)

* Rename again

* Rename yet again

* Update feegrant keys

* Add function to create prefix

Co-authored-by: Robert Zaremba <robert@zaremba.ch>
Co-authored-by: Frojdi Dymylja <33157909+fdymylja@users.noreply.github.com>
Co-authored-by: Aaron Craelius <aaron@regen.network>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
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:Store C:x/authz C:x/bank C:x/distribution distribution module related C:x/gov C:x/slashing C:x/staking T: State Machine Breaking State machine breaking changes (impacts consensus).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants