Skip to content

Commit 1ae61b4

Browse files
author
yihuang
authored
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 <[email protected]> --------- Signed-off-by: yihuang <[email protected]>
1 parent 8a698f4 commit 1ae61b4

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* (testground)[#1651](https://github.com/crypto-org-chain/cronos/pull/1651) Benchmark use cosmos broadcast rpc.
1818
* (testground)[#1650](https://github.com/crypto-org-chain/cronos/pull/1650) Benchmark support batch mode.
1919
* [#1658](https://github.com/crypto-org-chain/cronos/pull/1658) Optimize when block-list is empty.
20+
* (testground)[#1659](https://github.com/crypto-org-chain/cronos/pull/1659) Support skip check-tx in benchmark.
2021

2122
*Oct 14, 2024*
2223

app/app.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ const (
188188

189189
FlagBlockedAddresses = "blocked-addresses"
190190
FlagUnsafeIgnoreBlockListFailure = "unsafe-ignore-block-list-failure"
191+
FlagUnsafeDummyCheckTx = "unsafe-dummy-check-tx"
191192
)
192193

193194
var Forks = []Fork{}
@@ -289,6 +290,7 @@ type App struct {
289290
// encoding
290291
cdc *codec.LegacyAmino
291292
txConfig client.TxConfig
293+
txDecoder sdk.TxDecoder
292294
appCodec codec.Codec
293295
interfaceRegistry types.InterfaceRegistry
294296

@@ -352,6 +354,9 @@ type App struct {
352354
qms storetypes.RootMultiStore
353355

354356
blockProposalHandler *ProposalHandler
357+
358+
// unsafe to set for validator, used for testing
359+
dummyCheckTx bool
355360
}
356361

357362
// New returns a reference to an initialized chain.
@@ -456,6 +461,7 @@ func New(
456461
BaseApp: bApp,
457462
cdc: cdc,
458463
txConfig: txConfig,
464+
txDecoder: txDecoder,
459465
appCodec: appCodec,
460466
interfaceRegistry: interfaceRegistry,
461467
invCheckPeriod: invCheckPeriod,
@@ -464,6 +470,7 @@ func New(
464470
okeys: okeys,
465471
memKeys: memKeys,
466472
blockProposalHandler: blockProposalHandler,
473+
dummyCheckTx: cast.ToBool(appOpts.Get(FlagUnsafeDummyCheckTx)),
467474
}
468475

469476
app.SetDisableBlockGasMeter(true)
@@ -1466,3 +1473,21 @@ func (app *App) Close() error {
14661473
func maxParallelism() int {
14671474
return min(stdruntime.GOMAXPROCS(0), stdruntime.NumCPU())
14681475
}
1476+
1477+
func (app *App) CheckTx(req *abci.RequestCheckTx) (*abci.ResponseCheckTx, error) {
1478+
if app.dummyCheckTx {
1479+
tx, err := app.txDecoder(req.Tx)
1480+
if err != nil {
1481+
return nil, err
1482+
}
1483+
1484+
feeTx, ok := tx.(sdk.FeeTx)
1485+
if !ok {
1486+
return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "tx must be FeeTx")
1487+
}
1488+
1489+
return &abci.ResponseCheckTx{Code: abci.CodeTypeOK, GasWanted: int64(feeTx.GetGas())}, nil
1490+
}
1491+
1492+
return app.BaseApp.CheckTx(req)
1493+
}

0 commit comments

Comments
 (0)