Skip to content

Refactor test runner#744

Merged
DrEverr merged 19 commits into
mainfrom
td-ananas-vectors
Nov 3, 2025
Merged

Refactor test runner#744
DrEverr merged 19 commits into
mainfrom
td-ananas-vectors

Conversation

@tomusdrw

@tomusdrw tomusdrw commented Oct 27, 2025

Copy link
Copy Markdown
Member
  • Run traces & stf on both Ananas & Typeberry.
  • Fix gas inconsistencies in Ananas
  • Use inline-WASM for Ananas
  • Support clean loading of .bin & .json test vectors.
  • Support running test vectors for multiple chainspecs (without path-hacking).
  • Clean up some outdated todos.
  • Change default PVM backend to Ananas.

@coderabbitai

coderabbitai Bot commented Oct 27, 2025

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Multi-variant test execution supporting both "ananas" and "builtin" PVM backends.
    • Fluent builder API for test runner configuration with chainable methods.
  • Changes

    • Test timeout increased from 10 to 20 minutes.
    • Test file discovery now uses pattern-based configuration for better file filtering.
    • Default PVM backend changed to Ananas.
  • Removals

    • Removed getInterpreter() public method from DebuggerAdapter.
    • Removed WorkPackage hashing support.

Walkthrough

Replaces the previous test-runner API with a generic RunnerBuilder and a fluent runner<T,V>() builder that accumulates parsers, variants, and chainSpecs and builds Runner instances. Introduces RunOptions and updates many run* helpers to accept RunOptions (containing path and chainSpec) plus a variant discriminator (e.g., "ananas" | "builtin"); variant selects PvmBackend and is threaded into OnChain/runner calls. Test discovery now supports extension-based patterns and per-variant test creation/labeling. Multiple w3f modules were migrated to the builder/RunOptions style, several host-call/spec modules were removed, ChainSpec gained a name field, and a few type-branding constants were converted to unique symbols.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Heterogeneous, cross-cutting changes touching core test-runner wiring, many w3f runner modules, PVM variant mapping, and public typings.
  • Areas to inspect closely:
    • bin/test-runner/common.ts — RunnerBuilder, runner(), RunOptions, parsers, createTestDefinitions and per-variant test generation.
    • bin/test-runner/state-transition/state-transition.ts and bin/test-runner/w3f/accumulate.ts — updated signatures, variant → PvmBackend mapping, new OnChain invocation.
    • bin/test-runner/w3f/runners.ts and files invoking runner(...).fromJson/.fromBin/.withVariants/.build — ensure builder usage is consistent.
    • Deleted modules and removed helpers: bin/test-runner/w3f/spec.ts and host-calls-* modules — check callers for stale references.
    • Public API/type changes: unique-symbol branding changes, DebuggerAdapter.getInterpreter removal, InMemoryService.clone addition, ChainSpec.name addition.

Possibly related PRs

Suggested reviewers

  • mateuszsikora
  • DrEverr

Poem

🐇
I stitched a runner with a hop and a grin,
Parsers, specs, and variants tucked neatly within,
Two PVMs on the path, each test gets its name,
Options in my pouch — build, label, and tame,
Run the suite, nibble bugs — I celebrate the game!

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title 'Refactor test runner' accurately captures the main change in the changeset. The raw summary shows extensive refactoring of bin/test-runner/common.ts with a new RunnerBuilder API, updated test signatures across multiple files, and restructured test configurations. The title is concise and clearly conveys that the primary focus is on refactoring the test runner infrastructure.
Description check ✅ Passed The pull request description provides a comprehensive checklist of objectives that directly relate to the changeset. Each item corresponds to specific changes: multi-variant test support (Ananas & Typeberry), gas handling improvements, inline-WASM implementation, .bin/.json test vector loading, multi-chainspec support, TODO cleanup, and default backend changes. The description is well-structured and clearly explains the purpose behind the extensive refactoring.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch td-ananas-vectors

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cdc5d2a and 3505b52.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • packages/core/pvm-interpreter-ananas/package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/core/pvm-interpreter-ananas/package.json
⏰ Context from checks skipped due to timeout of 120000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: run (22.x)
  • GitHub Check: run (22.x)
  • GitHub Check: run (22.x)
  • GitHub Check: test (22.x)
  • GitHub Check: state_transition (22.x)
  • GitHub Check: e2e (22.x)

Comment @coderabbitai help to get the list of available commands and usage tips.

@tomusdrw
tomusdrw requested a review from DrEverr October 27, 2025 21:50

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🧹 Nitpick comments (2)
bin/test-runner/common.ts (2)

15-22: Avoid ‘as’ assertion; return the generic type directly.

The coding guidelines disallow as conversions. Preserve generics on the return instead of asserting to Runner<unknown, unknown>.

As per coding guidelines
Apply this diff:

