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: accaddr cachefix #15433

Merged
merged 15 commits into from
Mar 31, 2023
Merged

fix: accaddr cachefix #15433

merged 15 commits into from
Mar 31, 2023

Conversation

KyleMoser
Copy link
Contributor

Description

Closes: #15317

Updates previous PR following advice from @julienrbrt, see #15318 (comment).

Requesting this PR be merged into main, then backported to v0.47 (as this functionality is needed by go relayer).


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)

@KyleMoser KyleMoser self-assigned this Mar 16, 2023
@KyleMoser KyleMoser changed the title fix: accaddr cachefix #15317 fix: accaddr cachefix Mar 16, 2023
@KyleMoser KyleMoser marked this pull request as ready for review March 16, 2023 21:44
@KyleMoser KyleMoser requested a review from a team as a code owner March 16, 2023 21:44
@julienrbrt julienrbrt added the backport/v0.47.x PR scheduled for inclusion in the v0.47's next stable release label Mar 16, 2023
@julienrbrt julienrbrt mentioned this pull request Mar 16, 2023
19 tasks
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a changelog?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, thanks. Missed that in the contributor guide, my bad.

Copy link
Contributor

@likhita-809 likhita-809 left a comment

Choose a reason for hiding this comment

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

lgtm, needs changelog

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!

CHANGELOG.md Outdated
@@ -38,6 +38,8 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

* (types) [#15433](https://github.com/cosmos/cosmos-sdk/pull/15433) Allow disabling of account address caches (for printing bech32 account addresses).
Copy link
Member

Choose a reason for hiding this comment

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

The changelog should be under the bugfix or improvement section (whichever you think fits best).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved it there. Am I finally doing it right? :)

types/address.go Outdated
Comment on lines 114 to 117
// By default, caches are enabled. This enables or disables accAddrCache, consAddrCache, and valAddrCache.
func SetAddrCacheEnabled(enabled bool) {
isCachingEnabled = enabled
}

Choose a reason for hiding this comment

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

It's unsafe to mutate a global variable like this without synchronization (e.g. a mutex).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's only meant to be used once on client startup. If I put a mutex in SetAddrCacheEnabled it should also be locked when checking isCachingEnabled, meaning every time an address bech32 conversion happens.

Choose a reason for hiding this comment

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

You're correct that both reads and writes need to be synchronized. You might consider atomic.Bool as an alternative.

var cachingEnabled atomic.Bool

func SetCachingEnabled(b bool) { cachingEnabled.Store(b) }
func GetCachingEnabled() bool { return cachingEnabled.Load() }

@tac0turtle tac0turtle enabled auto-merge (squash) March 31, 2023 07:46
@tac0turtle tac0turtle added the A:automerge Automatically merge PR once all prerequisites pass. label Mar 31, 2023
types/address.go Outdated Show resolved Hide resolved
types/address.go Outdated Show resolved Hide resolved
types/address.go Outdated Show resolved Hide resolved
types/address.go Outdated Show resolved Hide resolved
types/address.go Outdated Show resolved Hide resolved
types/address.go Outdated Show resolved Hide resolved
types/address.go Outdated Show resolved Hide resolved
@tac0turtle tac0turtle merged commit cdf6471 into cosmos:main Mar 31, 2023
1 check passed
mergify bot pushed a commit that referenced this pull request Mar 31, 2023
Co-authored-by: Julien Robert <julien@rbrt.fr>
Co-authored-by: Marko <marbar3778@yahoo.com>
(cherry picked from commit cdf6471)

# Conflicts:
#	CHANGELOG.md
julienrbrt added a commit that referenced this pull request Mar 31, 2023
Co-authored-by: KyleMoser <KyleMoser@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
@yihuang yihuang added the backport/0.46.x PR scheduled for inclusion in the v0.46's next stable release label Jul 4, 2023
mergify bot pushed a commit that referenced this pull request Jul 4, 2023
Co-authored-by: Julien Robert <julien@rbrt.fr>
Co-authored-by: Marko <marbar3778@yahoo.com>
(cherry picked from commit cdf6471)

