Documentation ¶
Overview ¶
Package core implements the Ethereum consensus protocol.
Index ¶
- Constants
- Variables
- func AmoyGenesisBlock() *types.Genesis
- func ApplyMessage(evm *vm.EVM, msg Message, gp *GasPool, refunds bool, gasBailout bool) (*evmtypes.ExecutionResult, error)
- func ApplyTransaction(config *chain.Config, blockHashFunc func(n uint64) libcommon.Hash, ...) (*types.Receipt, []byte, error)
- func BlockPostValidation(gasUsed, blobGasUsed uint64, checkReceipts bool, receipts types.Receipts, ...) error
- func BorDevnetGenesisBlock() *types.Genesis
- func BorMainnetGenesisBlock() *types.Genesis
- func CalcGasLimit(parentGasLimit, desiredLimit uint64) uint64
- func CalcHashRootForTests(tx kv.RwTx, header *types.Header, histV4, trace bool) (hashRoot libcommon.Hash, err error)
- func CanTransfer(db evmtypes.IntraBlockState, addr libcommon.Address, amount *uint256.Int) bool
- func CheckEip1559TxGasFeeCap(from libcommon.Address, gasFeeCap, tip, baseFee *uint256.Int, isFree bool) error
- func ChiadoGenesisBlock() *types.Genesis
- func CommitGenesisBlock(db kv.RwDB, genesis *types.Genesis, dirs datadir.Dirs, logger log.Logger) (*chain.Config, *types.Block, error)
- func CommitGenesisBlockWithOverride(db kv.RwDB, genesis *types.Genesis, overridePragueTime *big.Int, ...) (*chain.Config, *types.Block, error)
- func DeveloperGenesisBlock(period uint64, faucet libcommon.Address) *types.Genesis
- func FinalizeBlockExecution(engine consensus.Engine, stateReader state.StateReader, header *types.Header, ...) (newBlock *types.Block, newTxs types.Transactions, newReceipt types.Receipts, ...)
- func GenesisBlockByChainName(chain string) *types.Genesis
- func GenesisBlockForTesting(db kv.RwDB, addr libcommon.Address, balance *big.Int, dirs datadir.Dirs, ...) *types.Block
- func GenesisToBlock(g *types.Genesis, dirs datadir.Dirs, logger log.Logger) (*types.Block, *state.IntraBlockState, error)
- func GenesisWithAccounts(db kv.RwDB, accs []GenAccount, dirs datadir.Dirs, logger log.Logger) *types.Block
- func GetHashFn(ref *types.Header, ...) func(n uint64) libcommon.Hash
- func GnosisGenesisBlock() *types.Genesis
- func HoleskyGenesisBlock() *types.Genesis
- func InitializeBlockExecution(engine consensus.Engine, chain consensus.ChainHeaderReader, ...) error
- func IntrinsicGas(data []byte, accessList types2.AccessList, isContractCreation bool, ...) (uint64, error)
- func MainnetGenesisBlock() *types.Genesis
- func MakeEmptyHeader(parent *types.Header, chainConfig *chain.Config, timestamp uint64, ...) *types.Header
- func MustCommitGenesis(g *types.Genesis, db kv.RwDB, dirs datadir.Dirs, logger log.Logger) *types.Block
- func NewEVMBlockContext(header *types.Header, blockHashFunc func(n uint64) libcommon.Hash, ...) evmtypes.BlockContext
- func NewEVMTxContext(msg Message) evmtypes.TxContext
- func SepoliaGenesisBlock() *types.Genesis
- func SkipAnalysis(config *chain.Config, blockNumber uint64) bool
- func SysCallContract(contract libcommon.Address, data []byte, chainConfig *chain.Config, ...) (result []byte, err error)
- func SysCreate(contract libcommon.Address, data []byte, chainConfig *chain.Config, ...) (result []byte, err error)
- func TestGenesisBlock() *types.Genesis
- func WriteGenesisBlock(tx kv.RwTx, genesis *types.Genesis, overridePragueTime *big.Int, ...) (*chain.Config, *types.Block, error)
- func WriteGenesisState(g *types.Genesis, tx kv.RwTx, dirs datadir.Dirs, logger log.Logger) (*types.Block, *state.IntraBlockState, error)
- type BlockBuilderParameters
- type BlockGen
- func (b *BlockGen) AddFailedTx(tx types.Transaction)
- func (b *BlockGen) AddFailedTxWithChain(getHeader func(hash libcommon.Hash, number uint64) *types.Header, ...)
- func (b *BlockGen) AddTx(tx types.Transaction)
- func (b *BlockGen) AddTxWithChain(getHeader func(hash libcommon.Hash, number uint64) *types.Header, ...)
- func (b *BlockGen) AddUncheckedReceipt(receipt *types.Receipt)
- func (b *BlockGen) AddUncheckedTx(tx types.Transaction)
- func (b *BlockGen) AddUncle(h *types.Header)
- func (b *BlockGen) GetHeader() *types.Header
- func (b *BlockGen) GetParent() *types.Block
- func (b *BlockGen) GetReceipts() []*types.Receipt
- func (b *BlockGen) Number() *big.Int
- func (b *BlockGen) OffsetTime(seconds int64)
- func (b *BlockGen) PrevBlock(index int) *types.Block
- func (b *BlockGen) SetCoinbase(addr libcommon.Address)
- func (b *BlockGen) SetDifficulty(diff *big.Int)
- func (b *BlockGen) SetExtra(data []byte)
- func (b *BlockGen) SetNonce(nonce types.BlockNonce)
- func (b *BlockGen) TxNonce(addr libcommon.Address) uint64
- type ChainEvent
- type ChainHeadEvent
- type ChainPack
- type ChainSideEvent
- type EphemeralExecResult
- type FakeChainReader
- func (cr *FakeChainReader) BorEventsByBlock(hash libcommon.Hash, number uint64) []rlp.RawValue
- func (cr *FakeChainReader) BorSpan(spanId uint64) *heimdall.Span
- func (cr *FakeChainReader) BorStartEventId(hash libcommon.Hash, number uint64) uint64
- func (cr *FakeChainReader) Config() *chain.Config
- func (cr *FakeChainReader) CurrentFinalizedHeader() *types.Header
- func (cr *FakeChainReader) CurrentHeader() *types.Header
- func (cr *FakeChainReader) CurrentSafeHeader() *types.Header
- func (cr *FakeChainReader) FrozenBlocks() uint64
- func (cr *FakeChainReader) FrozenBorBlocks() uint64
- func (cr *FakeChainReader) GetBlock(hash libcommon.Hash, number uint64) *types.Block
- func (cr *FakeChainReader) GetHeader(hash libcommon.Hash, number uint64) *types.Header
- func (cr *FakeChainReader) GetHeaderByHash(hash libcommon.Hash) *types.Header
- func (cr *FakeChainReader) GetHeaderByNumber(number uint64) *types.Header
- func (cr *FakeChainReader) GetTd(hash libcommon.Hash, number uint64) *big.Int
- func (cr *FakeChainReader) HasBlock(hash libcommon.Hash, number uint64) bool
- type GasPool
- func (gp *GasPool) AddBlobGas(amount uint64) *GasPool
- func (gp *GasPool) AddGas(amount uint64) *GasPool
- func (gp *GasPool) BlobGas() uint64
- func (gp *GasPool) Gas() uint64
- func (gp *GasPool) Reset(amount, blobGas uint64)
- func (gp *GasPool) String() string
- func (gp *GasPool) SubBlobGas(amount uint64) error
- func (gp *GasPool) SubGas(amount uint64) error
- type GenAccount
- type Message
- type NewTxsEvent
- type RejectedTx
- type RejectedTxs
- type RemovedLogsEvent
- type StateTransition
- type SyncMode
- type TxSenderCacher
Constants ¶
const ( TriesInMemory = 128 // See gas_limit in https://github.com/gnosischain/specs/blob/master/execution/withdrawals.md SysCallGasLimit = uint64(30_000_000) )
Variables ¶
var ( // ErrKnownBlock is returned when a block to import is already known locally. ErrKnownBlock = errors.New("block already known") // ErrBlacklistedHash is returned if a block to import is on the blacklist. ErrBlacklistedHash = errors.New("blacklisted hash") // ErrNoGenesis is returned when there is no Genesis Block. ErrNoGenesis = errors.New("genesis not found in chain") // ErrTipAboveFeeCap is a sanity error to ensure no one is able to specify a // transaction with a tip higher than the total fee cap. ErrTipAboveFeeCap = errors.New("tip higher than fee cap") // ErrMaxFeePerBlobGas is returned if the transaction specified a // max_fee_per_blob_gas that is below the current blob gas price. ErrMaxFeePerBlobGas = errors.New("max fee per blob gas too low") // ErrTipVeryHigh is a sanity error to avoid extremely big numbers specified // in the tip field. ErrTipVeryHigh = errors.New("tip higher than 2^256-1") // ErrFeeCapVeryHigh is a sanity error to avoid extremely big numbers specified // in the fee cap field. ErrFeeCapVeryHigh = errors.New("fee cap higher than 2^256-1") // ErrInternalFailure is returned when an unexpected internal error condition // prevents execution. ErrInternalFailure = errors.New("internal failure") )
var ( // ErrNonceTooLow is returned if the nonce of a transaction is lower than the // one present in the local chain. ErrNonceTooLow = errors.New("nonce too low") // ErrNonceTooHigh is returned if the nonce of a transaction is higher than the // next one expected based on the local chain. ErrNonceTooHigh = errors.New("nonce too high") // ErrNonceMax is returned if the nonce of a transaction sender account has // maximum allowed value and would become invalid if incremented. ErrNonceMax = errors.New("nonce has max value") // ErrGasLimitReached is returned by the gas pool if the amount of gas required // by a transaction is higher than what's left in the block. ErrGasLimitReached = errors.New("gas limit reached") // ErrBlobGasLimitReached is returned by the gas pool if the amount of blob gas required // by a transaction is higher than what's left in the block. ErrBlobGasLimitReached = errors.New("blob gas limit reached") // ErrMaxInitCodeSizeExceeded is returned if creation transaction provides the init code bigger // than init code size limit. ErrMaxInitCodeSizeExceeded = errors.New("max initcode size exceeded") // ErrInsufficientFunds is returned if the total cost of executing a transaction // is higher than the balance of the user's account. ErrInsufficientFunds = errors.New("insufficient funds for gas * price + value") // ErrGasUintOverflow is returned when calculating gas usage. ErrGasUintOverflow = errors.New("gas uint64 overflow") // ErrIntrinsicGas is returned if the transaction is specified to use less gas // than required to start the invocation. ErrIntrinsicGas = errors.New("intrinsic gas too low") // ErrTxTypeNotSupported is returned if a transaction is not supported in the // current network configuration. ErrTxTypeNotSupported = types.ErrTxTypeNotSupported // ErrFeeCapTooLow is returned if the transaction fee cap is less than the // the base fee of the block. ErrFeeCapTooLow = errors.New("fee cap less than block base fee") // ErrSenderNoEOA is returned if the sender of a transaction is a contract. // See EIP-3607: Reject transactions from senders with deployed code. ErrSenderNoEOA = errors.New("sender not an eoa") )
List of evm-call-message pre-checking errors. All state transition messages will be pre-checked before execution. If any invalidation detected, the corresponding error should be returned which is defined here.
- If the pre-checking happens in the miner, then the transaction won't be packed. - If the pre-checking happens in the block processing procedure, then a "BAD BLOCk" error should be emitted.
var BadHashes = map[libcommon.Hash]bool{ libcommon.HexToHash("05bef30ef572270f654746da22639a7a0c97dd97a7050b9e252391996aaeb689"): true, libcommon.HexToHash("7d05d08cbc596a2e5e4f13b80a743e53e09221b5323c3a61946b20873e58583f"): true, }
BadHashes represent a set of manually tracked bad hashes (usually hard forks)
var DevnetEtherbase = libcommon.HexToAddress("67b1d87101671b127f5f8714789c7192f7ad340e")
var DevnetSignKey = func(address libcommon.Address) *ecdsa.PrivateKey { return DevnetSignPrivateKey }
DevnetSignKey is defined like this to allow the devnet process to pre-allocate keys for nodes and then pass the address via --miner.etherbase - the function will be called to retieve the mining key
var DevnetSignPrivateKey, _ = crypto.HexToECDSA("26e86e45f6fc45ec6e2ecd128cec80fa1d1505e5507dcd2ae58c3130a7a97b48")
Pre-calculated version of:
DevnetSignPrivateKey = crypto.HexToECDSA(sha256.Sum256([]byte("erigon devnet key"))) DevnetEtherbase=crypto.PubkeyToAddress(DevnetSignPrivateKey.PublicKey)
var GenerateTrace bool
Functions ¶
func AmoyGenesisBlock ¶
AmoyGenesisBlock returns the Amoy network genesis block.
func ApplyMessage ¶
func ApplyMessage(evm *vm.EVM, msg Message, gp *GasPool, refunds bool, gasBailout bool) (*evmtypes.ExecutionResult, error)
ApplyMessage computes the new state by applying the given message against the old state within the environment.
ApplyMessage returns the bytes returned by any EVM execution (if it took place), the gas used (which includes gas refunds) and an error if it failed. An error always indicates a core error meaning that the message would always fail for that particular state and would never be accepted within a block. `refunds` is false when it is not required to apply gas refunds `gasBailout` is true when it is not required to fail transaction if the balance is not enough to pay gas. for trace_call to replicate OE/Parity behaviour
func ApplyTransaction ¶
func ApplyTransaction(config *chain.Config, blockHashFunc func(n uint64) libcommon.Hash, engine consensus.EngineReader, author *libcommon.Address, gp *GasPool, ibs *state.IntraBlockState, stateWriter state.StateWriter, header *types.Header, txn types.Transaction, usedGas, usedBlobGas *uint64, cfg vm.Config, ) (*types.Receipt, []byte, error)
ApplyTransaction attempts to apply a transaction to the given state database and uses the input parameters for its environment. It returns the receipt for the transaction, gas used and an error if the transaction failed, indicating the block was invalid.
func BlockPostValidation ¶
func BorDevnetGenesisBlock ¶
func BorMainnetGenesisBlock ¶
BorMainnetGenesisBlock returns the Bor Mainnet network genesis block.
func CalcGasLimit ¶
CalcGasLimit computes the gas limit of the next block after parent. It aims to keep the baseline gas close to the provided target, and increase it towards the target if the baseline gas is lower.
func CalcHashRootForTests ¶
func CanTransfer ¶
CanTransfer checks whether there are enough funds in the address' account to make a transfer. This does not take the necessary gas in to account to make the transfer valid.
func CheckEip1559TxGasFeeCap ¶
func ChiadoGenesisBlock ¶
func CommitGenesisBlock ¶
func CommitGenesisBlock(db kv.RwDB, genesis *types.Genesis, dirs datadir.Dirs, logger log.Logger) (*chain.Config, *types.Block, error)
CommitGenesisBlock writes or updates the genesis block in db. The block that will be used is:
genesis == nil genesis != nil +------------------------------------------ db has no genesis | main-net | genesis db has genesis | from DB | genesis (if compatible)
The stored chain configuration will be updated if it is compatible (i.e. does not specify a fork block below the local head block). In case of a conflict, the error is a *params.ConfigCompatError and the new, unwritten config is returned.
The returned chain configuration is never nil.
func DeveloperGenesisBlock ¶
DeveloperGenesisBlock returns the 'geth --dev' genesis block.
func FinalizeBlockExecution ¶
func FinalizeBlockExecution( engine consensus.Engine, stateReader state.StateReader, header *types.Header, txs types.Transactions, uncles []*types.Header, stateWriter state.StateWriter, cc *chain.Config, ibs *state.IntraBlockState, receipts types.Receipts, withdrawals []*types.Withdrawal, chainReader consensus.ChainReader, isMining bool, logger log.Logger, ) (newBlock *types.Block, newTxs types.Transactions, newReceipt types.Receipts, retRequests types.FlatRequests, err error)
func GenesisBlockByChainName ¶
func GenesisBlockForTesting ¶
func GenesisBlockForTesting(db kv.RwDB, addr libcommon.Address, balance *big.Int, dirs datadir.Dirs, logger log.Logger) *types.Block
GenesisBlockForTesting creates and writes a block in which addr has the given wei balance.
func GenesisToBlock ¶
func GenesisToBlock(g *types.Genesis, dirs datadir.Dirs, logger log.Logger) (*types.Block, *state.IntraBlockState, error)
ToBlock creates the genesis block and writes state of a genesis specification to the given database (or discards it if nil).
func GenesisWithAccounts ¶
func GetHashFn ¶
func GetHashFn(ref *types.Header, getHeader func(hash libcommon.Hash, number uint64) *types.Header) func(n uint64) libcommon.Hash
GetHashFn returns a GetHashFunc which retrieves header hashes by number
func GnosisGenesisBlock ¶
func HoleskyGenesisBlock ¶
HoleskyGenesisBlock returns the Holesky main net genesis block.
func IntrinsicGas ¶
func IntrinsicGas(data []byte, accessList types2.AccessList, isContractCreation bool, isHomestead, isEIP2028, isEIP3860 bool, authorizationsLen uint64) (uint64, error)
IntrinsicGas computes the 'intrinsic gas' for a message with the given data. TODO: convert the input to a struct
func MainnetGenesisBlock ¶
MainnetGenesisBlock returns the Ethereum main net genesis block.
func MakeEmptyHeader ¶
func MustCommitGenesis ¶
func NewEVMBlockContext ¶
func NewEVMBlockContext(header *types.Header, blockHashFunc func(n uint64) libcommon.Hash, engine consensus.EngineReader, author *libcommon.Address, config *chain.Config) evmtypes.BlockContext
NewEVMBlockContext creates a new context for use in the EVM.
func NewEVMTxContext ¶
NewEVMTxContext creates a new transaction context for a single transaction.
func SepoliaGenesisBlock ¶
SepoliaGenesisBlock returns the Sepolia network genesis block.
func SysCallContract ¶
func SysCreate ¶
func SysCreate(contract libcommon.Address, data []byte, chainConfig *chain.Config, ibs *state.IntraBlockState, header *types.Header) (result []byte, err error)
SysCreate is a special (system) contract creation methods for genesis constructors.
func TestGenesisBlock ¶
func WriteGenesisBlock ¶
Types ¶
type BlockBuilderParameters ¶
type BlockBuilderParameters struct { PayloadId uint64 ParentHash libcommon.Hash Timestamp uint64 PrevRandao libcommon.Hash SuggestedFeeRecipient libcommon.Address Withdrawals []*types.Withdrawal // added in Shapella (EIP-4895) ParentBeaconBlockRoot *libcommon.Hash // added in Dencun (EIP-4788) }
Parameters for PoS block building See also https://github.com/ethereum/execution-apis/blob/main/src/engine/cancun.md#payloadattributesv3
type BlockGen ¶
type BlockGen struct {
// contains filtered or unexported fields
}
BlockGen creates blocks for testing. See GenerateChain for a detailed explanation.
func (*BlockGen) AddFailedTx ¶
func (b *BlockGen) AddFailedTx(tx types.Transaction)
func (*BlockGen) AddFailedTxWithChain ¶
func (*BlockGen) AddTx ¶
func (b *BlockGen) AddTx(tx types.Transaction)
AddTx adds a transaction to the generated block. If no coinbase has been set, the block's coinbase is set to the zero address.
AddTx panics if the transaction cannot be executed. In addition to the protocol-imposed limitations (gas limit, etc.), there are some further limitations on the content of transactions that can be added. Notably, contract code relying on the BLOCKHASH instruction will panic during execution.
func (*BlockGen) AddTxWithChain ¶
func (b *BlockGen) AddTxWithChain(getHeader func(hash libcommon.Hash, number uint64) *types.Header, engine consensus.Engine, txn types.Transaction)
AddTxWithChain adds a transaction to the generated block. If no coinbase has been set, the block's coinbase is set to the zero address.
AddTxWithChain panics if the transaction cannot be executed. In addition to the protocol-imposed limitations (gas limit, etc.), there are some further limitations on the content of transactions that can be added. If contract code relies on the BLOCKHASH instruction, the block in chain will be returned.
func (*BlockGen) AddUncheckedReceipt ¶
AddUncheckedReceipt forcefully adds a receipts to the block without a backing transaction.
AddUncheckedReceipt will cause consensus failures when used during real chain processing. This is best used in conjunction with raw block insertion.
func (*BlockGen) AddUncheckedTx ¶
func (b *BlockGen) AddUncheckedTx(tx types.Transaction)
AddUncheckedTx forcefully adds a transaction to the block without any validation.
AddUncheckedTx will cause consensus failures when used during real chain processing. This is best used in conjunction with raw block insertion.
func (*BlockGen) GetReceipts ¶
func (*BlockGen) OffsetTime ¶
OffsetTime modifies the time instance of a block, implicitly changing its associated difficulty. It's useful to test scenarios where forking is not tied to chain length directly.
func (*BlockGen) PrevBlock ¶
PrevBlock returns a previously generated block by number. It panics if num is greater or equal to the number of the block being generated. For index -1, PrevBlock returns the parent block given to GenerateChain.
func (*BlockGen) SetCoinbase ¶
SetCoinbase sets the coinbase of the generated block. It can be called at most once.
func (*BlockGen) SetDifficulty ¶
SetDifficulty sets the difficulty field of the generated block. This method is useful for Clique tests where the difficulty does not depend on time. For the ethash tests, please use OffsetTime, which implicitly recalculates the diff.
func (*BlockGen) SetNonce ¶
func (b *BlockGen) SetNonce(nonce types.BlockNonce)
SetNonce sets the nonce field of the generated block.
type ChainEvent ¶
type ChainHeadEvent ¶
type ChainPack ¶
type ChainPack struct { Headers []*types.Header Blocks []*types.Block Receipts []types.Receipts TopBlock *types.Block // Convenience field to access the last block }
func GenerateChain ¶
func GenerateChain(config *chain.Config, parent *types.Block, engine consensus.Engine, db kv.RwDB, n int, gen func(int, *BlockGen)) (*ChainPack, error)
GenerateChain creates a chain of n blocks. The first block's parent will be the provided parent. db is used to store intermediate states and should contain the parent's state trie.
The generator function is called with a new block generator for every block. Any transactions and uncles added to the generator become part of the block. If gen is nil, the blocks will be empty and their coinbase will be the zero address.
Blocks created by GenerateChain do not contain valid proof of work values. Inserting them into BlockChain requires use of FakePow or a similar non-validating proof of work implementation.
func (*ChainPack) NumberOfPoWBlocks ¶
type ChainSideEvent ¶
type EphemeralExecResult ¶
type EphemeralExecResult struct { StateRoot libcommon.Hash `json:"stateRoot"` TxRoot libcommon.Hash `json:"txRoot"` ReceiptRoot libcommon.Hash `json:"receiptsRoot"` LogsHash libcommon.Hash `json:"logsHash"` Bloom types.Bloom `json:"logsBloom" gencodec:"required"` Receipts types.Receipts `json:"receipts"` Rejected RejectedTxs `json:"rejected,omitempty"` Difficulty *math.HexOrDecimal256 `json:"currentDifficulty" gencodec:"required"` GasUsed math.HexOrDecimal64 `json:"gasUsed"` StateSyncReceipt *types.Receipt `json:"-"` }
func ExecuteBlockEphemerally ¶
func ExecuteBlockEphemerally( chainConfig *chain.Config, vmConfig *vm.Config, blockHashFunc func(n uint64) libcommon.Hash, engine consensus.Engine, block *types.Block, stateReader state.StateReader, stateWriter state.WriterWithChangeSets, chainReader consensus.ChainReader, getTracer func(txIndex int, txHash libcommon.Hash) (vm.EVMLogger, error), logger log.Logger, ) (*EphemeralExecResult, error)
ExecuteBlockEphemerally runs a block from provided stateReader and writes the result to the provided stateWriter
type FakeChainReader ¶
func (*FakeChainReader) BorEventsByBlock ¶
func (*FakeChainReader) BorStartEventId ¶
func (cr *FakeChainReader) BorStartEventId(hash libcommon.Hash, number uint64) uint64
func (*FakeChainReader) Config ¶
func (cr *FakeChainReader) Config() *chain.Config
Config returns the chain configuration.
func (*FakeChainReader) CurrentFinalizedHeader ¶
func (cr *FakeChainReader) CurrentFinalizedHeader() *types.Header
func (*FakeChainReader) CurrentHeader ¶
func (cr *FakeChainReader) CurrentHeader() *types.Header
func (*FakeChainReader) CurrentSafeHeader ¶
func (cr *FakeChainReader) CurrentSafeHeader() *types.Header
func (*FakeChainReader) FrozenBlocks ¶
func (cr *FakeChainReader) FrozenBlocks() uint64
func (*FakeChainReader) FrozenBorBlocks ¶
func (cr *FakeChainReader) FrozenBorBlocks() uint64
func (*FakeChainReader) GetHeaderByHash ¶
func (cr *FakeChainReader) GetHeaderByHash(hash libcommon.Hash) *types.Header
func (*FakeChainReader) GetHeaderByNumber ¶
func (cr *FakeChainReader) GetHeaderByNumber(number uint64) *types.Header
type GasPool ¶
type GasPool struct {
// contains filtered or unexported fields
}
GasPool tracks the amount of gas available during execution of the transactions in a block. The zero value is a pool with zero gas available.
func (*GasPool) AddBlobGas ¶
AddBlobGas makes blob gas available for execution.
func (*GasPool) SubBlobGas ¶
SubBlobGas deducts the given amount from the pool if enough blob gas is available and returns an error otherwise.
type Message ¶
type Message interface { From() libcommon.Address To() *libcommon.Address GasPrice() *uint256.Int FeeCap() *uint256.Int Tip() *uint256.Int Gas() uint64 BlobGas() uint64 MaxFeePerBlobGas() *uint256.Int Value() *uint256.Int Nonce() uint64 CheckNonce() bool Data() []byte AccessList() types2.AccessList BlobHashes() []libcommon.Hash Authorizations() []types.Authorization IsFree() bool }
Message represents a message sent to a contract.
type NewTxsEvent ¶
type NewTxsEvent struct{ Txs []types.Transaction }
NewTxsEvent is posted when a batch of transactions enter the transaction pool.
type RejectedTx ¶
type RejectedTxs ¶
type RejectedTxs []*RejectedTx
type RemovedLogsEvent ¶
RemovedLogsEvent is posted when a reorg happens
type StateTransition ¶
type StateTransition struct {
// contains filtered or unexported fields
}
The State Transitioning Model
A state transition is a change made when a transaction is applied to the current world state The state transitioning model does all the necessary work to work out a valid new state root.
1) Nonce handling 2) Pre pay gas 3) Create a new state object if the recipient is \0*32 4) Value transfer == If contract creation ==
4a) Attempt to run transaction data 4b) If valid, use result as code for the new state object
== end == 5) Run Script section 6) Derive new state root
func NewStateTransition ¶
func NewStateTransition(evm *vm.EVM, msg Message, gp *GasPool) *StateTransition
NewStateTransition initialises and returns a new state transition object.
func (*StateTransition) TransitionDb ¶
func (st *StateTransition) TransitionDb(refunds bool, gasBailout bool) (*evmtypes.ExecutionResult, error)
TransitionDb will transition the state by applying the current message and returning the evm execution result with following fields.
- used gas: total gas used (including gas being refunded)
- returndata: the returned data from evm
- concrete execution error: various **EVM** error which aborts the execution, e.g. ErrOutOfGas, ErrExecutionReverted
However if any consensus issue encountered, return the error directly with nil evm execution result.
type TxSenderCacher ¶
type TxSenderCacher struct {
// contains filtered or unexported fields
}
TxSenderCacher is a helper structure to concurrently ecrecover transaction senders from digital signatures on background threads.
func NewTxSenderCacher ¶
func NewTxSenderCacher(threads int) *TxSenderCacher
NewTxSenderCacher creates a new transaction sender background cacher and starts as many processing goroutines as allowed by the GOMAXPROCS on construction.
func (*TxSenderCacher) Close ¶
func (cacher *TxSenderCacher) Close()
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package asm provides support for dealing with EVM assembly instructions (e.g., disassembling them).
|
Package asm provides support for dealing with EVM assembly instructions (e.g., disassembling them). |
Package forkid implements EIP-2124 (https://eips.ethereum.org/EIPS/eip-2124).
|
Package forkid implements EIP-2124 (https://eips.ethereum.org/EIPS/eip-2124). |
Package state provides a caching layer atop the Ethereum state trie.
|
Package state provides a caching layer atop the Ethereum state trie. |
Package types contains data types related to Ethereum consensus.
|
Package types contains data types related to Ethereum consensus. |
Package vm implements the Ethereum Virtual Machine.
|
Package vm implements the Ethereum Virtual Machine. |
runtime
Package runtime provides a basic execution model for executing EVM code.
|
Package runtime provides a basic execution model for executing EVM code. |