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

Add catch all panic handler in dex endblock #1196

Merged
merged 3 commits into from
Dec 29, 2023
Merged

Add catch all panic handler in dex endblock #1196

merged 3 commits into from
Dec 29, 2023

Conversation

codchen
Copy link
Collaborator

@codchen codchen commented Dec 29, 2023

Describe your changes and provide context

Any panic in EndBlock would cause the chain to halt, so we decide to add back panic recovery handler. Also made executions for multiple pairs sequential for each contract so that panics are easier to manage.

After this fix, there will be:

Testing performed to validate your change

Screen Shot 2023-12-29 at 12 25 42 PM Tested locally by reproducing the reported bug POC

Copy link

codecov bot commented Dec 29, 2023

Codecov Report

Attention: 8 lines in your changes are missing coverage. Please review.

Comparison is base (3a53526) 63.83% compared to head (6da466e) 63.38%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1196      +/-   ##
==========================================
- Coverage   63.83%   63.38%   -0.45%     
==========================================
  Files         257      257              
  Lines       16672    16690      +18     
==========================================
- Hits        10642    10579      -63     
- Misses       5526     5603      +77     
- Partials      504      508       +4     
Files Coverage Δ
x/dex/contract/execution.go 82.87% <100.00%> (ø)
x/dex/contract/runner.go 92.50% <100.00%> (+4.50%) ⬆️
x/dex/contract/abci.go 7.35% <63.63%> (+3.77%) ⬆️
x/dex/module.go 57.21% <20.00%> (-0.99%) ⬇️

... and 6 files with indirect coverage changes

@yzang2019
Copy link
Contributor

Can we add a metric for panicHandler so that we can monitor and alert on it?

@@ -130,16 +129,17 @@ func ExecutePairsInParallel(ctx sdk.Context, contractAddr string, dexkeeper *kee
cancelResults := []*types.Cancellation{}
settlements := []*types.SettlementEntry{}

mu := sync.Mutex{}
wg := sync.WaitGroup{}
// mu := sync.Mutex{}
Copy link
Contributor

Choose a reason for hiding this comment

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

We leave them here so that we can revert them in case we need?

@yzang2019 yzang2019 merged commit 3734b34 into main Dec 29, 2023
37 checks passed
@yzang2019 yzang2019 deleted the fix-dex branch December 29, 2023 19:24
philipsu522 pushed a commit that referenced this pull request Dec 29, 2023
* Add catch all panic handler in dex endblock

* test

* Add a new counter metric for recovered panics

---------

Co-authored-by: yzang2019 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants