da

package
v1.1.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrForceInclusionNotConfigured = errors.New("forced inclusion namespace not configured")

ErrForceInclusionNotConfigured is returned when the forced inclusion namespace is not configured.

Functions

This section is empty.

Types

type AsyncBlockRetriever

type AsyncBlockRetriever interface {
	Start(ctx context.Context)
	Stop()
	GetCachedBlock(ctx context.Context, daHeight uint64) (*BlockData, error)
	UpdateCurrentHeight(height uint64)
}

AsyncBlockRetriever provides background prefetching of DA blocks

func NewAsyncBlockRetriever

func NewAsyncBlockRetriever(
	client Client,
	logger zerolog.Logger,
	namespace []byte,
	daBlockTime time.Duration,
	daStartHeight uint64,
	prefetchWindow uint64,
) AsyncBlockRetriever

NewAsyncBlockRetriever creates a new async block retriever with in-memory cache.

type BlockData

type BlockData struct {
	Height    uint64
	Timestamp time.Time
	Blobs     [][]byte
}

BlockData contains data retrieved from a single DA height

type Client

type Client interface {
	// Submit submits blobs to the DA layer.
	Submit(ctx context.Context, data [][]byte, gasPrice float64, namespace []byte, options []byte) datypes.ResultSubmit

	// Retrieve retrieves blobs from the DA layer at the specified height and namespace.
	Retrieve(ctx context.Context, height uint64, namespace []byte) datypes.ResultRetrieve

	// RetrieveBlobs retrieves blobs from the DA layer at the specified height and namespace
	// without requiring a DA header timestamp. Callers that need deterministic DA time should
	// use Retrieve instead.
	RetrieveBlobs(ctx context.Context, height uint64, namespace []byte) datypes.ResultRetrieve

	// Get retrieves blobs by their IDs. Used for visualization and fetching specific blobs.
	Get(ctx context.Context, ids []datypes.ID, namespace []byte) ([]datypes.Blob, error)

	// Subscribe returns a channel that emits one SubscriptionEvent per DA block
	// that contains a blob in the given namespace. The channel is closed when ctx
	// is cancelled. Callers MUST drain the channel after cancellation.
	// The fetchTimestamp param is going to be removed with https://github.com/evstack/ev-node/issues/3142 as the timestamp is going to be included by default
	Subscribe(ctx context.Context, namespace []byte, fetchTimestamp bool) (<-chan datypes.SubscriptionEvent, error)

	// GetLatestDAHeight returns the latest height available on the DA layer.
	GetLatestDAHeight(ctx context.Context) (uint64, error)

	// Namespace accessors.
	GetHeaderNamespace() []byte
	GetDataNamespace() []byte
	GetForcedInclusionNamespace() []byte
	HasForcedInclusionNamespace() bool
}

Client represents the DA client contract.

type Config

type Config struct {
	DA                       *blobrpc.Client
	Logger                   zerolog.Logger
	DefaultTimeout           time.Duration
	Namespace                string
	DataNamespace            string
	ForcedInclusionNamespace string
}

Config contains configuration for the blob DA client.

type ForcedInclusionEvent

type ForcedInclusionEvent struct {
	Timestamp     time.Time
	StartDaHeight uint64
	EndDaHeight   uint64
	Txs           [][]byte
}

ForcedInclusionEvent contains forced inclusion transactions retrieved from DA.

type ForcedInclusionRetriever

type ForcedInclusionRetriever interface {
	RetrieveForcedIncludedTxs(ctx context.Context, daHeight uint64) (*ForcedInclusionEvent, error)
	Start(ctx context.Context)
	Stop()
}

ForcedInclusionRetriever defines the interface for retrieving forced inclusion transactions from DA.

func NewForcedInclusionRetriever

func NewForcedInclusionRetriever(
	client Client,
	logger zerolog.Logger,
	daBlockTime time.Duration,
	tracingEnabled bool,
	daStartHeight, daEpochSize uint64,
) ForcedInclusionRetriever

NewForcedInclusionRetriever creates a new forced inclusion retriever. It internally creates and manages an AsyncBlockRetriever for background prefetching.

type FullClient

type FullClient interface {
	Client
	Verifier
}

FullClient combines Client and Verifier interfaces. This is the complete interface implemented by the concrete DA client.

func NewClient

func NewClient(cfg Config) FullClient

NewClient creates a new blob client wrapper with pre-calculated namespace bytes.

func WithTracingClient

func WithTracingClient(inner FullClient) FullClient

WithTracingClient decorates the provided client with tracing spans.

type Subscriber

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

Subscriber is a shared DA subscription primitive that encapsulates the follow/catchup lifecycle. It subscribes to one or more DA namespaces, tracks the highest seen DA height, and drives sequential catchup via callbacks on SubscriberHandler.

Used by both DAFollower (syncing) and asyncBlockRetriever (forced inclusion).

func NewSubscriber

func NewSubscriber(cfg SubscriberConfig) *Subscriber

NewSubscriber creates a new Subscriber.

func (*Subscriber) HasReachedHead

func (s *Subscriber) HasReachedHead() bool

HasReachedHead returns whether the subscriber has caught up to DA head.

func (*Subscriber) HighestSeenDAHeight

func (s *Subscriber) HighestSeenDAHeight() uint64

HighestSeenDAHeight returns the highest DA height seen from the subscription.

func (*Subscriber) LocalDAHeight

func (s *Subscriber) LocalDAHeight() uint64

LocalDAHeight returns the current local DA height.

func (*Subscriber) Start

func (s *Subscriber) Start(ctx context.Context) error

Start begins the follow and catchup goroutines.

func (*Subscriber) Stop

func (s *Subscriber) Stop()

Stop gracefully stops the background goroutines.

type SubscriberConfig

type SubscriberConfig struct {
	Client      Client
	Logger      zerolog.Logger
	Namespaces  [][]byte // subscribe to all, merge into one channel
	DABlockTime time.Duration
	Handler     SubscriberHandler
	// Deprecated: Remove with https://github.com/evstack/ev-node/issues/3142
	FetchBlockTimestamp bool // the timestamp comes with an extra api call before Celestia v0.29.1-mocha.

	StartHeight uint64 // initial localDAHeight
}

SubscriberConfig holds configuration for creating a Subscriber.

type SubscriberHandler

type SubscriberHandler interface {
	// HandleEvent processes a subscription event.
	// isInline is true if the subscriber successfully claimed this height (via CAS).
	// Returning an error when isInline is true instructs the Subscriber to roll back the localDAHeight.
	HandleEvent(ctx context.Context, ev datypes.SubscriptionEvent, isInline bool) error

	// HandleCatchup is called for each height during sequential catchup.
	// The subscriber advances localDAHeight only after this returns (true, nil).
	// Returning an error rolls back localDAHeight and triggers a backoff retry.
	HandleCatchup(ctx context.Context, height uint64) error
}

SubscriberHandler is the callback interface for subscription consumers. Implementations drive the consumer-specific logic (caching, piping events, etc.).

type Verifier

type Verifier interface {
	// GetProofs returns inclusion Proofs for Blobs specified by their IDs.
	GetProofs(ctx context.Context, ids []datypes.ID, namespace []byte) ([]datypes.Proof, error)

	// Validate validates Commitments against the corresponding Proofs.
	Validate(ctx context.Context, ids []datypes.ID, proofs []datypes.Proof, namespace []byte) ([]bool, error)
}

Verifier defines the interface for DA proof verification operations. This is a subset of the DA interface used by sequencers to verify batch inclusion.

Jump to

Keyboard shortcuts

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