Skip to content

Commit 82c800c

Browse files
x3c41aclaude
andcommitted
Add --skip-authorize and --skip-ipfs-verify flags for live network testing
- Add --skip-authorize flag to skip sudo authorization (for pre-authorized accounts) - Add --skip-ipfs-verify flag to skip IPFS download verification - Update justfile live test recipes to use new flags Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 068b599 commit 82c800c

File tree

4 files changed

+64
-599
lines changed

4 files changed

+64
-599
lines changed

examples/justfile

Lines changed: 5 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -632,155 +632,33 @@ run-authorize-preimage-and-store-papi runtime ws_url="ws://localhost:10000" seed
632632
# ============================================================================
633633
#
634634
# Run store-big-data test against live Bulletin chain deployments.
635-
# These require pre-authorized accounts and a local Docker Kubo connected to collators.
635+
# These require pre-authorized accounts.
636636
#
637637
# Usage:
638638
# just run-live-tests-westend <seed>
639639
# just run-live-tests-westend <seed> http://127.0.0.1:8283 small
640-
# just run-live-tests-paseo <seed>
641-
#
642-
# Prerequisites for IPFS retrieval:
643-
# 1. Start local IPFS: docker run -d --name ipfs-node -p 4011:4011 -p 5011:5011 -p 8283:8283 ipfs/kubo:latest
644-
# 2. Connect to Bulletin IPFS nodes: docker exec ipfs-node ipfs swarm connect <multiaddr>
645-
# (Get multiaddrs by querying the collators' IPFS peer info)
646640

647641
# Live network endpoints
648642
WESTEND_RPC := "wss://westend-bulletin-rpc.polkadot.io"
649643
PASEO_RPC := "wss://paseo-bulletin-rpc.polkadot.io"
650644

651-
# Run store-big-data-live test against a live endpoint
645+
# Run store-big-data test against a live endpoint
652646
# Parameters:
653647
# ws_url - WebSocket URL of the Bulletin chain node
654648
# seed - Account seed phrase (must be pre-authorized on the network)
655-
# ipfs_gateway_url - IPFS Gateway URL (default: http://127.0.0.1:8283 for local Docker Kubo)
656-
# image_size - Image size preset: small, big32, big64, big96 (default: small for live tests)
649+
# ipfs_gateway_url - IPFS Gateway URL (default: http://127.0.0.1:8283)
650+
# image_size - Image size preset: small, big32, big64, big96 (default: small)
657651
_run-live-tests ws_url seed ipfs_gateway_url="http://127.0.0.1:8283" image_size="small": npm-install
658652
#!/usr/bin/env bash
659653
set -e
660654
echo "🌐 Running live tests against: {{ ws_url }}"
661-
echo " IPFS Gateway: {{ ipfs_gateway_url }}"
662-
echo " Image size: {{ image_size }}"
663-
664655
just papi-generate "{{ ws_url }}"
665-
666-
# Check if IPFS peers are configured for live network
667-
EXTRA_FLAGS=""
668-
if [ -z "$WESTEND_PEER1_ID" ] || [ -z "$WESTEND_PEER1_ADDR" ]; then
669-
echo ""
670-
echo "⚠️ IPFS peer info not configured - running storage-only test."
671-
echo " To enable IPFS verification, set WESTEND_PEER1_ID and WESTEND_PEER1_ADDR."
672-
echo ""
673-
EXTRA_FLAGS="--skip-ipfs-verify"
674-
fi
675-
676-
node store_big_data_live.js "{{ ws_url }}" "{{ seed }}" "{{ ipfs_gateway_url }}" "{{ image_size }}" $EXTRA_FLAGS
656+
node store_big_data.js "{{ ws_url }}" "{{ seed }}" "{{ ipfs_gateway_url }}" "{{ image_size }}" --skip-authorize --skip-ipfs-verify
677657

678658
# Run live tests against Westend Bulletin
679-
# Parameters:
680-
# seed - Account seed phrase (must be pre-authorized on the network)
681-
# ipfs_gateway_url - IPFS Gateway URL (default: http://127.0.0.1:8283)
682-
# image_size - Image size preset: small, big32, big64, big96 (default: small)
683659
run-live-tests-westend seed ipfs_gateway_url="http://127.0.0.1:8283" image_size="small":
684660
just _run-live-tests "{{ WESTEND_RPC }}" "{{ seed }}" "{{ ipfs_gateway_url }}" "{{ image_size }}"
685661

686662
# Run live tests against Paseo Bulletin
687-
# Parameters:
688-
# seed - Account seed phrase (must be pre-authorized on the network)
689-
# ipfs_gateway_url - IPFS Gateway URL (default: http://127.0.0.1:8283)
690-
# image_size - Image size preset: small, big32, big64, big96 (default: small)
691663
run-live-tests-paseo seed ipfs_gateway_url="http://127.0.0.1:8283" image_size="small":
692664
just _run-live-tests "{{ PASEO_RPC }}" "{{ seed }}" "{{ ipfs_gateway_url }}" "{{ image_size }}"
693-
694-
# Setup IPFS for live network testing (starts Docker Kubo)
695-
setup-live-ipfs:
696-
#!/usr/bin/env bash
697-
set -e
698-
echo "🐳 Setting up IPFS for live network testing..."
699-
700-
# Stop existing container if running
701-
docker stop ipfs-node 2>/dev/null || true
702-
docker rm ipfs-node 2>/dev/null || true
703-
docker volume rm ipfs-data 2>/dev/null || true
704-
705-
# Pull and start fresh kubo container
706-
docker pull ipfs/kubo:latest
707-
docker run -d --name ipfs-node -v ipfs-data:/data/ipfs -p 4011:4011 -p 5011:5011 -p 8283:8283 ipfs/kubo:latest
708-
709-
echo " Waiting for IPFS to initialize..."
710-
sleep 5
711-
712-
# Configure for isolated mode (no public DHT)
713-
docker exec ipfs-node ipfs bootstrap rm --all
714-
docker exec ipfs-node ipfs config --json Routing.Type '"none"'
715-
docker exec ipfs-node ipfs config --json Discovery.MDNS.Enabled false
716-
717-
# Restart to apply config
718-
docker restart ipfs-node
719-
sleep 5
720-
721-
docker exec ipfs-node ipfs --version
722-
echo "✅ IPFS ready. Connect to bulletin nodes with:"
723-
echo " docker exec ipfs-node ipfs swarm connect <multiaddr>"
724-
725-
# Connect IPFS to live Westend Bulletin network
726-
# Requires environment variables: WESTEND_PEER1_ID, WESTEND_PEER1_ADDR
727-
# Optional: WESTEND_PEER2_ID, WESTEND_PEER2_ADDR
728-
connect-live-ipfs-westend:
729-
#!/usr/bin/env bash
730-
set -e
731-
732-
if [ -z "$WESTEND_PEER1_ID" ] || [ -z "$WESTEND_PEER1_ADDR" ]; then
733-
echo "❌ Error: Live Westend peer info not configured."
734-
echo ""
735-
echo "Please set environment variables:"
736-
echo " export WESTEND_PEER1_ID='12D3KooW...'"
737-
echo " export WESTEND_PEER1_ADDR='/dns4/collator.example.com/tcp/30333/ws'"
738-
echo ""
739-
echo "Get these from the Westend Bulletin collator operators."
740-
exit 1
741-
fi
742-
743-
echo "🔗 Connecting to live Westend Bulletin IPFS nodes..."
744-
ADDR1="${WESTEND_PEER1_ADDR}/p2p/${WESTEND_PEER1_ID}"
745-
echo " Peer 1: $ADDR1"
746-
docker exec ipfs-node ipfs swarm connect "$ADDR1" || true
747-
748-
if [ -n "$WESTEND_PEER2_ID" ] && [ -n "$WESTEND_PEER2_ADDR" ]; then
749-
ADDR2="${WESTEND_PEER2_ADDR}/p2p/${WESTEND_PEER2_ID}"
750-
echo " Peer 2: $ADDR2"
751-
docker exec ipfs-node ipfs swarm connect "$ADDR2" || true
752-
fi
753-
754-
echo "✅ IPFS connection attempted. Check with: docker exec ipfs-node ipfs swarm peers"
755-
756-
# Start IPFS reconnect script for live Westend network
757-
# Requires environment variables: WESTEND_PEER1_ID, WESTEND_PEER1_ADDR
758-
ipfs-reconnect-live-westend-start test_dir:
759-
#!/usr/bin/env bash
760-
set -e
761-
762-
if [ -z "$WESTEND_PEER1_ID" ] || [ -z "$WESTEND_PEER1_ADDR" ]; then
763-
echo "❌ Error: Live Westend peer info not configured."
764-
exit 1
765-
fi
766-
767-
echo "🔄 Starting IPFS reconnect for live Westend..."
768-
ROOT_DIR="{{ justfile_directory() }}/.."
769-
cd "$ROOT_DIR"
770-
./scripts/ipfs-reconnect-westend-live.sh docker 10 > {{ test_dir }}/ipfs-reconnect-live.log 2>&1 &
771-
cd -
772-
773-
RECONNECT_PID=$!
774-
echo $RECONNECT_PID > {{ test_dir }}/ipfs-reconnect-live.pid
775-
echo " Reconnect PID: $RECONNECT_PID"
776-
echo " Log: {{ test_dir }}/ipfs-reconnect-live.log"
777-
sleep 2
778-
779-
# Teardown IPFS for live network testing
780-
teardown-live-ipfs:
781-
#!/usr/bin/env bash
782-
echo "🛑 Tearing down IPFS for live testing..."
783-
docker stop ipfs-node 2>/dev/null || true
784-
docker rm ipfs-node 2>/dev/null || true
785-
docker volume rm ipfs-data 2>/dev/null || true
786-
echo "✅ IPFS teardown complete"

examples/store_big_data.js

Lines changed: 59 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import { bulletin } from './.papi/descriptors/dist/index.mjs';
3030

3131
// Command line arguments: [ws_url] [seed] [ipfs_gateway_url] [image_size]
3232
// Note: --signer-disc=XX flag is also supported for parallel runs
33+
// Note: --skip-authorize flag skips account authorization (for live networks)
34+
// Note: --skip-ipfs-verify flag skips IPFS download verification
3335
const args = process.argv.slice(2).filter(arg => !arg.startsWith('--'));
3436
const NODE_WS = args[0] || 'ws://localhost:10000';
3537
const SEED = args[1] || '//Alice';
@@ -40,6 +42,11 @@ const IPFS_API_URL = IPFS_GATEWAY_URL.replace(':8283', ':5011');
4042
const IMAGE_SIZE = args[3] || 'big64';
4143
const NUM_SIGNERS = 16;
4244

45+
// Optional flags
46+
const signerDiscriminator = process.argv.find(arg => arg.startsWith("--signer-disc="))?.split("=")[1] ?? null;
47+
const SKIP_AUTHORIZE = process.argv.includes("--skip-authorize");
48+
const SKIP_IPFS_VERIFY = process.argv.includes("--skip-ipfs-verify");
49+
4350
// -------------------- queue --------------------
4451
const queue = [];
4552
function pushToQueue(data) {
@@ -230,13 +237,12 @@ export async function storeChunkedFile(api, filePath) {
230237
}
231238

232239
// Connect to IPFS API (for ipfs-http-client operations like block.get)
233-
const ipfs = create({
234-
url: IPFS_API_URL,
235-
});
236-
237-
// Optional signer discriminator, when we want to run the script in parallel and don't take care of nonces.
238-
// E.g.: node store_big_data.js --signer-disc=BB
239-
const signerDiscriminator = process.argv.find(arg => arg.startsWith("--signer-disc="))?.split("=")[1] ?? null;
240+
let ipfs = null;
241+
if (!SKIP_IPFS_VERIFY) {
242+
ipfs = create({
243+
url: IPFS_API_URL,
244+
});
245+
}
240246

241247
async function main() {
242248
await cryptoWaitReady()
@@ -255,7 +261,6 @@ async function main() {
255261
// Init WS PAPI client and typed api.
256262
client = createClient(getWsProvider(NODE_WS));
257263
const bulletinAPI = client.getTypedApi(bulletin);
258-
const { sudoSigner, _ } = setupKeyringAndSigners(SEED, '//Bigdatasigner');
259264

260265
// Let's do parallelism with multiple accounts
261266
const signers = Array.from({ length: NUM_SIGNERS }, (_, i) => {
@@ -267,15 +272,18 @@ async function main() {
267272
}
268273
});
269274

270-
// Authorize accounts.
271-
await authorizeAccount(
272-
bulletinAPI,
273-
sudoSigner,
274-
signers.map(a => a.address),
275-
100,
276-
BigInt(100 * 1024 * 1024), // 100 MiB
277-
TX_MODE_FINALIZED_BLOCK,
278-
);
275+
// Authorize accounts (skip for live networks with pre-authorized accounts)
276+
if (!SKIP_AUTHORIZE) {
277+
const { sudoSigner, _ } = setupKeyringAndSigners(SEED, '//Bigdatasigner');
278+
await authorizeAccount(
279+
bulletinAPI,
280+
sudoSigner,
281+
signers.map(a => a.address),
282+
100,
283+
BigInt(100 * 1024 * 1024), // 100 MiB
284+
TX_MODE_FINALIZED_BLOCK,
285+
);
286+
}
279287

280288
// Start 8 workers
281289
signers.forEach((signer, i) => {
@@ -311,38 +319,44 @@ async function main() {
311319
);
312320
console.log(`Downloading...${cid} / ${rootCid}`);
313321
assert.deepStrictEqual(cid, rootCid, '❌ CID mismatch between stored and computed DAG root');
314-
let downloadedContent = await fetchCid(IPFS_GATEWAY_URL, rootCid);
315-
console.log(`✅ Reconstructed file size: ${downloadedContent.length} bytes`);
316-
await fileToDisk(downloadedFileByDagPath, downloadedContent);
317-
filesAreEqual(filePath, downloadedFileByDagPath);
318-
assert.strictEqual(
319-
dataSize,
320-
downloadedContent.length,
321-
'❌ Failed to download all the data!'
322-
);
323-
324-
// Check all chunks are there.
325-
console.log(`Downloading by chunks...`);
326-
let downloadedChunks = [];
327-
for (const chunk of chunks) {
328-
// Download the chunk from IPFS.
329-
let block = await ipfs.block.get(chunk.cid, {timeout: 15000});
330-
downloadedChunks.push(block);
331-
}
332-
let fullBuffer = Buffer.concat(downloadedChunks);
333-
console.log(`✅ Reconstructed file size: ${fullBuffer.length} bytes`);
334-
await fileToDisk(downloadedFilePath, fullBuffer);
335-
filesAreEqual(filePath, downloadedFilePath);
336-
assert.strictEqual(
337-
dataSize,
338-
fullBuffer.length,
339-
'❌ Failed to download all the data!'
340-
);
341322

342323
// Print storage statistics
343324
await printStatistics(dataSize, bulletinAPI);
344325

345-
logTestResult(true, 'Store Big Data Test');
326+
if (SKIP_IPFS_VERIFY) {
327+
console.log(`Root CID: ${rootCid}`);
328+
logTestResult(true, 'Store Big Data Test (Storage Only)');
329+
} else {
330+
let downloadedContent = await fetchCid(IPFS_GATEWAY_URL, rootCid);
331+
console.log(`✅ Reconstructed file size: ${downloadedContent.length} bytes`);
332+
await fileToDisk(downloadedFileByDagPath, downloadedContent);
333+
filesAreEqual(filePath, downloadedFileByDagPath);
334+
assert.strictEqual(
335+
dataSize,
336+
downloadedContent.length,
337+
'❌ Failed to download all the data!'
338+
);
339+
340+
// Check all chunks are there.
341+
console.log(`Downloading by chunks...`);
342+
let downloadedChunks = [];
343+
for (const chunk of chunks) {
344+
// Download the chunk from IPFS.
345+
let block = await ipfs.block.get(chunk.cid, {timeout: 15000});
346+
downloadedChunks.push(block);
347+
}
348+
let fullBuffer = Buffer.concat(downloadedChunks);
349+
console.log(`✅ Reconstructed file size: ${fullBuffer.length} bytes`);
350+
await fileToDisk(downloadedFilePath, fullBuffer);
351+
filesAreEqual(filePath, downloadedFilePath);
352+
assert.strictEqual(
353+
dataSize,
354+
fullBuffer.length,
355+
'❌ Failed to download all the data!'
356+
);
357+
358+
logTestResult(true, 'Store Big Data Test');
359+
}
346360
resultCode = 0;
347361
} catch (error) {
348362
logError(`Error: ${error.message}`);

0 commit comments

Comments
 (0)