|
50 | 50 | (counter-constant IS_DATA))) |
51 | 51 |
|
52 | 52 | (defconstraint special-ct-constancy () |
53 | | - (if-not-zero (+ (- 1 [PHASE 5]) (- 1 DEPTH_1) IS_PREFIX (- 1 IS_DATA)) |
| 53 | + (if-not-zero (+ (- 1 PHASE_5) (- 1 DEPTH_1) IS_PREFIX (- 1 IS_DATA)) |
54 | 54 | (counter-constant [INPUT 1]))) |
55 | 55 |
|
56 | | -(defconstraint ct-incrementings () |
| 56 | +(defconstraint ct-incrementing () |
57 | 57 | (begin (if-zero (* IS_DATA IS_PREFIX) |
58 | 58 | (counter-incrementing LC)) |
59 | 59 | (counter-incrementing LC_CORRECTION))) |
60 | 60 |
|
61 | | -(defconstraint phase4-decrementing () |
62 | | - (phase-decrementing [PHASE 4] IS_PREFIX)) |
63 | | - |
64 | 61 | (defconstraint phase5-incrementing () |
65 | | - (phase-incrementing [PHASE 5] DEPTH_1)) |
| 62 | + (phase-incrementing PHASE_5 DEPTH_1)) |
66 | 63 |
|
67 | | -(defconstraint istopic-incrementing () |
| 64 | +(defconstraint is-topic-incrementing () |
68 | 65 | (phase-incrementing IS_TOPIC INDEX_LOCAL)) |
69 | 66 |
|
70 | 67 | (defconstraint phase1-constant () |
71 | | - (phase-constancy [PHASE 1] TXRCPT_SIZE)) |
| 68 | + (phase-constancy PHASE_1 TXRCPT_SIZE)) |
72 | 69 |
|
73 | 70 | ;; 4.1.2 Global Phase Constraints ;; |
74 | | -(defconstraint impose-phase-id () |
75 | | - (eq! PHASE_ID |
76 | | - (+ (reduce + |
77 | | - (for k [1 : 5] (* k [PHASE k]))) |
| 71 | +(defcomputedcolumn (PHASE_ID :i16) |
| 72 | + (+ |
| 73 | + (* 1 PHASE_1) |
| 74 | + (* 2 PHASE_2) |
| 75 | + (* 3 PHASE_3) |
| 76 | + (* 5 PHASE_5) |
78 | 77 | (* SUBPHASE_ID_WEIGHT_IS_PREFIX IS_PREFIX) |
79 | 78 | (* SUBPHASE_ID_WEIGHT_IS_OT IS_TOPIC) |
80 | 79 | (* SUBPHASE_ID_WEIGHT_IS_OD IS_DATA) |
81 | 80 | (* SUBPHASE_ID_WEIGHT_DEPTH DEPTH_1) |
82 | | - (* SUBPHASE_ID_WEIGHT_INDEX_LOCAL IS_TOPIC INDEX_LOCAL)))) |
| 81 | + (* SUBPHASE_ID_WEIGHT_INDEX_LOCAL IS_TOPIC INDEX_LOCAL))) |
83 | 82 |
|
84 | 83 | (defconstraint initial-stamp (:domain {0}) |
85 | 84 | (begin (vanishes! ABS_TX_NUM) |
86 | 85 | (vanishes! ABS_LOG_NUM))) |
87 | 86 |
|
| 87 | +(defun (phase-sum) (+ PHASE_1 PHASE_2 PHASE_3 PHASE_5)) |
| 88 | + |
88 | 89 | (defconstraint phase-exclusion () |
89 | 90 | (if-zero ABS_TX_NUM |
90 | | - (vanishes! (reduce + (for i [5] [PHASE i]))) |
91 | | - (eq! 1 |
92 | | - (reduce + (for i [5] [PHASE i]))))) |
| 91 | + (vanishes! (phase-sum)) |
| 92 | + (eq! 1 (phase-sum)))) |
93 | 93 |
|
94 | 94 | (defconstraint ABS_TX_NUM-evolution () |
95 | | - (if (or! (eq! [PHASE 1] 0) (remained-constant! [PHASE 1])) |
| 95 | + (if (or! (eq! PHASE_1 0) (remained-constant! PHASE_1)) |
96 | 96 | ;; no change |
97 | 97 | (remained-constant! ABS_TX_NUM) |
98 | 98 | ;; increment |
99 | 99 | (did-inc! ABS_TX_NUM 1))) |
100 | 100 |
|
101 | 101 | (defconstraint ABS_LOG_NUM-evolution () |
102 | | - (if-zero (+ (- 1 [PHASE 5]) (- 1 DEPTH_1) (- 1 IS_PREFIX) IS_TOPIC IS_DATA CT) |
| 102 | + (if-zero (+ (- 1 PHASE_5) (- 1 DEPTH_1) (- 1 IS_PREFIX) IS_TOPIC IS_DATA CT) |
103 | 103 | (did-inc! ABS_LOG_NUM 1) |
104 | 104 | (remained-constant! ABS_LOG_NUM))) |
105 | 105 |
|
|
111 | 111 | (if-not-zero PHASE_SIZE |
112 | 112 | (vanishes! PHASE_END))) |
113 | 113 |
|
114 | | -(defconstraint no-end-no-changephase (:guard ABS_TX_NUM) |
| 114 | +(defun (phase-wght-sum) (+ PHASE_1 |
| 115 | + (* 2 PHASE_2) |
| 116 | + (* 3 PHASE_3) |
| 117 | + (* 5 PHASE_5))) |
| 118 | + |
| 119 | +(defconstraint no-end-no-change-phase (:guard ABS_TX_NUM) |
115 | 120 | (if-zero PHASE_END |
116 | | - (eq! (reduce + |
117 | | - (for i [5] (* i [PHASE i]))) |
118 | | - (reduce + |
119 | | - (for i |
120 | | - [5] |
121 | | - (* i (next [PHASE i]))))))) |
| 121 | + (eq! (phase-wght-sum) |
| 122 | + (+ (next PHASE_1) |
| 123 | + (* 2 (next PHASE_2)) |
| 124 | + (* 3 (next PHASE_3)) |
| 125 | + (* 5 (next PHASE_5)))))) |
122 | 126 |
|
123 | 127 | (defconstraint phase-transition () |
124 | 128 | (if-eq PHASE_END 1 |
125 | 129 | (begin (eq! 1 |
126 | | - (+ (* [PHASE 1] (next [PHASE 2])) |
127 | | - (* [PHASE 2] (next [PHASE 3])) |
128 | | - (* [PHASE 3] (next [PHASE 4])) |
129 | | - (* [PHASE 4] (next [PHASE 5])) |
130 | | - (* [PHASE 5] (next [PHASE 1])))) |
131 | | - (if-eq [PHASE 5] 1 (vanishes! TXRCPT_SIZE))))) |
| 130 | + (+ (* PHASE_1 (next PHASE_2)) |
| 131 | + (* PHASE_2 (next PHASE_3)) |
| 132 | + (* PHASE_3 (next PHASE_5)) |
| 133 | + (* PHASE_5 (next PHASE_1)))) |
| 134 | + (if-eq PHASE_5 1 (vanishes! TXRCPT_SIZE))))) |
132 | 135 |
|
133 | 136 | ;; 4.1.3 Byte decomposition's loop heartbeat ;; |
134 | 137 | (defconstraint ct-imply-done (:guard ABS_TX_NUM) |
|
163 | 166 |
|
164 | 167 | ;; 4.1.6 Byte size updates ;; |
165 | 168 | (defconstraint globalsize-update () |
166 | | - (if-zero [PHASE 1] |
| 169 | + (if-zero PHASE_1 |
167 | 170 | (eq! TXRCPT_SIZE |
168 | 171 | (- (prev TXRCPT_SIZE) (* LC nBYTES))))) |
169 | 172 |
|
170 | | -(defconstraint phasesize-update () |
171 | | - (if-eq 1 (+ (* [PHASE 4] (- 1 IS_PREFIX)) |
172 | | - (* [PHASE 5] DEPTH_1)) |
| 173 | +(defconstraint phase-size-update () |
| 174 | + (if-eq 1 (* PHASE_5 DEPTH_1) |
173 | 175 | (eq! PHASE_SIZE |
174 | 176 | (- (prev PHASE_SIZE) (* LC nBYTES))))) |
175 | 177 |
|
176 | 178 | ;; LC correction nullity ;; |
177 | | -(defconstraint lccorrection-nullity () |
178 | | - (if-zero (+ [PHASE 1] (* [PHASE 5] IS_DATA)) |
| 179 | +(defconstraint lc-correction-nullity () |
| 180 | + (if-zero (+ PHASE_1 (* PHASE_5 IS_DATA)) |
179 | 181 | (vanishes! LC_CORRECTION))) |
180 | 182 |
|
181 | | -;; 4.1.8 Finalisation Constraints ;; |
182 | | -(defconstraint finalisation (:domain {-1}) |
| 183 | +;; 4.1.8 Finalization Constraints ;; |
| 184 | +(defconstraint finalization (:domain {-1}) |
183 | 185 | (if-not-zero ABS_TX_NUM |
184 | 186 | (begin (eq! PHASE_END 1) |
185 | | - (eq! [PHASE 5] 1) |
| 187 | + (eq! PHASE_5 1) |
186 | 188 | (eq! ABS_TX_NUM ABS_TX_NUM_MAX) |
187 | 189 | (eq! ABS_LOG_NUM ABS_LOG_NUM_MAX)))) |
188 | 190 |
|
|
192 | 194 | ;; ;; |
193 | 195 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
194 | 196 | ;; 4.2.1 Phase 1 : RLP prefix ;; |
195 | | -(defconstraint phase1-init (:guard [PHASE 1]);; 4.1.1 |
196 | | - (if-zero (prev [PHASE 1]) |
| 197 | +(defconstraint phase1-init (:guard PHASE_1);; 4.1.1 |
| 198 | + (if-zero (prev PHASE_1) |
197 | 199 | (begin (vanishes! (+ (- 1 IS_PREFIX) PHASE_END (next IS_PREFIX))) |
198 | 200 | (eq! nSTEP 1) |
199 | 201 | (if-zero [INPUT 1] |
|
203 | 205 | (* [INPUT 1] (^ 256 LLARGEMO))) |
204 | 206 | (eq! nBYTES 1)))))) |
205 | 207 |
|
206 | | -(defconstraint phase1-rlprefix (:guard [PHASE 1]) |
| 208 | +(defconstraint phase1-rlprefix (:guard PHASE_1) |
207 | 209 | (if-zero IS_PREFIX |
208 | 210 | (begin (eq! nSTEP 8) |
209 | 211 | (vanishes! LC_CORRECTION) |
210 | 212 | (eq! [INPUT 1] TXRCPT_SIZE) |
211 | | - (rlpPrefixOfByteString [INPUT 1] CT nSTEP DONE [PHASE 1] ACC_SIZE POWER BIT [ACC 1] [ACC 2] LC LIMB nBYTES) |
| 213 | + (rlpPrefixOfByteString [INPUT 1] CT nSTEP DONE PHASE_1 ACC_SIZE POWER BIT [ACC 1] [ACC 2] LC LIMB nBYTES) |
212 | 214 | (if-eq DONE 1 (eq! PHASE_END 1))))) |
213 | 215 |
|
214 | 216 | ;; 4.2.2 Phase 2 : status code Rz ;; |
215 | 217 | (defconstraint phase2 () |
216 | | - (if-eq [PHASE 2] 1 |
| 218 | + (if-eq PHASE_2 1 |
217 | 219 | (begin (eq! nSTEP 1) |
218 | 220 | (if-zero [INPUT 1] |
219 | 221 | (eq! LIMB |
|
225 | 227 |
|
226 | 228 | ;; 4.2.3 Phase 3 : cumulative gas Ru ;; |
227 | 229 | (defconstraint phase3 () |
228 | | - (if-eq [PHASE 3] 1 |
| 230 | + (if-eq PHASE_3 1 |
229 | 231 | (begin (eq! nSTEP 8) |
230 | 232 | (rlpPrefixInt [INPUT 1] CT nSTEP DONE [BYTE 1] [ACC 1] ACC_SIZE POWER BIT BIT_ACC LIMB LC nBYTES) |
231 | 233 | (if-eq DONE 1 |
232 | 234 | (begin (limbShifting [INPUT 1] POWER ACC_SIZE LIMB nBYTES) |
233 | 235 | (eq! PHASE_END 1)))))) |
234 | 236 |
|
235 | | -;; Phase 4: bloom filter Rb ;; |
236 | | -(defconstraint phase4-prefix (:guard [PHASE 4]) |
237 | | - (if-zero (prev [PHASE 4]) |
238 | | - (begin (vanishes! (+ (- 1 IS_PREFIX) PHASE_END (next IS_PREFIX))) |
239 | | - (eq! PHASE_SIZE 256) |
240 | | - (eq! nSTEP 1) |
241 | | - (eq! LIMB |
242 | | - (+ (* (+ RLP_PREFIX_INT_LONG 2) (^ 256 LLARGEMO)) |
243 | | - (* PHASE_SIZE (^ 256 13)))) |
244 | | - (eq! nBYTES 3) |
245 | | - (vanishes! INDEX_LOCAL)))) |
246 | | - |
247 | | -(defconstraint phase4-bloom-concatenation (:guard [PHASE 4]) |
248 | | - (if-zero IS_PREFIX |
249 | | - (begin (eq! nSTEP LLARGE) |
250 | | - (if-eq DONE 1 |
251 | | - (begin (for k |
252 | | - [1 : 4] |
253 | | - (begin (eq! [ACC k] [INPUT k]) |
254 | | - (eq! [INPUT k] |
255 | | - (shift LIMB (- k 4))) |
256 | | - (eq! (shift nBYTES (- k 4)) |
257 | | - LLARGE))) |
258 | | - (eq! (+ (shift LC -4) (shift LC -3)) |
259 | | - 1) |
260 | | - (if-zero PHASE_SIZE |
261 | | - (eq! PHASE_END 1)))) |
262 | | - (eq! INDEX_LOCAL |
263 | | - (+ (prev INDEX_LOCAL) |
264 | | - (* (prev LC) |
265 | | - (- 1 (prev IS_PREFIX)))))))) |
266 | | - |
267 | 237 | ;; Phase 5: log series Rl ;; |
268 | | -(defconstraint phase5-init (:guard [PHASE 5]) |
269 | | - (if-zero (prev [PHASE 5]) |
| 238 | +(defconstraint phase5-init (:guard PHASE_5) |
| 239 | + (if-zero (prev PHASE_5) |
270 | 240 | (vanishes! (+ DEPTH_1 (- 1 IS_PREFIX) IS_TOPIC IS_DATA)))) |
271 | 241 |
|
272 | | -(defconstraint phase5-phaseRlpPrefix (:guard [PHASE 5]) |
| 242 | +(defconstraint phase5-phaseRlpPrefix (:guard PHASE_5) |
273 | 243 | (if-zero DEPTH_1 |
274 | 244 | (begin (eq! [INPUT 1] PHASE_SIZE) |
275 | 245 | (if-zero [INPUT 1] |
|
279 | 249 | (eq! nBYTES 1) |
280 | 250 | (eq! PHASE_END 1)) |
281 | 251 | (begin (eq! nSTEP 8) |
282 | | - (rlpPrefixOfByteString [INPUT 1] CT nSTEP DONE [PHASE 5] ACC_SIZE POWER BIT [ACC 1] [ACC 2] LC LIMB nBYTES) |
| 252 | + (rlpPrefixOfByteString [INPUT 1] CT nSTEP DONE PHASE_5 ACC_SIZE POWER BIT [ACC 1] [ACC 2] LC LIMB nBYTES) |
283 | 253 | (if-eq DONE 1 |
284 | 254 | (vanishes! (+ (- 1 (next DEPTH_1)) |
285 | 255 | (- 1 (next IS_PREFIX)) |
286 | 256 | (next IS_TOPIC) |
287 | 257 | (next IS_DATA))))))))) |
288 | 258 |
|
289 | | -(defconstraint phase5-logentryRlpPrefix (:guard [PHASE 5]) |
| 259 | +(defconstraint phase5-logentryRlpPrefix (:guard PHASE_5) |
290 | 260 | (if-eq 1 (* DEPTH_1 IS_PREFIX (- 1 IS_TOPIC) (- 1 IS_DATA)) |
291 | 261 | (begin (eq! [INPUT 1] LOG_ENTRY_SIZE) |
292 | 262 | (eq! nSTEP 8) |
293 | | - (rlpPrefixOfByteString [INPUT 1] CT nSTEP DONE [PHASE 5] ACC_SIZE POWER BIT [ACC 1] [ACC 2] LC LIMB nBYTES) |
| 263 | + (rlpPrefixOfByteString [INPUT 1] CT nSTEP DONE PHASE_5 ACC_SIZE POWER BIT [ACC 1] [ACC 2] LC LIMB nBYTES) |
294 | 264 | (if-eq DONE 1 |
295 | 265 | (vanishes! (+ (next IS_PREFIX) (next IS_TOPIC) (next IS_DATA))))))) |
296 | 266 |
|
297 | | -(defconstraint phase5-rlpAddress (:guard [PHASE 5]) |
| 267 | +(defconstraint phase5-rlpAddress (:guard PHASE_5) |
298 | 268 | (if-zero (+ IS_PREFIX IS_TOPIC IS_DATA) |
299 | 269 | (begin (eq! nSTEP 3) |
300 | 270 | (eq! LC 1) |
|
311 | 281 | (- 1 (next IS_TOPIC)) |
312 | 282 | (next IS_DATA)))))))) |
313 | 283 |
|
314 | | -(defconstraint phase5-topic-prefix (:guard [PHASE 5]) |
| 284 | +(defconstraint phase5-topic-prefix (:guard PHASE_5) |
315 | 285 | (if-eq (* IS_PREFIX IS_TOPIC) 1 |
316 | 286 | (begin (vanishes! INDEX_LOCAL) |
317 | 287 | (eq! nSTEP 1) |
|
336 | 306 | (- 1 (next IS_TOPIC)) |
337 | 307 | (next IS_DATA)))))))) |
338 | 308 |
|
339 | | -(defconstraint phase5-topic (:guard [PHASE 5]) |
| 309 | +(defconstraint phase5-topic (:guard PHASE_5) |
340 | 310 | (if-zero (+ IS_PREFIX (- 1 IS_TOPIC)) |
341 | 311 | (begin (eq! nSTEP 3) |
342 | 312 | (eq! LC 1) |
|
360 | 330 | (- 1 (next IS_TOPIC)) |
361 | 331 | (next IS_DATA))))))))) |
362 | 332 |
|
363 | | -(defconstraint phase5-dataprefix (:guard [PHASE 5]) |
| 333 | +(defconstraint phase5-dataprefix (:guard PHASE_5) |
364 | 334 | (if-eq (* IS_PREFIX IS_DATA) 1 |
365 | 335 | (begin (eq! [INPUT 1] LOCAL_SIZE) |
366 | 336 | (if-zero LOCAL_SIZE |
|
402 | 372 | CT |
403 | 373 | nSTEP |
404 | 374 | DONE |
405 | | - [PHASE 1] |
| 375 | + PHASE_1 |
406 | 376 | ACC_SIZE |
407 | 377 | POWER |
408 | 378 | BIT |
|
416 | 386 | (next IS_TOPIC) |
417 | 387 | (- 1 (next IS_DATA)))))))))) |
418 | 388 |
|
419 | | -(defconstraint phase5-data (:guard [PHASE 5]) |
| 389 | +(defconstraint phase5-data (:guard PHASE_5) |
420 | 390 | (if-zero (+ IS_PREFIX (- 1 IS_DATA)) |
421 | 391 | (begin (eq! INDEX_LOCAL CT) |
422 | 392 | (eq! LC 1) |
|
431 | 401 | (next IS_TOPIC) |
432 | 402 | (next IS_DATA))))))))) |
433 | 403 |
|
434 | | -(defconstraint phase5-logEntrySize-update (:guard [PHASE 5]) |
| 404 | +(defconstraint phase5-logEntrySize-update (:guard PHASE_5) |
435 | 405 | (if-zero (+ (- 1 DEPTH_1) |
436 | 406 | (* IS_PREFIX (- 1 IS_TOPIC) (- 1 IS_DATA))) |
437 | 407 | (eq! LOG_ENTRY_SIZE |
438 | 408 | (- (prev LOG_ENTRY_SIZE) (* LC nBYTES))))) |
439 | 409 |
|
440 | | -(defconstraint phase5-localsize-update (:guard [PHASE 5]) |
| 410 | +(defconstraint phase5-localsize-update (:guard PHASE_5) |
441 | 411 | (if-zero (+ IS_PREFIX |
442 | 412 | (- 1 (+ IS_TOPIC IS_DATA))) |
443 | 413 | (eq! LOCAL_SIZE |
|
0 commit comments