Skip to content

Fix invalid signature traces#846

Merged
mateuszsikora merged 5 commits into
mainfrom
ms-fix-invalid-signature-traces
Dec 28, 2025
Merged

Fix invalid signature traces#846
mateuszsikora merged 5 commits into
mainfrom
ms-fix-invalid-signature-traces

Conversation

@mateuszsikora

@mateuszsikora mateuszsikora commented Dec 27, 2025

Copy link
Copy Markdown
Contributor

Changes:

  • currentValidatorData and previousValidatorData moved from state to input in reports
  • currentValidatorData and previousValidatorData from state replaced with corresponding values from safrole state update

it should be merged after: #845

@coderabbitai

coderabbitai Bot commented Dec 27, 2025

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Summary by CodeRabbit

  • Tests
    • Removed previously ignored test vectors and expanded coverage for reports.
    • Extended test inputs to include current and previous validator data for more realistic scenarios and assertions.
  • Bug Fixes
    • Reports validation and assignment flows now accept explicit current/previous validator data, improving correctness across rotations and epoch transitions.
  • Chores
    • Increased test-runner timeout to accommodate longer test executions.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

The PR threads per-validator data (currentValidatorData and previousValidatorData) through the reports transition pipeline by converting formerly internal Reports state into explicit input parameters and updating types and call sites. Reports.getGuarantorAssignment and verifyCredentials signatures changed to accept the two validator-data arguments; ReportsState exposure was narrowed. Tests and test utilities were updated to provide the new fields via tryAsPerValidator. The conformance test runner had nine entries removed from its ignored list (exposing those vectors) and the global test-runner timeout was increased from 20 to 25 minutes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested reviewers

  • skoszuta
  • tomusdrw
  • DrEverr

Poem

🐰 I hopped the state and carried the load,
Two tiny maps along the code road.
Tests once hidden now bound to the light,
Time ticked a bit more to get it all right.
A happy hop — reports take flight! 🎉

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'Fix invalid signature traces' is vague and does not clearly summarize the main changes, which involve moving validator data from state to input in the reports module. Consider revising the title to be more specific about the structural changes, such as 'Move validator data from state to input in reports' or 'Refactor validator data handling in reports module'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the main changes: moving validator data fields from state to input and replacing state references with safrole state update values, which directly relates to the changeset.
✨ 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 ms-fix-invalid-signature-traces

📜 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 a3c4dc1 and 1824858.

📒 Files selected for processing (1)
  • bin/test-runner/jam-conformance-072.ts
💤 Files with no reviewable changes (1)
  • bin/test-runner/jam-conformance-072.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). (5)
  • GitHub Check: Setup test vectors cache
  • GitHub Check: benchmarks (22.x)
  • GitHub Check: jam-e2e (22.x)
  • GitHub Check: e2e (22.x)
  • GitHub Check: test (22.x)

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

Base automatically changed from ms-update-links-in-reports to main December 27, 2025 15:21

@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/jam-conformance-072.ts (1)

14-15: Clarify the uncertainty in the comment.

The question mark added to this comment suggests uncertainty about whether the block should be rejected. If the expected behavior is unclear, this should be investigated and documented. Consider either:

  • Removing the test case from the ignored list if it should pass
  • Documenting why the behavior is uncertain
  • Filing an issue to investigate the expected behavior
📜 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 584584e and 0714cf2.

📒 Files selected for processing (9)
  • bin/test-runner/jam-conformance-072.ts
  • bin/test-runner/w3f/reports.ts
  • packages/jam/transition/chain-stf.ts
  • packages/jam/transition/reports/index.test.ts
  • packages/jam/transition/reports/input.ts
  • packages/jam/transition/reports/reports.ts
  • packages/jam/transition/reports/test.utils.ts
  • packages/jam/transition/reports/verify-contextual.test.ts
  • packages/jam/transition/reports/verify-credentials.test.ts
