Skip to content

More smoke tests#3242

Open
lrubasze wants to merge 26 commits intomainfrom
lrubasze/smoldot_more_smoke_tests
Open

More smoke tests#3242
lrubasze wants to merge 26 commits intomainfrom
lrubasze/smoldot_more_smoke_tests

Conversation

@lrubasze
Copy link
Copy Markdown
Contributor

@lrubasze lrubasze commented May 5, 2026

Summary

  • Three scenarios under e2e-tests/tests/:
    • smoke_fresh (genesis),
    • smoke_cold (snapshot + lightSyncState, no smoldot DB),
    • smoke_warm (snapshot + lightSyncState + persisted databaseContent).
  • Snapshot bundle published to gs://zombienet-db-snaps/zombienet/smoldot_smoke_db/v1/bundle.tar.gz, SHA-pinned in src/snapshot.rs. ARTIFACTS_DIR_OVERRIDE skips download for local iteration
  • snapshot generator added as a dedicated test smoke_generate_snapshots

Full description in e2e-tests/docs/smoke-scenarios.md

@lrubasze lrubasze force-pushed the lrubasze/smoldot_more_smoke_tests branch from a6c331f to c9bb6d7 Compare May 5, 2026 13:17
@lrubasze lrubasze requested review from AndreiEres, gab8i and skunert May 5, 2026 14:53
Copy link
Copy Markdown
Contributor

@AndreiEres AndreiEres left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Statement store tests still work :-)

Comment thread e2e-tests/js/smoke.js Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if you are aware of this, but chainHead_v1_followEvent emits on subscription first the finalized head and then a newBlock event per already known block. So if we want to count real new blocks since subscription time, we would need to wait for the initial burst. Just a thing to consider.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch 😄
Updated

@lrubasze lrubasze changed the base branch from fix/parachain-warm-start to main May 7, 2026 09:51
lrubasze added 21 commits May 7, 2026 10:12
Refactor smoke.rs onto a ScenarioConfig API admitting fresh/cold/warm
cases (cold/warm stubbed). Replace the 50-block warp-gap pre-wait with
a first-finalized gate; smoldot now resolves the warp-sync gate via
normal finality (6b3cfe2). Plan in e2e-tests/docs/smoke-scenarios.md.
Spawns westend-local + people-westend-local from genesis, waits for the
relay to reach a target finalized block, then produces:
- relaychain-db.tgz / parachain-db.tgz (validator-0 / alice data dirs)
- relay-spec.json (sync_state_genSyncSpec; bootNodes stripped)
- para-spec.json (zombienet-emitted; bootNodes stripped)
- smoldot-db/{relay,para}.json (chainHead_unstable_finalizedDatabase)
- sha256 manifest with snapshot.rs constants

Run with `cargo run --bin generate_snapshots -- --out DIR
--target-finalized N`. Defaults to N=100; bump to ~1500 for the real v1
artifact set. Validated end-to-end at N=20 in ~5 min.
Implement the cold/warm branches that were stubbed in the scenario module:
- Parse finalized height from chain-spec lightSyncState and from smoldot
  databaseContent JSONs (smoldot::header::decode).
- Inject current bootnode multiaddrs into runtime spec copies, since the
  committed artifacts have empty bootNodes (port-agnostic by design).
- Pass committed specs to zombienet via with_chain_spec_path.

Add e2e-tests/src/snapshot.rs as the artifact resolver: env-override path
takes priority, then ~/.cache/smoldot-e2e/{version} cache, then GCS
download with sha256 verification. SHA constants are placeholder (empty)
until the v1 artifact set is published — until then only env override is
accepted.

Add tests/smoke_cold.rs and tests/smoke_warm.rs scaffolds.
- Add --spec-at-finalized M; capture relay spec at #M, snapshot DBs at #N.
  Default M = N/2 so the M..N gap exceeds smoldot's warp_sync_minimum_gap
  (32) and smoldot exercises real warp sync — needed to traverse GRANDPA
  authority-set rotations between checkpoint and snapshot.
- Add --relay-db-snapshot / --para-db-snapshot to resume from a prior run's
  tarballs instead of starting from genesis.
