Skip to content

Commit

Permalink
Only apply DeliverTx hooks if there is no error (#544)
Browse files Browse the repository at this point in the history
## Describe your changes and provide context
Previously we only apply hooks if there is no error in DeliverTx
response, which is changed by the
[refactor](https://github.com/sei-protocol/sei-cosmos/pull/543/files).
This PR fixes it

## Testing performed to validate your change
integration test in sei-chain
  • Loading branch information
codchen authored Oct 22, 2024
1 parent 4e7d467 commit c7e50a2
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -1007,24 +1007,27 @@ func (app *BaseApp) runTx(ctx sdk.Context, mode runTxMode, tx sdk.Tx, checksum [
if ctx.CheckTxCallback() != nil {
ctx.CheckTxCallback()(ctx, err)
}
var evmTxInfo *abci.EvmTxInfo
if ctx.IsEVM() {
evmTxInfo = &abci.EvmTxInfo{
SenderAddress: ctx.EVMSenderAddress(),
Nonce: ctx.EVMNonce(),
TxHash: ctx.EVMTxHash(),
VmError: result.EvmError,
// only apply hooks if no error
if err == nil && (!ctx.IsEVM() || result.EvmError == "") {
var evmTxInfo *abci.EvmTxInfo
if ctx.IsEVM() {
evmTxInfo = &abci.EvmTxInfo{
SenderAddress: ctx.EVMSenderAddress(),
Nonce: ctx.EVMNonce(),
TxHash: ctx.EVMTxHash(),
VmError: result.EvmError,
}
}
var events []abci.Event = []abci.Event{}
if result != nil {
events = sdk.MarkEventsToIndex(result.Events, app.indexEvents)
}
for _, hook := range app.deliverTxHooks {
hook(ctx, tx, checksum, sdk.DeliverTxHookInput{
EvmTxInfo: evmTxInfo,
Events: events,
})
}
}
var events []abci.Event = []abci.Event{}
if result != nil {
events = sdk.MarkEventsToIndex(result.Events, app.indexEvents)
}
for _, hook := range app.deliverTxHooks {
hook(ctx, tx, checksum, sdk.DeliverTxHookInput{
EvmTxInfo: evmTxInfo,
Events: events,
})
}
return gInfo, result, anteEvents, priority, pendingTxChecker, expireHandler, ctx, err
}
Expand Down

0 comments on commit c7e50a2

Please sign in to comment.