dsl

package
v1.13.2 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2025 License: MIT Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Identifier added in v1.11.2

func Identifier(chain *Chain, tx *types.Transaction, rcpt *types.Receipt) inbox.Identifier

func RecipeToDepSet added in v1.13.1

RecipeToDepSet converts a recipe into a dependency-set for the supervisor.

func SetBlockTimeForChainA added in v1.12.0

func SetBlockTimeForChainA(blockTime uint64) setupOption

func SetBlockTimeForChainB added in v1.12.0

func SetBlockTimeForChainB(blockTime uint64) setupOption

func SetMessageExpiryTime added in v1.13.1

func SetMessageExpiryTime(expiryTime uint64) setupOption

func WithActIncludeTx added in v1.12.2

func WithActIncludeTx(includeTxAction helpers.Action) func(*AdvanceL1Opts)

func WithIdentifier added in v1.11.2

func WithIdentifier(ident inbox.Identifier) func(opts *ExecuteOpts)

func WithL1BlockCrossUnsafe added in v1.11.1

func WithL1BlockCrossUnsafe() func(*AddL2BlockOpts)

func WithL2BlockTransactions

func WithL2BlockTransactions(mkTxs ...TransactionCreator) func(*AddL2BlockOpts)

func WithL2BlocksUntilTimestamp added in v1.11.2

func WithL2BlocksUntilTimestamp(timestamp uint64) func(*AddL2BlockOpts)

func WithPayload added in v1.11.2

func WithPayload(payload []byte) func(opts *ExecuteOpts)

func WithPendingMessage added in v1.12.1

func WithPendingMessage(emitter *EmitterContract, chain *Chain, number uint64, logIndex int, msg string) func(opts *ExecuteOpts)

func WithSingleBatch added in v1.12.1

func WithSingleBatch() func(*AdvanceSafeHeadsOpts)

func WithSkipCrossSafeUpdate added in v1.12.2

func WithSkipCrossSafeUpdate() func(*SubmitBatchDataOpts)

Types

type AddL2BlockOpts

type AddL2BlockOpts struct {
	BlockIsNotCrossUnsafe bool
	TransactionCreators   []TransactionCreator
	UntilTimestamp        uint64
}

type AdvanceL1Opts

type AdvanceL1Opts struct {
	ChainOpts
	L1BlockTimeSeconds uint64
	TxInclusion        []helpers.Action
}

type AdvanceSafeHeadsOpts added in v1.12.1

type AdvanceSafeHeadsOpts struct {
	SingleBatch bool
}

type Chain

type Chain struct {
	ChainID eth.ChainID

	RollupCfg   *rollup.Config
	L2Genesis   *core.Genesis
	BatcherAddr common.Address

	Sequencer       *helpers.L2Sequencer
	SequencerEngine *helpers.L2Engine
	Batcher         *helpers.L2Batcher
}

Chain holds the most common per-chain action-test data and actors

type ChainOpts

type ChainOpts struct {
	Chains []*Chain
}

func (*ChainOpts) AddChain

func (c *ChainOpts) AddChain(chain *Chain)

func (*ChainOpts) SetChains

func (c *ChainOpts) SetChains(chains ...*Chain)

type DSLUser

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

func (*DSLUser) TransactOpts

func (u *DSLUser) TransactOpts(chainID *big.Int) (*bind.TransactOpts, common.Address)

type EmitterContract

type EmitterContract struct {
	EmittedMessages []*GeneratedTransaction
	// contains filtered or unexported fields
}

func NewEmitterContract

func NewEmitterContract(t helpers.Testing) *EmitterContract

func (*EmitterContract) Address added in v1.12.1

func (c *EmitterContract) Address(chain *Chain) common.Address

func (*EmitterContract) Deploy

func (c *EmitterContract) Deploy(user *DSLUser) TransactionCreator

func (*EmitterContract) EmitMessage

func (c *EmitterContract) EmitMessage(user *DSLUser, message string) TransactionCreator

func (*EmitterContract) LastEmittedMessage

