Documentation
¶
Overview ¶
Package testengine runs op-reth-test-engine, the Rust OP Stack execution engine that Go tests drive over a Unix domain socket: it locates the binary, spawns it over a genesis file behind a typed client, and builds the minimal chains and blocks its own tests drive it with.
Index ¶
- Constants
- Variables
- func ResolveBinary(ctx context.Context) (string, error)
- type Client
- func (c *Client) Close()
- func (c *Client) DumpAccounts(ctx context.Context, blockHash common.Hash, addrs []common.Address) (types.GenesisAlloc, error)
- func (c *Client) ForcedEmpty(ctx context.Context) (bool, error)
- func (c *Client) ForkchoiceUpdated(ctx context.Context, method eth.EngineAPIMethod, state eth.ForkchoiceState, ...) (*eth.ForkchoiceUpdatedResult, error)
- func (c *Client) GetPayload(ctx context.Context, method eth.EngineAPIMethod, id eth.PayloadID) (*eth.ExecutionPayloadEnvelope, error)
- func (c *Client) IncludeNextTx(ctx context.Context, from common.Address) (*IncludeNextTxResult, error)
- func (c *Client) IncludeTx(ctx context.Context, raw hexutil.Bytes) (*IncludeTxResult, error)
- func (c *Client) NewPayload(ctx context.Context, method eth.EngineAPIMethod, payload *eth.ExecutionPayload, ...) (*eth.PayloadStatusV1, error)
- func (c *Client) RPC() *rpc.Client
- func (c *Client) RemainingBlockGas(ctx context.Context) (uint64, error)
- func (c *Client) SetForceEmpty(ctx context.Context, forced bool) error
- func (c *Client) SocketPath() string
- type IncludeNextTxResult
- type IncludeTxResult
Constants ¶
const BinaryName = "op-reth-test-engine"
BinaryName is the name of the engine's binary and of the cargo package that builds it in the monorepo's rust/ workspace.
Variables ¶
var ErrNotConfigured = errors.New("engine binary not configured")
ErrNotConfigured is wrapped by the error ResolveBinary returns when no binary is configured, built, or requested to be built. The error's message says how to provide one; callers for which the engine is optional can skip on it.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a thin typed client for an op-reth-test-engine process: the Engine API methods the tests drive directly, the engine's optest_ namespace, and the raw RPC client for everything else.
func Spawn ¶
Spawn starts the engine binary at binPath over the L2 genesis JSON at genesisPath and dials its socket. The engine's stderr is forwarded to logw. The returned Client owns the process and must be closed.
func (*Client) DumpAccounts ¶
func (c *Client) DumpAccounts(ctx context.Context, blockHash common.Hash, addrs []common.Address) (types.GenesisAlloc, error)
DumpAccounts returns the state of the given accounts at the block with the given hash (optest_dumpAccounts): nonce, balance, code and non-zero storage. Accounts that do not exist at that block are absent from the result.
func (*Client) ForcedEmpty ¶
ForcedEmpty reports whether the block being built is force-empty (optest_forcedEmpty).
func (*Client) ForkchoiceUpdated ¶
func (c *Client) ForkchoiceUpdated(ctx context.Context, method eth.EngineAPIMethod, state eth.ForkchoiceState, attrs *eth.PayloadAttributes) (*eth.ForkchoiceUpdatedResult, error)
ForkchoiceUpdated calls method, a version of engine_forkchoiceUpdated; attrs may be nil.
func (*Client) GetPayload ¶
func (c *Client) GetPayload(ctx context.Context, method eth.EngineAPIMethod, id eth.PayloadID) (*eth.ExecutionPayloadEnvelope, error)
GetPayload calls method, a version of engine_getPayload.
func (*Client) IncludeNextTx ¶
func (c *Client) IncludeNextTx(ctx context.Context, from common.Address) (*IncludeNextTxResult, error)
IncludeNextTx executes the parked transaction from `from` with the account's next nonce into the block being built (optest_includeNextTx). eth_sendRawTransaction parks transactions.
func (*Client) IncludeTx ¶
IncludeTx executes the encoded transaction raw into the block being built (optest_includeTx). It returns a nil result if the block is force-empty, which drops the transaction.
func (*Client) NewPayload ¶
func (c *Client) NewPayload(ctx context.Context, method eth.EngineAPIMethod, payload *eth.ExecutionPayload, parentBeaconBlockRoot *common.Hash) (*eth.PayloadStatusV1, error)
NewPayload calls method, a version of engine_newPayload, with the parameters that version takes, as op-node sends them: V3 adds empty blob versioned hashes and parentBeaconBlockRoot, V4 empty execution requests.
func (*Client) RPC ¶
RPC returns the raw RPC client, for the eth_ namespace and for go-ethereum's and op-node's clients. It is valid until Close.
func (*Client) RemainingBlockGas ¶
RemainingBlockGas returns the gas still available in the block being built (optest_remainingBlockGas).
func (*Client) SetForceEmpty ¶
SetForceEmpty sets the force-empty flag of the block being built (optest_setForceEmpty).
func (*Client) SocketPath ¶
SocketPath returns the path of the engine's Unix socket, for processes that dial the engine themselves, such as kona-host. It is valid until Close.
type IncludeNextTxResult ¶
type IncludeNextTxResult struct {
TxHash *common.Hash `json:"txHash"`
GasUsed uint64 `json:"gasUsed"`
// Skipped reports that the block is force-empty, which drops the transaction.
Skipped bool `json:"skipped"`
// NoTx reports that no parked transaction from the account has the next nonce.
NoTx bool `json:"noTx"`
}
IncludeNextTxResult is the result of including the next parked transaction from an account in the block being built: exactly one of TxHash, Skipped and NoTx is set.
type IncludeTxResult ¶
IncludeTxResult is the result of including a transaction in the block being built.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package chainfixture is a fixed test chain for driving a testengine process directly: a chain id, a chain config with every OP Stack fork active at genesis, a genesis writer and helpers that build blocks over the engine API.
|
Package chainfixture is a fixed test chain for driving a testengine process directly: a chain id, a chain config with every OP Stack fork active at genesis, a genesis writer and helpers that build blocks over the engine API. |