Skip to content

fix: evaluate satisfier outcomes once per node - #4

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

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

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 every PR 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 repo-wide infra issue, 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. Same failure on [INFOSEC-634] Add security policy #3 and the base branch. Fixing this requires pinning/downgrading zizmor or repairing the fuzz workflow — CI config changes outside this PR's scope.

Full test matrix passed on the previous commit (df783f7, identical code modulo the doc-comment fix); the re-run on 6c068f5 is completing green so far.

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