-export function runner<T, V = string>(
+export function runner<T, V = string>(
   name: string,
   fromJson: FromJson<T>,
-  run: (test: T, path: string, t: TestContext, variant: V | null) => Promise<void>,
-  variants: V[] = [],
-): Runner<unknown, unknown> {
-  return { name, fromJson, run, variants } as Runner<unknown, unknown>;
+  run: (test: T, path: string, t: TestContext, variant: V | null) => Promise<void>,
+  variants: V[] = [],
+): Runner<T, V> {
+  return { name, fromJson, run, variants };
 }

Note: main can still accept Runner<unknown, unknown>[]; structural typing will allow arrays built by this function.


105-110: Readable test names per variant.

The [variant] file format is clear. Consider normalizing variant to string if future variants aren’t strings, but fine for "ananas"/"builtin".

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a46bfc7 and 7c4c24b.

📒 Files selected for processing (16)
  • bin/test-runner/common.ts (4 hunks)
  • bin/test-runner/state-transition/state-transition.ts (3 hunks)
  • bin/test-runner/w3f.ts (1 hunks)
  • bin/test-runner/w3f/accumulate.ts (2 hunks)
  • bin/test-runner/w3f/runners.ts (3 hunks)
  • packages/core/numbers/index.ts (1 hunks)
  • packages/core/pvm-debugger-adapter/debugger-adapter.ts (0 hunks)
  • packages/core/utils/opaque.ts (1 hunks)
  • packages/jam/config-node/node-config.ts (1 hunks)
  • packages/jam/jam-host-calls/externalities/partial-state.ts (0 hunks)
  • packages/jam/safrole/bandersnatch-vrf.ts (1 hunks)
  • packages/jam/state-merkleization/serialize-state-update.ts (0 hunks)
  • packages/jam/transition/accumulate/accumulate.ts (1 hunks)
  • packages/jam/transition/chain-stf.ts (2 hunks)
  • packages/jam/transition/hasher.ts (1 hunks)
  • packages/jam/transition/preimages.ts (0 hunks)
💤 Files with no reviewable changes (4)
  • packages/jam/transition/preimages.ts
  • packages/jam/state-merkleization/serialize-state-update.ts
  • packages/core/pvm-debugger-adapter/debugger-adapter.ts
  • packages/jam/jam-host-calls/externalities/partial-state.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.ts

⚙️ CodeRabbit configuration file

**/*.ts: rules from ./CODESTYLE.md should be adhered to.

**/*.ts: Any function whose documentation mention it must not be used in production code,
can be safely used in *.test.ts files. Other usage should be carefuly reviewed
and the comment must explain why it's safe to use there.

**/*.ts: as conversions must not be used. Suggest using tryAs conversion methods.

**/*.ts: Classes with static Codec field must have private constructor and static create method.

**/*.ts: Casting a bigint (or U64) using Number(x) must have an explanation comment why
it is safe.

**/*.ts: When making changes to code with comments containing links (in classes, constants, methods, etc.)
to graypaper.fluffylabs.dev, ensure those links point to the current version for this update.

Files:

  • packages/jam/safrole/bandersnatch-vrf.ts
  • packages/jam/config-node/node-config.ts
  • packages/jam/transition/accumulate/accumulate.ts
  • packages/jam/transition/hasher.ts
  • bin/test-runner/w3f.ts
  • bin/test-runner/w3f/accumulate.ts
  • bin/test-runner/state-transition/state-transition.ts
  • packages/jam/transition/chain-stf.ts
  • packages/core/numbers/index.ts
  • packages/core/utils/opaque.ts
  • bin/test-runner/common.ts
  • bin/test-runner/w3f/runners.ts
packages/core/**/*.ts

⚙️ CodeRabbit configuration file

packages/core/**/*.ts: Core packages must not import any JAM-related packages
(i.e. packages defined under packages/jam/**)

Files:

  • packages/core/numbers/index.ts
  • packages/core/utils/opaque.ts
🧬 Code graph analysis (5)
packages/jam/transition/accumulate/accumulate.ts (1)
packages/jam/node/common.ts (1)
  • logger (19-19)
bin/test-runner/state-transition/state-transition.ts (1)
packages/jam/transition/chain-stf.ts (1)
  • OnChain (117-440)
packages/jam/transition/chain-stf.ts (1)
packages/core/utils/debug.ts (1)
  • measure (112-124)
bin/test-runner/common.ts (3)
packages/core/json-parser/types.ts (1)
  • FromJson (3-12)
bin/test-runner/w3f/runners.ts (1)
  • runners (51-76)
packages/core/json-parser/parse.ts (1)
  • parseFromJson (6-140)
bin/test-runner/w3f/runners.ts (3)
bin/test-runner/common.ts (1)
  • runner (15-22)
bin/test-runner/w3f/accumulate.ts (2)
  • AccumulateTest (131-143)
  • runAccumulateTest (145-176)
bin/test-runner/state-transition/state-transition.ts (2)
  • StateTransition (35-51)
  • runStateTransition (102-179)
⏰ Context from checks skipped due to timeout of 120000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: run (22.x)
  • GitHub Check: run (22.x)
  • GitHub Check: run (22.x)
  • GitHub Check: benchmarks (22.x)
  • GitHub Check: test (22.x)
🔇 Additional comments (18)
packages/jam/safrole/bandersnatch-vrf.ts (1)

36-38: Comment update aligns with PR cleanup objectives.

The change from TODO to NOTE appropriately reflects that this export pattern is intentional rather than a pending task. The comment clearly explains the rationale (test mocking in ESM context), so marking it as NOTE is the right call.

packages/jam/config-node/node-config.ts (1)

22-22: LGTM! Default PVM backend switched to Ananas.

The change aligns with the PR objectives and is consistent with the broader updates across the codebase to support explicit PVM backend selection.

packages/jam/transition/accumulate/accumulate.ts (1)

238-238: LGTM! Minor log formatting cleanup.

Removing the trailing period improves consistency.

packages/core/utils/opaque.ts (1)

24-24: LGTM! Improved type branding with unique symbol.

Switching from a string literal to a unique symbol strengthens type-level branding without any runtime impact. This aligns with TypeScript best practices for nominal typing.

packages/core/numbers/index.ts (1)

3-3: LGTM! Type branding improvement consistent with broader pattern.

This change aligns with the unique symbol branding approach used in packages/core/utils/opaque.ts, improving type safety at compile time without runtime impact.

bin/test-runner/w3f.ts (1)

6-9: LGTM! More explicit ignore list with documentation.

Replacing the generic "traces/" pattern with specific file paths and adding an explanatory comment improves maintainability.

bin/test-runner/w3f/runners.ts (2)

52-52: LGTM! Enabling multi-backend testing for accumulate.

Adding the variants array ["ananas", "builtin"] enables the accumulate tests to run with both PVM backends, aligning with the PR objectives.


75-75: LGTM! Enabling multi-backend testing for traces.

Adding the variants array ["ananas", "builtin"] enables the state transition tests to run with both PVM backends, aligning with the PR objectives.

packages/jam/transition/chain-stf.ts (2)

305-305: LGTM! Enhanced logging with backend information.

Including the PVM backend name in the log message improves debugging and traceability when running tests with different backends.


148-148: All OnChain constructor calls properly pass the pvm parameter.

Verification confirms that both OnChain instantiations in the codebase pass the pvm parameter explicitly:

  • packages/workers/importer/importer.ts:52
  • bin/test-runner/state-transition/state-transition.ts:139

The constructor signature shows pvm: PvmBackend, with no default value, confirming it is required. The removal of the default has been properly propagated to all call sites.

packages/jam/transition/hasher.ts (1)

1-64: No issues found—removed methods are not referenced elsewhere.

The search confirms that the workPackage() method and encode helper removed from TransitionHasher are not called anywhere in the codebase. The methods named workPackage() found in the results belong to other classes (Fetch, FetchExternalities) and are unrelated to the removal.

bin/test-runner/state-transition/state-transition.ts (2)

8-8: Import of PvmBackend looks correct.

Matches the new OnChain constructor and variant plumbing.


139-139: OnChain now receives pvm — good propagation.

This matches packages/jam/transition/chain-stf.ts constructor.

bin/test-runner/w3f/accumulate.ts (1)

2-2: Type-only TestContext import OK.

Underscored parameter avoids unused warnings.

bin/test-runner/common.ts (4)

24-29: Runner type extension LGTM.

The variant: V | null in the run signature and variants: V[] field are consistent with per‑variant execution.


63-70: Per‑variant test expansion wiring looks good.

prepareTest returns multiple TestAndRunner entries and carry shouldSkip per entry; matches the new runner API.


141-172: Variant expansion logic is sound.

  • Uses first matching runner.
  • Parses once, maps across variants.
  • Passes variant through to run callback.

Minor: options = variants.length > 0 ? variants : [null] is clear and avoids branching elsewhere.


177-191: Invalid-case reporting remains helpful.

Aggregating parse errors per runner then failing the test is preserved for multi‑variant context.

Comment thread bin/test-runner/state-transition/state-transition.ts
Comment thread bin/test-runner/w3f/accumulate.ts Outdated

@DrEverr DrEverr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

☝ has a point.

Comment thread bin/test-runner/w3f/runners.ts Outdated
Comment thread packages/core/numbers/index.ts Outdated
Comment thread bin/test-runner/w3f/runners.ts Outdated
@tomusdrw
tomusdrw marked this pull request as draft October 28, 2025 21:47

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

♻️ Duplicate comments (1)
bin/test-runner/w3f/accumulate.ts (1)

144-149: Default to Ananas variant (and guard invalid inputs)

To make direct invocations safe outside the builder, default variant to "ananas" and map "builtin" explicitly; optionally guard unexpected values at runtime.

-export async function runAccumulateTest(
-  test: AccumulateTest,
-  { chainSpec }: RunOptions,
-  variant: "ananas" | "builtin",
-) {
-  const pvm = variant === "ananas" ? PvmBackend.Ananas : PvmBackend.BuiltIn;
+export async function runAccumulateTest(
+  test: AccumulateTest,
+  { chainSpec }: RunOptions,
+  variant: "ananas" | "builtin" = "ananas",
+) {
+  const pvm = variant === "builtin" ? PvmBackend.BuiltIn : PvmBackend.Ananas;
+  // Optional: if called from JS without TS checks
+  // if (variant !== "ananas" && variant !== "builtin") throw new Error(`Unsupported PVM variant: ${variant}`);
🧹 Nitpick comments (5)
bin/test-runner/common.ts (1)

204-204: Consider formatting for empty variant strings.

When runner.variant is an empty string (for tests without variants), the test case name will have an empty bracket prefix: [] filename. Consider conditional formatting.

Apply this diff to improve test name formatting:

-const testCase = `${runner.variant}` !== "" ? `[${runner.variant}] ${fileName}` : fileName;
+const testCase = runner.variant ? `[${runner.variant}] ${fileName}` : fileName;
bin/test-runner/javajam.ts (1)

4-9: Builder usage + per-variant traces: LGTM

Configuration is correct. Optional: centralize the variant list (e.g., export from common) to avoid drifting literals across files.

bin/test-runner/state-transition/state-transition.ts (1)

112-115: Avoid hardcoded path magic (optional)

The special-case path check is brittle. Consider extracting to a small allowlist/constant or moving into a helper to keep the rule centralized.

-const spec = options.path.includes("fuzz-reports/0.7.0/traces/1756548916/00000082.json")
-  ? jamConformance070V0Spec
-  : options.chainSpec;
+const SPECIAL_CASES = new Set<string>([
+  "fuzz-reports/0.7.0/traces/1756548916/00000082.json",
+]);
+const spec = [...SPECIAL_CASES].some((p) => options.path.includes(p))
+  ? jamConformance070V0Spec
+  : options.chainSpec;
bin/test-runner/w3f/assurances.ts (1)

169-175: Optional: reduce wrapper duplication

Both Tiny/Full wrappers duplicate the same pattern. Consider a small helper to DRY them.

-export async function runAssurancesTestTiny(testContent: AssurancesTestTiny, options: RunOptions) {
-  const spec = options.chainSpec;
-  const preState = TestState.toAssurancesState(testContent.pre_state, spec);
-  const postState = TestState.toAssurancesState(testContent.post_state, spec);
-  const input = Input.toAssurancesInput(testContent.input, spec, preState.availabilityAssignment);
-  const expectedResult = Output.toAssurancesTransitionResult(testContent.output);
-  await runAssurancesTest(options, preState, postState, input, expectedResult);
-}
+function buildAssurancesRun<T extends AssurancesTestTiny | AssurancesTestFull>() {
+  return async (testContent: T, options: RunOptions) => {
+    const spec = options.chainSpec;
+    const preState = TestState.toAssurancesState(testContent.pre_state, spec);
+    const postState = TestState.toAssurancesState(testContent.post_state, spec);
+    const input = Input.toAssurancesInput(testContent.input, spec, preState.availabilityAssignment);
+    const expectedResult = Output.toAssurancesTransitionResult(testContent.output);
+    await runAssurancesTest(options, preState, postState, input, expectedResult);
+  };
+}
+export const runAssurancesTestTiny = buildAssurancesRun<AssurancesTestTiny>();
+export const runAssurancesTestFull = buildAssurancesRun<AssurancesTestFull>();
bin/test-runner/w3f/codec/index.ts (1)

14-56: Consider passing chainSpec from RunOptions to runCodecTest.

All functions now receive RunOptions which includes a chainSpec field, but only the path is extracted and used. The underlying runCodecTest function still derives the chain spec by calling getChainSpec(file) internally. This redundant derivation is inefficient and inconsistent with the refactoring goals.

Consider updating runCodecTest in bin/test-runner/w3f/codec/common.ts to accept chainSpec as a parameter:

-export function runCodecTest<T>(codec: Codec<T>, test: T, file: string) {
-  const spec = getChainSpec(file);
+export function runCodecTest<T>(codec: Codec<T>, test: T, file: string, spec: ChainSpec) {
   const encoded = new Uint8Array(fs.readFileSync(file.replace("json", "bin")));
   const myEncoded = Encoder.encodeObject(codec, test, spec);
   assert.deepStrictEqual(myEncoded.toString(), BytesBlob.blobFrom(encoded).toString());

   const decoded = Decoder.decodeObject(codec, BytesBlob.blobFrom(encoded), spec);
   assert.deepStrictEqual(decoded, test);
 }

Then update all call sites in this file to pass chainSpec:

-export async function runAssurancesExtrinsicTest(test: AssurancesExtrinsic, { path: file }: RunOptions) {
-  runCodecTest(assurancesExtrinsicCodec, test, file);
+export async function runAssurancesExtrinsicTest(test: AssurancesExtrinsic, { path: file, chainSpec }: RunOptions) {
+  runCodecTest(assurancesExtrinsicCodec, test, file, chainSpec);
 }

Apply similar changes to the remaining 10 functions.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7c4c24b and 3dc18bf.

📒 Files selected for processing (36)
  • bin/test-runner/common.ts (4 hunks)
  • bin/test-runner/jamduna-067.ts (1 hunks)
  • bin/test-runner/javajam.ts (1 hunks)
  • bin/test-runner/state-transition/state-transition.ts (4 hunks)
  • bin/test-runner/w3f.ts (1 hunks)
  • bin/test-runner/w3f/accumulate.ts (3 hunks)
  • bin/test-runner/w3f/assurances.ts (2 hunks)
  • bin/test-runner/w3f/authorizations.ts (2 hunks)
  • bin/test-runner/w3f/codec/index.ts (1 hunks)
  • bin/test-runner/w3f/codec/work-item.ts (2 hunks)
  • bin/test-runner/w3f/codec/work-package.ts (2 hunks)
  • bin/test-runner/w3f/disputes.ts (2 hunks)
  • bin/test-runner/w3f/erasure-coding.ts (2 hunks)
  • bin/test-runner/w3f/host-calls-accumulate.ts (0 hunks)
  • bin/test-runner/w3f/host-calls-general.ts (0 hunks)
  • bin/test-runner/w3f/host-calls-refine.ts (0 hunks)
  • bin/test-runner/w3f/reports.ts (3 hunks)
  • bin/test-runner/w3f/runners.ts (1 hunks)
  • bin/test-runner/w3f/safrole.ts (2 hunks)
  • bin/test-runner/w3f/shuffling.ts (1 hunks)
  • bin/test-runner/w3f/spec.ts (0 hunks)
  • packages/core/numbers/index.ts (1 hunks)
  • packages/core/pvm-debugger-adapter/debugger-adapter.ts (0 hunks)
  • packages/core/utils/opaque.ts (1 hunks)
  • packages/jam/config-node/node-config.ts (1 hunks)
  • packages/jam/config/chain-spec.ts (4 hunks)
  • packages/jam/jam-host-calls/externalities/partial-state.ts (0 hunks)
  • packages/jam/safrole/bandersnatch-vrf.ts (1 hunks)
  • packages/jam/state-merkleization/serialize-state-update.ts (0 hunks)
  • packages/jam/state/in-memory-state.ts (2 hunks)
  • packages/jam/transition/accumulate/accumulate.ts (1 hunks)
  • packages/jam/transition/chain-stf.ts (2 hunks)
  • packages/jam/transition/externalities/accumulate-externalities.test.ts (2 hunks)
  • packages/jam/transition/externalities/accumulate-externalities.ts (1 hunks)
  • packages/jam/transition/hasher.ts (1 hunks)
  • packages/jam/transition/preimages.ts (0 hunks)
💤 Files with no reviewable changes (8)
  • packages/jam/jam-host-calls/externalities/partial-state.ts
  • packages/jam/state-merkleization/serialize-state-update.ts
  • bin/test-runner/w3f/host-calls-general.ts
  • packages/core/pvm-debugger-adapter/debugger-adapter.ts
  • packages/jam/transition/preimages.ts
  • bin/test-runner/w3f/spec.ts
  • bin/test-runner/w3f/host-calls-accumulate.ts
  • bin/test-runner/w3f/host-calls-refine.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/jam/transition/externalities/accumulate-externalities.test.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/jam/transition/accumulate/accumulate.ts
  • packages/core/utils/opaque.ts
  • packages/core/numbers/index.ts
  • packages/jam/safrole/bandersnatch-vrf.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.ts

⚙️ CodeRabbit configuration file

**/*.ts: rules from ./CODESTYLE.md should be adhered to.

**/*.ts: Any function whose documentation mention it must not be used in production code,
can be safely used in *.test.ts files. Other usage should be carefuly reviewed
and the comment must explain why it's safe to use there.

**/*.ts: as conversions must not be used. Suggest using tryAs conversion methods.

**/*.ts: Classes with static Codec field must have private constructor and static create method.

**/*.ts: Casting a bigint (or U64) using Number(x) must have an explanation comment why
it is safe.

**/*.ts: When making changes to code with comments containing links (in classes, constants, methods, etc.)
to graypaper.fluffylabs.dev, ensure those links point to the current version for this update.

Files:

  • bin/test-runner/w3f.ts
  • packages/jam/config/chain-spec.ts
  • bin/test-runner/w3f/shuffling.ts
  • packages/jam/transition/hasher.ts
  • bin/test-runner/w3f/codec/work-package.ts
  • bin/test-runner/w3f/authorizations.ts
  • packages/jam/transition/externalities/accumulate-externalities.ts
  • bin/test-runner/w3f/disputes.ts
  • bin/test-runner/w3f/safrole.ts
  • bin/test-runner/w3f/erasure-coding.ts
  • bin/test-runner/w3f/reports.ts
  • bin/test-runner/w3f/assurances.ts
  • bin/test-runner/w3f/codec/work-item.ts
  • bin/test-runner/javajam.ts
  • bin/test-runner/state-transition/state-transition.ts
  • bin/test-runner/jamduna-067.ts
  • packages/jam/state/in-memory-state.ts
  • bin/test-runner/w3f/runners.ts
  • bin/test-runner/w3f/accumulate.ts
  • packages/jam/config-node/node-config.ts
  • bin/test-runner/common.ts
  • bin/test-runner/w3f/codec/index.ts
  • packages/jam/transition/chain-stf.ts
🧠 Learnings (1)
📚 Learning: 2025-06-10T12:20:17.513Z
Learnt from: tomusdrw
PR: FluffyLabs/typeberry#419
File: packages/jam/state/state-inmemory.ts:141-149
Timestamp: 2025-06-10T12:20:17.513Z
Learning: In the `InMemoryService.copyFrom` function in `packages/jam/state/state-inmemory.ts`, duplicate checking for `(hash, length)` pairs in the lookup history is not necessary because the function operates under the assumption that the input `ServiceEntries` comes from an existing well-formed state, which already maintains the invariant of unique lookup history entries per hash and length combination.

Applied to files:

  • packages/jam/state/in-memory-state.ts
🧬 Code graph analysis (18)
bin/test-runner/w3f/shuffling.ts (1)
bin/test-runner/common.ts (2)
  • json (89-89)
  • json (90-90)
bin/test-runner/w3f/codec/work-package.ts (2)
packages/jam/block/work-package.ts (1)
  • WorkPackage (37-94)
bin/test-runner/common.ts (1)
  • RunOptions (72-76)
bin/test-runner/w3f/authorizations.ts (1)
bin/test-runner/common.ts (1)
  • RunOptions (72-76)
bin/test-runner/w3f/disputes.ts (1)
bin/test-runner/common.ts (1)
  • RunOptions (72-76)
bin/test-runner/w3f/safrole.ts (1)
bin/test-runner/common.ts (1)
  • RunOptions (72-76)
bin/test-runner/w3f/erasure-coding.ts (1)
bin/test-runner/common.ts (1)
  • RunOptions (72-76)
bin/test-runner/w3f/reports.ts (1)
bin/test-runner/common.ts (1)
  • RunOptions (72-76)
bin/test-runner/w3f/assurances.ts (1)
bin/test-runner/common.ts (1)
  • RunOptions (72-76)
bin/test-runner/w3f/codec/work-item.ts (2)
bin/test-runner/common.ts (1)
  • RunOptions (72-76)
bin/test-runner/w3f/codec/common.ts (1)
  • runCodecTest (7-15)
bin/test-runner/javajam.ts (3)
bin/test-runner/w3f/runners.ts (1)
  • runners (53-77)
bin/test-runner/common.ts (1)
  • runner (64-70)
bin/test-runner/state-transition/state-transition.ts (2)
  • runStateTransition (102-178)
  • StateTransition (35-51)
bin/test-runner/state-transition/state-transition.ts (3)
bin/test-runner/common.ts (1)
  • RunOptions (72-76)
packages/core/hash/blake2b.ts (1)
  • Blake2b (8-44)
bin/test-runner/state-transition/state-loader.ts (1)
  • loadState (39-45)
bin/test-runner/jamduna-067.ts (3)
bin/test-runner/w3f/runners.ts (1)
  • runners (53-77)
bin/test-runner/common.ts (1)
  • runner (64-70)
bin/test-runner/state-transition/state-transition.ts (2)
  • runStateTransition (102-178)
  • StateTransition (35-51)
packages/jam/state/in-memory-state.ts (2)
packages/jam/state/service.ts (1)
  • ServiceAccountInfo (82-154)
packages/core/collections/hash-dictionary.ts (1)
  • HashDictionary (24-102)
bin/test-runner/w3f/runners.ts (7)
packages/jam/config/chain-spec.ts (2)
  • tinyChainSpec (109-126)
  • fullChainSpec (132-147)
bin/test-runner/common.ts (1)
  • runner (64-70)
bin/test-runner/w3f/accumulate.ts (2)
  • runAccumulateTest (144-172)
  • AccumulateTest (130-142)
bin/test-runner/w3f/reports.ts (2)
  • runReportsTest (251-284)
  • ReportsTest (238-249)
bin/test-runner/w3f/shuffling.ts (2)
  • runShufflingTests (25-36)
  • shufflingTestsFromJson (23-23)
bin/test-runner/w3f/trie.ts (2)
  • runTrieTest (39-60)
  • trieTestSuiteFromJson (37-37)
bin/test-runner/w3f/codec/index.ts (4)
  • runAssurancesExtrinsicTest (14-16)
  • runBlockTest (18-20)
  • runDisputesExtrinsicTest (22-24)
  • runExtrinsicTest (26-28)
bin/test-runner/w3f/accumulate.ts (1)
bin/test-runner/common.ts (1)
  • RunOptions (72-76)
bin/test-runner/common.ts (3)
packages/core/json-parser/types.ts (1)
  • FromJson (3-12)
packages/core/codec/decoder.ts (2)
  • Decode (6-9)
  • Decoder (12-379)
packages/core/json-parser/parse.ts (1)
  • parseFromJson (6-140)
bin/test-runner/w3f/codec/index.ts (2)
bin/test-runner/common.ts (1)
  • RunOptions (72-76)
bin/test-runner/w3f/codec/common.ts (1)
  • runCodecTest (7-15)
packages/jam/transition/chain-stf.ts (1)
packages/core/utils/debug.ts (1)
  • measure (112-124)
⏰ Context from checks skipped due to timeout of 120000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: run (22.x)
  • GitHub Check: run (22.x)
  • GitHub Check: run (22.x)
  • GitHub Check: test (22.x)
🔇 Additional comments (34)
packages/jam/transition/externalities/accumulate-externalities.ts (1)

154-154: LGTM! Enhanced diagnostic message improves debuggability.

The improved error message now includes the actual preimage status value, making it easier to diagnose why eject operations fail when the previous code is not in the expected Unavailable state.

packages/jam/transition/chain-stf.ts (2)

5-5: LGTM! Import change necessary for runtime enum access.

The change from a type-only import to a mixed import (value for PvmBackend, type for ChainSpec) is correct and required to support the runtime enum indexing on line 305 where PvmBackend[this.accumulate.pvm] is used to label the performance metric.


305-305: Excellent observability improvement!

Adding the PVM backend name to the timer label enables differentiation of performance metrics when running test vectors with both Ananas and Builtin backends. This directly supports the PR objectives and will provide valuable performance comparison data.

packages/jam/config-node/node-config.ts (1)

22-22: Change verified: Ananas backend is production-ready and properly tested.

The default PVM backend switch is supported by comprehensive test coverage. The codebase already parametrizes tests across both backends (accumulate.test.ts), and both BuiltIn and Ananas interpreters are fully implemented. Tests relying on NODE_DEFAULTS will use Ananas, but existing parametric tests confirm compatibility.

packages/jam/transition/hasher.ts (1)

3-5: The review comment is based on incorrect assumptions.

The analysis found that:

  1. TransitionHasher class in packages/jam/transition/hasher.ts does not have a workPackage() method and never did. The class contains only: hashConcat(), hashConcatPrepend(), header(), and extrinsic().

  2. The workPackage() method exists in the IFetchExternalities interface (in packages/jam/jam-host-calls/fetch.ts), which is completely unrelated to the import changes in hasher.ts.

  3. The call at packages/jam/jam-host-calls/fetch.ts:320 (return this.fetch.workPackage()) invokes the interface method on an IFetchExternalities object, not on TransitionHasher. This method remains unchanged.

  4. The import modifications at lines 3-5 in hasher.ts are clean and correct—all imported symbols are actually used in the file.

There is no breaking change here, and no verification of method removal is needed.

Likely an incorrect or invalid review comment.

packages/jam/config/chain-spec.ts (1)

42-43: LGTM!

The addition of the name field to ChainSpec is implemented consistently across the class definition, constructor initialization, and both predefined instances. This enables explicit identification of chain specs at runtime, which aligns with the PR's goal of supporting per-variant test wiring.

Also applies to: 88-88, 110-110, 133-133

bin/test-runner/w3f.ts (1)

6-9: LGTM!

Replacing the broad "traces/" ignore pattern with explicit file-level ignores is more precise and maintainable. The explanatory comment clearly documents why these specific files are being ignored.

packages/jam/state/in-memory-state.ts (1)

48-48: LGTM!

The new clone() method provides proper deep-copy semantics for InMemoryService. All nested collections (preimages, lookupHistory, storage) are correctly cloned, and the import change from type-only to value import for ServiceAccountInfo is necessary to use ServiceAccountInfo.create(). This aligns with the PR's test infrastructure needs for isolating state between test runs.

Also applies to: 132-142

bin/test-runner/common.ts (5)

17-70: LGTM! Well-structured builder pattern.

The new RunnerBuilder class and runner() factory function provide a clean, type-safe API for configuring test runners with parsers, variants, and chain specs. The builder pattern enables flexible composition and clear configuration.


72-86: LGTM! RunOptions standardizes test parameter passing.

The RunOptions type and RunFunction signature provide a consistent interface across all test runners, replacing scattered string path parameters with a structured object containing test context, chain spec, and path.


88-113: LGTM! testFile namespace provides type-safe file handling.

The namespace clearly defines supported file types (json/bin) with corresponding parsers and content types, enabling type-safe parser selection.


248-250: Verify type safety of noneVariant assignment.

The type assertion "" as V may be unsafe if variant type V has specific constraints. While the comment acknowledges this, consider whether a sentinel type or explicit V | undefined would be safer.

Consider this safer alternative:

// Make variants explicitly optional in the type system
const possibleVariants: (V | undefined)[] = variants.length === 0 ? [undefined] : variants;

Or define a branded empty variant type if string literals are required.


294-308: Verify error handling for multi-variant scenarios.

The error path returns a single TestAndRunner entry with runner name "Invalid", even when multiple variants might be expected. This could mask which variant(s) failed to parse.

Consider whether variant-specific error entries would provide better diagnostics:

// Return one error entry per expected variant for clarity
return possibleVariants.map(variant => ({
  shouldSkip: false,
  runner: "Invalid",
  file: fileName,
  variant,
  test: () => { /* error logging */ }
}));
bin/test-runner/w3f/codec/work-package.ts (1)

