ap3

package
v0.14.1-acp-176.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: GPL-3.0, LGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

AP3 defines the dynamic fee window used after the Apricot Phase 3 upgrade.

Index

Constants

View Source
const (
	// WindowLen is the number of seconds of gas consumption to track.
	WindowLen = 10

	// MinBaseFee is the minimum base fee that is allowed after Apricot Phase 3
	// upgrade.
	//
	// This value was modified in Apricot Phase 4.
	MinBaseFee = 75 * utils.GWei

	// MaxBaseFee is the maximum base fee that is allowed after Apricot Phase 3
	// upgrade.
	//
	// This value was modified in Apricot Phase 4.
	MaxBaseFee = 225 * utils.GWei

	// InitialBaseFee is the base fee that is used for the first Apricot Phase 3
	// block.
	InitialBaseFee = MaxBaseFee

	// TargetGas is the target amount of gas to be included in the window. The
	// target amount of gas per second equals [TargetGas] / [WindowLen].
	//
	// This value was modified in Apricot Phase 5.
	TargetGas = 10_000_000

	// IntrinsicBlockGas is the amount of gas that should always be included in
	// the window.
	//
	// This value became dynamic in Apricot Phase 4.
	IntrinsicBlockGas = 1_000_000

	// BaseFeeChangeDenominator is the denominator used to smoothen base fee
	// changes.
	//
	// This value was modified in Apricot Phase 5.
	BaseFeeChangeDenominator = 12
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Window

type Window [WindowLen]uint64

Window is a window of the last WindowLen seconds of gas usage.

Index 0 is the oldest entry, and WindowLen-1 is the current entry.

func (*Window) Add

func (w *Window) Add(amounts ...uint64)

Add adds the amounts to the most recent entry in the window.

If the most recent entry overflows, it is set to math.MaxUint64.

func (*Window) Shift

func (w *Window) Shift(n uint64)

Shift removes the oldest n entries from the window and adds n new empty entries.

func (*Window) Sum

func (w *Window) Sum() uint64

Sum returns the sum of all the entries in the window.

If the sum overflows, math.MaxUint64 is returned.

Jump to

Keyboard shortcuts

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