func (c *EmitterContract) LastEmittedMessage() *GeneratedTransaction

type ExecuteOpts added in v1.11.2

type ExecuteOpts struct {
	Identifier *inbox.Identifier
	Payload    *[]byte
}

type GeneratedTransaction

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

func NewGeneratedTransaction

func NewGeneratedTransaction(t helpers.Testing, chain *Chain, tx *types.Transaction, from common.Address) *GeneratedTransaction

func (*GeneratedTransaction) CheckIncluded

func (m *GeneratedTransaction) CheckIncluded()

func (*GeneratedTransaction) CheckNotIncluded

func (m *GeneratedTransaction) CheckNotIncluded()

func (*GeneratedTransaction) Identifier

func (m *GeneratedTransaction) Identifier() inbox.Identifier

func (*GeneratedTransaction) Include added in v1.11.2

func (m *GeneratedTransaction) Include()

func (*GeneratedTransaction) IncludeDepositOK added in v1.12.2

func (m *GeneratedTransaction) IncludeDepositOK(l1User *DSLUser, depositTxOpts *bind.TransactOpts, l1Miner *helpers.L1Miner)

IncludeDepositOK includes the GeneratedTransaction via a user deposit transaction.

func (*GeneratedTransaction) IncludeOK added in v1.12.1

func (m *GeneratedTransaction) IncludeOK()

func (*GeneratedTransaction) MessagePayload added in v1.11.1

func (m *GeneratedTransaction) MessagePayload() []byte

func (*GeneratedTransaction) PendingIdentifier added in v1.12.1

func (m *GeneratedTransaction) PendingIdentifier(chain *Chain, logIndex int) inbox.Identifier

type InboxContract

type InboxContract struct {
	Transactions []*GeneratedTransaction
	// contains filtered or unexported fields
}

func NewInboxContract

func NewInboxContract(t helpers.Testing) *InboxContract

func (*InboxContract) Execute

func (i *InboxContract) Execute(user *DSLUser, initTx *GeneratedTransaction, args ...func(opts *ExecuteOpts)) TransactionCreator

func (*InboxContract) LastTransaction

func (i *InboxContract) LastTransaction() *GeneratedTransaction

type InteropActors

type InteropActors struct {
	L1Miner    *helpers.L1Miner
	Supervisor *SupervisorActor
	ChainA     *Chain
	ChainB     *Chain
}

InteropActors holds a bundle of global actors and actors of 2 chains.

func (*InteropActors) PrepareChainState added in v1.12.0

func (actors *InteropActors) PrepareChainState(t helpers.Testing)

type InteropDSL

type InteropDSL struct {
	Actors  *InteropActors
	Outputs *Outputs

	InboxContract *InboxContract
	// contains filtered or unexported fields
}

InteropDSL provides a high-level API to drive interop action tests so that the actual test reads more declaratively and is separated from the details of how each action is actually executed. DSL methods will typically:

  1. Check (and if needed, wait) for any required preconditions
  2. Perform the action, allowing components to fully process the effects of it
  3. Assert that the action completed. These are intended to be a sanity check to ensure tests fail fast if something doesn't work as expected. Options may be provided to perform more detailed or specific assertions

Optional inputs can be used to control lower level details of the operation. While it is also possible to directly access the Actors and low level actions, this should only be required when specifically testing low level details of that functionality. It is generally preferable to use optional inputs to the DSL methods to achieve the desired result rather than having to use the low level APIs directly.

Methods may also be provided specifically to verify some state. Methods may return some data from the system (e.g. OutputRootAtTimestamp) but it is generally preferred to provide an assertion method rather than a getter where that is viable. Assertion methods allow the DSL to provide more helpful information in failure messages and ensure the comparison is done correctly and consistently across tests rather than duplicating the assertion code in many tests.

