op_e2e

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: MIT Imports: 72 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrForkChoiceUpdatedNotValid is returned when a forkChoiceUpdated returns a status other than Valid
	ErrForkChoiceUpdatedNotValid = errors.New("forkChoiceUpdated status was not valid")
	// ErrNewPayloadNotValid is returned when a newPayload call returns a status other than Valid, indicating the new block is invalid
	ErrNewPayloadNotValid = errors.New("newPayload status was not valid")
)

Functions

func BuildOpProgramClient added in v1.0.6

func BuildOpProgramClient(t *testing.T) string

BuildOpProgramClient builds the `op-program` client executable and returns the path to the resulting executable

func FinalizeWithdrawal added in v1.0.5

func FinalizeWithdrawal(t *testing.T, cfg SystemConfig, l1Client *ethclient.Client, privKey *ecdsa.PrivateKey, withdrawalReceipt *types.Receipt, params withdrawals.ProvenWithdrawalParameters) *types.Receipt

func InitParallel

func InitParallel(t *testing.T)

func ProveAndFinalizeWithdrawal added in v1.0.5

func ProveAndFinalizeWithdrawal(t *testing.T, cfg SystemConfig, l1Client *ethclient.Client, l2Node *node.Node, ethPrivKey *ecdsa.PrivateKey, l2WithdrawalReceipt *types.Receipt) (*types.Receipt, *types.Receipt)

func ProveWithdrawal added in v1.0.5

func ProveWithdrawal(t *testing.T, cfg SystemConfig, l1Client *ethclient.Client, l2Node *node.Node, ethPrivKey *ecdsa.PrivateKey, l2WithdrawalReceipt *types.Receipt) (withdrawals.ProvenWithdrawalParameters, *types.Receipt)

func SendDepositTx added in v1.0.5

func SendDepositTx(t *testing.T, cfg SystemConfig, l1Client *ethclient.Client, l2Client *ethclient.Client, l1Opts *bind.TransactOpts, applyL2Opts DepositTxOptsFn)

SendDepositTx creates and sends a deposit transaction. The L1 transaction, including sender, is configured by the l1Opts param. The L2 transaction options can be configured by modifying the DepositTxOps value supplied to applyL2Opts Will verify that the transaction is included with the expected status on L1 and L2

func SendL2Tx added in v1.0.5

func SendL2Tx(t *testing.T, cfg SystemConfig, l2Client *ethclient.Client, privKey *ecdsa.PrivateKey, applyTxOpts TxOptsFn) *types.Receipt

SendL2Tx creates and sends a transaction. The supplied privKey is used to specify the account to send from and the transaction is sent to the supplied l2Client Transaction options and expected status can be configured in the applyTxOpts function by modifying the supplied TxOpts Will verify that the transaction is included with the expected status on l2Client and any clients added to TxOpts.VerifyClients

func SendWithdrawal added in v1.0.5

func SendWithdrawal(t *testing.T, cfg SystemConfig, l2Client *ethclient.Client, privKey *ecdsa.PrivateKey, applyOpts WithdrawalTxOptsFn) (*types.Transaction, *types.Receipt)

Types

type DepositContractConfig added in v1.0.1

type DepositContractConfig struct {
	L2Oracle           common.Address
	FinalizationPeriod *big.Int
}

type DepositTxOpts added in v1.0.5

type DepositTxOpts struct {
	ToAddr         common.Address
	Value          *big.Int
	GasLimit       uint64
	IsCreation     bool
	Data           []byte
	ExpectedStatus uint64
}

type DepositTxOptsFn added in v1.0.5

type DepositTxOptsFn func(l2Opts *DepositTxOpts)

type FnTracer added in v1.0.1

type FnTracer struct {
	OnNewL1HeadFn        func(ctx context.Context, sig eth.L1BlockRef)
	OnUnsafeL2PayloadFn  func(ctx context.Context, from peer.ID, payload *eth.ExecutionPayload)
	OnPublishL2PayloadFn func(ctx context.Context, payload *eth.ExecutionPayload)
}

func (*FnTracer) OnNewL1Head added in v1.0.1

func (n *FnTracer) OnNewL1Head(ctx context.Context, sig eth.L1BlockRef)

func (*FnTracer) OnPublishL2Payload added in v1.0.1

func (n *FnTracer) OnPublishL2Payload(ctx context.Context, payload *eth.ExecutionPayload)

func (*FnTracer) OnUnsafeL2Payload added in v1.0.1

func (n *FnTracer) OnUnsafeL2Payload(ctx context.Context, from peer.ID, payload *eth.ExecutionPayload)

type GethOption added in v1.0.1

type GethOption func(ethCfg *ethconfig.Config, nodeCfg *node.Config) error

type OpGeth added in v1.0.1

type OpGeth struct {
	L2Client      *ethclient.Client
	SystemConfig  eth.SystemConfig
	L1ChainConfig *params.ChainConfig
	L2ChainConfig *params.ChainConfig
	L1Head        eth.BlockInfo
	L2Head        *eth.ExecutionPayload
	// contains filtered or unexported fields
}

OpGeth is an actor that functions as a l2 op-geth node It provides useful functions for advancing and querying the chain

func NewOpGeth added in v1.0.1

func NewOpGeth(t *testing.T, ctx context.Context, cfg *SystemConfig) (*OpGeth, error)

func (*OpGeth) AddL2Block added in v1.0.1

func (d *OpGeth) AddL2Block(ctx context.Context, txs ...*types.Transaction) (*eth.ExecutionPayload, error)

AddL2Block Appends a new L2 block to the current chain including the specified transactions The L1Info transaction is automatically prepended to the created block

func (*OpGeth) Close added in v1.0.1

func (d *OpGeth) Close()