- Pre-stage per-node copies of the snapshot tarballs to dodge the TOCTOU
  race in zombienet-provider's `with_db_snapshot` cache (sibling nodes
  sharing one source path corrupt the partially-written file).
Sibling nodes consuming the same snapshot would end up with the source
node's session keys in their keystore (zombienet inserts per-node keys
via author_insertKey on top, but doesn't remove pre-existing ones).
Multiple nodes then try to author for the same slot — chain stalls
under BABE/Aura/GRANDPA equivocation.
- network.rs: stage per-node copies of the snapshot tarballs to dodge
  the TOCTOU race in zombienet's with_db_snapshot cache; tolerate
  smoldot-db hex headers without 0x prefix.
- snapshot.rs: all six artifacts (tarballs, specs, smoldot-db JSONs)
  resolved via GCS + ~/.cache/smoldot-e2e + sha256 verify. SHA constants
  pinned for v1. Single ARTIFACTS_DIR_OVERRIDE env points at a local
  generator output dir for dev iteration.
- smoke_{cold,warm}.rs: ? on the resolver calls.
- docs/smoke-scenarios.md: updated layout and override docs.
- Generator now produces a light-sync-state copy of each chain spec
  (genesis.raw → genesis.stateRootHash) alongside the full one. Smoldot
  loads the small spec; substrate keeps using the full one. Cuts smoldot
  init time and shrinks the artifact ~30x for these specs.
- All published artifacts are wrapped into a single bundle.tar.gz on GCS;
  snapshot.rs downloads + sha-verifies once per ARTIFACTS_VERSION and
  extracts in place. Single SHA constant replaces the per-file matrix.
- Reset BUNDLE_SHA256 to placeholder; will be filled in once the regen
  with the new shape lands.
- Trimmed docs/smoke-scenarios.md to scenario summary, bundle layout,
  and regeneration procedure (drops content already in source).
ISO 8601 prefix on smoldot logCallback output and PASS/FAIL report
lines, so cross-correlating with Rust-side env_logger entries during
test debugging stops being a guessing game.
Tarring before the smoldot dump captured the network DBs at an earlier
point than smoldot's persisted finalized. When the test later spawned
from the snapshot, smoldot's persisted block didn't yet exist in the
validator's DB and smoldot stalled on storage-proof-request-error
trying to fetch the runtime there.
…zedHead

Smoldot blocks legacy JSON-RPC functions until the warp-sync gate has
opened, so calling chain_getFinalizedHead right after addChain races
the gate and the warm path times out. Subscribe chainHead_v1_follow on
the relay, wait for the `initialized` event (which fires after warp
sync), grab the newest finalized block hash, fetch its header via
chainHead_v1_header, and decode the block number from the SCALE
compact-encoded number. Also bump the para chainHead deadline to 180s
so warm-path catch-up has headroom.
The lower-bound assertion on smoldot's first reported finalized block
exists to prove smoldot honoured the artifact's checkpoint (didn't
fall back to genesis). The new name says what it is and what's
expected of it.

  Rust    finalized_floor       -> expected_initial_finalized
  JS      finalizedFloor        -> expectedInitialFinalized
  env     FINALIZED_FLOOR       -> EXPECTED_INITIAL_FINALIZED
Promote network::extract_emitted_specs to public spawned_chain_spec_paths
and drop the near-identical helper in statement.rs.
Move src/bin/generate_snapshots.rs to tests/smoke_generate_snapshots.rs
as a #[tokio::test] #[ignore], driven by SMOKE_SNAPSHOT_* env vars
instead of CLI flags. Bumps DEFAULT_TARGET_FINALIZED 100 -> 2500.
Show ZOMBIE_PROVIDER=native and TARGET_FINALIZED=2500/SPEC_AT_FINALIZED=1250
in the genesis-run example, and fix the stale tests/generate_snapshots.rs
path to tests/smoke_generate_snapshots.rs.
Renumbers existing rows to 0001-0006 to keep the sequence tight.
@lrubasze lrubasze force-pushed the lrubasze/smoldot_more_smoke_tests branch from 71146d8 to b2f2f58 Compare May 7, 2026 10:14
BigTava added a commit that referenced this pull request May 7, 2026
Avoids matrix-slot collision with PR #3242 (more smoke tests), which
takes 0004-0006.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants