Skip to content

Commit

Permalink
fix: Parallel checktx ante-handler error
Browse files Browse the repository at this point in the history
  • Loading branch information
dudong2 committed Jan 15, 2025
1 parent 3c1f7a0 commit 7191568
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,9 @@ func (app *BaseApp) CheckTxSync(req *abci.RequestCheckTx) (*abci.ResponseCheckTx
waitWgs(waits)
defer app.checkAccountWGs.Done(signals)

gInfo, err := app.checkTx(mode, req.Tx, tx)
gInfo, anteEvents, err := app.checkTx(mode, req.Tx, tx)
if err != nil {
return sdkerrors.ResponseCheckTxWithEvents(err, gInfo.GasWanted, gInfo.GasUsed, nil, false), nil
return sdkerrors.ResponseCheckTxWithEvents(err, gInfo.GasWanted, gInfo.GasUsed, anteEvents, false), nil
}
return &abci.ResponseCheckTx{
GasWanted: int64(gInfo.GasWanted), // TODO: Should type accept unsigned ints?
Expand Down
11 changes: 8 additions & 3 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ func (app *BaseApp) preCheckTx(txBytes []byte) (tx sdk.Tx, err error) {
return tx, err
}

func (app *BaseApp) checkTx(mode execMode, txBytes []byte, tx sdk.Tx) (gInfo sdk.GasInfo, err error) {
func (app *BaseApp) checkTx(mode execMode, txBytes []byte, tx sdk.Tx) (gInfo sdk.GasInfo, anteEvents []abci.Event, err error) {
ctx := app.getContextForTx(mode, txBytes, -1)
gasCtx := &ctx

Expand All @@ -785,15 +785,20 @@ func (app *BaseApp) checkTx(mode execMode, txBytes []byte, tx sdk.Tx) (gInfo sdk
if !anteCtx.IsZero() {
gasCtx = &anteCtx
}
if err != nil {
return gInfo, anteEvents, err
}

if mode == execModeCheck {
err = app.mempool.Insert(ctx, tx)
if err != nil {
return gInfo, err
return gInfo, anteEvents, err
}
}

return gInfo, err
anteEvents = anteCtx.EventManager().Events().ToABCIEvents()

return gInfo, anteEvents, err
}

func (app *BaseApp) anteTx(ctx sdk.Context, txBytes []byte, tx sdk.Tx, simulate bool) (sdk.Context, error) {
Expand Down
4 changes: 2 additions & 2 deletions baseapp/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ func (app *BaseApp) checkTxAsync(req *RequestCheckTxAsync, waits []*sync.WaitGro
panic(fmt.Sprintf("unknown RequestCheckTx type: %s", req.txType))
}

gInfo, err := app.checkTx(mode, req.txBytes, req.tx)
gInfo, anteEvents, err := app.checkTx(mode, req.txBytes, req.tx)
if err != nil {
req.callback(sdkerrors.ResponseCheckTxWithEvents(err, gInfo.GasWanted, gInfo.GasUsed, nil, false))
req.callback(sdkerrors.ResponseCheckTxWithEvents(err, gInfo.GasWanted, gInfo.GasUsed, anteEvents, false))
return
}

Expand Down

0 comments on commit 7191568

Please sign in to comment.