mempool1559

package
v23.0.3-iavl-v1 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var (
	// We expect wallet multiplier * DefaultBaseFee < MinBaseFee * RecheckFeeConstant
	// conservatively assume a wallet multiplier of at least 7%.
	DefaultBaseFee = sdk.MustNewDecFromStr("0.0060")
	MinBaseFee     = sdk.MustNewDecFromStr("0.0025")
	MaxBaseFee     = sdk.MustNewDecFromStr("5")
	ResetInterval  = int64(6000)

	// Max increase per block is a factor of 1.06, max decrease is 9/10
	// If recovering at ~30M gas per block, decrease is .916
	MaxBlockChangeRate      = sdk.NewDec(1).Quo(sdk.NewDec(10))
	TargetGas               = int64(187_500_000)
	TargetBlockSpacePercent = sdk.MustNewDecFromStr("0.625")

	// N.B. on the reason for having two base fee constants for high and low fees:
	//
	// At higher base fees, we apply a smaller re-check factor.
	// The reason for this is that the recheck factor forces the base fee to get at minimum
	// "recheck factor" times higher than the spam rate. This leads to slow recovery
	// and a bad UX for user transactions. We aim for spam to start getting evicted from the mempool
	// sooner as to avoid more severe UX degradation for user transactions. Therefore,
	// we apply a smaller recheck factor at higher base fees.
	//
	// For low base fees:
	// In face of continuous spam, will take ~19 blocks from base fee > spam cost, to mempool eviction
	// ceil(log_{1.06}(RecheckFeeConstantLowBaseFee)) (assuming base fee not going over threshold)
	// So potentially 1.2 minutes of impaired UX from 1559 nodes on top of time to get to base fee > spam.
	RecheckFeeConstantLowBaseFee = "3"
	//
	// For high base fees:
	// In face of continuous spam, will take ~15 blocks from base fee > spam cost, to mempool eviction
	// ceil(log_{1.06}(RecheckFeeConstantHighBaseFee)) (assuming base fee surpasses threshold)
	RecheckFeeConstantHighBaseFee = "2.3"
	// Note, the choice of 0.01 was made by observing base fee metrics on mainnet and selecting
	// this value from Grafana dashboards. The observation is that below this threshold, we do not
	// observe user UX degradation. Therefore, we keep the original recheck factor.
	RecheckFeeBaseFeeThreshold = sdk.MustNewDecFromStr("0.01")
)
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