Skip to content

Conversation

@apoelstra
Copy link
Member

This completes the "threshold" conversion and completely drops the various ad-hoc error paths related to threshold values (most of which were just random strings).

The next set of PRs will be related to cleaning up errors in general a bit, to strongly-type things and add span information. But I am struggling a bit with how to box the associated error types for the MiniscriptKey types so it may be a while. (Very hard to do this in a std/nostd compatible way and the final result will probably be inconvenient/annoying for users.)

Miniscript rules say that for andor(x,y,z), x must be dissatisfiable
(must have the 'd' property). This means that we cannot construct a
Miniscript with a non-dissatisfiable first child of an AndOr, because we
would get a type-checking error.

However we do this check again in CompilerExtData::and_or, for some
reason. This is actually the *only* non-threshold-related error path in
CompilerExtData::type_check, and getting rid of it will let us eliminate
a ton of errors. So remove this.

NEXT, we remove the two threshold-related error paths. These are the
checks in CompilerExtData::type_check_common which check for k == 0
and for k > n. I *think* these paths are possible, but they are not
tested, so we can remove them without breaking our tests. So we remove
them here, allowing us to eliminate a ton of Ok(), ? and unwraps. The
next commit will use the new Threshold type to make these error paths
actually impossible.
Copy link
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

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

ACK 6925ae6

Copy link
Member

@sanket1729 sanket1729 left a comment

Choose a reason for hiding this comment

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

ACK 6925ae6

@apoelstra apoelstra merged commit 60ad2c9 into rust-bitcoin:master Apr 8, 2024
heap-coder added a commit to heap-coder/rust-miniscript that referenced this pull request Sep 27, 2025
… Satisfaction

6925ae66b9fc9183652c14f660ce3b62ba0707d6 clippy: remove now-unneeded i64 import (Andrew Poelstra)
0fb47b7fcde70e71321d726465b0ff885b20b3b5 satisfaction: use new Threshold type (Andrew Poelstra)
ff8f07769a5cd68cf3c8701d856739f58f00a996 miniscript: use new Threshold type for thresh (Andrew Poelstra)
95f8dacdcf83eec03a485faa790100e5263ea139 compiler: eliminate unused error paths (Andrew Poelstra)

Pull request description:

  This completes the "threshold" conversion and completely drops the various ad-hoc error paths related to threshold values (most of which were just random strings).

  The next set of PRs will be related to cleaning up errors in general a bit, to strongly-type things and add span information. But I am struggling a bit with how to box the associated error types for the MiniscriptKey types so it may be a while. (Very hard to do this in a std/nostd compatible way and the final result will probably be inconvenient/annoying for users.)

ACKs for top commit:
  tcharding:
    ACK 6925ae66b9fc9183652c14f660ce3b62ba0707d6
  sanket1729:
    ACK 6925ae66b9fc9183652c14f660ce3b62ba0707d6

Tree-SHA512: 04344be051cb5b16f691eafdb64818ffd44c9adc15f71ad6c664e9f337dc4ed52be66a540bf5c99eeb4b384a95d93e2518f290b84cf6abf9cb092e789b57a3fa
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.

3 participants