executor

package
v0.0.0-...-a3f79bb Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: LGPL-3.0 Imports: 40 Imported by: 0

Documentation

Overview

Package executor is a generated GoMock package.

Package executor is a generated GoMock package.

Package executor is a generated GoMock package.

Package executor is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AtBlock

func AtBlock[T any](block int) gomock.Matcher

AtBlock matches executor.State instances with the given block.

func AtTransaction

func AtTransaction[T any](block int, transaction int) gomock.Matcher

AtBlock matches executor.State instances with the given block and transaction number.

func Gt

func Gt(limit float64) gomock.Matcher

Gt matches every value greater than the given limit.

func Lt

func Lt(limit float64) gomock.Matcher

Lt matches every value less than the given limit.

func MakeEthTestProcessor

func MakeEthTestProcessor(cfg *utils.Config) (*ethTestProcessor, error)

MakeEthTestProcessor creates an executor.Processor which processes transaction created from ethereum test package.

func MatchRate

func MatchRate(constraint gomock.Matcher, name string) gomock.Matcher

func RunUtilPrimer

func RunUtilPrimer[T any](params Params, extensions []Extension[T], aidaDb db.BaseDB) (err error)

func WithError

func WithError(err error) gomock.Matcher

func WithState

func WithState(state state.StateDB) gomock.Matcher

WithState matches executor.State instances with the given state.

func WithSubstate

func WithSubstate(substate *substate.Substate) gomock.Matcher

WithSubstate matches executor.State instances with the given substate.

Types

type ArchiveDbTxProcessor

type ArchiveDbTxProcessor struct {
	*TxProcessor
}

func MakeArchiveDbTxProcessor

func MakeArchiveDbTxProcessor(cfg *utils.Config) (*ArchiveDbTxProcessor, error)

MakeArchiveDbTxProcessor creates a executor.Processor which processes transaction into ARCHIVE StateDb.

func (*ArchiveDbTxProcessor) Process

func (p *ArchiveDbTxProcessor) Process(state State[txcontext.TxContext], ctx *Context) error

Process transaction inside state into given ARCHIVE StateDb

type Consumer

type Consumer[T any] func(TransactionInfo[T]) error

Consumer is a type alias for the type of function to which payload information can be forwarded by a Provider.

type Context

type Context struct {
	// State is an optional StateDB instance manipulated during by the processor
	// and extensions of a block-range execution.
	State state.StateDB

	// Archive represents a historical State
	Archive state.NonCommittableStateDB

	// StateDbPath contains path to working stateDb directory
	StateDbPath string

	// AidaDb is an optional LevelDb readonly database containing data for testing StateDb (i.e. state hashes).
	AidaDb db.BaseDB

	// ErrorInput is used if continue-on-failure is enabled or if log-file is definer so that at the end
	// of the run, we log all errors into a file. This chanel should be only used for processing errors,
	// hence any non-fatal errors. Any fatal should still be returned so that the app ends.
	ErrorInput chan error

	// ExecutionResult is set after the execution.
	// It is used for validation and gas measurements.
	ExecutionResult txcontext.Result
}

Context summarizes context data for the current execution and is passed as a mutable object to Processors and Extensions. Either max decide to modify its content to implement their respective features.

type Executor

type Executor[T any] interface {
	// Run feeds all transactions of the given block range [from,to) to the
	// provided processor and performs the needed call-backs on the provided
	// extensions. If a processor or an extension returns an error, execution
	// stops with the reported error.
	// PreXXX events are delivered to the extensions in the given order, while
	// PostXXX events are delivered in reverse order. If any of the extensions
	// reports an error during processing of an event, the same event is still
	// delivered to the remaining extensions before processing is aborted.
	Run(params Params, processor Processor[T], extensions []Extension[T], aidaDb db.BaseDB) error
}

Executor is an entity coordinating the execution of transactions within a requested block range. It implements the decorator pattern, allowing extensions to monitor and annotate the execution at various hook-in points.

When running sequentially, the general execution is structured as follows:

PreRun()
for each block {
   PreBlock()
   for each transaction {
       PreTransaction()
       Processor.Process(transaction)
       PostTransaction()
   }
   PostBlock()
}
PostRun()

When running with multiple workers on TransactionLevel granularity, the execution is structures like this:

