Skip to content

Pre-publish hardening and minor version bumps#11

Merged
JasoonS merged 2 commits into
mainfrom
fixes/pre-publish-coderabbit
May 17, 2026
Merged

Pre-publish hardening and minor version bumps#11
JasoonS merged 2 commits into
mainfrom
fixes/pre-publish-coderabbit

Conversation

@JasoonS

@JasoonS JasoonS commented May 17, 2026

Copy link
Copy Markdown
Contributor

Cleans up the CodeRabbit findings on PR #9 that were worth fixing before the next publish, plus minor version bumps so the four crates can be released.

Version bumps

Crate Old New
hyperfuel-net-types 4.0.3 4.1.0
hyperfuel-format 4.0.1 4.1.0
hyperfuel-schema 4.0.0 4.1.0
hyperfuel-client 3.0.1 3.1.0

Security / correctness

  • parse_response.rs capnp limits restored. Previously nesting_limit(i32::MAX) + traversal_limit_in_words(None) removed the DoS safeguards capnp provides for untrusted network input. Now bounded at 64 nesting / 64M words (~512 MiB), enough for large paginated arrow responses but no longer effectively unbounded.
  • Quantity::From<u64> canonical. Previously stored 8 bytes with leading zeros, breaking the no-leading-zero invariant enforced by the Vec<u8> / &[u8] constructors. Quantity::from(5u64) != Quantity::from(vec![5]) was the bug; new test_from_u64_canonical covers the fix.
  • get_arrow_impl uses spawn_blocking. tokio::task::block_in_place panics on current-thread runtimes (#[tokio::test], flavor = "current_thread"). Library code shouldn't make that assumption.
  • get_height_impl propagates missing height. Previously unwrap_or(0) turned malformed / partial responses into a successful "genesis height" result, hiding bad data from retry and health-check loops.

Additive schema API (minor-safe)

  • hyperfuel_schema::try_project_schema added, returning Result<Schema> with an error listing any requested columns not present in the source schema. The existing project_schema is unchanged for backward compatibility; new code should prefer the try_ variant to catch typos in field_selection.

Cleanup

  • Drop tokio's test-util feature from hyperfuel-client's main deps (was unused; pulled timer-mocking machinery into production builds).
  • Fix swapped doc comments on ColumnMapping.{receipt,input,output} (had been labeled "log data" / "trace data" / "decoded log data" from the EVM-client copy-paste).
  • Fix "colum" typo in a column_mapping error message.
  • Delete hyperfuel-client/tests/api_test.rs (523 lines of commented-out tests still referencing hypersync_client / hypersync_format from the v2 import). Restoring API test coverage can be tracked in a follow-up issue.

Examples restored

  • examples/simple-logs added back as a workspace member, ported from v1 to the current ClientConfig + preset_query_get_logs API. Used as a live smoke test in this PR: cargo run -p simple-logs returned archive_height=Some(53810724) against https://fuel.hypersync.xyz, exercising the full HTTP → capnp → spawn_blocking → arrow path against the production server.

Deliberately skipped (defer or won't-fix)

  • FromArrow trait silently panic-instead-of-Result (from_arrow.rs:14/159) and parquet_out.rs:331 unwrap on array_to_columns: real tech debt acknowledged in source comments. Restoring proper Result-typing touches multiple files and is a larger refactor; defer to a tracking issue.
  • map_l1_fee_scalar triple unwrap: same family as above (needs caller updates).
  • Utf8View not handled in concat_chunks workaround: worth verifying with a test against the real schema before fixing; not exercised by any current test.
  • Cosmetic / theoretical: rayon_async::spawn T: Sync bound, TransactionType Add/Sub derives, util.rs schema metadata discard, stream.rs double-unwrap on JoinError, README.md heading level, lib.rs:74 reqwest::Client::builder().build().unwrap(), lib.rs:294 extra retry sleep before final return.

Test plan

  • cargo build --workspace --all-targets
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace (34 tests pass, including new test_from_u64_canonical)
  • cargo run -p simple-logs against the live fuel.hypersync.xyz server
  • CI green

Summary by CodeRabbit

  • New Features

    • Added a new simple-logs example.
    • Added explicit field-validation for schema projections.
  • Bug Fixes

    • Improved error handling for missing response data.
    • Fixed documentation and error-message text for clarity.
  • Improvements

    • Safer parsing with bounded limits and improved parsing task handling.
    • Canonicalized quantity serialization logic.
  • Chores

    • Package version bumps across several crates.

Review Change Stack

Addresses CodeRabbit findings on the v2-import PR (#9) that were worth
fixing before the next publish; deliberately skips theoretical/cosmetic
ones and defers the larger FromArrow trait Result-typing refactor.

Crate version bumps (all minor):
- hyperfuel-net-types 4.0.3  -> 4.1.0
- hyperfuel-format    4.0.1  -> 4.1.0
- hyperfuel-schema    4.0.0  -> 4.1.0
- hyperfuel-client    3.0.1  -> 3.1.0

Security / correctness fixes:
- hyperfuel-client/src/parse_response.rs: restore bounded capnp limits
  (nesting_limit(64), traversal_limit_in_words(Some(64M)) ~= 512 MiB).
  Previous nesting_limit(i32::MAX) + traversal_limit_in_words(None)
  removed the DoS safeguards capnp provides specifically for untrusted
  network input.
- hyperfuel-format/src/types/quantity.rs: From<u64> now strips leading
  zeros to preserve the no-leading-zero invariant enforced by the
  Vec<u8>/&[u8] constructors. Previously Quantity::from(5u64) stored
  [0,0,0,0,0,0,0,5] which broke Eq/Hash/round-trip equality against
  the canonical form. New test_from_u64_canonical covers this.
- hyperfuel-client/src/lib.rs get_arrow_impl: swap block_in_place for
  spawn_blocking. block_in_place panics on tokio current-thread
  runtimes (#[tokio::test], flavor = "current_thread"), making the
  library hostile to common configurations.
- hyperfuel-client/src/lib.rs get_height_impl: propagate missing
  height instead of unwrap_or(0). Previously a malformed response
  collapsed into a successful "genesis height" result, hiding bad
  data from retry / health-check loops.

Schema API improvement (additive, minor-safe):
- hyperfuel-schema/src/util.rs: add try_project_schema returning
  Result<Schema> that errors when requested columns are absent.
  The existing project_schema is unchanged (still silently drops
  unknown fields) for backward compatibility. New code should
  prefer try_project_schema to catch typos in field selections.

Cleanup:
- hyperfuel-client/Cargo.toml: remove tokio's test-util feature from
  main deps (was unused; bringing testing-only timer-mocking machinery
  into production builds).
- hyperfuel-client/src/column_mapping.rs: fix doc comments on receipt
  / input / output (were labeled "log data" / "trace data" /
  "decoded log data" from the EVM-client copy-paste). Fix "colum"
  typo in error message.
- hyperfuel-client/tests/api_test.rs: deleted. 523 lines of
  commented-out tests that referenced hypersync_client / hypersync_format
  (wrong crate names from the v2 import). Track restoring API test
  coverage in a follow-up issue if wanted.

Examples:
- Restore examples/simple-logs (workspace member), ported to the
  current ClientConfig API. Used as a live smoke test against
  https://fuel.hypersync.xyz: archive_height returned correctly,
  full HTTP -> capnp -> spawn_blocking -> arrow path exercised.

Verified: cargo build --workspace --all-targets, cargo clippy
--workspace --all-targets -- -D warnings, cargo test --workspace
(34 tests pass), cargo run -p simple-logs against the live server.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented May 17, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5c78dc20-4acb-4248-82b5-e2a583bc7319

📥 Commits

Reviewing files that changed from the base of the PR and between 1957316 and 820e8c3.

📒 Files selected for processing (1)
  • hyperfuel-format/src/types/quantity.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • hyperfuel-format/src/types/quantity.rs

📝 Walkthrough

Walkthrough

This PR canonicalizes Quantity encoding with tests, adds try_project_schema for validated schema projection, tightens Cap'n Proto parsing limits and improves client async/error handling, corrects small client docs/typos, adds a simple-logs example, and updates several crate versions.

Changes

Quantity canonicalization and library updates

Layer / File(s) Summary
Simple logs example
Cargo.toml, examples/simple-logs/Cargo.toml, examples/simple-logs/src/main.rs
New example crate showing hyperfuel_client initialization, contract ID setup from hex literals, a logs query over blocks 0..=50_000, and printing response metadata and log count.
Client error handling and async safety
hyperfuel-client/src/lib.rs, hyperfuel-client/src/parse_response.rs, hyperfuel-client/src/column_mapping.rs, hyperfuel-client/Cargo.toml
get_height_impl now errors if height is missing; get_arrow_impl parses Arrow IPC bytes via spawn_blocking with added context and returns byte length; Cap'n Proto reader limits set to nesting_limit(64) and traversal_limit_in_words(Some(64 * 1024 * 1024)); column mapping docs corrected and an error-message typo fixed; client crate version bumped.
Schema projection with field validation
hyperfuel-schema/src/util.rs, hyperfuel-schema/src/lib.rs, hyperfuel-schema/Cargo.toml
project_schema now filters/clones fields directly; new try_project_schema returns an error listing missing requested fields or delegates to project_schema; public re-exports updated; schema crate version bumped.
Quantity canonical encoding and tests
hyperfuel-format/src/types/quantity.rs, hyperfuel-format/Cargo.toml
From<u64> for Quantity canonicalizes encoding (zero → single zero byte; non-zero → big-endian trimmed of leading zeros); tests added for edge cases; format crate version bumped.
Net-types manifest
hyperfuel-net-types/Cargo.toml
Package version for hyperfuel-net-types updated to 4.1.0.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Pre-publish hardening and minor version bumps' accurately summarizes the main focus: version bumps for four crates and security/correctness hardening changes before publication.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 docstrings
  • Create stacked PR
  • Commit on current branch

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 `@hyperfuel-format/src/types/quantity.rs`:
- Around line 217-223: In test_from_u64_canonical, rustfmt requires the long
assert_eq! to be split across multiple lines; update the final
assert_eq!(Quantity::from(u64::MAX), Quantity::from(hex!("ffffffffffffffff")));
in the test to a multi-line assert_eq! with the first argument on its own line,
the second argument on the next line, and the closing parenthesis on its own
line so the test function (test_from_u64_canonical) passes cargo fmt --check.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a7947a7a-f0dc-48d0-b2c4-ff73e44c085a

📥 Commits

Reviewing files that changed from the base of the PR and between bbca973 and 1957316.

📒 Files selected for processing (14)
  • Cargo.toml
  • examples/simple-logs/Cargo.toml
  • examples/simple-logs/src/main.rs
  • hyperfuel-client/Cargo.toml
  • hyperfuel-client/src/column_mapping.rs
  • hyperfuel-client/src/lib.rs
  • hyperfuel-client/src/parse_response.rs
  • hyperfuel-client/tests/api_test.rs
  • hyperfuel-format/Cargo.toml
  • hyperfuel-format/src/types/quantity.rs
  • hyperfuel-net-types/Cargo.toml
  • hyperfuel-schema/Cargo.toml
  • hyperfuel-schema/src/lib.rs
  • hyperfuel-schema/src/util.rs
💤 Files with no reviewable changes (1)
  • hyperfuel-client/tests/api_test.rs

Comment thread hyperfuel-format/src/types/quantity.rs
Splits the long assert_eq! in test_from_u64_canonical across multiple
lines to satisfy cargo fmt --check. No behavior change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@JasoonS JasoonS merged commit a562959 into main May 17, 2026
4 checks passed
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