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: .String() panics when pubkey is set on a BaseAccount #13838

Merged
merged 8 commits into from
Nov 14, 2022

Conversation

julienrbrt
Copy link
Member

Description

Discovered in #13742.
.String() panics when pubkey is set on a BaseAccount,


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)

@julienrbrt julienrbrt requested a review from a team as a code owner November 11, 2022 11:42
@codecov
Copy link

codecov bot commented Nov 11, 2022

Codecov Report

Merging #13838 (db46b2d) into main (78886bc) will increase coverage by 0.00%.
The diff coverage is 71.42%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #13838   +/-   ##
=======================================
  Coverage   56.74%   56.75%           
=======================================
  Files         637      637           
  Lines       54738    54740    +2     
=======================================
+ Hits        31063    31069    +6     
+ Misses      21154    21148    -6     
- Partials     2521     2523    +2     
Impacted Files Coverage Δ
x/auth/types/account.go 79.32% <71.42%> (+2.49%) ⬆️

@aaronc
Copy link
Member

aaronc commented Nov 11, 2022

I don't think String should be marshaling YAML at all. We should just let codegen generate String and get rid of these custom gogo overrides

@julienrbrt
Copy link
Member Author

I don't think String should be marshaling YAML at all. We should just let codegen generate String and get rid of these custom gogo overrides

I think we cannot do this because of #10965.

@amaury1093
Copy link
Contributor

I think we cannot do this because of #10965.

I propose for this PR to let codegen generate String (i.e. remove MarshalYAML), and solve #10965 separately.

@julienrbrt
Copy link
Member Author

I think we cannot do this because of #10965.

I propose for this PR to let codegen generate String (i.e. remove MarshalYAML), and solve #10965 separately.

I am not sure I understand. We cannot use codegen String() here before #10965.

@julienrbrt julienrbrt added the backport/v0.47.x PR scheduled for inclusion in the v0.47's next stable release label Nov 11, 2022
go.mod Outdated Show resolved Hide resolved
@github-actions github-actions bot added C:CLI C:Cosmovisor Issues and PR related to Cosmovisor C:orm C:Rosetta Issues and PR related to Rosetta labels Nov 14, 2022
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.

LGTM, though i would completely clean up all YAML stuff on all accounts (base, module, vesting...). Maybe in a separate PR.

out, _ := acc.MarshalYAML()
return out.(string)
}

// MarshalYAML returns the YAML representation of an account.
func (acc BaseAccount) MarshalYAML() (interface{}, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also remove this method?

Copy link
Member Author

@julienrbrt julienrbrt Nov 14, 2022

Choose a reason for hiding this comment

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

Yes, this is sort of what #13850 is aimed to do.

@julienrbrt julienrbrt enabled auto-merge (squash) November 14, 2022 14:30
@julienrbrt julienrbrt enabled auto-merge (squash) November 14, 2022 14:37
@julienrbrt julienrbrt merged commit d9bc5ac into main Nov 14, 2022
@julienrbrt julienrbrt deleted the julien/ba-pubkey-string branch November 14, 2022 14:56
mergify bot pushed a commit that referenced this pull request Nov 14, 2022
tac0turtle pushed a commit that referenced this pull request Nov 14, 2022
#13855)

(cherry picked from commit d9bc5ac)

Co-authored-by: Julien Robert <julien@rbrt.fr>
dawid-kruk added a commit to chain4energy/c4e-chain that referenced this pull request Mar 17, 2023
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
Labels
backport/v0.47.x PR scheduled for inclusion in the v0.47's next stable release C:CLI C:Cosmovisor Issues and PR related to Cosmovisor C:orm C:Rosetta Issues and PR related to Rosetta C:x/auth
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants