From 8fc926973ff5e7ee49fae0bcc4677a5a6de7830d Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 28 Apr 2024 23:31:41 -0700 Subject: [PATCH 1/3] Make recheck not re-run validate basic --- baseapp/baseapp.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 2726a36f080b..0126bee82060 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -871,8 +871,10 @@ 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 + if mode != runTxModeReCheck { + if err := validateBasicTxMsgs(app.msgServiceRouter, msgs); err != nil { + return sdk.GasInfo{}, nil, nil, err + } } if app.anteHandler != nil { From f390972a1ab4df6b0b50986c80c6f75157faa28f Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 28 Apr 2024 23:33:56 -0700 Subject: [PATCH 2/3] Fix variable naming for upstream SDK --- baseapp/baseapp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 0126bee82060..82f909567953 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -871,7 +871,7 @@ func (app *BaseApp) runTx(mode execMode, txBytes []byte) (gInfo sdk.GasInfo, res } msgs := tx.GetMsgs() - if mode != runTxModeReCheck { + if mode != execModeReCheck { if err := validateBasicTxMsgs(app.msgServiceRouter, msgs); err != nil { return sdk.GasInfo{}, nil, nil, err } From 1525eb1b54b48a1fa63ca215089de45babfe8ef3 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 28 Apr 2024 23:34:51 -0700 Subject: [PATCH 3/3] Add code comment --- CHANGELOG.md | 1 + baseapp/baseapp.go | 2 ++ 2 files changed, 3 insertions(+) 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 82f909567953..f4cb145b273a 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -871,6 +871,8 @@ func (app *BaseApp) runTx(mode execMode, txBytes []byte) (gInfo sdk.GasInfo, res } msgs := tx.GetMsgs() + // 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