10-10: LGTM!

The migration to RunOptions is implemented correctly, using destructuring with alias { path: file } to maintain the existing variable name. This aligns with the broader test runner API standardization in the PR.

Also applies to: 80-81

bin/test-runner/w3f/codec/work-item.ts (1)

7-7: LGTM!

The migration to RunOptions is implemented correctly with direct destructuring of the path property. This aligns with the broader test runner API standardization in the PR.

Also applies to: 61-62

bin/test-runner/w3f/erasure-coding.ts (1)

18-18: LGTM!

The migration to RunOptions with direct chainSpec destructuring is cleaner than the previous path-based chain spec derivation. This aligns with the broader test runner API standardization in the PR.

Also applies to: 30-30

bin/test-runner/w3f/shuffling.ts (1)

23-23: All import sites have been successfully updated.

The verification confirms:

  • Export in shuffling.ts line 23 correctly uses the new name shufflingTestsFromJson
  • No remaining references to the old name shufflingTests exist in the codebase
  • Import site in runners.ts line 44 properly uses the new name

The rename is complete and consistent across the codebase.

bin/test-runner/w3f/disputes.ts (1)

14-14: RunOptions injection looks good

Signature/import change aligns with the new runner API; chainSpec usage remains correct.

Also applies to: 91-91