PreRun()
for transaction in parallel {
    PreTransaction()
    Processor.Process(transaction)
    PostTransaction()
}
PostRun()

Note that there are no block boundary events in the parallel mode.

When running with multiple workers on BlockLevel granularity, the execution is structures like this:

PreRun()
for block in parallel {
   PreBlock()
   for each transaction {
       PreTransaction()
       Processor.Process(transaction)
       PostTransaction()
   }
   PostBlock()
}
PostRun()

Note that every worker has its own Context so any manipulation with this variable does not need to be thread safe.

Each PreXXX() and PostXXX() is a hook-in point at which extensions may track information and/or interfere with the execution. For more details on the specific call-backs see the Extension interface below.

func NewExecutor

func NewExecutor[T any](provider Provider[T], logLevel string) Executor[T]

NewExecutor creates a new executor based on the given provider.

type Extension

type Extension[T any] interface {
	// PreRun is called before the begin of the execution of a block range,
	// even if the range is empty. The provided state lists the initial block
	// of the range. For every run, PreRun is only called once, before any
	// other call-back. If an error is reported, execution will abort after
	// PreRun has been called on all registered Extensions.
	PreRun(State[T], *Context) error

	// PostRun is guranteed to be called at the end of each execution. An
	// execution may end successfully, if no exception has been produced by
	// the Processor or any Extension, or in a failure state, if errors
	// have been produced. In case of a successful execution, the provided
	// state lists the first non-executiond block, while in an error case
	// it references the last transaction attempted to be processed. Also,
	// the second parameter contains the error causing the abort.
	PostRun(State[T], *Context, error) error

	// PreBlock is called once before the begin of processing a block with
	// the state containing the number of the Block. This function is not
	// called when running with multiple workers.
	PreBlock(State[T], *Context) error

	// PostBlock is called once after the end of processing a block with
	// the state containing the number of the Block and the last transaction
	// processed in the block. This function is not called when running with
	// multiple workers.
	PostBlock(State[T], *Context) error

	// PreTransaction is called once before each transaction with the state
	// listing the block number, the transaction number, and the substate data
	// providing the input for the subsequent execution of the transaction.
	// When running with multiple workers, this function may be called
	// concurrently, and must thus be thread safe.
	PreTransaction(State[T], *Context) error

	// PostTransaction is called once after each transaction with the state
	// listing the block number, the transaction number, and the substate data
	// providing the input for the subsequent execution of the transaction.
	// When running with multiple workers, this function may be called
	// concurrently, and must thus be thread safe.
	PostTransaction(State[T], *Context) error
}

Extension is an interface for modulare annotations to the execution of a range of transactions. During various stages, methods of extensions are called, enabling them to monitor and/or interfere with the execution. Since blocks may be processed in parallel, callbacks are generally required to be thread safe (with the exception of the Pre-/ and PostRun) callback.

type LiveDbTxProcessor

type LiveDbTxProcessor struct {
	*TxProcessor
}

func MakeLiveDbTxProcessor

func MakeLiveDbTxProcessor(cfg *utils.Config) (*LiveDbTxProcessor, error)

MakeLiveDbTxProcessor creates a executor.Processor which processes transaction into LIVE StateDb.

func (*LiveDbTxProcessor) Process

func (p *LiveDbTxProcessor) Process(state State[txcontext.TxContext], ctx *Context) error

Process transaction inside state into given LIVE StateDb

type MockExecutor

type MockExecutor[T any] struct {
	// contains filtered or unexported fields
}

MockExecutor is a mock of Executor interface.

func NewMockExecutor

func NewMockExecutor[T any](ctrl *gomock.Controller) *MockExecutor[T]

NewMockExecutor creates a new mock instance.

func (*MockExecutor[T]) EXPECT

func (m *MockExecutor[T]) EXPECT() *MockExecutorMockRecorder[T]

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockExecutor[T]) Run

func (m *MockExecutor[T]) Run(params Params, processor Processor[T], extensions []Extension[T], aidaDb db.BaseDB) error

Run mocks base method.

type MockExecutorMockRecorder

type MockExecutorMockRecorder[T any] struct {
	// contains filtered or unexported fields
}

MockExecutorMockRecorder is the mock recorder for MockExecutor.

func (*MockExecutorMockRecorder[T]) Run

func (mr *MockExecutorMockRecorder[T]) Run(params, processor, extensions, aidaDb any) *gomock.Call

Run indicates an expected call of Run.

type MockExtension

type MockExtension[T any] struct {
	// contains filtered or unexported fields
}

MockExtension is a mock of Extension interface.

func NewMockExtension

func NewMockExtension[T any](ctrl *gomock.Controller) *MockExtension[T]

NewMockExtension creates a new mock instance.

func (*MockExtension[T]) EXPECT

func (m *MockExtension[T]) EXPECT() *MockExtensionMockRecorder[T]

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockExtension[T]) PostBlock

func (m *MockExtension[T]) PostBlock(arg0 State[T], arg1 *Context) error

PostBlock mocks base method.

func (*MockExtension[T]) PostRun

func (m *MockExtension[T]) PostRun(arg0 State[T], arg1 *Context, arg2 error) error

PostRun mocks base method.

func (*MockExtension[T]) PostTransaction

func (m *MockExtension[T]) PostTransaction(arg0 State[T], arg1 *Context) error

PostTransaction mocks base method.

func (*MockExtension[T]) PreBlock

func (m *MockExtension[T]) PreBlock(arg0 State[T], arg1 *Context) error

PreBlock mocks base method.

func (*MockExtension[T]) PreRun

func (m *MockExtension[T]) PreRun(arg0 State[T], arg1 *Context) error

PreRun mocks base method.

func (*MockExtension[T]) PreTransaction

func (m *MockExtension[T]) PreTransaction(arg0 State[T], arg1 *Context) error

PreTransaction mocks base method.

type MockExtensionMockRecorder

type MockExtensionMockRecorder[T any] struct {
	// contains filtered or unexported fields
}

MockExtensionMockRecorder is the mock recorder for MockExtension.

func (*MockExtensionMockRecorder[T]) PostBlock

func (mr *MockExtensionMockRecorder[T]) PostBlock(arg0, arg1 any) *gomock.Call

PostBlock indicates an expected call of PostBlock.

func (*MockExtensionMockRecorder[T]) PostRun

func (mr *MockExtensionMockRecorder[T]) PostRun(arg0, arg1, arg2 any) *gomock.Call

PostRun indicates an expected call of PostRun.

func (*MockExtensionMockRecorder[T]) PostTransaction

func (mr *MockExtensionMockRecorder[T]) PostTransaction(arg0, arg1 any) *gomock.Call

PostTransaction indicates an expected call of PostTransaction.

func (*MockExtensionMockRecorder[T]) PreBlock

func (mr *MockExtensionMockRecorder[T]) PreBlock(arg0, arg1 any) *gomock.Call

PreBlock indicates an expected call of PreBlock.

func (*MockExtensionMockRecorder[T]) PreRun

func (mr *MockExtensionMockRecorder[T]) PreRun(arg0, arg1 any) *gomock.Call

PreRun indicates an expected call of PreRun.

func (*MockExtensionMockRecorder[T]) PreTransaction

func (mr *MockExtensionMockRecorder[T]) PreTransaction(arg0, arg1 any) *gomock.Call

PreTransaction indicates an expected call of PreTransaction.

type MockProcessor

type MockProcessor[T any] struct {
	// contains filtered or unexported fields
}

MockProcessor is a mock of Processor interface.

func NewMockProcessor

func NewMockProcessor[T any](ctrl *gomock.Controller) *MockProcessor[T]

NewMockProcessor creates a new mock instance.

func (*MockProcessor[T]) EXPECT

func (m *MockProcessor[T]) EXPECT() *MockProcessorMockRecorder[T]

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockProcessor[T]) Process

func (m *MockProcessor[T]) Process(arg0 State[T], arg1 *Context) error

Process mocks base method.

type MockProcessorMockRecorder

type MockProcessorMockRecorder[T any] struct {
	// contains filtered or unexported fields
}

MockProcessorMockRecorder is the mock recorder for MockProcessor.

func (*MockProcessorMockRecorder[T]) Process

func (mr *MockProcessorMockRecorder[T]) Process(arg0, arg1 any) *gomock.Call

Process indicates an expected call of Process.

type MockProvider

