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

chore(types): add MustAccAddressFromBech32 util func #12201

Merged
merged 3 commits into from
Jun 9, 2022

Conversation

fedekunze
Copy link
Collaborator

Description

Closes: #XXXX


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)

@codecov
Copy link

codecov bot commented Jun 9, 2022

Codecov Report

Merging #12201 (2f1512c) into main (4e6545b) will increase coverage by 0.08%.
The diff coverage is 46.15%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #12201      +/-   ##
==========================================
+ Coverage   66.07%   66.16%   +0.08%     
==========================================
  Files         672      672              
  Lines       71046    70990      -56     
==========================================
+ Hits        46946    46971      +25     
+ Misses      21435    21382      -53     
+ Partials     2665     2637      -28     
Impacted Files Coverage Δ
simapp/export.go 11.94% <0.00%> (+0.17%) ⬆️
types/address.go 65.76% <0.00%> (-1.01%) ⬇️
types/tx/types.go 0.00% <0.00%> (ø)
x/bank/keeper/msg_server.go 3.03% <0.00%> (+0.04%) ⬆️
x/distribution/keeper/genesis.go 13.04% <0.00%> (+0.36%) ⬆️
x/group/msgs.go 53.67% <0.00%> (+1.46%) ⬆️
x/group/types.go 48.79% <0.00%> (+0.35%) ⬆️
x/staking/keeper/val_state_change.go 64.77% <0.00%> (+0.48%) ⬆️
server/rosetta/converter.go 56.75% <100.00%> (+0.46%) ⬆️
x/auth/tx/builder.go 82.05% <100.00%> (+1.07%) ⬆️
... and 30 more

@alexanderbez alexanderbez added backport/0.45.x backport/0.46.x PR scheduled for inclusion in the v0.46's next stable release labels Jun 9, 2022
@alexanderbez alexanderbez changed the title imp(types): add MustAccAddressFromBech32 util func chore(types): add MustAccAddressFromBech32 util func Jun 9, 2022
@alexanderbez alexanderbez merged commit 82e13b1 into main Jun 9, 2022
@alexanderbez alexanderbez deleted the fedekunze/types-address branch June 9, 2022 16:26
mergify bot pushed a commit that referenced this pull request Jun 9, 2022
mergify bot pushed a commit that referenced this pull request Jun 9, 2022
(cherry picked from commit 82e13b1)

# Conflicts:
#	CHANGELOG.md
#	server/rosetta/converter.go
#	simapp/export.go
#	x/authz/keeper/genesis.go
#	x/feegrant/simulation/operations.go
#	x/gov/keeper/deposit.go
#	x/gov/keeper/msg_server.go
#	x/gov/keeper/tally.go
#	x/group/msgs.go
#	x/group/types.go
#	x/nft/keeper/genesis.go
#	x/staking/keeper/delegation.go
#	x/staking/keeper/genesis.go
@robert-zaremba
Copy link
Collaborator

In the past we were trying to remove / limit panics. I know it can reduce the code, but it hides the error in panic down stream.
Should we revisit this?
cc: @aaronc , @alexanderbez

@alexanderbez
Copy link
Contributor

Well the code paths that call this new API panic'd anyway and in cases of BeginBlock/EndBlock, they need to panic. So I don't see a need to revert this. Those that want to handle the errors gracefully still can call the original error-returning API.

@robert-zaremba
Copy link
Collaborator

IMO it encourages a wrong style. Panic, if needed, should happen when there is no way to recover.
Moreover testing is harder. Because we can't check an error, instead we need to use recover. If we add more error aggregation primitives, then panics will conflict with that road.
In the PR most of the updates are related to GetSigners.... which are not related to BeginBlock etc...

@alexanderbez
Copy link
Contributor

IMO it encourages a wrong style. Panic, if needed, should happen when there is no way to recover.

That's exactly what's happening here. This API provides a convenience method to avoid if err != nil { panic(...) } boilerplate, i.e. this will be used in code paths that already panic.

@robert-zaremba
Copy link
Collaborator

Probably i didn't express it correctly. I don't think it's good to add that method to a public API. Having it internal is OK. It's already a technical debt that we don't return errors and panic instead.
I'm worried that it will be used in other places instead of returning an error.

@alexanderbez
Copy link
Contributor

It's the developer's responsibility to ensure they handle errors correctly IMO.

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.

None yet

3 participants