Documentation
¶
Index ¶
- type DummyExecutor
- func (e *DummyExecutor) ExecuteTxs(ctx context.Context, txs [][]byte, blockHeight uint64, timestamp time.Time, ...) ([]byte, uint64, error)
- func (e *DummyExecutor) GetStateRoot() []byte
- func (e *DummyExecutor) GetTxs(context.Context) ([][]byte, error)
- func (e *DummyExecutor) InitChain(ctx context.Context, genesisTime time.Time, initialHeight uint64, ...) ([]byte, uint64, error)
- func (e *DummyExecutor) InjectTx(tx []byte)
- func (e *DummyExecutor) SetFinal(ctx context.Context, blockHeight uint64) error
- type Executor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DummyExecutor ¶
type DummyExecutor struct {
// contains filtered or unexported fields
}
DummyExecutor is a dummy implementation of the DummyExecutor interface for testing
func NewDummyExecutor ¶
func NewDummyExecutor() *DummyExecutor
NewDummyExecutor creates a new dummy DummyExecutor instance
func (*DummyExecutor) ExecuteTxs ¶
func (e *DummyExecutor) ExecuteTxs(ctx context.Context, txs [][]byte, blockHeight uint64, timestamp time.Time, prevStateRoot []byte) ([]byte, uint64, error)
ExecuteTxs simulate execution of transactions.
func (*DummyExecutor) GetStateRoot ¶
func (e *DummyExecutor) GetStateRoot() []byte
GetStateRoot returns the current state root in a thread-safe manner
func (*DummyExecutor) GetTxs ¶
func (e *DummyExecutor) GetTxs(context.Context) ([][]byte, error)
GetTxs returns the list of transactions (types.Tx) within the DummyExecutor instance and an error if any.
func (*DummyExecutor) InitChain ¶
func (e *DummyExecutor) InitChain(ctx context.Context, genesisTime time.Time, initialHeight uint64, chainID string) ([]byte, uint64, error)
InitChain initializes the chain state with the given genesis time, initial height, and chain ID. It returns the state root hash, the maximum byte size, and an error if the initialization fails.
func (*DummyExecutor) InjectTx ¶
func (e *DummyExecutor) InjectTx(tx []byte)
InjectTx adds a transaction to the internal list of injected transactions in the DummyExecutor instance.
type Executor ¶
type Executor interface { // InitChain initializes a new blockchain instance with genesis parameters. // Requirements: // - Must generate initial state root representing empty/genesis state // - Must validate and store genesis parameters for future reference // - Must ensure idempotency (repeated calls with identical parameters should return same results) // - Must return error if genesis parameters are invalid // - Must return maxBytes indicating maximum allowed bytes for a set of transactions in a block // // Parameters: // - ctx: Context for timeout/cancellation control // - genesisTime: timestamp marking chain start time in UTC // - initialHeight: First block height (must be > 0) // - chainID: Unique identifier string for the blockchain // // Returns: // - stateRoot: Hash representing initial state // - maxBytes: Maximum allowed bytes for transactions in a block // - err: Any initialization errors InitChain(ctx context.Context, genesisTime time.Time, initialHeight uint64, chainID string) (stateRoot []byte, maxBytes uint64, err error) // GetTxs fetches available transactions from the execution layer's mempool. // Requirements: // - Must return currently valid transactions only // - Must handle empty mempool case gracefully // - Must respect context cancellation/timeout // - Should perform basic transaction validation // - Should not remove transactions from mempool // - May remove invalid transactions from mempool // // Parameters: // - ctx: Context for timeout/cancellation control // // Returns: // - []types.Tx: Slice of valid transactions // - error: Any errors during transaction retrieval GetTxs(ctx context.Context) ([][]byte, error) // ExecuteTxs processes transactions to produce a new block state. // Requirements: // - Must validate state transition against previous state root // - Must handle empty transaction list // - Must maintain deterministic execution // - Must respect context cancellation/timeout // - The rest of the rules are defined by the specific execution layer // // Parameters: // - ctx: Context for timeout/cancellation control // - txs: Ordered list of transactions to execute // - blockHeight: Height of block being created (must be > 0) // - timestamp: Block creation time in UTC // - prevStateRoot: Previous block's state root hash // // Returns: // - updatedStateRoot: New state root after executing transactions // - maxBytes: Maximum allowed transaction size (may change with protocol updates) // - err: Any execution errors ExecuteTxs(ctx context.Context, txs [][]byte, blockHeight uint64, timestamp time.Time, prevStateRoot []byte) (updatedStateRoot []byte, maxBytes uint64, err error) // SetFinal marks a block as finalized at the specified height. // Requirements: // - Must verify block exists at specified height // - Must be idempotent // - Must maintain finality guarantees (no reverting finalized blocks) // - Must respect context cancellation/timeout // - Should clean up any temporary state/resources // // Parameters: // - ctx: Context for timeout/cancellation control // - blockHeight: Height of block to finalize // // Returns: // - error: Any errors during finalization SetFinal(ctx context.Context, blockHeight uint64) error }
Executor defines the interface that execution clients must implement to be compatible with Evolve. This interface enables the separation between consensus and execution layers, allowing for modular and pluggable execution environments.
Note: if you are modifying this interface, ensure that all implementations are compatible (evm, abci, protobuf/grpc, etc..