Skip to content

[Review] Merge bitcoin/bitcoin#36988: guix: replace search-our-patches with local-file - #8

Merged
jonatack merged 1 commit into
bitcoin-v:masterfrom
BTC4Peace:audit/pr-afa492e23386
Dec 1, 2026
Merged

jonatack merged 1 commit into
bitcoin-v:masterfrom
BTC4Peace:audit/pr-afa492e23386

Conversation

@auditbob

@auditbob auditbob Bot commented Dec 1, 2026

Copy link
Copy Markdown

Upstream commit: bitcoin/bitcoin@afa492e

13eee77d0d71bb3a06f365cbfb714b7f46491b08 guix: replace search-our-patches with local-file (Sjors Provoost)

Pull request description:

Drop our search-our-patches helper in favor of local-file.

Noticed while working on #36838.

Guix build:

x86_64
...

ACKs for top commit:
fanquake:
ACK 13eee77d0d71bb3a06f365cbfb714b7f46491b08
hebasto:
ACK 13eee77d0d71bb3a06f365cbfb714b7f46491b08.

Tree-SHA512: 45bfdf98be47761b41acf864c8f496a455949ca5ac1b1a42dde8b44b95763406c54ef495194a40d650eef47963d2331e4ce58db2688c90e34d6776ea0e9b0154

13eee77d0d71bb3a06f365cbfb714b7f46491b08 guix: replace search-our-patches with local-file (Sjors Provoost)

Pull request description:

  Drop our `search-our-patches` helper in favor of `local-file`.

  Noticed while working on bitcoin#36838.

  Guix build:

  ```
  x86_64
  ...
  ```

ACKs for top commit:
  fanquake:
    ACK 13eee77d0d71bb3a06f365cbfb714b7f46491b08
  hebasto:
    ACK 13eee77d0d71bb3a06f365cbfb714b7f46491b08.

Tree-SHA512: 45bfdf98be47761b41acf864c8f496a455949ca5ac1b1a42dde8b44b95763406c54ef495194a40d650eef47963d2331e4ce58db2688c90e34d6776ea0e9b0154

Cherry-picked-from: bitcoin/bitcoin@afa492e
@auditbob

auditbob Bot commented Dec 1, 2026

Copy link
Copy Markdown
Author

Post-Merge Audit — afa492e233868bcf4799bb62943baa28017938f6

1. Summary

Build-tooling-only cleanup in the Guix reproducible-build machinery, merging PR #36988:

  • contrib/guix/toolchains.scm: deletes the local search-our-patches macro (which parameterized %patch-path to (dirname (current-filename)) + /patches and called search-patch) together with its (gnu packages) import, and narrows (guix gexp) to #:select (gexp local-file) (contrib/guix/toolchains.scm:9). The four patch-application sites now pass store objects directly: base-gcc (:95-98), binutils-mingw-patches (:116-118), winpthreads-patches (:120-122), and the glibc-2.31 origin patches field (:259-260) — six patch files total, all relative paths of the form patches/<name>.patch.
  • contrib/guix/guix-build: drops ln -sfn "${PWD}/contrib/guix/patches" "${package_path}/patches"; only the module symlink remains (contrib/guix/guix-build:330-332), still fed to guix shell via --load-path="$package_path" (:437, documented at :401-404).
  • The module's #:export list is unchanged across the diff, so no consumer of (toolchains) (e.g. contrib/guix/manifest_build.scm:7, contrib/guix/linux_static.scm:1, contrib/guix/manifest_gui.scm:11) can break from missing exports.

Motivation: use Guix's supported local-file mechanism instead of the legacy patch-path search, so patches become first-class store inputs of the patched-source derivations rather than path strings discovered through a mutable search path.

2. Consensus & Validation

None. No src/ code, consensus constants, script/transaction/block validation, mempool, chainstate, UTXO or reorg logic is touched; the diff is confined to contrib/guix/.

The only "validation-adjacent" effect is reproducibility/provenance of the release toolchain: patches now enter the source derivations as local-file objects instead of strings resolved via %patch-path, so the affected derivations (base-gcc, cross-binutils, glibc-2.31, winpthreads) get new hashes and existing substitutes cannot be reused until rebuilt/attested. Patch application order is preserved exactly (gcc-remap-guix-store.patch → gcc-ssa-generation.patch; glibc-guix-prefix.patch → glibc-riscv-jumptarget.patch), which is what matters for output reproducibility.

3. Security, P2P & DoS

No node-level security, P2P, serialization, integer, or UB surface. No RPC.

