cosmos-sdk: github.com/cosmos/cosmos-sdk/x/auth/ante Index | Files

package ante

import "github.com/cosmos/cosmos-sdk/x/auth/ante"

Index

Package Files

ante.go basic.go fee.go setup.go sigverify.go

func DeductFees Uses

func DeductFees(supplyKeeper types.SupplyKeeper, ctx sdk.Context, acc exported.Account, fees sdk.Coins) error

DeductFees deducts fees from the given account.

NOTE: We could use the BankKeeper (in addition to the AccountKeeper, because the BankKeeper doesn't give us accounts), but it seems easier to do this.

func DefaultSigVerificationGasConsumer Uses

func DefaultSigVerificationGasConsumer(
    meter sdk.GasMeter, sig []byte, pubkey crypto.PubKey, 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 Uses

func GetSignerAcc(ctx sdk.Context, ak keeper.AccountKeeper, addr sdk.AccAddress) (exported.Account, error)

GetSignerAcc returns an account for a given address that is expected to sign a transaction.

func NewAnteHandler Uses

func NewAnteHandler(ak keeper.AccountKeeper, supplyKeeper types.SupplyKeeper, sigGasConsumer SignatureVerificationGasConsumer) sdk.AnteHandler

NewAnteHandler returns an AnteHandler that checks and increments sequence numbers, checks signatures & account numbers, and deducts fees from the first signer.

func SetGasMeter Uses

func SetGasMeter(simulate bool, ctx sdk.Context, gasLimit uint64) sdk.Context

SetGasMeter returns a new context with a gas meter set from a given context.

type ConsumeTxSizeGasDecorator Uses

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 simulate=true, then signatures must either be completely filled in or empty. CONTRACT: To use this decorator, signatures of transaction must be represented as types.StdSignature otherwise simulate mode will incorrectly estimate gas cost.

func NewConsumeGasForTxSizeDecorator Uses

func NewConsumeGasForTxSizeDecorator(ak keeper.AccountKeeper) ConsumeTxSizeGasDecorator

func (ConsumeTxSizeGasDecorator) AnteHandle Uses

func (cgts ConsumeTxSizeGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error)

type DeductFeeDecorator Uses

type DeductFeeDecorator struct {
    // contains filtered or unexported fields
}

DeductFeeDecorator deducts fees from the first signer of the tx If the first signer does not have the funds to pay for the fees, return with InsufficientFunds error Call next AnteHandler if fees successfully deducted CONTRACT: Tx must implement FeeTx interface to use DeductFeeDecorator

func NewDeductFeeDecorator Uses

func NewDeductFeeDecorator(ak keeper.AccountKeeper, sk types.SupplyKeeper) DeductFeeDecorator

func (DeductFeeDecorator) AnteHandle Uses

func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error)

type FeeTx Uses

type FeeTx interface {
    sdk.Tx
    GetGas() uint64
    GetFee() sdk.Coins
    FeePayer() sdk.AccAddress
}

FeeTx defines the interface to be implemented by Tx to use the FeeDecorators

type GasTx Uses

type GasTx interface {
    sdk.Tx
    GetGas() uint64
}

GasTx defines a Tx with a GetGas() method which is needed to use SetUpContextDecorator

type IncrementSequenceDecorator Uses

type IncrementSequenceDecorator struct {
    // contains filtered or unexported fields
}

IncrementSequenceDecorator handles incrementing sequences of all signers. Use the IncrementSequenceDecorator decorator to prevent replay attacks. Note, there is no need to execute IncrementSequenceDecorator on CheckTx or RecheckTX since it is merely updating the nonce. As a result, this has the side effect that subsequent and sequential txs orginating from the same account cannot be handled correctly in a reliable way. To send sequential txs orginating from the same account, it is recommended to instead use multiple messages in a tx.

CONTRACT: The tx must implement the SigVerifiableTx interface.

func NewIncrementSequenceDecorator Uses

func NewIncrementSequenceDecorator(ak keeper.AccountKeeper) IncrementSequenceDecorator

func (IncrementSequenceDecorator) AnteHandle Uses

func (isd IncrementSequenceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error)

type MempoolFeeDecorator Uses

type MempoolFeeDecorator struct{}

MempoolFeeDecorator will check if the transaction's fee is at least as large as the local validator's minimum gasFee (defined in validator config). If fee is too low, decorator returns error and tx is rejected from mempool. Note this only applies when ctx.CheckTx = true If fee is high enough or not CheckTx, then call next AnteHandler CONTRACT: Tx must implement FeeTx to use MempoolFeeDecorator

func NewMempoolFeeDecorator Uses

func NewMempoolFeeDecorator() MempoolFeeDecorator

func (MempoolFeeDecorator) AnteHandle Uses

func (mfd MempoolFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error)

type SetPubKeyDecorator Uses

type SetPubKeyDecorator struct {
    // contains filtered or unexported fields
}

SetPubKeyDecorator sets PubKeys in context for any signer which does not already have pubkey set PubKeys must be set in context for all signers before any other sigverify decorators run CONTRACT: Tx must implement SigVerifiableTx interface

func NewSetPubKeyDecorator Uses

func NewSetPubKeyDecorator(ak keeper.AccountKeeper) SetPubKeyDecorator

func (SetPubKeyDecorator) AnteHandle Uses

func (spkd SetPubKeyDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error)

type SetUpContextDecorator Uses

type SetUpContextDecorator struct{}

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 Uses

func NewSetUpContextDecorator() SetUpContextDecorator

func (SetUpContextDecorator) AnteHandle Uses

func (sud SetUpContextDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error)

type SigGasConsumeDecorator Uses

type SigGasConsumeDecorator struct {
    // contains filtered or unexported fields
}

Consume parameter-defined amount of gas for each signature according to the passed-in SignatureVerificationGasConsumer function before calling the next AnteHandler CONTRACT: Pubkeys are set in context for all signers before this decorator runs CONTRACT: Tx must implement SigVerifiableTx interface

func NewSigGasConsumeDecorator Uses

func NewSigGasConsumeDecorator(ak keeper.AccountKeeper, sigGasConsumer SignatureVerificationGasConsumer) SigGasConsumeDecorator

func (SigGasConsumeDecorator) AnteHandle Uses

func (sgcd SigGasConsumeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error)

type SigVerifiableTx Uses

type SigVerifiableTx interface {
    sdk.Tx
    GetSignatures() [][]byte
    GetSigners() []sdk.AccAddress
    GetPubKeys() []crypto.PubKey // If signer already has pubkey in context, this list will have nil in its place
    GetSignBytes(ctx sdk.Context, acc exported.Account) []byte
}

SigVerifiableTx defines a Tx interface for all signature verification decorators

type SigVerificationDecorator Uses

type SigVerificationDecorator struct {
    // contains filtered or unexported fields
}

Verify all signatures for a tx and return an error if any are invalid. Note, the SigVerificationDecorator decorator will not get executed on ReCheck.

CONTRACT: Pubkeys are set in context for all signers before this decorator runs CONTRACT: Tx must implement SigVerifiableTx interface

func NewSigVerificationDecorator Uses

func NewSigVerificationDecorator(ak keeper.AccountKeeper) SigVerificationDecorator

func (SigVerificationDecorator) AnteHandle Uses

func (svd SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error)

type SignatureVerificationGasConsumer Uses

type SignatureVerificationGasConsumer = func(meter sdk.GasMeter, sig []byte, pubkey crypto.PubKey, 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 TxWithMemo Uses

type TxWithMemo interface {
    sdk.Tx
    GetMemo() string
}

Tx must have GetMemo() method to use ValidateMemoDecorator

type ValidateBasicDecorator Uses

type ValidateBasicDecorator struct{}

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 Uses

func NewValidateBasicDecorator() ValidateBasicDecorator

func (ValidateBasicDecorator) AnteHandle Uses

func (vbd ValidateBasicDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error)

type ValidateMemoDecorator Uses

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 Uses

func NewValidateMemoDecorator(ak keeper.AccountKeeper) ValidateMemoDecorator

func (ValidateMemoDecorator) AnteHandle Uses

func (vmd ValidateMemoDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error)

type ValidateSigCountDecorator Uses

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 Uses

func NewValidateSigCountDecorator(ak keeper.AccountKeeper) ValidateSigCountDecorator

func (ValidateSigCountDecorator) AnteHandle Uses

func (vscd ValidateSigCountDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error)

Package ante imports 13 packages (graph) and is imported by 2 packages. Updated 2019-12-11. Refresh now. Tools for package owners.