Skip to content

pre-generated test keys for faster CI#587

Open
anshalshuklabot wants to merge 17 commits intoblockblaz:mainfrom
anshalshuklabot:feat/pregenerated-test-keys
Open

pre-generated test keys for faster CI#587
anshalshuklabot wants to merge 17 commits intoblockblaz:mainfrom
anshalshuklabot:feat/pregenerated-test-keys

Conversation

@anshalshuklabot
Copy link

  • Add keygen command to zeam-tools for generating XMSS key pairs
  • Add test-keys submodule (anshalshuklabot/zeam-test-keys) with 32 pre-generated keys
  • Update getTestKeyManager to load pre-generated keys from disk (near-instant)
  • Falls back to runtime generation if test-keys submodule not initialized
  • build.zig: add xmss and types imports to tools target

Each XMSS key takes ~1 min to generate at runtime. Loading 32 pre-generated keys from SSZ files is near-instant, significantly speeding up CI and tests.

- Add keygen command to zeam-tools for generating XMSS key pairs
- Add test-keys submodule (anshalshuklabot/zeam-test-keys) with 32 pre-generated keys
- Update getTestKeyManager to load pre-generated keys from disk (near-instant)
- Falls back to runtime generation if test-keys submodule not initialized
- build.zig: add xmss and types imports to tools target

Each XMSS key takes ~1 min to generate at runtime. Loading 32 pre-generated
keys from SSZ files is near-instant, significantly speeding up CI and tests.
@anshalshukla
Copy link
Collaborator

This PR is end to end created using openclaw, I'm just trying it out using a separate bot account. Will review if later.

anshalshuklabot and others added 6 commits February 22, 2026 12:33
- Search upward for test-keys/ directory (handles test runners in subdirs)
- Load pre-generated keys for first 32 validators, generate rest at runtime
- If 40 validators needed: loads 32 from disk + generates 8 at runtime
- Fixes CI failure where keys weren't found
Ensures test-keys submodule is available in every CI job.
Fixes CACHE MISS in Dummy prove jobs where pre-generated
keys weren't found.
tools now imports @zeam/xmss which requires libhashsig_glue.a.
Without this dependency, the tools binary and tests fail to link
on CI where Rust libs aren't pre-built in the cache.
The tools executable was missing proper Rust library linking (libhashsig_glue.a,
libmultisig_glue.a, liblibp2p_glue.a) and platform-specific frameworks (macOS).
Replace manual step.dependOn with addRustGlueLib() which handles object files,
linkLibC, linkSystemLibrary(unwind), and macOS frameworks.
@gballet gballet changed the title feat: pre-generated test keys for faster CI pre-generated test keys for faster CI Feb 27, 2026
anshalshukla and others added 9 commits March 4, 2026 17:22
addRustGlueLib only adds object files and link flags but not the step
dependency that ensures Rust libs are built first. Both dependOn AND
addRustGlueLib are needed, matching how all other targets are wired.
The relative path search for test-keys/hash-sig-keys failed because Zig
test binaries run from cache directories, not the repo root. Fix by
injecting the absolute repo path as a build option (test_keys_path) from
build.zig using pathFromRoot(), and add build_options import to
key-manager module.

All 5 build commands verified locally:
- zig build all
- zig build test
- zig build simtest
- zig build spectest:generate
- zig build spectest
Two fixes:
1. Track actually_loaded count instead of assuming all num_preloaded keys
   were inserted. On partial failure (corrupt SSZ, addKeypair error), the
   fallback loop now starts from the correct index, so no validators are
   left without keys.

2. Replace boolean owns_keypairs with num_owned_keypairs counter. Pre-
   generated keys (index < num_owned_keypairs) are freed on deinit while
   cached runtime keys (index >= num_owned_keypairs) are skipped. This
   prevents leaking ~20MB private keys when the mixed ownership path is
   taken.
Replace index-threshold ownership check with a per-key owned_keys hashmap.
addKeypair() marks keys as owned (freed on deinit), addCachedKeypair()
does not (for borrowed/cached runtime keys).

This fixes the regression where CLI-loaded keys (arbitrary validator
indices) were never freed because num_owned_keypairs stayed 0. Now any
caller using addKeypair() gets correct cleanup regardless of index order.
@anshalshukla
Copy link
Collaborator

CI test time reduction summary.
test (ubuntu): 50m -> 11m
test (macos): 17m -> 9m

Copy link
Contributor

@ch4r10t33r ch4r10t33r left a comment

Choose a reason for hiding this comment

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

Looks good to me.

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