-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: check policy validity to prevent duplicate check #772
feat: check policy validity to prevent duplicate check #772
Conversation
The original code was intentional. One of the initials goals of the library was to enable the creation of Miniscripts that are valid according to consensus rules, though not necessarily policy-valid. Initially, we envisioned this feature for use cases such as block explorers displaying inferred Miniscripts. Which is why Perhaps it’s time to reconsider whether we should continue supporting non-standard but consensus-valid Miniscripts. We could simplify by limiting support to policy-valid Miniscripts only. wdyt @apoelstra? |
Actually, looking at this again, we have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 4fe88da.
Thank you for the detailed review. It's a not bug fix that we need to backport, it’s a valuable code cleanup that consolidates scattered checks into the constructor. |
4fe88da
to
757daee
Compare
Thanks for the detailed review! I wasn't not sure whether it's intentional. I've changed just commit message from |
Sure, if you think this is an improvement @sanket1729 I will review this and merge it. But in general I want to overhaul all the validation logic (which not only includes standardness vs non-standardness but also "sane" vs "insane"), which currently is spread across the codebase in adhoc and inconsistent ways. I have #723 (comment) about this plan and have made a substantial amount of progress toward it. But in order to do this I needed to clean up some error returns, which required I eliminate some recursion throughout the library, which is currently blocked on #745 (which is a pretty minor PR, but it's in my working branch and I use it heavily to guide my un-recursion work, so I'd like it to be merged before PR'ing more stuff). |
Ok, looking at my current working branch, I have about 40 commits queued up and none of them are in conflict with this (one completely rewrites the Miniscript string parser but this part of the logic is essentially unchanged, so I'll need to rebase but it's not like this is unnecessary/wasted work). So let's pull this in. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 757daee; successfully ran local tests
Sorry, I missed this and it drowned in notifications. ACKed this PR now. Excited for the cleanups. We can holdoff merging this if you want to try to opening a PR with the other changes. |
No worries! I've been pretty busy with Simplicity and hadn't had time to work on this anyway, or I would've pinged you. And I merged this one -- will rebase my work on it, changing the local checks to global ones in my refactor. |
Miniscript::from_ast()
only executescheck_global_consensus_validity()
which does not includecheck_global_policy_validity()
. Change to usecheck_global_validity()
to check both consensus and policy validness.wrap_into_miniscript()
executescheck_global_validity()
internally afterMiniscript::from_ast()
. AsMiniscript::from_ast()
now executescheck_global_validity()
, it doesn't have to check duplicately.I was originally thinking to change
check_global_validity()
insidewrap_into_miniscript()
tocheck_global_policy_validity()
(as consensus check is done byfrom_ast()
). I think it's better to strengthen the validness check infrom_ast()
, and do nothing inwrap_into_miniscript()
.