forked from argotorg/fe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpacked.fe
More file actions
840 lines (775 loc) · 30.6 KB
/
Copy pathpacked.fe
File metadata and controls
840 lines (775 loc) · 30.6 KB
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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
/// Tightly packed byte encoding — the Fe equivalent of Solidity's
/// `abi.encodePacked`.
///
/// Values are concatenated big-endian with no padding and no length
/// prefixes: a `u16` contributes exactly 2 bytes, an `Address` exactly
/// 20, dynamic `Bytes` exactly `len()` payload bytes. This is the
/// encoding behind CREATE2 salts (`keccak256(token0 ++ token1)`),
/// EIP-712 / EIP-191 digests
/// (`keccak256(0x19 ++ 0x01 ++ domain_separator ++ struct_hash)`), and
/// most ad-hoc byte blobs a contract needs to hash.
///
/// ## Which layer to use
///
/// Use `keccak_packed` / `encode_packed` with a tuple unless your
/// payload shape is only known at runtime (loops over collections,
/// conditional fields, dynamic concatenation); then use the `Packed`
/// builder directly. For SSZ/consensus hashing use `std::evm::ssz` —
/// nothing here overlaps that domain.
///
/// ```ignore
/// let salt = keccak_packed((token0, token1))
/// let digest = keccak_packed((0x19 as u8, 0x01 as u8, domain_separator, struct_hash))
///
/// let mut p = Packed::new()
/// for item in items {
/// p.u256(item)
/// }
/// let root = p.keccak256()
/// ```
///
/// Types without an `EncodePacked` impl (structs, storage handles) are
/// deliberately compile errors. Implement `EncodePacked` for your own
/// type — delegating to the `Packed` append methods — to make it
/// packable.
///
/// ## Scope
///
/// Strict `abi.encodePacked` parity. Deliberate omissions:
/// - Arrays with non-byte element types are not packable: Solidity
/// pads every element of e.g. `uint8[]` to 32 bytes inside
/// `encodePacked`, a surprising rule this module does not reproduce.
/// Only `[u8; N]` is supported (N raw bytes, matching `bytesN`
/// values and Solidity's `bytes`).
/// - No decoding counterpart: packed encoding is not self-describing,
/// and Solidity has none either.
use core::abi::{Bytes, BytesView, MemoryInput}
use core::num::IntDowncast
use core::result::Result
use ingot::abi::FixedBytes
use super::crypto
use super::effects::{Address, RawMem}
use super::mem
use super::ops
/// Default initial capacity (in bytes) for `Packed::new`.
const DEFAULT_CAPACITY: u256 = 128
/// A value with a tightly packed byte encoding (Solidity
/// `abi.encodePacked` semantics).
///
/// Implementations delegate to the `Packed` append methods — no
/// encoding logic lives in the impls themselves.
pub trait EncodePacked {
/// Exact number of bytes this value contributes.
fn packed_width(self) -> u256
/// Append this value to a builder.
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem)
}
/// Pack a value (typically a tuple) into an exactly-sized fresh buffer.
///
/// The returned builder holds exactly the packed encoding; call
/// `keccak256`, `sha256`, or `as_bytes` on it, or keep appending.
pub fn encode_packed<T: EncodePacked>(_ value: own T) -> Packed uses (mem: mut RawMem) {
let mut p = Packed::with_capacity(bytes: value.packed_width())
value.pack_into(mut p)
p
}
/// keccak256 of the packed encoding — the dominant consumer.
pub fn keccak_packed<T: EncodePacked>(_ value: own T) -> u256 uses (mem: mut RawMem) {
encode_packed(value).keccak256()
}
/// Imperative builder for packed byte payloads.
///
/// A bump-allocated memory buffer with byte-precise appends. Writes
/// never touch memory beyond the buffer's current capacity, and the
/// buffer grows (copy-on-grow, doubling) whenever an append would
/// exceed it — a wrong capacity hint can cost a copy, never a panic
/// or memory corruption. Growth moves the buffer, which is safe
/// because the base pointer is never exposed before the terminal ops.
///
/// One unsupported edge: `append_mem` reading from this builder's own
/// buffer (the source may be stale or overlapping if the append
/// triggers growth).
pub struct Packed {
base: u256,
cursor: u256,
limit: u256,
}
impl Packed {
/// Growable buffer with a default initial capacity (128 bytes).
pub fn new() -> Self uses (mem: mut RawMem) {
Packed::with_capacity(bytes: DEFAULT_CAPACITY)
}
/// Growable buffer with a chosen initial capacity. The capacity is
/// a copy-avoidance hint, never a contract — writes past it grow
/// the buffer.
pub fn with_capacity(bytes: u256) -> Self uses (mem: mut RawMem) {
let base = mem::alloc(bytes)
Packed { base, cursor: base, limit: base + bytes }
}
/// Append a `u256` as 32 big-endian bytes.
pub fn u256(mut self, _ value: u256) uses (mem: mut RawMem) {
self.append_word(value, width: 32)
}
/// Append a `u128` as 16 big-endian bytes.
pub fn u128(mut self, _ value: u128) uses (mem: mut RawMem) {
self.append_word(value: value as u256, width: 16)
}
/// Append a `u64` as 8 big-endian bytes.
pub fn u64(mut self, _ value: u64) uses (mem: mut RawMem) {
self.append_word(value: value as u256, width: 8)
}
/// Append a `u32` as 4 big-endian bytes.
pub fn u32(mut self, _ value: u32) uses (mem: mut RawMem) {
self.append_word(value: value as u256, width: 4)
}
/// Append a `u16` as 2 big-endian bytes.
pub fn u16(mut self, _ value: u16) uses (mem: mut RawMem) {
self.append_word(value: value as u256, width: 2)
}
/// Append a `u8` as 1 byte.
pub fn u8(mut self, _ value: u8) uses (mem: mut RawMem) {
self.append_word(value: value as u256, width: 1)
}
/// Append a `bool` as 1 byte (`0x00` / `0x01`).
pub fn bool_(mut self, _ value: bool) uses (mem: mut RawMem) {
self.append_word(value: if value { 1 } else { 0 }, width: 1)
}
/// Append an `Address` as 20 bytes.
pub fn address(mut self, _ value: Address) uses (mem: mut RawMem) {
// `inner` is a public field, so a caller can hand us a
// non-canonical value with bits above the low 160 set. Revert
// like `fixed_bytes` does rather than silently truncating
// distinct values into colliding encodings.
if value.inner >> 160 != 0 {
ops::revert(offset: 0, len: 0)
}
self.append_word(value: value.inner, width: 20)
}
/// Append the *effective* bytes of a fixed-size string — `len()`
/// bytes, not the capacity `N` — matching Solidity's packed
/// `string`.
pub fn string<const N: usize>(mut self, _ value: String<N>) uses (mem: mut RawMem) {
self.append_word(value: value as u256, width: value.len() as u256)
}
/// Append a `FixedBytes<N>` as its N raw bytes.
///
/// `bytesN` values sit **left-aligned** in an ABI word — the
/// opposite of integer alignment and the classic `encodePacked`
/// footgun — but packed they are just the N content bytes: a
/// `bytes4` contributes 4 bytes, never a zero-padded word.
pub fn fixed_bytes<const N: usize>(mut self, _ value: FixedBytes<N>) uses (mem: mut RawMem) {
// The ABI encoder (`FixedBytes::word`) reverts on unsupported
// widths; do the same rather than silently appending nothing
// for `N == 0` or tripping `append_word`'s assert for `N > 32`.
if N == 0 || N > 32 {
ops::revert(offset: 0, len: 0)
}
// `val` is a public field, so a caller can hand us a
// non-canonical value with bytes above the low N set. The ABI
// encoder (`FixedBytes::word`) reverts on those; do the same
// rather than silently truncating distinct values into
// colliding encodings.
if N < 32 && value.val >> ((N as u256) * 8) != 0 {
ops::revert(offset: 0, len: 0)
}
self.append_word(value: value.val, width: N as u256)
}
/// Append a fixed byte array verbatim.
pub fn bytes<const N: usize>(mut self, _ value: [u8; N]) uses (mem: mut RawMem) {
self.reserve(N as u256)
let mut i: usize = 0
while i < N {
mem.mstore8(addr: self.cursor + (i as u256), value: value[i])
i += 1
}
self.cursor += N as u256
}
/// Append `len` raw bytes copied from memory at `ptr`.
///
/// Unsupported edge: `ptr` must not point into this builder's own
/// buffer — an append that triggers growth would leave `ptr`
/// pointing at the stale allocation.
pub fn append_mem(mut self, ptr: u256, len: u256) uses (mem: mut RawMem) {
self.reserve(len)
copy_bytes(dest: self.cursor, src: ptr, len: len)
self.cursor += len
}
/// Bytes written so far.
pub fn len(self) -> u256 {
self.cursor - self.base
}
/// keccak256 of the bytes written so far.
pub fn keccak256(self) -> u256 {
ops::keccak256(offset: self.base, len: self.len())
}
/// SHA-256 of the bytes written so far (precompile 0x02). Reverts
/// if the precompile call fails.
pub fn sha256(self) -> u256 {
match crypto::sha256(offset: self.base, len: self.len()) {
Result::Ok(digest) => digest,
Result::Err(_) => ops::revert(offset: 0, len: 0),
}
}
/// Copy out as a Solidity-compatible `bytes memory` payload (fresh
/// allocation: length word + zero-padded payload words).
pub fn as_bytes(self) -> Bytes uses (mem: mut RawMem) {
let len = self.len()
let padded = (len + 31) / 32 * 32
let data = mem::alloc(32 + padded)
mem.mstore(addr: data, value: len)
if padded != 0 {
// Zero the last payload word so the padding bytes are
// canonical regardless of what the copy leaves behind.
mem.mstore(addr: data + padded, value: 0)
}
copy_bytes(dest: data + 32, src: self.base, len: len)
Bytes { data, len, size: 32 + padded }
}
/// Write the low `width` bytes of `value` big-endian at the cursor.
///
/// Byte-precise: never touches memory beyond the buffer's
/// capacity. When a whole word fits below `limit` a single
/// left-aligned `mstore` is used (the bytes it zeroes past `width`
/// are inside our own capacity and overwritten by later appends);
/// otherwise the bytes are written individually.
#[arithmetic(unchecked)]
fn append_word(mut self, value: u256, width: u256) uses (mem: mut RawMem) {
assert!(width <= 32)
if width == 0 {
return
}
self.reserve(width)
if self.cursor + 32 <= self.limit {
mem.mstore(addr: self.cursor, value: value << ((32 - width) * 8))
} else {
let mut i: u256 = 0
while i < width {
let b: u8 = (value >> ((width - 1 - i) * 8)).downcast_truncate()
mem.mstore8(addr: self.cursor + i, value: b)
i += 1
}
}
self.cursor += width
}
/// Ensure `additional` bytes fit below `limit`, growing
/// (copy-on-grow, doubling until it fits) if they don't.
fn reserve(mut self, _ additional: u256) uses (mem: mut RawMem) {
if self.cursor + additional <= self.limit {
return
}
let len = self.len()
let needed = len + additional
let mut cap = self.limit - self.base
if cap == 0 {
cap = 32
}
while cap < needed {
cap *= 2
}
let base = mem::alloc(cap)
copy_bytes(dest: base, src: self.base, len: len)
self.base = base
self.cursor = base + len
self.limit = base + cap
}
}
// Byte-precise memory copy: whole words first, then the sub-word tail
// one byte at a time, so exactly `len` destination bytes are written.
fn copy_bytes(dest: u256, src: u256, len: u256) uses (mem: mut RawMem) {
let words_end = len / 32 * 32
let mut off: u256 = 0
while off < words_end {
mem.mstore(addr: dest + off, value: mem.mload(src + off))
off += 32
}
while off < len {
let b: u8 = (mem.mload(src + off) >> 248).downcast_truncate()
mem.mstore8(addr: dest + off, value: b)
off += 1
}
}
// -----------------------------------------------------------------------------
// EncodePacked implementations (matching Solidity's `abi.encodePacked`
// byte-for-byte)
// -----------------------------------------------------------------------------
impl EncodePacked for u8 {
fn packed_width(self) -> u256 { 1 }
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
p.u8(self)
}
}
impl EncodePacked for u16 {
fn packed_width(self) -> u256 { 2 }
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
p.u16(self)
}
}
impl EncodePacked for u32 {
fn packed_width(self) -> u256 { 4 }
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
p.u32(self)
}
}
impl EncodePacked for u64 {
fn packed_width(self) -> u256 { 8 }
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
p.u64(self)
}
}
impl EncodePacked for u128 {
fn packed_width(self) -> u256 { 16 }
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
p.u128(self)
}
}
impl EncodePacked for u256 {
fn packed_width(self) -> u256 { 32 }
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
p.u256(self)
}
}
// Signed integers pack as two's complement in their exact width:
// `i8(-1)` is `0xff`, `i16(-2)` is `0xfffe`. `downcast_truncate` to the
// same-width unsigned type keeps the bit pattern.
impl EncodePacked for i8 {
fn packed_width(self) -> u256 { 1 }
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
let bits: u8 = self.downcast_truncate()
p.u8(bits)
}
}
impl EncodePacked for i16 {
fn packed_width(self) -> u256 { 2 }
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
let bits: u16 = self.downcast_truncate()
p.u16(bits)
}
}
impl EncodePacked for i32 {
fn packed_width(self) -> u256 { 4 }
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
let bits: u32 = self.downcast_truncate()
p.u32(bits)
}
}
impl EncodePacked for i64 {
fn packed_width(self) -> u256 { 8 }
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
let bits: u64 = self.downcast_truncate()
p.u64(bits)
}
}
impl EncodePacked for i128 {
fn packed_width(self) -> u256 { 16 }
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
let bits: u128 = self.downcast_truncate()
p.u128(bits)
}
}
impl EncodePacked for i256 {
fn packed_width(self) -> u256 { 32 }
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
let bits: u256 = self.downcast_truncate()
p.u256(bits)
}
}
impl EncodePacked for bool {
fn packed_width(self) -> u256 { 1 }
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
p.bool_(self)
}
}
impl EncodePacked for Address {
fn packed_width(self) -> u256 { 20 }
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
p.address(self)
}
}
// The effective string bytes (`len()`), not the capacity `N`.
impl<const N: usize> EncodePacked for String<N> {
fn packed_width(self) -> u256 { self.len() as u256 }
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
p.string(self)
}
}
impl<const N: usize> EncodePacked for [u8; N] {
fn packed_width(self) -> u256 { N as u256 }
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
p.bytes(self)
}
}
// N raw content bytes — see `Packed::fixed_bytes` for the alignment
// footgun.
impl<const N: usize> EncodePacked for FixedBytes<N> {
fn packed_width(self) -> u256 { N as u256 }
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
p.fixed_bytes(self)
}
}
// `len()` raw payload bytes, no length word.
impl EncodePacked for Bytes {
fn packed_width(self) -> u256 { self.len }
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
p.append_mem(ptr: self.payload_ptr(), len: self.len)
}
}
impl EncodePacked for BytesView<MemoryInput> {
fn packed_width(self) -> u256 { self.len }
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
p.append_mem(ptr: self.input.base + self.start, len: self.len)
}
}
// -----------------------------------------------------------------------------
// Tuple implementations (arity 1..=16, per-arity like `Encode<Sol>`,
// `AsBytes`, and `ssz::Merkleize`)
// -----------------------------------------------------------------------------
//
// Fields are concatenated in declaration order; nested tuples flatten
// naturally through recursion.
impl<T0> EncodePacked for (T0,)
where T0: EncodePacked
{
fn packed_width(self) -> u256 {
self.0.packed_width()
}
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
self.0.pack_into(mut p)
}
}
impl<T0, T1> EncodePacked for (T0, T1)
where T0: EncodePacked, T1: EncodePacked
{
fn packed_width(self) -> u256 {
self.0.packed_width() + self.1.packed_width()
}
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
self.0.pack_into(mut p)
self.1.pack_into(mut p)
}
}
impl<T0, T1, T2> EncodePacked for (T0, T1, T2)
where T0: EncodePacked, T1: EncodePacked, T2: EncodePacked
{
fn packed_width(self) -> u256 {
self.0.packed_width() + self.1.packed_width() + self.2.packed_width()
}
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
self.0.pack_into(mut p)
self.1.pack_into(mut p)
self.2.pack_into(mut p)
}
}
impl<T0, T1, T2, T3> EncodePacked for (T0, T1, T2, T3)
where T0: EncodePacked, T1: EncodePacked, T2: EncodePacked, T3: EncodePacked
{
fn packed_width(self) -> u256 {
self.0.packed_width() + self.1.packed_width() + self.2.packed_width()
+ self.3.packed_width()
}
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
self.0.pack_into(mut p)
self.1.pack_into(mut p)
self.2.pack_into(mut p)
self.3.pack_into(mut p)
}
}
impl<T0, T1, T2, T3, T4> EncodePacked for (T0, T1, T2, T3, T4)
where T0: EncodePacked, T1: EncodePacked, T2: EncodePacked, T3: EncodePacked,
T4: EncodePacked
{
fn packed_width(self) -> u256 {
self.0.packed_width() + self.1.packed_width() + self.2.packed_width()
+ self.3.packed_width() + self.4.packed_width()
}
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
self.0.pack_into(mut p)
self.1.pack_into(mut p)
self.2.pack_into(mut p)
self.3.pack_into(mut p)
self.4.pack_into(mut p)
}
}
impl<T0, T1, T2, T3, T4, T5> EncodePacked for (T0, T1, T2, T3, T4, T5)
where T0: EncodePacked, T1: EncodePacked, T2: EncodePacked, T3: EncodePacked,
T4: EncodePacked, T5: EncodePacked
{
fn packed_width(self) -> u256 {
self.0.packed_width() + self.1.packed_width() + self.2.packed_width()
+ self.3.packed_width() + self.4.packed_width() + self.5.packed_width()
}
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
self.0.pack_into(mut p)
self.1.pack_into(mut p)
self.2.pack_into(mut p)
self.3.pack_into(mut p)
self.4.pack_into(mut p)
self.5.pack_into(mut p)
}
}
impl<T0, T1, T2, T3, T4, T5, T6> EncodePacked for (T0, T1, T2, T3, T4, T5, T6)
where T0: EncodePacked, T1: EncodePacked, T2: EncodePacked, T3: EncodePacked,
T4: EncodePacked, T5: EncodePacked, T6: EncodePacked
{
fn packed_width(self) -> u256 {
self.0.packed_width() + self.1.packed_width() + self.2.packed_width()
+ self.3.packed_width() + self.4.packed_width() + self.5.packed_width()
+ self.6.packed_width()
}
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
self.0.pack_into(mut p)
self.1.pack_into(mut p)
self.2.pack_into(mut p)
self.3.pack_into(mut p)
self.4.pack_into(mut p)
self.5.pack_into(mut p)
self.6.pack_into(mut p)
}
}
impl<T0, T1, T2, T3, T4, T5, T6, T7> EncodePacked for (T0, T1, T2, T3, T4, T5, T6, T7)
where T0: EncodePacked, T1: EncodePacked, T2: EncodePacked, T3: EncodePacked,
T4: EncodePacked, T5: EncodePacked, T6: EncodePacked, T7: EncodePacked
{
fn packed_width(self) -> u256 {
self.0.packed_width() + self.1.packed_width() + self.2.packed_width()
+ self.3.packed_width() + self.4.packed_width() + self.5.packed_width()
+ self.6.packed_width() + self.7.packed_width()
}
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
self.0.pack_into(mut p)
self.1.pack_into(mut p)
self.2.pack_into(mut p)
self.3.pack_into(mut p)
self.4.pack_into(mut p)
self.5.pack_into(mut p)
self.6.pack_into(mut p)
self.7.pack_into(mut p)
}
}
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8> EncodePacked
for (T0, T1, T2, T3, T4, T5, T6, T7, T8)
where T0: EncodePacked, T1: EncodePacked, T2: EncodePacked, T3: EncodePacked,
T4: EncodePacked, T5: EncodePacked, T6: EncodePacked, T7: EncodePacked,
T8: EncodePacked
{
fn packed_width(self) -> u256 {
self.0.packed_width() + self.1.packed_width() + self.2.packed_width()
+ self.3.packed_width() + self.4.packed_width() + self.5.packed_width()
+ self.6.packed_width() + self.7.packed_width() + self.8.packed_width()
}
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
self.0.pack_into(mut p)
self.1.pack_into(mut p)
self.2.pack_into(mut p)
self.3.pack_into(mut p)
self.4.pack_into(mut p)
self.5.pack_into(mut p)
self.6.pack_into(mut p)
self.7.pack_into(mut p)
self.8.pack_into(mut p)
}
}
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> EncodePacked
for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)
where T0: EncodePacked, T1: EncodePacked, T2: EncodePacked, T3: EncodePacked,
T4: EncodePacked, T5: EncodePacked, T6: EncodePacked, T7: EncodePacked,
T8: EncodePacked, T9: EncodePacked
{
fn packed_width(self) -> u256 {
self.0.packed_width() + self.1.packed_width() + self.2.packed_width()
+ self.3.packed_width() + self.4.packed_width() + self.5.packed_width()
+ self.6.packed_width() + self.7.packed_width() + self.8.packed_width()
+ self.9.packed_width()
}
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
self.0.pack_into(mut p)
self.1.pack_into(mut p)
self.2.pack_into(mut p)
self.3.pack_into(mut p)
self.4.pack_into(mut p)
self.5.pack_into(mut p)
self.6.pack_into(mut p)
self.7.pack_into(mut p)
self.8.pack_into(mut p)
self.9.pack_into(mut p)
}
}
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> EncodePacked
for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)
where T0: EncodePacked, T1: EncodePacked, T2: EncodePacked, T3: EncodePacked,
T4: EncodePacked, T5: EncodePacked, T6: EncodePacked, T7: EncodePacked,
T8: EncodePacked, T9: EncodePacked, T10: EncodePacked
{
fn packed_width(self) -> u256 {
self.0.packed_width() + self.1.packed_width() + self.2.packed_width()
+ self.3.packed_width() + self.4.packed_width() + self.5.packed_width()
+ self.6.packed_width() + self.7.packed_width() + self.8.packed_width()
+ self.9.packed_width() + self.10.packed_width()
}
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
self.0.pack_into(mut p)
self.1.pack_into(mut p)
self.2.pack_into(mut p)
self.3.pack_into(mut p)
self.4.pack_into(mut p)
self.5.pack_into(mut p)
self.6.pack_into(mut p)
self.7.pack_into(mut p)
self.8.pack_into(mut p)
self.9.pack_into(mut p)
self.10.pack_into(mut p)
}
}
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> EncodePacked
for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)
where T0: EncodePacked, T1: EncodePacked, T2: EncodePacked, T3: EncodePacked,
T4: EncodePacked, T5: EncodePacked, T6: EncodePacked, T7: EncodePacked,
T8: EncodePacked, T9: EncodePacked, T10: EncodePacked, T11: EncodePacked
{
fn packed_width(self) -> u256 {
self.0.packed_width() + self.1.packed_width() + self.2.packed_width()
+ self.3.packed_width() + self.4.packed_width() + self.5.packed_width()
+ self.6.packed_width() + self.7.packed_width() + self.8.packed_width()
+ self.9.packed_width() + self.10.packed_width() + self.11.packed_width()
}
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
self.0.pack_into(mut p)
self.1.pack_into(mut p)
self.2.pack_into(mut p)
self.3.pack_into(mut p)
self.4.pack_into(mut p)
self.5.pack_into(mut p)
self.6.pack_into(mut p)
self.7.pack_into(mut p)
self.8.pack_into(mut p)
self.9.pack_into(mut p)
self.10.pack_into(mut p)
self.11.pack_into(mut p)
}
}
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> EncodePacked
for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)
where T0: EncodePacked, T1: EncodePacked, T2: EncodePacked, T3: EncodePacked,
T4: EncodePacked, T5: EncodePacked, T6: EncodePacked, T7: EncodePacked,
T8: EncodePacked, T9: EncodePacked, T10: EncodePacked, T11: EncodePacked,
T12: EncodePacked
{
fn packed_width(self) -> u256 {
self.0.packed_width() + self.1.packed_width() + self.2.packed_width()
+ self.3.packed_width() + self.4.packed_width() + self.5.packed_width()
+ self.6.packed_width() + self.7.packed_width() + self.8.packed_width()
+ self.9.packed_width() + self.10.packed_width() + self.11.packed_width()
+ self.12.packed_width()
}
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
self.0.pack_into(mut p)
self.1.pack_into(mut p)
self.2.pack_into(mut p)
self.3.pack_into(mut p)
self.4.pack_into(mut p)
self.5.pack_into(mut p)
self.6.pack_into(mut p)
self.7.pack_into(mut p)
self.8.pack_into(mut p)
self.9.pack_into(mut p)
self.10.pack_into(mut p)
self.11.pack_into(mut p)
self.12.pack_into(mut p)
}
}
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> EncodePacked
for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)
where T0: EncodePacked, T1: EncodePacked, T2: EncodePacked, T3: EncodePacked,
T4: EncodePacked, T5: EncodePacked, T6: EncodePacked, T7: EncodePacked,
T8: EncodePacked, T9: EncodePacked, T10: EncodePacked, T11: EncodePacked,
T12: EncodePacked, T13: EncodePacked
{
fn packed_width(self) -> u256 {
self.0.packed_width() + self.1.packed_width() + self.2.packed_width()
+ self.3.packed_width() + self.4.packed_width() + self.5.packed_width()
+ self.6.packed_width() + self.7.packed_width() + self.8.packed_width()
+ self.9.packed_width() + self.10.packed_width() + self.11.packed_width()
+ self.12.packed_width() + self.13.packed_width()
}
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
self.0.pack_into(mut p)
self.1.pack_into(mut p)
self.2.pack_into(mut p)
self.3.pack_into(mut p)
self.4.pack_into(mut p)
self.5.pack_into(mut p)
self.6.pack_into(mut p)
self.7.pack_into(mut p)
self.8.pack_into(mut p)
self.9.pack_into(mut p)
self.10.pack_into(mut p)
self.11.pack_into(mut p)
self.12.pack_into(mut p)
self.13.pack_into(mut p)
}
}
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> EncodePacked
for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)
where T0: EncodePacked, T1: EncodePacked, T2: EncodePacked, T3: EncodePacked,
T4: EncodePacked, T5: EncodePacked, T6: EncodePacked, T7: EncodePacked,
T8: EncodePacked, T9: EncodePacked, T10: EncodePacked, T11: EncodePacked,
T12: EncodePacked, T13: EncodePacked, T14: EncodePacked
{
fn packed_width(self) -> u256 {
self.0.packed_width() + self.1.packed_width() + self.2.packed_width()
+ self.3.packed_width() + self.4.packed_width() + self.5.packed_width()
+ self.6.packed_width() + self.7.packed_width() + self.8.packed_width()
+ self.9.packed_width() + self.10.packed_width() + self.11.packed_width()
+ self.12.packed_width() + self.13.packed_width() + self.14.packed_width()
}
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
self.0.pack_into(mut p)
self.1.pack_into(mut p)
self.2.pack_into(mut p)
self.3.pack_into(mut p)
self.4.pack_into(mut p)
self.5.pack_into(mut p)
self.6.pack_into(mut p)
self.7.pack_into(mut p)
self.8.pack_into(mut p)
self.9.pack_into(mut p)
self.10.pack_into(mut p)
self.11.pack_into(mut p)
self.12.pack_into(mut p)
self.13.pack_into(mut p)
self.14.pack_into(mut p)
}
}
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> EncodePacked
for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)
where T0: EncodePacked, T1: EncodePacked, T2: EncodePacked, T3: EncodePacked,
T4: EncodePacked, T5: EncodePacked, T6: EncodePacked, T7: EncodePacked,
T8: EncodePacked, T9: EncodePacked, T10: EncodePacked, T11: EncodePacked,
T12: EncodePacked, T13: EncodePacked, T14: EncodePacked, T15: EncodePacked
{
fn packed_width(self) -> u256 {
self.0.packed_width() + self.1.packed_width() + self.2.packed_width()
+ self.3.packed_width() + self.4.packed_width() + self.5.packed_width()
+ self.6.packed_width() + self.7.packed_width() + self.8.packed_width()
+ self.9.packed_width() + self.10.packed_width() + self.11.packed_width()
+ self.12.packed_width() + self.13.packed_width() + self.14.packed_width()
+ self.15.packed_width()
}
fn pack_into(own self, _ p: mut Packed) uses (mem: mut RawMem) {
self.0.pack_into(mut p)
self.1.pack_into(mut p)
self.2.pack_into(mut p)
self.3.pack_into(mut p)
self.4.pack_into(mut p)
self.5.pack_into(mut p)
self.6.pack_into(mut p)
self.7.pack_into(mut p)
self.8.pack_into(mut p)
self.9.pack_into(mut p)
self.10.pack_into(mut p)
self.11.pack_into(mut p)
self.12.pack_into(mut p)
self.13.pack_into(mut p)
self.14.pack_into(mut p)
self.15.pack_into(mut p)
}
}