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: migrate away from using valBech32 globals (2/2) #17157

Merged
merged 22 commits into from
Aug 14, 2023

Conversation

tac0turtle
Copy link
Member

Description

this pr aims ot migrate away from using valaddress bech32 globals


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)

@julienrbrt julienrbrt added the backport/v0.50.x PR scheduled for inclusion in the v0.50's next stable release label Aug 3, 2023
@julienrbrt julienrbrt mentioned this pull request Aug 3, 2023
3 tasks
@@ -60,13 +60,18 @@
panic("stake should not be negative")
}

valBz, err := k.stakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator())
if err != nil {
panic(err)

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods Warning

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
@tac0turtle
Copy link
Member Author

tac0turtle commented Aug 8, 2023

this commit makes things pretty ugly, 1a9f45f. Not sure any other way around this, but we should def break this api in the near future and clean all this up

still need to add changelogs for all the breaks, but i will mark it as r4r for reviews now

@tac0turtle tac0turtle marked this pull request as ready for review August 8, 2023 09:58
@tac0turtle tac0turtle requested a review from a team as a code owner August 8, 2023 09:58
@github-prbot github-prbot requested review from a team, kocubinski and julienrbrt and removed request for a team August 8, 2023 09:59
@tac0turtle
Copy link
Member Author

tac0turtle commented Aug 8, 2023

im going to try the altvalue codec for this type to see what the difference is, this pr isn't the best

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.

That's ... verbose 😅 but it is not that ugly, only tests are.

x/staking/types/exported.go Outdated Show resolved Hide resolved
x/distribution/testutil/staking_helper.go Show resolved Hide resolved
x/distribution/testutil/staking_helper.go Show resolved Hide resolved
x/evidence/types/evidence.go Outdated Show resolved Hide resolved
x/staking/types/historical_info.go Show resolved Hide resolved
x/staking/types/keys.go Show resolved Hide resolved
x/staking/types/validator.go Show resolved Hide resolved
func FromABCIEvidence(e comet.Evidence) *Equivocation {
bech32PrefixConsAddr := sdk.GetConfig().GetBech32ConsensusAddrPrefix()
consAddr, err := sdk.Bech32ifyAddressBytes(bech32PrefixConsAddr, e.Validator().Address())
func FromABCIEvidence(e comet.Evidence, conAc address.Codec) *Equivocation {
Copy link
Member

Choose a reason for hiding this comment

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

Changelog needed.

@@ -49,8 +50,8 @@ func (e *Equivocation) ValidateBasic() error {

// GetConsensusAddress returns the validator's consensus address at time of the
// Equivocation infraction.
func (e Equivocation) GetConsensusAddress() sdk.ConsAddress {
addr, _ := sdk.ConsAddressFromBech32(e.ConsensusAddress)
func (e Equivocation) GetConsensusAddress(consAc address.Codec) sdk.ConsAddress {
Copy link
Member

Choose a reason for hiding this comment

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

ditto

x/staking/types/exported.go Show resolved Hide resolved
Copy link
Member

@facundomedica facundomedica left a comment

Choose a reason for hiding this comment

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

utACK

x/staking/types/exported.go Show resolved Hide resolved
@tac0turtle tac0turtle added this pull request to the merge queue Aug 14, 2023
Merged via the queue into main with commit e60c583 Aug 14, 2023
48 checks passed
@tac0turtle tac0turtle deleted the marko/valAddress2 branch August 14, 2023 08:07
mergify bot pushed a commit that referenced this pull request Aug 14, 2023
Co-authored-by: marbar3778 <marbar3778@yahoo.com>
(cherry picked from commit e60c583)

# Conflicts:
#	CHANGELOG.md
#	simapp/export.go
#	tests/integration/distribution/keeper/grpc_query_test.go
#	tests/integration/distribution/keeper/msg_server_test.go
#	tests/integration/gov/keeper/tally_test.go
#	tests/integration/staking/keeper/determinstic_test.go
#	tests/integration/staking/keeper/grpc_query_test.go
#	x/distribution/keeper/allocation.go
#	x/distribution/keeper/allocation_test.go
#	x/distribution/keeper/delegation.go
#	x/distribution/keeper/validator.go
#	x/distribution/simulation/operations.go
#	x/distribution/simulation/operations_test.go
#	x/distribution/testutil/staking_helper.go
#	x/evidence/testutil/expected_keepers_mocks.go
#	x/evidence/types/expected_keepers.go
#	x/slashing/simulation/operations_test.go
#	x/staking/keeper/delegation.go
#	x/staking/keeper/grpc_query.go
#	x/staking/keeper/historical_info_test.go
#	x/staking/keeper/query_utils.go
#	x/staking/keeper/validator.go
#	x/staking/simulation/operations_test.go
#	x/staking/types/historical_info_test.go
#	x/staking/types/keys.go
julienrbrt added a commit that referenced this pull request Aug 14, 2023
…17157) (#17379)

Co-authored-by: Marko <marko@baricevic.me>
Co-authored-by: marbar3778 <marbar3778@yahoo.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
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:Simulations C:x/distribution distribution module related C:x/evidence C:x/gov C:x/slashing C:x/staking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants