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

Stop Directly Constructing Policy AST #253

Open
JeremyRubin opened this issue Oct 29, 2022 · 5 comments
Open

Stop Directly Constructing Policy AST #253

JeremyRubin opened this issue Oct 29, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@JeremyRubin
Copy link
Collaborator

The Policy AST is not intended to be directly constructed. Switch to our own custom AST, or a macro language, strings, or something else to ensure that all the properties of miniscript are correctly checked.

@ProofOfKeags
Copy link
Collaborator

ProofOfKeags commented Oct 31, 2022

Should we go after our own CBC Policy construct that we "compile" to the policy FE language and parse it with actual policy?

I'm not yet sure if a CBC Policy AST is possible. I can look into this.

@JeremyRubin
Copy link
Collaborator Author

a CBC subset of policy isn't easy given how timelocks are implemented, so I think it's out of scope.

@ProofOfKeags ProofOfKeags added the bug Something isn't working label Nov 2, 2022
@JeremyRubin
Copy link
Collaborator Author

cc @apoelstra I think a more succinct explanation of why the "just do it as strings" approach for using Policy v.s. working with the AST directly is that it makes it really difficult to programmatically construct the policy fragments. i.e., in my compiler passes I do some manipulations on the AST that requires inspecting them or generating them programmatically. writing a bunch of custom string concatenating code would be sad. not sure if i expressed that well before, but one example is we have a function that generates different threshold groups that become available at different times which is a function of input parameters. string templating that would be meh.

so i think regardless of if we do strings when we pass to policy, we want some kind of PolicyBuilder enum that we can use to emit policy / build it up programmatically.

@apoelstra
Copy link

Sure, we'll explore this.

@ProofOfKeags
Copy link
Collaborator

Alternatively, understanding the "gaps" in where you can create a structurally well-typed Policy expression in the AST that isn't valid semantically would at least help us craft a Policy builder ourselves. I anticipate that the work to understand those gaps is not too much less than actually having an API for it though. If it is that could be a very helpful intermediate step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants