Skip to content

Commit

Permalink
Problem: don't support skipping check-tx in benchmark (#1659)
Browse files Browse the repository at this point in the history
* Problem: don't support skipping check-tx in benchmark

* Update CHANGELOG.md

Signed-off-by: yihuang <[email protected]>

---------

Signed-off-by: yihuang <[email protected]>
  • Loading branch information
yihuang authored Oct 23, 2024
1 parent 8a698f4 commit 1ae61b4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*

Expand Down
25 changes: 25 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ const (

FlagBlockedAddresses = "blocked-addresses"
FlagUnsafeIgnoreBlockListFailure = "unsafe-ignore-block-list-failure"
FlagUnsafeDummyCheckTx = "unsafe-dummy-check-tx"
)

var Forks = []Fork{}
Expand Down Expand Up @@ -289,6 +290,7 @@ type App struct {
// encoding
cdc *codec.LegacyAmino
txConfig client.TxConfig
txDecoder sdk.TxDecoder
appCodec codec.Codec
interfaceRegistry types.InterfaceRegistry

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -456,6 +461,7 @@ func New(
BaseApp: bApp,
cdc: cdc,
txConfig: txConfig,
txDecoder: txDecoder,
appCodec: appCodec,
interfaceRegistry: interfaceRegistry,
invCheckPeriod: invCheckPeriod,
Expand All @@ -464,6 +470,7 @@ func New(
okeys: okeys,
memKeys: memKeys,
blockProposalHandler: blockProposalHandler,
dummyCheckTx: cast.ToBool(appOpts.Get(FlagUnsafeDummyCheckTx)),
}

app.SetDisableBlockGasMeter(true)
Expand Down Expand Up @@ -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)
}

0 comments on commit 1ae61b4

Please sign in to comment.