Fix BLS host functions panicking on non-BLS public keys - #8652
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughBLS host functions now reject non-BLS and invalid public keys with controlled errors. Tests cover successful BLS inputs, non-BLS inputs, UTF-8 and CBOR error handling, and signature behavior. ChangesBLS host input validation
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@fvm/crypto/crypto_test.go`:
- Around line 563-569: Update the test’s pk.SignAlgo value to
runtime.SignatureAlgorithmBLS_BLS12_381 so VerifyPOP and AggregatePublicKeys
reach crypto.DecodePublicKey with the invalid PublicKey bytes and exercise the
intended decode-error path.
In `@fvm/crypto/crypto.go`:
- Line 263: In fvm/crypto/crypto.go, guard the public-key parameter before the
SignAlgo access at lines 263-263 and return a NewValueErrorf for nil pk; also
guard each key before key.SignAlgo at lines 313-313 and return an indexed
NewValueErrorf identifying the nil entry. Ensure both cases are treated as input
validation errors rather than panics or unexpected crypto failures.
🪄 Autofix
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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 0a57a153-7505-4f73-9812-83917f8a13c9
📒 Files selected for processing (3)
fvm/crypto/crypto.gofvm/crypto/crypto_test.gofvm/fvm_signature_test.go
FVM review — 4 findings, 1 of them importantThe fix itself is the right shape: a non-BLS Important1. This changes execution results and needs a coordinated height upgrade (HCU); the PR description doesn't say so. Two distinct result changes:
Failure scenario: two ENs on either side of this change execute the same block containing a transaction that passes an ECDSA Nits
Verified and found correct
Produced in collaboration with Claude. |
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
fbb1351 to
e622c49
Compare
FVM review4 findings, 1 important — no production bug in the diff itself; the important one is that the e2e assertion meant to pin the HCU-relevant behavior doesn't actually pin anything. The core change is sound: both host functions now gate on Important
Concretely: if a future Cadence bump stopped mapping the host error to The reported code that downstream systems index is assert.Equal(t, fvmErrors.ErrCodeCadenceRunTimeError, output.Err.Code())Nits
Pre-existing
Verified and found correct
Note: |
Closes: #8649
VerifyPOPandAggregatePublicKeyspanicked on valid non-BLS public keys (e.g. ECDSA), reachable from Cadence because neither stdlib entry point gates on the signature algorithm. ForBLS.aggregatePublicKeysthis violated the documented nil return; forPublicKey.verifyPoPthe abort is documented, but it surfaced as a panic asserting a false invariant.Changes
SignAlgoand return aNewValueErrorffor non-BLS keys, following theVerifySignatureFromRuntimepatternNewValueErrorf, panic only on unexpected crypto-module errorsFor
aggregatePublicKeysthe Cadence stdlib maps any host error to nil, so this restores the documented behavior with no Cadence change. Gating in the Cadence stdlib remains as optional defense in depth.This changes execution results and must ship via a Height Coordinated Upgrade:
BLS.aggregatePublicKeyswith non-BLS keys previously aborted the entire transaction (host panic recovered by Cadence); it now returns the documentedniland execution continues. Transactions handling the optional (e.g.?? fallback) can now commit where they previously failed.PublicKey.verifyPoPwith a non-BLS key still aborts, but the reportedErrorCodechanges from 1101 (CadenceRunTimeError) to 1051 (ValueError), which downstream systems index. E2e tests pin both behaviors.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
Bug Fixes
Tests