Skip to content

Conversation

@tomusdrw
Copy link
Contributor

@tomusdrw tomusdrw commented Oct 20, 2025

And allow for easy state dumping to import in state viewer.

@tomusdrw tomusdrw requested a review from DrEverr October 20, 2025 12:50
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 20, 2025

📝 Walkthrough

Summary by CodeRabbit

  • Chores
    • Enhanced worker logging to display seal verification configuration status at runtime.
    • Improved internal state serialization capabilities.

Walkthrough

This PR introduces two additive enhancements across separate modules. First, a toString() method is added to the StateEntries class that serializes its internal entries dictionary to a formatted JSON string with 2-space indentation. Second, a runtime warning log is introduced in the worker importer that triggers when seal verification is configured to be omitted. Both changes preserve existing control flow and public APIs.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

The changes are straightforward and additive: a utility serialization method and a conditional warning statement. Both involve minimal logic density and represent independent, simple enhancements across two distinct functional areas. The homogeneous nature of these changes (simple additions with no complex interactions) keeps review overhead low, though context understanding for each module is needed.

Possibly related PRs

  • Fix state entries comparison. #581 — Modifies StateEntries class in the same file to expose/serialize internal entries differently, directly related to the toString() addition.
  • Block Generator E2E test #627 — Adds and propagates the omitSealVerification flag with related importer logging enhancements, connected to the worker importer warning.

Suggested reviewers

  • mateuszsikora
  • skoszuta

Poem

🐰 A rabbit's verse on strings and warnings clear:

Entries dance in JSON's neat attire,
While seals heed warnings, loud and sincere,
Small additions, each one by design entire,
Serialization blooms, transparency's fire! 🌟

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title "Add warning for dev mode" refers to the runtime warning added to the importer when seal verification is omitted, which is a legitimate and clearly described aspect of the changeset. While the PR also includes a new toString() method for state serialization (mentioned in the description), the title appropriately highlights one of the main changes without needing to cover all modifications. The title is specific, clear, and directly related to code present in the changeset.
Description Check ✅ Passed The description "And allow for easy state dumping to import in state viewer" directly relates to the new toString() method added to the StateEntries class, which serializes entries to JSON format for easy inspection and output. This clearly describes a real and significant part of the changeset. Although the description doesn't mention the warning aspect of the PR, it is sufficiently related to the changeset to pass this lenient check.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch td-assorted

📜 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 ef1ea0e and e7458f1.

📒 Files selected for processing (2)
  • packages/jam/state-merkleization/state-entries.ts (1 hunks)
  • packages/workers/importer/main.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:

  • packages/jam/state-merkleization/state-entries.ts
  • packages/workers/importer/main.ts
🧬 Code graph analysis (2)
packages/jam/state-merkleization/state-entries.ts (1)
packages/jam/state/state-update.ts (2)
  • key (175-180)
  • value (182-187)
packages/workers/importer/main.ts (1)
packages/jam/node/common.ts (1)
  • logger (19-19)
⏰ 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: test (22.x)
  • GitHub Check: run (22.x)
  • GitHub Check: run (22.x)
  • GitHub Check: run (22.x)
  • GitHub Check: run (22.x)
🔇 Additional comments (2)
packages/workers/importer/main.ts (1)

44-46: LGTM! Clear dev-mode warning.

The warning is well-positioned and the message appropriately emphasizes that seal verification bypass should only be used in development environments.

packages/jam/state-merkleization/state-entries.ts (1)

72-82: JSON serialization for StateKey and BytesBlob is correct.

Both types have proper JSON serialization support:

  • BytesBlob has an explicit toJSON() method that returns a hex-encoded string
  • StateKey (defined as Opaque<OpaqueHash, "stateKey">) wraps OpaqueHash which is Bytes<HASH_SIZE>, and Bytes extends BytesBlob, inheriting its toJSON() method

The toString() implementation at lines 72-82 will correctly serialize both keys and values.


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

@mateuszsikora mateuszsikora enabled auto-merge (squash) October 20, 2025 15:06
@mateuszsikora mateuszsikora enabled auto-merge (squash) October 20, 2025 15:34
@github-actions
Copy link

