-
Notifications
You must be signed in to change notification settings - Fork 149
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
Use Threshold
type in concrete policy and in Terminal::multi/multi_a
#674
Conversation
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.
Sans the map_err
thing, ACK 1345fb2
src/descriptor/sortedmulti.rs
Outdated
let ms = Miniscript::from_ast(term)?; | ||
// This would check all the consensus rules for p2sh/p2wsh and | ||
// even tapscript in future | ||
Ctx::check_local_validity(&ms).map_err(From::from) | ||
Ctx::check_local_validity(&ms).map_err(Error::from)?; |
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.
Ctx::check_local_validity(&ms).map_err(Error::from)?; | |
Ctx::check_local_validity(&ms)?; |
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.
Yeah, I could drop it here. In future though I want to move away from using from
and explicitly write variants (e.g. map_err(Error::ScriptContext)
or whatever).
But agreed that .map_err(Error::from)?
is the worst of both worlds and I should drop it.
keys.len() - 1, | ||
keys.iter().map(|pubkey| Arc::new(Concrete::Key(*pubkey))), | ||
) | ||
.unwrap(); |
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.
I notice there's a few unwraps() in this PR. Just curious if there's a reason to do this instead of returning an Error type.
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.
These are tests. unwraps
are common in test and that is how we test most things.
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.
Oops, I had meant to place this comment on the generate_combination()
changes. Heh yeah, I get using unwrap on the tests though.
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.
Yeah, that was one occurrence which was a safe unwrap because of miniscript invariants around Threshold
. We could add a expect with a message with the reasoning, but there was a short comment the commit message explaining that.
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.
I added an expect
. There was also a debug_assert
which would have triggered before the unwrap
did, but better to be explicit.
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 1345fb2
keys.len() - 1, | ||
keys.iter().map(|pubkey| Arc::new(Concrete::Key(*pubkey))), | ||
) | ||
.unwrap(); |
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.
These are tests. unwraps
are common in test and that is how we test most things.
This one is a pretty big diff but hopefully the unit tests provide some assurance. One maybe-subtle change is that the debug_assert in `generate_combinations` was incorrect -- it checked that k <= n, but the logic depended on k < n. I fixed the debug_assert and nothing broke.
1345fb2
to
79d3f7e
Compare
Rebased to fix the |
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 79d3f7e
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 79d3f7e
Some more large but mostly-mechanical diffs. This is able to eliminate a bunch of error paths, though the actual error variants can't be removed until we also convert Terminal::thresh in the next PR(s). At that point we will start to see the real benefits of this type because fallible functions will become fallible and massive amounts of compiler error-checking can just go away entirely.
Also removes the allocation in
SortedMulti::constructor_check
that was pointed out in #660.