actpool

package
v2.4.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: Apache-2.0 Imports: 32 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoBundlesForHeight = errors.New("no bundles for the height")
	ErrNilBundle          = errors.New("bundle is nil")
	ErrBundleTargetHeight = errors.New("bundle target block height is invalid")
	ErrBundleExists       = errors.New("bundle already exists")
	ErrBundleUUIDExists   = errors.New("bundle with UUID already exists")
	ErrEmptyBundle        = errors.New("bundle is empty")
	ErrBundleNotFound     = errors.New("bundle not found")
	ErrNilBlock           = errors.New("block is nil")
	ErrInvalidCaller      = errors.New("invalid caller")
	ErrBlockHeightTooLow  = errors.New("block height is too low")
)
View Source
var (
	// DefaultConfig is the default config for actpool
	DefaultConfig = Config{
		MaxNumActsPerPool:  32000,
		MaxGasLimitPerPool: 320000000,
		MaxNumActsPerAcct:  2000,
		WorkerBufferSize:   2000,
		ActionExpiry:       10 * time.Minute,
		MinGasPriceStr:     big.NewInt(unit.Qev).String(),
		MaxNumBlobsPerAcct: 16,
		EnableBundlePool:   true,
		BlackList: []string{
			"io10epxv6w4he9pgx0qtagm7lc78aw9jsm7s8t0tw",
			"io10jr2hh4xcm3s3yhq98zudxh08e9uume6e0ekee",
			"io126e8lcld9ucl6nxm55s6hxmq9velxw9u9t8ps5",
			"io13pgqh3dhd63sen5clvt2cvqflshf0swxzq4utt",
			"io1470pxq9qusz36pk4ljny446pwmkg9pvuzeshlj",
			"io147r62u9rf2szarfnn6pxse53vmkahlgk9s69ru",
			"io14y3zwpnpd5uv8clanfr73xnkxz2mk2qgjcgngu",
			"io153n6d37236qjaxtmlegvunnejx4dqz5gdeq889",
			"io15526y7w3n24dhjsk958ge23aprs9urrte3jlr3",
			"io16zkt2tg3rv9wnunjdsffywdhw7ceyhpph7v3r5",
			"io17n3utl90flcnn9wlskx8c7lk8rmcrf5th86273",
			"io19rw6y85rh4d78az0s7w5dknp6j06cst5wtwnt3",
			"io1aj8u2a0tr2mjumcxy4zrnecszr8mh6wkrmjrxq",
			"io1d97phgd9uvrcw9yylucx5drwuwl8s7eef8mh0p",
			"io1e3uf73n3vfyev3hhhkwx6phnatduqtp7l2hvjr",
			"io1fp748ue6tsssn3z9q5cxcpyewjvcptkrtryju3",
			"io1fqv56nlmr2fnuex66j09k0qn5962yeezkp688n",
			"io1frcfdlrtrk0kk354sl703e2v7qwd3rclajhg5r",
			"io1fseuvqpg8gchcnc4sz3e2z73h8q837ult8yjv6",
			"io1fsrrc02mldtwhjjncngvf58yxw2emmgsz9gk0p",
			"io1ft54ueh2qn0nfep6xf92nm60n5sqlj0d9uzksg",
			"io1ftl20mky24k43yp06zcjx653ktas9xmvzvtasz",
			"io1g0k4e2km87l0vyx6mz4wvg23nvstxn0x6vddn7",
			"io1jyclx2jhdpe0ljn38683ga26hnpucx03v9elmn",
			"io1llaf2w7kpek7zv2gqe6u9mkvfmd20h3ael6c2u",
			"io1rvfvt9hdyu6fe3f7z5cj8a4vqhn8yk5eync2jp",
			"io1rxzrf2q3letflu36p2w097ekkz4da4wuk7wnxw",
			"io1va6umgyewzjatq8nrznyct9f2yp49rkpxtx3jj",
			"io1zh88jlem8vvzp9z6t73rs4qd72jnzpm8pv8ndu",
		},
		BlackListActiveHeight: 45404174,
		Store: &StoreConfig{
			Datadir: "/var/data/actpool.cache",
		},
	}
)
View Source
var (

	// ErrGasTooHigh error when the intrinsic gas of an action is too high
	ErrGasTooHigh = errors.New("action gas is too high")
)