type MockProvider[T any] struct {
	// contains filtered or unexported fields
}

MockProvider is a mock of Provider interface.

func NewMockProvider

func NewMockProvider[T any](ctrl *gomock.Controller) *MockProvider[T]

NewMockProvider creates a new mock instance.

func (*MockProvider[T]) Close

func (m *MockProvider[T]) Close()

Close mocks base method.

func (*MockProvider[T]) EXPECT

func (m *MockProvider[T]) EXPECT() *MockProviderMockRecorder[T]

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockProvider[T]) Run

func (m *MockProvider[T]) Run(from, to int, consumer Consumer[T]) error

Run mocks base method.

type MockProviderMockRecorder

type MockProviderMockRecorder[T any] struct {
	// contains filtered or unexported fields
}

MockProviderMockRecorder is the mock recorder for MockProvider.

func (*MockProviderMockRecorder[T]) Close

func (mr *MockProviderMockRecorder[T]) Close() *gomock.Call

Close indicates an expected call of Close.

func (*MockProviderMockRecorder[T]) Run

func (mr *MockProviderMockRecorder[T]) Run(from, to, consumer any) *gomock.Call

Run indicates an expected call of Run.

type MockRPCReqConsumer

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

MockRPCReqConsumer is a mock of RPCReqConsumer interface.

func NewMockRPCReqConsumer

func NewMockRPCReqConsumer(ctrl *gomock.Controller) *MockRPCReqConsumer

NewMockRPCReqConsumer creates a new mock instance.

func (*MockRPCReqConsumer) Consume

func (m *MockRPCReqConsumer) Consume(block, transaction int, req *rpc.RequestAndResults) error

Consume mocks base method.

func (*MockRPCReqConsumer) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

type MockRPCReqConsumerMockRecorder

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

MockRPCReqConsumerMockRecorder is the mock recorder for MockRPCReqConsumer.

func (*MockRPCReqConsumerMockRecorder) Consume

func (mr *MockRPCReqConsumerMockRecorder) Consume(block, transaction, req any) *gomock.Call

Consume indicates an expected call of Consume.

type MockTxConsumer

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

MockTxConsumer is a mock of TxConsumer interface.

func NewMockTxConsumer

func NewMockTxConsumer(ctrl *gomock.Controller) *MockTxConsumer

NewMockTxConsumer creates a new mock instance.

func (*MockTxConsumer) Consume

func (m *MockTxConsumer) Consume(block, transaction int, substate txcontext.TxContext) error

Consume mocks base method.

func (*MockTxConsumer) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

type MockTxConsumerMockRecorder

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

MockTxConsumerMockRecorder is the mock recorder for MockTxConsumer.

func (*MockTxConsumerMockRecorder) Consume

func (mr *MockTxConsumerMockRecorder) Consume(block, transaction, substate any) *gomock.Call

Consume indicates an expected call of Consume.

type MockexecutionResult

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

MockexecutionResult is a mock of executionResult interface.

func NewMockexecutionResult

func NewMockexecutionResult(ctrl *gomock.Controller) *MockexecutionResult

NewMockexecutionResult creates a new mock instance.

func (*MockexecutionResult) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockexecutionResult) Failed

func (m *MockexecutionResult) Failed() bool

Failed mocks base method.

func (*MockexecutionResult) GetError

func (m *MockexecutionResult) GetError() error

GetError mocks base method.

func (*MockexecutionResult) GetGasUsed

func (m *MockexecutionResult) GetGasUsed() uint64

GetGasUsed mocks base method.

func (*MockexecutionResult) Return

func (m *MockexecutionResult) Return() []byte

Return mocks base method.

type MockexecutionResultMockRecorder

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

MockexecutionResultMockRecorder is the mock recorder for MockexecutionResult.

func (*MockexecutionResultMockRecorder) Failed

Failed indicates an expected call of Failed.

func (*MockexecutionResultMockRecorder) GetError

GetError indicates an expected call of GetError.

func (*MockexecutionResultMockRecorder) GetGasUsed

func (mr *MockexecutionResultMockRecorder) GetGasUsed() *gomock.Call

GetGasUsed indicates an expected call of GetGasUsed.

func (*MockexecutionResultMockRecorder) Return

