antewrapper

package
v1.8.0-rc10 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultInsufficientFeeMsg = "not enough fees; after deducting fees required,got"
	SimAppChainID             = "simapp-unit-testing"
)

Variables

View Source
var (
	AttributeKeyBaseFee       = "basefee"
	AttributeKeyAdditionalFee = "additionalfee"
)

Functions

func CalculateAdditionalFeesToBePaid added in v1.8.0

func CalculateAdditionalFeesToBePaid(ctx sdk.Context, mbfk msgfeestypes.MsgFeesKeeper, msgs ...sdk.Msg) (sdk.Coins, error)

CalculateAdditionalFeesToBePaid computes the stability tax on MsgSend and MsgMultiSend.

func DeductFees added in v1.8.0

func DeductFees(bankKeeper types.BankKeeper, ctx sdk.Context, acc types.AccountI, fees sdk.Coins) error

DeductFees deducts fees from the given account.

func EnsureAccountHasSufficientFeesWithAcctBalanceCheck added in v1.8.0

func EnsureAccountHasSufficientFeesWithAcctBalanceCheck(gas uint64, feeCoins sdk.Coins, additionalFees sdk.Coins,
	balancePerCoin sdk.Coins, minGasPriceForAdditionalFeeCalc sdk.Coin) error

func EnsureSufficientFees added in v1.8.0

func EnsureSufficientFees(gas uint64, feeCoins sdk.Coins, additionalFees sdk.Coins,
	minGasPriceForAdditionalFeeCalc sdk.Coin) error

EnsureSufficientFees to be used by msg_service_router

func EnsureSufficientMempoolFees added in v1.8.0

func EnsureSufficientMempoolFees(ctx sdk.Context, gas uint64, feeCoins sdk.Coins, additionalFees sdk.Coins) error

EnsureSufficientMempoolFees verifies that the given transaction has supplied enough fees(gas + additional fees) to cover a proposer's minimum fees. A result object is returned indicating success or failure.

Contract: This should only be called during CheckTx as it cannot be part of consensus.

func NewAnteHandler

func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error)

func NewFeeGasMeterWrapper added in v1.8.0

func NewFeeGasMeterWrapper(logger log.Logger, baseMeter sdkgas.GasMeter, isSimulate bool) sdkgas.GasMeter

NewFeeGasMeterWrapper returns a reference to a new tracing gas meter that will track calls to the base gas meter

Types

type FeeGasMeter added in v1.8.0

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

func (*FeeGasMeter) BaseFeeConsumed added in v1.8.0

func (g *FeeGasMeter) BaseFeeConsumed() sdk.Coins

func (*FeeGasMeter) ConsumeBaseFee added in v1.8.0

func (g *FeeGasMeter) ConsumeBaseFee(amount sdk.Coins) sdk.Coins

func (*FeeGasMeter) ConsumeFee added in v1.8.0

func (g *FeeGasMeter) ConsumeFee(amount sdk.Coin, msgType string)

ConsumeFee increments the amount of msg fee required by a msg type.

func (*FeeGasMeter) ConsumeGas added in v1.8.0

func (g *FeeGasMeter) ConsumeGas(amount sdkgas.Gas, descriptor string)

ConsumeGas increments the amount of gas used on the meter associated with a given purpose.

func (*FeeGasMeter) FeeConsumed added in v1.8.0

func (g *FeeGasMeter) FeeConsumed() sdk.Coins

FeeConsumed returns total fee consumed in the current fee gas meter, is returned Sorted.

func (*FeeGasMeter) FeeConsumedByMsg added in v1.8.0

func (g *FeeGasMeter) FeeConsumedByMsg() map[string]sdk.Coin

FeeConsumedByMsg total fee consumed for a particular MsgType

func (*FeeGasMeter) FeeConsumedForType added in v1.8.0

func (g *FeeGasMeter) FeeConsumedForType(msgType string) sdk.Coin

func (*FeeGasMeter) GasConsumed added in v1.8.0

func (g *FeeGasMeter) GasConsumed() sdkgas.Gas

GasConsumed reports the amount of gas consumed at Log.Info level

func (*FeeGasMeter) GasConsumedToLimit added in v1.8.0

func (g *FeeGasMeter) GasConsumedToLimit() sdkgas.Gas

GasConsumedToLimit will report the actual consumption or the meter limit, whichever is less.

