overlay-engine
Core BSV Overlay Services engine. Platform-agnostic — no HTTP, no storage implementation, no Cloudflare deps. Defines the traits that everything else plugs into.
Part of the bsv-overlay-cloudflare workspace. See the
root README for how the four crates compose.
What this crate provides
-
Engine— the central orchestrator. Its public surface mirrors mainline@bsv/overlay@2.2.0:submit(&TaggedBEEF, SubmitMode)— 3-phase pipeline: SPV verify (the reference'stx.verifywalk: merkle paths against theChainTrackerAND every unproven input's script executed, see the rootCLAUDE.md"Submit verification"), dedupe, dispatch to the topic manager(s), record admissions, callBroadcaster.lookup(&LookupQuestion)— dispatch to a registered lookup service.start_gasp_sync()— pull outputs from peers per-topic using the GASP protocol.sync_advertisements()— drive theAdvertiserto issue / find / revoke SHIP/SLAP records for the topics we host.evict_output()— surgical removal of a stored output.
-
Traits that wrap the moving parts of an overlay:
Trait Purpose Implementations StorageTransaction + output persistence, applied-tx dedupe, GASP host-sync cursor MemoryStorage(in-crate, test/dev);D1Storage(inoverlay-cloudflare)TopicManagerPer-topic PushDrop admission validator. Returns outputsToAdmit+coinsToRetainfrom a BEEF.SHIPTopicManager,SLAPTopicManager, etc. (inoverlay-discovery)LookupServicePer-service query handler. Responds to LookupQuestionwith anoutput-listorformula.SHIPLookupService, etc. (inoverlay-discovery)AdvertiserIssues, finds, and revokes on-chain SHIP/SLAP advertisements for self. WalletAdvertiser(inoverlay-discovery),CloudflareAdvertiser(inoverlay-cloudflare)BroadcasterPropagates an admitted transaction (e.g. ARC, peer overlays). WorkerArcBroadcaster,WorkerBroadcaster(inoverlay-cloudflare)ChainTrackerMerkle-root verification for SPV. Absent, submitstill executes scripts (the reference's'scripts only').WorkerChainTracker(inoverlay-cloudflare) -
MemoryStorage— a reference in-memoryStorageimpl for tests and local dev. Enable withfeatures = ["memory-storage"]. -
EngineBuilder— chainable config for constructing anEnginewithout dozens of constructor positional args. Carries thewith_script_verification(bool)escape hatch (DEFAULT ON). -
GASP sync (
gasp.rs) — pure-Rust implementation of the Graph Aware Sync Protocol for overlay-to-overlay ingestion. Works over anyGASPRemotetransport.
Quick taste
use ;
let engine = with_all;
let steak = engine.submit.await?;
Testing
# All tests, including property tests and integration tests
# Live tests (hit a deployed overlay) — requires OVERLAY_URL env var
OVERLAY_URL=https://<your-overlay>.workers.dev \
Categories: unit tests, engine-parity integration tests (ported from
the TS Engine's test suite), cross-SDK (byte-exact BEEF/txid checks
against @bsv/sdk), property tests via proptest, and live smoke
tests against deployed worker(s).
License
Licensed under either of Apache-2.0 or MIT at your option.