# Conflicts:
#	CHANGELOG.md
julienrbrt pushed a commit that referenced this pull request Jul 5, 2023
Co-authored-by: KyleMoser <KyleMoser@users.noreply.github.com>
Co-authored-by: HuangYi <huang@crypto.com>
roy-dydx pushed a commit to dydxprotocol/cosmos-sdk that referenced this pull request Jul 11, 2023
Co-authored-by: KyleMoser <KyleMoser@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
GAtom22 pushed a commit to evmos/cosmos-sdk that referenced this pull request Jul 12, 2023
Co-authored-by: KyleMoser <KyleMoser@users.noreply.github.com>
Co-authored-by: HuangYi <huang@crypto.com>
GAtom22 pushed a commit to evmos/cosmos-sdk that referenced this pull request Jul 12, 2023
Co-authored-by: KyleMoser <KyleMoser@users.noreply.github.com>
Co-authored-by: HuangYi <huang@crypto.com>
cmwaters added a commit to celestiaorg/cosmos-sdk that referenced this pull request Aug 15, 2023
* build(deps): bump cometbft to v0.34.29 (cosmos#16553)

* fix(x/auth): ensure nil .BaseAccounts are reported in ModuleAccount.Validate (backport cosmos#16554) (cosmos#16570)

Co-authored-by: Emmanuel T Odeke <emmanuel@orijtech.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>

* fix: snapshotter's failure is not propogated (backport cosmos#16588) (cosmos#16604)

Co-authored-by: yihuang <huang@crypto.com>

* feat: add custom max gas for block for sim config (backport cosmos#16656) (cosmos#16731)

Co-authored-by: mmsqe <mavis@crypto.com>
Co-authored-by: marbar3778 <marbar3778@yahoo.com>

* fix: accaddr cachefix (backport cosmos#15433) (cosmos#16823)

Co-authored-by: KyleMoser <KyleMoser@users.noreply.github.com>
Co-authored-by: HuangYi <huang@crypto.com>

* fix(cli): improve `prune` command ux (backport cosmos#16856) (cosmos#16876)

Co-authored-by: Julien Robert <julien@rbrt.fr>

* fix: query tx events with `>=` and `<=` operators (cosmos#16994)

* docs: change bank multi-send command description (backport cosmos#16950) (cosmos#17019)

* chore: prepare v0.46.14 (cosmos#16879)

* refactor: add MigrateHandler to allow reuse migrate genesis related function  (backport cosmos#17296) (cosmos#17301)

Co-authored-by: mmsqe <mavis@crypto.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>

* fix: resolve migration map in MigrateHandler (cosmos#17301) (cosmos#17302)

* feat(x/gov): Emit VoterAddr (backport cosmos#17354) (cosmos#17357)

Co-authored-by: Devon Bear <itsdevbear@berachain.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>

* feat(x/gov): add MsgSubmitProposal SetMsgs method (backport cosmos#17387) (cosmos#17388)

Co-authored-by: Julien Robert <julien@rbrt.fr>

---------

Co-authored-by: Julien Robert <julien@rbrt.fr>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Emmanuel T Odeke <emmanuel@orijtech.com>
Co-authored-by: yihuang <huang@crypto.com>
Co-authored-by: mmsqe <mavis@crypto.com>
Co-authored-by: marbar3778 <marbar3778@yahoo.com>
Co-authored-by: KyleMoser <KyleMoser@users.noreply.github.com>
Co-authored-by: Rootul P <rootulp@gmail.com>
Co-authored-by: Devon Bear <itsdevbear@berachain.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. backport/v0.47.x PR scheduled for inclusion in the v0.47's next stable release backport/0.46.x PR scheduled for inclusion in the v0.46's next stable release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AccAddress caching causes incorrect bech32 prefixes
6 participants