From 4fb1b9e8ea9e656a53fdd3cdf78b12f4552aee9e Mon Sep 17 00:00:00 2001 From: marcello33 Date: Mon, 14 Oct 2024 09:35:44 +0200 Subject: [PATCH] chg: make runTx private again --- baseapp/abci.go | 2 +- baseapp/abci_test.go | 2 +- baseapp/abci_utils.go | 4 ++-- baseapp/baseapp.go | 16 ++++++++-------- baseapp/recovery.go | 4 ++-- baseapp/test_helpers.go | 12 ++++++------ 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/baseapp/abci.go b/baseapp/abci.go index 958949925721..a78fc700bc14 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -347,7 +347,7 @@ func (app *BaseApp) CheckTx(req *abci.RequestCheckTx) (*abci.ResponseCheckTx, er return nil, fmt.Errorf("unknown RequestCheckTx type: %s", req.Type) } - gInfo, result, anteEvents, err := app.RunTx(mode, req.Tx) + gInfo, result, anteEvents, err := app.runTx(mode, req.Tx) if err != nil { return sdkerrors.ResponseCheckTxWithEvents(err, gInfo.GasWanted, gInfo.GasUsed, anteEvents, app.trace), nil } diff --git a/baseapp/abci_test.go b/baseapp/abci_test.go index 58a6cb6b057e..ee044fc1efc5 100644 --- a/baseapp/abci_test.go +++ b/baseapp/abci_test.go @@ -928,7 +928,7 @@ func TestABCI_TxGasLimits(t *testing.T) { // AnteHandlers must have their own defer/recover in order for the BaseApp // to know how much gas was used! This is because the GasMeter is created in // the AnteHandler, but if it panics the context won't be set properly in - // RunTx's recover call. + // runTx's recover call. defer func() { if r := recover(); r != nil { switch rType := r.(type) { diff --git a/baseapp/abci_utils.go b/baseapp/abci_utils.go index e59caaae644b..0b570ab52a69 100644 --- a/baseapp/abci_utils.go +++ b/baseapp/abci_utils.go @@ -173,7 +173,7 @@ func (h *DefaultProposalHandler) SetTxSelector(ts TxSelector) { // transactions are added to the proposal. Transactions are valid if they: // // 1) Successfully encode to bytes. -// 2) Are valid (i.e. pass RunTx, AnteHandler only). +// 2) Are valid (i.e. pass runTx, AnteHandler only). // // Enumeration is halted once RequestPrepareProposal.MaxBytes of transactions is // reached or the mempool is exhausted. @@ -250,7 +250,7 @@ func (h *DefaultProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHan // ABCI proposal. Every transaction in the proposal must pass 2 conditions: // // 1. The transaction bytes must decode to a valid transaction. -// 2. The transaction must be valid (i.e. pass RunTx, AnteHandler only) +// 2. The transaction must be valid (i.e. pass runTx, AnteHandler only) // // If any transaction fails to pass either condition, the proposal is rejected. // Note that step (2) is identical to the validation step performed in diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 109639706e9d..8de14c5f058b 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -163,7 +163,7 @@ type BaseApp struct { // if BaseApp is passed to the upgrade keeper's NewKeeper method. appVersion uint64 - // recovery handler for app.RunTx method + // recovery handler for app.runTx method runTxRecoveryMiddleware recoveryMiddleware // trace set will return full stack traces for errors in ABCI Log field @@ -534,7 +534,7 @@ func (app *BaseApp) StoreConsensusParams(ctx sdk.Context, cp cmtproto.ConsensusP return app.paramStore.Set(ctx, cp) } -// AddRunTxRecoveryHandler adds custom app.RunTx method panic handlers. +// AddRunTxRecoveryHandler adds custom app.runTx method panic handlers. func (app *BaseApp) AddRunTxRecoveryHandler(handlers ...RecoveryHandler) { for _, h := range handlers { app.runTxRecoveryMiddleware = newRecoveryMiddleware(h, app.runTxRecoveryMiddleware) @@ -738,7 +738,7 @@ func (app *BaseApp) deliverTx(tx []byte) *abci.ExecTxResult { telemetry.SetGauge(float32(gInfo.GasWanted), "tx", "gas", "wanted") }() - gInfo, result, anteEvents, err := app.RunTx(execModeFinalize, tx) + gInfo, result, anteEvents, err := app.runTx(execModeFinalize, tx) if err != nil { resultStr = "failed" resp = sdkerrors.ResponseExecTxResultWithEvents( @@ -788,14 +788,14 @@ func (app *BaseApp) endBlock(ctx context.Context) (sdk.EndBlock, error) { return endblock, nil } -// RunTx processes a transaction within a given execution mode, encoded transaction +// runTx processes a transaction within a given execution mode, encoded transaction // bytes, and the decoded transaction itself. All state transitions occur through // a cached Context depending on the mode provided. State only gets persisted // if all messages get executed successfully and the execution mode is DeliverTx. // Note, gas execution info is always returned. A reference to a Result is // returned if the tx does not run out of gas and if all the messages are valid // and execute successfully. An error is returned otherwise. -func (app *BaseApp) RunTx(mode execMode, txBytes []byte) (gInfo sdk.GasInfo, result *sdk.Result, anteEvents []abci.Event, err error) { +func (app *BaseApp) runTx(mode execMode, txBytes []byte) (gInfo sdk.GasInfo, result *sdk.Result, anteEvents []abci.Event, err error) { // NOTE: GasWanted should be returned by the AnteHandler. GasUsed is // determined by the GasMeter. We need access to the context to get the gas // meter, so we initialize upfront. @@ -813,7 +813,7 @@ func (app *BaseApp) RunTx(mode execMode, txBytes []byte) (gInfo sdk.GasInfo, res if r := recover(); r != nil { recoveryMW := newOutOfGasRecoveryMiddleware(gasWanted, ctx, app.runTxRecoveryMiddleware) err, result = processRecovery(r, recoveryMW), nil - ctx.Logger().Error("panic recovered in RunTx", "err", err) + ctx.Logger().Error("panic recovered in runTx", "err", err) } gInfo = sdk.GasInfo{GasWanted: gasWanted, GasUsed: ctx.GasMeter().GasConsumed()} @@ -1073,7 +1073,7 @@ func (app *BaseApp) PrepareProposalVerifyTx(tx sdk.Tx) ([]byte, error) { return nil, err } - _, _, _, err = app.RunTx(execModePrepareProposal, bz) + _, _, _, err = app.runTx(execModePrepareProposal, bz) if err != nil { return nil, err } @@ -1092,7 +1092,7 @@ func (app *BaseApp) ProcessProposalVerifyTx(txBz []byte) (sdk.Tx, error) { return nil, err } - _, _, _, err = app.RunTx(execModeProcessProposal, txBz) + _, _, _, err = app.runTx(execModeProcessProposal, txBz) if err != nil { return nil, err } diff --git a/baseapp/recovery.go b/baseapp/recovery.go index 746618bfce8b..ca6cfca0625a 100644 --- a/baseapp/recovery.go +++ b/baseapp/recovery.go @@ -47,7 +47,7 @@ func newRecoveryMiddleware(handler RecoveryHandler, next recoveryMiddleware) rec } } -// newOutOfGasRecoveryMiddleware creates a standard OutOfGas recovery middleware for app.RunTx method. +// newOutOfGasRecoveryMiddleware creates a standard OutOfGas recovery middleware for app.runTx method. func newOutOfGasRecoveryMiddleware(gasWanted uint64, ctx sdk.Context, next recoveryMiddleware) recoveryMiddleware { handler := func(recoveryObj interface{}) error { err, ok := recoveryObj.(storetypes.ErrorOutOfGas) @@ -66,7 +66,7 @@ func newOutOfGasRecoveryMiddleware(gasWanted uint64, ctx sdk.Context, next recov return newRecoveryMiddleware(handler, next) } -// newDefaultRecoveryMiddleware creates a default (last in chain) recovery middleware for app.RunTx method. +// newDefaultRecoveryMiddleware creates a default (last in chain) recovery middleware for app.runTx method. func newDefaultRecoveryMiddleware() recoveryMiddleware { handler := func(recoveryObj interface{}) error { return errorsmod.Wrap( diff --git a/baseapp/test_helpers.go b/baseapp/test_helpers.go index 5f026cda62a9..db603f2f2982 100644 --- a/baseapp/test_helpers.go +++ b/baseapp/test_helpers.go @@ -11,21 +11,21 @@ import ( // SimCheck defines a CheckTx helper function that used in tests and simulations. func (app *BaseApp) SimCheck(txEncoder sdk.TxEncoder, tx sdk.Tx) (sdk.GasInfo, *sdk.Result, error) { - // RunTx expects tx bytes as argument, so we encode the tx argument into - // bytes. Note that RunTx will actually decode those bytes again. But since + // runTx expects tx bytes as argument, so we encode the tx argument into + // bytes. Note that runTx will actually decode those bytes again. But since // this helper is only used in tests/simulation, it's fine. bz, err := txEncoder(tx) if err != nil { return sdk.GasInfo{}, nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "%s", err) } - gasInfo, result, _, err := app.RunTx(execModeCheck, bz) + gasInfo, result, _, err := app.runTx(execModeCheck, bz) return gasInfo, result, err } // Simulate executes a tx in simulate mode to get result and gas info. func (app *BaseApp) Simulate(txBytes []byte) (sdk.GasInfo, *sdk.Result, error) { - gasInfo, result, _, err := app.RunTx(execModeSimulate, txBytes) + gasInfo, result, _, err := app.runTx(execModeSimulate, txBytes) return gasInfo, result, err } @@ -35,7 +35,7 @@ func (app *BaseApp) SimDeliver(txEncoder sdk.TxEncoder, tx sdk.Tx) (sdk.GasInfo, if err != nil { return sdk.GasInfo{}, nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "%s", err) } - gasInfo, result, _, err := app.RunTx(execModeFinalize, bz) + gasInfo, result, _, err := app.runTx(execModeFinalize, bz) return gasInfo, result, err } @@ -46,7 +46,7 @@ func (app *BaseApp) SimTxFinalizeBlock(txEncoder sdk.TxEncoder, tx sdk.Tx) (sdk. return sdk.GasInfo{}, nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "%s", err) } - gasInfo, result, _, err := app.RunTx(execModeFinalize, bz) + gasInfo, result, _, err := app.runTx(execModeFinalize, bz) return gasInfo, result, err }