Documentation ¶
Index ¶
- Constants
- func ConsumeMultisignatureVerificationGas(meter gas.Meter, sig *signing.MultiSignatureData, pubKey multisig.PubKey, ...) error
- func CountSubKeys(pub cryptotypes.PubKey) int
- func DeductFees(bankKeeper types.BankKeeper, ctx context.Context, acc []byte, fees sdk.Coins) error
- func DefaultSigVerificationGasConsumer(meter gas.Meter, sig signing.SignatureV2, params types.Params) error
- func GetSignerAcc(ctx context.Context, ak AccountKeeper, addr sdk.AccAddress) sdk.AccountI
- func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error)
- func OnlyLegacyAminoSigners(sigData signing.SignatureData) bool
- func SetGasMeter(ctx sdk.Context, gasLimit uint64) sdk.Context
- func TxIdentifier(timeout uint64, tx sdk.Tx) ([32]byte, error)
- type AccountAbstractionKeeper
- type AccountKeeper
- type ConsensusKeeper
- type ConsumeTxSizeGasDecorator
- type DeductFeeDecorator
- type ExtensionOptionChecker
- type FeegrantKeeper
- type GasTx
- type HandlerOptions
- type HasExtensionOptionsTx
- type RejectExtensionOptionsDecorator
- type SetUpContextDecorator
- type SigVerificationDecorator
- type SignatureVerificationGasConsumer
- type TxFeeChecker
- type TxTimeoutHeightDecorator
- type TxWithTimeoutHeight
- type UnorderedTxDecorator
- type ValidateBasicDecorator
- type ValidateMemoDecorator
- type ValidateSigCountDecorator
Constants ¶
const DefaultSha256Cost = 25
Variables ¶
This section is empty.
Functions ¶
func ConsumeMultisignatureVerificationGas ¶
func ConsumeMultisignatureVerificationGas( meter gas.Meter, sig *signing.MultiSignatureData, pubKey multisig.PubKey, params types.Params, accSeq uint64, ) error
ConsumeMultisignatureVerificationGas consumes gas from a GasMeter for verifying a multisig pubKey signature.
func CountSubKeys ¶ added in v0.40.0
func CountSubKeys(pub cryptotypes.PubKey) int
CountSubKeys counts the total number of keys for a multi-sig public key. A non-multisig, i.e. a regular signature, it naturally a count of 1. If it is a multisig, then it recursively calls it on its pubkeys.
func DeductFees ¶
DeductFees deducts fees from the given account.
func DefaultSigVerificationGasConsumer ¶
func DefaultSigVerificationGasConsumer(meter gas.Meter, sig signing.SignatureV2, params types.Params) error
DefaultSigVerificationGasConsumer is the default implementation of SignatureVerificationGasConsumer. It consumes gas for signature verification based upon the public key type. The cost is fetched from the given params and is matched by the concrete type.
func GetSignerAcc ¶
func GetSignerAcc(ctx context.Context, ak AccountKeeper, addr sdk.AccAddress) sdk.AccountI
GetSignerAcc returns an account for a given address that is expected to sign a transaction.
func NewAnteHandler ¶
func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error)
NewAnteHandler returns an AnteHandler that checks and increments sequence numbers, checks signatures & account numbers, and deducts fees from the first signer.
func OnlyLegacyAminoSigners ¶ added in v0.40.0
func OnlyLegacyAminoSigners(sigData signing.SignatureData) bool
OnlyLegacyAminoSigners checks SignatureData to see if all signers are using SIGN_MODE_LEGACY_AMINO_JSON. If this is the case then the corresponding SignatureV2 struct will not have account sequence explicitly set, and we should skip the explicit verification of sig.Sequence in the SigVerificationDecorator's AnteHandler function.
func SetGasMeter ¶
SetGasMeter returns a new context with a gas meter set from a given context.
Types ¶
type AccountKeeper ¶
type AccountKeeper interface { GetParams(ctx context.Context) (params types.Params) GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI SetAccount(ctx context.Context, acc sdk.AccountI) GetModuleAddress(moduleName string) sdk.AccAddress NewAccountWithAddress(ctx context.Context, addr sdk.AccAddress) sdk.AccountI AddressCodec() address.Codec GetEnvironment() appmodule.Environment }
AccountKeeper defines the contract needed for AccountKeeper related APIs. Interface provides support to use non-sdk AccountKeeper for AnteHandler's decorators.
type ConsensusKeeper ¶
type ConsumeTxSizeGasDecorator ¶
type ConsumeTxSizeGasDecorator struct {
// contains filtered or unexported fields
}
ConsumeTxSizeGasDecorator will take in parameters and consume gas proportional to the size of tx before calling next AnteHandler. Note, the gas costs will be slightly over estimated due to the fact that any given signing account may need to be retrieved from state.
CONTRACT: If exec mode = simulate, then signatures must either be completely filled in or empty. CONTRACT: To use this decorator, signatures of transaction must be represented as legacytx.StdSignature otherwise simulate mode will incorrectly estimate gas cost.
func NewConsumeGasForTxSizeDecorator ¶
func NewConsumeGasForTxSizeDecorator(ak AccountKeeper) ConsumeTxSizeGasDecorator
func (ConsumeTxSizeGasDecorator) AnteHandle ¶
func (cgts ConsumeTxSizeGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool, next sdk.AnteHandler) (newCtx sdk.Context, err error)
AnteHandle implements an AnteHandler decorator for the ConsumeTxSizeGasDecorator.
func (ConsumeTxSizeGasDecorator) ValidateTx ¶
ValidateTx implements an TxValidator for ConsumeTxSizeGasDecorator
type DeductFeeDecorator ¶
type DeductFeeDecorator struct {
// contains filtered or unexported fields
}
DeductFeeDecorator deducts fees from the fee payer. The fee payer is the fee granter (if specified) or first signer of the tx. If the fee payer does not have the funds to pay for the fees, return an InsufficientFunds error. Call next AnteHandler if fees are successfully deducted. CONTRACT: The Tx must implement the FeeTx interface to use DeductFeeDecorator.
func NewDeductFeeDecorator ¶
func NewDeductFeeDecorator(ak AccountKeeper, bk types.BankKeeper, fk FeegrantKeeper, tfc TxFeeChecker) *DeductFeeDecorator
func (*DeductFeeDecorator) AnteHandle ¶
func (dfd *DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool, next sdk.AnteHandler) (sdk.Context, error)
AnteHandle implements an AnteHandler decorator for the DeductFeeDecorator
func (*DeductFeeDecorator) SetMinGasPrices ¶
func (dfd *DeductFeeDecorator) SetMinGasPrices(minGasPrices sdk.DecCoins)
SetMinGasPrices sets the minimum-gas-prices value in the state of DeductFeeDecorator
func (*DeductFeeDecorator) ValidateTx ¶
func (dfd *DeductFeeDecorator) ValidateTx(ctx context.Context, tx transaction.Tx) error
ValidateTx implements an TxValidator for DeductFeeDecorator Note: This method is applicable only for transactions that implement the sdk.FeeTx interface.
type ExtensionOptionChecker ¶ added in v0.46.0
type ExtensionOptionChecker func(*codectypes.Any) bool
ExtensionOptionChecker is a function that returns true if the extension option is accepted.
type FeegrantKeeper ¶ added in v0.43.0
type FeegrantKeeper interface {
UseGrantedFees(ctx context.Context, granter, grantee sdk.AccAddress, fee sdk.Coins, msgs []sdk.Msg) error
}
FeegrantKeeper defines the expected feegrant keeper.
type HandlerOptions ¶ added in v0.43.0
type HandlerOptions struct { Environment appmodule.Environment AccountKeeper AccountKeeper AccountAbstractionKeeper AccountAbstractionKeeper BankKeeper types.BankKeeper ConsensusKeeper ConsensusKeeper ExtensionOptionChecker ExtensionOptionChecker FeegrantKeeper FeegrantKeeper SignModeHandler *txsigning.HandlerMap SigGasConsumer func(meter gas.Meter, sig signing.SignatureV2, params types.Params) error TxFeeChecker TxFeeChecker UnorderedTxManager *unorderedtx.Manager }
HandlerOptions are the options required for constructing a default SDK AnteHandler.
type HasExtensionOptionsTx ¶ added in v0.40.0
type HasExtensionOptionsTx interface { GetExtensionOptions() []*codectypes.Any GetNonCriticalExtensionOptions() []*codectypes.Any }
type RejectExtensionOptionsDecorator ¶ added in v0.40.0
type RejectExtensionOptionsDecorator struct {
// contains filtered or unexported fields
}
RejectExtensionOptionsDecorator is an AnteDecorator that rejects all extension options which can optionally be included in protobuf transactions. Users that need extension options should create a custom AnteHandler chain that handles needed extension options properly and rejects unknown ones.
func NewExtensionOptionsDecorator ¶ added in v0.46.0
func NewExtensionOptionsDecorator(checker ExtensionOptionChecker) RejectExtensionOptionsDecorator
NewExtensionOptionsDecorator creates a new antehandler that rejects all extension options which can optionally be included in protobuf transactions that don't pass the checker. Users that need extension options should pass a custom checker that returns true for the needed extension options.
func (RejectExtensionOptionsDecorator) AnteHandle ¶ added in v0.40.0
func (r RejectExtensionOptionsDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool, next sdk.AnteHandler) (newCtx sdk.Context, err error)
AnteHandle implements the AnteDecorator.AnteHandle method
func (RejectExtensionOptionsDecorator) ValidateTx ¶
type SetUpContextDecorator ¶
type SetUpContextDecorator struct {
// contains filtered or unexported fields
}
SetUpContextDecorator sets the GasMeter in the Context and wraps the next AnteHandler with a defer clause to recover from any downstream OutOfGas panics in the AnteHandler chain to return an error with information on gas provided and gas used. CONTRACT: Must be first decorator in the chain CONTRACT: Tx must implement GasTx interface
func NewSetUpContextDecorator ¶
func NewSetUpContextDecorator(env appmodule.Environment, consensusKeeper ConsensusKeeper) SetUpContextDecorator
func (SetUpContextDecorator) AnteHandle ¶
type SigVerificationDecorator ¶
type SigVerificationDecorator struct {
// contains filtered or unexported fields
}
SigVerificationDecorator verifies all signatures for a tx and returns an error if any are invalid. It will populate an account's public key if that is not present only if PubKey.Address() == Account.Address(). Note, the SigVerificationDecorator will not check signatures on ReCheckTx. It will also increase the sequence number, and consume gas for signature verification.
In cases where unordered or parallel transactions are desired, it is recommended to set unordered=true with a reasonable timeout_height value, in which case this nonce verification and increment will be skipped.
CONTRACT: Tx must implement SigVerifiableTx interface
func NewSigVerificationDecorator ¶
func NewSigVerificationDecorator(ak AccountKeeper, signModeHandler *txsigning.HandlerMap, sigGasConsumer SignatureVerificationGasConsumer, aaKeeper AccountAbstractionKeeper) SigVerificationDecorator
func (SigVerificationDecorator) AnteHandle ¶
func (SigVerificationDecorator) ValidateTx ¶
func (svd SigVerificationDecorator) ValidateTx(ctx context.Context, tx transaction.Tx) error
type SignatureVerificationGasConsumer ¶
type SignatureVerificationGasConsumer = func(meter gas.Meter, sig signing.SignatureV2, params types.Params) error
SignatureVerificationGasConsumer is the type of function that is used to both consume gas when verifying signatures and also to accept or reject different types of pubkeys This is where apps can define their own PubKey
type TxFeeChecker ¶ added in v0.46.0
TxFeeChecker checks if the provided fee is enough and returns the effective fee and tx priority. The effective fee should be deducted later, and the priority should be returned in the ABCI response.
type TxTimeoutHeightDecorator ¶ added in v0.40.0
type TxTimeoutHeightDecorator struct {
// contains filtered or unexported fields
}
TxTimeoutHeightDecorator defines an AnteHandler decorator that checks for a tx height timeout.
func NewTxTimeoutHeightDecorator ¶ added in v0.43.0
func NewTxTimeoutHeightDecorator(env appmodulev2.Environment) TxTimeoutHeightDecorator
TxTimeoutHeightDecorator defines an AnteHandler decorator that checks for a tx height timeout.
func (TxTimeoutHeightDecorator) AnteHandle ¶ added in v0.40.0
func (txh TxTimeoutHeightDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool, next sdk.AnteHandler) (newCtx sdk.Context, err error)
AnteHandle implements an AnteHandler decorator for the TxHeightTimeoutDecorator.
func (TxTimeoutHeightDecorator) ValidateTx ¶
ValidateTx implements an TxValidator for the TxHeightTimeoutDecorator type where the current block height is checked against the tx's height timeout. If a height timeout is provided (non-zero) and is less than the current block height, then an error is returned.
type TxWithTimeoutHeight ¶ added in v0.40.0
type TxWithTimeoutHeight interface { sdk.Tx GetTimeoutHeight() uint64 GetTimeoutTimeStamp() time.Time }
TxWithTimeoutHeight defines the interface a tx must implement in order for TxTimeoutHeightDecorator to process the tx.
type UnorderedTxDecorator ¶
type UnorderedTxDecorator struct {
// contains filtered or unexported fields
}
UnorderedTxDecorator defines an AnteHandler decorator that is responsible for checking if a transaction is intended to be unordered and if so, evaluates the transaction accordingly. An unordered transaction will bypass having it's nonce incremented, which allows fire-and-forget along with possible parallel transaction processing, without having to deal with nonces.
The transaction sender must ensure that unordered=true and a timeout_height is appropriately set. The AnteHandler will check that the transaction is not a duplicate and will evict it from memory when the timeout is reached.
The UnorderedTxDecorator should be placed as early as possible in the AnteHandler chain to ensure that during DeliverTx, the transaction is added to the UnorderedTxManager.
func NewUnorderedTxDecorator ¶
func NewUnorderedTxDecorator( maxDuration time.Duration, m *unorderedtx.Manager, env appmodulev2.Environment, gasCost uint64, ) *UnorderedTxDecorator
func (*UnorderedTxDecorator) AnteHandle ¶
func (*UnorderedTxDecorator) ValidateTx ¶
func (d *UnorderedTxDecorator) ValidateTx(ctx context.Context, tx transaction.Tx) error
type ValidateBasicDecorator ¶
type ValidateBasicDecorator struct {
// contains filtered or unexported fields
}
ValidateBasicDecorator will call tx.ValidateBasic and return any non-nil error. If ValidateBasic passes, decorator calls next AnteHandler in chain. Note, ValidateBasicDecorator decorator will not get executed on ReCheckTx since it is not dependent on application state.
func NewValidateBasicDecorator ¶
func NewValidateBasicDecorator(env appmodulev2.Environment) ValidateBasicDecorator
func (ValidateBasicDecorator) AnteHandle ¶
func (vbd ValidateBasicDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool, next sdk.AnteHandler) (newCtx sdk.Context, err error)
AnteHandle implements an AnteHandler decorator for the ValidateBasicDecorator.
func (ValidateBasicDecorator) ValidateTx ¶
ValidateTx implements an TxValidator for ValidateBasicDecorator
type ValidateMemoDecorator ¶
type ValidateMemoDecorator struct {
// contains filtered or unexported fields
}
ValidateMemoDecorator will validate memo given the parameters passed in If memo is too large decorator returns with error, otherwise call next AnteHandler CONTRACT: Tx must implement TxWithMemo interface
func NewValidateMemoDecorator ¶
func NewValidateMemoDecorator(ak AccountKeeper) ValidateMemoDecorator
func (ValidateMemoDecorator) AnteHandle ¶
func (vmd ValidateMemoDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool, next sdk.AnteHandler) (newCtx sdk.Context, err error)
AnteHandle implements an AnteHandler decorator for the ValidateMemoDecorator.
func (ValidateMemoDecorator) ValidateTx ¶
ValidateTx implements an TxValidator for ValidateMemoDecorator
type ValidateSigCountDecorator ¶
type ValidateSigCountDecorator struct {
// contains filtered or unexported fields
}
ValidateSigCountDecorator takes in Params and returns errors if there are too many signatures in the tx for the given params otherwise it calls next AnteHandler Use this decorator to set parameterized limit on number of signatures in tx CONTRACT: Tx must implement SigVerifiableTx interface
func NewValidateSigCountDecorator ¶
func NewValidateSigCountDecorator(ak AccountKeeper) ValidateSigCountDecorator
func (ValidateSigCountDecorator) AnteHandle ¶
func (vscd ValidateSigCountDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool, next sdk.AnteHandler) (newCtx sdk.Context, err error)
AnteHandle implements an ante decorator for ValidateSigCountDecorator
func (ValidateSigCountDecorator) ValidateTx ¶
ValidateTx implements an TxValidator for ValidateSigCountDecorator
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package testutil is a generated GoMock package.
|
Package testutil is a generated GoMock package. |