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(baseapp): ABCI Consensus Failure Fix #16700

Merged
merged 14 commits into from
Jun 28, 2023

Conversation

davidterpay
Copy link
Contributor

@davidterpay davidterpay commented Jun 26, 2023

Description

In this PR, I fix the issue outlined here #16676. TLDR is that FinalizeBlock must return a response for all transactions included in a proposal, otherwise Comet will trigger a consensus failure.

Closes: #16676

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)

mergify bot and others added 4 commits June 7, 2023 21:31
cosmos#16448)

Co-authored-by: Jeancarlo Barrios <JeancarloBarrios@users.noreply.github.com>
…) (cosmos#16451)

Co-authored-by: Chill Validation <92176880+chillyvee@users.noreply.github.com>
@davidterpay davidterpay requested a review from a team as a code owner June 26, 2023 17:21
@github-prbot github-prbot requested review from a team, facundomedica and atheeshp and removed request for a team June 26, 2023 17:21
Comment on lines 679 to +688
// vote extensions, so skip those.
txResults := make([]*abci.ExecTxResult, 0, len(req.Txs))
for _, rawTx := range req.Txs {
var response *abci.ExecTxResult

if _, err := app.txDecoder(rawTx); err == nil {
txResults = append(txResults, app.deliverTx(rawTx))
response = app.deliverTx(rawTx)
} else {
// In the case where a transaction included in a block proposal is malformed,
// we still want to return a default response to comet. This is because comet
Copy link
Contributor

Choose a reason for hiding this comment

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

Change potentially affects state.

Call sequence:

(*github.com/cosmos/cosmos-sdk/baseapp.BaseApp).FinalizeBlock (baseapp/abci.go:648)

Copy link
Member

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

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

can we make this against main, then a bot will backport it

@davidterpay davidterpay changed the base branch from release/v0.50.x to main June 26, 2023 17:44
@davidterpay davidterpay requested a review from julienrbrt as a code owner June 26, 2023 17:44
@github-actions github-actions bot removed the Type: CI label Jun 26, 2023
@davidterpay
Copy link
Contributor Author

@tac0turtle Switched and caught up to main.

@julienrbrt julienrbrt added the backport/v0.50.x PR scheduled for inclusion in the v0.50's next stable release label Jun 26, 2023
CHANGELOG.md Outdated
@@ -312,6 +312,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/crypto) [#15258](https://github.com/cosmos/cosmos-sdk/pull/15258) Write keyhash file with permissions 0600 instead of 0555.
* (cli) [#16138](https://github.com/cosmos/cosmos-sdk/pull/16138) Fix snapshot commands panic if snapshot don't exists.
* (x/gov) [#16230](https://github.com/cosmos/cosmos-sdk/pull/16231) Fix: rawlog JSON formatting of proposal_vote option field
* (baseapp) [#16700](https://github.com/cosmos/cosmos-sdk/pull/16700) Fix: Consensus Failure in returning no response to malformed transactions
Copy link
Member

Choose a reason for hiding this comment

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

Can you move the changelog to unreleased?

baseapp/abci.go Show resolved Hide resolved
@julienrbrt julienrbrt changed the title fix(ABCI): Consensus Failure Fix fix(baseapp): ABCI Consensus Failure Fix Jun 26, 2023
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

preliminary ACK, thanks @davidterpay!

However, we need to:

  1. Update the changelog entry placement as @julienrbrt pointed out
  2. Add a unit test in abci_test.go that creates and sets proposal handlers that inject VE. Note, we already have VE handlers that do this, you just need to set them.

@davidterpay
Copy link
Contributor Author

davidterpay commented Jun 28, 2023

@alexanderbez

Pushed a unit test that

  1. sets up prepare and process proposal to inject and verify a single vote extension
  2. executes a request for both (in order)
  3. executes finalize block smoothly

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

## [Unreleased]

* (baseapp) [#16700](https://github.com/cosmos/cosmos-sdk/pull/16700) Fix: Consensus Failure in returning no response to malformed transactions
Copy link
Member

Choose a reason for hiding this comment

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

nit, can you place it under the bug fixes category

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! one nit.

@davidterpay
Copy link
Contributor Author

nit fixed 🫡

@julienrbrt julienrbrt enabled auto-merge June 28, 2023 19:20
@julienrbrt julienrbrt added this pull request to the merge queue Jun 28, 2023
Merged via the queue into cosmos:main with commit 078e7cb Jun 28, 2023
mergify bot pushed a commit that referenced this pull request Jun 28, 2023
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Jeancarlo Barrios <JeancarloBarrios@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
Co-authored-by: Chill Validation <92176880+chillyvee@users.noreply.github.com>
(cherry picked from commit 078e7cb)

# Conflicts:
#	CHANGELOG.md
julienrbrt added a commit that referenced this pull request Jun 28, 2023
Co-authored-by: David Terpay <35130517+davidterpay@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
@alexanderbez
Copy link
Contributor

Phenomenal work @davidterpay -- thanks so much 🙏

@faddat faddat mentioned this pull request Nov 8, 2024
12 tasks
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Consensus Failure in Ignoring Malformed Transactions
4 participants