bin/test-runner/w3f/authorizations.ts (1)

13-13: Consistent shift to RunOptions

Clean swap from path-based spec to injected chainSpec. No behavioral regressions spotted.

Also applies to: 80-86

bin/test-runner/w3f/safrole.ts (1)

33-33: Good migration to RunOptions

Signature/import update matches the builder pattern; chainSpec flows correctly through Safrole setup.

Also applies to: 214-214

bin/test-runner/w3f/accumulate.ts (1)

114-114: Cloning services prevents shared-state bleed

Using service.clone() when building the services map avoids cross-test mutation. Good call for test isolation.

bin/test-runner/w3f/reports.ts (2)

12-12: Type-only imports LGTM

Type-only usage for ChainSpec/RunOptions is correct and keeps value bundle clean.

Also applies to: 46-46


251-284: RunOptions wiring: good migration

Signature switch to RunOptions and spec extraction is consistent with runners. No issues found.

bin/test-runner/state-transition/state-transition.ts (5)

17-17: Import addition LGTM

RunOptions import is appropriate for the new API.


98-100: ChainSpec name initialization

Adding a name to jamConformance070V0Spec is fine and helpful for diagnostics.


102-108: Variant-to-PVM mapping looks correct

Explicit variant param and mapping to PvmBackend is clear and matches the builder’s withVariants setup.


