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 bech32 prefix in evidence #8461

Merged
merged 4 commits into from
Jan 29, 2021

Conversation

yihuang
Copy link
Collaborator

@yihuang yihuang commented Jan 28, 2021

Description

When decoding the consensus address, it should use the dynamic configured prefix, rather than the constant.

Problem:

  • when cosmos based chain customized prefix, double sign behaviour don't get jailed.

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

@tomtau
Copy link
Contributor

tomtau commented Jan 28, 2021

technically, this may be a consensus-breaking change for non-gaia live networks on 0.41 but probably ok to go with that?

@alessio
Copy link
Contributor

alessio commented Jan 28, 2021

Hi @yihuang, and thanks for taking the time the submit this patch and help make Cosmos SDK better.

If the bug is confirmed and it is reproducible in master, we generally accept PRs in master first. Once a PR is fixed in master, we cherry-pick the respective commit and open PRs against the supported stable branches.

Thus, would you mind re-targeting this PR to master please?

@yihuang yihuang force-pushed the fix_bech32_prefix_in_evidence branch from d99db72 to cecc19e Compare January 28, 2021 07:17
@yihuang yihuang changed the base branch from release/v0.41.x to master January 28, 2021 07:17
@yihuang
Copy link
Collaborator Author

yihuang commented Jan 28, 2021

Hi @yihuang, and thanks for taking the time the submit this patch and help make Cosmos SDK better.

If the bug is confirmed and it is reproducible in master, we generally accept PRs in master first. Once a PR is fixed in master, we cherry-pick the respective commit and open PRs against the supported stable branches.

Thus, would you mind re-targeting this PR to master please?

Done.

I didn't confirmed in master, because master needs some extra changes for our tests to run. But the patch should be good in master too.

@codecov
Copy link

codecov bot commented Jan 28, 2021

Codecov Report

Merging #8461 (4f55c93) into master (784a9a6) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8461      +/-   ##
==========================================
+ Coverage   61.47%   61.49%   +0.01%     
==========================================
  Files         630      630              
  Lines       36398    36399       +1     
==========================================
+ Hits        22377    22384       +7     
+ Misses      11671    11664       -7     
- Partials     2350     2351       +1     
Impacted Files Coverage Δ
x/evidence/types/evidence.go 87.50% <100.00%> (+19.75%) ⬆️

@yihuang yihuang force-pushed the fix_bech32_prefix_in_evidence branch 2 times, most recently from 41e9023 to 03521ef Compare January 28, 2021 08:46
Copy link
Collaborator

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

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

I confirm, this indeed causes problem, and the changeset is a proper fix.

@robert-zaremba
Copy link
Collaborator

@yihuang - thanks for catching this and contributing back to the SDK.

@alessio , indeed , the problem is in the following lines:

evidence := types.FromABCIEvidence(tmEvidence)
k.HandleEquivocationEvidence(ctx, evidence.(*types.Equivocation))

Above, the evidence doesn't have a prefix from config, however, when decoding, in Equivocation.GetConsensusAddress() sdk.ConsAddress, we use config to get the right prefix.

Another fix would be to use []byte instead of string for Equivocation.ConsensusAddress. This way we would avoid bech32 roundtrip at all. Probably we would need to add one more type for "presentation layer".

I approved this PR, because it solves the issue, we can think if we would prefer to alternative solution I mentioned above (I slightly prefer a solution with two types: one for model / operations, and one for presentation) - it's more bulletproof, we avoid bugs with wrong cons/val etc... prefixes.

Finally we have to add a test - ideally in this PR, but I'm OK to do it in a new PR. The test should be more or less following:

evidence := types.FromABCIEvidence(tmEvidence)
consAddr := evidence.GetConsensusAddress()
/// now we do a check:
assert.EqualValues(e.Validator.Address, consAddr)

@alessio
Copy link
Contributor

alessio commented Jan 28, 2021

Finally we have to add a test - ideally in this PR, but I'm OK to do it in a new PR

@yihuang feel like adding a test by chance?

@yihuang yihuang force-pushed the fix_bech32_prefix_in_evidence branch from 03521ef to 556ed19 Compare January 28, 2021 11:45
@yihuang
Copy link
Collaborator Author

yihuang commented Jan 28, 2021

unit test added, manually confirmed that without the change, the test fails.

@yihuang yihuang force-pushed the fix_bech32_prefix_in_evidence branch from 556ed19 to d0d778a Compare January 28, 2021 11:47
@alessio
Copy link
Contributor

alessio commented Jan 28, 2021

@tomtau dixit:

technically, this may be a consensus-breaking change for non-gaia live networks on 0.41 but probably ok to go with that?

This would go right away into v0.42 I suppose

@alessio
Copy link
Contributor

alessio commented Jan 28, 2021

@yihuang last bit: can you add a changelog entry please?

@tomtau I was thinking again about your comment, and yes, this is potentially breaking for v0.41 networks, except the Cosmos Hub.

@robert-zaremba
Copy link
Collaborator

I was thinking again about your comment, and yes, this is potentially breaking for v0.41 networks, except the Cosmos Hub.

Breaking change term is a ambiguous. This change is backward compatible, but creates valid state changes which were not valid before. So it's a soft fork.

@alessio
Copy link
Contributor

alessio commented Jan 28, 2021

Yep, the change is potentially state breaking

