actions

package
v0.8.10 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2022 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	STATUS_INVALID         = &eth.ForkchoiceUpdatedResult{PayloadStatus: eth.PayloadStatusV1{Status: eth.ExecutionInvalid}, PayloadID: nil}
	STATUS_SYNCING         = &eth.ForkchoiceUpdatedResult{PayloadStatus: eth.PayloadStatusV1{Status: eth.ExecutionSyncing}, PayloadID: nil}
	INVALID_TERMINAL_BLOCK = eth.PayloadStatusV1{Status: eth.ExecutionInvalid, LatestValidHash: &common.Hash{}}
)

Functions

This section is empty.

Types

type Action

type Action func(t Testing)

Action is a function that may change the state of one or more actors or check their state. Action definitions are meant to be very small building blocks, and then composed into larger patterns to write more elaborate tests.

type ActionStatus

type ActionStatus uint

ActionStatus defines the state of an action, to make a basic distinction between InvalidAction() and other calls.

const (
	// ActionOK indicates the action is valid to apply
	ActionOK ActionStatus = iota
	// ActionInvalid indicates the action is not applicable, and a different next action may taken.
	ActionInvalid
)

type L1CanonSrc added in v0.8.10

type L1CanonSrc func(num uint64) *types.Block

L1CanonSrc is used to sync L1 from another node. The other node always has the canonical chain. May be nil if there is nothing to sync from

type L1Miner added in v0.8.10

type L1Miner struct {
	L1Replica
	// contains filtered or unexported fields
}

L1Miner wraps a L1Replica with instrumented block building ability.

func NewL1Miner added in v0.8.10

func NewL1Miner(log log.Logger, genesis *core.Genesis) *L1Miner

NewL1Miner creates a new L1Replica that can also build blocks.

func (*L1Miner) ActL1EndBlock added in v0.8.10

func (s *L1Miner) ActL1EndBlock(t Testing)

ActL1EndBlock finishes the new L1 block, and applies it to the chain as unsafe block

func (*L1Miner) ActL1IncludeTx added in v0.8.10

func (s *L1Miner) ActL1IncludeTx(from common.Address) Action

ActL1IncludeTx includes the next tx from L1 tx pool from the given account

func (*L1Miner) ActL1SetFeeRecipient added in v0.8.10

func (s *L1Miner) ActL1SetFeeRecipient(coinbase common.Address)

func (*L1Miner) ActL1StartBlock added in v0.8.10

func (s *L1Miner) ActL1StartBlock(timeDelta uint64) Action

ActL1StartBlock returns an action to build a new L1 block on top of the head block, with timeDelta added to the head block time.

func (*L1Miner) Close added in v0.8.10

func (s *L1Miner) Close() error

type L1Replica added in v0.8.10

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

L1Replica is an instrumented in-memory L1 geth node that: - can sync from the given canonical L1 blocks source - can rewind the chain back (for reorgs) - can provide an RPC with mock errors

func NewL1Replica added in v0.8.10

func NewL1Replica(log log.Logger, genesis *core.Genesis) *L1Replica

NewL1Replica constructs a L1Replica starting at the given genesis.

func (*L1Replica) ActL1FinalizeNext added in v0.8.10

func (s *L1Replica) ActL1FinalizeNext(t Testing)

ActL1FinalizeNext finalizes the next block, which must be marked as safe before doing so (see ActL1SafeNext).

func (*L1Replica) ActL1RPCFail added in v0.8.10

func (s *L1Replica) ActL1RPCFail(t Testing)

ActL1RPCFail makes the next L1 RPC request to this node fail

func (*L1Replica) ActL1RewindDepth added in v0.8.10

func (s *L1Replica) ActL1RewindDepth(depth uint64) Action

func (*L1Replica) ActL1RewindToParent added in v0.8.10

func (s *L1Replica) ActL1RewindToParent(t Testing)

ActL1RewindToParent rewinds the L1 chain to parent block of head

func (*L1Replica) ActL1SafeNext added in v0.8.10

func (s *L1Replica) ActL1SafeNext(t Testing)

ActL1SafeNext marks the next unsafe block as safe.

func (*L1Replica) ActL1Sync added in v0.8.10

func (s *L1Replica) ActL1Sync(canonL1 func(num uint64) *types.Block) Action

ActL1Sync processes the next canonical L1 block, or rewinds one block if the canonical block cannot be applied to the head.

func (*L1Replica) CanonL1Chain added in v0.8.10

func (s *L1Replica) CanonL1Chain() func(num uint64) *types.Block

func (*L1Replica) Close added in v0.8.10

