Skip to content

ci: add mainnet sync test (first 1000 blocks)#1460

Merged
gilescope merged 12 commits into
mainfrom
oscar-sync-mainnet-1000
May 6, 2026
Merged

ci: add mainnet sync test (first 1000 blocks)#1460
gilescope merged 12 commits into
mainfrom
oscar-sync-mainnet-1000

Conversation

@ozgb

@ozgb ozgb commented May 5, 2026

Copy link
Copy Markdown
Contributor

Overview

Adds a sync-test for the first 1000 blocks of mainnet. Uses a snapshot of Cardano mainnet containing only the mainnet data we need (6.8 MB)

Added:

  • Script to construct a new snapshot from a db-sync postgres instance
  • Script to run the sync test
  • Earthly targets for both

Example: https://github.com/midnightntwrk/midnight-node/actions/runs/25375174559/job/74411117476?pr=1460

🗹 TODO before merging

  • Ready

📌 Submission Checklist

  • All commits are signed off (git commit -s) for the DCO
  • Changes are backward-compatible (or flagged if breaking)
  • Pull request description explains why the change is needed
  • Self-reviewed the diff
  • I have included a change file, or skipped for this reason: Only affects CI
  • If the changes introduce a new feature, I have bumped the node minor version
  • Update documentation (if relevant)
  • Updated AGENTS.md if build commands, architecture, or workflows changed
  • No new todos introduced

🧪 Testing Evidence

Please describe any additional testing aside from CI:

  • Additional tests are provided (if possible)

🔱 Fork Strategy

  • Node Runtime Update
  • Node Client Update
  • Other:
  • N/A

Links

@ozgb ozgb requested a review from a team as a code owner May 5, 2026 11:47
ozgb added 10 commits May 5, 2026 12:51
Adds +sync-mainnet-1000 / +sync-mainnet-1000-snapshot earthly targets that
verify a fresh midnight-node can sync the first 1000 blocks of Midnight
Mainnet against a captive postgres preloaded with a minimal cardano-db-sync
snapshot.

The snapshot generator (scripts/sync-test/build-snapshot.sh) runs against a
host-local db-sync and dumps just enough rows for the cnight-observation,
committee-selection, federated-authority and bridge data sources to return
identical results to the producer's full db-sync over the cardano window
that Midnight blocks 1..1000 reference. Server-side TEMP TABLEs materialise
the consumed-in-window NIGHT producer set once, then every COPY filters off
it -- without that, the cnight inherent's byte-exact equality check fails
on block #1 and best stays at #0 forever.

The runner (scripts/sync-test/run-sync.sh) spins up a postgres:17.4-alpine
container with self-signed TLS (matching midnight-node's PgSslMode::Require),
loads the snapshot, runs midnight-node with CFG_PRESET=mainnet, and tails
its logs until 'best: #N >= SYNC_UNTIL' (default 1000) or it stalls.

Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
The cnight observation data source runs four parallel cardano queries
(get_registrations / get_deregistrations / get_asset_creates /
get_asset_spends). Each spawns parallel workers that allocate shared
memory segments via dsm_impl_posix. Docker's default /dev/shm is 64MB,
which is too small even for one worker pair on the ma_tx_out scan, so
the queries fail with 'could not resize shared memory segment ... No
space left on device' and block import for Midnight block #1.

Bump --shm-size=1g on the postgres receiver. Also gitignore the
snapshot file produced by build-snapshot.sh so it's not accidentally
committed.

Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
…lder

Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
… -> 21MB

Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
@ozgb ozgb force-pushed the oscar-sync-mainnet-1000 branch 2 times, most recently from ba03cb9 to 56783ca Compare May 5, 2026 11:53
ozgb added 2 commits May 5, 2026 13:02
Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>

@gilescope gilescope left a comment

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.

An integration test that is fast!

@gilescope gilescope added this pull request to the merge queue May 6, 2026
Merged via the queue into main with commit ee8d04e May 6, 2026
56 checks passed
@gilescope gilescope deleted the oscar-sync-mainnet-1000 branch May 6, 2026 16:42
@rsporny rsporny mentioned this pull request May 29, 2026
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants