Commit 460400d
committed
Merge #773: refactor expression parsing and checksum checking
eb4f8c4 expression: move checksum validation into expression parsing (Andrew Poelstra)
bb2e658 expression: add explicit well-formedness check to parser (Andrew Poelstra)
9b03043 expression: add some unit tests (Andrew Poelstra)
ad85f92 expression: implement PartialEq/Eq for trees (Andrew Poelstra)
b0508d8 checksum: clean up errors and error paths (Andrew Poelstra)
Pull request description:
As a step toward rewriting the expression parser to be non-recursive, add a pre-parsing well-formedness check, which verifies that an expression is well-formed, uses only the correct character set, and that the checksum (if present) is valid.
Along the way, replace the error types returned from the `expression` module with a new more-precise one which can identify the location of parse errors (and identify what the error was in a more correct way). This improves our error reporting and drops many instances of the stringly-typed `BadDescriptor` error.
There is currently a bunch of special logic for Taproot descriptors which have the extra characters `{` and `}`. To the extent possible, this PR doesn't touch that logic. It will be addressed in a later PR.
The benchmarks show a slight slowdown since we essentially added new validation logic without removing the old logic. Later PRs will improve things.
ACKs for top commit:
sanket1729:
ACK eb4f8c4
Tree-SHA512: cb972e9683aca51f8d18ab61521af8606f47bd1d0bc37dd1ed085101dbc4dd69b382eb05e8e21d2856ac68ebe7d2ca7879ca8a0692dacbea0b22b7b10c9ef987File tree
12 files changed
+465
-120
lines changed- src
- descriptor
- expression
- miniscript
- policy
12 files changed
+465
-120
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
| |||
186 | 185 | | |
187 | 186 | | |
188 | 187 | | |
189 | | - | |
190 | | - | |
| 188 | + | |
191 | 189 | | |
192 | 190 | | |
193 | 191 | | |
| |||
387 | 385 | | |
388 | 386 | | |
389 | 387 | | |
390 | | - | |
391 | | - | |
| 388 | + | |
392 | 389 | | |
393 | 390 | | |
394 | 391 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | 17 | | |
19 | | - | |
20 | 18 | | |
21 | 19 | | |
22 | 20 | | |
23 | 21 | | |
24 | | - | |
| 22 | + | |
25 | 23 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
32 | 88 | | |
33 | 89 | | |
34 | 90 | | |
35 | 91 | | |
36 | 92 | | |
37 | 93 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
42 | 101 | | |
43 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
44 | 116 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
54 | 125 | | |
55 | 126 | | |
56 | | - | |
| 127 | + | |
57 | 128 | | |
58 | 129 | | |
59 | 130 | | |
| |||
78 | 149 | | |
79 | 150 | | |
80 | 151 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
90 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
91 | 164 | | |
92 | 165 | | |
93 | 166 | | |
| |||
100 | 173 | | |
101 | 174 | | |
102 | 175 | | |
103 | | - | |
104 | 176 | | |
105 | 177 | | |
106 | 178 | | |
| |||
192 | 264 | | |
193 | 265 | | |
194 | 266 | | |
195 | | - | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
196 | 270 | | |
197 | 271 | | |
198 | 272 | | |
| |||
229 | 303 | | |
230 | 304 | | |
231 | 305 | | |
232 | | - | |
233 | | - | |
| 306 | + | |
| 307 | + | |
234 | 308 | | |
235 | 309 | | |
236 | 310 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
| |||
988 | 987 | | |
989 | 988 | | |
990 | 989 | | |
991 | | - | |
992 | | - | |
| 990 | + | |
993 | 991 | | |
994 | 992 | | |
995 | 993 | | |
| |||
1053 | 1051 | | |
1054 | 1052 | | |
1055 | 1053 | | |
1056 | | - | |
1057 | | - | |
| 1054 | + | |
1058 | 1055 | | |
1059 | 1056 | | |
1060 | 1057 | | |
| |||
1066 | 1063 | | |
1067 | 1064 | | |
1068 | 1065 | | |
1069 | | - | |
1070 | | - | |
1071 | | - | |
1072 | | - | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
1073 | 1070 | | |
1074 | 1071 | | |
1075 | 1072 | | |
| |||
1841 | 1838 | | |
1842 | 1839 | | |
1843 | 1840 | | |
1844 | | - | |
| 1841 | + | |
1845 | 1842 | | |
1846 | 1843 | | |
1847 | 1844 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
| |||
288 | 287 | | |
289 | 288 | | |
290 | 289 | | |
291 | | - | |
292 | | - | |
| 290 | + | |
293 | 291 | | |
294 | 292 | | |
295 | 293 | | |
| |||
505 | 503 | | |
506 | 504 | | |
507 | 505 | | |
508 | | - | |
509 | | - | |
| 506 | + | |
510 | 507 | | |
511 | 508 | | |
512 | 509 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
109 | 108 | | |
110 | 109 | | |
111 | 110 | | |
112 | | - | |
113 | | - | |
| 111 | + | |
114 | 112 | | |
115 | 113 | | |
116 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
557 | 557 | | |
558 | 558 | | |
559 | 559 | | |
560 | | - | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
561 | 563 | | |
562 | 564 | | |
563 | 565 | | |
| |||
587 | 589 | | |
588 | 590 | | |
589 | 591 | | |
590 | | - | |
591 | | - | |
592 | 592 | | |
593 | 593 | | |
594 | 594 | | |
| |||
0 commit comments