config

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: MIT Imports: 3 Imported by: 10

Documentation

Overview

Package config provides a configuration struct and getters for the submitter.

Config contains configuration for the submitter. It can be loaded from a YAML file. Chain-specific configuration items can be provided via the `Chains` map, which overrides the global config for each chain. If a chain-specific item is not provided, the global config is used.

Index

Constants

View Source
const (
	// DefaultMaxBatchSize is the default maximum number of transactions to send in a batch.
	DefaultMaxBatchSize = 10

	// DefaultBumpIntervalSeconds is the default number of seconds to wait before bumping a transaction.
	DefaultBumpIntervalSeconds = 30

	// DefaultGasBumpPercentage is the default percentage to bump the gas price by.
	DefaultGasBumpPercentage = 5

	// DefaultGasEstimate is the default gas estimate to use for transactions.
	DefaultGasEstimate = uint64(1200000)
)

Variables

View Source
var DefaultMaxPrice = big.NewInt(500 * params.GWei)

DefaultMaxPrice is the default max price of a tx.

Functions

This section is empty.

Types

type ChainConfig

type ChainConfig struct {
	// MaxBatchSize is the maximum number of transactions to send in a batch
	// if this is zero, the default will be used. This field is ignored if batching is disabled.
	MaxBatchSize int `yaml:"max_batch_size"`
	// Batch is whether or not to batch transactions at the rpc level
	DoNotBatch bool `yaml:"skip_batching"`
	// MaxGasPrice is the maximum gas price to use for transactions
	MaxGasPrice *big.Int `yaml:"max_gas_price"`
	// BumpIntervalSeconds is the number of seconds to wait before bumping a transaction
	BumpIntervalSeconds int `yaml:"bump_interval_seconds"`
	// GasBumpPercentages is the percentage to bump the gas price by
	// this is applied to the greatrer of the chainprice or the last price
	GasBumpPercentage int `yaml:"gas_bump_percentage"`
	// IsL2 is whether or not this chain is an L2 chain
	IsL2 bool `yaml:"is_l2"`
	// GasEstimate is the gas estimate to use for transactions
	// if dynamic gas estimation is enabled, this is only used as a default if the estimate fails
	GasEstimate uint64 `yaml:"gas_estimate"`
	// DynamicGasEstimate is whether or not to use dynamic gas estimation
	DynamicGasEstimate bool `yaml:"dynamic_gas_estimate"`
	// SupportsEIP1559 is whether or not this chain supports EIP1559
	SupportsEIP1559 bool `yaml:"supports_eip_1559"`
}

ChainConfig contains configuration for a specific chain.

type Config

type Config struct {
	// GlobalConfig stores the default configuration
	ChainConfig `yaml:",inline"`
	// Chains overrides the global config for each chain
	Chains map[int]ChainConfig `yaml:"chains"`
}

Config contains configuration for the submitter.

func (*Config) GetBatch

func (c *Config) GetBatch(chainID int) bool

GetBatch returns whether or not to batch transactions at the rpc level.

func (*Config) GetBumpInterval

func (c *Config) GetBumpInterval(chainID int) time.Duration

GetBumpInterval returns the number of seconds to wait before bumping a transaction TODO: test this method.

func (*Config) GetDynamicGasEstimate

func (c *Config) GetDynamicGasEstimate(chainID int) bool

GetDynamicGasEstimate returns whether or not to use dynamic gas estimation TODO: test this method.

func (*Config) GetGasBumpPercentage

func (c *Config) GetGasBumpPercentage(chainID int) (gasBumpPercentage int)

GetGasBumpPercentage returns the percentage to bump the gas price by TODO: test this method.

func (*Config) GetGasEstimate

func (c *Config) GetGasEstimate(chainID int) (gasEstimate uint64)

GetGasEstimate returns the gas estimate to use for transactions TODO: test this method.

func (*Config) GetMaxBatchSize

func (c *Config) GetMaxBatchSize(chainID int) int

GetMaxBatchSize returns the maximum number of transactions to send in a batch.

func (*Config) GetMaxGasPrice

func (c *Config) GetMaxGasPrice(chainID int) (maxPrice *big.Int)

GetMaxGasPrice returns the maximum gas price to use for transactions.

func (*Config) IsL2

func (c *Config) IsL2(chainID int) bool

IsL2 returns whether or not this chain is an L2 chain.

func (*Config) SetGlobalEIP1559Support

func (c *Config) SetGlobalEIP1559Support(supportsEIP1559 bool)

SetGlobalEIP1559Support is a helper function that sets the global EIP1559 support.

func (*Config) SetGlobalMaxGasPrice

func (c *Config) SetGlobalMaxGasPrice(maxPrice *big.Int)

SetGlobalMaxGasPrice is a helper function that sets the global gas price.

func (*Config) SupportsEIP1559

func (c *Config) SupportsEIP1559(chainID int) bool

SupportsEIP1559 returns whether or not this chain supports EIP1559.

type IConfig

type IConfig interface {
	// GetMaxBatchSize returns the maximum number of transactions to send in a batch.
	GetMaxBatchSize(chainID int) int
	// GetBatch returns whether or not to batch transactions at the rpc level.
	GetBatch(chainID int) bool
	// GetMaxGasPrice returns the maximum gas price to use for transactions.
	GetMaxGasPrice(chainID int) (maxPrice *big.Int)
	// GetBumpInterval returns the number of seconds to wait before bumping a transaction
	// TODO: test this method.
	GetBumpInterval(chainID int) time.Duration
	// IsL2 returns whether or not this chain is an L2 chain.
	IsL2(chainID int) bool
	// GetGasBumpPercentage returns the percentage to bump the gas price by
	// TODO: test this method.
	GetGasBumpPercentage(chainID int) (gasBumpPercentage int)
	// GetGasEstimate returns the gas estimate to use for transactions
	// TODO: test this method.
	GetGasEstimate(chainID int) (gasEstimate uint64)
	// GetDynamicGasEstimate returns whether or not to use dynamic gas estimation
	// TODO: test this method.
	GetDynamicGasEstimate(chainID int) bool
	// SupportsEIP1559 returns whether or not this chain supports EIP1559.
	SupportsEIP1559(chainID int) bool
	// SetGlobalMaxGasPrice is a helper function that sets the global gas price.
	SetGlobalMaxGasPrice(maxPrice *big.Int)
	// SetGlobalEIP1559Support is a helper function that sets the global EIP1559 support.
	SetGlobalEIP1559Support(supportsEIP1559 bool)
}

IConfig ...

Jump to

Keyboard shortcuts

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