clsync

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: MIT, MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CLSync

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

CLSync holds on to a queue of received unsafe payloads, and tries to apply them to the tip of the chain when requested to.

func NewCLSync

func NewCLSync(log log.Logger, cfg *rollup.Config, metrics Metrics) *CLSync

func (*CLSync) AttachEmitter added in v1.8.0

func (eq *CLSync) AttachEmitter(em event.Emitter)

func (*CLSync) LowestQueuedUnsafeBlock

func (eq *CLSync) LowestQueuedUnsafeBlock() eth.L2BlockRef

LowestQueuedUnsafeBlock retrieves the first queued-up L2 unsafe payload, or a zeroed reference if there is none.

func (*CLSync) OnEvent added in v1.8.0

func (eq *CLSync) OnEvent(ev event.Event) bool

type Metrics

type Metrics interface {
	RecordUnsafePayloadsBuffer(length uint64, memSize uint64, next eth.BlockID)
}

type PayloadsQueue

type PayloadsQueue struct {
	MaxSize uint64

	SizeFn func(p *eth.ExecutionPayloadEnvelope) uint64
	// contains filtered or unexported fields
}

PayloadsQueue buffers payloads by block number. PayloadsQueue is not safe to use concurrently. PayloadsQueue exposes typed Push/Peek/Pop methods to use the queue, without the need to use heap.Push/heap.Pop as caller. PayloadsQueue maintains a MaxSize by counting and tracking sizes of added eth.ExecutionPayload entries. When the size grows too large, the first (lowest block-number) payload is removed from the queue. PayloadsQueue allows entries with same block number, but does not allow duplicate blocks

func NewPayloadsQueue

func NewPayloadsQueue(log log.Logger, maxSize uint64, sizeFn func(p *eth.ExecutionPayloadEnvelope) uint64) *PayloadsQueue

func (*PayloadsQueue) Len

func (upq *PayloadsQueue) Len() int

func (*PayloadsQueue) MemSize

func (upq *PayloadsQueue) MemSize() uint64

func (*PayloadsQueue) Peek

Peek retrieves the payload with the lowest block number from the queue in O(1), or nil if the queue is empty.

func (*PayloadsQueue) Pop

Pop removes the payload with the lowest block number from the queue in O(log(N)), and may return nil if the queue is empty.

func (*PayloadsQueue) Push

Push adds the payload to the queue, in O(log(N)).

Don't DoS ourselves by buffering too many unsafe payloads. If the queue size after pushing exceed the allowed memory, then pop payloads until memory is not exceeding anymore.

We prefer higher block numbers over lower block numbers, since lower block numbers are more likely to be conflicts and/or read from L1 sooner. The higher payload block numbers can be preserved, and once L1 contents meets these, they can all be processed in order.

type ReceivedUnsafePayloadEvent added in v1.8.0

type ReceivedUnsafePayloadEvent struct {
	Envelope *eth.ExecutionPayloadEnvelope
}

func (ReceivedUnsafePayloadEvent) String added in v1.8.0

func (ev ReceivedUnsafePayloadEvent) String() string

Jump to

Keyboard shortcuts

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