func (*FeeGasMeter) IsOutOfGas added in v1.8.0

func (g *FeeGasMeter) IsOutOfGas() bool

IsOutOfGas indicates the gas meter has tracked consumption at or above the limit

func (*FeeGasMeter) IsPastLimit added in v1.8.0

func (g *FeeGasMeter) IsPastLimit() bool

IsPastLimit indicates consumption has passed the limit (if any)

func (*FeeGasMeter) IsSimulate added in v1.8.0

func (g *FeeGasMeter) IsSimulate() bool

func (*FeeGasMeter) Limit added in v1.8.0

func (g *FeeGasMeter) Limit() sdkgas.Gas

Limit for amount of gas that can be consumed (if zero then unlimited)

func (*FeeGasMeter) RefundGas added in v1.8.0

func (g *FeeGasMeter) RefundGas(amount uint64, descriptor string)

RefundGas refunds an amount of gas

func (*FeeGasMeter) String added in v1.8.0

func (g *FeeGasMeter) String() string

String implements stringer interface

type FeeMeterContextDecorator added in v1.8.0

type FeeMeterContextDecorator struct{}

FeeMeterContextDecorator is an AnteDecorator that wraps the current context gas meter with a msg based fee meter. Also, it merges functionality from GasTracerContextDecorator in previous versions which provided an AnteDecorator that wraps the current context gas meter with one that outputs debug logging and telemetry whenever gas is consumed on the meter.

func NewFeeMeterContextDecorator added in v1.8.0

func NewFeeMeterContextDecorator() FeeMeterContextDecorator

NewFeeMeterContextDecorator creates a new FeeMeterContextDecorator

func (FeeMeterContextDecorator) AnteHandle added in v1.8.0

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

AnteHandle implements the AnteDecorator.AnteHandle method

type HandlerOptions added in v1.8.0

type HandlerOptions struct {
	AccountKeeper   cosmosante.AccountKeeper
	BankKeeper      banktypes.Keeper
	FeegrantKeeper  msgfeestypes.FeegrantKeeper
	MsgFeesKeeper   msgfeestypes.MsgFeesKeeper
	SignModeHandler authsigning.SignModeHandler
	SigGasConsumer  func(meter sdk.GasMeter, sig signing.SignatureV2, params types.Params) error
}

HandlerOptions are the options required for constructing a default SDK AnteHandler.

type MsgFeesDecorator added in v1.8.0

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

MsgFeesDecorator will check if the transaction's fee is at least as large as tax + additional minimum gasFee (defined in msgfeeskeeper) and record additional fee proceeds to msgfees module to track additional fee proceeds. 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 MsgFeesDecorator

func NewMsgFeesDecorator added in v1.8.0

func NewMsgFeesDecorator(bankKeeper banktypes.Keeper, accountKeeper cosmosante.AccountKeeper, feegrantKeeper msgfeestypes.FeegrantKeeper, keeper msgfeestypes.MsgFeesKeeper) MsgFeesDecorator

func (MsgFeesDecorator) AnteHandle added in v1.8.0

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

AnteHandle handles msg fee checking has two functions ensures, 1. has enough fees to add to Mempool (this involves CheckTx) 2. Makes sure enough fees are present for additional message fees Let z be the Total Fees to be paid Let x be the Base gas Fees to be paid Let y is the additional fees to be paid per MsgType then z = x + y This Fee Decorator makes sure that z is >= to x + y

type ProvenanceDeductFeeDecorator added in v1.8.0

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

ProvenanceDeductFeeDecorator 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 ProvenanceDeductFeeDecorator

func (ProvenanceDeductFeeDecorator) AnteHandle added in v1.8.0

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

type TxGasLimitDecorator added in v1.8.0

type TxGasLimitDecorator struct{}

TxGasLimitDecorator will check if the transaction's gas amount is higher than 5% of the maximum gas allowed per block. If gas is too high, decorator returns error and tx is rejected from mempool. If gas is below the limit, then call next AnteHandler CONTRACT: Tx must implement FeeTx to use TxGasLimitDecorator

func NewTxGasLimitDecorator added in v1.8.0

func NewTxGasLimitDecorator() TxGasLimitDecorator

func (TxGasLimitDecorator) AnteHandle added in v1.8.0

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

Jump to

Keyboard shortcuts

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