💤 Files with no reviewable changes (1)
  • packages/jam/transition/reports/test.utils.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:

  • packages/jam/transition/reports/input.ts
  • packages/jam/transition/chain-stf.ts
  • packages/jam/transition/reports/verify-credentials.test.ts
  • bin/test-runner/jam-conformance-072.ts
  • packages/jam/transition/reports/verify-contextual.test.ts
  • bin/test-runner/w3f/reports.ts
  • packages/jam/transition/reports/reports.ts
  • packages/jam/transition/reports/index.test.ts
🧠 Learnings (3)
📚 Learning: 2025-06-18T20:35:13.536Z
Learnt from: tomusdrw
Repo: FluffyLabs/typeberry PR: 442
File: packages/core/pvm-debugger-adapter/index.ts:22-40
Timestamp: 2025-06-18T20:35:13.536Z
Learning: The `typeberry/utils` package has browser compatibility issues due to Node.js-specific code like `measure` function using `process.hrtime()` and `testUtils` importing `node:assert`, causing white screens in browser environments.

Applied to files:

  • packages/jam/transition/reports/verify-credentials.test.ts
  • packages/jam/transition/reports/verify-contextual.test.ts
📚 Learning: 2025-06-18T20:35:13.536Z
Learnt from: tomusdrw
Repo: FluffyLabs/typeberry PR: 442
File: packages/core/pvm-debugger-adapter/index.ts:22-40
Timestamp: 2025-06-18T20:35:13.536Z
Learning: The `measure` function in `typeberry/utils/debug.ts` attempts environment detection by checking `process === undefined` but still causes bundling issues because bundlers see the `process.hrtime` reference in the Node.js branch.

Applied to files:

  • packages/jam/transition/reports/verify-credentials.test.ts
  • packages/jam/transition/reports/verify-contextual.test.ts
📚 Learning: 2025-06-10T12:06:32.535Z
Learnt from: tomusdrw
Repo: FluffyLabs/typeberry PR: 419
File: packages/jam/database-lmdb/states.test.ts:158-160
Timestamp: 2025-06-10T12:06:32.535Z
Learning: In test code, tomusdrw prefers pragmatic solutions over strict type safety when listing all entries would be cumbersome. Using `Object.assign({}, state)` for state updates in tests is acceptable even if it compromises type safety, prioritizing test maintainability and readability.

Applied to files:

  • packages/jam/transition/reports/reports.ts
  • packages/jam/transition/reports/index.test.ts
🧬 Code graph analysis (1)
packages/jam/transition/reports/verify-contextual.test.ts (3)
packages/jam/block/common.ts (1)
  • tryAsPerValidator (56-62)
packages/jam/transition/reports/test.utils.ts (1)
  • initialValidators (297-323)
packages/jam/config/chain-spec.ts (1)
  • tinyChainSpec (109-126)
⏰ 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: benchmarks (22.x)
  • GitHub Check: Setup test vectors cache
  • GitHub Check: e2e (22.x)
  • GitHub Check: test (22.x)
🔇 Additional comments (17)
packages/jam/transition/chain-stf.ts (1)

280-281: LGTM! Validator data correctly passed from safrole to reports.

The validator data fields are properly sourced from the safrole state update (lines 242-243) and passed to the reports transition, aligning with the PR objective to move these fields from state to input.

packages/jam/transition/reports/input.ts (1)

60-67: LGTM! ReportsInput properly extended with validator data fields.

The new fields are well-documented with Greek letter references and properly typed using SafroleStateUpdate's type definitions, ensuring type safety and consistency.

packages/jam/transition/reports/verify-contextual.test.ts (3)

2-2: LGTM! Import updated to include tryAsPerValidator.


14-22: LGTM! Test utilities import extended with initialValidators.


43-44: LGTM! Test inputs consistently extended with validator data.

All test cases properly populate currentValidatorData and previousValidatorData using the same validator set. This is appropriate for contextual validation tests that don't focus on validator rotation scenarios.

Also applies to: 80-81, 114-115, 149-150, 183-184, 219-220, 255-256, 293-294, 333-334, 378-379, 416-417

packages/jam/transition/reports/index.test.ts (2)

2-2: LGTM! Imports updated for validator data support.

Also applies to: 9-9


22-23: LGTM! Test input properly extended with validator data.

packages/jam/transition/reports/verify-credentials.test.ts (2)

2-2: LGTM! Import updated to include tryAsPerValidator.


42-43: LGTM! All credential verification tests consistently updated.

All test cases properly include the required validator data fields, maintaining consistency with the refactoring objectives.

Also applies to: 77-78, 108-109, 139-140, 170-171, 201-202, 232-233

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

4-4: LGTM! PerValidator type imported for validator data support.


69-69: LGTM! Return type correctly omits validator data fields.

The validator data fields are intentionally omitted from the return type since they're added later from the test state, maintaining proper separation of concerns.


114-115: LGTM! Test state properly returns validator data.

The test harness correctly separates current and previous validators from the JSON test vectors and converts them to PerValidator arrays using tryAsPerValidator, enabling proper testing of validator rotation scenarios.

Also applies to: 137-138


279-283: LGTM! Validator data correctly passed to reports transition.

The spread pattern cleanly merges the input with validator data from the pre-state, aligning with the refactoring to move validator data from state to input.

packages/jam/transition/reports/reports.ts (3)

21-25: LGTM! ReportsState correctly updated to remove validator data fields.

The validator data fields are properly removed from the state since they're now passed as input parameters, completing the refactoring objective.


141-150: LGTM! Validator data correctly passed to getGuarantorAssignment.

The verifyCredentials method properly forwards the validator data from the input to getGuarantorAssignment, maintaining the data flow for credential verification.


197-255: LGTM! getGuarantorAssignment correctly refactored to accept validator data as parameters.

The method signature is properly updated to receive validator data as explicit parameters instead of reading from state. The logic for selecting between current and previous validator data based on rotation is preserved (lines 230, 242), maintaining the correct behavior for different epoch and rotation scenarios.

bin/test-runner/jam-conformance-072.ts (1)

7-28: Unable to verify the claim about un-ignored test vectors. The git history for this file is not accessible in the current repository state (detached HEAD at FETCH_HEAD), and no diff information is available to confirm which entries were removed from the ignored list. Additionally, the test runner cannot be executed in this environment to verify whether previously ignored tests now pass. Manual verification of the actual changes to the ignored list and test execution results is required.

@tomusdrw tomusdrw added this pull request to the merge queue Dec 28, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Dec 28, 2025
@mateuszsikora mateuszsikora added this pull request to the merge queue Dec 28, 2025
Merged via the queue into main with commit 093673a Dec 28, 2025
9 checks passed
@mateuszsikora mateuszsikora deleted the ms-fix-invalid-signature-traces branch December 28, 2025 16:52
@github-actions

