Skip to content

Commit

Permalink
feat: add fee skipping (#1327)
Browse files Browse the repository at this point in the history
# Related Github tickets

- #2466

# Background

This change introduces as custom `TxFeeChecker` implementation, which
simply returns an empty fee for every transaction, as well as a constant
priority.

Merging this change will lead to an equal transaction prioritization
across Paloma, without the option to incentivize validators to include a
transaction in an earlier block.

# Testing completed

- [x] test coverage exists or has been added/updated
- [x] tested in a private testnet

# Breaking changes

- [x] I have checked my code for breaking changes
- [x] If there are breaking changes, there is a supporting migration.
  • Loading branch information
byte-bandit authored Jan 14, 2025
1 parent eb86e9a commit 9091ad7
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,7 @@ func New(
SignModeHandler: txConfig.SignModeHandler(),
FeegrantKeeper: app.FeeGrantKeeper,
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
TxFeeChecker: palomamodule.TxFeeSkipper,
},
)
if err != nil {
Expand Down
7 changes: 7 additions & 0 deletions x/paloma/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,10 @@ func (d VerifyAuthorisedSignatureDecorator) AnteHandle(ctx sdk.Context, tx sdk.T

return next(ctx, tx, simulate)
}

// TxFeeSkipper is a TxFeeChecker that skips fee deduction entirely.
// Every transaction will be considered valid and no fee will be deducted.
// This also means that every transaction will be prioritized equally.
func TxFeeSkipper(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error) {
return sdk.NewCoins(), 42, nil
}
34 changes: 34 additions & 0 deletions x/paloma/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,37 @@ func Test_VerifyAuthorisedSignatureDecorator(t *testing.T) {
})
}
}

func Test_TxFeeSkipper(t *testing.T) {
t.Run("with no msgs in tx", func(t *testing.T) {
ctx := sdk.NewContext(nil, tmproto.Header{}, false, log.NewNopLogger())
tx := &tx{
msgs: []sdk.Msg{
&types.MsgAddStatusUpdate{
Status: "bar",
Level: 0,
Metadata: vtypes.MsgMetadata{
Creator: "foo",
Signers: []string{"foo"},
},
},
},
}
fee, p, err := paloma.TxFeeSkipper(ctx, tx)

require.Equal(t, sdk.Coins{}, fee)
require.True(t, fee.IsZero())
require.Equal(t, int64(42), p)
require.NoError(t, err)
})

t.Run("with nil tx", func(t *testing.T) {
ctx := sdk.NewContext(nil, tmproto.Header{}, false, log.NewNopLogger())
fee, p, err := paloma.TxFeeSkipper(ctx, nil)

require.Equal(t, sdk.Coins{}, fee)
require.True(t, fee.IsZero())
require.Equal(t, int64(42), p)
require.NoError(t, err)
})
}

0 comments on commit 9091ad7

Please sign in to comment.