chain_container

package
v1.16.9 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 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.OutputResponse, 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.
	// 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) (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)
	// 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 added in v1.16.7

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 added in v1.16.7

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

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

func (*DenyList) Add added in v1.16.7

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

Add adds a payload hash to the deny list at the given block height. Multiple hashes can be denied at the same height.

func (*DenyList) Close added in v1.16.7

func (d *DenyList) Close() error

Close closes the database.

func (*DenyList) Contains added in v1.16.7

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 added in v1.16.7

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

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

func (*DenyList) GetDeniedRecords added in v1.16.9

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

GetDeniedRecords returns all denied records at the given block height.

func (*DenyList) PruneAtOrAfterTimestamp added in v1.16.9

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 added in v1.16.9

type DenyRecord struct {
	PayloadHash       common.Hash `json:"payloadHash"`
	DecisionTimestamp uint64      `json:"decisionTimestamp"`
}

DenyRecord stores a denied payload hash along with decision provenance.

type ResetCallback added in v1.16.7

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