Copy link
Copy Markdown
View all
File Benchmark Ops
bytes/hex-from.ts[0] parse hex using Number with NaN checking 50841.22 ±0.25% 88.91% slower
bytes/hex-from.ts[1] parse hex from char codes 458359.84 ±0.51% fastest ✅
bytes/hex-from.ts[2] parse hex from string nibbles 244110.23 ±0.16% 46.74% slower
math/count-bits-u64.ts[0] standard method 435238.15 ±0.65% 85.32% slower
math/count-bits-u64.ts[1] magic 2965688.63 ±1.47% fastest ✅
math/add_one_overflow.ts[0] add and take modulus 94666782.8 ±4.41% fastest ✅
math/add_one_overflow.ts[1] condition before calculation 92886278.72 ±5.27% 1.88% slower
collections/map-set.ts[0] 2 gets + conditional set 86355.27 ±0.08% fastest ✅
collections/map-set.ts[1] 1 get 1 set 48954.87 ±0.1% 43.31% slower
hash/index.ts[0] hash with numeric representation 71.02 ±0.25% 27.92% slower
hash/index.ts[1] hash with string representation 36.63 ±0.39% 62.82% slower
hash/index.ts[2] hash with symbol representation 69.68 ±0.23% 29.28% slower
hash/index.ts[3] hash with uint8 representation 68.5 ±0.45% 30.48% slower
hash/index.ts[4] hash with packed representation 98.53 ±0.56% fastest ✅
hash/index.ts[5] hash with bigint representation 74.71 ±1.76% 24.18% slower
hash/index.ts[6] hash with uint32 representation 81.49 ±0.8% 17.29% slower
logger/index.ts[0] console.log with string concat 3951585.47 ±51.56% fastest ✅
logger/index.ts[1] console.log with args 1519663.38 ±61.94% 61.54% slower
codec/bigint.compare.ts[0] compare custom 8688954.93 ±69.96% 91.2% slower
codec/bigint.compare.ts[1] compare bigint 98780336.19 ±4.19% fastest ✅
codec/bigint.decode.ts[0] decode custom 71903656.79 ±3.77% fastest ✅
codec/bigint.decode.ts[1] decode bigint 36012408.19 ±1.36% 49.92% slower
math/count-bits-u32.ts[0] standard method 36938558.77 ±2.14% 61.93% slower
math/count-bits-u32.ts[1] magic 97018737.51 ±3.75% fastest ✅
math/mul_overflow.ts[0] multiply and bring back to u32 99188616.94 ±4.83% 0.32% slower
math/mul_overflow.ts[1] multiply and take modulus 99505370.61 ±4.08% fastest ✅
math/switch.ts[0] switch 98611945.51 ±3.99% fastest ✅
math/switch.ts[1] if 97086493.67 ±5.74% 1.55% slower
bytes/hex-to.ts[0] number toString + padding 80458.25 ±0.51% fastest ✅
bytes/hex-to.ts[1] manual 6480.21 ±0.41% 91.95% slower
codec/encoding.ts[0] manual encode 882428.14 ±0.6% 15.58% slower
codec/encoding.ts[1] int32array encode 1037661.61 ±0.59% 0.72% slower
codec/encoding.ts[2] dataview encode 1045222.6 ±0.46% fastest ✅
codec/decoding.ts[0] manual decode 7136178.8 ±0.76% 90.42% slower
codec/decoding.ts[1] int32array decode 70915834.95 ±3.97% 4.83% slower
codec/decoding.ts[2] dataview decode 74517519.94 ±3.24% fastest ✅
codec/view_vs_collection.ts[0] Get first element from Decoded 11230.24 ±0.34% 56.87% slower
codec/view_vs_collection.ts[1] Get first element from View 26038.65 ±0.97% fastest ✅
codec/view_vs_collection.ts[2] Get 50th element from Decoded 11247.73 ±0.16% 56.8% slower
codec/view_vs_collection.ts[3] Get 50th element from View 14165.3 ±0.78% 45.6% slower
codec/view_vs_collection.ts[4] Get last element from Decoded 11490.68 ±0.46% 55.87% slower
codec/view_vs_collection.ts[5] Get last element from View 9670.35 ±0.52% 62.86% slower
codec/view_vs_object.ts[0] Get the first field from Decoded 178237.17 ±0.55% fastest ✅
codec/view_vs_object.ts[1] Get the first field from View 45575.74 ±0.47% 74.43% slower
codec/view_vs_object.ts[2] Get the first field as view from View 45005.07 ±0.55% 74.75% slower
codec/view_vs_object.ts[3] Get two fields from Decoded 177216.84 ±0.61% 0.57% slower
codec/view_vs_object.ts[4] Get two fields from View 35966.53 ±0.56% 79.82% slower
codec/view_vs_object.ts[5] Get two fields from materialized from View 73079.17 ±0.55% 59% slower
codec/view_vs_object.ts[6] Get two fields as views from View 35845.55 ±0.58% 79.89% slower
codec/view_vs_object.ts[7] Get only third field from Decoded 177571.19 ±0.57% 0.37% slower
codec/view_vs_object.ts[8] Get only third field from View 44703.36 ±0.56% 74.92% slower
codec/view_vs_object.ts[9] Get only third field as view from View 44387.02 ±0.59% 75.1% slower
collections/hash-dict-vs-blob-dict_get.ts[0] StringHashDictionary 1557.71 ±0.43% 1.75% slower
collections/hash-dict-vs-blob-dict_get.ts[1] BlobDictionary(1) 1555.37 ±0.36% 1.9% slower
collections/hash-dict-vs-blob-dict_get.ts[2] BlobDictionary(2) 1554.18 ±0.71% 1.98% slower
collections/hash-dict-vs-blob-dict_get.ts[3] BlobDictionary(3) 1569.94 ±0.88% 0.98% slower
collections/hash-dict-vs-blob-dict_get.ts[4] BlobDictionary(4) 1547.06 ±0.72% 2.43% slower
collections/hash-dict-vs-blob-dict_get.ts[5] BlobDictionary(5) 1585.52 ±0.84% fastest ✅
collections/hash-dict-vs-blob-dict_set.ts[0] StringHashDictionary 1604.95 ±0.45% fastest ✅
collections/hash-dict-vs-blob-dict_set.ts[1] BlobDictionary(1) 1587.56 ±0.41% 1.08% slower
collections/hash-dict-vs-blob-dict_set.ts[2] BlobDictionary(2) 1558.35 ±0.82% 2.9% slower
collections/hash-dict-vs-blob-dict_set.ts[3] BlobDictionary(3) 1514.77 ±0.84% 5.62% slower
collections/hash-dict-vs-blob-dict_set.ts[4] BlobDictionary(4) 1514.52 ±0.61% 5.63% slower
collections/hash-dict-vs-blob-dict_set.ts[5] BlobDictionary(5) 1544.29 ±0.67% 3.78% slower
collections/hash-dict-vs-blob-dict_delete.ts[0] StringHashDictionary 2019.33 ±0.25% fastest ✅
collections/hash-dict-vs-blob-dict_delete.ts[1] BlobDictionary(1) 2008.61 ±0.53% 0.53% slower
collections/hash-dict-vs-blob-dict_delete.ts[2] BlobDictionary(2) 2006.63 ±0.66% 0.63% slower
collections/hash-dict-vs-blob-dict_delete.ts[3] BlobDictionary(3) 1935.27 ±1.15% 4.16% slower
collections/hash-dict-vs-blob-dict_delete.ts[4] BlobDictionary(4) 1863.54 ±0.76% 7.71% slower
collections/hash-dict-vs-blob-dict_delete.ts[5] BlobDictionary(5) 1856.83 ±0.67% 8.05% slower
collections/map_vs_sorted.ts[0] Map 134436.6 ±0.08% fastest ✅
collections/map_vs_sorted.ts[1] Map-array 46166.67 ±0.07% 65.66% slower
collections/map_vs_sorted.ts[2] Array 25460.07 ±2.69% 81.06% slower
collections/map_vs_sorted.ts[3] SortedArray 83066.4 ±0.13% 38.21% slower
bytes/bytes-to-number.ts[0] Conversion with bitops 3489.28 ±5.55% 1.41% slower
bytes/bytes-to-number.ts[1] Conversion without bitops 3539.34 ±5.36% fastest ✅
bytes/compare.ts[0] Comparing Uint32 bytes 10224.7 ±0.12% fastest ✅
bytes/compare.ts[1] Comparing raw bytes 9651.84 ±0.18% 5.6% slower
hash/blake2b.ts[0] our hasher 1.12 ±0.12% fastest ✅
hash/blake2b.ts[1] blake2b js 0.03 ±0.06% 97.32% slower
crypto/ed25519.ts[0] native crypto 3.49 ±18.25% fastest ✅
crypto/ed25519.ts[1] wasm lib 2.08 ±0.3% 40.4% slower
crypto/ed25519.ts[2] wasm lib batch 2.06 ±0.25% 40.97% slower

Benchmarks summary: 83/83 OK ✅

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