diff --git a/.tool-versions b/.tool-versions index 07df84b..7d9da02 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1 +1,2 @@ -scarb 2.6.3 \ No newline at end of file +scarb 2.6.3 +starknet-foundry 0.24.0 \ No newline at end of file diff --git a/bootloader_input.json b/bootloader_input.json index f90bd7f..6fa3e3b 100644 --- a/bootloader_input.json +++ b/bootloader_input.json @@ -9,7 +9,7 @@ "0x100000000000000000000000000000000", "0x400280007ff97fff", "0x10780017fff7fff", - "0x4b", + "0xb6", "0x4825800180007ffa", "0x0", "0x400280007ff97fff", @@ -19,14 +19,77 @@ "0x20680017fff7fff", "0x4", "0x10780017fff7fff", + "0xa", + "0x482680017ffc8000", + "0x1", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x480a7ffc7fff8000", + "0x10780017fff7fff", + "0x8", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x20680017fff7ffe", + "0x20", + "0x40780017fff7fff", + "0x1", + "0x48127ff97fff8000", + "0x48127ff77fff8000", + "0x48127ff97fff8000", + "0x48127ff97fff8000", + "0x48127ffb7fff8000", + "0x48127ffa7fff8000", + "0x480080007ff88000", + "0x1104800180018000", + "0xa0", + "0x20680017fff7ffa", + "0xb", + "0x48127ff87fff8000", + "0x48127ff87fff8000", + "0x48127ff97fff8000", + "0x48127ff97fff8000", + "0x48127ff97fff8000", + "0x48127ff97fff8000", + "0x48127ff97fff8000", + "0x10780017fff7fff", + "0x14", + "0x48127ff87fff8000", + "0x48127ff87fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x48127ffa7fff8000", + "0x48127ff87fff8000", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x20680017fff7ffd", + "0x64", + "0x48307ffb80007ffc", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", "0x10", "0x40780017fff7fff", "0x1", "0x480680017fff8000", "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", "0x400080007ffe7fff", - "0x48127ffc7fff8000", - "0x48127ffa7fff8000", + "0x48127ff67fff8000", + "0x48127ff67fff8000", "0x480a7ffb7fff8000", "0x480680017fff8000", "0x1", @@ -35,47 +98,91 @@ "0x1", "0x208b7fff7fff7ffe", "0x1104800180018000", - "0x40", + "0x27a", "0x482480017fff8000", - "0x3f", + "0x279", "0x480080007fff8000", "0xa0680017fff8000", "0x9", - "0x4824800180007ff8", - "0x0", + "0x4824800180007ff4", + "0x254e", "0x482480017fff8000", "0x100000000000000000000000000000000", - "0x400080007ff77fff", + "0x400080007ff17fff", "0x10780017fff7fff", - "0x16", - "0x4824800180007ff8", - "0x0", - "0x400080007ff87fff", - "0x40780017fff7fff", + "0x34", + "0x4824800180007ff4", + "0x254e", + "0x400080007ff27fff", + "0x482480017ff28000", "0x1", - "0x480680017fff8000", + "0x48127ff67fff8000", + "0x48127ff67fff8000", + "0x1104800180018000", + "0xb3", + "0x20680017fff7ffd", + "0x21", + "0x40780017fff7fff", "0x1", - "0x484480017fff8000", - "0x2", - "0x400080007ffd7fff", - "0x482480017ff58000", + "0x48307ffd80007ffe", + "0x400080007ffe7fff", + "0x48127ffa7fff8000", + "0x48127fb67fff8000", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x482480017ff98000", "0x1", + "0x1104800180018000", + "0x146", + "0x20680017fff7ffd", + "0xa", + "0x48127ffb7fff8000", "0x48127ffb7fff8000", "0x480a7ffb7fff8000", "0x480680017fff8000", "0x0", - "0x48127ff97fff8000", - "0x482480017ff88000", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x48127ffc7fff8000", + "0x48127fb87fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", "0x1", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", "0x208b7fff7fff7ffe", "0x40780017fff7fff", "0x1", "0x480680017fff8000", "0x4f7574206f6620676173", "0x400080007ffe7fff", - "0x482480017ff58000", + "0x482480017fef8000", "0x1", - "0x48127ff37fff8000", + "0x48127fef7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4661696c656420746f20646573657269616c697a6520706172616d202331", + "0x400080007ffe7fff", + "0x48127ff77fff8000", + "0x48127ff77fff8000", "0x480a7ffb7fff8000", "0x480680017fff8000", "0x1", @@ -98,24 +205,899 @@ "0x482480017ff98000", "0x1", "0x208b7fff7fff7ffe", - "0x208b7fff7fff7ffe" - ], - "bytecode_segment_lengths": [ - 96 - ], - "hints": [ + "0xa0680017fff8000", + "0x7", + "0x482680017ff88000", + "0xfffffffffffffffffffffffffffff6be", + "0x400280007ff77fff", + "0x10780017fff7fff", + "0x43", + "0x4825800180007ff8", + "0x942", + "0x400280007ff77fff", + "0x482680017ff78000", + "0x1", + "0x20780017fff7ffd", + "0xd", + "0x48127fff7fff8000", + "0x48127ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x480a7ff97fff8000", + "0x480a7ffa7fff8000", + "0x480680017fff8000", + "0x0", + "0x480a7ffb7fff8000", + "0x480a7ffc7fff8000", + "0x208b7fff7fff7ffe", + "0x48297ff980007ffa", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0xa", + "0x482680017ff98000", + "0x1", + "0x480a7ffa7fff8000", + "0x480680017fff8000", + "0x0", + "0x480280007ff98000", + "0x10780017fff7fff", + "0x8", + "0x480a7ff97fff8000", + "0x480a7ffa7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x20680017fff7ffe", + "0xf", + "0x400280007ffc7fff", + "0x48127ffa7fff8000", + "0x48127ff87fff8000", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x480a7ffb7fff8000", + "0x482680017ffc8000", + "0x1", + "0x4825800180007ffd", + "0x1", + "0x1104800180018000", + "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffc9", + "0x208b7fff7fff7ffe", + "0x48127ffa7fff8000", + "0x48127ff87fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ff97fff8000", + "0x48127ff97fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482680017ff78000", + "0x1", + "0x480a7ff87fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x48127ff87fff8000", + "0x482480017ff78000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0xe1", + "0x20680017fff7ffc", + "0x8f", + "0x48507ffd7ffd8000", + "0xa0680017fff8000", + "0x7", + "0x4824800180007ffe", + "0x100000000", + "0x400080007ff67fff", + "0x10780017fff7fff", + "0x78", + "0x482480017ffe8000", + "0xffffffffffffffffffffffff00000000", + "0x400080007ff67fff", + "0x48507ffb7ffb8000", + "0xa0680017fff8000", + "0x7", + "0x4824800180007ffe", + "0x100000000", + "0x400080017ff37fff", + "0x10780017fff7fff", + "0x5e", + "0x482480017ffe8000", + "0xffffffffffffffffffffffff00000000", + "0x400080017ff37fff", + "0x48507ff97ff98000", + "0xa0680017fff8000", + "0x7", + "0x4824800180007ffe", + "0x100000000", + "0x400080027ff07fff", + "0x10780017fff7fff", + "0x44", + "0x482480017ffe8000", + "0xffffffffffffffffffffffff00000000", + "0x400080027ff07fff", + "0xa0680017fff8000", + "0x8", + "0x48307ff97ff68000", + "0x4824800180007fff", + "0x100000000", + "0x400080037fed7fff", + "0x10780017fff7fff", + "0x2a", + "0x48307ff97ff68001", + "0x4824800180007fff", + "0xffffffffffffffffffffffff00000000", + "0x400080037fed7ffe", + "0x482480017fed8000", + "0x4", + "0x48307ff980007ffe", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0x10", + "0x40780017fff7fff", + "0x2", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x696e76616c69642076616c7565", + "0x400080007ffe7fff", + "0x48127ffa7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffc7fff8000", + "0x482480017ffb8000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x48127ff17fff8000", + "0x48127ff37fff8000", + "0x48127ff57fff8000", + "0x400080007ffc7ffd", + "0x400080017ffc7ffe", + "0x400080027ffc7fff", + "0x48127ffa7fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x3", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x4", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x7533325f616464204f766572666c6f77", + "0x400080007ffe7fff", + "0x482480017fe78000", + "0x4", + "0x480680017fff8000", + "0x1", + "0x48127ffc7fff8000", + "0x482480017ffb8000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x7", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x7533325f6d756c204f766572666c6f77", + "0x400080007ffe7fff", + "0x482480017fe78000", + "0x3", + "0x480680017fff8000", + "0x1", + "0x48127ffc7fff8000", + "0x482480017ffb8000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0xa", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x7533325f6d756c204f766572666c6f77", + "0x400080007ffe7fff", + "0x482480017fe78000", + "0x2", + "0x480680017fff8000", + "0x1", + "0x48127ffc7fff8000", + "0x482480017ffb8000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0xd", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x7533325f6d756c204f766572666c6f77", + "0x400080007ffe7fff", + "0x482480017fe78000", + "0x1", + "0x480680017fff8000", + "0x1", + "0x48127ffc7fff8000", + "0x482480017ffb8000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x10", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7074696f6e3a3a756e77726170206661696c65642e", + "0x400080007ffe7fff", + "0x48127fe77fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffc7fff8000", + "0x482480017ffb8000", + "0x1", + "0x208b7fff7fff7ffe", + "0xa0680017fff8000", + "0x7", + "0x482680017ff98000", + "0xfffffffffffffffffffffffffffff722", + "0x400280007ff87fff", + "0x10780017fff7fff", + "0x2f", + "0x4825800180007ff9", + "0x8de", + "0x400280007ff87fff", + "0x482680017ff88000", + "0x1", + "0x48297ffa80007ffb", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0xa", + "0x482680017ffa8000", + "0x1", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x0", + "0x480a7ffa7fff8000", + "0x10780017fff7fff", + "0x8", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x20680017fff7ffe", + "0xe", + "0x480080007fff8000", + "0x400280007ffd7fff", + "0x48127ff97fff8000", + "0x48127ff77fff8000", + "0x48127ff97fff8000", + "0x48127ff97fff8000", + "0x480a7ffc7fff8000", + "0x482680017ffd8000", + "0x1", + "0x1104800180018000", + "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffd7", + "0x208b7fff7fff7ffe", + "0x48127ffa7fff8000", + "0x48127ff87fff8000", + "0x480680017fff8000", + "0x0", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482680017ff88000", + "0x1", + "0x480a7ff97fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffb7fff8000", + "0x482480017ffa8000", + "0x1", + "0x208b7fff7fff7ffe", + "0x48297ffc80007ffd", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0xa", + "0x482680017ffc8000", + "0x1", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x480a7ffc7fff8000", + "0x10780017fff7fff", + "0x8", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x20680017fff7ffe", + "0xad", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x12", + "0x4824800180007ffe", + "0x100000000", + "0x4844800180008002", + "0x8000000000000110000000000000000", + "0x4830800080017ffe", + "0x480280007ffb7fff", + "0x482480017ffe8000", + "0xefffffffffffffde00000000ffffffff", + "0x480280017ffb7fff", + "0x400280027ffb7ffb", + "0x402480017fff7ffb", + "0xffffffffffffffffffffffffffffffff", + "0x20680017fff7fff", + "0x96", + "0x402780017fff7fff", + "0x1", + "0x400280007ffb7ffe", + "0x482480017ffe8000", + "0xffffffffffffffffffffffff00000000", + "0x400280017ffb7fff", + "0x482680017ffb8000", + "0x2", + "0x48307ff880007ff9", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0xa", + "0x482480017ff78000", + "0x1", + "0x48127ff77fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ff47fff8000", + "0x10780017fff7fff", + "0x8", + "0x48127ff77fff8000", + "0x48127ff77fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x20680017fff7ffe", + "0x6b", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x12", + "0x4824800180007ffe", + "0x100000000", + "0x4844800180008002", + "0x8000000000000110000000000000000", + "0x4830800080017ffe", + "0x480080007ff57fff", + "0x482480017ffe8000", + "0xefffffffffffffde00000000ffffffff", + "0x480080017ff37fff", + "0x400080027ff27ffb", + "0x402480017fff7ffb", + "0xffffffffffffffffffffffffffffffff", + "0x20680017fff7fff", + "0x54", + "0x402780017fff7fff", + "0x1", + "0x400080007ff87ffe", + "0x482480017ffe8000", + "0xffffffffffffffffffffffff00000000", + "0x400080017ff77fff", + "0x482480017ff78000", + "0x2", + "0x48307ff880007ff9", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0xa", + "0x482480017ff78000", + "0x1", + "0x48127ff77fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ff47fff8000", + "0x10780017fff7fff", + "0x8", + "0x48127ff77fff8000", + "0x48127ff77fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x20680017fff7ffe", + "0x29", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x12", + "0x4824800180007ffe", + "0x100000000", + "0x4844800180008002", + "0x8000000000000110000000000000000", + "0x4830800080017ffe", + "0x480080007ff57fff", + "0x482480017ffe8000", + "0xefffffffffffffde00000000ffffffff", + "0x480080017ff37fff", + "0x400080027ff27ffb", + "0x402480017fff7ffb", + "0xffffffffffffffffffffffffffffffff", + "0x20680017fff7fff", + "0x14", + "0x402780017fff7fff", + "0x1", + "0x400080007ff87ffe", + "0x482480017ffe8000", + "0xffffffffffffffffffffffff00000000", + "0x400080017ff77fff", + "0x40780017fff7fff", + "0x5", + "0x482480017ff28000", + "0x2", + "0x48127ff37fff8000", + "0x48127ff37fff8000", + "0x480680017fff8000", + "0x0", + "0x48127fe27fff8000", + "0x48127fea7fff8000", + "0x48127ff27fff8000", + "0x208b7fff7fff7ffe", + "0x482480017ff28000", + "0x3", + "0x10780017fff7fff", + "0x5", + "0x40780017fff7fff", + "0x8", + "0x48127ff27fff8000", + "0x48127ff37fff8000", + "0x48127ff37fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x9", + "0x482480017fe98000", + "0x3", + "0x10780017fff7fff", + "0x5", + "0x40780017fff7fff", + "0x11", + "0x48127fe97fff8000", + "0x48127fea7fff8000", + "0x48127fea7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x12", + "0x482680017ffb8000", + "0x3", + "0x10780017fff7fff", + "0x5", + "0x40780017fff7fff", + "0x1a", + "0x480a7ffb7fff8000", + "0x48127fe17fff8000", + "0x48127fe17fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x208b7fff7fff7ffe" + ], + "bytecode_segment_lengths": [ + 202, + 92, + 162, + 66, + 207 + ], + "hints": [ + [ + 0, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x0" + }, + "rhs": { + "Deref": { + "register": "FP", + "offset": -6 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 33, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 80, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 99, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x254e" + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -11 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 119, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 158, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 173, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 187, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 202, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x942" + }, + "rhs": { + "Deref": { + "register": "FP", + "offset": -8 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 274, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 302, + [ + { + "TestLessThan": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -1 + } + }, + "rhs": { + "Immediate": "0x100000000" + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 313, + [ + { + "TestLessThan": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -1 + } + }, + "rhs": { + "Immediate": "0x100000000" + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 324, + [ + { + "TestLessThan": { + "lhs": { + "Deref": { + "register": "AP", + "offset": -1 + } + }, + "rhs": { + "Immediate": "0x100000000" + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 334, + [ + { + "TestLessThan": { + "lhs": { + "BinOp": { + "op": "Add", + "a": { + "register": "AP", + "offset": -9 + }, + "b": { + "Deref": { + "register": "AP", + "offset": -6 + } + } + } + }, + "rhs": { + "Immediate": "0x100000000" + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], [ - 0, + 355, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 367, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 384, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 399, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 414, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 429, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 444, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 456, [ { "TestLessThanOrEqual": { "lhs": { - "Immediate": "0x0" + "Immediate": "0x8de" }, "rhs": { "Deref": { "register": "FP", - "offset": -6 + "offset": -7 } }, "dst": { @@ -127,7 +1109,7 @@ ] ], [ - 17, + 508, [ { "AllocSegment": { @@ -140,32 +1122,82 @@ ] ], [ - 36, + 544, [ { - "TestLessThanOrEqual": { + "TestLessThan": { "lhs": { - "Immediate": "0x0" + "BinOp": { + "op": "Add", + "a": { + "register": "AP", + "offset": -1 + }, + "b": { + "Immediate": "0x0" + } + } }, "rhs": { + "Immediate": "0x100000000" + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 548, + [ + { + "LinearSplit": { + "value": { "Deref": { "register": "AP", - "offset": -7 + "offset": -1 } }, - "dst": { + "scalar": { + "Immediate": "0x8000000000000110000000000000000" + }, + "max_x": { + "Immediate": "0xfffffffffffffffffffffffffffffffe" + }, + "x": { "register": "AP", "offset": 0 + }, + "y": { + "register": "AP", + "offset": 1 } } } ] ], [ - 48, + 590, [ { - "AllocSegment": { + "TestLessThan": { + "lhs": { + "BinOp": { + "op": "Add", + "a": { + "register": "AP", + "offset": -1 + }, + "b": { + "Immediate": "0x0" + } + } + }, + "rhs": { + "Immediate": "0x100000000" + }, "dst": { "register": "AP", "offset": 0 @@ -175,23 +1207,54 @@ ] ], [ - 65, + 594, [ { - "AllocSegment": { - "dst": { + "LinearSplit": { + "value": { + "Deref": { + "register": "AP", + "offset": -1 + } + }, + "scalar": { + "Immediate": "0x8000000000000110000000000000000" + }, + "max_x": { + "Immediate": "0xfffffffffffffffffffffffffffffffe" + }, + "x": { "register": "AP", "offset": 0 + }, + "y": { + "register": "AP", + "offset": 1 } } } ] ], [ - 80, + 636, [ { - "AllocSegment": { + "TestLessThan": { + "lhs": { + "BinOp": { + "op": "Add", + "a": { + "register": "AP", + "offset": -1 + }, + "b": { + "Immediate": "0x0" + } + } + }, + "rhs": { + "Immediate": "0x100000000" + }, "dst": { "register": "AP", "offset": 0 @@ -199,6 +1262,35 @@ } } ] + ], + [ + 640, + [ + { + "LinearSplit": { + "value": { + "Deref": { + "register": "AP", + "offset": -1 + } + }, + "scalar": { + "Immediate": "0x8000000000000110000000000000000" + }, + "max_x": { + "Immediate": "0xfffffffffffffffffffffffffffffffe" + }, + "x": { + "register": "AP", + "offset": 0 + }, + "y": { + "register": "AP", + "offset": 1 + } + } + } + ] ] ], "pythonic_hints": [ @@ -209,40 +1301,178 @@ ] ], [ - 17, + 33, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 80, [ "memory[ap + 0] = segments.add()" ] ], [ - 36, + 99, [ - "memory[ap + 0] = 0 <= memory[ap + -7]" + "memory[ap + 0] = 9550 <= memory[ap + -11]" ] ], [ - 48, + 119, [ "memory[ap + 0] = segments.add()" ] ], [ - 65, + 158, [ "memory[ap + 0] = segments.add()" ] ], [ - 80, + 173, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 187, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 202, + [ + "memory[ap + 0] = 2370 <= memory[fp + -8]" + ] + ], + [ + 274, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 302, + [ + "memory[ap + 0] = memory[ap + -1] < 4294967296" + ] + ], + [ + 313, + [ + "memory[ap + 0] = memory[ap + -1] < 4294967296" + ] + ], + [ + 324, + [ + "memory[ap + 0] = memory[ap + -1] < 4294967296" + ] + ], + [ + 334, + [ + "memory[ap + 0] = (memory[ap + -9] + memory[ap + -6]) % PRIME < 4294967296" + ] + ], + [ + 355, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 367, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 384, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 399, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 414, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 429, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 444, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 456, + [ + "memory[ap + 0] = 2270 <= memory[fp + -7]" + ] + ], + [ + 508, [ "memory[ap + 0] = segments.add()" ] + ], + [ + 544, + [ + "memory[ap + 0] = (memory[ap + -1] + 0) % PRIME < 4294967296" + ] + ], + [ + 548, + [ + "\n(value, scalar) = (memory[ap + -1], 10633823966279327296825105735305134080)\nx = min(value // scalar, 340282366920938463463374607431768211454)\ny = value - x * scalar\nmemory[ap + 0] = x\nmemory[ap + 1] = y\n" + ] + ], + [ + 590, + [ + "memory[ap + 0] = (memory[ap + -1] + 0) % PRIME < 4294967296" + ] + ], + [ + 594, + [ + "\n(value, scalar) = (memory[ap + -1], 10633823966279327296825105735305134080)\nx = min(value // scalar, 340282366920938463463374607431768211454)\ny = value - x * scalar\nmemory[ap + 0] = x\nmemory[ap + 1] = y\n" + ] + ], + [ + 636, + [ + "memory[ap + 0] = (memory[ap + -1] + 0) % PRIME < 4294967296" + ] + ], + [ + 640, + [ + "\n(value, scalar) = (memory[ap + -1], 10633823966279327296825105735305134080)\nx = min(value // scalar, 340282366920938463463374607431768211454)\ny = value - x * scalar\nmemory[ap + 0] = x\nmemory[ap + 1] = y\n" + ] ] ], "entry_points_by_type": { "EXTERNAL": [ { - "selector": "0x0", + "selector": "0xe2054f8a912367e38a22ce773328ff8aabf8082c4120bad9ef085e1dbf29a7", "offset": 0, "builtins": [ "range_check" diff --git a/cairo0-bootloader/bootloader/contract/execute_entry_point.cairo b/cairo0-bootloader/bootloader/contract/execute_entry_point.cairo index d84c010..8628324 100644 --- a/cairo0-bootloader/bootloader/contract/execute_entry_point.cairo +++ b/cairo0-bootloader/bootloader/contract/execute_entry_point.cairo @@ -181,7 +181,7 @@ func execute_entry_point{ // Use tempvar to pass the rest of the arguments to contract_entry_point(). let current_ap = ap; tempvar args = EntryPointCallArguments( - gas_builtin=0, + gas_builtin=1000000, syscall_ptr=syscall_ptr, calldata_start=calldata_start, calldata_end=calldata_end, @@ -242,8 +242,8 @@ func execute_entry_point{ %{ print(ids.entry_point_return_values.failure_flag) - for i in range(0, 1): - print(hex(memory[ids.retdata_start + i])) + for i in range(0, 4): + print(memory[ids.retdata_start + i]) %} return (retdata_size=0, retdata=cast(0, felt*)); diff --git a/cairo0-bootloader/bootloader/contract/run_contract_bootloader.cairo b/cairo0-bootloader/bootloader/contract/run_contract_bootloader.cairo index 4861c52..f5453f5 100644 --- a/cairo0-bootloader/bootloader/contract/run_contract_bootloader.cairo +++ b/cairo0-bootloader/bootloader/contract/run_contract_bootloader.cairo @@ -93,12 +93,17 @@ func run_contract_bootloader{ local calldata: felt*; %{ ids.calldata = segments.add() %} + + assert calldata[0] = 0x3; + assert calldata[1] = 0x3; + assert calldata[2] = 0x4; + assert calldata[3] = 0x5; - local execution_info: ExecutionInfo = ExecutionInfo(selector=0); + local execution_info: ExecutionInfo = ExecutionInfo(selector=0x00e2054f8a912367e38a22ce773328ff8aabf8082c4120bad9ef085e1dbf29a7); local execution_context: ExecutionContext = ExecutionContext( entry_point_type=ENTRY_POINT_TYPE_EXTERNAL, - calldata_size=0, + calldata_size=4, calldata=calldata, execution_info=&execution_info, ); diff --git a/cairo1/Scarb.lock b/cairo1/Scarb.lock deleted file mode 100644 index 81f37d4..0000000 --- a/cairo1/Scarb.lock +++ /dev/null @@ -1,6 +0,0 @@ -# Code generated by scarb DO NOT EDIT. -version = 1 - -[[package]] -name = "example" -version = "0.1.0" diff --git a/cairo1/Scarb.toml b/cairo1/Scarb.toml deleted file mode 100644 index d6b7d0f..0000000 --- a/cairo1/Scarb.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "example" -version = "0.1.0" -edition = "2023_11" - -# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html - -[dependencies] diff --git a/cairo1/contract.json b/cairo1/contract.json deleted file mode 100644 index 1acc529..0000000 --- a/cairo1/contract.json +++ /dev/null @@ -1,251 +0,0 @@ -{ - "prime": "0x800000000000011000000000000000000000000000000000000000000000001", - "compiler_version": "2.6.3", - "bytecode": [ - "0xa0680017fff8000", - "0x7", - "0x482680017ffa8000", - "0x100000000000000000000000000000000", - "0x400280007ff97fff", - "0x10780017fff7fff", - "0x49", - "0x4825800180007ffa", - "0x0", - "0x400280007ff97fff", - "0x482680017ff98000", - "0x1", - "0x48297ffc80007ffd", - "0x20680017fff7fff", - "0x4", - "0x10780017fff7fff", - "0x10", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", - "0x400080007ffe7fff", - "0x48127ffc7fff8000", - "0x48127ffa7fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x1104800180018000", - "0x3e", - "0x482480017fff8000", - "0x3d", - "0x480080007fff8000", - "0xa0680017fff8000", - "0x9", - "0x4824800180007ff8", - "0x0", - "0x482480017fff8000", - "0x100000000000000000000000000000000", - "0x400080007ff77fff", - "0x10780017fff7fff", - "0x14", - "0x4824800180007ff8", - "0x0", - "0x400080007ff87fff", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0xfffffff0f", - "0x400080007ffe7fff", - "0x482480017ff68000", - "0x1", - "0x48127ffc7fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x0", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4f7574206f6620676173", - "0x400080007ffe7fff", - "0x482480017ff58000", - "0x1", - "0x48127ff37fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4f7574206f6620676173", - "0x400080007ffe7fff", - "0x482680017ff98000", - "0x1", - "0x480a7ffa7fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe" - ], - "bytecode_segment_lengths": [ - 93 - ], - "hints": [ - [ - 0, - [ - { - "TestLessThanOrEqual": { - "lhs": { - "Immediate": "0x0" - }, - "rhs": { - "Deref": { - "register": "FP", - "offset": -6 - } - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 17, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 36, - [ - { - "TestLessThanOrEqual": { - "lhs": { - "Immediate": "0x0" - }, - "rhs": { - "Deref": { - "register": "AP", - "offset": -7 - } - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 48, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 63, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 78, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ] - ], - "pythonic_hints": [ - [ - 0, - [ - "memory[ap + 0] = 0 <= memory[fp + -6]" - ] - ], - [ - 17, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 36, - [ - "memory[ap + 0] = 0 <= memory[ap + -7]" - ] - ], - [ - 48, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 63, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 78, - [ - "memory[ap + 0] = segments.add()" - ] - ] - ], - "entry_points_by_type": { - "EXTERNAL": [ - { - "selector": "0x36fbc999025b89d36d31dc2f9c0a03b4377755e1f27e0e42a385aaba90f61a6", - "offset": 0, - "builtins": [ - "range_check" - ] - } - ], - "L1_HANDLER": [], - "CONSTRUCTOR": [] - } -} \ No newline at end of file diff --git a/cairo1/src/lib.cairo b/cairo1/src/lib.cairo deleted file mode 100644 index 0352d5e..0000000 --- a/cairo1/src/lib.cairo +++ /dev/null @@ -1,28 +0,0 @@ -#[derive(Drop, Serde)] -struct Input { - a: u32, - b: u32, - c: u32, -} - -struct Output { - a_2: u32, - b_2: u32, - c_2: u32, -} - -fn main(input: Array) -> Output { - let mut input_span = input.span(); - let input = Serde::::deserialize(ref input_span).unwrap(); - - let a_2 = input.a * input.a; - let b_2 = input.b * input.b; - let c_2 = input.c * input.c; - assert (a_2 + b_2 == c_2, 'invalid value'); - - Output { - a_2, - b_2, - c_2, - } -} \ No newline at end of file diff --git a/contract/.gitignore b/contract/.gitignore new file mode 100644 index 0000000..a0d82f2 --- /dev/null +++ b/contract/.gitignore @@ -0,0 +1,4 @@ +target +.snfoundry_cache/ + +contract.* \ No newline at end of file diff --git a/contract/Scarb.lock b/contract/Scarb.lock new file mode 100644 index 0000000..e4f03d7 --- /dev/null +++ b/contract/Scarb.lock @@ -0,0 +1,14 @@ +# Code generated by scarb DO NOT EDIT. +version = 1 + +[[package]] +name = "contract" +version = "0.1.0" +dependencies = [ + "snforge_std", +] + +[[package]] +name = "snforge_std" +version = "0.24.0" +source = "git+https://github.com/foundry-rs/starknet-foundry?tag=v0.24.0#95e9fb09cb91b3c05295915179ee1b55bf923653" diff --git a/contract/Scarb.toml b/contract/Scarb.toml new file mode 100644 index 0000000..65e57ab --- /dev/null +++ b/contract/Scarb.toml @@ -0,0 +1,18 @@ +[package] +name = "contract" +version = "0.1.0" +edition = "2023_11" + +# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html + +[dependencies] +starknet = "2.6.3" + +[dev-dependencies] +snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.24.0" } + +[[target.starknet-contract]] +sierra = true + +[scripts] +test = "snforge test" diff --git a/contract/src/lib.cairo b/contract/src/lib.cairo new file mode 100644 index 0000000..667f6a2 --- /dev/null +++ b/contract/src/lib.cairo @@ -0,0 +1,41 @@ +#[starknet::interface] +pub trait IHelloStarknet { + fn main(ref self: TContractState, input: Array) -> Array; +} + +#[starknet::contract] +mod HelloStarknet { + #[derive(Drop, Serde)] + struct Input { + a: u32, + b: u32, + c: u32, + } + + #[derive(Drop, Serde)] + struct Output { + a_2: u32, + b_2: u32, + c_2: u32, + } + + #[storage] + struct Storage {} + + #[abi(embed_v0)] + impl HelloStarknetImpl of super::IHelloStarknet { + fn main(ref self: ContractState, input: Array) -> Array { + let mut input_span = input.span(); + let input = Serde::::deserialize(ref input_span).unwrap(); + + let a_2 = input.a * input.a; + let b_2 = input.b * input.b; + let c_2 = input.c * input.c; + assert(a_2 + b_2 == c_2, 'invalid value'); + + let mut output = array![]; + Output { a_2, b_2, c_2, }.serialize(ref output); + output + } + } +}