Skip to content
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

refactor: check the node syntax before size limit #747

Merged
merged 2 commits into from
Sep 12, 2024

Conversation

ChrisCho-H
Copy link
Contributor

@ChrisCho-H ChrisCho-H commented Sep 11, 2024

I’m not 100% sure if it’s intended, but the behavior of check_global_consensus_validity, which checks the script size limit first and then node could confuse the user-side.
For example, If sh or wsh descriptor uses multi_a with 999 public key(e.g. descriptor::Wsh::from_str("wsh(multi_a(pk1...pk999)")), it will throw an error on the size limit, not the fragment multi_a. It might be a bit more efficient in case of size overflow, but

  1. As miniscript functions as a language, syntax or grammar check should precedes stack limit. While the most of syntax are checked before check_global_consensus_validity, Syntax of which validity differ on context(e.g. multi and multi_a) are not.
  2. It’s more helpful to debug for user if blocked by wrong syntax first.
  3. It’s weird to check the script size which could be possibly wrong script upon context.

While descriptor itself is kinda helper tool which uses miniscript, it would worth checking syntax first.

@apoelstra
Copy link
Member

concept ACK. Agreed this is a better order of operations for the user.

Can you add a unit test? I'm planning to significantly rewrite this code in the next few months and without a unit test I'm likely to accidentally revert this behavior.

CI failure looks unrelated to you. We don't pin our nightly compiler here (yet) and it looks like there's a new lint.

@apoelstra
Copy link
Member

CI failures are unrelated.

@apoelstra
Copy link
Member

LOL at how bad the existing error messages are. But that's fine, it's unrelated to this PR.

Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK 3cdc711 successfully ran local tests

@apoelstra apoelstra merged commit 286fa88 into rust-bitcoin:master Sep 12, 2024
29 of 30 checks passed
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