Skip to content
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased Provenance]

* nothing
### Improvments

* [618](https://github.com/provenance-io/cosmos-sdk/pull/618) Provenance: Remove the fee handler (now using the post handler).

---

Expand Down
35 changes: 7 additions & 28 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,6 @@ type BaseApp struct {
// trace set will return full stack traces for errors in ABCI Log field
trace bool

feeHandler sdk.FeeHandler

aggregateEventsFunc func(anteEvents []abci.Event, resultEvents []abci.Event) ([]abci.Event, []abci.Event)

// indexEvents defines the set of events in the form {eventType}.{attributeKey},
Expand Down Expand Up @@ -984,7 +982,13 @@ func (app *BaseApp) runTxProv(mode execMode, txBytes []byte) (gInfo sdk.GasInfo,

newCtx, errPostHandler := app.postHandler(postCtx, tx, mode == execModeSimulate, err == nil)
if errPostHandler != nil {
return gInfo, nil, anteEvents, ctx, errors.Join(err, errPostHandler)
// The result of errors.Join breaks the response code stuff, resulting in code 1 (logic error) always.
// So if there was also an error running the msgs, we'll use the error code from that, but include
// the post handler error too. Otherwise, we just return the post handler error.
if err != nil {
errPostHandler = errorsmod.Wrap(err, errPostHandler.Error())
}
return gInfo, nil, anteEvents, ctx, errPostHandler
}

// we don't want runTx to panic if runMsgs has failed earlier
Expand All @@ -995,16 +999,10 @@ func (app *BaseApp) runTxProv(mode execMode, txBytes []byte) (gInfo sdk.GasInfo,
}

if err == nil {
var feeEvents sdk.Events
if mode == execModeFinalize {
// When block gas exceeds, it'll panic and won't commit the cached store.
consumeBlockGas()

feeEvents, err = FeeInvoke(mode, app, runMsgCtx)
if err != nil {
return gInfo, nil, nil, ctx, err
}

msCache.Write()
app.finalizeBlockState.eventHistory = append(app.finalizeBlockState.eventHistory, result.Events...)
}
Expand All @@ -1013,12 +1011,6 @@ func (app *BaseApp) runTxProv(mode execMode, txBytes []byte) (gInfo sdk.GasInfo,
// append the events in the order of occurrence
result.Events = append(anteEvents, result.Events...)
}

// additional fee events
if len(feeEvents) > 0 {
// append the fee events at the end of the other events, since they get charged at the end of the Tx
result.Events = append(result.Events, feeEvents.ToABCIEvents()...)
}
}

if result != nil { // tx was successful run aggregator for ante and result events
Expand All @@ -1038,19 +1030,6 @@ func AggregateEvents(app *BaseApp, anteEvents []abci.Event, resultEvents []abci.
return anteEvents, resultEvents
}

// FeeInvoke apply fee logic and append events
func FeeInvoke(mode execMode, app *BaseApp, runMsgCtx sdk.Context) (sdk.Events, error) {
if app.feeHandler != nil {
// call the msgFee
_, eventsFromFeeHandler, err := app.feeHandler(runMsgCtx, mode == execModeSimulate)
if err != nil {
return nil, err
}
return eventsFromFeeHandler, nil
}
return nil, nil
}

// runMsgs iterates through a list of messages and executes them with the provided
// Context and execution mode. Messages will only be executed during simulation
// and DeliverTx. An error is returned if any single message fails or if a
Expand Down
10 changes: 1 addition & 9 deletions baseapp/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"math"

abci "github.com/cometbft/cometbft/abci/types"

dbm "github.com/cosmos/cosmos-db"

"cosmossdk.io/store/metrics"
Expand Down Expand Up @@ -319,15 +320,6 @@ func (app *BaseApp) SetQueryMultiStore(ms storetypes.MultiStore) {
app.qms = ms
}

// SetFeeHandler sets the FeeHandler which if set will change the behavior of fee handling
func (app *BaseApp) SetFeeHandler(feeHandler sdk.FeeHandler) {
if app.sealed {
panic("SetFeeHandler() on sealed BaseApp")
}

app.feeHandler = feeHandler
}

// SetAggregateEventsFunc sets the function that aggregates events from baseapp result events and feehandler events
func (app *BaseApp) SetAggregateEventsFunc(aggregateEventsFunc func(resultEvents []abci.Event, feeEvents []abci.Event) ([]abci.Event, []abci.Event)) {
if app.sealed {
Expand Down