Skip to content

Conversation

@tomusdrw
Copy link
Contributor

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 11, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Summary by CodeRabbit

  • Chores
    • Updated dependencies with flexible versioning ranges.
    • Bumped rollup to latest compatible version.
    • Configured project for ES module support.
    • Updated Biome configuration schema.

Walkthrough

This PR moves the top-level "type": "module" to package.json root, relaxes devDependency versions, and bumps rollup. It adds an explicit Uint8Array return type in safeAllocUint8Array and removes an unnecessary Uint8Array cast in message concatenation. Multiple numeric-parsing sites were changed to use explicit radix or Number(...) instead of implicit parseInt. The TransitionHasher constructor was simplified to accept only keccak and blake2b (removing ChainSpec), and all call sites/tests were updated. A hex benchmark fix returns parsed values, and biome.jsonc schema version was updated.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

  • Heterogeneous changes spanning manifest, typing, parsing semantics, API signature, and tests.
  • Areas needing extra attention:
    • TransitionHasher constructor signature change and all updated call sites/tests.
    • Numeric-parsing semantics where parseInt was replaced or explicit radix added (verify intended behavior on non-integer inputs).
    • package.json "type": "module" relocation and devDependency range relaxations.
    • AccumulateData constructor parameter visibility change (public vs private field removal).
    • Benchmark and minor typing tweaks for potential runtime impacts.

Possibly related PRs

Suggested reviewers

  • mateuszsikora
  • skoszuta
  • DrEverr

Poem

🐇 I hopped through code at break of day,

moved modules, tuned the parse-away,
removed a cast, declared a type to stay,
slimmer hasher, calls now fewer — hooray,
small clean hops, the build hops on its way 🥕

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Description check ⚠️ Warning No pull request description was provided by the author, making it impossible to assess whether the description is related to the changeset. Add a detailed pull request description explaining the purpose and impact of the changes, including rationale for removing ChainSpec from TransitionHasher and other code improvements.
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The PR title 'Update dependencies' is vague and does not reflect the actual changes in the changeset, which involve multiple code refactoring fixes beyond just dependency updates. Consider using a more descriptive title that reflects the main changes, such as 'Refactor TransitionHasher constructor and add explicit type annotations' or 'Fix Number parsing and type safety across codebase'.

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/core/json-parser/index.test.ts (1)

56-56: Note the behavior change from parseInt to Number.

Similar to the change in bin/tci/args.ts, this switches from Number.parseInt(v) to Number(v). While both can parse the hex string "0x123" correctly, Number() has stricter parsing rules and can handle floating-point values.

For consistency across the codebase, please ensure this change aligns with the intended numeric parsing strategy.

📜 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 65ca2b0 and d8988bb.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (15)
  • benchmarks/bytes/hex-from.ts (1 hunks)
  • bin/jam/test/e2e.ts (1 hunks)
  • bin/tci/args.ts (1 hunks)
  • bin/test-runner/state-transition/state-transition.ts (1 hunks)
  • biome.jsonc (1 hunks)
  • package.json (1 hunks)
  • packages/core/json-parser/index.test.ts (1 hunks)
  • packages/core/networking/bin/test.ts (1 hunks)
  • packages/jam/config-node/jip-chain-spec.ts (1 hunks)
  • packages/jam/transition/accumulate/accumulate-data.ts (1 hunks)
  • packages/jam/transition/block-verifier.test.ts (1 hunks)
  • packages/jam/transition/hasher.test.ts (1 hunks)
  • packages/jam/transition/hasher.ts (0 hunks)
  • packages/workers/block-generator/generator.ts (1 hunks)
  • packages/workers/importer/main.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/jam/transition/hasher.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json
🧰 Additional context used
📓 Path-based instructions (2)
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/networking/bin/test.ts
  • packages/core/json-parser/index.test.ts