Build-pipeline considerations, all verified as unchanged or benign:

  • Patch contents are unchanged; all six referenced basenames exist in contrib/guix/patches/ (binutils-unaligned-default.patch, gcc-remap-guix-store.patch, gcc-ssa-generation.patch, glibc-guix-prefix.patch, glibc-riscv-jumptarget.patch, winpthreads-remap-guix-store.patch), so no dangling reference or silently-dropped patch was introduced.
  • Hermeticity is at least as strong as before: local-file makes the patch files hashed derivation inputs, whereas the removed path only fed a search-path string into search-patch. I could not independently confirm the stronger claim that the old string form produced machine-dependent derivation text (that lives in Guix's patch-and-repack, not in this repo), so I am not asserting a hermeticity defect in the pre-merge state — only that the new form is unambiguously store-based.
  • [Nit] The relative local-file names now depend on Guile/Guix resolving the module's source file to the real contrib/guix/toolchains.scm rather than the staged symlink ${VERSION_BASE}/guix-package-path/toolchains.scm (contrib/guix/guix-build:332). The fact that the pre-merge code needed an explicit patches symlink next to the staged module suggests (dirname (current-filename)) had previously been observed to resolve to the staging directory. The PR's own x86_64 build for the merged tree plus two operator ACKs indicate the pinned Guix (--commit=60f6956aeffa7f30285745bd0ea615e9acfc74f8, contrib/guix/libexec/prelude.bash:74) canonicalizes correctly for local-file, but this invariant is now implicit and untested in-tree. Cheap hardening: a one-line comment at contrib/guix/guix-build:332 stating that local-file paths are relative to the canonical contrib/guix/toolchains.scm, hence staging patches is no longer required — or replace the staging directory with --load-path="${PWD}/contrib/guix", which removes the indirection entirely.

4. Concurrency & Locking

None. Shell/Guile build scripts and package definitions only; no mutexes, no cs_main/mempool/wallet interaction, no shared mutable state.

5. Code Quality & Test Coverage

  • No stale references remain: search-our-patches and search-patch produce zero matches under contrib/, and %patch-path is no longer referenced anywhere in contrib/guix. guix-package-path appears only at its definition/use site in contrib/guix/guix-build:330, and contrib/guix/README.md contains no mention of patches or the staging directory, so no documentation was invalidated.
  • The selective import at contrib/guix/toolchains.scm:9 still provides gexp, which is required by the surviving reader forms #~, #$, #$@ at contrib/guix/toolchains.scm:35, :131, :188, :208, :225, :230. Keeping gexp (not just local-file) is correct and necessary; nothing else from (guix gexp) is used.
  • The rewritten glibc-2.31 origin (contrib/guix/toolchains.scm:250-260) is structurally consistent with the rest of the file: (patches (list …)) is properly closed inside the origin, and the surrounding arguments/substitute-keyword-arguments bodies are unaffected. binutils-mingw-patches/winpthreads-patches/base-gcc keep the same argument shape, so package-with-extra-patches receives a list of file-like objects in the position where it previously received a list of strings.
  • [Nit] local-file names store items by basename, and all six basenames are unique today. A future patch added under a different directory with a duplicated basename would collide by name (not content) in the store; nothing to fix for this merge.
  • [Nit] No in-tree coverage evaluates these .scm files; a path-resolution or import regression here is caught only by a human running ./contrib/guix/guix-build. A guix-attest comparison against a pre-merge attestation set would settle both the path-resolution question and the (unverified) claim that toolchain outputs are bit-identical despite the changed derivations.

6. Cross-Audit Reconciliation & Post-Merge Verdict

Confirmed by both auditors and re-verified here: the six patch basenames exist in contrib/guix/patches/; search-our-patches and search-patch are gone with no remaining references; the remaining #~/#$/#$@ forms justify keeping gexp in the #:select at contrib/guix/toolchains.scm:9; no src/ impact; the pinned Guix commit is 60f6956aeffa7f30285745bd0ea615e9acfc74f8 (contrib/guix/libexec/prelude.bash:74) and VERSION_BASE includes the version/commit (contrib/guix/libexec/prelude.bash:116-120, used at contrib/guix/guix-build:330), so staging directories are per-version rather than long-lived.

Only-one-auditor claims, adjudicated:

  • Audit A's staging-symlink/local-file path-resolution concern: the mechanism is real (relative local-file resolution via the module source file, module loaded through the symlink at contrib/guix/guix-build:332), but I found no evidence of an actual failure, and the PR's successful build plus two ACKs argue against one. Downgraded from [Risk] to [Nit] (documentation/hardening), not a defect.
  • Audit A's hermeticity-upgrade claim: partially verified (patches are now hashed derivation inputs by construction); the sub-claim that the old string form produced host-dependent derivation text cannot be verified from this repo, so it is dropped as an overstated benefit.
  • Audit B's "toolchain derivations are identical / outputs bit-identical" claim: not verifiable here (requires Guix internals and an attestation diff). Treat as unverified; the practical consequence is a one-time toolchain rebuild/resubstitution, which is normal for this kind of change.
  • Audit B's statements about which Guix module exports package-with-extra-patches are unverifiable from this repository and are dropped; the safe, verified statement is that #:export for (toolchains) is unchanged, so manifest consumers are unaffected.

Overall risk: low. Contained Guix build-pipeline cleanup with no runtime, consensus, or node-level effect. Key lines to double-check: contrib/guix/toolchains.scm:9, :97-98, :118, :122, :259-260 (relative local-file resolution and import selection), contrib/guix/guix-build:330-332 (removed patches symlink, retained module symlink), and contrib/guix/guix-build:437 (--load-path="$package_path").

Triage: routine


📊 Token Usage & Review Stats
Stage Model Input Tokens Cache Hit Output Reasoning Total Rounds Latency
Audit A deepseek-flash 258,674 244,224 (94%) 35,818 32,032 294,492 9 235.2s
Audit B gemini-4-neon-high 815,210 720,827 (88%) 11,844 8,870 827,054 15 215.3s
Judge deepseek-flash 156,299 119,808 (77%) 17,314 13,162 173,613 9 119.8s
Total — 1,230,183 1,084,859 (88%) 64,976 54,064 1,295,159 33 570.3s

@auditbob auditbob Bot added audited Automated review completed Build system labels Dec 1, 2026

@jonatack jonatack left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

utACK a856636

@jonatack
jonatack merged commit c17339a into bitcoin-v:master Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

audited Automated review completed Build system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants