Skip to content

Commit 79d1c73

Browse files
SpicyLemondependabot[bot]julienrbrtalessiozrbecker
authored
Remove fee handler and fix post-handler error handling. (#618)
* Remove the fee handler customization since the SDK added a post handler that does pretty much the same thing. * Make DefaultGasLimit a variable instead of constant. * Fix the post handler response code thing. * Bring in SDK changes up to v0.50.12 and Mark v0.50.12-pio-1. (#614) * build(deps): Bump github.com/cosmos/cosmos-db from 1.1.0 to 1.1.1 (cosmos#23030) * build(deps): Bump github.com/cosmos/ledger-cosmos-go from 0.13.3 to 0.14.0 (cosmos#23029) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Julien Robert <julien@rbrt.fr> * feat(x/tx): add an option to encode maps using amino json (backport cosmos#23539) (cosmos#23540) Co-authored-by: Julien Robert <julien@rbrt.fr> * feat(client/v2): add map support (backport cosmos#23544) (cosmos#23554) Co-authored-by: Julien Robert <julien@rbrt.fr> * docs(keyring): add keyctl docs (backport cosmos#23563) (cosmos#23566) Co-authored-by: Alessio Treglia <al@essio.dev> * docs: correct explanation on how to set custom signer via depinject (backport cosmos#23654) (cosmos#23663) Co-authored-by: Julien Robert <julien@rbrt.fr> * chore: remove unused orm module (backport cosmos#23633) (cosmos#23637) Co-authored-by: Zachary Becker <zrbecker@gmail.com> * Merge commit from fork * Prevent empty groups (cherry picked from commit 95090a0ec1f193104ba7d6d033a490d1515e54d8) * Handle inflight proposals (cherry picked from commit 855983471882068894ed7952b592ab3e61b464b9) * No empty group with simulations * Update changelog * Set release date * updates * Update RELEASE_NOTES.md * Update RELEASE_NOTES.md --------- Co-authored-by: Alex Peters <alpe@users.noreply.github.com> Co-authored-by: Julien Robert <julien@rbrt.fr> * Mark v0.50.12-pio-1 in the changelog. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Julien Robert <julien@rbrt.fr> Co-authored-by: Alessio Treglia <al@essio.dev> Co-authored-by: Zachary Becker <zrbecker@gmail.com> * Prov: Improve performance of GetAllBalances and GetAccountsBalances. (#616) * Improve performance of GetAllBalances and GetAccountsBalances. * Add changelog entry. * Bring in SDK changes up to v0.50.13 and Mark v0.50.13-pio-1. (#615) * Merge commit from fork * Fix ABS061 * Use typed event * Add changelog * Review feedback * Check for events * Review feedback * Remove unecessary code comments * Set release date * fix changelog --------- Co-authored-by: Alex | Interchain Labs <alex@interchainlabs.io> * Add changelog entry. * Put nothing back at the top of the changelog. --------- Co-authored-by: Alexander Peters <alpe@users.noreply.github.com> Co-authored-by: Alex | Interchain Labs <alex@interchainlabs.io> * Add a bunch of logging. * Revert "Add a bunch of logging." This reverts commit 3baf4d3. * Make the DefaultGasLimit a constant again (back to how the SDK has it). * Add changelog entry. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Julien Robert <julien@rbrt.fr> Co-authored-by: Alessio Treglia <al@essio.dev> Co-authored-by: Zachary Becker <zrbecker@gmail.com> Co-authored-by: Alexander Peters <alpe@users.noreply.github.com> Co-authored-by: Alex | Interchain Labs <alex@interchainlabs.io>
1 parent 6c2a7cf commit 79d1c73

3 files changed

Lines changed: 11 additions & 38 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ Ref: https://keepachangelog.com/en/1.0.0/
3838

3939
## [Unreleased Provenance]
4040

41-
* nothing
41+
### Improvments
42+
43+
* [618](https://github.com/provenance-io/cosmos-sdk/pull/618) Provenance: Remove the fee handler (now using the post handler).
4244

4345
---
4446

baseapp/baseapp.go

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,6 @@ type BaseApp struct {
172172
// trace set will return full stack traces for errors in ABCI Log field
173173
trace bool
174174

175-
feeHandler sdk.FeeHandler
176-
177175
aggregateEventsFunc func(anteEvents []abci.Event, resultEvents []abci.Event) ([]abci.Event, []abci.Event)
178176

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

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

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

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

1003-
feeEvents, err = FeeInvoke(mode, app, runMsgCtx)
1004-
if err != nil {
1005-
return gInfo, nil, nil, ctx, err
1006-
}
1007-
10081006
msCache.Write()
10091007
app.finalizeBlockState.eventHistory = append(app.finalizeBlockState.eventHistory, result.Events...)
10101008
}
@@ -1013,12 +1011,6 @@ func (app *BaseApp) runTxProv(mode execMode, txBytes []byte) (gInfo sdk.GasInfo,
10131011
// append the events in the order of occurrence
10141012
result.Events = append(anteEvents, result.Events...)
10151013
}
1016-
1017-
// additional fee events
1018-
if len(feeEvents) > 0 {
1019-
// append the fee events at the end of the other events, since they get charged at the end of the Tx
1020-
result.Events = append(result.Events, feeEvents.ToABCIEvents()...)
1021-
}
10221014
}
10231015

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

1041-
// FeeInvoke apply fee logic and append events
1042-
func FeeInvoke(mode execMode, app *BaseApp, runMsgCtx sdk.Context) (sdk.Events, error) {
1043-
if app.feeHandler != nil {
1044-
// call the msgFee
1045-
_, eventsFromFeeHandler, err := app.feeHandler(runMsgCtx, mode == execModeSimulate)
1046-
if err != nil {
1047-
return nil, err
1048-
}
1049-
return eventsFromFeeHandler, nil
1050-
}
1051-
return nil, nil
1052-
}
1053-
10541033
// runMsgs iterates through a list of messages and executes them with the provided
10551034
// Context and execution mode. Messages will only be executed during simulation
10561035
// and DeliverTx. An error is returned if any single message fails or if a

baseapp/options.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"math"
77

88
abci "github.com/cometbft/cometbft/abci/types"
9+
910
dbm "github.com/cosmos/cosmos-db"
1011

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

322-
// SetFeeHandler sets the FeeHandler which if set will change the behavior of fee handling
323-
func (app *BaseApp) SetFeeHandler(feeHandler sdk.FeeHandler) {
324-
if app.sealed {
325-
panic("SetFeeHandler() on sealed BaseApp")
326-
}
327-
328-
app.feeHandler = feeHandler
329-
}
330-
331323
// SetAggregateEventsFunc sets the function that aggregates events from baseapp result events and feehandler events
332324
func (app *BaseApp) SetAggregateEventsFunc(aggregateEventsFunc func(resultEvents []abci.Event, feeEvents []abci.Event) ([]abci.Event, []abci.Event)) {
333325
if app.sealed {

0 commit comments

Comments
 (0)