**/*.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/core/networking/bin/test.ts
  • packages/jam/transition/accumulate/accumulate-data.ts
  • packages/jam/transition/block-verifier.test.ts
  • packages/jam/transition/hasher.test.ts
  • packages/workers/importer/main.ts
  • benchmarks/bytes/hex-from.ts
  • bin/test-runner/state-transition/state-transition.ts
  • bin/jam/test/e2e.ts
  • packages/jam/config-node/jip-chain-spec.ts
  • bin/tci/args.ts
  • packages/workers/block-generator/generator.ts
  • packages/core/json-parser/index.test.ts
🧠 Learnings (1)
📓 Common learnings
Learnt from: tomusdrw
Repo: FluffyLabs/typeberry PR: 625
File: benchmarks/package.json:8-15
Timestamp: 2025-09-15T14:37:04.214Z
Learning: In the FluffyLabs/typeberry monorepo, the workspace:* protocol does not work for internal typeberry dependencies. The working approach is to use "*" as the version specifier for internal monorepo packages instead of "workspace:*".
🧬 Code graph analysis (6)
packages/jam/transition/accumulate/accumulate-data.ts (1)
packages/jam/block/common.ts (1)
  • ServiceGas (31-31)
packages/jam/transition/block-verifier.test.ts (2)
packages/jam/transition/hasher.ts (1)
  • TransitionHasher (9-62)
packages/core/hash/blake2b.ts (1)
  • Blake2b (8-44)
packages/jam/transition/hasher.test.ts (1)
packages/jam/transition/hasher.ts (1)
  • TransitionHasher (9-62)
packages/workers/importer/main.ts (1)
packages/jam/transition/hasher.ts (1)
  • TransitionHasher (9-62)
bin/test-runner/state-transition/state-transition.ts (1)
packages/jam/transition/hasher.ts (1)
  • TransitionHasher (9-62)
packages/workers/block-generator/generator.ts (1)
packages/jam/transition/hasher.ts (1)
  • TransitionHasher (9-62)
⏰ 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: e2e (22.x)
  • GitHub Check: test (22.x)
  • GitHub Check: run (22.x)
  • GitHub Check: state_transition (22.x)
  • GitHub Check: run (22.x)
  • GitHub Check: run (22.x)
🔇 Additional comments (11)
packages/core/networking/bin/test.ts (1)

90-90: LGTM! Explicit radix prevents octal interpretation.

Adding the explicit radix 10 is a good practice that prevents strings with leading zeros from being incorrectly parsed as octal numbers.

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

17-17: LGTM! Explicit radix improves parsing safety.

Adding the explicit radix 10 is consistent with the broader pattern in this PR and prevents potential issues with octal interpretation.

bin/jam/test/e2e.ts (1)

67-67: LGTM! Explicit radix ensures correct block number parsing.

Adding the explicit radix 10 is appropriate for parsing block numbers and aligns with the broader improvements in this PR.

benchmarks/bytes/hex-from.ts (1)

97-97: LGTM! Returning the value prevents dead code elimination.

Returning the computed value is good practice in benchmarks as it prevents the optimizer from potentially eliminating the computation, ensuring accurate performance measurements.

bin/tci/args.ts (1)

64-64: Change from Number.parseInt() to Number() improves CLI argument validation—concern is not applicable.

The original review raised concerns about stricter parsing behavior, but actually the opposite is true. Using Number(v) with the Number.isNaN() check is more strict:

  • parseInt("42abc") silently returns 42 and discards the invalid suffix
  • Number("42abc") returns NaN, which triggers the error: "Cannot parse '42abc' as a number"

For CLI arguments expecting integers (port, timestamp, validatorindex), rejecting malformed input like "42abc" is the correct behavior. The implementation is sound:

  1. No fractional values are expected (all tests use integers)
  2. Hex notation like "0xbeef" works correctly with Number()
  3. Downstream conversions (tryAsU16, tryAsTimeSlot, tryAsValidatorIndex) provide additional range validation
biome.jsonc (1)

2-2: Schema version is valid and accessible; review configuration for compatibility with documented breaking changes.

The schema URL at https://biomejs.dev/schemas/2.3.4/schema.json is accessible (HTTP 200). Between Biome 2.0.6 and 2.3.4, there are several documented breaking changes:

  • Configuration format: include/ignore replaced with includes (different glob semantics); deniedGlobals changed from array to record structure
  • CLI/API: renamed and removed options (--skip-errors--skip-parse-errors)
  • Linter: v2.1.x changed noImportCycles rule to ignore type-only imports by default

These changes may require updating the biome.jsonc configuration if your project uses any of these deprecated patterns. Run biome migrate to automatically update your configuration, or manually verify compatibility.

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

94-94: LGTM! Constructor call updated correctly.

The TransitionHasher constructor call has been correctly updated to match the new signature that no longer requires the ChainSpec parameter.

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

33-33: LGTM! Test updated correctly.

The test correctly instantiates TransitionHasher with the updated constructor signature, removing the spec parameter.

packages/workers/block-generator/generator.ts (1)

75-75: LGTM! Constructor call updated correctly.

The TransitionHasher instantiation has been correctly updated to use only the keccak and blake2b hashers, removing the chainSpec parameter as per the updated API.

packages/workers/importer/main.ts (1)

25-25: LGTM! Constructor call updated correctly.

The TransitionHasher instantiation has been properly updated to remove the chainSpec parameter, correctly awaiting both the keccak and blake2b hashers.

packages/jam/transition/block-verifier.test.ts (1)

28-28: LGTM! Test updated correctly.

The test correctly instantiates TransitionHasher with the updated constructor signature, removing the spec parameter and properly awaiting both hashers.

@tomusdrw tomusdrw enabled auto-merge (squash) November 13, 2025 10:07
@tomusdrw tomusdrw merged commit fcdfbb1 into main Nov 13, 2025
16 checks passed
@tomusdrw tomusdrw deleted the td-deps branch November 13, 2025 10:26
@github-actions
Copy link

View all
File Benchmark Ops
bytes/hex-to.ts[0] number toString + padding 305623.61 ±0.65% fastest ✅
bytes/hex-to.ts[1] manual 16026.58 ±0.45% 94.76% slower
hash/index.ts[0] hash with numeric representation 190.6 ±0.39% 27.79% slower
hash/index.ts[1] hash with string representation 114.59 ±0.41% 56.59% slower
hash/index.ts[2] hash with symbol representation 183.24 ±0.31% 30.58% slower
hash/index.ts[3] hash with uint8 representation 163.4 ±0.29% 38.1% slower
hash/index.ts[4] hash with packed representation 263.96 ±0.29% fastest ✅
hash/index.ts[5] hash with bigint representation 188.69 ±0.47% 28.52% slower
hash/index.ts[6] hash with uint32 representation 197.59 ±0.49% 25.14% slower
logger/index.ts[0] console.log with string concat 8415869.73 ±40.33% fastest ✅
logger/index.ts[1] console.log with args 713202.62 ±111.95% 91.53% slower
math/add_one_overflow.ts[0] add and take modulus 228351970.09 ±29.41% 5.43% slower
math/add_one_overflow.ts[1] condition before calculation 241465286.59 ±6.07% fastest ✅
math/count-bits-u64.ts[0] standard method 2728892.19 ±4.71% 96.94% slower
math/count-bits-u64.ts[1] magic 89221585.79 ±1.16% fastest ✅
codec/encoding.ts[0] manual encode 2066499 ±0.76% 19.86% slower
codec/encoding.ts[1] int32array encode 2499824.12 ±0.89% 3.06% slower
codec/encoding.ts[2] dataview encode 2578695.99 ±0.87% fastest ✅
bytes/hex-from.ts[0] parse hex using Number with NaN checking 106372.96 ±0.83% 82.72% slower
bytes/hex-from.ts[1] parse hex from char codes 615437.59 ±1% fastest ✅
bytes/hex-from.ts[2] parse hex from string nibbles 433793.74 ±0.69% 29.51% slower
codec/bigint.compare.ts[0] compare custom 258946951.01 ±4.47% fastest ✅
codec/bigint.compare.ts[1] compare bigint 257908050.68 ±5.91% 0.4% slower
collections/map-set.ts[0] 2 gets + conditional set 116438.87 ±0.46% fastest ✅
collections/map-set.ts[1] 1 get 1 set 59785.14 ±0.53% 48.66% slower
codec/bigint.decode.ts[0] decode custom 173398327.99 ±1.89% fastest ✅
codec/bigint.decode.ts[1] decode bigint 69361529.32 ±1.72% 60% slower
codec/decoding.ts[0] manual decode 11578875.18 ±1.29% 92.9% slower
codec/decoding.ts[1] int32array decode 154020499.71 ±3.82% 5.61% slower
codec/decoding.ts[2] dataview decode 163172031.18 ±2.8% fastest ✅
math/count-bits-u32.ts[0] standard method 93591079.61 ±1.94% 61.86% slower
math/count-bits-u32.ts[1] magic 245373733.84 ±4.29% fastest ✅
math/mul_overflow.ts[0] multiply and bring back to u32 265248582.76 ±4.71% fastest ✅
math/mul_overflow.ts[1] multiply and take modulus 255972985.45 ±5.79% 3.5% slower
math/switch.ts[0] switch 248738704.23 ±6.88% 3.39% slower
math/switch.ts[1] if 257475906.53 ±5.49% fastest ✅
codec/view_vs_object.ts[0] Get the first field from Decoded 37781.22 ±87.15% 92.88% slower
codec/view_vs_object.ts[1] Get the first field from View 86262.53 ±2.92% 83.75% slower
codec/view_vs_object.ts[2] Get the first field as view from View 88868.16 ±3.29% 83.26% slower
codec/view_vs_object.ts[3] Get two fields from Decoded 473068.27 ±0.97% 10.9% slower
codec/view_vs_object.ts[4] Get two fields from View 72842.16 ±1.17% 86.28% slower
codec/view_vs_object.ts[5] Get two fields from materialized from View 168066.36 ±1.68% 68.35% slower
codec/view_vs_object.ts[6] Get two fields as views from View 84315.64 ±0.33% 84.12% slower
codec/view_vs_object.ts[7] Get only third field from Decoded 530948.71 ±0.51% fastest ✅
codec/view_vs_object.ts[8] Get only third field from View 97920.38 ±1.67% 81.56% slower
codec/view_vs_object.ts[9] Get only third field as view from View 91489.61 ±1.51% 82.77% slower
codec/view_vs_collection.ts[0] Get first element from Decoded 32006.32 ±1.38% 56.42% slower
codec/view_vs_collection.ts[1] Get first element from View 73438.21 ±0.44% fastest ✅
codec/view_vs_collection.ts[2] Get 50th element from Decoded 33456.95 ±0.4% 54.44% slower
codec/view_vs_collection.ts[3] Get 50th element from View 37043.8 ±0.15% 49.56% slower
codec/view_vs_collection.ts[4] Get last element from Decoded 33513.49 ±0.32% 54.37% slower
codec/view_vs_collection.ts[5] Get last element from View 25265.9 ±0.28% 65.6% slower
collections/map_vs_sorted.ts[0] Map 283909.1 ±0.04% fastest ✅
collections/map_vs_sorted.ts[1] Map-array 101288.18 ±0.04% 64.32% slower
collections/map_vs_sorted.ts[2] Array 81837.03 ±0.63% 71.17% slower
collections/map_vs_sorted.ts[3] SortedArray 199538.93 ±0.2% 29.72% slower
bytes/compare.ts[0] Comparing Uint32 bytes 20808.28 ±0.25% 3.81% slower
bytes/compare.ts[1] Comparing raw bytes 21631.97 ±0.06% fastest ✅
hash/blake2b.ts[0] our hasher 2.23 ±0.2% fastest ✅
hash/blake2b.ts[1] blake2b js 0.05 ±0.25% 97.76% slower
crypto/ed25519.ts[0] native crypto 5.89 ±17.02% 80.76% slower
crypto/ed25519.ts[1] wasm lib 10.87 ±0.02% 64.49% slower
crypto/ed25519.ts[2] wasm lib batch 30.61 ±0.44% fastest ✅

Benchmarks summary: 63/63 OK ✅

@coderabbitai coderabbitai bot mentioned this pull request Nov 13, 2025
@coderabbitai coderabbitai bot mentioned this pull request Nov 23, 2025
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