ante

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2023 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const MaxOracleMsgGasUsage = uint64(100_000)

MaxOracleMsgGasUsage is constant expected oracle msg gas cost

View Source
const TaxPowerUpgradeHeight = 9346889

TaxPowerUpgradeHeight is when taxes are allowed to go into effect This will still need a parameter change proposal, but can be activated anytime after this height

Variables

This section is empty.

Functions

func ConsumeMultisignatureVerificationGas

func ConsumeMultisignatureVerificationGas(
	meter sdk.GasMeter, 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

func CountSubKeys(pub cryptotypes.PubKey) int

CountSubKeys counts the total number of keys for a multi-sig public key.

func DefaultSigVerificationGasConsumer

func DefaultSigVerificationGasConsumer(
	meter sdk.GasMeter, 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 EnsureSufficientMempoolFees

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

EnsureSufficientMempoolFees verifies that the given transaction has supplied enough fees(gas + stability) 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 FilterMsgAndComputeTax

func FilterMsgAndComputeTax(ctx sdk.Context, tk TreasuryKeeper, msgs ...sdk.Msg) sdk.Coins

FilterMsgAndComputeTax computes the stability tax on MsgSend and MsgMultiSend.

func GetSignerAcc

func GetSignerAcc(ctx sdk.Context, ak cosmosante.AccountKeeper, addr sdk.AccAddress) (types.AccountI, error)

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

func HandleCheckMinInitialDeposit added in v1.2.0

func HandleCheckMinInitialDeposit(ctx sdk.Context, msg sdk.Msg, govKeeper govkeeper.Keeper, treasuryKeeper TreasuryKeeper) (err error)

HandleCheckMinInitialDeposit

func IsMsgSubmitProposal added in v1.2.0

func IsMsgSubmitProposal(msg sdk.Msg) bool

IsMsgSubmitProposal checks whether the input msg is a MsgSubmitProposal

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

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.

Types

type BankKeeper

type BankKeeper interface {
	SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
	SendCoinsFromModuleToModule(ctx sdk.Context, senderModule string, recipientModule string, amt sdk.Coins) error
}

BankKeeper defines the contract needed for supply related APIs (noalias)

type BurnTaxFeeDecorator

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

BurnTaxFeeDecorator will immediately burn the collected Tax

func NewBurnTaxFeeDecorator

func NewBurnTaxFeeDecorator(accountKeeper cosmosante.AccountKeeper, treasuryKeeper TreasuryKeeper, bankKeeper BankKeeper, distrKeeper DistrKeeper) BurnTaxFeeDecorator

NewBurnTaxFeeDecorator returns new tax fee decorator instance

func (BurnTaxFeeDecorator) AnteHandle

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

AnteHandle handles msg tax fee checking

type DistrKeeper

type DistrKeeper interface {
	FundCommunityPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error
	GetFeePool(ctx sdk.Context) distributiontypes.FeePool
}

type GovKeeper added in v1.2.0

type GovKeeper interface {
	GetDepositParams(ctx sdk.Context) govtypes.DepositParams
}

type HandlerOptions

type HandlerOptions struct {
	AccountKeeper      cosmosante.AccountKeeper
	BankKeeper         BankKeeper
	FeegrantKeeper     cosmosante.FeegrantKeeper
	OracleKeeper       OracleKeeper
	TreasuryKeeper     TreasuryKeeper
	SignModeHandler    signing.SignModeHandler
	SigGasConsumer     cosmosante.SignatureVerificationGasConsumer
	IBCChannelKeeper   channelkeeper.Keeper
	DistributionKeeper distributionkeeper.Keeper
	GovKeeper          govkeeper.Keeper
}

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

type IncrementSequenceDecorator

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 RecheckTX since CheckTx would already bump the sequence number.

NOTE: Since CheckTx and DeliverTx state are managed separately, subsequent and sequential txs orginating from the same account cannot be handled correctly in a reliable way unless sequence numbers are managed and tracked manually by a client. It is recommended to instead use multiple messages in a tx.

func (IncrementSequenceDecorator) AnteHandle

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

type MinInitialDepositDecorator added in v1.2.0

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

MinInitialDeposit Decorator will check Initial Deposits for MsgSubmitProposal

func NewMinInitialDepositDecorator added in v1.2.0

func NewMinInitialDepositDecorator(govKeeper govkeeper.Keeper, treasuryKeeper TreasuryKeeper) MinInitialDepositDecorator

NewMinInitialDeposit returns new min initial deposit decorator instance

func (MinInitialDepositDecorator) AnteHandle added in v1.2.0

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

AnteHandle handles checking MsgSubmitProposal

type OracleKeeper

type OracleKeeper interface {
	ValidateFeeder(ctx sdk.Context, feederAddr sdk.AccAddress, validatorAddr sdk.ValAddress) error
}

OracleKeeper for feeder validation

type SetPubKeyDecorator

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 (SetPubKeyDecorator) AnteHandle

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

type SigGasConsumeDecorator

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 (SigGasConsumeDecorator) AnteHandle

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

type SigVerificationDecorator

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 will not check signatures on ReCheck.

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

func (SigVerificationDecorator) AnteHandle

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

type SignatureVerificationGasConsumer

type SignatureVerificationGasConsumer = func(meter sdk.GasMeter, 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 SpammingPreventionDecorator

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

SpammingPreventionDecorator will check if the transaction's gas is smaller than configured hard cap

func NewSpammingPreventionDecorator

func NewSpammingPreventionDecorator(oracleKeeper OracleKeeper) SpammingPreventionDecorator

NewSpammingPreventionDecorator returns new spamming prevention decorator instance

func (SpammingPreventionDecorator) AnteHandle

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

AnteHandle handles msg tax fee checking

func (SpammingPreventionDecorator) CheckOracleSpamming

func (spd SpammingPreventionDecorator) CheckOracleSpamming(ctx sdk.Context, msgs []sdk.Msg) error

CheckOracleSpamming check whether the msgs are spamming purpose or not

type TaxFeeDecorator

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

TaxFeeDecorator will check if the transaction's fee is at least as large as tax + the local validator's minimum gasFee (defined in validator config) and record tax proceeds to treasury module to track tax 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 MempoolFeeDecorator

func NewTaxFeeDecorator

func NewTaxFeeDecorator(treasuryKeeper TreasuryKeeper) TaxFeeDecorator

NewTaxFeeDecorator returns new tax fee decorator instance

func (TaxFeeDecorator) AnteHandle

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

AnteHandle handles msg tax fee checking

type TreasuryKeeper

type TreasuryKeeper interface {
	RecordEpochTaxProceeds(ctx sdk.Context, delta sdk.Coins)
	GetTaxRate(ctx sdk.Context) (taxRate sdk.Dec)
	GetTaxCap(ctx sdk.Context, denom string) (taxCap sdk.Int)
	GetBurnSplitRate(ctx sdk.Context) sdk.Dec
	HasBurnTaxExemptionAddress(ctx sdk.Context, addresses ...string) bool
	GetMinInitialDepositRatio(ctx sdk.Context) sdk.Dec
}

TreasuryKeeper for tax charging & recording

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 (ValidateSigCountDecorator) AnteHandle

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

Jump to

Keyboard shortcuts

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