Skip to content

fix: evaluate satisfier outcomes once per node - #4

Open
mukeshsp wants to merge 1 commit into
masterfrom
mukesh/CSHLD-2226-bound-satisfaction
Open

mukeshsp wants to merge 1 commit into
masterfrom
mukesh/CSHLD-2226-bound-satisfaction

Conversation

@mukeshsp

Copy link
Copy Markdown

What

  • Compute satisfaction and dissatisfaction in post-order with per-call, node-identity outcome storage; reuse child outcomes rather than recursively recomputing subtrees.
  • Enforce existing context consensus/standardness resource checks before normal and malleable satisfaction/template construction.
  • Add deterministic 100-level branching complexity coverage, resource-limit boundaries, descriptor planning and signed PSBT finalization regressions; update API docs and changelog.

Why

Nested, well-typed scripts can otherwise make descriptor planning or PSBT finalization consume exponential CPU: a ~28-level or_b(u:t:v:X, s:pk) chain (sane, non-malleable, within Segwitv0 limits) costs ~5e9 allocating helper calls, and wsh()/tr() forms admit 82–100 levels that never return. Independent resource checks reject invalid untrusted scripts before provider queries.

Test plan

  • cargo test -p miniscript --all-features — 158 unit tests, 5 integration tests, 7 doc tests (2 ignored) passed.
  • cargo check -p miniscript --no-default-features passed.
  • 100-level or_b/or_d/andor/thresh normal and malleable planning regression: one availability query per key occurrence, 0.05–0.07 s combined.
  • Standalone smoke: descriptor planning, signed PSBT finalization and resource rejection completed in 434 ms.

Ticket: CSHLD-2226
https://linear.app/bitgo/issue/CSHLD-2226/rust-miniscript-satisfier-recursion-is-exponential-in-nesting-depth-or

@linear-code

linear-code Bot commented Nov 11, 2026

Copy link
Copy Markdown

CSHLD-2226

@mukeshsp
mukeshsp force-pushed the mukesh/CSHLD-2226-bound-satisfaction branch from 413cd64 to df783f7 Compare November 11, 2026 12:02
@mukeshsp

Copy link
Copy Markdown
Author

CI status after df783f7 (rustfmt fixes):

  • ✅ Format - nightly — was failing on the first push (formatting of the new code); fixed in df783f7.
  • ✅ All Test jobs that have completed (stable/nightly, minimal/recent) pass, including the new tests/satisfaction_regressions.rs suite; Test - 1.63.0 jobs were still compiling at last check.
  • ❌ Docs - stable toolchain — pre-existing, not caused by this PR: broken intra-doc link at src/policy/concrete.rs:349 ([doc/compiler.md] resolves to no item with -D warnings). This file is untouched here; the same job fails on chore: add catalog-info.yaml for Backstage developer portal #2 and [INFOSEC-634] Add security policy #3.
  • ❌ Run Zizmor — pre-existing, not caused by this PR: the action exits with fatal: no audit was performed before auditing; no workflow or policy files are changed here. The same job fails on [INFOSEC-634] Add security policy #3.

Happy to split the concrete.rs doc-link one-liner into its own tiny PR if maintainers prefer a green Docs job here.

Compute satisfaction and dissatisfaction in post-order and reuse child
outcomes, preventing nested branches from consuming exponential CPU.
Check context resource limits before satisfaction and template building
to reject invalid untrusted descriptors and PSBT scripts early.

Cover nested branch complexity, resource boundaries, descriptor plans,
and signed PSBT finalization. Document the stricter resource checks.

Ticket: CSHLD-2226
Signed-off-by: Mukesh Mahadev Prajapati <mukeshmahadev@bitgo.com>
@mukeshsp
mukeshsp force-pushed the mukesh/CSHLD-2226-bound-satisfaction branch from df783f7 to 6c068f5 Compare November 11, 2026 13:07
@mukeshsp

mukeshsp commented Nov 11, 2026 •

Copy link
Copy Markdown
Author

Update after 6c068f5 (adds a one-line courtesy fix: src/policy/concrete.rs:349 broken intra-doc link → plain text, matching the style of line 378):

  • ✅ Docs - stable toolchain now passes (was failing on other PRs in this fork, incl. chore: add catalog-info.yaml for Backstage developer portal #2/[INFOSEC-634] Add security policy #3).
  • ✅ Format - nightly, Lint - nightly, Docs - nightly all pass.
  • ❌ Lint GitHub Actions Files (Run Zizmor job) still fails — pre-existing, not caused by this PR. Root cause per the job log: zizmor latest (v1.30.0) crashes while loading a pre-existing workflow:
    error: failed to load file://./.github/workflows/cron-daily-fuzz.yml as workflow
      = help: this typically indicates a bug in zizmor; please report it
    fatal: no audit was performed
    
    Additionally the workflow references .zizmor-ci-policy.yml, which does not exist in the repo. The same job fails on PR [INFOSEC-634] Add security policy #3 and failed on the first push of this branch (413cd64); note this fork's master has no push-triggered CI runs, so there is no direct base-branch run to compare against. Fixing this requires pinning/downgrading zizmor or repairing the fuzz workflow — CI config changes outside this PR's scope.

Full test matrix (stable/nightly/1.63 MSRV) passed on the identical code at df783f7.

@mukeshsp
mukeshsp marked this pull request as ready for review November 17, 2026 10:29

@claude claude 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.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

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.

2 participants