func (s *L1Replica) Close() error

func (*L1Replica) EthClient added in v0.8.10

func (s *L1Replica) EthClient() *ethclient.Client

func (*L1Replica) RPCClient added in v0.8.10

func (s *L1Replica) RPCClient() client.RPC

type L2Engine added in v0.8.10

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

L2Engine is an in-memory implementation of the Engine API, without support for snap-sync, and no concurrency or background processes.

func NewL2Engine added in v0.8.10

func NewL2Engine(log log.Logger, genesis *core.Genesis, rollupGenesisL1 eth.BlockID, jwtPath string) *L2Engine

func (*L2Engine) ActL2IncludeTx added in v0.8.10

func (e *L2Engine) ActL2IncludeTx(from common.Address) Action

ActL2IncludeTx includes the next transaction from the given address in the block that is being built

func (*L2Engine) ActL2RPCFail added in v0.8.10

func (e *L2Engine) ActL2RPCFail(t Testing)

ActL2RPCFail makes the next L2 RPC request fail

func (*L2Engine) Close added in v0.8.10

func (e *L2Engine) Close() error

func (*L2Engine) EthClient added in v0.8.10

func (s *L2Engine) EthClient() *ethclient.Client

func (*L2Engine) RPCClient added in v0.8.10

func (e *L2Engine) RPCClient() client.RPC

type L2EngineAPI added in v0.8.10

type L2EngineAPI L2Engine

L2EngineAPI wraps an engine actor, and implements the RPC backend required to serve the engine API. This re-implements some of the Geth API work, but changes the API backend so we can deterministically build and control the L2 block contents to reach very specific edge cases as desired for testing.

func (*L2EngineAPI) ForkchoiceUpdatedV1 added in v0.8.10

func (ea *L2EngineAPI) ForkchoiceUpdatedV1(ctx context.Context, state *eth.ForkchoiceState, attr *eth.PayloadAttributes) (*eth.ForkchoiceUpdatedResult, error)

func (*L2EngineAPI) GetPayloadV1 added in v0.8.10

func (ea *L2EngineAPI) GetPayloadV1(ctx context.Context, payloadId eth.PayloadID) (*eth.ExecutionPayload, error)

func (*L2EngineAPI) NewPayloadV1 added in v0.8.10

func (ea *L2EngineAPI) NewPayloadV1(ctx context.Context, payload *eth.ExecutionPayload) (*eth.PayloadStatusV1, error)

type L2Verifier added in v0.8.10

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

L2Verifier is an actor that functions like a rollup node, without the full P2P/API/Node stack, but just the derivation state, and simplified driver.

func NewL2Verifier added in v0.8.10

func NewL2Verifier(log log.Logger, l1 derive.L1Fetcher, eng derive.Engine, cfg *rollup.Config) *L2Verifier

func (*L2Verifier) ActL2PipelineFull added in v0.8.10

func (s *L2Verifier) ActL2PipelineFull(t Testing)

func (*L2Verifier) ActL2PipelineStep added in v0.8.10

func (s *L2Verifier) ActL2PipelineStep(t Testing)

ActL2PipelineStep runs one iteration of the L2 derivation pipeline

func (*L2Verifier) ActL2UnsafeGossipReceive added in v0.8.10

func (s *L2Verifier) ActL2UnsafeGossipReceive(payload *eth.ExecutionPayload) Action

ActL2UnsafeGossipReceive creates an action that can receive an unsafe execution payload, like gossipsub

func (*L2Verifier) SyncStatus added in v0.8.10

func (s *L2Verifier) SyncStatus() *eth.SyncStatus

type StatefulTesting added in v0.8.10

type StatefulTesting interface {
	Testing
	Reset(actionCtx context.Context)
	State() ActionStatus
}

func NewDefaultTesting added in v0.8.10

func NewDefaultTesting(tb e2eutils.TestingBase) StatefulTesting

NewDefaultTesting returns a new testing obj. Returns an interface, we're likely changing the behavior here as we build more action tests.

type Testing

type Testing interface {
	e2eutils.TestingBase
	// Ctx shares a context to execute an action with, the test runner may interrupt the action without stopping the test.
	Ctx() context.Context
	// InvalidAction indicates the failure is due to action incompatibility, does not stop the test.
	InvalidAction(format string, args ...any)
}

Testing is an interface to Go-like testing, extended with a context getter for the test runner to shut down individual actions without interrupting the test, and a signaling function for when an invalid action is hit. This helps custom test runners navigate slow or invalid actions, e.g. during fuzzing.

Jump to

Keyboard shortcuts

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