Skip to content

Bump native bandersnatch#999

Merged
tomusdrw merged 3 commits into
mainfrom
td-bump-native
Jun 8, 2026
Merged

Bump native bandersnatch#999
tomusdrw merged 3 commits into
mainfrom
td-bump-native

Conversation

@tomusdrw

@tomusdrw tomusdrw commented Jun 1, 2026

Copy link
Copy Markdown
Member

with batch ticket verification

@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d8ece4bd-52e3-4366-a6ff-81b2c34edfb7

📥 Commits

Reviewing files that changed from the base of the PR and between 06f5aab and 4807a98.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • bin/lib/package.json
  • packages/core/crypto/package.json
  • packages/core/erasure-coding/package.json

📝 Walkthrough

Summary by CodeRabbit

  • Chores

    • Updated a native dependency to version 0.5.1 across core packages.
  • Refactor

    • Ticket verification changed to a batch-style response: verification now yields a single overall validity flag plus a list of ticket IDs, and flows that consume verification short-circuit on a failed batch.

Walkthrough

This PR bumps @typeberry/native to 0.5.1 in three package manifests and refactors bandersnatchVrf.verifyTickets to return a single batch result object { isValid, tickets: EntropyHash[] }. The verifier now reads one discriminator byte for overall validity and parses the rest as HASH_SIZE chunks; tests and all call sites (safrole accumulator and block-authorship pool verification) were updated to check verificationResult.isValid and map verified ticket IDs from verificationResult.tickets.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • mateuszsikora
  • skoszuta

Poem

