Skip to content

nix: build generated Rust against local runtimes; pin hbls b9aafc7 - #300

Open
Benjmhart wants to merge 4 commits into
sean/experimental-nix-fixes-2from
sean-nix-fix
Open

Benjmhart wants to merge 4 commits into
sean/experimental-nix-fixes-2from
sean-nix-fix

Conversation

@Benjmhart

@Benjmhart Benjmhart commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Fixes the local-development problem on sean/experimental-nix-fixes-2: generated Rust code and the Rust testsuites now build against this repo's own lbr-prelude / plutus-ledger-api instead of crates.io, so edits to runtimes/rust/lbr-prelude are actually picked up.

Root cause

extras/lbf-nix/lbf-rust.nix pins lbr-prelude = "0.1.3" and plutus-ledger-api from crates.io, and the testsuite Cargo.tomls do the same, so local runtime changes never reached generated code. The workarounds on the branch didn't take effect:

  • the vendored plutus-ledger-api had its lbf feature disabled (90 cfg(feature = "lbf") blocks, including the Json impls generated code needs);
  • lbr-prelude was renumbered to 0.1.0, which doesn't satisfy pla's ^0.1.3, so the [patch.crates-io] entries never applied;
  • the generator's fallback path was changed to -v0, which broke lbf-plutus -> lbf-prelude.

Changes

  • settings.rust.localCrates, passed as extraVersions by the 4 in-repo lbfRust callers. The public lib.lbf-nix defaults stay on crates.io.
  • runtimes/rust/plutus-ledger-api/build.nix: fetches the published pla 3.1.0 crate (checksum from staging's Cargo.lock) and rewrites its lbr-prelude dep to the local runtime. This replaces the vendored copies of plutus-ledger-api and is-plutus-data-derive (~17k lines, identical to the 3.1.0 release apart from Cargo.toml).
  • Rust testsuites use path deps; lockfiles regenerated.
  • hbls: pinned to b9aafc7, which compiles hbls's own bundled blst C and assembly. Before that commit, hbls's library defined no blst_* symbols, so loading it (PlutusTx plugin) failed with undefined symbol: blst_scalar_from_lendian; minimal repro. The hbls source block in settings.nix differs from the branch only in rev/hash; nothing in this PR patches hbls or links blst.
  • Removed the malformed, unused hbls flake input (github://..., locked as a path); flake.lock is back to staging's.
  • nixfmt / cabal-fmt fixes so pre-commit passes.

Verification (x86_64-linux)

All 31 checks build, including lbt-plutus-rust-test (131 tests), lbt-prelude-rust-test, clippy, and check-lbt-plutus-plutustx (383 tests, against hbls b9aafc7). Every packages and devShells output evaluates. A monolithic nix flake check wasn't completed locally: evaluation needs more than 11G and the machine's earlyoom killed it, so the checks were run per attribute instead.

Known gaps

  • hbls b9aafc7: G1Point/G2Point == is inverted (src/HBLS.hs lines 56 and 150 test blst_p*_is_equal with (== 0), but it returns 1 when equal), so mempty == mempty is False. hbls also can't be consumed as a cabal source-repository-package because its headers aren't in extra-source-files. Neither affects this PR's checks; both still need to be reported to hbls.

  • Rust maps G1Element/G2Element to the placeholder lbr_prelude::types::Unsupported, which has no Eq/Json impls. Any schema that uses them will fail to compile for Rust.

  • check-lbt-plutus-plutustx needs about 18.6 GB peak for GHC on one test module (PlutusTx plugin); on smaller machines run it with --max-jobs 1.

  • Not cleaned up here (unrelated to the fix): the commented-out block in lbf-haskell.nix, the lbr-plutarch.cabal bounds, and the newline change in lbt-prelude-haskell/cabal.project.

🤖 Generated with Claude Code

Benjmhart and others added 4 commits October 1, 2026 10:03
lbf-rust.nix pins lbr-prelude/plutus-ledger-api to crates.io, so edits to
runtimes/rust/lbr-prelude never reached generated code or the testsuites.
In-repo lbfRust callers now pass settings.rust.localCrates as extraVersions
(public lib.lbf-nix defaults unchanged). plutus-ledger-api 3.1.0 is fetched
from crates.io with its lbr-prelude dep rewritten to the local runtime,
replacing the vendored copies of plutus-ledger-api and is-plutus-data-derive.
Drops the malformed, unused hbls flake input.

Testsuite Cargo.lock files still need regenerating under nix.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
hbls.cabal (ecef8c6) never links blst, so loading it (PlutusTx plugin)
failed with undefined blst_* symbols. Add pkgconfig-depends: libblst,
the same blst cardano-crypto-class already links here.

Regenerate lbt-prelude-rust/lbt-plutus-rust Cargo.lock for the local
path deps, and apply nixfmt/cabal-fmt so pre-commit passes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
hbls vendors blst v0.3.17's C sources but not its assembly, and its
.cabal compiles neither. blst has no portable C path on x86_64/aarch64,
so add v0.3.17's build/ (pinned) next to the vendored C and declare
c-sources: cbits/server.c and asm-sources: cbits/build/assembly.S, as
blst's own build.sh does. The resulting hbls .so defines all blst_*
symbols itself and has no libblst dependency.

Reverts the previous pkgconfig-depends: libblst approach, which defeated
the point of hbls vendoring blst.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
hbls b9aafc7 vendors blst's assembly and declares c-sources itself, so the
library links with no help from us. Revert settings.nix's hbls-src to the
original plain fetch, bumping only rev/hash, and drop the blst v0.3.17 fetch.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Benjmhart Benjmhart changed the title nix: build generated Rust against local runtimes; link hbls to libblst nix: build generated Rust against local runtimes; pin hbls b9aafc7 Oct 8, 2026

This branch has not been deployed

No deployments
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