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

Baseapp recovery middleware #6053

Merged
merged 11 commits into from
Jun 5, 2020

Conversation

iTiky
Copy link

@iTiky iTiky commented Apr 22, 2020

Description

PR adds panic recovery middleware which is used in app.runTx() method. Feature add ability for Cosmos SDK based projects to register custom panic handlers for app.Deliver().
Proposed middleware acts as a handling chain for recover() object, for example: Custom user-defined handler -> Standard OutOfGas handler -> Default handler. User can assert recovery object type and if it matches, add some logging context / emit panic / etc (example).

Idea background:

  • In our project for specific keeper's panic source (critical error) we have to emit panic() to start a CONSENSUS FAILURE!!! mechanism. For that we have to inject (copy-paste) the entire baseapp source code to modify it and it makes a lot of migration to newer SDK version problems.
  • The proposed solution might be used in other defer recover() sections where the handling customization is required.

For contributor use:

  • 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

For admin use:

  • Added appropriate labels to PR (ex. WIP, R4R, docs, etc)
  • Reviewers assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@alexanderbez
Copy link
Contributor

Thanks for contributing to the framework @iTiky! This proposal looks very interesting. Before taking a look at the actual changes, it's clear that this work makes critical changes to the execution model design.

That being the case, I'd highly recommend first creating and submitting an ADR (essentially an RFC). This way we have record of the context and what decision was made and why.

We should leave this PR open and to be used as a reference in the meantime 👍

Mikhail Kornilov added 2 commits April 29, 2020 19:25
@codecov
Copy link

codecov bot commented Apr 29, 2020

Codecov Report

Merging #6053 into master will increase coverage by 0.03%.
The diff coverage is 84.21%.

@@            Coverage Diff             @@
##           master    #6053      +/-   ##
==========================================
+ Coverage   55.66%   55.70%   +0.03%     
==========================================
  Files         448      449       +1     
  Lines       26983    27006      +23     
==========================================
+ Hits        15020    15043      +23     
+ Misses      10884    10883       -1     
- Partials     1079     1080       +1     

@iTiky
Copy link
Author

iTiky commented May 13, 2020

@alexanderbez As the ADR-022 is approved can we push this implementation?

@alexanderbez
Copy link
Contributor

Yes, ADR is approved. Let's merge that and then we can further review this 👍

@iTiky
Copy link
Author

iTiky commented May 20, 2020

@alexanderbez ADR is merged and implementation here is identical to the discussed one. Can we push it forward? I'm really looking forward to use this solution in our project and remove unnecessary BaseApp code copy-paste.

@alexanderbez
Copy link
Contributor

@iTiky do you mind merging in the latest master, please? I'd like to test this out locally via Gaia.

@iTiky
Copy link
Author

iTiky commented May 20, 2020

Done

@iTiky
Copy link
Author

iTiky commented May 28, 2020

@alexanderbez Was the local test successful? I'm really curious about that )

@alexanderbez
Copy link
Contributor

@jgimeno @alessio do you have the capacity to help review and test this?

@alessio
Copy link
Contributor

alessio commented May 28, 2020

@iTiky please merge master in

Copy link
Contributor

@alessio alessio left a comment

Choose a reason for hiding this comment

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

Tested, it seems to work pretty well. Though I think we may need some docs here: docs/core/

@iTiky iTiky requested review from alessio and removed request for hschoenburg May 29, 2020 12:18
Copy link
Contributor

@alessio alessio left a comment

Choose a reason for hiding this comment

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

Approved

@tac0turtle tac0turtle added the A:automerge Automatically merge PR once all prerequisites pass. label Jun 5, 2020
@tac0turtle
Copy link
Member

tac0turtle commented Jun 5, 2020

@iTiky could merge master

@tac0turtle
Copy link
Member

@Mergifyio refresh

@mergify
Copy link
Contributor

mergify bot commented Jun 5, 2020

Command refresh: success

@mergify mergify bot merged commit ced080a into cosmos:master Jun 5, 2020
@iTiky iTiky deleted the baseapp-recovery-middleware branch August 26, 2020 15:20
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants