Skip to content

Commit

Permalink
sync-interop: NDNd SvSync
Browse files Browse the repository at this point in the history
  • Loading branch information
yoursunny committed Dec 26, 2024
1 parent d953fe6 commit 8728e23
Show file tree
Hide file tree
Showing 22 changed files with 76 additions and 41 deletions.
2 changes: 1 addition & 1 deletion integ/browser-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"puppeteer": "^23.11.1",
"ts-loader": "^9.5.1",
"tslib": "^2.8.1",
"type-fest": "^4.30.2",
"type-fest": "^4.31.0",
"webpack": "^5.97.1",
"webpack-cli": "^6.0.1",
"webpack-dev-server": "^5.2.0"
Expand Down
56 changes: 43 additions & 13 deletions integ/sync-interop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,52 +101,82 @@ corepack pnpm literate integ/sync-interop/syncps.ts
Test environment:

* Ubuntu 22.04
* ndn-cxx 0.8.1-88-g5eb7a075
* NFD 22.12-69-gec352f2b
* Node.js 20.12.2
* ndn-cxx 0.9.0-1-g0311642a
* NFD 24.07-1-gee97f534
* Node.js v22.11.0
* Go 1.23.4

Reference implementation:

* [StateVectorSync C++ library](https://github.com/named-data/ndn-svs) commit `1bf5c25dcc3085affae58e87e3e85d0eedee6561` (2024-04-27)
* [StateVectorSync C++ library](https://github.com/named-data/ndn-svs) commit `e502c2aef95640d33b51c92c9659ec0bb7ee6386` (2024-12-15)
* [SVS v2](https://github.com/named-data/ndn-svs/pull/26) commit `1290954f8d0d5c1f61caab9ac1aeacde500c9990` (2024-03-08)
* [NDNd](https://github.com/named-data/ndnd) commit `e5c2033375770932ea049a5bde9a9c1db7b6dcce` (2024-12-25)

Build reference program:

```bash
# in ndn-svs directory
./waf configure --with-examples
./waf

# in $HOME directory
go install -v github.com/named-data/ndnd/std/examples/low-level/svs@@v1.4.1-0.20241225025915-e5c203337577
```

Environment variables:

```bash
# if testing with C++, SVS v1
export NDNTS_INTEROP_SVS2=0
export NDNTS_INTEROP_B64HMAC=dGhpcyBpcyBhIHNlY3JldCBtZXNzYWdl
export NDNTS_INTEROP_HASMSG=1

# if testing with C++, SVS v2
export NDNTS_INTEROP_SVS2=1
export NDNTS_INTEROP_B64HMAC=dGhpcyBpcyBhIHNlY3JldCBtZXNzYWdl
export NDNTS_INTEROP_HASMSG=1

# if testing with NDNd
export NDNTS_INTEROP_SVS2=1
export NDNTS_INTEROP_B64HMAC=''
export NDNTS_INTEROP_HASMSG=0
```

Test `SvSync`:

```bash
# in ndn-svs directory
# C++: in ndn-svs directory
LD_LIBRARY_PATH=build ./build/examples/chat /${RANDOM}

# in NDNts directory
export NDNTS_INTEROP_SVS2=1 # if testing SVS v2
# NDNd: in $HOME directory
~/go/bin/svs ndnd-${RANDOM}

# in NDNts directory, after setting environment variables
corepack pnpm literate integ/sync-interop/svsync.ts
```

Test `SvPublisher`:

```bash
# in NDNts directory
export NDNTS_INTEROP_SVS2=1 # if testing SVS v2
# in NDNts directory, after setting environment variables
corepack pnpm literate integ/sync-interop/svsps-publisher.ts

# in ndn-svs directory
# C++: in ndn-svs directory
LD_LIBRARY_PATH=build ./build/examples/chat-pubsub /${RANDOM}
```

Test `SvSubscriber`:

```bash
# in ndn-svs directory
# C++: in ndn-svs directory
LD_LIBRARY_PATH=build ./build/examples/chat-pubsub /${RANDOM}

# in NDNts directory
export NDNTS_INTEROP_SVS2=1 # if testing SVS v2
# in NDNts directory, after setting environment variables
corepack pnpm literate integ/sync-interop/svsps-subscriber.ts
```

What to do and what to observe:

* For C++ `chat` or `chat-pubsub` publisher: type a line on the console and press ENTER to publish an update.
* NDNts and NDNd publisher do not need user interaction.
* Look at console logs: when one peer publishes an update, the other peer should see the update.
20 changes: 11 additions & 9 deletions integ/sync-interop/svs-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ export const myDataPrefix = myID.append(...syncPrefix.comps);
export async function openSvSync(): Promise<SvSync> {
await openUplinks();

const key = await HMAC.cryptoGenerate({
importRaw: Buffer.from("dGhpcyBpcyBhIHNlY3JldCBtZXNzYWdl", "base64"),
}, false);
const opts: SvSync.Options = {
syncPrefix,
signer: createSigner(HMAC, key),
verifier: createVerifier(HMAC, key),
};
const opts: SvSync.Options = { syncPrefix };

if (process.env.NDNTS_INTEROP_SVS2) {
const b64hmac = process.env.NDNTS_INTEROP_B64HMAC;
if (b64hmac) {
const key = await HMAC.cryptoGenerate({
importRaw: Buffer.from(b64hmac, "base64"),
}, false);
opts.signer = createSigner(HMAC, key);
opts.verifier = createVerifier(HMAC, key);
}

if (process.env.NDNTS_INTEROP_SVS2 === "1") {
opts.svs2interest = true;
opts.svs2suppression = true;
}
Expand Down
3 changes: 3 additions & 0 deletions integ/sync-interop/svsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ exitClosers.push(producer);
sync.addEventListener("update", (update) => {
const { id, loSeqNum, hiSeqNum } = update;
console.log(`UPDATE ${id} ${loSeqNum}..${hiSeqNum}`);
if (process.env.NDNTS_INTEROP_HASMSG === "0") {
return;
}
for (const seqNum of update.seqNums()) {
void (async () => {
try {
Expand Down
2 changes: 1 addition & 1 deletion mk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"js-yaml": "^4.1.0",
"readlink": "^3.0.0",
"split2": "^4.2.0",
"type-fest": "^4.30.2"
"type-fest": "^4.31.0"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@yoursunny/xo-config": "0.60.0",
"codedown": "^3.2.1",
"tslib": "^2.8.1",
"typedoc": "^0.27.5",
"typedoc": "^0.27.6",
"typescript": "~5.7.2",
"vitest": "^2.1.8"
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/autoconfig/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@
"@types/default-gateway": "^7.2.2",
"@types/koa": "^2.15.0",
"koa": "^2.15.3",
"type-fest": "^4.30.2"
"type-fest": "^4.31.0"
}
}
2 changes: 1 addition & 1 deletion pkg/keychain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"idb-keyval": "^6.2.1",
"mnemonist": "^0.39.8",
"tslib": "^2.8.1",
"type-fest": "^4.30.2",
"type-fest": "^4.31.0",
"wait-your-turn": "^1.0.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion pkg/l3face/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"retry": "^0.13.1",
"streaming-iterables": "^8.0.1",
"tslib": "^2.8.1",
"type-fest": "^4.30.2",
"type-fest": "^4.31.0",
"typescript-event-target": "^1.1.1"
}
}
2 changes: 1 addition & 1 deletion pkg/nac/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@yoursunny/asn1": "0.0.20200718",
"mnemonist": "^0.39.8",
"tslib": "^2.8.1",
"type-fest": "^4.30.2"
"type-fest": "^4.31.0"
},
"devDependencies": {
"@ndn/l3face": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion pkg/ndncert/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"nodemailer": "^6.9.16",
"p-timeout": "^6.1.3",
"tslib": "^2.8.1",
"type-fest": "^4.30.2",
"type-fest": "^4.31.0",
"typescript-event-target": "^1.1.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion pkg/nfdmgmt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"devDependencies": {
"@ndn/l3face": "workspace:*",
"@ndn/node-transport": "workspace:*",
"type-fest": "^4.30.2",
"type-fest": "^4.31.0",
"typescript-event-target": "^1.1.1"
}
}
2 changes: 1 addition & 1 deletion pkg/node-transport/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"event-iterator": "^2.0.0",
"p-event": "^6.0.1",
"tslib": "^2.8.1",
"type-fest": "^4.30.2",
"type-fest": "^4.31.0",
"url-format-lax": "^2.0.0",
"url-parse-lax": "^5.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/packet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"buffer-compare": "^1.1.1",
"mnemonist": "^0.39.8",
"tslib": "^2.8.1",
"type-fest": "^4.30.2"
"type-fest": "^4.31.0"
},
"devDependencies": {
"@types/buffer-compare": "^0.0.33"
Expand Down
2 changes: 1 addition & 1 deletion pkg/pyrepo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@ndn/util": "workspace:*",
"streaming-iterables": "^8.0.1",
"tslib": "^2.8.1",
"type-fest": "^4.30.2",
"type-fest": "^4.31.0",
"typescript-event-target": "^1.1.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion pkg/repo-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@
"@ndn/node-transport": "workspace:*",
"@ndn/segmented-object": "workspace:*",
"stream-mock": "^2.0.5",
"type-fest": "^4.30.2"
"type-fest": "^4.31.0"
}
}
2 changes: 1 addition & 1 deletion pkg/repo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"memory-level": "^2.0.0",
"streaming-iterables": "^8.0.1",
"tslib": "^2.8.1",
"type-fest": "^4.30.2",
"type-fest": "^4.31.0",
"typescript-event-target": "^1.1.1",
"wait-your-turn": "^1.0.1"
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/segmented-object/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@
"@ndn/l3face": "workspace:*",
"@ndn/repo-api": "workspace:*",
"stream-mock": "^2.0.5",
"type-fest": "^4.30.2"
"type-fest": "^4.31.0"
}
}
2 changes: 1 addition & 1 deletion pkg/svs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@ndn/util": "workspace:*",
"streaming-iterables": "^8.0.1",
"tslib": "^2.8.1",
"type-fest": "^4.30.2",
"type-fest": "^4.31.0",
"typescript-event-target": "^1.1.1",
"wait-your-turn": "^1.0.1"
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/tlv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
"@ndn/util": "workspace:*",
"mnemonist": "^0.39.8",
"tslib": "^2.8.1",
"type-fest": "^4.30.2"
"type-fest": "^4.31.0"
}
}
2 changes: 1 addition & 1 deletion pkg/trust-schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"mnemonist": "^0.39.8",
"obliterator": "^2.0.4",
"tslib": "^2.8.1",
"type-fest": "^4.30.2"
"type-fest": "^4.31.0"
},
"devDependencies": {
"@ndn/l3face": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"streaming-iterables": "^8.0.1",
"tiny-invariant": "^1.3.3",
"tslib": "^2.8.1",
"type-fest": "^4.30.2",
"type-fest": "^4.31.0",
"wait-your-turn": "^1.0.1"
},
"devDependencies": {
Expand Down

0 comments on commit 8728e23

Please sign in to comment.