From 1ae61b41edf5ea91c76d5cb149d0a57c3d1c57ab Mon Sep 17 00:00:00 2001 From: yihuang Date: Wed, 23 Oct 2024 15:12:58 +0800 Subject: [PATCH] Problem: don't support skipping check-tx in benchmark (#1659) * Problem: don't support skipping check-tx in benchmark * Update CHANGELOG.md Signed-off-by: yihuang --------- Signed-off-by: yihuang --- CHANGELOG.md | 1 + app/app.go | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8da07261a..1ecb6b2c69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ * (testground)[#1651](https://github.com/crypto-org-chain/cronos/pull/1651) Benchmark use cosmos broadcast rpc. * (testground)[#1650](https://github.com/crypto-org-chain/cronos/pull/1650) Benchmark support batch mode. * [#1658](https://github.com/crypto-org-chain/cronos/pull/1658) Optimize when block-list is empty. +* (testground)[#1659](https://github.com/crypto-org-chain/cronos/pull/1659) Support skip check-tx in benchmark. *Oct 14, 2024* diff --git a/app/app.go b/app/app.go index b8905c4170..2ef656b0d5 100644 --- a/app/app.go +++ b/app/app.go @@ -188,6 +188,7 @@ const ( FlagBlockedAddresses = "blocked-addresses" FlagUnsafeIgnoreBlockListFailure = "unsafe-ignore-block-list-failure" + FlagUnsafeDummyCheckTx = "unsafe-dummy-check-tx" ) var Forks = []Fork{} @@ -289,6 +290,7 @@ type App struct { // encoding cdc *codec.LegacyAmino txConfig client.TxConfig + txDecoder sdk.TxDecoder appCodec codec.Codec interfaceRegistry types.InterfaceRegistry @@ -352,6 +354,9 @@ type App struct { qms storetypes.RootMultiStore blockProposalHandler *ProposalHandler + + // unsafe to set for validator, used for testing + dummyCheckTx bool } // New returns a reference to an initialized chain. @@ -456,6 +461,7 @@ func New( BaseApp: bApp, cdc: cdc, txConfig: txConfig, + txDecoder: txDecoder, appCodec: appCodec, interfaceRegistry: interfaceRegistry, invCheckPeriod: invCheckPeriod, @@ -464,6 +470,7 @@ func New( okeys: okeys, memKeys: memKeys, blockProposalHandler: blockProposalHandler, + dummyCheckTx: cast.ToBool(appOpts.Get(FlagUnsafeDummyCheckTx)), } app.SetDisableBlockGasMeter(true) @@ -1466,3 +1473,21 @@ func (app *App) Close() error { func maxParallelism() int { return min(stdruntime.GOMAXPROCS(0), stdruntime.NumCPU()) } + +func (app *App) CheckTx(req *abci.RequestCheckTx) (*abci.ResponseCheckTx, error) { + if app.dummyCheckTx { + tx, err := app.txDecoder(req.Tx) + if err != nil { + return nil, err + } + + feeTx, ok := tx.(sdk.FeeTx) + if !ok { + return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "tx must be FeeTx") + } + + return &abci.ResponseCheckTx{Code: abci.CodeTypeOK, GasWanted: int64(feeTx.GetGas())}, nil + } + + return app.BaseApp.CheckTx(req) +}