123-123: Using options.path for block discovery

Switch to options.path is consistent with the new RunOptions flow.


138-139: Pass PVM into OnChain

Constructor update to include pvm is correct and matches downstream usage.

bin/test-runner/w3f/assurances.ts (2)

148-156: Tiny: RunOptions migration LGTM

Spec pulled from options; wrapper is correct.


158-166: Full: RunOptions migration LGTM

Same as Tiny; consistent and correct.

bin/test-runner/w3f/runners.ts (3)

48-52: Helper constants LGTM

pvms/tiny/full/tinyFull helpers improve readability and reuse.


54-77: Runners array migration LGTM

Builder pattern with withVariants for PVM-dependent runners ensures both Ananas and Builtin are exercised. Ordering (Ananas first) aligns with “default Ananas” objective.


82-101: codecRunners: spec-scoped fromJson wiring looks correct

Per-flavor spec is passed where required; setup matches the new runner API.

bin/test-runner/jamduna-067.ts (1)

4-9: Chainspec handling is correct; no action needed

The chainSpecs array is properly handled through implicit default detection. When runner() is called without a chainSpecs parameter, the RunnerBuilder returns an empty chainSpecs array. During test execution, this empty array triggers the fallback to [tinyChainSpec] (line 254 in common.ts), ensuring each test case receives the appropriate default chainSpec. No additional chainSpec wiring is required.

Comment thread bin/test-runner/state-transition/state-transition.ts
@tomusdrw
tomusdrw marked this pull request as ready for review October 30, 2025 22:18
@tomusdrw tomusdrw changed the title Run test vectors using both Ananas and Builtin Refactor test runner Oct 30, 2025

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
bin/test-runner/w3f-davxy-071.ts (1)

19-22: Consider using a conventional exit code.

The error handling is good, but process.exit(-1) is unconventional. Standard practice uses positive integers (e.g., process.exit(1)) for error conditions. While -1 works in Node.js (interpreted as 255), positive integers are more portable and follow common conventions.

Apply this diff if you'd like to use a conventional exit code:

-    process.exit(-1);
+    process.exit(1);
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e15ed21 and fed7acc.

📒 Files selected for processing (1)
  • bin/test-runner/w3f-davxy-071.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.ts

⚙️ CodeRabbit configuration file

**/*.ts: rules from ./CODESTYLE.md should be adhered to.

**/*.ts: Any function whose documentation mention it must not be used in production code,
can be safely used in *.test.ts files. Other usage should be carefuly reviewed
and the comment must explain why it's safe to use there.

**/*.ts: as conversions must not be used. Suggest using tryAs conversion methods.

**/*.ts: Classes with static Codec field must have private constructor and static create method.

