Skip to content

Sync engine: backfill, streaming, and gap recovery #11

@tac0turtle

Description

@tac0turtle

Summary

Implement the sync engine (pkg/sync/) that orchestrates fetching namespace data from upstream and persisting it to the store.

State machine

INITIALIZING → BACKFILLING → STREAMING
                    ↑            │
                    └────────────┘ (gap detected)

Components

Coordinator (pkg/sync/coordinator.go)

  • Manages state transitions between backfill and streaming modes
  • Loads checkpoint from store on startup
  • Determines start height from config or last checkpoint

Backfill (pkg/sync/backfill.go)

Subscription manager (pkg/sync/subscriptions.go)

Interface dependency

Consumes DataFetcher interface (pkg/fetch/fetcher.go):

type DataFetcher interface {
    GetHeader(ctx context.Context, height uint64) (*header.ExtendedHeader, error)
    GetBlobs(ctx context.Context, height uint64, ns Namespace) ([]*blob.Blob, error)
    GetNetworkHead(ctx context.Context) (uint64, error)
    SubscribeHeaders(ctx context.Context) (<-chan *header.ExtendedHeader, error)
    Close() error
}

References

  • Design doc: test_plan.md — Sync Engine section

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions