Skip to content

Unify the two satisfaction algorithms#102

Merged
sipa merged 6 commits into
masterfrom
202202_unify_sat
Feb 22, 2022
Merged

Unify the two satisfaction algorithms#102
sipa merged 6 commits into
masterfrom
202202_unify_sat

Conversation

@sipa
Copy link
Copy Markdown
Owner

@sipa sipa commented Feb 18, 2022

This changes the malleable satisfaction algorithm to produce the same result as the non-malleable one, in case a non-malleable satisfaction exists. Further, any non-malleable result gains the guarantee that it is valid assuming a new ValidSatisfaction(), which is weaker than IsSane(), and crucially, doesn't require IsNonMalleable().

Lots of code simplifications follow.

The downside is that this makes the malleable satisfaction algorithm less aggressively pursue minimal witness size (because it's internally using the same priorities as the non-malleable one). On the other hand, it simplifies the code, and makes it more testable (as demonstrated by the few incorrect noncanonical/malleable annotations that were necessary to make this work).

I have some ideas about how to bring back an actual don't-care-about-malleability satisfier in a more testable way, but that can wait until after integration in Bitcoin Core.

Copy link
Copy Markdown
Contributor

@darosior darosior left a comment

Choose a reason for hiding this comment

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

That's great, it clarifies the API and simplifies the code. I don't think we should optimize for the malleable satisfaction so IMO the tradeoff is totally worth it.

A couple of comments on the tests. I'm going to test this after having rebased the Bitcoin Core satisfaction PR.

Comment thread bitcoin/script/miniscript.h
Comment thread bitcoin/test/fuzz/miniscript_random.cpp Outdated
Comment thread bitcoin/test/fuzz/miniscript_random.cpp
Comment thread bitcoin/script/miniscript.h
Comment thread bitcoin/script/miniscript.cpp Outdated
@darosior
Copy link
Copy Markdown
Contributor

Had to rebase on top of #101, so if you need to rebase: https://github.com/darosior/miniscript/tree/202202_unify_sat

@sipa
Copy link
Copy Markdown
Owner Author

sipa commented Feb 21, 2022

Rebased on merged #101, and addressed comments.

Copy link
Copy Markdown
Contributor

@darosior darosior left a comment

Choose a reason for hiding this comment

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

The unit test doesn't compile but passes once compiled. LGTM otherwise. The extended fuzz target also passes on my corpus (running it in background today).

Comment thread bitcoin/test/miniscript_tests.cpp Outdated
Comment thread bitcoin/script/miniscript.h
Copy link
Copy Markdown
Contributor

@darosior darosior left a comment

Choose a reason for hiding this comment

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

ACK 6fbd6e4

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