**/*.ts: Casting a bigint (or U64) using Number(x) must have an explanation comment why
it is safe.

**/*.ts: When making changes to code with comments containing links (in classes, constants, methods, etc.)
to graypaper.fluffylabs.dev, ensure those links point to the current version for this update.

Files:

  • bin/test-runner/w3f-davxy-071.ts
🧠 Learnings (2)
📓 Common learnings
Learnt from: tomusdrw
Repo: FluffyLabs/typeberry PR: 399
File: .github/workflows/vectors-jamduna.yml:78-78
Timestamp: 2025-05-26T21:31:58.688Z
Learning: In the typeberry project, the npm start script in the test-runner workspace is designed to accept test suite names as arguments (e.g., "jamduna", "w3f"). The command `npm start -w typeberry/test-runner jamduna` is the correct way to run the jamduna test suite, not `npm run jamduna`. This is an architectural design choice where the start script acts as a unified entry point for different test suites.
📚 Learning: 2025-05-26T21:31:58.688Z
Learnt from: tomusdrw
Repo: FluffyLabs/typeberry PR: 399
File: .github/workflows/vectors-jamduna.yml:78-78
Timestamp: 2025-05-26T21:31:58.688Z
Learning: In the typeberry project, the npm start script in the test-runner workspace is designed to accept test suite names as arguments (e.g., "jamduna", "w3f"). The command `npm start -w typeberry/test-runner jamduna` is the correct way to run the jamduna test suite, not `npm run jamduna`. This is an architectural design choice where the start script acts as a unified entry point for different test suites.

Applied to files:

  • bin/test-runner/w3f-davxy-071.ts
⏰ Context from checks skipped due to timeout of 120000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: test (22.x)
  • GitHub Check: benchmarks (22.x)
  • GitHub Check: e2e (22.x)
  • GitHub Check: run (22.x)
  • GitHub Check: run (22.x)
  • GitHub Check: run (22.x)
🔇 Additional comments (3)
bin/test-runner/w3f-davxy-071.ts (3)

5-8: LGTM! Clear improvement in test vector configuration.

The new structure with patterns and per-extension accepted mapping makes the test discovery more explicit and extensible, aligning well with the PR's goal to support clean loading of multiple test vector formats.


11-11: Good addition.

Including genesis.bin in the ignored list is consistent with the support for both .bin and .json test vectors.


12-15: LGTM! Consistent with the new pattern-based API.

The change from full filenames to base paths (without extensions) aligns with the new pattern-based test discovery approach. The comments explaining the ignore reasons are helpful.

@DrEverr DrEverr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

Comment thread bin/test-runner/common.ts
Comment thread bin/test-runner/common.ts

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
bin/test-runner/w3f-davxy-071.ts (1)

15-18: Use exit code 1 instead of -1.

While the error handling is good, exit code -1 is not standard. Exit codes should be in the range 0-255, where 0 indicates success and positive values indicate errors. Node.js will convert -1 to 255, but it's clearer to use 1 explicitly.

Apply this diff:

   .catch((e) => {
     logger.error`${e}`;
-    process.exit(-1);
+    process.exit(1);
   });
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 73234b0 and cdc5d2a.

📒 Files selected for processing (3)
  • bin/test-runner/w3f-davxy-071.ts (1 hunks)
  • packages/jam/transition/externalities/accumulate-externalities.test.ts (2 hunks)
  • packages/jam/transition/externalities/accumulate-externalities.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/jam/transition/externalities/accumulate-externalities.test.ts
  • packages/jam/transition/externalities/accumulate-externalities.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.ts

⚙️ CodeRabbit configuration file

**/*.ts: rules from ./CODESTYLE.md should be adhered to.

**/*.ts: Any function whose documentation mention it must not be used in production code,
can be safely used in *.test.ts files. Other usage should be carefuly reviewed
and the comment must explain why it's safe to use there.

**/*.ts: as conversions must not be used. Suggest using tryAs conversion methods.

**/*.ts: Classes with static Codec field must have private constructor and static create method.

**/*.ts: Casting a bigint (or U64) using Number(x) must have an explanation comment why
it is safe.

**/*.ts: When making changes to code with comments containing links (in classes, constants, methods, etc.)
to graypaper.fluffylabs.dev, ensure those links point to the current version for this update.

Files:

  • bin/test-runner/w3f-davxy-071.ts
🧠 Learnings (1)
📚 Learning: 2025-05-26T21:31:58.688Z
Learnt from: tomusdrw
Repo: FluffyLabs/typeberry PR: 399
File: .github/workflows/vectors-jamduna.yml:78-78
Timestamp: 2025-05-26T21:31:58.688Z
Learning: In the typeberry project, the npm start script in the test-runner workspace is designed to accept test suite names as arguments (e.g., "jamduna", "w3f"). The command `npm start -w typeberry/test-runner jamduna` is the correct way to run the jamduna test suite, not `npm run jamduna`. This is an architectural design choice where the start script acts as a unified entry point for different test suites.

Applied to files:

  • bin/test-runner/w3f-davxy-071.ts
⏰ Context from checks skipped due to timeout of 120000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: e2e (22.x)
  • GitHub Check: test (22.x)
🔇 Additional comments (2)
bin/test-runner/w3f-davxy-071.ts (2)

5-8: LGTM! Pattern-based configuration aligns with the refactoring.

The change from a flat list to a per-extension mapping structure is consistent with the project-wide shift to pattern-based test discovery mentioned in the PR objectives.


11-11: LGTM! Ignored path correctly updated for pattern-based system.

Removing the .json extension is appropriate since the new pattern-based configuration handles extensions separately.

@github-actions

github-actions Bot commented Nov 3, 2025

