@effectstream/sync 0.100.14 → 0.100.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # @effectstream/sync
2
+
3
+ The blockchain-sync service inside an EffectStream node. Reads finalized
4
+ blocks from every chain you've configured (EVM, Bitcoin, Cardano, Midnight,
5
+ Avail, Celestia, NEAR…), normalizes them into a single rollup ordering,
6
+ and stages the inputs the state machine consumes.
7
+
8
+ - Blockchain-sync service: reads finalized blocks from every configured chain.
9
+ - Normalises into a single rollup ordering and stages inputs for the state machine.
10
+ - Drop-in fetchers: EVM, Bitcoin, Cardano UTXO-RPC, Midnight, Avail, Celestia, NEAR, NTP.
11
+ - `genSyncProtocols(config)` is what the runtime calls during boot.
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ bun add @effectstream/sync
17
+ # or
18
+ npm install @effectstream/sync
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ This package pairs with [`@effectstream/runtime`](https://www.npmjs.com/package/@effectstream/runtime),
24
+ which boots sync as part of `start()`: it calls `genSyncProtocols(...)`
25
+ against the `syncProtocols` section of your
26
+ [`@effectstream/config`](https://www.npmjs.com/package/@effectstream/config),
27
+ then drives the resulting fetcher + state pairs every block. As an app
28
+ author you declare which protocols to sync in your config; everything
29
+ else runs automatically.
30
+
31
+ If you're building a new chain integration, implement the sync-protocol
32
+ interfaces in [`src/sync-protocols/`](https://github.com/effectstream/effectstream/tree/main/packages/node-sdk/sync/src/sync-protocols).
33
+
34
+ ## Inside EffectStream
35
+
36
+ `genSyncProtocols(config)` is what the runtime calls during boot. It walks
37
+ the `syncProtocols` section of your `@effectstream/config`, instantiates a
38
+ fetcher for each chain (viem for EVM, UTXORpc for Cardano, the Midnight
39
+ SDK for Midnight, etc.), and writes paginated blocks into PostgreSQL
40
+ through `@effectstream/db`. The state machine then drains that queue.
41
+
42
+ ```typescript
43
+ import { genSyncProtocols } from "@effectstream/sync";
44
+ // inside the runtime startup path:
45
+ const protocols = await genSyncProtocols(config);
46
+ // protocols.parallelEvmRPC_fast.runOne() // poll one block
47
+ ```
48
+
49
+ ## Key exports
50
+
51
+ - `genSyncProtocols(dbConn, syncInfo)` — Effection generator that instantiates a runtime fetcher + state pair for every protocol in `syncInfo` (from `config.syncProtocols`). Called from the runtime's process-blocks loop.
52
+ - `AllSyncProtocols` — union type covering every supported protocol; useful when authoring config that fans out.
53
+ - `ChainBlock`, plus base `Fetcher`/`State` types from `sync-protocols/base/` — the wire shape per chain.
54
+
55
+ Per-chain `Fetcher` / `SyncState` classes (`EvmFetcher`,
56
+ `BitcoinFetcher`, `MidnightFetcher`, `AvailFetcher`, `UtxoRpcFetcher`,
57
+ `NtpFetcher`, `CelestiaFetcher`, `NearFetcher`, and matching `*SyncState`
58
+ classes) are exported but are internal to the factory wiring —
59
+ application code drives them through `genSyncProtocols` rather than
60
+ instantiating them directly. Reach for them only if you're writing a
61
+ custom orchestration layer.
62
+
63
+ ## Examples
64
+
65
+ End-to-end sync test (boots a node, reads blocks, asserts the DB):
66
+ [`e2e/evm/sync/`](https://github.com/effectstream/effectstream/tree/main/e2e/evm/sync).
67
+
68
+ Runnable: [`test/examples.test.ts`](./test/examples.test.ts).
69
+
70
+ ## Links
71
+
72
+ - Docs: https://effectstream.github.io/docs/packages/node/sync
73
+ - Source: https://github.com/effectstream/effectstream/tree/main/packages/node-sdk/sync
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effectstream/sync",
3
- "version": "0.100.14",
3
+ "version": "0.100.16",
4
4
  "license": "MIT",
5
5
  "homepage": "https://effectstream.github.io/docs/",
6
6
  "repository": {
@@ -13,10 +13,10 @@
13
13
  },
14
14
  "exports": "./src/mod.ts",
15
15
  "dependencies": {
16
- "@effectstream/config": "0.100.14",
17
- "@effectstream/db": "0.100.14",
18
- "@effectstream/log": "0.100.14",
19
- "@effectstream/utils": "0.100.14",
16
+ "@effectstream/config": "0.100.16",
17
+ "@effectstream/db": "0.100.16",
18
+ "@effectstream/log": "0.100.16",
19
+ "@effectstream/utils": "0.100.16",
20
20
  "@midnight-ntwrk/ledger-v8": "8.0.3",
21
21
  "@midnight-ntwrk/midnight-js-indexer-public-data-provider": "4.0.2",
22
22
  "@midnight-ntwrk/onchain-runtime": "npm:@midnight-ntwrk/onchain-runtime-v3@3.0.0",
@@ -0,0 +1,18 @@
1
+ // Examples for the README — verify public exports resolve.
2
+
3
+ import { test, expect } from "bun:test";
4
+ import * as sync from "../src/mod.ts";
5
+
6
+ test("README: genSyncProtocols is exported as a generator factory", () => {
7
+ expect(typeof sync.genSyncProtocols).toBe("function");
8
+ });
9
+
10
+ test("README: per-chain fetchers and states are exported", () => {
11
+ // A sampling of the protocols supported by the package.
12
+ expect("EvmFetcher" in sync).toBe(true);
13
+ expect("BitcoinFetcher" in sync).toBe(true);
14
+ expect("MidnightFetcher" in sync).toBe(true);
15
+ expect("AvailFetcher" in sync).toBe(true);
16
+ expect("UtxoRpcFetcher" in sync).toBe(true);
17
+ expect("CelestiaFetcher" in sync).toBe(true);
18
+ });