mempool1559

package
v21.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BackupFilename = "eip1559state.json"
)

Variables

View Source
var (
	DefaultBaseFee = sdk.MustNewDecFromStr("0.01")
	MinBaseFee     = sdk.MustNewDecFromStr("0.0025")
	MaxBaseFee     = sdk.MustNewDecFromStr("10")

	// Max increase per block is a factor of 15/14, max decrease is 9/10
	MaxBlockChangeRate = sdk.NewDec(1).Quo(sdk.NewDec(10))
	TargetGas          = int64(70_000_000)
	// In face of continuous spam, will take ~21 blocks from base fee > spam cost, to mempool eviction
	// ceil(log_{15/14}(RecheckFee mnConstant))
	// So potentially 2 minutes of impaired UX from 1559 nodes on top of time to get to base fee > spam.
	RecheckFeeConstant = int64(4)
	ResetInterval      = int64(2000)
)
View Source
var CurEipState = EipState{

	BackupFilePath: "",
	CurBaseFee:     sdk.NewDec(0),
	// contains filtered or unexported fields
}

CurEipState is a global variable used in the BeginBlock, EndBlock and DeliverTx (fee decorator AnteHandler) functions, it's also using when determining if a transaction has enough gas to successfully execute

Functions

func BeginBlockCode

func BeginBlockCode(ctx sdk.Context)

BeginBlockCode runs at the start of every block and it reset the CurEipStates lastBlockHeight and totalGasWantedThisBlock

func DeliverTxCode

func DeliverTxCode(ctx sdk.Context, tx sdk.FeeTx)

DeliverTxCode is run on every transaction and will collect the gas for every transaction for use calculating gas

func EndBlockCode

func EndBlockCode(ctx sdk.Context)

EndBlockCode runs at the end of every block and it updates the base fee based on the block attributes

Types

type EipState

type EipState struct {
	BackupFilePath string
	CurBaseFee     osmomath.Dec `json:"cur_base_fee"`
	// contains filtered or unexported fields
}

EipState tracks the current base fee and totalGasWantedThisBlock this structure is never written to state

func (EipState) Clone

func (e EipState) Clone() EipState

func (*EipState) GetCurBaseFee

func (e *EipState) GetCurBaseFee() osmomath.Dec

GetCurBaseFee returns a clone of the CurBaseFee to avoid overwriting the initial value in the EipState, we use this in the AnteHandler to Check transactions

func (*EipState) GetCurRecheckBaseFee

func (e *EipState) GetCurRecheckBaseFee() osmomath.Dec

GetCurRecheckBaseFee returns a clone of the CurBaseFee / RecheckFeeConstant to account for rechecked transactions in the feedecorator ante handler

Jump to

Keyboard shortcuts

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