Functions

func IsBlackListedFunc added in v2.4.0

func IsBlackListedFunc(blackList []string, activeHeight uint64) func(addr string, height uint64) bool

IsBlackListedFunc creates a function that checks if an address is blacklisted at a given height

func WithBundlePool added in v2.4.0

func WithBundlePool(bp *BundlePool) func(*actPool) error

WithBundlePool is the option to set bundle pool.

func WithClock

func WithClock(c clock.Clock) interface{ ActQueueOption }

WithClock returns an option to overwrite clock.

func WithStore

func WithStore(cfg StoreConfig, encode encodeAction, decode decodeAction) func(*actPool) error

WithStore is the option to set store encode and decode functions.

func WithTimeOut

func WithTimeOut(ttl time.Duration) interface{ ActQueueOption }

WithTimeOut returns an option to overwrite time out setting.

Types

type ActPool

type ActPool interface {
	action.SealedEnvelopeValidator
	lifecycle.StartStopper
	// Reset resets actpool state
	Reset()
	// PendingActionMap returns an action map with all accepted actions
	PendingActionMap() map[string][]*action.SealedEnvelope
	// Add adds an action into the pool after passing validation
	Add(ctx context.Context, act *action.SealedEnvelope) error
	// GetPendingNonce returns pending nonce in pool given an account address
	GetPendingNonce(addr string) (uint64, error)
	// GetUnconfirmedActs returns unconfirmed actions in pool given an account address
	GetUnconfirmedActs(addr string) []*action.SealedEnvelope
	// GetActionByHash returns the pending action in pool given action's hash
	GetActionByHash(hash hash.Hash256) (*action.SealedEnvelope, error)
	// GetSize returns the act pool size
	GetSize() uint64
	// GetCapacity returns the act pool capacity
	GetCapacity() uint64
	// GetGasSize returns the act pool gas size
	GetGasSize() uint64
	// GetGasCapacity returns the act pool gas capacity
	GetGasCapacity() uint64
	// DeleteAction deletes an invalid action from pool
	DeleteAction(address.Address)
	// ReceiveBlock will be called when a new block is committed
	ReceiveBlock(*block.Block) error
	// BundlePool returns a BundlePool instance
	BundlePool() *BundlePool

	AddActionEnvelopeValidators(...action.SealedEnvelopeValidator)
	AddSubscriber(sub Subscriber)
}

ActPool is the interface of actpool

func NewActPool

func NewActPool(g genesis.Genesis, sf protocol.StateReader, cfg Config, opts ...Option) (ActPool, error)

NewActPool constructs a new actpool

type ActQueue

type ActQueue interface {
	Put(*action.SealedEnvelope) error
	UpdateQueue() []*action.SealedEnvelope
	UpdateAccountState(uint64, *big.Int) []*action.SealedEnvelope
	AccountState() (uint64, *big.Int)
	PendingNonce() uint64
	NextAction() (bool, *big.Int)
	Len() int
	Empty() bool
	PendingActs(context.Context) []*action.SealedEnvelope
	AllActs() []*action.SealedEnvelope
	PopActionWithLargestNonce() *action.SealedEnvelope
	Reset()
}

ActQueue is the interface of actQueue

func NewActQueue

func NewActQueue(ap *actPool, address string, pendingNonce uint64, balance *big.Int, ops ...ActQueueOption) ActQueue

NewActQueue create a new action queue

type ActQueueOption

type ActQueueOption interface {
	SetActQueueOption(*actQueue)
}

ActQueueOption is the option for actQueue.

type BroadcastBundleFunc added in v2.4.0

type BroadcastBundleFunc func(ctx context.Context, sender address.Address, uuid string, bundle *action.Bundle)

BroadcastBundleFunc is the interface for broadcasting bundles.

type BundlePool added in v2.4.0

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

BundlePool defines a pool of bundles.

func NewBundlePool added in v2.4.0

func NewBundlePool(g genesis.Genesis) *BundlePool

NewBundlePool creates a new BundlePool

func (*BundlePool) AddBundle added in v2.4.0

func (bp *BundlePool) AddBundle(ctx context.Context, sender address.Address, uuid string, bundle *action.Bundle) error

AddBundle adds a bundle to the pool.

