Skip to content

Refactor DeliverTx hook so that panics can be handled

Compare
Choose a tag to compare
@codchen codchen released this 17 Oct 03:35
· 14 commits to main since this release
4e7d467
Refactor DeliverTx hook so that panics can be handled (#543)

## Describe your changes and provide context
Panics in tx handler is usually handled by a defer statement containing
a `recover()` clause. Previously the call stack looks like:
```
func DeliverTx:
    func runTx:
        deferred recover
        (actual processing)
    DeliverTx hook
```
In the above structure, DeliverTx hooks are run on `DeliverTx` level, so
they are outside the deferred recover clause which is within `runTx`
level.

This PR changes it to be:
```
func DeliverTx:
    func runTx:
        deferred recover
        (actual processing)
        DeliverTx hook
```
so that the hook can be recovered as well

## Testing performed to validate your change
unit test