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

Move and rename crate::policy::semantic::Policy to crate::r#abstract::Abstract #604

Closed
wants to merge 8 commits into from

Conversation

tcharding
Copy link
Member

@tcharding tcharding commented Sep 27, 2023

Based on discussion in #603. This requires #603 to be updated.

Done as a series of steps, I don't usually do PRs like this but after reviewing the recent bitcoin_io PR I think it does help for making review easier when there are a load of simple but slightly different changes involved in getting from one state to another. Can squash, merge, or re-split if required. Please comment on the patch series style if you have any suggestions on how I can make review easier.

Draft for feedback please, especially the last patch - the struct rename from Policy to Abstract. Note also this leaves concrete::Policy named as is.

We can import types to test in unit tests using `use super::*`.
@tcharding
Copy link
Member Author

There will be some grammar mistakes in docs 'a' vs 'an' because of semantic to abstract change. Will fix later.

We used "semantic" so as not to clash with the reserved Rust keyword
"abstract", however there is a language feature to deal with such name
clashes - the raw identifier syntax `r#foo`.

Use `r#abstract` and rename the `policy/semantic.rs` file to
`policy/abstract.rs`. There is more re-naming to do to complete the
semantic -> abstract change but here we _only_ do the module name to
ease review.
The `Liftable` trait is its own thing, it defines a trait to lift
miniscript, descriptors, and concrete policies to an abstract policy.

Move the `Liftable` and associated error type and impls to a new `lift`
module that lives under the recently created `crate::r#abstract` module.

Note we alse remove the `Semantic` and `Concrete` public
re-names/re-exports from `crate::policy` because we are transitioning
away from using the term "semantic", however to minimise the changes in
this patch we add a bunch of

  `use crate::policy::concrete::Policy as Concrete`

statements.
We are moving away from the usage of "semantic" as a synonym for
"abstract".

Use `Abstract` instead of `Semantic` as the type alias for
`crate::policy::r#abstract::Policy`.
Make it explicit that the `Policy` returned by `lift` in the
`descriptor::tr` module is a `r#abstract::Policy`.
The abstract policy is different from the concrete policy because it is
only part of rust-miniscript and not miniscript in general. To help
differentiate it move it to a separate module.

Note to reviewers, `git` couldn't work out that this is basically a file
move so I've left the `src/policy/abstract.rs` file in the repo but it
is not included in the build. Reviewers can do `diff
src/policy/abstract.rs src/abstract/mod.rs` to ease review. It will be
removed in the next patch.
We do not build this file in the build, remove it.
Use the identifier `Abstract` to further disambiguate the abstract
policy and the concrete policy. This has the nice advantage of removing
a few usages of the kind-of-ugly `r#abstract::Policy`.
@tcharding
Copy link
Member Author

tcharding commented Sep 28, 2023

TODO: Remove the serialization impl from Abstract.

@apoelstra
Copy link
Member

Sorry, but I think we should keep the module name as semantic. If users only needed to type r#abstract when importing stuff that would be okay, but needing to write r#abstract::Policy all over the place is pretty ugly. And just Abstract as a type doesn't feel right. (policy::Abstract would be okay, but this PR moves the type out of the policy module.)

What if we called the module lift and changed the type name to Lifted?

Or we could keep it as Policy and users can write lift::Policy...though this may continue to cause confusion with the actual "policy language".

@tcharding
Copy link
Member Author

No sweat, I'll have another play with it.

@tcharding tcharding mentioned this pull request Oct 3, 2023
@tcharding
Copy link
Member Author

I did #607 so we can see what its like, I will need to close the unwanted one and [re]write the PR description.

@tcharding
Copy link
Member Author

I don't think this is going anywhere

@tcharding tcharding closed this Mar 27, 2024
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