@yihuang
Copy link
Collaborator Author

yihuang commented Jan 28, 2021

I was thinking again about your comment, and yes, this is potentially breaking for v0.41 networks, except the Cosmos Hub.

Breaking change term is a ambiguous. This change is backward compatible, but creates valid state changes which were not valid before. So it's a soft fork.

Isn't it a hard fork? old version won't jail the faulting validator, new version will, they won't agree on the state ever after?

@yihuang yihuang force-pushed the fix_bech32_prefix_in_evidence branch from d0d778a to 4f55c93 Compare January 28, 2021 17:07
@yihuang
Copy link
Collaborator Author

yihuang commented Jan 28, 2021

@yihuang last bit: can you add a changelog entry please?

Done

Co-authored-by: Tomas Tauber <2410580+tomtau@users.noreply.github.com>
@yihuang yihuang force-pushed the fix_bech32_prefix_in_evidence branch from 4f55c93 to c722083 Compare January 28, 2021 17:08
@fedekunze fedekunze added C:x/evidence A:automerge Automatically merge PR once all prerequisites pass. labels Jan 29, 2021
@tac0turtle
Copy link
Member

@alessio & @robert-zaremba was this backported?

@robert-zaremba
Copy link
Collaborator

@marbar3778 - this is scheduled f the upcoming release.

tomtau added a commit to crypto-com/cosmos-sdk that referenced this pull request Feb 4, 2021
fix bech32 prefix in evidence (cosmos#8461)

Co-authored-by: Tomas Tauber <2410580+tomtau@users.noreply.github.com>

Co-authored-by: Tomas Tauber <2410580+tomtau@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
@robert-zaremba
Copy link
Collaborator

robert-zaremba commented Feb 4, 2021

For the record:

  • Based on the current release schedule, this won't go into 0.41.x line because it's a state machine breaking change
  • This doesn't affect Gaia - so we don't need this patch for Gaia update
  • However, 0.41.x is buggy for anyone else and we need to communicate clearly that nobody except Gaia should use 0.41.x (nor 0.40.x) and should wait for 0.42.x.

@robert-zaremba
Copy link
Collaborator

cc: @clevinson , @zmanian - check above.

@amaury1093 amaury1093 mentioned this pull request Feb 8, 2021
10 tasks
@clevinson clevinson mentioned this pull request Feb 23, 2021
7 tasks
tomtau added a commit to crypto-com/cosmos-sdk that referenced this pull request Feb 24, 2021
fix bech32 prefix in evidence (cosmos#8461)

Co-authored-by: Tomas Tauber <2410580+tomtau@users.noreply.github.com>

Co-authored-by: Tomas Tauber <2410580+tomtau@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
clevinson added a commit that referenced this pull request Feb 26, 2021
* add disclaimer for v0.41 series for non-hub SDK chains due to #8461

* update issue link

* update issue link, pt2

* fix bad issue link
mergify bot pushed a commit that referenced this pull request Feb 26, 2021
* add disclaimer for v0.41 series for non-hub SDK chains due to #8461

* update issue link

* update issue link, pt2

* fix bad issue link

(cherry picked from commit b19ac2c)

# Conflicts:
#	CHANGELOG.md
alessio pushed a commit that referenced this pull request Feb 26, 2021
… (#8708)

* Add warning notice in changelog for v0.41.x bug (ref: #8461) (#8707)

* add disclaimer for v0.41 series for non-hub SDK chains due to #8461

(cherry picked from commit b19ac2c)

Co-authored-by: Cory <cjlevinson@gmail.com>
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
SegueII pushed a commit to irisnet/cosmos-sdk that referenced this pull request Mar 2, 2021
Co-authored-by: Tomas Tauber <2410580+tomtau@users.noreply.github.com>

Co-authored-by: Tomas Tauber <2410580+tomtau@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
hydrogen18 added a commit to akash-network/cosmos-sdk that referenced this pull request Mar 2, 2021
tomtau added a commit to crypto-com/cosmos-sdk that referenced this pull request Mar 3, 2021
fix bech32 prefix in evidence (cosmos#8461)

Co-authored-by: Tomas Tauber <2410580+tomtau@users.noreply.github.com>

Co-authored-by: Tomas Tauber <2410580+tomtau@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
clevinson pushed a commit that referenced this pull request Mar 4, 2021
Co-authored-by: Tomas Tauber <2410580+tomtau@users.noreply.github.com>

Co-authored-by: Tomas Tauber <2410580+tomtau@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
SegueII pushed a commit to irisnet/cosmos-sdk that referenced this pull request Mar 4, 2021
Co-authored-by: Tomas Tauber <2410580+tomtau@users.noreply.github.com>

Co-authored-by: Tomas Tauber <2410580+tomtau@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
@amaury1093
Copy link
Contributor

@Mergifyio backport release/v0.42.x

mergify bot pushed a commit that referenced this pull request Mar 4, 2021
Co-authored-by: Tomas Tauber <2410580+tomtau@users.noreply.github.com>

Co-authored-by: Tomas Tauber <2410580+tomtau@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
(cherry picked from commit d6e4a2e)

# Conflicts:
#	CHANGELOG.md
@mergify
Copy link
Contributor

mergify bot commented Mar 4, 2021

Command backport release/v0.42.x: success

Backports have been created

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:x/evidence
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants