Skip to content

Conversation

patrick-ogrady
Copy link
Contributor

@patrick-ogrady patrick-ogrady commented Jul 31, 2025

Resolves: #1338

Credit to @BrendanChou for the insightful approach.

Future work: #1339

@patrick-ogrady patrick-ogrady changed the title [utils] Introduce VarArray [utils] Introduce Span Jul 31, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new Span trait to the utils sequence module to handle variable-size byte sequences, while refactoring the existing Array trait to inherit from Span. The change enables better type safety and API design for handling both fixed-size and variable-size data types.

  • Introduces the Span trait for variable-size byte sequences with EncodeSize constraint
  • Refactors Array trait to inherit from Span while adding EncodeFixed constraint
  • Updates all existing array types to implement both Span and Array traits

Reviewed Changes

Copilot reviewed 44 out of 44 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
utils/src/sequence/mod.rs Introduces Span trait and refactors Array to inherit from it
utils/src/sequence/*.rs Adds Span implementations to U32, U64, prefixed_u64::U64, and FixedBytes
utils/src/lib.rs Updates module structure from array to sequence and exports Span
Multiple storage files Updates import paths from array:: to sequence::
Multiple cryptography files Adds Span implementations to cryptographic types and updates imports
resolver/src/*.rs Changes type constraints from Array to Span for keys in Producer/Consumer traits

@patrick-ogrady patrick-ogrady marked this pull request as ready for review July 31, 2025 21:09
BrendanChou
BrendanChou previously approved these changes Jul 31, 2025
@patrick-ogrady patrick-ogrady changed the title [utils] Introduce Span [utils] Introduce Span (and rename array to sequence) Jul 31, 2025
@patrick-ogrady patrick-ogrady merged commit 6b2c76d into main Jul 31, 2025
34 checks passed
@patrick-ogrady patrick-ogrady deleted the var-array branch July 31, 2025 22:10
@codecov
Copy link

codecov bot commented Jul 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.22%. Comparing base (525cac4) to head (bab7386).
⚠️ Report is 1 commits behind head on main.

@@            Coverage Diff             @@
##             main    #1337      +/-   ##
==========================================
- Coverage   91.22%   91.22%   -0.01%     
==========================================
  Files         262      262              
  Lines       65073    65073              
==========================================
- Hits        59362    59361       -1     
- Misses       5711     5712       +1     
Files with missing lines Coverage Δ
consensus/src/marshal/actor.rs 77.28% <ø> (ø)
consensus/src/marshal/finalizer.rs 88.63% <ø> (ø)
cryptography/src/blake3/mod.rs 75.00% <ø> (ø)
cryptography/src/bls12381/scheme.rs 89.35% <ø> (ø)
cryptography/src/bls12381/tle.rs 94.65% <ø> (ø)
cryptography/src/ed25519/scheme.rs 90.51% <ø> (ø)
cryptography/src/secp256r1/scheme.rs 92.47% <ø> (ø)
cryptography/src/sha256/mod.rs 97.14% <ø> (ø)
resolver/src/p2p/mocks/consumer.rs 90.90% <ø> (ø)
resolver/src/p2p/mocks/key.rs 40.00% <ø> (ø)
... and 19 more

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 525cac4...bab7386. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Resolver/Consumer would have to use type Key: VarArray (Array but variable length for multiple key types) instead of Array

2 participants