Required inputs to methods are specified as normal parameters, so type checking enforces their presence. Optional inputs to methods are specified by a config struct and accept a vararg of functions that can update that struct. This is roughly inline with the typical opts pattern in Golang but with significantly reduced boilerplate code since so many methods wil define their own config. With* methods are only provided for the most common optional args and tests will normally supply a custom function that sets all the optional values they need at once. Common options can be extracted to a reusable struct (e.g. ChainOpts above) which may expose helper methods to aid test readability and reduce boilerplate.

func NewInteropDSL

func NewInteropDSL(t helpers.Testing, opts ...setupOption) *InteropDSL

func (*InteropDSL) AddL2Block

func (d *InteropDSL) AddL2Block(chain *Chain, optionalArgs ...func(*AddL2BlockOpts))

AddL2Block adds a new unsafe block to the specified chain and fully processes it in the supervisor

func (*InteropDSL) AdvanceL1

func (d *InteropDSL) AdvanceL1(optionalArgs ...func(*AdvanceL1Opts))

AdvanceL1 adds a new L1 block with the specified transactions and ensures it is processed by the specified chains and the supervisor.

func (*InteropDSL) AdvanceL2ToLastBlockOfOrigin added in v1.12.2

func (d *InteropDSL) AdvanceL2ToLastBlockOfOrigin(chain *Chain, l1OriginHeight uint64)

AdvanceL2ToLastBlockOfOrigin advances the chain to the last block of the epoch at the specified L1 origin.

func (*InteropDSL) AdvanceSafeHeads added in v1.12.1

func (d *InteropDSL) AdvanceSafeHeads(optionalArgs ...func(*AdvanceSafeHeadsOpts))

AdvanceSafeHeads advances the safe heads for all chains by adding a new L2 block and submitting batch data for each chain. By default, submits batch data for each chain in separate L1 blocks.

func (*InteropDSL) CreateUser

func (d *InteropDSL) CreateUser() *DSLUser

func (*InteropDSL) DepSet added in v1.12.0

func (*InteropDSL) DeployEmitterContracts added in v1.12.1

func (d *InteropDSL) DeployEmitterContracts() *EmitterContract

DeployEmitterContracts deploys an emitter contract on both chains

func (*InteropDSL) ProcessCrossSafe

func (d *InteropDSL) ProcessCrossSafe(optionalArgs ...func(*ProcessCrossSafeOpts))

ProcessCrossSafe processes evens in the supervisor and nodes to ensure the cross-safe head is fully updated.

func (*InteropDSL) SubmitBatchData

func (d *InteropDSL) SubmitBatchData(optionalArgs ...func(*SubmitBatchDataOpts))

SubmitBatchData submits batch data to L1 and processes the new L1 blocks, advancing the safe heads. By default, submits all batch data for all chains.

type InteropSetup

type InteropSetup struct {
	Log        log.Logger
	Deployment *interopgen.WorldDeployment
	Out        *interopgen.WorldOutput
	DepSet     *depset.StaticConfigDependencySet
	Keys       devkeys.Keys
	T          helpers.Testing
}

InteropSetup holds the chain deployment and config contents, before instantiating any services.

func SetupInterop

func SetupInterop(t helpers.Testing, opts ...setupOption) *InteropSetup

SetupInterop creates an InteropSetup to instantiate actors on, with 2 L2 chains.

func (*InteropSetup) CreateActors

func (is *InteropSetup) CreateActors() *InteropActors

type Message added in v1.12.1

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

func NewMessage added in v1.12.1

func NewMessage(dsl *InteropDSL, chain *Chain, emitter *EmitterContract, message string) *Message

func (*Message) ActEmitDeposit added in v1.12.2

func (m *Message) ActEmitDeposit(l1User *DSLUser) helpers.Action

ActEmitDeposit returns an action that emits a message via a user deposit transaction.

func (*Message) CheckEmitted added in v1.12.1

func (m *Message) CheckEmitted()

func (*Message) CheckExecuted added in v1.12.1

func (m *Message) CheckExecuted()

func (*Message) CheckNotEmitted added in v1.12.1

func (m *Message) CheckNotEmitted()