func (*OpGeth) CreatePayloadAttributes added in v1.0.1

func (d *OpGeth) CreatePayloadAttributes(txs ...*types.Transaction) (*eth.PayloadAttributes, error)

CreatePayloadAttributes creates a valid PayloadAttributes containing a L1Info deposit transaction followed by the supplied transactions.

func (*OpGeth) StartBlockBuilding added in v1.0.1

func (d *OpGeth) StartBlockBuilding(ctx context.Context, attrs *eth.PayloadAttributes) (*eth.ForkchoiceUpdatedResult, error)

StartBlockBuilding begins block building for the specified PayloadAttributes by sending a engine_forkChoiceUpdated call. The current L2Head is used as the parent of the new block. ErrForkChoiceUpdatedNotValid is returned if the forkChoiceUpdate call returns a status other than valid.

type System added in v1.0.1

type System struct {
	RollupConfig *rollup.Config

	L2GenesisCfg *core.Genesis

	// Connections to running nodes
	Nodes             map[string]*node.Node
	Backends          map[string]*geth_eth.Ethereum
	Clients           map[string]*ethclient.Client
	RollupNodes       map[string]*rollupNode.OpNode
	L2OutputSubmitter *l2os.L2OutputSubmitter
	BatchSubmitter    *bss.BatchSubmitter
	Mocknet           mocknet.Mocknet

	// TimeTravelClock is nil unless SystemConfig.SupportL1TimeTravel was set to true
	// It provides access to the clock instance used by the L1 node. Calling TimeTravelClock.AdvanceBy
	// allows tests to quickly time travel L1 into the future.
	// Note that this time travel may occur in a single block, creating a very large difference in the Time
	// on sequential blocks.
	TimeTravelClock *clock.AdvancingClock
	// contains filtered or unexported fields
}

func (*System) Close added in v1.0.1

func (sys *System) Close()

func (*System) NodeEndpoint added in v1.0.5

func (sys *System) NodeEndpoint(name string) string

type SystemConfig added in v1.0.1

type SystemConfig struct {
	Secrets                *e2eutils.Secrets
	L1InfoPredeployAddress common.Address

	DeployConfig *genesis.DeployConfig

	JWTFilePath string
	JWTSecret   [32]byte

	Premine        map[common.Address]*big.Int
	Nodes          map[string]*rollupNode.Config // Per node config. Don't use populate rollup.Config
	Loggers        map[string]log.Logger
	GethOptions    map[string][]GethOption
	ProposerLogger log.Logger
	BatcherLogger  log.Logger

	// map of outbound connections to other nodes. Node names prefixed with "~" are unconnected but linked.
	// A nil map disables P2P completely.
	// Any node name not in the topology will not have p2p enabled.
	P2PTopology map[string][]string

	// Enables req-resp sync in the P2P nodes
	P2PReqRespSync bool

	// If the proposer can make proposals for L2 blocks derived from L1 blocks which are not finalized on L1 yet.
	NonFinalizedProposals bool

	// Explicitly disable batcher, for tests that rely on unsafe L2 payloads
	DisableBatcher bool

	// Target L1 tx size for the batcher transactions
	BatcherTargetL1TxSizeBytes uint64

	// SupportL1TimeTravel determines if the L1 node supports quickly skipping forward in time
	SupportL1TimeTravel bool
}

func DefaultSystemConfig added in v1.0.1

func DefaultSystemConfig(t *testing.T) SystemConfig

func (SystemConfig) L1ChainIDBig added in v1.0.1

func (cfg SystemConfig) L1ChainIDBig() *big.Int

func (SystemConfig) L2ChainIDBig added in v1.0.1

func (cfg SystemConfig) L2ChainIDBig() *big.Int

func (SystemConfig) Start added in v1.0.1

func (cfg SystemConfig) Start(_opts ...SystemConfigOption) (*System, error)

type SystemConfigOption added in v1.0.1

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

type SystemConfigOptions added in v1.0.1

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

func NewSystemConfigOptions added in v1.0.1

func NewSystemConfigOptions(_opts []SystemConfigOption) (SystemConfigOptions, error)

func (*SystemConfigOptions) Get added in v1.0.1

func (s *SystemConfigOptions) Get(key, role string) (systemConfigHook, bool)

type TxOpts added in v1.0.5

type TxOpts struct {
	ToAddr         *common.Address
	Nonce          uint64
	Value          *big.Int
	Gas            uint64
	GasTipCap      *big.Int
	GasFeeCap      *big.Int
	Data           []byte
	ExpectedStatus uint64
	VerifyClients  []*ethclient.Client
}

func (*TxOpts) VerifyOnClients added in v1.0.5

func (o *TxOpts) VerifyOnClients(clients ...*ethclient.Client)

VerifyOnClients adds additional l2 clients that should sync the block the tx is included in Checks that the receipt received from these clients is equal to the receipt received from the sequencer

type TxOptsFn added in v1.0.5

type TxOptsFn func(opts *TxOpts)

type WithdrawalTxOpts added in v1.0.5

type WithdrawalTxOpts struct {
	ToAddr         *common.Address
	Nonce          uint64
	Value          *big.Int
	Gas            uint64
	Data           []byte
	ExpectedStatus uint64
	VerifyClients  []*ethclient.Client
}

func (*WithdrawalTxOpts) VerifyOnClients added in v1.0.5

func (o *WithdrawalTxOpts) VerifyOnClients(clients ...*ethclient.Client)

VerifyOnClients adds additional l2 clients that should sync the block the tx is included in Checks that the receipt received from these clients is equal to the receipt received from the sequencer

type WithdrawalTxOptsFn added in v1.0.5

type WithdrawalTxOptsFn func(opts *WithdrawalTxOpts)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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