chain_container

package
v1.16.13 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainContainer

type ChainContainer interface {
	Start(ctx context.Context) error
	Stop(ctx context.Context) error
	Pause(ctx context.Context) error
	Resume(ctx context.Context) error

	ID() eth.ChainID
	LocalSafeBlockAtTimestamp(ctx context.Context, ts uint64) (eth.L2BlockRef, error)
	SyncStatus(ctx context.Context) (*eth.SyncStatus, error)
	VerifiedAt(ctx context.Context, ts uint64) (l2, l1 eth.BlockID, err error)
	OptimisticAt(ctx context.Context, ts uint64) (l2, l1 eth.BlockID, err error)
	OutputRootAtL2BlockNumber(ctx context.Context, l2BlockNum uint64) (eth.Bytes32, error)
	OptimisticOutputAtTimestamp(ctx context.Context, ts uint64) (*eth.OutputV0, error)
	// RewindEngine rewinds the engine to the highest block with timestamp less than or equal to the given timestamp.
	// invalidatedBlock is the block that triggered the rewind and is passed to reset callbacks.
	// WARNING: this is a dangerous stateful operation and is intended to be called only
	// by interop transition application. Other callers should not use it until the
	// interface is refactored to make that ownership explicit.
	// TODO(#19561): remove this footgun by moving reorg-triggering operations behind a
	// smaller interop-owned interface.
	RewindEngine(ctx context.Context, timestamp uint64, invalidatedBlock eth.BlockRef) error
	RegisterVerifier(v activity.VerificationActivity)
	// VerifierCurrentL1s returns the CurrentL1 from each registered verifier.
	// This allows callers to determine the minimum L1 block that all verifiers have processed.
	VerifierCurrentL1s() []eth.BlockID
	// FetchReceipts fetches the receipts for a given block by hash.
	// Returns block info and receipts, or an error if the block or receipts cannot be fetched.
	FetchReceipts(ctx context.Context, blockHash eth.BlockID) (eth.BlockInfo, types.Receipts, error)
	// BlockTime returns the block time in seconds for this chain.
	BlockTime() uint64
	// InvalidateBlock adds a block to the deny list and triggers a rewind if the chain
	// currently uses that block at the specified height.
	// output is the marshaled eth.Output preimage for optimistic root computation.
	// WARNING: this is a dangerous stateful operation and is intended to be called only
	// by interop transition application. Other callers should not use it until the
	// interface is refactored to make that ownership explicit.
	// TODO(#19561): remove this footgun by moving reorg-triggering operations behind a
	// smaller interop-owned interface.
	// Returns true if a rewind was triggered, false otherwise.
	InvalidateBlock(ctx context.Context, height uint64, payloadHash common.Hash, decisionTimestamp uint64, stateRoot, messagePasserStorageRoot eth.Bytes32) (bool, error)
	// PruneDeniedAtOrAfterTimestamp removes deny-list entries with DecisionTimestamp >= timestamp.
	// Returns map of removed hashes by height.
	PruneDeniedAtOrAfterTimestamp(timestamp uint64) (map[uint64][]common.Hash, error)
	// PauseAndStopVN pauses the chain container restart loop and stops the virtual node.
	// This is used to freeze a chain's VN before a multi-chain rewind begins, preventing
	// the VN from issuing forkchoice updates that race with the rewind of a peer chain.
	PauseAndStopVN(ctx context.Context) error
	// IsDenied checks if a block hash is on the deny list at the given height.
	IsDenied(height uint64, payloadHash common.Hash) (bool, error)
	// GetDeniedOutput returns the reconstructed OutputV0 for a denied block.
	// Returns nil if the block is not denied at that height.
	GetDeniedOutput(height uint64, payloadHash common.Hash) (*eth.OutputV0, error)
	// OutputV0AtBlockNumber returns the full OutputV0 for the block at the given number.
	OutputV0AtBlockNumber(ctx context.Context, l2BlockNum uint64) (*eth.OutputV0, error)
	// SetResetCallback sets a callback that is invoked when the chain resets.
	// The supernode uses this to notify activities about chain resets.
	SetResetCallback(cb ResetCallback)
}

func NewChainContainer

func NewChainContainer(
	chainID eth.ChainID,
	vncfg *opnodecfg.Config,
	log gethlog.Logger,
	cfg config.CLIConfig,
	initOverload *rollupNode.InitializationOverrides,
	rpcHandler *oprpc.Handler,
	setHandler func(chainID string, h http.Handler),
	addMetricsRegistry func(key string, g prometheus.Gatherer),
) ChainContainer

type DenyList

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

DenyList provides persistence for invalid block payload hashes using bbolt. Blocks are keyed by block height, with each height potentially having multiple denied hashes.

func OpenDenyList

func OpenDenyList(dataDir string) (*DenyList, error)

OpenDenyList opens or creates a DenyList at the given data directory.

func (*DenyList) Add

func (d *DenyList) Add(height uint64, payloadHash common.Hash, decisionTimestamp uint64, stateRoot, messagePasserStorageRoot eth.Bytes32) error

Add adds a payload hash to the deny list at the given block height. stateRoot and messagePasserStorageRoot are the output preimage fields for optimistic root computation. Multiple hashes can be denied at the same height.

func (*DenyList) Close

func (d *DenyList) Close() error

Close closes the database.

func (*DenyList) Contains

func (d *DenyList) Contains(height uint64, payloadHash common.Hash) (bool, error)

Contains checks if a payload hash is denied at the given block height.

func (*DenyList) GetDeniedHashes

func (d *DenyList) GetDeniedHashes(height uint64) ([]common.Hash, error)

GetDeniedHashes returns all denied payload hashes at the given block height.

func (*DenyList) GetDeniedRecords

func (d *DenyList) GetDeniedRecords(height uint64) ([]DenyRecord, error)

GetDeniedRecords returns all denied records at the given block height.

func (*DenyList) GetOutputV0

func (d *DenyList) GetOutputV0(height uint64, payloadHash common.Hash) (*eth.OutputV0, error)

GetOutputV0 reconstructs and returns the full OutputV0 for a denied block. Returns nil if the hash is not denied at that height.

func (*DenyList) LastDeniedOutputV0

func (d *DenyList) LastDeniedOutputV0(height uint64) (*eth.OutputV0, error)

LastDeniedOutputV0 returns the OutputV0 for the most recently denied block at the given height. Returns nil if no blocks are denied at that height. Note: supernode does not currently behave in well defined ways when there are multiple denied blocks at the same height.

func (*DenyList) PruneAtOrAfterTimestamp

func (d *DenyList) PruneAtOrAfterTimestamp(timestamp uint64) (map[uint64][]common.Hash, error)

PruneAtOrAfterTimestamp iterates all keys in the bucket, decodes records, removes any where DecisionTimestamp >= timestamp, re-encodes remaining. Returns map of removed hashes by height.

type DenyRecord

type DenyRecord struct {
	PayloadHash              common.Hash `json:"payloadHash"`
	DecisionTimestamp        uint64      `json:"decisionTimestamp"`
	StateRoot                eth.Bytes32 `json:"stateRoot"`
	MessagePasserStorageRoot eth.Bytes32 `json:"messagePasserStorageRoot"`
}

DenyRecord stores a denied payload hash along with decision provenance and the output preimage fields for optimistic root computation.

type ResetCallback

type ResetCallback func(chainID eth.ChainID, timestamp uint64, invalidatedBlock eth.BlockRef)

ResetCallback is called when the chain container resets due to an invalidated block. The supernode uses this to notify activities about the reset. invalidatedBlock is the block that was invalidated and triggered the reset.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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