Copy link
Copy Markdown
View all
File Benchmark Ops
codec/bigint.compare.ts[0] compare custom 233086737.68 ±8.07% fastest ✅
codec/bigint.compare.ts[1] compare bigint 198848737.26 ±9.06% 14.69% slower
codec/bigint.decode.ts[0] decode custom 138241173.76 ±3.68% fastest ✅
codec/bigint.decode.ts[1] decode bigint 85694767.67 ±3.38% 38.01% slower
codec/decoding.ts[0] manual decode 20005471.54 ±1.36% 85.97% slower
codec/decoding.ts[1] int32array decode 138781378.26 ±4.62% 2.66% slower
codec/decoding.ts[2] dataview decode 142568357.86 ±3.9% fastest ✅
codec/encoding.ts[0] manual encode 2804123.69 ±1.45% 21.13% slower
codec/encoding.ts[1] int32array encode 3499031.27 ±1.6% 1.58% slower
codec/encoding.ts[2] dataview encode 3555160.78 ±1.57% fastest ✅
collections/map-set.ts[0] 2 gets + conditional set 112893.52 ±0.92% fastest ✅
collections/map-set.ts[1] 1 get 1 set 54989.49 ±1.22% 51.29% slower
hash/index.ts[0] hash with numeric representation 165.24 ±1.77% 25.19% slower
hash/index.ts[1] hash with string representation 95.95 ±1.45% 56.56% slower
hash/index.ts[2] hash with symbol representation 163.71 ±1.38% 25.88% slower
hash/index.ts[3] hash with uint8 representation 144.67 ±1.43% 34.5% slower
hash/index.ts[4] hash with packed representation 220.87 ±3.23% fastest ✅
hash/index.ts[5] hash with bigint representation 168.44 ±1.65% 23.74% slower
hash/index.ts[6] hash with uint32 representation 184.31 ±1.31% 16.55% slower
math/add_one_overflow.ts[0] add and take modulus 228089962.54 ±7.28% fastest ✅
math/add_one_overflow.ts[1] condition before calculation 213685066.66 ±8.36% 6.32% slower
math/count-bits-u32.ts[0] standard method 83066876.52 ±3.37% 60.62% slower
math/count-bits-u32.ts[1] magic 210926607.81 ±6.78% fastest ✅
math/count-bits-u64.ts[0] standard method 1400714.95 ±1.32% 86.54% slower
math/count-bits-u64.ts[1] magic 10403546.15 ±0.91% fastest ✅
math/mul_overflow.ts[0] multiply and bring back to u32 228356087.61 ±8.01% 2.19% slower
math/mul_overflow.ts[1] multiply and take modulus 233462155.6 ±6.22% fastest ✅
math/switch.ts[0] switch 235848624.1 ±7.35% fastest ✅
math/switch.ts[1] if 224184614.63 ±7.98% 4.95% slower
bytes/hex-from.ts[0] parse hex using Number with NaN checking 126999.13 ±0.41% 85.07% slower
bytes/hex-from.ts[1] parse hex from char codes 850875.32 ±0.45% fastest ✅
bytes/hex-from.ts[2] parse hex from string nibbles 534981.89 ±0.49% 37.13% slower
bytes/hex-to.ts[0] number toString + padding 302882.12 ±0.59% fastest ✅
bytes/hex-to.ts[1] manual 16506.35 ±0.46% 94.55% slower
logger/index.ts[0] console.log with string concat 6809528.33 ±53.4% fastest ✅
logger/index.ts[1] console.log with args 367914.29 ±143.79% 94.6% slower
codec/view_vs_collection.ts[0] Get first element from Decoded 25192.72 ±3.41% 56.12% slower
codec/view_vs_collection.ts[1] Get first element from View 57419.05 ±0.49% fastest ✅
codec/view_vs_collection.ts[2] Get 50th element from Decoded 25739.12 ±1.96% 55.17% slower
codec/view_vs_collection.ts[3] Get 50th element from View 28219.27 ±1.54% 50.85% slower
codec/view_vs_collection.ts[4] Get last element from Decoded 30504.47 ±0.51% 46.87% slower
codec/view_vs_collection.ts[5] Get last element from View 23485.21 ±0.43% 59.1% slower
codec/view_vs_object.ts[0] Get the first field from Decoded 496051.95 ±0.11% 1.85% slower
codec/view_vs_object.ts[1] Get the first field from View 99978.02 ±0.75% 80.22% slower
codec/view_vs_object.ts[2] Get the first field as view from View 102169.97 ±0.15% 79.79% slower
codec/view_vs_object.ts[3] Get two fields from Decoded 502097.96 ±0.25% 0.66% slower
codec/view_vs_object.ts[4] Get two fields from View 81452.89 ±0.16% 83.88% slower
codec/view_vs_object.ts[5] Get two fields from materialized from View 171066.58 ±0.27% 66.15% slower
codec/view_vs_object.ts[6] Get two fields as views from View 81331.61 ±0.19% 83.91% slower
codec/view_vs_object.ts[7] Get only third field from Decoded 505426.29 ±0.28% fastest ✅
codec/view_vs_object.ts[8] Get only third field from View 101090.72 ±0.23% 80% slower
codec/view_vs_object.ts[9] Get only third field as view from View 100726.36 ±0.07% 80.07% slower
bytes/compare.ts[0] Comparing Uint32 bytes 21186.37 ±0.3% 5.27% slower
bytes/compare.ts[1] Comparing raw bytes 22365.9 ±0.11% fastest ✅
collections/map_vs_sorted.ts[0] Map 294851.48 ±0.26% fastest ✅
collections/map_vs_sorted.ts[1] Map-array 103583.96 ±0.05% 64.87% slower
collections/map_vs_sorted.ts[2] Array 63666.22 ±0.14% 78.41% slower
collections/map_vs_sorted.ts[3] SortedArray 176660.26 ±0.11% 40.09% slower
hash/blake2b.ts[0] our hasher 2.23 ±0.29% fastest ✅
hash/blake2b.ts[1] blake2b js 0.05 ±0.32% 97.76% slower
crypto/ed25519.ts[0] native crypto 5.27 ±18.61% 82.76% slower
crypto/ed25519.ts[1] wasm lib 10.87 ±0.02% 64.44% slower
crypto/ed25519.ts[2] wasm lib batch 30.57 ±0.53% fastest ✅

Benchmarks summary: 63/63 OK ✅

@DrEverr
DrEverr merged commit 2ecdea0 into main Nov 3, 2025
16 checks passed
@DrEverr
DrEverr deleted the td-ananas-vectors branch November 3, 2025 15:02
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.

3 participants