func (*Message) CheckNotExecuted added in v1.12.1

func (m *Message) CheckNotExecuted()

func (*Message) Emit added in v1.12.1

func (m *Message) Emit() *Message

func (*Message) EmitDeposit added in v1.12.2

func (m *Message) EmitDeposit(l1User *DSLUser) *Message

EmitDeposit emits a message via a user deposit transaction.

func (*Message) ExecuteIdentifier added in v1.12.1

func (m *Message) ExecuteIdentifier() inbox.Identifier

func (*Message) ExecuteOn added in v1.12.1

func (m *Message) ExecuteOn(target *Chain, execOpts ...func(*ExecuteOpts)) *Message

func (*Message) ExecutePayload added in v1.12.1

func (m *Message) ExecutePayload() []byte

func (*Message) ExecutePendingOn added in v1.12.2

func (m *Message) ExecutePendingOn(target *Chain, pendingMessageBlockNumber uint64, execOpts ...func(*ExecuteOpts)) *Message

ExecutePendingOn executes a message that may not have been emitted yet.

type OutputRootSource

type OutputRootSource interface {
	OutputAtBlock(ctx context.Context, blockNum uint64) (*eth.OutputResponse, error)
	RollupConfig(ctx context.Context) (*rollup.Config, error)
}

type Outputs added in v1.11.1

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

func (*Outputs) OptimisticBlockAtTimestamp added in v1.11.1

func (d *Outputs) OptimisticBlockAtTimestamp(chain *Chain, timestamp uint64) types.OptimisticBlock

func (*Outputs) OutputRootAtTimestamp added in v1.11.1

func (d *Outputs) OutputRootAtTimestamp(chain *Chain, timestamp uint64) *eth.OutputResponse

func (*Outputs) SuperRoot added in v1.11.1

func (d *Outputs) SuperRoot(timestamp uint64) eth.Super

func (*Outputs) TransitionState added in v1.11.1

func (d *Outputs) TransitionState(timestamp uint64, step uint64, pendingProgress ...types.OptimisticBlock) *types.TransitionState

type ProcessCrossSafeOpts

type ProcessCrossSafeOpts struct {
	ChainOpts
}

type SubmitBatchDataOpts

type SubmitBatchDataOpts struct {
	ChainOpts
	SkipCrossSafeUpdate bool
}

type SuperRootSource

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

SuperRootSource is a testing helper to create a Super Root from a set of rollup clients

func NewSuperRootSource

func NewSuperRootSource(ctx context.Context, sources ...OutputRootSource) (*SuperRootSource, error)

func (*SuperRootSource) CreateSuperRoot

func (s *SuperRootSource) CreateSuperRoot(ctx context.Context, timestamp uint64) (*eth.SuperV1, error)

type SupervisorActor

type SupervisorActor struct {
	sources.SupervisorClient
	// contains filtered or unexported fields
}

SupervisorActor represents a supervisor, instrumented to run synchronously for action-test purposes.

func NewSupervisor

func NewSupervisor(t helpers.Testing, logger log.Logger, depSet depset.DependencySetSource) *SupervisorActor

NewSupervisor creates a new SupervisorActor, to action-test the supervisor with.

func (*SupervisorActor) ProcessFull

func (sa *SupervisorActor) ProcessFull(t helpers.Testing)

func (*SupervisorActor) Rewind

func (sa *SupervisorActor) Rewind(chain eth.ChainID, block eth.BlockID) error

func (*SupervisorActor) SignalFinalizedL1

func (sa *SupervisorActor) SignalFinalizedL1(t helpers.Testing)

func (*SupervisorActor) SignalLatestL1

func (sa *SupervisorActor) SignalLatestL1(t helpers.Testing)

type TransactionCreator

type TransactionCreator func(chain *Chain) *GeneratedTransaction

type TxIncluder added in v1.11.2

type TxIncluder interface {
	IncludeTx(transaction *types.Transaction, from common.Address) (*types.Receipt, error)
}

Jump to

Keyboard shortcuts

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