Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: don't support skipping check-tx in benchmark #1659

Merged
merged 4 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
Loading