Commit 4490289
committed
Merge #732: Refactor
a195c81 fuzz: add compile_taproot fuzztest (Andrew Poelstra)
a6ca4ce policy: clean up error types in compile_tr (Andrew Poelstra)
bedb6d7 policy: unwrap a few impossible error cases in compile_tr (Andrew Poelstra)
a3338fb policy: use new tapleaf_probability_iter for num_tap_leaves (Andrew Poelstra)
3522703 policy: reduce error paths in Concrete::extract_key to one (Andrew Poelstra)
9f53c01 compiler: split segwit_limits test into 2 (Andrew Poelstra)
7de96d3 policy: split up error enum for concrete and semantic (Andrew Poelstra)
Pull request description:
Right now our Taproot compiler does some complicated analysis to identify a key within a policy that may be extracted to use as an internal key. Specifically, if you look at the "disjunction tree" at the root of a policy, every leaf of this tree can be a tapbranch and any leaf which is just a pubkey-check and nothing else is a candidate to be the internal key.
However, our logic to do this is convoluted, has many unnecessary error paths, and lots of gratuitous allocations (which ironically make the code harder, not easier, to follow).
This PR smooths all that out by introducing a new iterator over the potential tapbranches of a policy (along with their probabilities). It also cleans up much of the error handling in the policy module, eliminating 3 calls to the stringly-typed `errstr` function.
ACKs for top commit:
sanket1729:
ACK a195c81
Tree-SHA512: 62278a0d778c4e68faf69f757d2ad2fedc43e6b213df7cf9fef6d5a898c6db9b18d5c9a753d974bad26cda693c5eb170bf5e5b28d14c7196d12d64fb6f49e712extract_key logic in Taproot compilerFile tree
9 files changed
+195
-131
lines changed- .github/workflows
- fuzz
- fuzz_targets
- src
- policy
9 files changed
+195
-131
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
22 | 26 | | |
23 | 27 | | |
24 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
464 | 464 | | |
465 | 465 | | |
466 | 466 | | |
467 | | - | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
468 | 470 | | |
469 | 471 | | |
470 | 472 | | |
| |||
529 | 531 | | |
530 | 532 | | |
531 | 533 | | |
532 | | - | |
| 534 | + | |
| 535 | + | |
533 | 536 | | |
534 | 537 | | |
535 | 538 | | |
| |||
595 | 598 | | |
596 | 599 | | |
597 | 600 | | |
598 | | - | |
| 601 | + | |
| 602 | + | |
599 | 603 | | |
600 | 604 | | |
601 | 605 | | |
| |||
649 | 653 | | |
650 | 654 | | |
651 | 655 | | |
652 | | - | |
653 | | - | |
654 | | - | |
655 | | - | |
656 | | - | |
657 | 656 | | |
658 | 657 | | |
659 | 658 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
53 | 63 | | |
54 | 64 | | |
55 | 65 | | |
| |||
66 | 76 | | |
67 | 77 | | |
68 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
69 | 85 | | |
70 | 86 | | |
71 | 87 | | |
| |||
77 | 93 | | |
78 | 94 | | |
79 | 95 | | |
80 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
81 | 101 | | |
82 | 102 | | |
83 | 103 | | |
| |||
1511 | 1531 | | |
1512 | 1532 | | |
1513 | 1533 | | |
1514 | | - | |
| 1534 | + | |
1515 | 1535 | | |
1516 | 1536 | | |
1517 | 1537 | | |
| |||
1537 | 1557 | | |
1538 | 1558 | | |
1539 | 1559 | | |
| 1560 | + | |
1540 | 1561 | | |
| 1562 | + | |
| 1563 | + | |
1541 | 1564 | | |
1542 | 1565 | | |
1543 | 1566 | | |
| |||
0 commit comments