🐰 I parsed the bytes and hopped with glee,
One flag to rule the batch — tickets set free.
From many small checks to a single bright tune,
Hashes in a row, beneath the moon. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Bump native bandersnatch' is partially related to the changeset but overly broad—it refers to the native dependency bump in three package.json files, but the main change involves restructuring the bandersnatch VRF ticket verification API to use batch verification with a new return shape across multiple application files.
Description check ✅ Passed The description 'with batch ticket verification' is related to the changeset, specifically describing the batch verification behavior changes to the ticket verification API across multiple files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch td-bump-native

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

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/jam/safrole/bandersnatch-vrf.ts`:
- Around line 162-170: The payload length for decoded hashes must be validated
before chunking to avoid partial blobs and out-of-range ticket indexing: in the
batchVerifyTicket flow check that verificationResult.subarray(1).length ===
tickets.length * HASH_SIZE (or at least >= if you intend to tolerate extra
padding) and if it does not match, set isValid = false (or throw) and skip
decoding; reference RESULT_INDEX, ResultValues.Ok,
verificationResult.subarray(1), BytesBlob.chunks, HASH_SIZE, Bytes.fromBlob, and
tickets to locate where to add this length check and early-return/handling.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a4bfc143-9e4f-47ed-b924-edfe40c4ef96

📥 Commits

Reviewing files that changed from the base of the PR and between 9587022 and 06f5aab.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (8)
  • bin/lib/package.json
  • packages/core/crypto/package.json
  • packages/core/erasure-coding/package.json
  • packages/jam/safrole/bandersnatch-vrf.test.ts
  • packages/jam/safrole/bandersnatch-vrf.ts
  • packages/jam/safrole/safrole.test.ts
  • packages/jam/safrole/safrole.ts
  • packages/workers/block-authorship/main.ts

Comment thread packages/jam/safrole/bandersnatch-vrf.ts
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
File Benchmark Error
collections/map-set.ts[0] 2 gets + conditional set Significant speed difference: (current) "45172.44 (1.102948800182908) ±1.67%" vs "86222.26 (1.3252659980015085) ± 10%" (previous)
hash/index.ts[7] hash with uint32 representation Fastest result changed to (current) "hash with uint32 representation[6]" from "hash with packed representation[4]" (expected) ❌
View all
File Benchmark Ops
bytes/hex-from.ts[0] parse hex using Number with NaN checking 69856.46 ±4.44% 83.19% slower
bytes/hex-from.ts[1] parse hex from char codes 415535.56 ±1.8% fastest ✅
bytes/hex-from.ts[2] parse hex from string nibbles 245622.98 ±1.33% 40.89% slower
bytes/hex-to.ts[0] number toString + padding 83529.93 ±1.24% fastest ✅
bytes/hex-to.ts[1] manual 6486.13 ±1.14% 92.23% slower
codec/bigint.compare.ts[0] compare custom 87038944.52 ±4.66% fastest ✅
codec/bigint.compare.ts[1] compare bigint 81964389.09 ±5.79% 5.83% slower
codec/bigint.decode.ts[0] decode custom 66694401.42 ±2.54% 17.75% slower
codec/bigint.decode.ts[1] decode bigint 81090375.27 ±4.62% fastest ✅
codec/decoding.ts[0] manual decode 8609421.43 ±2.23% 86.7% slower
codec/decoding.ts[1] int32array decode 64741155.07 ±3.19% fastest ✅
codec/decoding.ts[2] dataview decode 55661218.5 ±5.67% 14.02% slower
codec/encoding.ts[0] manual encode 2185018.39 ±1.14% 23.28% slower
codec/encoding.ts[1] int32array encode 2786982.66 ±2.42% 2.15% slower
codec/encoding.ts[2] dataview encode 2848176.65 ±1.02% fastest ✅
collections/map-set.ts[0] 2 gets + conditional set 45172.44 ±1.67% fastest ✅
collections/map-set.ts[1] 1 get 1 set 37133.24 ±1.15% 17.8% slower
logger/index.ts[0] console.log with string concat 4380491.77 ±25.42% fastest ✅
logger/index.ts[1] console.log with args 1453803.97 ±85.25% 66.81% slower
math/add_one_overflow.ts[0] add and take modulus 88316621.18 ±4.09% fastest ✅
math/add_one_overflow.ts[1] condition before calculation 85859876.87 ±4.23% 2.78% slower
math/count-bits-u32.ts[0] standard method 22412432.81 ±67.55% 49.13% slower
math/count-bits-u32.ts[1] magic 44060416.45 ±65.94% fastest ✅
math/count-bits-u64.ts[0] standard method 589055.2 ±1.3% 86.21% slower
math/count-bits-u64.ts[1] magic 4272231.75 ±1.31% fastest ✅
math/mul_overflow.ts[0] multiply and bring back to u32 95515905.85 ±3.91% fastest ✅
math/mul_overflow.ts[1] multiply and take modulus 88503817.7 ±4.22% 7.34% slower
math/switch.ts[0] switch 90222205.75 ±4.9% 2.23% slower
math/switch.ts[1] if 92276095.32 ±4.22% fastest ✅
hash/index.ts[0] hash with numeric representation 62.35 ±1.14% 27.79% slower
hash/index.ts[1] hash with string representation 38.63 ±1.63% 55.26% slower
hash/index.ts[2] hash with symbol representation 61.1 ±0.52% 29.24% slower
hash/index.ts[3] hash with uint8 representation 68.08 ±1.56% 21.16% slower
hash/index.ts[4] hash with packed representation 83.67 ±3.18% 3.1% slower
hash/index.ts[5] hash with bigint representation 71.41 ±0.78% 17.3% slower
hash/index.ts[6] hash with uint32 representation 86.35 ±0.46% fastest ✅
bytes/bytes-to-number.ts[0] Conversion with bitops 2627.46 ±0.82% fastest ✅
bytes/bytes-to-number.ts[1] Conversion without bitops 1762.57 ±3% 32.92% slower
bytes/compare.ts[0] Comparing Uint32 bytes 6047.96 ±7.15% 45.38% slower
bytes/compare.ts[1] Comparing raw bytes 11073.01 ±3.46% fastest ✅
codec/view_vs_collection.ts[0] Get first element from Decoded 17287.53 ±3.16% 49.82% slower
codec/view_vs_collection.ts[1] Get first element from View 34449.66 ±2.99% fastest ✅
codec/view_vs_collection.ts[2] Get 50th element from Decoded 17576.69 ±3.55% 48.98% slower
codec/view_vs_collection.ts[3] Get 50th element from View 18791.75 ±4.33% 45.45% slower
codec/view_vs_collection.ts[4] Get last element from Decoded 18198.75 ±4.08% 47.17% slower
codec/view_vs_collection.ts[5] Get last element from View 13112.8 ±5.23% 61.94% slower
codec/view_vs_object.ts[0] Get the first field from Decoded 227271.77 ±10.02% 6.4% slower
codec/view_vs_object.ts[1] Get the first field from View 49133.5 ±6.01% 79.76% slower
codec/view_vs_object.ts[2] Get the first field as view from View 46465.52 ±4.98% 80.86% slower
codec/view_vs_object.ts[3] Get two fields from Decoded 166768.37 ±8.69% 31.32% slower
codec/view_vs_object.ts[4] Get two fields from View 40972.39 ±1.59% 83.13% slower
codec/view_vs_object.ts[5] Get two fields from materialized from View 76809.21 ±2.41% 68.37% slower
codec/view_vs_object.ts[6] Get two fields as views from View 39645.43 ±0.99% 83.67% slower
codec/view_vs_object.ts[7] Get only third field from Decoded 242809.99 ±1.04% fastest ✅
codec/view_vs_object.ts[8] Get only third field from View 48661.64 ±1.67% 79.96% slower
codec/view_vs_object.ts[9] Get only third field as view from View 24561.25 ±97.41% 89.88% slower
collections/map_vs_sorted.ts[0] Map 151368.9 ±1.59% fastest ✅
collections/map_vs_sorted.ts[1] Map-array 43559.74 ±1.17% 71.22% slower
collections/map_vs_sorted.ts[2] Array 27487.81 ±93.41% 81.84% slower
collections/map_vs_sorted.ts[3] SortedArray 52655.79 ±7.8% 65.21% slower
collections/hash-dict-vs-blob-dict_delete.ts[0] StringHashDictionary 2316.55 ±0.79% 3.37% slower
collections/hash-dict-vs-blob-dict_delete.ts[1] BlobDictionary(1) 2257.43 ±2.76% 5.83% slower
collections/hash-dict-vs-blob-dict_delete.ts[2] BlobDictionary(2) 2256.08 ±1.05% 5.89% slower
collections/hash-dict-vs-blob-dict_delete.ts[3] BlobDictionary(3) 2261.7 ±1.86% 5.65% slower
collections/hash-dict-vs-blob-dict_delete.ts[4] BlobDictionary(4) 2397.22 ±1.52% fastest ✅
collections/hash-dict-vs-blob-dict_delete.ts[5] BlobDictionary(5) 2227.57 ±2.36% 7.08% slower
collections/hash-dict-vs-blob-dict_get.ts[0] StringHashDictionary 2844.04 ±0.63% fastest ✅
collections/hash-dict-vs-blob-dict_get.ts[1] BlobDictionary(1) 2696.89 ±1.56% 5.17% slower
collections/hash-dict-vs-blob-dict_get.ts[2] BlobDictionary(2) 2730.9 ±1.52% 3.98% slower
collections/hash-dict-vs-blob-dict_get.ts[3] BlobDictionary(3) 2804.96 ±0.6% 1.37% slower
collections/hash-dict-vs-blob-dict_get.ts[4] BlobDictionary(4) 2577.41 ±1.71% 9.38% slower
collections/hash-dict-vs-blob-dict_get.ts[5] BlobDictionary(5) 2453.94 ±1.05% 13.72% slower
collections/hash-dict-vs-blob-dict_set.ts[0] StringHashDictionary 1835.21 ±1.89% 13.26% slower
collections/hash-dict-vs-blob-dict_set.ts[1] BlobDictionary(1) 2039.71 ±1.11% 3.59% slower
collections/hash-dict-vs-blob-dict_set.ts[2] BlobDictionary(2) 2115.71 ±0.4% fastest ✅
collections/hash-dict-vs-blob-dict_set.ts[3] BlobDictionary(3) 1943.11 ±1.41% 8.16% slower
collections/hash-dict-vs-blob-dict_set.ts[4] BlobDictionary(4) 2055.25 ±0.62% 2.86% slower
collections/hash-dict-vs-blob-dict_set.ts[5] BlobDictionary(5) 1835.95 ±3.19% 13.22% slower
hash/blake2b.ts[0] our hasher 1.06 ±5.59% fastest ✅
hash/blake2b.ts[1] blake2b js 0.03 ±1.68% 97.17% slower
crypto/ed25519.ts[0] native crypto 4.36 ±4.74% fastest ✅
crypto/ed25519.ts[1] wasm lib 2.77 ±5.62% 36.47% slower
crypto/ed25519.ts[2] wasm lib batch 2.76 ±7.22% 36.7% slower

Benchmarks summary: 82/83 OK ❌

@tomusdrw

tomusdrw commented Jun 7, 2026

Copy link
Copy Markdown
Member Author

@fluffylabs-bot benchmark

@fluffylabs-bot

fluffylabs-bot Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Benchmark workflow triggered successfully! 🎉
Requested by: @tomusdrw
PR number: #999
Target repository: FluffyLabs/typeberry-testing

🔗 Check the Actions tab for workflow progress.

@fluffylabs-bot

fluffylabs-bot Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Picofuzz Benchmark Results

fallback

Metric @typeberry/jam@0.8.4 Current Difference
min 3.67ms 3.76ms ≈ +0.08ms (+2.24%)
mean 6.77ms 4.90ms 🟢 -1.88ms (-27.69%)
p90 10.17ms 5.61ms 🟢 -4.56ms (-44.81%)
p99 11.68ms 10.08ms 🟢 -1.61ms (-13.74%)

safrole

Metric @typeberry/jam@0.8.4 Current Difference
min 3.83ms 3.89ms ≈ +0.06ms (+1.55%)
mean 11.66ms 11.38ms ≈ -0.28ms (-2.39%)
p90 20.19ms 19.99ms ≈ -0.20ms (-1.00%)
p99 26.81ms 24.34ms ≈ -2.47ms (-9.20%)

storage

Metric @typeberry/jam@0.8.4 Current Difference
min 3.95ms 4.27ms ≈ +0.32ms (+8.15%)
mean 26.79ms 26.23ms ≈ -0.56ms (-2.08%)
p90 53.68ms 54.47ms ≈ +0.79ms (+1.46%)
p99 72.44ms 74.77ms ≈ +2.33ms (+3.22%)

storage_light

Metric @typeberry/jam@0.8.4 Current Difference
min 5.39ms 5.95ms 🔴 +0.56ms (+10.38%)
mean 18.58ms 17.29ms ≈ -1.29ms (-6.97%)
p90 29.86ms 28.12ms ≈ -1.73ms (-5.81%)
p99 40.25ms 36.71ms ≈ -3.54ms (-8.79%)

🤖 Automated benchmark

@tomusdrw

tomusdrw commented Jun 8, 2026

Copy link
Copy Markdown
Member Author

@fluffylabs-bot benchmark

@fluffylabs-bot

fluffylabs-bot Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Benchmark workflow triggered successfully! 🎉
Requested by: @tomusdrw
PR number: #999
Target repository: FluffyLabs/typeberry-testing

🔗 Check the Actions tab for workflow progress.

@tomusdrw tomusdrw merged commit 2e4ce67 into main Jun 8, 2026
16 of 17 checks passed
@tomusdrw tomusdrw deleted the td-bump-native branch June 8, 2026 09:47
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.

1 participant