From 92ae8850e1ff0ca6ff2e18f8fb9acf458e7f8f92 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Mon, 29 Apr 2024 01:13:40 -0700 Subject: [PATCH] perf: Make recheck not re-run validate basic (#20208) --- CHANGELOG.md | 1 + baseapp/baseapp.go | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5e0e8ac1799..b33db49d7cdf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -94,6 +94,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i * (x/genutil) [#19735](https://github.com/cosmos/cosmos-sdk/pull/19735) Update genesis api to match new `appmodule.HasGenesis` interface. * (server) [#19966](https://github.com/cosmos/cosmos-sdk/pull/19966) Return BlockHeader by shallow copy in server Context. * (proto) [#20098](https://github.com/cosmos/cosmos-sdk/pull/20098) Use cosmos_proto added_in annotation instead of // Since comments. +* (baseapp) [#20208](https://github.com/cosmos/cosmos-sdk/pull/20208) Skip running validateBasic for rechecking txs. ### Bug Fixes diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 2726a36f080b..f4cb145b273a 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -871,8 +871,12 @@ func (app *BaseApp) runTx(mode execMode, txBytes []byte) (gInfo sdk.GasInfo, res } msgs := tx.GetMsgs() - if err := validateBasicTxMsgs(app.msgServiceRouter, msgs); err != nil { - return sdk.GasInfo{}, nil, nil, err + // run validate basic if mode != recheck. + // as validate basic is stateless, it is guaranteed to pass recheck, given that its passed checkTx. + if mode != execModeReCheck { + if err := validateBasicTxMsgs(app.msgServiceRouter, msgs); err != nil { + return sdk.GasInfo{}, nil, nil, err + } } if app.anteHandler != nil {