-
Notifications
You must be signed in to change notification settings - Fork 261
/
ante.go
70 lines (67 loc) · 3.31 KB
/
ante.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package ante
import (
blobante "github.com/celestiaorg/celestia-app/x/blob/ante"
blob "github.com/celestiaorg/celestia-app/x/blob/keeper"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
ibcante "github.com/cosmos/ibc-go/v6/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v6/modules/core/keeper"
)
func NewAnteHandler(
accountKeeper ante.AccountKeeper,
bankKeeper authtypes.BankKeeper,
blobKeeper blob.Keeper,
feegrantKeeper ante.FeegrantKeeper,
signModeHandler signing.SignModeHandler,
sigGasConsumer ante.SignatureVerificationGasConsumer,
channelKeeper *ibckeeper.Keeper,
) sdk.AnteHandler {
return sdk.ChainAnteDecorators(
// Set up the context with a gas meter.
// Contract: must be called first.
ante.NewSetUpContextDecorator(),
// Ensure the tx does not contain any extension options.
ante.NewExtensionOptionsDecorator(nil),
// Ensure the tx passes ValidateBasic.
ante.NewValidateBasicDecorator(),
// Ensure the tx has not reached a height timeout.
ante.NewTxTimeoutHeightDecorator(),
// Ensure the tx memo <= max memo characters.
ante.NewValidateMemoDecorator(accountKeeper),
// Ensure the tx's gas limit is > the gas consumed based on the tx size.
// Side effect: consumes gas from the gas meter.
ante.NewConsumeGasForTxSizeDecorator(accountKeeper),
// Ensure the feepayer (fee granter or first signer) has enough funds to pay for the tx.
// Side effect: deducts fees from the fee payer. Sets the tx priority in context.
ante.NewDeductFeeDecorator(accountKeeper, bankKeeper, feegrantKeeper, checkTxFeeWithValidatorMinGasPrices),
// Set public keys in the context for fee-payer and all signers.
// Contract: must be called before all signature verification decorators.
ante.NewSetPubKeyDecorator(accountKeeper),
// Ensure that the tx's count of signatures is <= the tx signature limit.
ante.NewValidateSigCountDecorator(accountKeeper),
// Ensure that the tx's gas limit is > the gas consumed based on signature verification.
// Side effect: consumes gas from the gas meter.
ante.NewSigGasConsumeDecorator(accountKeeper, sigGasConsumer),
// Ensure that the tx's signatures are valid. For each signature, ensure
// that the signature's sequence number (a.k.a nonce) matches the
// account sequence number of the signer.
// Note: does not consume gas from the gas meter.
ante.NewSigVerificationDecorator(accountKeeper, signModeHandler),
// Ensure that the tx's gas limit is > the gas consumed based on the blob size(s).
// Contract: must be called after all decorators that consume gas.
// Note: does not consume gas from the gas meter.
blobante.NewMinGasPFBDecorator(blobKeeper),
// Ensure that the tx's total blob size is <= the max blob size.
blobante.NewMaxBlobSizeDecorator(blobKeeper),
// Ensure that tx's with a MsgSubmitProposal have atleast one proposal
// message.
NewGovProposalDecorator(),
// Side effect: increment the nonce for all tx signers.
ante.NewIncrementSequenceDecorator(accountKeeper),
// Ensure that the tx is not a IBC packet or update message that has already been processed.
ibcante.NewRedundantRelayDecorator(channelKeeper),
)
}
var DefaultSigVerificationGasConsumer = ante.DefaultSigVerificationGasConsumer