func (*BundlePool) BundlesAtHeight added in v2.4.0

func (bp *BundlePool) BundlesAtHeight(height uint64) ([]string, []address.Address, []*action.Bundle, error)

BundlesAtHeight retrieves all bundles at a specific height.

func (*BundlePool) DeleteBundle added in v2.4.0

func (bp *BundlePool) DeleteBundle(caller address.Address, uuid string) error

DeleteBundle deletes a bundle from the pool by its UUID.

func (*BundlePool) ReceiveBlock added in v2.4.0

func (bp *BundlePool) ReceiveBlock(blk *block.Block) error

ReceiveBlock handles the reception of a block and removes all bundles at the block's height.

func (*BundlePool) Reset added in v2.4.0

func (bp *BundlePool) Reset()

Reset clears the bundle pool.

func (*BundlePool) SetBroadcastHandler added in v2.4.0

func (bp *BundlePool) SetBroadcastHandler(broadcast BroadcastBundleFunc)

func (*BundlePool) SetValidator added in v2.4.0

func (bp *BundlePool) SetValidator(validateFunc ValidateActionFunc)

func (*BundlePool) Size added in v2.4.0

func (bp *BundlePool) Size() int

Size retrieves the number of bundles in the pool.

type Config

type Config struct {
	// MaxNumActsPerPool indicates maximum number of actions the whole actpool can hold
	MaxNumActsPerPool uint64 `yaml:"maxNumActsPerPool"`
	// MaxGasLimitPerPool indicates maximum gas limit the whole actpool can hold
	MaxGasLimitPerPool uint64 `yaml:"maxGasLimitPerPool"`
	// MaxNumActsPerAcct indicates maximum number of actions an account queue can hold
	MaxNumActsPerAcct uint64 `yaml:"maxNumActsPerAcct"`
	// WorkerBufferSize indicates the buffer size for each worker's job queue
	WorkerBufferSize uint64 `yaml:"bufferPerAcct"`
	// ActionExpiry defines how long an action will be kept in action pool.
	ActionExpiry time.Duration `yaml:"actionExpiry"`
	// MinGasPriceStr defines the minimal gas price the delegate will accept for an action
	MinGasPriceStr string `yaml:"minGasPrice"`
	// BlackList lists the account address that are banned from initiating actions
	BlackList []string `yaml:"blackList"`
	// BlackListActiveHeight is the height from which the blacklist is enforced (0 means always enforced)
	BlackListActiveHeight uint64 `yaml:"blackListActiveHeight"`
	// Store defines the config for persistent cache
	Store *StoreConfig `yaml:"store"`
	// MaxNumBlobsPerAcct defines the maximum number of blob txs an account can have
	MaxNumBlobsPerAcct uint64 `yaml:"maxNumBlobsPerAcct"`
	// EnableBundlePool indicates whether to enable bundle pool
	EnableBundlePool bool `yaml:"enableBundlePool"`
}

Config is the actpool config

func (Config) IsBlackListedFunc added in v2.4.0

func (ap Config) IsBlackListedFunc() func(addr string, height uint64) bool

IsBlackListedFunc returns a function that checks if an address is blacklisted at a given height

func (Config) MinGasPrice

func (ap Config) MinGasPrice() *big.Int

MinGasPrice returns the minimal gas price threshold

type Option

type Option func(pool *actPool) error

Option sets action pool construction parameter

type SortedActions

type SortedActions []*action.SealedEnvelope

SortedActions is a slice of actions that implements sort.Interface to sort by Value.

func (SortedActions) Len

func (p SortedActions) Len() int

func (SortedActions) Less

func (p SortedActions) Less(i, j int) bool

func (SortedActions) Swap

func (p SortedActions) Swap(i, j int)

type StoreConfig

type StoreConfig struct {
	Datadir string `yaml:"datadir"` // Data directory containing the currently executable blobs
}

StoreConfig is the configuration for the blob store

type Subscriber

type Subscriber interface {
	OnAdded(context.Context, *action.SealedEnvelope)
	OnRemoved(*action.SealedEnvelope)
}

Subscriber is the interface for actpool subscriber

type ValidateActionFunc added in v2.4.0

type ValidateActionFunc func(context.Context, *action.SealedEnvelope) error

ValidateActionFunc is the function validating an action.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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