Documentation ¶
Index ¶
- Constants
- Variables
- func BumpGasPriceOnly(config Config, originalGasPrice *big.Int, originalGasLimit uint64) (gasPrice *big.Int, chainSpecificGasLimit uint64, err error)
- func HexToInt64(input interface{}) int64
- func Int64ToHex(n int64) string
- type Block
- type BlockHistoryEstimator
- func (b *BlockHistoryEstimator) BumpGas(originalGasPrice *big.Int, gasLimit uint64) (bumpedGasPrice *big.Int, chainSpecificGasLimit uint64, err error)
- func (b *BlockHistoryEstimator) Close() error
- func (b *BlockHistoryEstimator) Connect(bn *models.Head) error
- func (b *BlockHistoryEstimator) EstimateGas(_ []byte, gasLimit uint64, _ ...Opt) (gasPrice *big.Int, chainSpecificGasLimit uint64, err error)
- func (b *BlockHistoryEstimator) FetchBlocks(ctx context.Context, head models.Head) error
- func (b *BlockHistoryEstimator) FetchBlocksAndRecalculate(ctx context.Context, head models.Head)
- func (b *BlockHistoryEstimator) OnNewLongestChain(ctx context.Context, head models.Head)
- func (b *BlockHistoryEstimator) Recalculate(head models.Head)
- func (b *BlockHistoryEstimator) RollingBlockHistory() []Block
- func (b *BlockHistoryEstimator) Start() error
- type Config
- type Estimator
- type Opt
- type OptimismGasPricesResponse
- type Transaction
- type TxType
Constants ¶
const LegacyTxType = TxType(0x0)
Variables ¶
var (
ErrNoSuitableTransactions = errors.New("no suitable transactions")
)
Functions ¶
func BumpGasPriceOnly ¶
func BumpGasPriceOnly(config Config, originalGasPrice *big.Int, originalGasLimit uint64) (gasPrice *big.Int, chainSpecificGasLimit uint64, err error)
BumpGasPriceOnly will increase the price and apply multiplier to the gas limit
func HexToInt64 ¶
func HexToInt64(input interface{}) int64
HexToInt64 performs the inverse of Int64ToHex Returns 0 on invalid input
func Int64ToHex ¶
Int64ToHex converts an int64 into go-ethereum's hex representation
Types ¶
type Block ¶
type Block struct { Number int64 Hash common.Hash ParentHash common.Hash Transactions []Transaction }
Block represents an ethereum block This type is only used for the block history estimator, and can be expensive to unmarshal. Don't add unnecessary fields here.
func (Block) MarshalJSON ¶
MarshalJSON implements json marshalling for Block
func (*Block) UnmarshalJSON ¶
UnmarshalJSON unmarshals to a Block
type BlockHistoryEstimator ¶
type BlockHistoryEstimator struct { utils.StartStopOnce // contains filtered or unexported fields }
func (*BlockHistoryEstimator) Close ¶
func (b *BlockHistoryEstimator) Close() error
func (*BlockHistoryEstimator) Connect ¶
func (b *BlockHistoryEstimator) Connect(bn *models.Head) error
func (*BlockHistoryEstimator) EstimateGas ¶
func (*BlockHistoryEstimator) FetchBlocks ¶
func (*BlockHistoryEstimator) FetchBlocksAndRecalculate ¶
func (b *BlockHistoryEstimator) FetchBlocksAndRecalculate(ctx context.Context, head models.Head)
func (*BlockHistoryEstimator) OnNewLongestChain ¶
func (b *BlockHistoryEstimator) OnNewLongestChain(ctx context.Context, head models.Head)
OnNewLongestChain recalculates and sets global gas price if a sampled new head comes in and we are not currently fetching
func (*BlockHistoryEstimator) Recalculate ¶
func (b *BlockHistoryEstimator) Recalculate(head models.Head)
FetchHeadsAndRecalculate adds the given heads to the history and recalculates gas price
func (*BlockHistoryEstimator) RollingBlockHistory ¶
func (b *BlockHistoryEstimator) RollingBlockHistory() []Block
func (*BlockHistoryEstimator) Start ¶
func (b *BlockHistoryEstimator) Start() error
type Config ¶
type Config interface { BlockHistoryEstimatorBatchSize() uint32 BlockHistoryEstimatorBlockDelay() uint16 BlockHistoryEstimatorBlockHistorySize() uint16 BlockHistoryEstimatorTransactionPercentile() uint16 ChainID() *big.Int EthFinalityDepth() uint EthGasBumpPercent() uint16 EthGasBumpWei() *big.Int EthGasLimitMultiplier() float32 EthGasPriceDefault() *big.Int EthMaxGasPriceWei() *big.Int EthMinGasPriceWei() *big.Int GasEstimatorMode() string }
Config defines an interface for configuration in the gas package
type Estimator ¶
type Estimator interface { OnNewLongestChain(context.Context, models.Head) Start() error Close() error EstimateGas(calldata []byte, gasLimit uint64, opts ...Opt) (gasPrice *big.Int, chainSpecificGasLimit uint64, err error) BumpGas(originalGasPrice *big.Int, gasLimit uint64) (bumpedGasPrice *big.Int, chainSpecificGasLimit uint64, err error) }
Estimator provides an interface for estimating gas price and limit
func NewBlockHistoryEstimator ¶
NewBlockHistoryEstimator returns a new BlockHistoryEstimator that listens for new heads and updates the base gas price dynamically based on the configured percentile of gas prices in that block
func NewFixedPriceEstimator ¶
func NewOptimismEstimator ¶
NewOptimismEstimator returns a new optimism estimator
type OptimismGasPricesResponse ¶
OptimismGasPricesResponse is the shape of the response when calling rollup_gasPrices
func (*OptimismGasPricesResponse) UnmarshalJSON ¶
func (g *OptimismGasPricesResponse) UnmarshalJSON(b []byte) error
type Transaction ¶
type Transaction struct { GasPrice *big.Int GasLimit uint64 MaxFeePerGas *big.Int MaxPriorityFeePerGas *big.Int Type TxType Hash common.Hash }
Transaction represents an ethereum transaction Use our own type because geth's type has validation failures on e.g. zero gas used, which can occur on other chains. This type is only used for the block history estimator, and can be expensive to unmarshal. Don't add unnecessary fields here.
func (*Transaction) UnmarshalJSON ¶
func (t *Transaction) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals a Transaction