Skip to content

feat(runtime): implement SIMD-0512 enable_sha512_syscall#1575

Merged
yewman merged 1 commit into
mainfrom
harnew/enable_sha512_syscall
Jun 15, 2026
Merged

feat(runtime): implement SIMD-0512 enable_sha512_syscall#1575
yewman merged 1 commit into
mainfrom
harnew/enable_sha512_syscall

Conversation

@yewman

@yewman yewman commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Intent

  • Implement SIMD-0512
  • Adds sol_sha512 as a new syscall to BPF programs, gated on the enable_sha512_syscall feature.
  • Generalises the existing hash-syscall scaffolding so it can emit a 64-byte digest in addition to the 32-byte digests already supported (sha256, keccak256, blake3).

Implementation

  • hash.zig
    • hashSyscall(comptime H: type) no longer hard-codes [32]u8 for the result region; it now uses [H.Hasher.digest_length]u8 so the same template produces both 32- and 64-byte hashers.
    • Adds the sha512 syscall, wrapping std.crypto.hash.sha2.Sha512.
  • lib.zig
    • Registers sol_sha512 in the Syscall enum, wires it into the dispatch table, and gates it on .enable_sha512_syscall.
  • features.zon
    • Promotes the existing enable_sha512_syscall entry from .unsupported (with a "Not scheduled for activation" note) to .supported and adds the SIMD-0512 description.

The CU cost reuses the existing sha256_base_cost / sha256_byte_cost budget knobs, matching agave's sha512 syscall, which doesn't introduce dedicated cost fields.

Gating

sol_sha512 is only visible to programs once enable_sha512_syscall (s512oDwgx8hjMnaQjXfqqrZroVj4HvC6TkN3iSSWXCh) is active for the current slot, via the standard syscall-feature-gate mechanism. With the feature inactive the syscall is unregistered, matching agave's behaviour.

References

  • agave: programs/bpf_loader/src/syscalls/mod.rs (SyscallSha512)
  • firedancer: src/flamenco/runtime/program/fd_bpf_loader_program.c (sol_sha512)

Tests

  • test sha512 in hash.zig — hashes two scattered VM slices ("Gaggablaghblagh!" and "flurbos"), asserts the 64-byte digest matches std.crypto.hash.sha2.Sha512 computed locally, and exercises the same access-violation matrix (mis-aligned source, out-of-bounds source length, mis-aligned destination, exhausted compute meter) as the existing sha256 test.

Fuzzing: TODO (need to tweak kunorpus to generate sol_sha512 fixtures)

Follow-ups

None.

@github-project-automation github-project-automation Bot moved this to 🏗 In progress in Sig Jun 8, 2026
@codecov

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

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

@yewman yewman force-pushed the harnew/enable_sha512_syscall branch 2 times, most recently from 26f1063 to 4e2bdad Compare June 10, 2026 10:21
@yewman yewman closed this Jun 10, 2026
@yewman yewman force-pushed the harnew/enable_sha512_syscall branch from 4e2bdad to 1fbfd57 Compare June 10, 2026 10:29
@github-project-automation github-project-automation Bot moved this from 🏗 In progress to ✅ Done in Sig Jun 10, 2026
Adds sol_sha512 syscall, matching agave and firedancer:

- Flip enable_sha512_syscall (s512oDwgx8hjMnaQjXfqqrZroVj4HvC6TkN3iSSWXCh)
  in features.zon from .unsupported to .supported.
- Generalize hashSyscall to use H.Hasher.digest_length instead of a
  hard-coded [32]u8 result buffer (behavior-preserving for sha256,
  keccak256, and blake3; enables the 64-byte digest required by sha512).
- Add hash.sha512 export wrapping std.crypto.hash.sha2.Sha512.
- Register sol_sha512 in the Syscall enum, the syscall map, and the
  feature gate table (gated on enable_sha512_syscall).
- Add a unit test mirroring agave's test_syscall_sha512 to cover the
  64-byte digest path end-to-end through the VM memory map.

Cost model reuses sha256_max_slices, sha256_base_cost, sha256_byte_cost
and mem_op_base_cost as specified by SIMD-0512 and as implemented in
both agave (compute_cost.sha256_*) and firedancer (FD_VM_SHA256_*).
@yewman yewman reopened this Jun 10, 2026
@github-project-automation github-project-automation Bot moved this from ✅ Done to 🟢 Ready in Sig Jun 10, 2026
@yewman yewman marked this pull request as ready for review June 10, 2026 10:43
@github-project-automation github-project-automation Bot moved this from 🟢 Ready to 👀 In review in Sig Jun 15, 2026
@yewman yewman added this pull request to the merge queue Jun 15, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 15, 2026
@yewman yewman added this pull request to the merge queue Jun 15, 2026
Merged via the queue into main with commit b48a686 Jun 15, 2026
26 of 27 checks passed
@yewman yewman deleted the harnew/enable_sha512_syscall branch June 15, 2026 09:25
@github-project-automation github-project-automation Bot moved this from 👀 In review to ✅ Done in Sig Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

3 participants