ante

package
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package ante defines the SDK auth module's AnteHandler as well as an internal AnteHandler for an Ethereum transaction (i.e MsgEthereumTx).

During CheckTx, the transaction is passed through a series of pre-message execution validation checks such as signature and account verification in addition to minimum fees being checked. Otherwise, during DeliverTx, the transaction is simply passed to the EVM which will also perform the same series of checks. The distinction is made in CheckTx to prevent spam and DoS attacks.

Index

Constants

View Source
const (
	// Default ante codespace
	DefaultRootCodespace string = "ante"

	CodeFeePayerAddressDoesNotExist    CodeType = 101
	CodeFeeLessThanCommission          CodeType = 102
	CodeFailedToSendCoins              CodeType = 103
	CodeInsufficientFundsToPayFee      CodeType = 104
	CodeInvalidFeeAmount               CodeType = 105
	CodeCoinDoesNotExist               CodeType = 106
	CodeNotStdTxType                   CodeType = 107
	CodeNotFeeTxType                   CodeType = 108
	CodeOutOfGas                       CodeType = 109
	CodeNotGasTxType                   CodeType = 110
	CodeInvalidAddressOfCreatedAccount CodeType = 111
	CodeUnableToFindCreatedAccount     CodeType = 112
	CodeUnknownTransaction             CodeType = 113
	CodeCoinReserveInsufficient        CodeType = 114
	CodeCoinReserveBecomeInsufficient  CodeType = 115
	CodeCoinVolumeBecomeInsufficient   CodeType = 116
)
View Source
const (
	GasCommissionDesc = "commission"
)

Gas consumption descriptors.

Variables

This section is empty.

Functions

func CalculateFee

func CalculateFee(msgs []sdk.Msg, txBytesLen int64, factor sdk.Dec) (sdk.Int, error)

Calculate fee in base coin

func DeductFees

func DeductFees(ctx sdk.Context, bankKeeper evmTypes.BankKeeper, coinKeeper coinTypes.CoinKeeper,
	feePayerAddress sdk.AccAddress, fee sdk.Coin) error

DeductFees deducts fees from the given account.

func ErrCoinDoesNotExist

func ErrCoinDoesNotExist(feeDenom string) *sdkerrors.Error

func ErrCoinReserveBecomeInsufficient

func ErrCoinReserveBecomeInsufficient(reserve, decreasing, minReserve string) *sdkerrors.Error

func ErrCoinReserveInsufficient

func ErrCoinReserveInsufficient(reserve, commission string) *sdkerrors.Error

func ErrCoinVolumeBecomeInsufficient

func ErrCoinVolumeBecomeInsufficient(volume, decreasing, minVolume string) *sdkerrors.Error

func ErrFailedToSendCoins

func ErrFailedToSendCoins(err string) *sdkerrors.Error

func ErrFeeLessThanCommission

func ErrFeeLessThanCommission(feeInBaseCoin, commissionInBaseCoin string) *sdkerrors.Error

func ErrFeePayerAddressDoesNotExist

func ErrFeePayerAddressDoesNotExist(feePayer string) *sdkerrors.Error

func ErrInsufficientFundsToPayFee

func ErrInsufficientFundsToPayFee(coins, fee string) *sdkerrors.Error

func ErrInvalidAddressOfCreatedAccount

func ErrInvalidAddressOfCreatedAccount() *sdkerrors.Error

func ErrInvalidFeeAmount

func ErrInvalidFeeAmount(fee string) *sdkerrors.Error

func ErrNotFeeTxType

func ErrNotFeeTxType() *sdkerrors.Error

func ErrNotGasTxType

func ErrNotGasTxType() *sdkerrors.Error

func ErrNotStdTxType

func ErrNotStdTxType() *sdkerrors.Error

func ErrOutOfGas

func ErrOutOfGas(location, gasWanted, gasUsed string) *sdkerrors.Error

func ErrUnableToFindCreatedAccount

func ErrUnableToFindCreatedAccount() *sdkerrors.Error

func ErrUnknownTransaction

func ErrUnknownTransaction(txType string) *sdkerrors.Error

func NewAnteHandler

func NewAnteHandler(options HandlerOptions) sdk.AnteHandler

NewAnteHandler returns an ante handler responsible for attempting to route an Ethereum or SDK transaction to an internal ante handler for performing transaction-level processing (e.g. fee payment, signature verification) before being passed onto it's respective handler.

func NewCommissionGasMeter

func NewCommissionGasMeter(limit sdk.Gas) sdk.GasMeter

func SetGasMeter

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.

Types

type CodeType

type CodeType = uint32

Local code type

type FeeDecorator

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

func NewFeeDecorator

NewFeeDecorator creates new FeeDecorator to deduct fee

func (FeeDecorator) AnteHandle

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

AnteHandle implements sdk.AnteHandler function.

type HandlerOptions

type HandlerOptions struct {
	AccountKeeper evmtypes.AccountKeeper
	BankKeeper    evmtypes.BankKeeper
	//IBCKeeper       *ibckeeper.Keeper
	FeeMarketKeeper evmtypes.FeeMarketKeeper
	EvmKeeper       evmante.EVMKeeper
	FeegrantKeeper  authante.FeegrantKeeper
	CoinKeeper      cointypes.CoinKeeper
	SignModeHandler authsigning.SignModeHandler
	SigGasConsumer  func(meter sdk.GasMeter, sig signing.SignatureV2, params authtypes.Params) error
	Cdc             codec.BinaryCodec
	MaxTxGasWanted  uint64
}

HandlerOptions defines the list of module keepers required to run the Decimal AnteHandler decorators.

func (HandlerOptions) Validate

func (options HandlerOptions) Validate() error

Validate checks if the keepers are defined

type SetUpContextDecorator

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

func NewSetUpContextDecorator() SetUpContextDecorator

func (SetUpContextDecorator) AnteHandle

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

type ValidatorCommissionDecorator

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

ValidatorCommissionDecorator validates that the validator commission is always greater or equal than the min commission rate

func NewValidatorCommissionDecorator

func NewValidatorCommissionDecorator(cdc codec.BinaryCodec) ValidatorCommissionDecorator

NewValidatorCommissionDecorator creates a new NewValidatorCommissionDecorator

func (ValidatorCommissionDecorator) AnteHandle

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

AnteHandle checks if the tx contains a staking create validator or edit validator. It errors if the the commission rate is below the min threshold.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL