Cross-Shard Simulation E2E Tests: Improved/Innovative New Test Case

⏱️ 1.5–2 hours📊 Level 5Hands-on lab

Why this project

After Phase 4: Cross-Shard Transactions, you run the deterministic multi-shard simulation E2E in the repo: cross_shard_tx_sim (split_config(): split armed, pool surplus seats child committees). You add trace markers, print per-shard committed heights and transaction status, and relate the polling loop (mempool → committed → executed → finalized) to the five-phase cross-shard story—not a repeat of the single-shard height lab.

Prerequisites

Files you will touch

Step 1 — Baseline run

From the hyperscale-rs repository root:

cargo test -p hyperscale-simulation --test scenarios cross_shard_tx_sim -- --nocapture

Confirm the test passes. Note the ASCII diagram in the test comment (withdraw on shard 0, deposit on shard 1), seed discovery for accounts on different shards, and the final per-shard validator dump (nodes 0–2 vs 3–5).

Step 2 — Trace markers

In cross_shard_tx_sim, add two markers:

  1. After runner.initialize_genesis_with_balances(...) — e.g. println!("[lab-xshard] genesis balances set");
  2. After runner.schedule_initial_event(... SubmitTransaction ...) — e.g. println!("[lab-xshard] cross-shard tx scheduled: {:?}", tx_hash);

Re-run the same cargo test command and confirm both markers appear before the polling loop output.

Step 3 — Per-shard snapshot after warm-up

After the existing runner.run_until(Duration::from_secs(3)); (consensus warm-up), insert a helper that prints:

Use the tx_hash already computed in the test. Print one line per node with a [lab-xshard] prefix. You are not required to assert strict height equality across shards—cross-shard progress is tracked via mempool status and finalization on the transaction hash.

Step 4 — Poll loop visibility

Inside the existing for iteration in 0..100 loop, when finalized first becomes true, add:

println!("[lab-xshard] finalized at iteration {} sim_elapsed={:?}", iteration, runner.now().checked_sub(start_time).unwrap());

After the loop, print runner.stats() once. In your notes (or a comment in a scratch file), map which flags flipped in order: in_mempool, committed, executed, finalized, completed.

Step 5 — Stretch (optional)

What “done” looks like

Next

Continue to Cross-Shard Production E2E hands-on to draft what a production cross-shard integration test would need.