View all
File Benchmark Ops
bytes/hex-to.ts[0] number toString + padding 323415.42 ±0.4% fastest ✅
bytes/hex-to.ts[1] manual 16103.36 ±0.27% 95.02% slower
hash/index.ts[0] hash with numeric representation 189.07 ±0.36% 27.35% slower
hash/index.ts[1] hash with string representation 117.25 ±0.36% 54.95% slower
hash/index.ts[2] hash with symbol representation 179.14 ±0.28% 31.17% slower
hash/index.ts[3] hash with uint8 representation 160.84 ±0.29% 38.2% slower
hash/index.ts[4] hash with packed representation 260.26 ±0.13% fastest ✅
hash/index.ts[5] hash with bigint representation 188.47 ±0.33% 27.58% slower
hash/index.ts[6] hash with uint32 representation 198.09 ±0.24% 23.89% slower
collections/map-set.ts[0] 2 gets + conditional set 117648.15 ±0.22% fastest ✅
collections/map-set.ts[1] 1 get 1 set 59812.71 ±0.2% 49.16% slower
codec/decoding.ts[0] manual decode 22091152.23 ±0.51% 85.86% slower
codec/decoding.ts[1] int32array decode 156258367.01 ±3.51% fastest ✅
codec/decoding.ts[2] dataview decode 149965665.37 ±3.05% 4.03% slower
codec/encoding.ts[0] manual encode 2745673.32 ±1.34% 17.56% slower
codec/encoding.ts[1] int32array encode 3330451.81 ±1.39% fastest ✅
codec/encoding.ts[2] dataview encode 3145941.92 ±1.51% 5.54% slower
bytes/hex-from.ts[0] parse hex using Number with NaN checking 131112.95 ±1.07% 84.33% slower
bytes/hex-from.ts[1] parse hex from char codes 836803.68 ±0.82% fastest ✅
bytes/hex-from.ts[2] parse hex from string nibbles 542987.75 ±0.59% 35.11% slower
codec/bigint.compare.ts[0] compare custom 253802945.24 ±5.63% fastest ✅
codec/bigint.compare.ts[1] compare bigint 238412097.13 ±6.65% 6.06% slower
codec/bigint.decode.ts[0] decode custom 168096271.87 ±2.62% fastest ✅
codec/bigint.decode.ts[1] decode bigint 98053057.68 ±2.81% 41.67% slower
math/add_one_overflow.ts[0] add and take modulus 240961814.52 ±6.96% 3.93% slower
math/add_one_overflow.ts[1] condition before calculation 250816607.07 ±6.12% fastest ✅
math/count-bits-u32.ts[0] standard method 86153999.16 ±2.15% 65.98% slower
math/count-bits-u32.ts[1] magic 253268745.42 ±5.36% fastest ✅
math/count-bits-u64.ts[0] standard method 1368746.87 ±0.49% 86.96% slower
math/count-bits-u64.ts[1] magic 10495983.14 ±1.32% fastest ✅
math/mul_overflow.ts[0] multiply and bring back to u32 247072421.55 ±7% 3.78% slower
math/mul_overflow.ts[1] multiply and take modulus 256781745.43 ±5.79% fastest ✅
math/switch.ts[0] switch 234548611.98 ±8.41% 8.91% slower
math/switch.ts[1] if 257501710.42 ±6.56% fastest ✅
logger/index.ts[0] console.log with string concat 6664632.14 ±60.6% fastest ✅
logger/index.ts[1] console.log with args 1022323.98 ±89.25% 84.66% slower
codec/view_vs_object.ts[0] Get the first field from Decoded 476392.21 ±2.23% 0.84% slower
codec/view_vs_object.ts[1] Get the first field from View 94910.16 ±2.98% 80.24% slower
codec/view_vs_object.ts[2] Get the first field as view from View 100678.75 ±1.58% 79.04% slower
codec/view_vs_object.ts[3] Get two fields from Decoded 480407.84 ±2.23% fastest ✅
codec/view_vs_object.ts[4] Get two fields from View 73496.96 ±3.48% 84.7% slower
codec/view_vs_object.ts[5] Get two fields from materialized from View 165288.38 ±1.11% 65.59% slower
codec/view_vs_object.ts[6] Get two fields as views from View 78663.37 ±1.48% 83.63% slower
codec/view_vs_object.ts[7] Get only third field from Decoded 477542.09 ±1.79% 0.6% slower
codec/view_vs_object.ts[8] Get only third field from View 97106.71 ±1.6% 79.79% slower
codec/view_vs_object.ts[9] Get only third field as view from View 91490.57 ±1.79% 80.96% slower
codec/view_vs_collection.ts[0] Get first element from Decoded 24874.38 ±1.31% 55.57% slower
codec/view_vs_collection.ts[1] Get first element from View 55980.23 ±1.64% fastest ✅
codec/view_vs_collection.ts[2] Get 50th element from Decoded 23302.36 ±1.3% 58.37% slower
codec/view_vs_collection.ts[3] Get 50th element from View 23747.75 ±1.06% 57.58% slower
codec/view_vs_collection.ts[4] Get last element from Decoded 21121.36 ±1.13% 62.27% slower
codec/view_vs_collection.ts[5] Get last element from View 14863.71 ±1.29% 73.45% slower
collections/map_vs_sorted.ts[0] Map 286202.28 ±0.62% fastest ✅
collections/map_vs_sorted.ts[1] Map-array 87378.47 ±1.45% 69.47% slower
collections/map_vs_sorted.ts[2] Array 23973.81 ±6.29% 91.62% slower
collections/map_vs_sorted.ts[3] SortedArray 172510.24 ±1.46% 39.72% slower
bytes/compare.ts[0] Comparing Uint32 bytes 16848.34 ±4.1% fastest ✅
bytes/compare.ts[1] Comparing raw bytes 15004.96 ±3.92% 10.94% slower
hash/blake2b.ts[0] our hasher 1.93 ±3.05% fastest ✅
hash/blake2b.ts[1] blake2b js 0.04 ±4.23% 97.93% slower
crypto/ed25519.ts[0] native crypto 4.83 ±19.72% 83.45% slower
crypto/ed25519.ts[1] wasm lib 9.12 ±6.35% 68.76% slower
crypto/ed25519.ts[2] wasm lib batch 29.19 ±0.79% fastest ✅

Benchmarks summary: 63/63 OK ✅

@mateuszsikora mateuszsikora merged commit 0303f5b into main Oct 20, 2025
16 checks passed
@mateuszsikora mateuszsikora deleted the td-assorted branch October 20, 2025 15:54
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