parallel

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: GPL-3.0, LGPL-3.0, LGPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package parallel implements Block-STM parallel EVM execution.

The algorithm speculatively executes transactions in parallel, tracks read/write sets, validates for conflicts, and re-executes on abort. Designed with GPU-compatible data structures for future kernel offload.

Based on Block-STM (https://arxiv.org/abs/2203.06871) with EVM-specific optimizations: lazy beneficiary evaluation, lazy raw transfers, and GPU-native multi-version memory layout.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AcquireMemory

func AcquireMemory() *evmMemory

AcquireMemory returns a pooled EVM memory buffer, reset to empty.

func AcquireScratch

func AcquireScratch() *workerScratch

AcquireScratch returns a pooled worker scratch space.

func AcquireStack

func AcquireStack() *evmStack

AcquireStack returns a pooled EVM stack, reset to empty.

func IsGPUEligible

func IsGPUEligible(tx *types.Transaction) bool

IsGPUEligible returns true if a transaction can be dispatched to the GPU EVM kernel. GPU-eligible transactions are simple value transfers: no contract creation, no calldata (which implies no CALL/CREATE/ DELEGATECALL in the execution trace).

func PinWorker

func PinWorker()

PinWorker locks the calling goroutine to its current OS thread. This improves CPU cache locality for Block-STM workers by preventing the Go scheduler from migrating them between cores mid-execution.

Must be paired with UnpinWorker before the goroutine exits.

func PreRecoverSenders added in v0.4.0

func PreRecoverSenders(signer types.Signer, txs types.Transactions) (*SenderCache, *GPUEcrecoverStats)

PreRecoverSenders recovers all transaction sender addresses using GPU batch ecrecover. Returns a SenderCache that maps tx hash to sender address.

Call this before block execution. During EVM execution, look up senders from the cache instead of computing ecrecover per-transaction.

The GPU batches all signatures into a single kernel dispatch, processing them in parallel across GPU shader cores. Falls back to parallel goroutines on CPU if no GPU is available.

Performance context:

CPU sequential: ~334ms for 10k txs (87% of block processing)
CPU parallel (10 cores): ~48ms for 10k txs
GPU target: <5ms for 10k txs

func ReleaseMemory

func ReleaseMemory(m *evmMemory)

ReleaseMemory returns an EVM memory buffer to the pool.

func ReleaseScratch

func ReleaseScratch(w *workerScratch)

ReleaseScratch returns worker scratch space to the pool.

func ReleaseStack

func ReleaseStack(s *evmStack)

ReleaseStack returns an EVM stack to the pool.

func UnpinWorker

func UnpinWorker()

UnpinWorker releases the OS thread lock from PinWorker.

Types

type Engine

type Engine struct {
	UseGPU bool // When true, GPU dispatch paths (e.g. cgo bridge to luxcpp) are enabled where available
	// contains filtered or unexported fields
}

Engine executes a block's transactions in parallel using Block-STM.

Architecture:

  • MvMemory: multi-version data structure holding all intermediate state
  • Scheduler: collaborative task assignment with dependency tracking
  • Workers: goroutines that execute or validate transactions
  • Lazy evaluation: beneficiary + raw transfers resolved post-execution

GPU Roadmap:

Phase 1 (current): Go goroutines, MvMemory in CPU memory
Phase 2: MvMemory backed by zapdb GPU cache (hot state in GPU VRAM)
Phase 3: Scheduler atomics + validation kernel on GPU
Phase 4: EVM opcode interpreter as GPU kernel (GPUEVM)

func NewEngine

func NewEngine(concurrency int, opts ...EngineOption) *Engine

NewEngine creates a parallel execution engine. concurrency=0 means auto-detect (GOMAXPROCS).

func (*Engine) ApplyToState

func (e *Engine) ApplyToState(
	statedb *state.StateDB,
	results []ExecResult,
	txs types.Transactions,
)

ApplyToState applies finalized write sets from parallel execution to the canonical statedb in transaction order. This is called after all transactions have been validated to commit the parallel results to the real state trie.

func (*Engine) ExecuteBlock

func (e *Engine) ExecuteBlock(
	config *ethparams.ChainConfig,
	header *types.Header,
	txs types.Transactions,
	stateGetter StateGetter,
	vmFactory VMFactory,
) ([]*types.Receipt, error)

ExecuteBlock processes all transactions in a block in parallel.

Parameters:

  • config: chain configuration
  • header: block header (for coinbase, gas limit, etc.)
  • txs: transactions to execute
  • stateGetter: function to read pre-block state for a location
  • vmFactory: function to create an EVM instance for a transaction

Returns receipts in original transaction order.

func (*Engine) Hasher

func (e *Engine) Hasher() Hasher

Hasher returns the engine's batch hasher (GPU or CPU). Callers use this to accelerate trie node hashing during state root computation after parallel execution completes.

func (*Engine) Stats

func (e *Engine) Stats() StatsSnapshot

Stats returns a snapshot of execution statistics.

type EngineOption

type EngineOption func(*Engine)

EngineOption configures the parallel execution engine.

func WithGPUEcrecover added in v0.4.0

func WithGPUEcrecover() EngineOption

WithGPUEcrecover returns an EngineOption that enables GPU-accelerated sender recovery before block execution. Sender recovery itself dispatches to the luxgpu cgo bridge (which calls the C++ Metal/CUDA kernel); the trie-node hasher stays on CPU because there is no Go-native GPU keccak entry point.

type ExecResult

type ExecResult struct {
	Receipt  *types.Receipt
	ReadSet  []ReadEntry
	WriteSet []WriteEntry
	GasUsed  uint64
	Err      error

	// Blocking: if non-nil, this execution is blocked on another tx
	BlockedBy *TxIdx
}

ExecResult holds the result of executing a single transaction.

type FinishFlags

type FinishFlags uint8

FinishFlags are set when a transaction finishes execution.

const (
	FlagWroteNewLocation FinishFlags = 1 << 0 // Wrote to a location not in previous incarnation
	FlagReadDependency   FinishFlags = 1 << 1 // Read from another transaction's output
)

type GPUDispatcher

type GPUDispatcher interface {
	Available() bool
	Backend() string
	ExecuteBlock(signer types.Signer, txs []*types.Transaction, senders []common.Address) ([]GPUEVMResult, error)
}

GPUDispatcher is the interface for GPU EVM opcode dispatch. Implemented by GPUEVMDispatcher (gpu build tag) or nil (CPU-only).

type GPUEVMResult

type GPUEVMResult struct {
	GasUsed uint64
	Success bool
}

GPUEVMResult holds the result of GPU EVM execution for one transaction.

type GPUEcrecoverStats added in v0.4.0

type GPUEcrecoverStats struct {
	NumTxs     int
	Duration   time.Duration
	Backend    string  // "Metal", "CUDA", "CPU"
	Throughput float64 // signatures/second
}

GPUEcrecoverStats tracks performance metrics for sender recovery.

type Hasher

type Hasher interface {
	// BatchHash computes Keccak-256 hashes for a batch of inputs.
	// Returns one hash per input, in the same order.
	BatchHash(inputs [][]byte) []common.Hash

	// Backend returns the name of the compute backend ("Metal", "CUDA", "CPU").
	Backend() string
}

Hasher computes Keccak-256 hashes for trie node batches. The CPU implementation is the only one in Go; GPU keccak lives in luxcpp (Metal/CUDA kernels) and is reached through the luxgpu cgo bridge, not through a Go-native hasher.

func NewCPUHasher

func NewCPUHasher() Hasher

NewCPUHasher returns a Hasher that uses parallel CPU goroutines.

type LocationHash

type LocationHash uint64

LocationHash is a pre-computed hash of a MemoryLocation for fast lookups. Uses FxHash-style fast hashing — the last 8 bytes of the address.

type LocationType

type LocationType uint8

LocationType identifies the kind of state access. Balance and nonce are separate types to prevent conflation — writing one must never clobber the other in MvMemory.

const (
	LocationBalance  LocationType = 0 // Account balance only
	LocationNonce    LocationType = 1 // Account nonce only
	LocationCodeHash LocationType = 2 // Contract code hash
	LocationStorage  LocationType = 3 // Storage slot
)

type MemoryLocation

type MemoryLocation struct {
	Address common.Address // 20 bytes
	Type    LocationType   // 1 byte
	Slot    common.Hash    // 32 bytes (only for LocationStorage)
}

MemoryLocation uniquely identifies a piece of EVM state. Comparable in Go — used directly as map key in MvMemory to prevent hash-collision attacks (see F02). LocationHash is retained for GPU kernel sharding hints only.

func (*MemoryLocation) Hash

func (loc *MemoryLocation) Hash() LocationHash

Hash computes the LocationHash for fast map lookups.

type MemoryValue

type MemoryValue struct {
	Type    ValueType
	Balance common.Hash // 32 bytes: absolute or delta (LocationBalance only)
	Nonce   uint64      // LocationNonce only
	Storage common.Hash // 32 bytes: for LocationStorage and LocationCodeHash
}

MemoryValue is the value stored in the multi-version data structure. Each LocationType uses only the relevant field:

  • LocationBalance → Balance
  • LocationNonce → Nonce
  • LocationCodeHash → Storage (code hash stored as hash)
  • LocationStorage → Storage

type MvEntry

type MvEntry struct {
	TxIdx       uint32 // 0 = empty, N+1 = written by tx N
	Incarnation uint32
	IsEstimate  bool // true = placeholder after abort
	Value       MemoryValue
}

MvEntry is one version of a value in the multi-version memory. 0 = empty, non-zero TxIdx+1 = written by that tx.

type MvMemory

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

MvMemory is the multi-version memory structure for Block-STM.

Each memory location maps to a version chain: an ordered set of entries indexed by TxIdx. A read for transaction N finds the highest entry with TxIdx < N. This is the core data structure enabling optimistic parallel execution.

GPU Design: The version chains are stored as fixed-size arrays indexed by TxIdx (max block_size entries per location). This maps directly to GPU shared memory / global memory with atomic CAS for concurrent access. On unified memory (Metal/Apple Silicon), the CPU accesses these arrays directly in GPU VRAM via buffer_get_host_ptr().

func NewMvMemory

func NewMvMemory(blockSize uint32) *MvMemory

NewMvMemory creates a new multi-version memory for a block.

func (*MvMemory) ClearTxSets

func (m *MvMemory) ClearTxSets(txIdx TxIdx)

ClearTxSets clears the read/write sets for a transaction (before re-execution).

func (*MvMemory) ConvertWritesToEstimates

func (m *MvMemory) ConvertWritesToEstimates(txIdx TxIdx)

ConvertWritesToEstimates replaces all writes by a transaction with ESTIMATE markers. Called when a transaction fails validation — this cascades aborts to dependent txs.

func (*MvMemory) LazyLocations

func (m *MvMemory) LazyLocations() []MemoryLocation

LazyLocations returns all locations marked for lazy evaluation.

func (*MvMemory) MarkLazy

func (m *MvMemory) MarkLazy(loc MemoryLocation)

MarkLazy marks a location as needing lazy post-evaluation.

func (*MvMemory) PreAllocateEstimates

func (m *MvMemory) PreAllocateEstimates(loc MemoryLocation)

PreAllocateEstimates pre-populates a location with ESTIMATE markers for all transaction indices. Used for the beneficiary address — since every tx pays gas to coinbase, this prevents false conflicts.

func (*MvMemory) Read

func (m *MvMemory) Read(loc MemoryLocation, txIdx TxIdx) (MvEntry, bool)

Read finds the closest version written by a transaction with index < txIdx. Returns the entry and whether it was found. If an ESTIMATE marker is found, returns (entry, true) with IsEstimate=true, signaling the caller to block on that transaction.

func (*MvMemory) RecordReadSet

func (m *MvMemory) RecordReadSet(txIdx TxIdx, reads []ReadEntry)

RecordReadSet stores the read set for a transaction (called after execution).

func (*MvMemory) RecordWriteSet

func (m *MvMemory) RecordWriteSet(txIdx TxIdx, incarnation uint32, writes []WriteEntry)

RecordWriteSet stores the write set and applies writes to MvMemory.

func (*MvMemory) ValidateReadSet

func (m *MvMemory) ValidateReadSet(txIdx TxIdx) bool

ValidateReadSet re-checks all reads made by a transaction. Returns true if all reads are still valid (same writer, same incarnation).

func (*MvMemory) Write

func (m *MvMemory) Write(loc MemoryLocation, txIdx TxIdx, incarnation uint32, value MemoryValue)

Write records a value written by a transaction.

func (*MvMemory) WriteEstimate

func (m *MvMemory) WriteEstimate(loc MemoryLocation, txIdx TxIdx)

WriteEstimate marks a location with an ESTIMATE placeholder. This is called when a transaction is aborted — it signals to higher transactions that this value is being recomputed.

type ParallelStateDB

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

ParallelStateDB wraps a base state.StateDB for one transaction in parallel mode. It intercepts reads through MvMemory first (for values written by earlier transactions in the same block) and falls back to the base statedb. Writes are buffered locally and flushed as a WriteSet after execution.

GPU Roadmap: This is the layer that would be replaced by GPU kernels. Each "read" becomes a GPU hash table lookup in MvMemory (in GPU VRAM). Each "write" becomes a GPU atomic store.

func NewParallelStateDB

func NewParallelStateDB(
	txIdx TxIdx,
	incarnation uint32,
	mvMemory *MvMemory,
	stateGetter StateGetter,
	beneficiaryLoc MemoryLocation,
	base *state.StateDB,
) *ParallelStateDB

NewParallelStateDB creates a state accessor for one transaction.

func (*ParallelStateDB) AccessEvents

func (s *ParallelStateDB) AccessEvents() *state.AccessEvents

func (*ParallelStateDB) AddAddressToAccessList

func (s *ParallelStateDB) AddAddressToAccessList(addr common.Address)

func (*ParallelStateDB) AddBalance

func (s *ParallelStateDB) AddBalance(addr common.Address, amount *uint256.Int, reason tracing.BalanceChangeReason) uint256.Int

func (*ParallelStateDB) AddLog

func (s *ParallelStateDB) AddLog(l *types.Log)

func (*ParallelStateDB) AddPreimage

func (s *ParallelStateDB) AddPreimage(hash common.Hash, preimage []byte)

func (*ParallelStateDB) AddRefund

func (s *ParallelStateDB) AddRefund(gas uint64)

func (*ParallelStateDB) AddSlotToAccessList

func (s *ParallelStateDB) AddSlotToAccessList(addr common.Address, slot common.Hash)

func (*ParallelStateDB) AddressInAccessList

func (s *ParallelStateDB) AddressInAccessList(addr common.Address) bool

func (*ParallelStateDB) CreateAccount

func (s *ParallelStateDB) CreateAccount(addr common.Address)

func (*ParallelStateDB) CreateContract

func (s *ParallelStateDB) CreateContract(addr common.Address)

func (*ParallelStateDB) Empty

func (s *ParallelStateDB) Empty(addr common.Address) bool

func (*ParallelStateDB) Exist

func (s *ParallelStateDB) Exist(addr common.Address) bool

func (*ParallelStateDB) Finalise

func (s *ParallelStateDB) Finalise(deleteEmptyObjects bool)

Finalise is a no-op for ParallelStateDB. State finalization happens post-validation via ApplyToState on the canonical statedb.

func (*ParallelStateDB) FinalizeParallel

func (s *ParallelStateDB) FinalizeParallel() ([]ReadEntry, []WriteEntry)

FinalizeParallel returns the accumulated read/write sets for Block-STM validation. This is called after EVM execution completes for this tx.

func (*ParallelStateDB) GetBalance

func (s *ParallelStateDB) GetBalance(addr common.Address) *uint256.Int

func (*ParallelStateDB) GetCode

func (s *ParallelStateDB) GetCode(addr common.Address) []byte

func (*ParallelStateDB) GetCodeHash

func (s *ParallelStateDB) GetCodeHash(addr common.Address) common.Hash

func (*ParallelStateDB) GetCodeSize

func (s *ParallelStateDB) GetCodeSize(addr common.Address) int

func (*ParallelStateDB) GetCommittedState

func (s *ParallelStateDB) GetCommittedState(addr common.Address, hash common.Hash) common.Hash

func (*ParallelStateDB) GetNonce

func (s *ParallelStateDB) GetNonce(addr common.Address) uint64

func (*ParallelStateDB) GetRefund

func (s *ParallelStateDB) GetRefund() uint64

func (*ParallelStateDB) GetState

func (s *ParallelStateDB) GetState(addr common.Address, slot common.Hash) common.Hash

func (*ParallelStateDB) GetStateAndCommittedState

func (s *ParallelStateDB) GetStateAndCommittedState(addr common.Address, key common.Hash) (common.Hash, common.Hash)

func (*ParallelStateDB) GetStorageRoot

func (s *ParallelStateDB) GetStorageRoot(addr common.Address) common.Hash

func (*ParallelStateDB) GetTransientState

func (s *ParallelStateDB) GetTransientState(addr common.Address, key common.Hash) common.Hash

func (*ParallelStateDB) HasSelfDestructed

func (s *ParallelStateDB) HasSelfDestructed(addr common.Address) bool

func (*ParallelStateDB) Logs

func (s *ParallelStateDB) Logs() []*types.Log

func (*ParallelStateDB) PointCache

func (s *ParallelStateDB) PointCache() *utils.PointCache

func (*ParallelStateDB) Prepare

func (s *ParallelStateDB) Prepare(rules ethparams.Rules, sender, coinbase common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList)

func (*ParallelStateDB) RevertToSnapshot

func (s *ParallelStateDB) RevertToSnapshot(revid int)

func (*ParallelStateDB) SelfDestruct

func (s *ParallelStateDB) SelfDestruct(addr common.Address) uint256.Int

func (*ParallelStateDB) SelfDestruct6780

func (s *ParallelStateDB) SelfDestruct6780(addr common.Address) (uint256.Int, bool)

func (*ParallelStateDB) SetCode

func (s *ParallelStateDB) SetCode(addr common.Address, code []byte, reason tracing.CodeChangeReason) []byte

func (*ParallelStateDB) SetNonce

func (s *ParallelStateDB) SetNonce(addr common.Address, nonce uint64, reason tracing.NonceChangeReason)

SetNonce writes a nonce value to the LocationNonce location only. Balance is stored at a separate LocationBalance location — no conflation.

func (*ParallelStateDB) SetState

func (s *ParallelStateDB) SetState(addr common.Address, slot, value common.Hash) common.Hash

func (*ParallelStateDB) SetTransientState

func (s *ParallelStateDB) SetTransientState(addr common.Address, key, value common.Hash)

func (*ParallelStateDB) SlotInAccessList

func (s *ParallelStateDB) SlotInAccessList(addr common.Address, slot common.Hash) (bool, bool)

func (*ParallelStateDB) Snapshot

func (s *ParallelStateDB) Snapshot() int

func (*ParallelStateDB) SubBalance

func (s *ParallelStateDB) SubBalance(addr common.Address, amount *uint256.Int, reason tracing.BalanceChangeReason) uint256.Int

func (*ParallelStateDB) SubRefund

func (s *ParallelStateDB) SubRefund(gas uint64)

func (*ParallelStateDB) TxHash

func (s *ParallelStateDB) TxHash() common.Hash

func (*ParallelStateDB) Witness

func (s *ParallelStateDB) Witness() *stateless.Witness

type ReadEntry

type ReadEntry struct {
	Location MemoryLocation
	Origin   ReadOrigin
}

ReadEntry is one entry in a transaction's read set.

type ReadOrigin

type ReadOrigin struct {
	FromMvMemory bool      // true = read from MvMemory, false = read from storage
	Version      TxVersion // if FromMvMemory, the version that wrote the value
}

ReadOrigin records where a value was read from.

type Scheduler

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

Scheduler implements collaborative task assignment for Block-STM.

Workers compete for tasks by atomically incrementing execution_idx and validation_idx. The scheduler prioritizes validation over execution to minimize wasted re-executions. Dependencies between transactions are tracked: when a blocked transaction's dependency completes, it is automatically re-scheduled.

GPU Design: execution_idx and validation_idx map directly to GPU atomics. The status array (one per tx) maps to GPU shared memory with atomic CAS. Dependency tracking uses fixed-size arrays indexed by TxIdx.

func NewScheduler

func NewScheduler(blockSize uint32) *Scheduler

NewScheduler creates a scheduler for a block with the given number of transactions.

func (*Scheduler) Abort

func (s *Scheduler) Abort()

Abort signals a fatal error — all workers should stop.

func (*Scheduler) AddDependency

func (s *Scheduler) AddDependency(txIdx TxIdx, blockingTx TxIdx)

AddDependency records that txIdx is blocked on blockingTx. When blockingTx completes, txIdx will be re-scheduled.

CRITICAL: We must register the dependency BEFORE setting status to Aborting. Otherwise resumeDependents could drain the list before we add to it, leaving the tx stuck in Aborting forever. After registration, we check if blockingTx already completed — if so, we self-resume immediately.

func (*Scheduler) Done

func (s *Scheduler) Done() bool

Done returns true when all transactions are validated.

func (*Scheduler) FinishExecution

func (s *Scheduler) FinishExecution(version TxVersion, flags FinishFlags)

FinishExecution marks a transaction as executed and schedules validation.

func (*Scheduler) FinishValidation

func (s *Scheduler) FinishValidation(version TxVersion, aborted bool)

FinishValidation marks a transaction as validated. If aborted is true, the transaction will be re-executed.

func (*Scheduler) IsAborted

func (s *Scheduler) IsAborted() bool

IsAborted returns true if a fatal error occurred.

func (*Scheduler) NextTask

func (s *Scheduler) NextTask() Task

NextTask returns the next task for a worker to execute. Returns TaskNone when all transactions are validated (termination).

func (*Scheduler) TryValidationAbort

func (s *Scheduler) TryValidationAbort(version TxVersion) bool

TryValidationAbort attempts to abort a transaction that failed validation. Returns true if the abort was successful.

type SenderCache added in v0.4.0

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

SenderCache is a concurrent map of pre-recovered transaction senders. Used to populate the EVM's sender cache before block execution.

func NewSenderCache added in v0.4.0

func NewSenderCache(capacity int) *SenderCache

NewSenderCache creates a new sender cache.

func (*SenderCache) Get added in v0.4.0

func (c *SenderCache) Get(txHash common.Hash) (common.Address, bool)

Get retrieves a cached sender address for a transaction hash.

func (*SenderCache) Set added in v0.4.0

func (c *SenderCache) Set(txHash common.Hash, sender common.Address)

Set stores a sender address for a transaction hash.

type SenderRecovery added in v0.4.0

type SenderRecovery struct {
	Sender common.Address
	Valid  bool
}

SenderRecovery holds a pre-recovered transaction sender address.

type StateGetter

type StateGetter func(loc MemoryLocation) (MemoryValue, bool)

StateGetter reads pre-block state for a memory location. This is the interface to the underlying database (zapdb with GPU cache).

type Stats

type Stats struct {
	TotalTxs      uint64
	Executions    atomic.Uint64 // Total execution attempts (including re-executions)
	Validations   atomic.Uint64
	Aborts        atomic.Uint64 // Validation failures causing re-execution
	LazyAddresses atomic.Uint64 // Addresses evaluated lazily
	FellBack      bool          // True if fell back to sequential

	// GPU opcode dispatch metrics
	GPUEligible atomic.Uint64 // Transactions eligible for GPU dispatch
	GPUExecuted atomic.Uint64 // Transactions actually dispatched to GPU
	GPUFallback atomic.Uint64 // Transactions that fell back from GPU to Go EVM
}

Stats tracks parallel execution statistics. Not safe to copy — use StatsSnapshot for value semantics.

type StatsSnapshot

type StatsSnapshot struct {
	TotalTxs    uint64
	Executions  uint64
	Validations uint64
	Aborts      uint64
	FellBack    bool

	// GPU opcode dispatch metrics
	GPUEligible uint64
	GPUExecuted uint64
	GPUFallback uint64
}

StatsSnapshot is a copy-safe snapshot of Stats.

type Task

type Task struct {
	Type    TaskType
	Version TxVersion
}

Task is a unit of work for a parallel worker.

type TaskType

type TaskType uint8

TaskType identifies the kind of work.

const (
	TaskNone       TaskType = 0
	TaskExecution  TaskType = 1
	TaskValidation TaskType = 2
)

type TxIdx

type TxIdx uint32

TxIdx is a transaction index within the block.

type TxReadWriteSet

type TxReadWriteSet struct {
	ReadSet  []ReadEntry
	WriteSet []WriteEntry
	// contains filtered or unexported fields
}

TxReadWriteSet holds the read and write sets for one transaction.

type TxState

type TxState struct {
	Status      TxStatus
	Incarnation uint32
}

TxState holds the mutable state of a transaction in the scheduler.

type TxStatus

type TxStatus uint8

TxStatus tracks the execution state of a transaction.

const (
	StatusReadyToExecute TxStatus = 0
	StatusExecuting      TxStatus = 1
	StatusExecuted       TxStatus = 2
	StatusValidated      TxStatus = 3
	StatusAborting       TxStatus = 4
)

type TxVersion

type TxVersion struct {
	TxIdx       TxIdx
	Incarnation uint32
}

TxVersion is (TxIdx, Incarnation) — identifies a specific execution attempt.

type VMFactory

type VMFactory func(txIdx TxIdx) (*vm.EVM, error)

VMFactory creates an EVM instance for executing a transaction. Each worker gets its own EVM instance (no sharing).

type ValueType

type ValueType uint8

ValueType identifies the kind of value.

const (
	ValueAbsolute     ValueType = 0 // Full value (balance, nonce, storage)
	ValueLazyCredit   ValueType = 1 // Delta: +balance (beneficiary, transfer recipient)
	ValueLazyDebit    ValueType = 2 // Delta: -balance, +1 nonce (transfer sender)
	ValueSelfDestruct ValueType = 3 // Account destroyed
)

type WriteEntry

type WriteEntry struct {
	Location MemoryLocation
	Value    MemoryValue
}

WriteEntry is one entry in a transaction's write set.

Jump to

Keyboard shortcuts

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