miner

package
v1.13.2 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2025 License: GPL-3.0, LGPL-3.0 Imports: 33 Imported by: 0

README

Miner

The miner is a package inherited from go-ethereum with a large amount of functionality stripped out since it is not needed in coreth.

In go-ethereum, the miner needs to perform PoW in order to try and produce the next block. Since Avalanche does not rely on PoW in any way, the miner within Coreth is only used to produce blocks on demand.

All of the async functionality has been stripped out in favor of a much lighter weight miner implementation which takes a backend that supplies the blockchain and transaction pool and exposes the functionality to produce a new block with the contents of the transaction pool.

FinalizeAndAssemble

One nuance of the miner, is that it makes use of the call FinalizeAndAssemble from the coreth consensus engine. This callback, as hinted at in the name, performs the same work as Finalize in addition to assembling the block.

This means that whenever a verification or processing operation is added in Finalize it must be added in FinalizeAndAssemble as well to ensure that a block produced by the miner is processed in the same way by a node receiving that block, which did not produce it.

To illustrate, if nodeA produces a block and sends it to the network. When nodeB receives that block and processes it, it needs to process it and see the exact same result as nodeA. Otherwise, there could be a situation where two nodes either disagree on the validity of a block or process it differently and perform a different state transition as a result.

Documentation

Overview

Package miner implements Ethereum block creation and mining.

Index

Constants

This section is empty.

Variables

View Source
var ErrInsufficientGasCapacityToBuild = errors.New("insufficient gas capacity to build block")

Functions

This section is empty.

Types

type Backend

type Backend interface {
	BlockChain() *core.BlockChain
	TxPool() *txpool.TxPool
}

Backend wraps all methods required for mining.

type BidRuntime

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

type BuilderConfig

type BuilderConfig struct {
	Address common.Address `json:"address"`
	URL     string         `json:"url"`
}

type Config

type Config struct {
	Etherbase                    common.Address `toml:",omitempty"` // Public address for block mining rewards
	TestOnlyAllowDuplicateBlocks bool           // Allow mining of duplicate blocks (used in tests only)

	Mev MevConfig // Mev configuration
}

Config is the configuration parameters of mining.

type MevConfig

type MevConfig struct {
	Enabled             bool            `json:"enabled"`             // Whether to enable Mev or not
	Builders            []BuilderConfig `json:"builders"`            // The list of builders
	ValidatorCommission uint64          `json:"validatorCommission"` // 100 means the validator claims 1% from block reward
	ValidatorWallet     common.Address  `json:"validatorWallet"`     // The wallet of the validator that gets the rewards
}

type Miner

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

func New

func New(eth Backend, config *Config, chainConfig *params.ChainConfig, mux *event.TypeMux, engine consensus.Engine, clock *mockable.Clock) *Miner

func (*Miner) BestPackedBlockReward

func (miner *Miner) BestPackedBlockReward(parentHash common.Hash) *big.Int

func (*Miner) GenerateBlock

func (miner *Miner) GenerateBlock(predicateContext *precompileconfig.PredicateContext) (*types.Block, error)

func (*Miner) MevParams

func (miner *Miner) MevParams() *bidTypes.MevParams

func (*Miner) MevRunning

func (miner *Miner) MevRunning() bool

MevRunning return true if mev is running.

func (*Miner) SendBid

func (miner *Miner) SendBid(ctx context.Context, bidArgs *bidTypes.BidArgs) (common.Hash, error)

func (*Miner) SetEtherbase

func (miner *Miner) SetEtherbase(addr common.Address)

func (*Miner) SubscribePendingLogs

func (miner *Miner) SubscribePendingLogs(ch chan<- []*types.Log) event.Subscription

SubscribePendingLogs starts delivering logs from pending transactions to the given channel.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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