Return indicates an expected call of Return.

type Mockprocessor

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

Mockprocessor is a mock of processor interface.

func NewMockprocessor

func NewMockprocessor(ctrl *gomock.Controller) *Mockprocessor

NewMockprocessor creates a new mock instance.

func (*Mockprocessor) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

type MockprocessorMockRecorder

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

MockprocessorMockRecorder is the mock recorder for Mockprocessor.

type ParallelismGranularity

type ParallelismGranularity byte

ParallelismGranularity determines isolation level if same archive is kept for all transactions in block or for each is created new one

const (
	TransactionLevel ParallelismGranularity = iota // Post and Pre Transactions() need to be Thread-Safe
	BlockLevel
)

type Params

type Params struct {
	// From is the beginning of the range of blocks to be processed (inclusive).
	From int
	// To is the end of the range of blocks to be processed (exclusive).
	To int
	// State is an optional StateDB instance to be made available to the
	// processor and extensions during execution.
	State state.StateDB
	// NumWorkers is the number of concurrent goroutines to be used to
	// process blocks. If the number of workers is 1, transactions are
	// guranteed to be processed in-order. If it is > 1 no fixed order
	// is guranteed. Any number <= 1 is considered to be 1, thus the default
	// value of 0 is valid.
	NumWorkers int
	// ParallelismGranularity determines whether parallelism is done on block or transaction level
	ParallelismGranularity ParallelismGranularity
}

Params summarizes input parameters for a run of the executor.

type Processor

type Processor[T any] interface {
	// Process is called on each transaction in the range of blocks covered
	// by an Executor run. When running with multiple workers, the Process
	// function is required to be thread safe.
	Process(State[T], *Context) error
}

Processor is an interface for the entity to which an executor is feeding transactions to.

type Provider

type Provider[T any] interface {
	// Run iterates through transaction in the block range [from,to) in order
	// and forwards payload information for each transaction in the range to
	// the provided consumer. Execution aborts if the consumer returns an error
	// or an error during the payload retrieval process occurred.
	Run(from int, to int, consumer Consumer[T]) error
	// Close releases resources held by the provider implementation. After this
	// no more operations are allowed on the same instance.
	Close()
}

func NewEthStateTestProvider

func NewEthStateTestProvider(cfg *utils.Config) Provider[txcontext.TxContext]

func NewNormaTxProvider

func NewNormaTxProvider(cfg *utils.Config, stateDb state.StateDB) Provider[txcontext.TxContext]

NewNormaTxProvider creates a new norma tx provider.

func OpenRpcRecording

func OpenRpcRecording(cfg *utils.Config, ctx *cli.Context) (Provider[*rpc.RequestAndResults], error)

func OpenSubstateProvider

func OpenSubstateProvider(cfg *utils.Config, ctxt *cli.Context, aidaDb db.BaseDB) (Provider[txcontext.TxContext], error)

OpenSubstateProvider opens a substate database as configured in the given parameters.

type RPCReqConsumer

type RPCReqConsumer interface {
	Consume(block int, transaction int, req *rpc.RequestAndResults) error
}

type State

type State[T any] struct {
	// Block the current block number, valid for all call-backs.
	Block int

	// Transaction is the transaction number of the current transaction within
	// its respective block. It is only valid for PreTransaction, PostTransaction,
	// PostBlock, and for PostRun events in case of an abort.
	Transaction int

	// Data is the input required for processing the current transaction. It is
	// only valid for Pre- and PostTransaction events.
	Data T
}

State summarizes the current state of an execution and is passed to Processors and Extensions as an input for their actions.

type TransactionInfo

type TransactionInfo[T any] struct {
	Block       int
	Transaction int
	Data        T
}

TransactionInfo summarizes the per-transaction information provided by a Provider.

type TxConsumer

type TxConsumer interface {
	Consume(block int, transaction int, substate txcontext.TxContext) error
}

type TxProcessor

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

func MakeTxProcessor

func MakeTxProcessor(cfg *utils.Config) (*TxProcessor, error)

func (*TxProcessor) ProcessTransaction

func (s *TxProcessor) ProcessTransaction(db state.VmStateDB, block int, tx int, st txcontext.TxContext) (txcontext.Result, error)

Directories

Path Synopsis
statedb/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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