ante

package
v0.4.0-rc11 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const MaxMsgGasUsage = uint64(140_000)

MaxMsgGasUsage defines the maximum gas allowed for an oracle transaction.

Variables

This section is empty.

Functions

func AssertMinProtocolGasPrice

func AssertMinProtocolGasPrice(gasPrices sdk.DecCoins) error

AssertMinProtocolGasPrice returns an error if the provided gasPrices are lower then the required by protocol.

func FeeAndPriority

func FeeAndPriority(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error)

FeeAndPriority ensures tx has enough fee coins to pay for the gas at the CheckTx time to early remove transactions from the mempool without enough attached fee. The validator min fee check is ignored if the tx contains only oracle messages and tx gas limit is <= MaxMsgGasUsage. Essentially, validators can provide price transactison for free as long as the gas per message is in the MaxMsgGasUsage limit.

func IsOracleTx

func IsOracleTx(msgs []sdk.Msg) bool

IsOracleTx checks if all messages are oracle messages

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.

Types

type HandlerOptions

type HandlerOptions struct {
	AccountKeeper     cosmosante.AccountKeeper
	BankKeeper        types.BankKeeper
	FeegrantKeeper    cosmosante.FeegrantKeeper
	OracleKeeper      OracleKeeper
	IBCKeeper         *ibckeeper.Keeper
	SignModeHandler   *txsigning.HandlerMap
	SigGasConsumer    cosmosante.SignatureVerificationGasConsumer
	TXCounterStoreKey storetypes.StoreKey
}

type OracleKeeper

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

OracleKeeper for feeder validation

type SpamPreventionDecorator

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

SpamPreventionDecorator defines a custom Ojo AnteHandler decorator that is responsible for preventing oracle message spam. Specifically, it prohibits oracle feeders from submitting multiple oracle messages in a single block.

func NewSpamPreventionDecorator

func NewSpamPreventionDecorator(oracleKeeper OracleKeeper) *SpamPreventionDecorator

func (*SpamPreventionDecorator) AnteHandle

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

func (*SpamPreventionDecorator) CheckOracleSpam

func (spd *SpamPreventionDecorator) CheckOracleSpam(ctx sdk.Context, msgs []sdk.Msg) error

CheckOracleSpam performs the check of whether or not we've seen an oracle message from an oracle feeder in the current block. If we have, we return an error which prohibits the transaction from being processed.

Jump to

Keyboard shortcuts

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