Skip to main content

midnight_onchain_runtime/vendored/
program_fragments.rs

1#[macro_export]
2macro_rules! kernel_claim_zswap_nullifier {
3  ($f:expr_2021, $fcached:expr_2021, $nul:expr_2021) => {
4    [
5      Op::Swap { n: 0.try_into().unwrap() },
6      Op::Idx { cached: true.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(0 as u8).into())].try_into().unwrap() },
7      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($nul.clone().try_into().unwrap())).try_into().unwrap() },
8      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Null.try_into().unwrap() },
9      Op::Ins { cached: true.try_into().unwrap(), n: 2.try_into().unwrap() },
10      Op::Swap { n: 0.try_into().unwrap() },
11    ]
12  };
13}
14pub use kernel_claim_zswap_nullifier;
15#[macro_export]
16macro_rules! kernel_claim_zswap_coin_spend {
17  ($f:expr_2021, $fcached:expr_2021, $note:expr_2021) => {
18    [
19      Op::Swap { n: 0.try_into().unwrap() },
20      Op::Idx { cached: true.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(2 as u8).into())].try_into().unwrap() },
21      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($note.clone().try_into().unwrap())).try_into().unwrap() },
22      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Null.try_into().unwrap() },
23      Op::Ins { cached: true.try_into().unwrap(), n: 2.try_into().unwrap() },
24      Op::Swap { n: 0.try_into().unwrap() },
25    ]
26  };
27}
28pub use kernel_claim_zswap_coin_spend;
29#[macro_export]
30macro_rules! kernel_claim_zswap_coin_receive {
31  ($f:expr_2021, $fcached:expr_2021, $note:expr_2021) => {
32    [
33      Op::Swap { n: 0.try_into().unwrap() },
34      Op::Idx { cached: true.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(1 as u8).into())].try_into().unwrap() },
35      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($note.clone().try_into().unwrap())).try_into().unwrap() },
36      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Null.try_into().unwrap() },
37      Op::Ins { cached: true.try_into().unwrap(), n: 2.try_into().unwrap() },
38      Op::Swap { n: 0.try_into().unwrap() },
39    ]
40  };
41}
42pub use kernel_claim_zswap_coin_receive;
43#[macro_export]
44macro_rules! kernel_claim_contract_call {
45  ($f:expr_2021, $fcached:expr_2021, $addr:expr_2021, $entry_point:expr_2021, $comm:expr_2021) => {
46    [
47      Op::Swap { n: 0.try_into().unwrap() },
48      Op::Idx { cached: true.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(3 as u8).into())].try_into().unwrap() },
49      Op::Dup { n: 0.try_into().unwrap() },
50      Op::Size,
51      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new(AlignedValue::concat([AlignedValue::from($addr.clone()), AlignedValue::from($entry_point.clone()), AlignedValue::from($comm.clone())].iter()).try_into().unwrap())).try_into().unwrap() },
52      Op::Concat { cached: true.try_into().unwrap(), n: 160.try_into().unwrap() },
53      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Null.try_into().unwrap() },
54      Op::Ins { cached: true.try_into().unwrap(), n: 2.try_into().unwrap() },
55      Op::Swap { n: 0.try_into().unwrap() },
56    ]
57  };
58}
59pub use kernel_claim_contract_call;
60#[macro_export]
61macro_rules! kernel_checkpoint {
62  ($f:expr_2021, $fcached:expr_2021) => {
63    [
64      Op::Ckpt,
65    ]
66  };
67}
68pub use kernel_checkpoint;
69#[macro_export]
70macro_rules! kernel_mint {
71  ($f:expr_2021, $fcached:expr_2021, $domain_sep:expr_2021, $amount:expr_2021) => {
72    [
73      Op::Swap { n: 0.try_into().unwrap() },
74      Op::Idx { cached: true.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(4 as u8).into())].try_into().unwrap() },
75      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($domain_sep.clone().try_into().unwrap())).try_into().unwrap() },
76      Op::Dup { n: 1.try_into().unwrap() },
77      Op::Dup { n: 1.try_into().unwrap() },
78      Op::Member,
79      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($amount.clone().try_into().unwrap())).try_into().unwrap() },
80      Op::Swap { n: 0.try_into().unwrap() },
81      Op::Neg,
82      Op::Branch { skip: 4.try_into().unwrap() },
83      Op::Dup { n: 2.try_into().unwrap() },
84      Op::Dup { n: 2.try_into().unwrap() },
85      Op::Idx { cached: true.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Stack].try_into().unwrap() },
86      Op::Add,
87      Op::Ins { cached: true.try_into().unwrap(), n: 2.try_into().unwrap() },
88      Op::Swap { n: 0.try_into().unwrap() },
89    ]
90  };
91}
92pub use kernel_mint;
93#[macro_export]
94macro_rules! kernel_self {
95  ($f:expr_2021, $fcached:expr_2021) => {
96    [
97      Op::Dup { n: 2.try_into().unwrap() },
98      Op::Idx { cached: true.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(0 as u8).into())].try_into().unwrap() },
99      Op::Popeq { cached: true.try_into().unwrap(), result: ().try_into().unwrap() },
100    ]
101  };
102}
103pub use kernel_self;
104#[macro_export]
105macro_rules! Cell_read {
106  ($f:expr_2021, $fcached:expr_2021, $value_type:ty) => {
107    [
108      Op::Dup { n: 0.try_into().unwrap() },
109      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: false.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
110      Op::Popeq { cached: $fcached.try_into().unwrap(), result: ().try_into().unwrap() },
111    ]
112  };
113}
114pub use Cell_read;
115#[macro_export]
116macro_rules! Cell_write {
117  ($f:expr_2021, $fcached:expr_2021, $value_type:ty, $value:expr_2021) => {
118    [
119      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().iter().cloned().rev().collect::<Vec<_>>().iter().cloned().skip(1).collect::<Vec<_>>().iter().cloned().rev().collect::<Vec<_>>().try_into().unwrap() },
120      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($f.clone().iter().cloned().rev().collect::<Vec<_>>()[0].clone().try_into().unwrap())).try_into().unwrap() },
121      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Cell(Sp::new($value.clone().try_into().unwrap())).try_into().unwrap() },
122      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
123      Op::Ins { cached: true.try_into().unwrap(), n: (($f.clone().len() as u8) - 1).try_into().unwrap() },
124    ]
125  };
126}
127pub use Cell_write;
128#[macro_export]
129macro_rules! Cell_reset_to_default {
130  ($f:expr_2021, $fcached:expr_2021, $value_type:ty) => {
131    [
132      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().iter().cloned().rev().collect::<Vec<_>>().iter().cloned().skip(1).collect::<Vec<_>>().iter().cloned().rev().collect::<Vec<_>>().try_into().unwrap() },
133      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($f.clone().iter().cloned().rev().collect::<Vec<_>>()[0].clone().try_into().unwrap())).try_into().unwrap() },
134      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Cell(Sp::new(AlignedValue::from(<$value_type>::default()).try_into().unwrap())).try_into().unwrap() },
135      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
136      Op::Ins { cached: true.try_into().unwrap(), n: (($f.clone().len() as u8) - 1).try_into().unwrap() },
137    ]
138  };
139}
140pub use Cell_reset_to_default;
141#[macro_export]
142macro_rules! Cell_write_coin {
143  ($f:expr_2021, $fcached:expr_2021, $value_type:ty, $coin:expr_2021, $recipient:expr_2021) => {
144    [
145      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().iter().cloned().rev().collect::<Vec<_>>().iter().cloned().skip(1).collect::<Vec<_>>().iter().cloned().rev().collect::<Vec<_>>().try_into().unwrap() },
146      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($f.clone().iter().cloned().rev().collect::<Vec<_>>()[0].clone().try_into().unwrap())).try_into().unwrap() },
147      Op::Dup { n: (3 + ((($f.clone().len() as u8) - 1) * 2)).try_into().unwrap() },
148      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($coin.clone().commitment(&$recipient.clone()).try_into().unwrap())).try_into().unwrap() },
149      Op::Idx { cached: true.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(1 as u8).into()), Key::Stack].try_into().unwrap() },
150      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($coin.clone().try_into().unwrap())).try_into().unwrap() },
151      Op::Swap { n: 0.try_into().unwrap() },
152      Op::Concat { cached: true.try_into().unwrap(), n: 91.try_into().unwrap() },
153      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
154      Op::Ins { cached: true.try_into().unwrap(), n: (($f.clone().len() as u8) - 1).try_into().unwrap() },
155    ]
156  };
157}
158pub use Cell_write_coin;
159#[macro_export]
160macro_rules! Counter_read {
161  ($f:expr_2021, $fcached:expr_2021) => {
162    [
163      Op::Dup { n: 0.try_into().unwrap() },
164      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: false.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
165      Op::Popeq { cached: true.try_into().unwrap(), result: ().try_into().unwrap() },
166    ]
167  };
168}
169pub use Counter_read;
170#[macro_export]
171macro_rules! Counter_less_than {
172  ($f:expr_2021, $fcached:expr_2021, $threshold:expr_2021) => {
173    [
174      Op::Dup { n: 0.try_into().unwrap() },
175      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: false.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
176      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($threshold.clone().try_into().unwrap())).try_into().unwrap() },
177      Op::Lt,
178      Op::Popeq { cached: true.try_into().unwrap(), result: ().try_into().unwrap() },
179    ]
180  };
181}
182pub use Counter_less_than;
183#[macro_export]
184macro_rules! Counter_increment {
185  ($f:expr_2021, $fcached:expr_2021, $amount:expr_2021) => {
186    [
187      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
188      Op::Addi { immediate: u32::try_from($amount.clone()).unwrap().try_into().unwrap() },
189      Op::Ins { cached: true.try_into().unwrap(), n: ($f.clone().len() as u8).try_into().unwrap() },
190    ]
191  };
192}
193pub use Counter_increment;
194#[macro_export]
195macro_rules! Counter_decrement {
196  ($f:expr_2021, $fcached:expr_2021, $amount:expr_2021) => {
197    [
198      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
199      Op::Subi { immediate: u32::try_from($amount.clone()).unwrap().try_into().unwrap() },
200      Op::Ins { cached: true.try_into().unwrap(), n: ($f.clone().len() as u8).try_into().unwrap() },
201    ]
202  };
203}
204pub use Counter_decrement;
205#[macro_export]
206macro_rules! Counter_reset_to_default {
207  ($f:expr_2021, $fcached:expr_2021) => {
208    [
209      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().iter().cloned().rev().collect::<Vec<_>>().iter().cloned().skip(1).collect::<Vec<_>>().iter().cloned().rev().collect::<Vec<_>>().try_into().unwrap() },
210      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($f.clone().iter().cloned().rev().collect::<Vec<_>>()[0].clone().try_into().unwrap())).try_into().unwrap() },
211      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Cell(Sp::new(AlignedValue::from(0 as u64).try_into().unwrap())).try_into().unwrap() },
212      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
213      Op::Ins { cached: true.try_into().unwrap(), n: (($f.clone().len() as u8) - 1).try_into().unwrap() },
214    ]
215  };
216}
217pub use Counter_reset_to_default;
218#[macro_export]
219macro_rules! Set_reset_to_default {
220  ($f:expr_2021, $fcached:expr_2021, $value_type:ty) => {
221    [
222      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().iter().cloned().rev().collect::<Vec<_>>().iter().cloned().skip(1).collect::<Vec<_>>().iter().cloned().rev().collect::<Vec<_>>().try_into().unwrap() },
223      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($f.clone().iter().cloned().rev().collect::<Vec<_>>()[0].clone().try_into().unwrap())).try_into().unwrap() },
224      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Map([].iter().cloned().collect()).try_into().unwrap() },
225      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
226      Op::Ins { cached: true.try_into().unwrap(), n: (($f.clone().len() as u8) - 1).try_into().unwrap() },
227    ]
228  };
229}
230pub use Set_reset_to_default;
231#[macro_export]
232macro_rules! Set_is_empty {
233  ($f:expr_2021, $fcached:expr_2021, $value_type:ty) => {
234    [
235      Op::Dup { n: 0.try_into().unwrap() },
236      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: false.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
237      Op::Size,
238      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new(AlignedValue::from(0 as u64).try_into().unwrap())).try_into().unwrap() },
239      Op::Eq,
240      Op::Popeq { cached: true.try_into().unwrap(), result: ().try_into().unwrap() },
241    ]
242  };
243}
244pub use Set_is_empty;
245#[macro_export]
246macro_rules! Set_size {
247  ($f:expr_2021, $fcached:expr_2021, $value_type:ty) => {
248    [
249      Op::Dup { n: 0.try_into().unwrap() },
250      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: false.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
251      Op::Size,
252      Op::Popeq { cached: true.try_into().unwrap(), result: ().try_into().unwrap() },
253    ]
254  };
255}
256pub use Set_size;
257#[macro_export]
258macro_rules! Set_member {
259  ($f:expr_2021, $fcached:expr_2021, $value_type:ty, $elem:expr_2021) => {
260    [
261      Op::Dup { n: 0.try_into().unwrap() },
262      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: false.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
263      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($elem.clone().try_into().unwrap())).try_into().unwrap() },
264      Op::Member,
265      Op::Popeq { cached: true.try_into().unwrap(), result: ().try_into().unwrap() },
266    ]
267  };
268}
269pub use Set_member;
270#[macro_export]
271macro_rules! Set_insert {
272  ($f:expr_2021, $fcached:expr_2021, $value_type:ty, $elem:expr_2021) => {
273    [
274      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
275      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($elem.clone().try_into().unwrap())).try_into().unwrap() },
276      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Null.try_into().unwrap() },
277      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
278      Op::Ins { cached: true.try_into().unwrap(), n: ($f.clone().len() as u8).try_into().unwrap() },
279    ]
280  };
281}
282pub use Set_insert;
283#[macro_export]
284macro_rules! Set_remove {
285  ($f:expr_2021, $fcached:expr_2021, $value_type:ty, $elem:expr_2021) => {
286    [
287      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
288      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($elem.clone().try_into().unwrap())).try_into().unwrap() },
289      Op::Rem { cached: false.try_into().unwrap() },
290      Op::Ins { cached: true.try_into().unwrap(), n: ($f.clone().len() as u8).try_into().unwrap() },
291    ]
292  };
293}
294pub use Set_remove;
295#[macro_export]
296macro_rules! Set_insert_coin {
297  ($f:expr_2021, $fcached:expr_2021, $value_type:ty, $coin:expr_2021, $recipient:expr_2021) => {
298    [
299      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
300      Op::Dup { n: (2 + (($f.clone().len() as u8) * 2)).try_into().unwrap() },
301      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($coin.clone().commitment(&$recipient.clone()).try_into().unwrap())).try_into().unwrap() },
302      Op::Idx { cached: true.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(1 as u8).into()), Key::Stack].try_into().unwrap() },
303      Op::Concat { cached: true.try_into().unwrap(), n: 91.try_into().unwrap() },
304      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($coin.clone().try_into().unwrap())).try_into().unwrap() },
305      Op::Swap { n: 0.try_into().unwrap() },
306      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Null.try_into().unwrap() },
307      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
308      Op::Ins { cached: true.try_into().unwrap(), n: ($f.clone().len() as u8).try_into().unwrap() },
309    ]
310  };
311}
312pub use Set_insert_coin;
313#[macro_export]
314macro_rules! Map_reset_to_default {
315  ($f:expr_2021, $fcached:expr_2021, $key_type:ty, $value_type:ty) => {
316    [
317      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().iter().cloned().rev().collect::<Vec<_>>().iter().cloned().skip(1).collect::<Vec<_>>().iter().cloned().rev().collect::<Vec<_>>().try_into().unwrap() },
318      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($f.clone().iter().cloned().rev().collect::<Vec<_>>()[0].clone().try_into().unwrap())).try_into().unwrap() },
319      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Map([].iter().cloned().collect()).try_into().unwrap() },
320      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
321      Op::Ins { cached: true.try_into().unwrap(), n: (($f.clone().len() as u8) - 1).try_into().unwrap() },
322    ]
323  };
324}
325pub use Map_reset_to_default;
326#[macro_export]
327macro_rules! Map_is_empty {
328  ($f:expr_2021, $fcached:expr_2021, $key_type:ty, $value_type:ty) => {
329    [
330      Op::Dup { n: 0.try_into().unwrap() },
331      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: false.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
332      Op::Size,
333      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new(AlignedValue::from(0 as u64).try_into().unwrap())).try_into().unwrap() },
334      Op::Eq,
335      Op::Popeq { cached: true.try_into().unwrap(), result: ().try_into().unwrap() },
336    ]
337  };
338}
339pub use Map_is_empty;
340#[macro_export]
341macro_rules! Map_size {
342  ($f:expr_2021, $fcached:expr_2021, $key_type:ty, $value_type:ty) => {
343    [
344      Op::Dup { n: 0.try_into().unwrap() },
345      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: false.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
346      Op::Size,
347      Op::Popeq { cached: true.try_into().unwrap(), result: ().try_into().unwrap() },
348    ]
349  };
350}
351pub use Map_size;
352#[macro_export]
353macro_rules! Map_member {
354  ($f:expr_2021, $fcached:expr_2021, $key_type:ty, $value_type:ty, $key:expr_2021) => {
355    [
356      Op::Dup { n: 0.try_into().unwrap() },
357      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: false.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
358      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($key.clone().try_into().unwrap())).try_into().unwrap() },
359      Op::Member,
360      Op::Popeq { cached: true.try_into().unwrap(), result: ().try_into().unwrap() },
361    ]
362  };
363}
364pub use Map_member;
365#[macro_export]
366macro_rules! Map_lookup {
367  ($f:expr_2021, $fcached:expr_2021, $key_type:ty, $value_type:ty, $key:expr_2021) => {
368    [
369      Op::Dup { n: 0.try_into().unwrap() },
370      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: false.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
371      Op::Idx { cached: false.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Value($key.clone().into())].try_into().unwrap() },
372      Op::Popeq { cached: false.try_into().unwrap(), result: ().try_into().unwrap() },
373    ]
374  };
375}
376pub use Map_lookup;
377#[macro_export]
378macro_rules! Map_insert {
379  ($f:expr_2021, $fcached:expr_2021, $key_type:ty, $value_type:ty, $key:expr_2021, $value:expr_2021) => {
380    [
381      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
382      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($key.clone().try_into().unwrap())).try_into().unwrap() },
383      Op::Push { storage: true.try_into().unwrap(), value: StateValue::from($value.clone()).try_into().unwrap() },
384      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
385      Op::Ins { cached: true.try_into().unwrap(), n: ($f.clone().len() as u8).try_into().unwrap() },
386    ]
387  };
388}
389pub use Map_insert;
390#[macro_export]
391macro_rules! Map_insert_default {
392  ($f:expr_2021, $fcached:expr_2021, $key_type:ty, $value_type:ty, $key:expr_2021) => {
393    [
394      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
395      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($key.clone().try_into().unwrap())).try_into().unwrap() },
396      Op::Push { storage: true.try_into().unwrap(), value: StateValue::from(AlignedValue::from(<$value_type>::default())).try_into().unwrap() },
397      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
398      Op::Ins { cached: true.try_into().unwrap(), n: ($f.clone().len() as u8).try_into().unwrap() },
399    ]
400  };
401}
402pub use Map_insert_default;
403#[macro_export]
404macro_rules! Map_remove {
405  ($f:expr_2021, $fcached:expr_2021, $key_type:ty, $value_type:ty, $key:expr_2021) => {
406    [
407      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
408      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($key.clone().try_into().unwrap())).try_into().unwrap() },
409      Op::Rem { cached: false.try_into().unwrap() },
410      Op::Ins { cached: true.try_into().unwrap(), n: ($f.clone().len() as u8).try_into().unwrap() },
411    ]
412  };
413}
414pub use Map_remove;
415#[macro_export]
416macro_rules! Map_insert_coin {
417  ($f:expr_2021, $fcached:expr_2021, $key_type:ty, $value_type:ty, $key:expr_2021, $coin:expr_2021, $recipient:expr_2021) => {
418    [
419      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
420      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($key.clone().try_into().unwrap())).try_into().unwrap() },
421      Op::Dup { n: (2 + (($f.clone().len() as u8) * 2)).try_into().unwrap() },
422      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($coin.clone().commitment(&$recipient.clone()).try_into().unwrap())).try_into().unwrap() },
423      Op::Idx { cached: true.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(1 as u8).into()), Key::Stack].try_into().unwrap() },
424      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($coin.clone().try_into().unwrap())).try_into().unwrap() },
425      Op::Swap { n: 0.try_into().unwrap() },
426      Op::Concat { cached: true.try_into().unwrap(), n: 91.try_into().unwrap() },
427      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
428      Op::Ins { cached: true.try_into().unwrap(), n: ($f.clone().len() as u8).try_into().unwrap() },
429    ]
430  };
431}
432pub use Map_insert_coin;
433#[macro_export]
434macro_rules! List_reset_to_default {
435  ($f:expr_2021, $fcached:expr_2021, $value_type:ty) => {
436    [
437      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().iter().cloned().rev().collect::<Vec<_>>().iter().cloned().skip(1).collect::<Vec<_>>().iter().cloned().rev().collect::<Vec<_>>().try_into().unwrap() },
438      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($f.clone().iter().cloned().rev().collect::<Vec<_>>()[0].clone().try_into().unwrap())).try_into().unwrap() },
439      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Array(vec![StateValue::Null, StateValue::Null, StateValue::Cell(Sp::new(AlignedValue::from(0 as u64).try_into().unwrap()))].into()).try_into().unwrap() },
440      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
441      Op::Ins { cached: true.try_into().unwrap(), n: (($f.clone().len() as u8) - 1).try_into().unwrap() },
442    ]
443  };
444}
445pub use List_reset_to_default;
446#[macro_export]
447macro_rules! List_is_empty {
448  ($f:expr_2021, $fcached:expr_2021, $value_type:ty) => {
449    [
450      Op::Dup { n: 0.try_into().unwrap() },
451      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: false.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
452      Op::Idx { cached: false.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(1 as u8).into())].try_into().unwrap() },
453      Op::Type,
454      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new(AlignedValue::from(1 as u8).try_into().unwrap())).try_into().unwrap() },
455      Op::Eq,
456      Op::Popeq { cached: true.try_into().unwrap(), result: ().try_into().unwrap() },
457    ]
458  };
459}
460pub use List_is_empty;
461#[macro_export]
462macro_rules! List_length {
463  ($f:expr_2021, $fcached:expr_2021, $value_type:ty) => {
464    [
465      Op::Dup { n: 0.try_into().unwrap() },
466      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: false.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
467      Op::Idx { cached: false.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(2 as u8).into())].try_into().unwrap() },
468      Op::Popeq { cached: true.try_into().unwrap(), result: ().try_into().unwrap() },
469    ]
470  };
471}
472pub use List_length;
473#[macro_export]
474macro_rules! List_head {
475  ($f:expr_2021, $fcached:expr_2021, $value_type:ty) => {
476    [
477      Op::Dup { n: 0.try_into().unwrap() },
478      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: false.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
479      Op::Idx { cached: false.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(0 as u8).into())].try_into().unwrap() },
480      Op::Dup { n: 0.try_into().unwrap() },
481      Op::Type,
482      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new(AlignedValue::from(1 as u8).try_into().unwrap())).try_into().unwrap() },
483      Op::Eq,
484      Op::Branch { skip: 4.try_into().unwrap() },
485      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new(AlignedValue::from(1 as u8).try_into().unwrap())).try_into().unwrap() },
486      Op::Swap { n: 0.try_into().unwrap() },
487      Op::Concat { cached: false.try_into().unwrap(), n: (2 + (<$value_type>::alignment().max_aligned_size() as u32)).try_into().unwrap() },
488      Op::Jmp { skip: 2.try_into().unwrap() },
489      Op::Pop,
490      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new(AlignedValue::concat([AlignedValue::from(AlignedValue::from(0 as u8)), AlignedValue::from(AlignedValue::from(<$value_type>::default()))].iter()).try_into().unwrap())).try_into().unwrap() },
491      Op::Popeq { cached: true.try_into().unwrap(), result: ().try_into().unwrap() },
492    ]
493  };
494}
495pub use List_head;
496#[macro_export]
497macro_rules! List_pop_front {
498  ($f:expr_2021, $fcached:expr_2021, $value_type:ty) => {
499    [
500      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
501      Op::Idx { cached: false.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(1 as u8).into())].try_into().unwrap() },
502      Op::Ins { cached: true.try_into().unwrap(), n: ($f.clone().len() as u8).try_into().unwrap() },
503    ]
504  };
505}
506pub use List_pop_front;
507#[macro_export]
508macro_rules! List_push_front {
509  ($f:expr_2021, $fcached:expr_2021, $value_type:ty, $value:expr_2021) => {
510    [
511      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
512      Op::Dup { n: 0.try_into().unwrap() },
513      Op::Idx { cached: false.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(2 as u8).into())].try_into().unwrap() },
514      Op::Addi { immediate: 1.try_into().unwrap() },
515      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Array(vec![StateValue::Cell(Sp::new($value.clone().try_into().unwrap())), StateValue::Null, StateValue::Null].into()).try_into().unwrap() },
516      Op::Swap { n: 0.try_into().unwrap() },
517      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new(AlignedValue::from(2 as u8).try_into().unwrap())).try_into().unwrap() },
518      Op::Swap { n: 0.try_into().unwrap() },
519      Op::Ins { cached: true.try_into().unwrap(), n: 1.try_into().unwrap() },
520      Op::Swap { n: 0.try_into().unwrap() },
521      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new(AlignedValue::from(1 as u8).try_into().unwrap())).try_into().unwrap() },
522      Op::Swap { n: 0.try_into().unwrap() },
523      Op::Ins { cached: true.try_into().unwrap(), n: (($f.clone().len() as u8) + 1).try_into().unwrap() },
524    ]
525  };
526}
527pub use List_push_front;
528#[macro_export]
529macro_rules! List_push_front_coin {
530  ($f:expr_2021, $fcached:expr_2021, $value_type:ty, $coin:expr_2021, $recipient:expr_2021) => {
531    [
532      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
533      Op::Dup { n: 0.try_into().unwrap() },
534      Op::Idx { cached: false.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(2 as u8).into())].try_into().unwrap() },
535      Op::Addi { immediate: 1.try_into().unwrap() },
536      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new(AlignedValue::from(0 as u8).try_into().unwrap())).try_into().unwrap() },
537      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Array(vec![StateValue::Null, StateValue::Null, StateValue::Null].into()).try_into().unwrap() },
538      Op::Dup { n: (4 + (($f.clone().len() as u8) * 2)).try_into().unwrap() },
539      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($coin.clone().commitment(&$recipient.clone()).try_into().unwrap())).try_into().unwrap() },
540      Op::Idx { cached: true.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(1 as u8).into()), Key::Stack].try_into().unwrap() },
541      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($coin.clone().try_into().unwrap())).try_into().unwrap() },
542      Op::Swap { n: 0.try_into().unwrap() },
543      Op::Concat { cached: true.try_into().unwrap(), n: 91.try_into().unwrap() },
544      Op::Ins { cached: true.try_into().unwrap(), n: 1.try_into().unwrap() },
545      Op::Swap { n: 0.try_into().unwrap() },
546      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new(AlignedValue::from(2 as u8).try_into().unwrap())).try_into().unwrap() },
547      Op::Swap { n: 0.try_into().unwrap() },
548      Op::Ins { cached: true.try_into().unwrap(), n: 1.try_into().unwrap() },
549      Op::Swap { n: 0.try_into().unwrap() },
550      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new(AlignedValue::from(1 as u8).try_into().unwrap())).try_into().unwrap() },
551      Op::Swap { n: 0.try_into().unwrap() },
552      Op::Ins { cached: true.try_into().unwrap(), n: (($f.clone().len() as u8) + 1).try_into().unwrap() },
553    ]
554  };
555}
556pub use List_push_front_coin;
557#[macro_export]
558macro_rules! MerkleTree_reset_to_default {
559  ($f:expr_2021, $fcached:expr_2021, $nat:literal, $value_type:ty) => {
560    [
561      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().iter().cloned().rev().collect::<Vec<_>>().iter().cloned().skip(1).collect::<Vec<_>>().iter().cloned().rev().collect::<Vec<_>>().try_into().unwrap() },
562      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($f.clone().iter().cloned().rev().collect::<Vec<_>>()[0].clone().try_into().unwrap())).try_into().unwrap() },
563      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Array(vec![StateValue::BoundedMerkleTree(MerkleTree::blank($nat)), StateValue::Cell(Sp::new(AlignedValue::from(0 as u64).try_into().unwrap()))].into()).try_into().unwrap() },
564      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
565      Op::Ins { cached: true.try_into().unwrap(), n: (($f.clone().len() as u8) - 1).try_into().unwrap() },
566    ]
567  };
568}
569pub use MerkleTree_reset_to_default;
570#[macro_export]
571macro_rules! MerkleTree_is_full {
572  ($f:expr_2021, $fcached:expr_2021, $nat:literal, $value_type:ty) => {
573    [
574      Op::Dup { n: 0.try_into().unwrap() },
575      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: false.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
576      Op::Idx { cached: false.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(1 as u8).into())].try_into().unwrap() },
577      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new(AlignedValue::from((2 as u64).pow($nat) as u64).try_into().unwrap())).try_into().unwrap() },
578      Op::Lt,
579      Op::Neg,
580      Op::Popeq { cached: true.try_into().unwrap(), result: ().try_into().unwrap() },
581    ]
582  };
583}
584pub use MerkleTree_is_full;
585#[macro_export]
586macro_rules! MerkleTree_check_root {
587  ($f:expr_2021, $fcached:expr_2021, $nat:literal, $value_type:ty, $rt:expr_2021) => {
588    [
589      Op::Dup { n: 0.try_into().unwrap() },
590      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: false.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
591      Op::Idx { cached: false.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(0 as u8).into())].try_into().unwrap() },
592      Op::Root,
593      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($rt.clone().try_into().unwrap())).try_into().unwrap() },
594      Op::Eq,
595      Op::Popeq { cached: true.try_into().unwrap(), result: ().try_into().unwrap() },
596    ]
597  };
598}
599pub use MerkleTree_check_root;
600#[macro_export]
601macro_rules! MerkleTree_insert {
602  ($f:expr_2021, $fcached:expr_2021, $nat:literal, $value_type:ty, $item:expr_2021) => {
603    [
604      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
605      Op::Idx { cached: false.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(0 as u8).into())].try_into().unwrap() },
606      Op::Dup { n: 2.try_into().unwrap() },
607      Op::Idx { cached: false.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(1 as u8).into())].try_into().unwrap() },
608      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Cell(Sp::new(leaf_hash(&ValueReprAlignedValue(AlignedValue::from($item.clone()))).try_into().unwrap())).try_into().unwrap() },
609      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
610      Op::Ins { cached: true.try_into().unwrap(), n: 1.try_into().unwrap() },
611      Op::Idx { cached: false.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(1 as u8).into())].try_into().unwrap() },
612      Op::Addi { immediate: 1.try_into().unwrap() },
613      Op::Ins { cached: true.try_into().unwrap(), n: (($f.clone().len() as u8) + 1).try_into().unwrap() },
614    ]
615  };
616}
617pub use MerkleTree_insert;
618#[macro_export]
619macro_rules! MerkleTree_insert_index {
620  ($f:expr_2021, $fcached:expr_2021, $nat:literal, $value_type:ty, $item:expr_2021, $index:expr_2021) => {
621    [
622      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
623      Op::Idx { cached: false.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(0 as u8).into())].try_into().unwrap() },
624      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($index.clone().try_into().unwrap())).try_into().unwrap() },
625      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Cell(Sp::new(leaf_hash(&ValueReprAlignedValue(AlignedValue::from($item.clone()))).try_into().unwrap())).try_into().unwrap() },
626      Op::Ins { cached: false.try_into().unwrap(), n: 2.try_into().unwrap() },
627      Op::Idx { cached: false.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(1 as u8).into())].try_into().unwrap() },
628      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($index.clone().try_into().unwrap())).try_into().unwrap() },
629      Op::Addi { immediate: 1.try_into().unwrap() },
630      Op::Dup { n: 1.try_into().unwrap() },
631      Op::Dup { n: 1.try_into().unwrap() },
632      Op::Lt,
633      Op::Branch { skip: 2.try_into().unwrap() },
634      Op::Pop,
635      Op::Jmp { skip: 2.try_into().unwrap() },
636      Op::Swap { n: 0.try_into().unwrap() },
637      Op::Pop,
638      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
639      Op::Ins { cached: true.try_into().unwrap(), n: ($f.clone().len() as u8).try_into().unwrap() },
640    ]
641  };
642}
643pub use MerkleTree_insert_index;
644#[macro_export]
645macro_rules! MerkleTree_insert_hash {
646  ($f:expr_2021, $fcached:expr_2021, $nat:literal, $value_type:ty, $hash:expr_2021) => {
647    [
648      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
649      Op::Idx { cached: false.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(0 as u8).into())].try_into().unwrap() },
650      Op::Dup { n: 2.try_into().unwrap() },
651      Op::Idx { cached: false.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(1 as u8).into())].try_into().unwrap() },
652      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Cell(Sp::new($hash.clone().try_into().unwrap())).try_into().unwrap() },
653      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
654      Op::Ins { cached: true.try_into().unwrap(), n: 1.try_into().unwrap() },
655      Op::Idx { cached: false.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(1 as u8).into())].try_into().unwrap() },
656      Op::Addi { immediate: 1.try_into().unwrap() },
657      Op::Ins { cached: true.try_into().unwrap(), n: (($f.clone().len() as u8) + 1).try_into().unwrap() },
658    ]
659  };
660}
661pub use MerkleTree_insert_hash;
662#[macro_export]
663macro_rules! MerkleTree_insert_hash_index {
664  ($f:expr_2021, $fcached:expr_2021, $nat:literal, $value_type:ty, $hash:expr_2021, $index:expr_2021) => {
665    [
666      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
667      Op::Idx { cached: false.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(0 as u8).into())].try_into().unwrap() },
668      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($index.clone().try_into().unwrap())).try_into().unwrap() },
669      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Cell(Sp::new($hash.clone().try_into().unwrap())).try_into().unwrap() },
670      Op::Ins { cached: false.try_into().unwrap(), n: 2.try_into().unwrap() },
671      Op::Idx { cached: false.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(1 as u8).into())].try_into().unwrap() },
672      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($index.clone().try_into().unwrap())).try_into().unwrap() },
673      Op::Addi { immediate: 1.try_into().unwrap() },
674      Op::Dup { n: 1.try_into().unwrap() },
675      Op::Dup { n: 1.try_into().unwrap() },
676      Op::Lt,
677      Op::Branch { skip: 2.try_into().unwrap() },
678      Op::Pop,
679      Op::Jmp { skip: 2.try_into().unwrap() },
680      Op::Swap { n: 0.try_into().unwrap() },
681      Op::Pop,
682      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
683      Op::Ins { cached: true.try_into().unwrap(), n: ($f.clone().len() as u8).try_into().unwrap() },
684    ]
685  };
686}
687pub use MerkleTree_insert_hash_index;
688#[macro_export]
689macro_rules! MerkleTree_insert_index_default {
690  ($f:expr_2021, $fcached:expr_2021, $nat:literal, $value_type:ty, $index:expr_2021) => {
691    [
692      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
693      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($index.clone().try_into().unwrap())).try_into().unwrap() },
694      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Cell(Sp::new(leaf_hash(&ValueReprAlignedValue(AlignedValue::from(AlignedValue::from(<$value_type>::default())))).try_into().unwrap())).try_into().unwrap() },
695      Op::Ins { cached: false.try_into().unwrap(), n: 2.try_into().unwrap() },
696      Op::Idx { cached: false.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(1 as u8).into())].try_into().unwrap() },
697      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($index.clone().try_into().unwrap())).try_into().unwrap() },
698      Op::Addi { immediate: 1.try_into().unwrap() },
699      Op::Dup { n: 1.try_into().unwrap() },
700      Op::Dup { n: 1.try_into().unwrap() },
701      Op::Lt,
702      Op::Branch { skip: 2.try_into().unwrap() },
703      Op::Pop,
704      Op::Jmp { skip: 2.try_into().unwrap() },
705      Op::Swap { n: 0.try_into().unwrap() },
706      Op::Pop,
707      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
708      Op::Ins { cached: true.try_into().unwrap(), n: ($f.clone().len() as u8).try_into().unwrap() },
709    ]
710  };
711}
712pub use MerkleTree_insert_index_default;
713#[macro_export]
714macro_rules! HistoricMerkleTree_reset_to_default {
715  ($f:expr_2021, $fcached:expr_2021, $nat:literal, $value_type:ty) => {
716    [
717      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().iter().cloned().rev().collect::<Vec<_>>().iter().cloned().skip(1).collect::<Vec<_>>().iter().cloned().rev().collect::<Vec<_>>().try_into().unwrap() },
718      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($f.clone().iter().cloned().rev().collect::<Vec<_>>()[0].clone().try_into().unwrap())).try_into().unwrap() },
719      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Array(vec![StateValue::BoundedMerkleTree(MerkleTree::blank($nat)), StateValue::Cell(Sp::new(AlignedValue::from(0 as u64).try_into().unwrap())), StateValue::Map([].iter().cloned().collect())].into()).try_into().unwrap() },
720      Op::Idx { cached: false.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(2 as u8).into())].try_into().unwrap() },
721      Op::Dup { n: 2.try_into().unwrap() },
722      Op::Idx { cached: false.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(0 as u8).into())].try_into().unwrap() },
723      Op::Root,
724      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Null.try_into().unwrap() },
725      Op::Ins { cached: true.try_into().unwrap(), n: 2.try_into().unwrap() },
726      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
727      Op::Ins { cached: true.try_into().unwrap(), n: (($f.clone().len() as u8) - 1).try_into().unwrap() },
728    ]
729  };
730}
731pub use HistoricMerkleTree_reset_to_default;
732#[macro_export]
733macro_rules! HistoricMerkleTree_is_full {
734  ($f:expr_2021, $fcached:expr_2021, $nat:literal, $value_type:ty) => {
735    [
736      Op::Dup { n: 0.try_into().unwrap() },
737      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: false.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
738      Op::Idx { cached: false.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(1 as u8).into())].try_into().unwrap() },
739      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new(AlignedValue::from((2 as u64).pow($nat) as u64).try_into().unwrap())).try_into().unwrap() },
740      Op::Lt,
741      Op::Neg,
742      Op::Popeq { cached: true.try_into().unwrap(), result: ().try_into().unwrap() },
743    ]
744  };
745}
746pub use HistoricMerkleTree_is_full;
747#[macro_export]
748macro_rules! HistoricMerkleTree_check_root {
749  ($f:expr_2021, $fcached:expr_2021, $nat:literal, $value_type:ty, $rt:expr_2021) => {
750    [
751      Op::Dup { n: 0.try_into().unwrap() },
752      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: false.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
753      Op::Idx { cached: false.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(2 as u8).into())].try_into().unwrap() },
754      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($rt.clone().try_into().unwrap())).try_into().unwrap() },
755      Op::Member,
756      Op::Popeq { cached: true.try_into().unwrap(), result: ().try_into().unwrap() },
757    ]
758  };
759}
760pub use HistoricMerkleTree_check_root;
761#[macro_export]
762macro_rules! HistoricMerkleTree_insert {
763  ($f:expr_2021, $fcached:expr_2021, $nat:literal, $value_type:ty, $item:expr_2021) => {
764    [
765      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
766      Op::Idx { cached: false.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(0 as u8).into())].try_into().unwrap() },
767      Op::Dup { n: 2.try_into().unwrap() },
768      Op::Idx { cached: false.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(1 as u8).into())].try_into().unwrap() },
769      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Cell(Sp::new(leaf_hash(&ValueReprAlignedValue(AlignedValue::from($item.clone()))).try_into().unwrap())).try_into().unwrap() },
770      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
771      Op::Ins { cached: true.try_into().unwrap(), n: 1.try_into().unwrap() },
772      Op::Idx { cached: false.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(1 as u8).into())].try_into().unwrap() },
773      Op::Addi { immediate: 1.try_into().unwrap() },
774      Op::Ins { cached: true.try_into().unwrap(), n: 1.try_into().unwrap() },
775      Op::Idx { cached: false.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(2 as u8).into())].try_into().unwrap() },
776      Op::Dup { n: 2.try_into().unwrap() },
777      Op::Idx { cached: false.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(0 as u8).into())].try_into().unwrap() },
778      Op::Root,
779      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Null.try_into().unwrap() },
780      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
781      Op::Ins { cached: true.try_into().unwrap(), n: (($f.clone().len() as u8) + 1).try_into().unwrap() },
782    ]
783  };
784}
785pub use HistoricMerkleTree_insert;
786#[macro_export]
787macro_rules! HistoricMerkleTree_insert_index {
788  ($f:expr_2021, $fcached:expr_2021, $nat:literal, $value_type:ty, $item:expr_2021, $index:expr_2021) => {
789    [
790      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
791      Op::Idx { cached: false.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(0 as u8).into())].try_into().unwrap() },
792      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($index.clone().try_into().unwrap())).try_into().unwrap() },
793      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Cell(Sp::new(leaf_hash(&ValueReprAlignedValue(AlignedValue::from($item.clone()))).try_into().unwrap())).try_into().unwrap() },
794      Op::Ins { cached: false.try_into().unwrap(), n: 2.try_into().unwrap() },
795      Op::Idx { cached: false.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(1 as u8).into())].try_into().unwrap() },
796      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($index.clone().try_into().unwrap())).try_into().unwrap() },
797      Op::Addi { immediate: 1.try_into().unwrap() },
798      Op::Dup { n: 1.try_into().unwrap() },
799      Op::Dup { n: 1.try_into().unwrap() },
800      Op::Lt,
801      Op::Branch { skip: 2.try_into().unwrap() },
802      Op::Pop,
803      Op::Jmp { skip: 2.try_into().unwrap() },
804      Op::Swap { n: 0.try_into().unwrap() },
805      Op::Pop,
806      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
807      Op::Idx { cached: false.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(2 as u8).into())].try_into().unwrap() },
808      Op::Dup { n: 2.try_into().unwrap() },
809      Op::Idx { cached: false.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(0 as u8).into())].try_into().unwrap() },
810      Op::Root,
811      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Null.try_into().unwrap() },
812      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
813      Op::Ins { cached: true.try_into().unwrap(), n: (($f.clone().len() as u8) + 1).try_into().unwrap() },
814    ]
815  };
816}
817pub use HistoricMerkleTree_insert_index;
818#[macro_export]
819macro_rules! HistoricMerkleTree_insert_hash {
820  ($f:expr_2021, $fcached:expr_2021, $nat:literal, $value_type:ty, $hash:expr_2021) => {
821    [
822      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
823      Op::Idx { cached: false.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(0 as u8).into())].try_into().unwrap() },
824      Op::Dup { n: 2.try_into().unwrap() },
825      Op::Idx { cached: false.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(1 as u8).into())].try_into().unwrap() },
826      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Cell(Sp::new($hash.clone().try_into().unwrap())).try_into().unwrap() },
827      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
828      Op::Ins { cached: true.try_into().unwrap(), n: 1.try_into().unwrap() },
829      Op::Idx { cached: false.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(1 as u8).into())].try_into().unwrap() },
830      Op::Addi { immediate: 1.try_into().unwrap() },
831      Op::Ins { cached: true.try_into().unwrap(), n: 1.try_into().unwrap() },
832      Op::Idx { cached: false.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(2 as u8).into())].try_into().unwrap() },
833      Op::Dup { n: 2.try_into().unwrap() },
834      Op::Idx { cached: false.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(0 as u8).into())].try_into().unwrap() },
835      Op::Root,
836      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Null.try_into().unwrap() },
837      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
838      Op::Ins { cached: true.try_into().unwrap(), n: (($f.clone().len() as u8) + 1).try_into().unwrap() },
839    ]
840  };
841}
842pub use HistoricMerkleTree_insert_hash;
843#[macro_export]
844macro_rules! HistoricMerkleTree_insert_hash_index {
845  ($f:expr_2021, $fcached:expr_2021, $nat:literal, $value_type:ty, $hash:expr_2021, $index:expr_2021) => {
846    [
847      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
848      Op::Idx { cached: false.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(0 as u8).into())].try_into().unwrap() },
849      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($index.clone().try_into().unwrap())).try_into().unwrap() },
850      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Cell(Sp::new($hash.clone().try_into().unwrap())).try_into().unwrap() },
851      Op::Ins { cached: false.try_into().unwrap(), n: 2.try_into().unwrap() },
852      Op::Idx { cached: false.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(1 as u8).into())].try_into().unwrap() },
853      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($index.clone().try_into().unwrap())).try_into().unwrap() },
854      Op::Addi { immediate: 1.try_into().unwrap() },
855      Op::Dup { n: 1.try_into().unwrap() },
856      Op::Dup { n: 1.try_into().unwrap() },
857      Op::Lt,
858      Op::Branch { skip: 2.try_into().unwrap() },
859      Op::Pop,
860      Op::Jmp { skip: 2.try_into().unwrap() },
861      Op::Swap { n: 0.try_into().unwrap() },
862      Op::Pop,
863      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
864      Op::Idx { cached: false.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(2 as u8).into())].try_into().unwrap() },
865      Op::Dup { n: 2.try_into().unwrap() },
866      Op::Idx { cached: false.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(0 as u8).into())].try_into().unwrap() },
867      Op::Root,
868      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Null.try_into().unwrap() },
869      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
870      Op::Ins { cached: true.try_into().unwrap(), n: (($f.clone().len() as u8) + 1).try_into().unwrap() },
871    ]
872  };
873}
874pub use HistoricMerkleTree_insert_hash_index;
875#[macro_export]
876macro_rules! HistoricMerkleTree_insert_index_default {
877  ($f:expr_2021, $fcached:expr_2021, $nat:literal, $value_type:ty, $index:expr_2021) => {
878    [
879      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
880      Op::Idx { cached: false.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(0 as u8).into())].try_into().unwrap() },
881      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($index.clone().try_into().unwrap())).try_into().unwrap() },
882      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Cell(Sp::new(leaf_hash(&ValueReprAlignedValue(AlignedValue::from(AlignedValue::from(<$value_type>::default())))).try_into().unwrap())).try_into().unwrap() },
883      Op::Ins { cached: false.try_into().unwrap(), n: 2.try_into().unwrap() },
884      Op::Idx { cached: false.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(1 as u8).into())].try_into().unwrap() },
885      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new($index.clone().try_into().unwrap())).try_into().unwrap() },
886      Op::Addi { immediate: 1.try_into().unwrap() },
887      Op::Dup { n: 1.try_into().unwrap() },
888      Op::Dup { n: 1.try_into().unwrap() },
889      Op::Lt,
890      Op::Branch { skip: 2.try_into().unwrap() },
891      Op::Pop,
892      Op::Jmp { skip: 2.try_into().unwrap() },
893      Op::Swap { n: 0.try_into().unwrap() },
894      Op::Pop,
895      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
896      Op::Idx { cached: false.try_into().unwrap(), push_path: true.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(2 as u8).into())].try_into().unwrap() },
897      Op::Dup { n: 2.try_into().unwrap() },
898      Op::Idx { cached: false.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(0 as u8).into())].try_into().unwrap() },
899      Op::Root,
900      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Null.try_into().unwrap() },
901      Op::Ins { cached: false.try_into().unwrap(), n: 1.try_into().unwrap() },
902      Op::Ins { cached: true.try_into().unwrap(), n: (($f.clone().len() as u8) + 1).try_into().unwrap() },
903    ]
904  };
905}
906pub use HistoricMerkleTree_insert_index_default;
907#[macro_export]
908macro_rules! HistoricMerkleTree_reset_history {
909  ($f:expr_2021, $fcached:expr_2021, $nat:literal, $value_type:ty) => {
910    [
911      Op::Idx { cached: $fcached.try_into().unwrap(), push_path: true.try_into().unwrap(), path: $f.clone().try_into().unwrap() },
912      Op::Push { storage: false.try_into().unwrap(), value: StateValue::Cell(Sp::new(AlignedValue::from(2 as u8).try_into().unwrap())).try_into().unwrap() },
913      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Map([].iter().cloned().collect()).try_into().unwrap() },
914      Op::Dup { n: 2.try_into().unwrap() },
915      Op::Idx { cached: false.try_into().unwrap(), push_path: false.try_into().unwrap(), path: vec![Key::Value(AlignedValue::from(0 as u8).into())].try_into().unwrap() },
916      Op::Root,
917      Op::Push { storage: true.try_into().unwrap(), value: StateValue::Null.try_into().unwrap() },
918      Op::Ins { cached: true.try_into().unwrap(), n: (($f.clone().len() as u8) + 2).try_into().unwrap() },
919    ]
920  };
921}
922pub use HistoricMerkleTree_reset_history;