diff --git a/assembler/test_data/asm/sys/NonceHolder_asm.json b/assembler/test_data/asm/sys/NonceHolder_asm.json index 1c719d70..bdf74837 100644 --- a/assembler/test_data/asm/sys/NonceHolder_asm.json +++ b/assembler/test_data/asm/sys/NonceHolder_asm.json @@ -1,5 +1,5 @@ { - "program": "heap_malloc:\n.LBL17_0:\n mov r3 18446744060824649731\n mload r0 [r3]\n add r2 r0 r1\n mov r1 18446744060824649731\n mstore [r1] r2\n ret\nvector_new:\n.LBL18_0:\n mov r4 18446744060824649731\n mload r0 [r4]\n add r2 r1 1\n add r3 r0 r2\n mov r2 18446744060824649731\n mstore [r2] r3\n mstore [r0] r1\n ret\nsplit_field:\n.LBL19_0:\n mov r6 r1\n mov r1 r6\n.PROPHET19_0:\n mov r0 psp\n mload r0 [r0]\n mov r7 r0\n range r7\n mov r1 r6\n.PROPHET19_1:\n mov r0 psp\n mload r0 [r0]\n mov r1 r0\n range r1\n mul r4 r7 4294967296\n add r5 r4 r1\n eq r4 r6 r5\n assert r4\n mstore [r2] r7\n mstore [r3] r1\n ret\nmemcpy:\n.LBL20_0:\n add r9 r9 1\n mov r4 0\n mstore [r9,-1] r4\n jmp .LBL20_1\n.LBL20_1:\n mload r4 [r9,-1]\n gte r5 r3 r4\n neq r6 r4 r3\n and r5 r5 r6\n cjmp r5 .LBL20_2\n jmp .LBL20_3\n.LBL20_2:\n mload r6 [r1,r4]\n mstore [r2,r4] r6\n add r5 r4 1\n mstore [r9,-1] r5\n jmp .LBL20_1\n.LBL20_3:\n add r9 r9 -1\n ret\nmemcmp_eq:\n.LBL21_0:\n add r9 r9 1\n mov r4 0\n mstore [r9,-1] r4\n jmp .LBL21_1\n.LBL21_1:\n mload r4 [r9,-1]\n gte r5 r3 r4\n neq r6 r4 r3\n and r5 r5 r6\n cjmp r5 .LBL21_2\n mov r0 1\n jmp .LBL21_3\n.LBL21_2:\n mload r6 [r1,r4]\n mload r7 [r2,r4]\n add r5 r4 1\n mstore [r9,-1] r5\n eq r4 r6 r7\n cjmp r4 .LBL21_1\n mov r0 0\n jmp .LBL21_3\n.LBL21_3:\n add r9 r9 -1\n ret\nmemcmp_ne:\n.LBL22_0:\n add r9 r9 1\n mov r4 0\n mstore [r9,-1] r4\n jmp .LBL22_1\n.LBL22_1:\n mload r4 [r9,-1]\n gte r5 r3 r4\n neq r6 r4 r3\n and r5 r5 r6\n cjmp r5 .LBL22_2\n mov r0 0\n jmp .LBL22_3\n.LBL22_2:\n mload r6 [r1,r4]\n mload r7 [r2,r4]\n add r5 r4 1\n mstore [r9,-1] r5\n eq r4 r6 r7\n cjmp r4 .LBL22_1\n mov r0 1\n jmp .LBL22_3\n.LBL22_3:\n add r9 r9 -1\n ret\nmemcmp_ugt:\n.LBL23_0:\n add r9 r9 1\n mov r4 0\n mstore [r9,-1] r4\n jmp .LBL23_1\n.LBL23_1:\n mload r4 [r9,-1]\n gte r5 r3 r4\n neq r6 r4 r3\n and r5 r5 r6\n cjmp r5 .LBL23_2\n mov r0 0\n jmp .LBL23_3\n.LBL23_2:\n mload r6 [r1,r4]\n mload r7 [r2,r4]\n add r5 r4 1\n mstore [r9,-1] r5\n gte r4 r7 r6\n cjmp r4 .LBL23_1\n mov r0 1\n jmp .LBL23_3\n.LBL23_3:\n add r9 r9 -1\n ret\nmemcmp_uge:\n.LBL24_0:\n add r9 r9 1\n mov r4 0\n mstore [r9,-1] r4\n jmp .LBL24_1\n.LBL24_1:\n mload r4 [r9,-1]\n gte r5 r3 r4\n neq r6 r4 r3\n and r5 r5 r6\n cjmp r5 .LBL24_2\n mov r0 1\n jmp .LBL24_3\n.LBL24_2:\n mload r6 [r1,r4]\n mload r7 [r2,r4]\n add r5 r4 1\n mstore [r9,-1] r5\n gte r4 r6 r7\n cjmp r4 .LBL24_1\n mov r0 0\n jmp .LBL24_3\n.LBL24_3:\n add r9 r9 -1\n ret\nmemcmp_ult:\n.LBL25_0:\n add r9 r9 1\n mov r4 0\n mstore [r9,-1] r4\n jmp .LBL25_1\n.LBL25_1:\n mload r4 [r9,-1]\n gte r5 r3 r4\n neq r6 r4 r3\n and r5 r5 r6\n cjmp r5 .LBL25_2\n mov r0 0\n jmp .LBL25_3\n.LBL25_2:\n mload r6 [r1,r4]\n mload r7 [r2,r4]\n add r5 r4 1\n mstore [r9,-1] r5\n gte r4 r6 r7\n cjmp r4 .LBL25_1\n mov r0 1\n jmp .LBL25_3\n.LBL25_3:\n add r9 r9 -1\n ret\nmemcmp_ule:\n.LBL26_0:\n add r9 r9 1\n mov r4 0\n mstore [r9,-1] r4\n jmp .LBL26_1\n.LBL26_1:\n mload r4 [r9,-1]\n gte r5 r3 r4\n neq r6 r4 r3\n and r5 r5 r6\n cjmp r5 .LBL26_2\n mov r0 1\n jmp .LBL26_3\n.LBL26_2:\n mload r6 [r1,r4]\n mload r7 [r2,r4]\n add r5 r4 1\n mstore [r9,-1] r5\n gte r4 r7 r6\n cjmp r4 .LBL26_1\n mov r0 0\n jmp .LBL26_3\n.LBL26_3:\n add r9 r9 -1\n ret\nfield_memcmp_ugt:\n.LBL27_0:\n add r9 r9 20\n mstore [r9,-2] r9\n mstore [r9,-8] r1\n mov r1 r2\n mstore [r9,-13] r1\n mov r1 r3\n mstore [r9,-10] r1\n mov r1 0\n mstore [r9,-7] r1\n jmp .LBL27_1\n.LBL27_1:\n mload r1 [r9,-7]\n mstore [r9,-12] r1\n mload r1 [r9,-10]\n mload r2 [r9,-12]\n gte r1 r1 r2\n mload r2 [r9,-10]\n mload r3 [r9,-12]\n neq r2 r3 r2\n and r1 r1 r2\n cjmp r1 .LBL27_2\n mov r0 0\n jmp .LBL27_4\n.LBL27_2:\n mload r1 [r9,-8]\n mload r2 [r9,-12]\n mload r1 [r1,r2]\n mload r2 [r9,-12]\n mload r3 [r9,-13]\n mload r2 [r3,r2]\n mstore [r9,-9] r2\n add r3 r9 -5\n add r2 r9 -6\n call split_field\n mload r1 [r9,-6]\n mstore [r9,-20] r1\n mload r1 [r9,-5]\n mstore [r9,-17] r1\n add r3 r9 -3\n add r2 r9 -4\n mload r1 [r9,-9]\n call split_field\n mload r1 [r9,-4]\n mload r2 [r9,-3]\n mload r3 [r9,-12]\n add r3 r3 1\n mstore [r9,-11] r3\n mload r3 [r9,-11]\n mstore [r9,-7] r3\n mload r3 [r9,-20]\n gte r1 r1 r3\n cjmp r1 .LBL27_3\n mov r0 1\n jmp .LBL27_4\n.LBL27_3:\n mload r1 [r9,-17]\n gte r1 r2 r1\n cjmp r1 .LBL27_1\n mov r0 1\n jmp .LBL27_4\n.LBL27_4:\n add r9 r9 -20\n ret\nfield_memcmp_uge:\n.LBL28_0:\n add r9 r9 20\n mstore [r9,-2] r9\n mstore [r9,-8] r1\n mov r1 r2\n mstore [r9,-13] r1\n mov r1 r3\n mstore [r9,-10] r1\n mov r1 0\n mstore [r9,-7] r1\n jmp .LBL28_1\n.LBL28_1:\n mload r1 [r9,-7]\n mstore [r9,-12] r1\n mload r1 [r9,-10]\n mload r2 [r9,-12]\n gte r1 r1 r2\n mload r2 [r9,-10]\n mload r3 [r9,-12]\n neq r2 r3 r2\n and r1 r1 r2\n cjmp r1 .LBL28_2\n mov r0 1\n jmp .LBL28_4\n.LBL28_2:\n mload r1 [r9,-8]\n mload r2 [r9,-12]\n mload r1 [r1,r2]\n mload r2 [r9,-12]\n mload r3 [r9,-13]\n mload r2 [r3,r2]\n mstore [r9,-9] r2\n add r3 r9 -5\n add r2 r9 -6\n call split_field\n mload r1 [r9,-6]\n mstore [r9,-20] r1\n mload r1 [r9,-5]\n mstore [r9,-17] r1\n add r3 r9 -3\n add r2 r9 -4\n mload r1 [r9,-9]\n call split_field\n mload r1 [r9,-4]\n mload r2 [r9,-3]\n mload r3 [r9,-12]\n add r3 r3 1\n mstore [r9,-11] r3\n mload r3 [r9,-11]\n mstore [r9,-7] r3\n mload r3 [r9,-20]\n gte r1 r3 r1\n cjmp r1 .LBL28_3\n mov r0 0\n jmp .LBL28_4\n.LBL28_3:\n mload r1 [r9,-17]\n gte r1 r1 r2\n cjmp r1 .LBL28_1\n mov r0 0\n jmp .LBL28_4\n.LBL28_4:\n add r9 r9 -20\n ret\nfield_memcmp_ule:\n.LBL29_0:\n add r9 r9 20\n mstore [r9,-2] r9\n mstore [r9,-8] r1\n mov r1 r2\n mstore [r9,-13] r1\n mov r1 r3\n mstore [r9,-10] r1\n mov r1 0\n mstore [r9,-7] r1\n jmp .LBL29_1\n.LBL29_1:\n mload r1 [r9,-7]\n mstore [r9,-12] r1\n mload r1 [r9,-10]\n mload r2 [r9,-12]\n gte r1 r1 r2\n mload r2 [r9,-10]\n mload r3 [r9,-12]\n neq r2 r3 r2\n and r1 r1 r2\n cjmp r1 .LBL29_2\n mov r0 1\n jmp .LBL29_4\n.LBL29_2:\n mload r1 [r9,-8]\n mload r2 [r9,-12]\n mload r1 [r1,r2]\n mload r2 [r9,-12]\n mload r3 [r9,-13]\n mload r2 [r3,r2]\n mstore [r9,-9] r2\n add r3 r9 -5\n add r2 r9 -6\n call split_field\n mload r1 [r9,-6]\n mstore [r9,-20] r1\n mload r1 [r9,-5]\n mstore [r9,-17] r1\n add r3 r9 -3\n add r2 r9 -4\n mload r1 [r9,-9]\n call split_field\n mload r1 [r9,-4]\n mload r2 [r9,-3]\n mload r3 [r9,-12]\n add r3 r3 1\n mstore [r9,-11] r3\n mload r3 [r9,-11]\n mstore [r9,-7] r3\n mload r3 [r9,-20]\n gte r1 r1 r3\n cjmp r1 .LBL29_3\n mov r0 0\n jmp .LBL29_4\n.LBL29_3:\n mload r1 [r9,-17]\n gte r1 r2 r1\n cjmp r1 .LBL29_1\n mov r0 0\n jmp .LBL29_4\n.LBL29_4:\n add r9 r9 -20\n ret\nfield_memcmp_ult:\n.LBL30_0:\n add r9 r9 20\n mstore [r9,-2] r9\n mstore [r9,-8] r1\n mov r1 r2\n mstore [r9,-13] r1\n mov r1 r3\n mstore [r9,-10] r1\n mov r1 0\n mstore [r9,-7] r1\n jmp .LBL30_1\n.LBL30_1:\n mload r1 [r9,-7]\n mstore [r9,-12] r1\n mload r1 [r9,-10]\n mload r2 [r9,-12]\n gte r1 r1 r2\n mload r2 [r9,-10]\n mload r3 [r9,-12]\n neq r2 r3 r2\n and r1 r1 r2\n cjmp r1 .LBL30_2\n mov r0 0\n jmp .LBL30_4\n.LBL30_2:\n mload r1 [r9,-8]\n mload r2 [r9,-12]\n mload r1 [r1,r2]\n mload r2 [r9,-12]\n mload r3 [r9,-13]\n mload r2 [r3,r2]\n mstore [r9,-9] r2\n add r3 r9 -5\n add r2 r9 -6\n call split_field\n mload r1 [r9,-6]\n mstore [r9,-20] r1\n mload r1 [r9,-5]\n mstore [r9,-17] r1\n add r3 r9 -3\n add r2 r9 -4\n mload r1 [r9,-9]\n call split_field\n mload r1 [r9,-4]\n mload r2 [r9,-3]\n mload r3 [r9,-12]\n add r3 r3 1\n mstore [r9,-11] r3\n mload r3 [r9,-11]\n mstore [r9,-7] r3\n mload r3 [r9,-20]\n gte r1 r3 r1\n cjmp r1 .LBL30_3\n mov r0 1\n jmp .LBL30_4\n.LBL30_3:\n mload r1 [r9,-17]\n gte r1 r1 r2\n cjmp r1 .LBL30_1\n mov r0 1\n jmp .LBL30_4\n.LBL30_4:\n add r9 r9 -20\n ret\nu32_div_mod:\n.LBL31_0:\n add r9 r9 5\n mstore [r9,-3] r1\n mov r1 r2\n mstore [r9,-4] r1\n mload r1 [r9,-4]\n mov r2 r1\n mload r1 [r9,-3]\n.PROPHET31_0:\n mov r0 psp\n mload r0 [r0]\n mov r1 r0\n mstore [r9,-5] r1\n mload r1 [r9,-5]\n range r1\n mload r1 [r9,-5]\n add r5 r1 1\n not r7 r5\n add r7 r7 1\n mload r1 [r9,-4]\n add r6 r1 r7\n range r6\n mload r1 [r9,-4]\n mov r2 r1\n mload r1 [r9,-3]\n.PROPHET31_1:\n mov r0 psp\n mload r0 [r0]\n mov r1 r0\n range r3\n mload r2 [r9,-4]\n mul r2 r1 r2\n mstore [r9,-1] r2\n mload r2 [r9,-1]\n mload r5 [r9,-5]\n add r2 r2 r5\n mstore [r9,-2] r2\n mload r2 [r9,-2]\n mload r5 [r9,-3]\n eq r2 r2 r5\n assert r2\n mstore [r3] r1\n mload r1 [r9,-5]\n mstore [r4] r1\n add r9 r9 -5\n ret\nu32_power:\n.LBL32_0:\n mov r0 1\n mov r3 0\n jmp .LBL32_1\n.LBL32_1:\n add r5 r3 1\n mul r4 r0 r1\n gte r3 r2 r5\n cjmp r3 .LBL32_1\n mov r0 r4\n mov r3 r5\n jmp .LBL32_2\n.LBL32_2:\n range r0\n ret\nonlyEntrypointCall:\n.LBL33_0:\n add r9 r9 3\n mstore [r9,-2] r9\n mov r1 4\n call heap_malloc\n mov r5 r0\n mov r6 0\n mstore [r5] r6\n mov r6 0\n mstore [r5,+1] r6\n mov r6 0\n mstore [r5,+2] r6\n mov r6 32769\n mstore [r5,+3] r6\n mstore [r9,-3] r5\n mov r1 12\n call heap_malloc\n mov r1 r0\n mov r5 1\n tload r1 r5 12\n mload r2 [r9,-3]\n mov r3 4\n call memcmp_eq\n mov r5 r0\n assert r5\n add r9 r9 -3\n ret\nsetNonce:\n.LBL34_0:\n add r9 r9 41\n mstore [r9,-2] r9\n mov r5 r1\n mov r6 r2\n mstore [r9,-4] r5\n mstore [r9,-3] r6\n call onlyEntrypointCall\n mload r5 [r9,-3]\n mstore [r9,-10] r5\n mload r5 [r9,-4]\n mstore [r9,-8] r5\n mov r1 4\n call heap_malloc\n mov r5 r0\n mstore [r9,-13] r5\n mov r5 0\n mload r6 [r9,-13]\n mstore [r6] r5\n mov r5 0\n mload r6 [r9,-13]\n mstore [r6,+1] r5\n mov r5 0\n mload r6 [r9,-13]\n mstore [r6,+2] r5\n mov r5 0\n mload r6 [r9,-13]\n mstore [r6,+3] r5\n mov r1 8\n call heap_malloc\n mov r5 r0\n mstore [r9,-17] r5\n mov r3 4\n mload r2 [r9,-17]\n mload r1 [r9,-13]\n call memcpy\n mov r3 4\n mload r5 [r9,-17]\n add r2 r5 4\n mload r1 [r9,-8]\n call memcpy\n mov r1 4\n call heap_malloc\n mov r5 r0\n mstore [r9,-30] r5\n mload r5 [r9,-17]\n poseidon r5 r5 8\n mstore [r9,-30] r5\n mov r1 4\n call heap_malloc\n mov r5 r0\n mload r6 [r9,-30]\n sload r6 r5\n mload r5 [r5]\n mload r6 [r9,-30]\n mload r6 [r6]\n add r6 r6 1\n mstore [r9,-6] r6\n mload r6 [r9,-6]\n mload r7 [r9,-30]\n mstore [r7] r6\n add r5 r5 1\n mstore [r9,-5] r5\n mload r5 [r9,-5]\n range r5\n mload r5 [r9,-5]\n mload r6 [r9,-10]\n eq r5 r6 r5\n assert r5\n mload r5 [r9,-4]\n mstore [r9,-33] r5\n mov r1 4\n call heap_malloc\n mov r5 r0\n mstore [r9,-35] r5\n mov r5 0\n mload r6 [r9,-35]\n mstore [r6] r5\n mov r5 0\n mload r6 [r9,-35]\n mstore [r6,+1] r5\n mov r5 0\n mload r6 [r9,-35]\n mstore [r6,+2] r5\n mov r5 0\n mload r6 [r9,-35]\n mstore [r6,+3] r5\n mov r1 8\n call heap_malloc\n mov r5 r0\n mstore [r9,-36] r5\n mov r3 4\n mload r2 [r9,-36]\n mload r1 [r9,-35]\n call memcpy\n mov r3 4\n mload r5 [r9,-36]\n add r2 r5 4\n mload r1 [r9,-33]\n call memcpy\n mov r1 4\n call heap_malloc\n mov r5 r0\n mstore [r9,-40] r5\n mload r5 [r9,-36]\n poseidon r5 r5 8\n mstore [r9,-40] r5\n mload r5 [r9,-3]\n mstore [r9,-41] r5\n mov r1 4\n call heap_malloc\n mov r5 r0\n mload r6 [r9,-41]\n mstore [r5] r6\n mov r6 0\n mstore [r5,+1] r6\n mov r6 0\n mstore [r5,+2] r6\n mov r6 0\n mstore [r5,+3] r6\n mload r6 [r9,-40]\n sstore r6 r5\n add r9 r9 -41\n ret\ngetNonce:\n.LBL35_0:\n add r9 r9 17\n mstore [r9,-2] r9\n mov r5 r1\n mstore [r9,-3] r5\n mload r5 [r9,-3]\n mstore [r9,-4] r5\n mov r1 4\n call heap_malloc\n mov r5 r0\n mstore [r9,-6] r5\n mov r5 0\n mload r6 [r9,-6]\n mstore [r6] r5\n mov r5 0\n mload r6 [r9,-6]\n mstore [r6,+1] r5\n mov r5 0\n mload r6 [r9,-6]\n mstore [r6,+2] r5\n mov r5 0\n mload r6 [r9,-6]\n mstore [r6,+3] r5\n mov r1 8\n call heap_malloc\n mov r5 r0\n mstore [r9,-9] r5\n mov r3 4\n mload r2 [r9,-9]\n mload r1 [r9,-6]\n call memcpy\n mov r3 4\n mload r5 [r9,-9]\n add r2 r5 4\n mload r1 [r9,-4]\n call memcpy\n mov r1 4\n call heap_malloc\n mov r5 r0\n mstore [r9,-16] r5\n mload r5 [r9,-9]\n poseidon r5 r5 8\n mstore [r9,-16] r5\n mov r1 4\n call heap_malloc\n mov r5 r0\n mload r6 [r9,-16]\n sload r6 r5\n mload r0 [r5]\n mload r5 [r9,-16]\n mload r5 [r5]\n add r5 r5 1\n mstore [r9,-5] r5\n mload r5 [r9,-5]\n mload r6 [r9,-16]\n mstore [r6] r5\n add r9 r9 -17\n ret\nfunction_dispatch:\n.LBL36_0:\n add r9 r9 3\n mstore [r9,-2] r9\n mov r2 r3\n eq r8 r1 3726813225\n cjmp r8 .LBL36_2\n eq r8 r1 1093482716\n cjmp r8 .LBL36_3\n eq r8 r1 755185067\n cjmp r8 .LBL36_4\n jmp .LBL36_1\n.LBL36_1:\n ret\n.LBL36_2:\n call onlyEntrypointCall\n mov r1 1\n call heap_malloc\n mov r1 r0\n mov r2 0\n mstore [r1] r2\n tstore r1 1\n add r9 r9 -3\n ret\n.LBL36_3:\n add r1 r2 0\n mload r2 [r1,+4]\n call setNonce\n mov r1 1\n call heap_malloc\n mov r1 r0\n mov r2 0\n mstore [r1] r2\n tstore r1 1\n add r9 r9 -3\n ret\n.LBL36_4:\n add r1 r2 0\n call getNonce\n mov r1 r0\n mstore [r9,-3] r1\n mov r1 2\n call heap_malloc\n mov r1 r0\n mload r2 [r9,-3]\n mstore [r1] r2\n mov r2 1\n mstore [r1,+1] r2\n tstore r1 2\n add r9 r9 -3\n ret\nmain:\n.LBL37_0:\n add r9 r9 8\n mstore [r9,-2] r9\n mov r1 13\n call heap_malloc\n mov r5 r0\n mov r6 1\n tload r5 r6 13\n mload r5 [r5]\n mstore [r9,-4] r5\n mov r1 14\n call heap_malloc\n mov r5 r0\n mov r6 1\n tload r5 r6 14\n mload r5 [r5]\n mstore [r9,-6] r5\n mload r5 [r9,-6]\n add r5 r5 14\n mstore [r9,-3] r5\n mload r1 [r9,-3]\n call heap_malloc\n mov r3 r0\n mov r5 1\n mload r6 [r9,-3]\n tload r3 r5 r6\n mload r2 [r9,-6]\n mload r1 [r9,-4]\n call function_dispatch\n add r9 r9 -8\n end\n", + "program": "heap_malloc:\n.LBL14_0:\n add r9 r9 1\n mstore [r9,-1] r1\n mload r1 [r9,-1]\n mov r3 18446744060824649731\n mload r0 [r3]\n add r2 r0 r1\n mov r1 18446744060824649731\n mstore [r1] r2\n add r9 r9 -1\n ret\nvector_new:\n.LBL15_0:\n add r9 r9 1\n mstore [r9,-1] r1\n mload r1 [r9,-1]\n mov r4 18446744060824649731\n mload r0 [r4]\n add r2 r1 1\n add r3 r0 r2\n mov r2 18446744060824649731\n mstore [r2] r3\n mstore [r0] r1\n add r9 r9 -1\n ret\nmemcpy:\n.LBL16_0:\n add r9 r9 4\n mstore [r9,-4] r1\n mload r1 [r9,-4]\n mstore [r9,-3] r2\n mload r2 [r9,-3]\n mstore [r9,-2] r3\n mload r3 [r9,-2]\n mov r4 0\n mstore [r9,-1] r4\n jmp .LBL16_1\n.LBL16_1:\n mload r4 [r9,-1]\n gte r5 r3 r4\n neq r6 r4 r3\n and r5 r5 r6\n cjmp r5 .LBL16_2\n jmp .LBL16_3\n.LBL16_2:\n mload r6 [r1,r4]\n mstore [r2,r4] r6\n add r5 r4 1\n mstore [r9,-1] r5\n jmp .LBL16_1\n.LBL16_3:\n add r9 r9 -4\n ret\nmemcmp_eq:\n.LBL17_0:\n add r9 r9 4\n mstore [r9,-4] r1\n mload r1 [r9,-4]\n mstore [r9,-3] r2\n mload r2 [r9,-3]\n mstore [r9,-2] r3\n mload r3 [r9,-2]\n mov r4 0\n mstore [r9,-1] r4\n jmp .LBL17_1\n.LBL17_1:\n mload r4 [r9,-1]\n gte r5 r3 r4\n neq r6 r4 r3\n and r5 r5 r6\n cjmp r5 .LBL17_2\n mov r0 1\n jmp .LBL17_3\n.LBL17_2:\n mload r6 [r1,r4]\n mload r7 [r2,r4]\n add r5 r4 1\n mstore [r9,-1] r5\n eq r4 r6 r7\n cjmp r4 .LBL17_1\n mov r0 0\n jmp .LBL17_3\n.LBL17_3:\n add r9 r9 -4\n ret\nmemcmp_ugt:\n.LBL18_0:\n add r9 r9 4\n mstore [r9,-4] r1\n mload r1 [r9,-4]\n mstore [r9,-3] r2\n mload r2 [r9,-3]\n mstore [r9,-2] r3\n mload r3 [r9,-2]\n mov r4 0\n mstore [r9,-1] r4\n jmp .LBL18_1\n.LBL18_1:\n mload r4 [r9,-1]\n gte r5 r3 r4\n neq r6 r4 r3\n and r5 r5 r6\n cjmp r5 .LBL18_2\n mov r0 1\n jmp .LBL18_3\n.LBL18_2:\n mload r6 [r1,r4]\n mload r7 [r2,r4]\n add r5 r4 1\n mstore [r9,-1] r5\n gte r4 r6 r7\n neq r5 r6 r7\n and r4 r4 r5\n cjmp r4 .LBL18_1\n mov r0 0\n jmp .LBL18_3\n.LBL18_3:\n add r9 r9 -4\n ret\nmemcmp_uge:\n.LBL19_0:\n add r9 r9 4\n mstore [r9,-4] r1\n mload r1 [r9,-4]\n mstore [r9,-3] r2\n mload r2 [r9,-3]\n mstore [r9,-2] r3\n mload r3 [r9,-2]\n mov r4 0\n mstore [r9,-1] r4\n jmp .LBL19_1\n.LBL19_1:\n mload r4 [r9,-1]\n gte r5 r3 r4\n neq r6 r4 r3\n and r5 r5 r6\n cjmp r5 .LBL19_2\n mov r0 1\n jmp .LBL19_3\n.LBL19_2:\n mload r6 [r1,r4]\n mload r7 [r2,r4]\n add r5 r4 1\n mstore [r9,-1] r5\n gte r4 r6 r7\n cjmp r4 .LBL19_1\n mov r0 0\n jmp .LBL19_3\n.LBL19_3:\n add r9 r9 -4\n ret\nu32_div_mod:\n.LBL20_0:\n add r9 r9 9\n mstore [r9,-4] r1\n mload r1 [r9,-4]\n mstore [r9,-7] r1\n mstore [r9,-3] r2\n mload r1 [r9,-3]\n mstore [r9,-8] r1\n mstore [r9,-2] r3\n mload r3 [r9,-2]\n mstore [r9,-1] r4\n mload r4 [r9,-1]\n mload r1 [r9,-8]\n mov r2 r1\n mload r1 [r9,-7]\n.PROPHET20_0:\n mov r0 psp\n mload r0 [r0]\n mov r1 r0\n mstore [r9,-9] r1\n mload r1 [r9,-9]\n range r1\n mload r1 [r9,-9]\n add r5 r1 1\n not r7 r5\n add r7 r7 1\n mload r1 [r9,-8]\n add r6 r1 r7\n range r6\n mload r1 [r9,-8]\n mov r2 r1\n mload r1 [r9,-7]\n.PROPHET20_1:\n mov r0 psp\n mload r0 [r0]\n mov r1 r0\n range r3\n mload r2 [r9,-8]\n mul r2 r1 r2\n mstore [r9,-5] r2\n mload r2 [r9,-5]\n mload r5 [r9,-9]\n add r2 r2 r5\n mstore [r9,-6] r2\n mload r2 [r9,-6]\n mload r5 [r9,-7]\n eq r2 r2 r5\n assert r2\n mstore [r3] r1\n mload r1 [r9,-9]\n mstore [r4] r1\n add r9 r9 -9\n ret\nu32_power:\n.LBL21_0:\n add r9 r9 2\n mstore [r9,-2] r1\n mload r1 [r9,-2]\n mstore [r9,-1] r2\n mload r2 [r9,-1]\n mov r0 1\n mov r3 0\n jmp .LBL21_1\n.LBL21_1:\n add r5 r3 1\n mul r4 r0 r1\n gte r3 r2 r5\n cjmp r3 .LBL21_1\n mov r0 r4\n mov r3 r5\n jmp .LBL21_2\n.LBL21_2:\n range r0\n add r9 r9 -2\n ret\nonlyEntrypointCall:\n.LBL22_0:\n add r9 r9 3\n mstore [r9,-2] r9\n mov r1 4\n call heap_malloc\n mov r5 r0\n mov r6 0\n mstore [r5] r6\n mov r6 0\n mstore [r5,+1] r6\n mov r6 0\n mstore [r5,+2] r6\n mov r6 32769\n mstore [r5,+3] r6\n mstore [r9,-3] r5\n mov r1 12\n call heap_malloc\n mov r1 r0\n mov r5 1\n tload r1 r5 12\n mload r2 [r9,-3]\n mov r3 4\n call memcmp_eq\n mov r5 r0\n assert r5\n add r9 r9 -3\n ret\nisNonceUsed:\n.LBL23_0:\n add r9 r9 31\n mstore [r9,-2] r9\n mov r5 r1\n mov r6 r2\n mstore [r9,-4] r5\n mstore [r9,-3] r6\n mload r5 [r9,-4]\n mstore [r9,-6] r5\n mov r1 4\n call heap_malloc\n mov r5 r0\n mstore [r9,-9] r5\n mov r5 0\n mload r6 [r9,-9]\n mstore [r6] r5\n mov r5 0\n mload r6 [r9,-9]\n mstore [r6,+1] r5\n mov r5 0\n mload r6 [r9,-9]\n mstore [r6,+2] r5\n mov r5 0\n mload r6 [r9,-9]\n mstore [r6,+3] r5\n mov r1 8\n call heap_malloc\n mov r5 r0\n mstore [r9,-11] r5\n mov r3 4\n mload r2 [r9,-11]\n mload r1 [r9,-9]\n call memcpy\n mov r3 4\n mload r5 [r9,-11]\n add r2 r5 4\n mload r1 [r9,-6]\n call memcpy\n mov r1 4\n call heap_malloc\n mov r5 r0\n mstore [r9,-19] r5\n mload r5 [r9,-11]\n poseidon r5 r5 8\n mstore [r9,-19] r5\n mload r5 [r9,-3]\n mstore [r9,-18] r5\n mov r1 4\n call heap_malloc\n mov r5 r0\n mstore [r9,-21] r5\n mload r5 [r9,-18]\n mload r6 [r9,-21]\n mstore [r6] r5\n mov r5 0\n mload r6 [r9,-21]\n mstore [r6,+1] r5\n mov r5 0\n mload r6 [r9,-21]\n mstore [r6,+2] r5\n mov r5 0\n mload r6 [r9,-21]\n mstore [r6,+3] r5\n mov r1 8\n call heap_malloc\n mov r5 r0\n mstore [r9,-25] r5\n mov r3 4\n mload r2 [r9,-25]\n mload r1 [r9,-19]\n call memcpy\n mov r3 4\n mload r5 [r9,-25]\n add r2 r5 4\n mload r1 [r9,-21]\n call memcpy\n mov r1 4\n call heap_malloc\n mov r5 r0\n mstore [r9,-31] r5\n mload r5 [r9,-25]\n poseidon r5 r5 8\n mstore [r9,-31] r5\n mov r1 4\n call heap_malloc\n mov r5 r0\n mload r6 [r9,-31]\n sload r6 r5\n mload r0 [r5]\n mload r5 [r9,-31]\n mload r5 [r5]\n add r5 r5 1\n mstore [r9,-5] r5\n mload r5 [r9,-5]\n mload r6 [r9,-31]\n mstore [r6] r5\n add r9 r9 -31\n ret\nsetNonce:\n.LBL24_0:\n add r9 r9 139\n mstore [r9,-2] r9\n mov r5 r1\n mov r6 r2\n mstore [r9,-4] r5\n mstore [r9,-3] r6\n call onlyEntrypointCall\n mload r5 [r9,-4]\n mstore [r9,-11] r5\n mov r1 4\n call heap_malloc\n mov r5 r0\n mstore [r9,-16] r5\n mov r5 0\n mload r6 [r9,-16]\n mstore [r6] r5\n mov r5 0\n mload r6 [r9,-16]\n mstore [r6,+1] r5\n mov r5 0\n mload r6 [r9,-16]\n mstore [r6,+2] r5\n mov r5 0\n mload r6 [r9,-16]\n mstore [r6,+3] r5\n mov r1 8\n call heap_malloc\n mov r5 r0\n mstore [r9,-20] r5\n mov r3 4\n mload r2 [r9,-20]\n mload r1 [r9,-16]\n call memcpy\n mov r3 4\n mload r5 [r9,-20]\n add r2 r5 4\n mload r1 [r9,-11]\n call memcpy\n mov r1 4\n call heap_malloc\n mov r5 r0\n mstore [r9,-30] r5\n mload r5 [r9,-20]\n poseidon r5 r5 8\n mstore [r9,-30] r5\n mload r5 [r9,-3]\n mstore [r9,-32] r5\n mov r1 4\n call heap_malloc\n mov r5 r0\n mstore [r9,-39] r5\n mload r5 [r9,-32]\n mload r6 [r9,-39]\n mstore [r6] r5\n mov r5 0\n mload r6 [r9,-39]\n mstore [r6,+1] r5\n mov r5 0\n mload r6 [r9,-39]\n mstore [r6,+2] r5\n mov r5 0\n mload r6 [r9,-39]\n mstore [r6,+3] r5\n mov r1 8\n call heap_malloc\n mov r5 r0\n mstore [r9,-40] r5\n mov r3 4\n mload r2 [r9,-40]\n mload r1 [r9,-30]\n call memcpy\n mov r3 4\n mload r5 [r9,-40]\n add r2 r5 4\n mload r1 [r9,-39]\n call memcpy\n mov r1 4\n call heap_malloc\n mov r5 r0\n mstore [r9,-56] r5\n mload r5 [r9,-40]\n poseidon r5 r5 8\n mstore [r9,-56] r5\n mov r1 4\n call heap_malloc\n mov r5 r0\n mload r6 [r9,-56]\n sload r6 r5\n mload r5 [r5]\n mload r6 [r9,-56]\n mload r6 [r6]\n add r6 r6 1\n mstore [r9,-6] r6\n mload r6 [r9,-6]\n mload r7 [r9,-56]\n mstore [r7] r6\n eq r5 r5 0\n assert r5\n mload r5 [r9,-4]\n mstore [r9,-59] r5\n mov r1 4\n call heap_malloc\n mov r5 r0\n mstore [r9,-60] r5\n mov r5 0\n mload r6 [r9,-60]\n mstore [r6] r5\n mov r5 0\n mload r6 [r9,-60]\n mstore [r6,+1] r5\n mov r5 0\n mload r6 [r9,-60]\n mstore [r6,+2] r5\n mov r5 0\n mload r6 [r9,-60]\n mstore [r6,+3] r5\n mov r1 8\n call heap_malloc\n mov r5 r0\n mstore [r9,-66] r5\n mov r3 4\n mload r2 [r9,-66]\n mload r1 [r9,-60]\n call memcpy\n mov r3 4\n mload r5 [r9,-66]\n add r2 r5 4\n mload r1 [r9,-59]\n call memcpy\n mov r1 4\n call heap_malloc\n mov r5 r0\n mstore [r9,-76] r5\n mload r5 [r9,-66]\n poseidon r5 r5 8\n mstore [r9,-76] r5\n mload r5 [r9,-3]\n mstore [r9,-77] r5\n mov r1 4\n call heap_malloc\n mov r5 r0\n mstore [r9,-81] r5\n mload r5 [r9,-77]\n mload r6 [r9,-81]\n mstore [r6] r5\n mov r5 0\n mload r6 [r9,-81]\n mstore [r6,+1] r5\n mov r5 0\n mload r6 [r9,-81]\n mstore [r6,+2] r5\n mov r5 0\n mload r6 [r9,-81]\n mstore [r6,+3] r5\n mov r1 8\n call heap_malloc\n mov r5 r0\n mstore [r9,-84] r5\n mov r3 4\n mload r2 [r9,-84]\n mload r1 [r9,-76]\n call memcpy\n mov r3 4\n mload r5 [r9,-84]\n add r2 r5 4\n mload r1 [r9,-81]\n call memcpy\n mov r1 4\n call heap_malloc\n mov r5 r0\n mstore [r9,-92] r5\n mload r5 [r9,-84]\n poseidon r5 r5 8\n mstore [r9,-92] r5\n mov r1 4\n call heap_malloc\n mov r5 r0\n mov r6 1\n mstore [r5] r6\n mov r6 0\n mstore [r5,+1] r6\n mov r6 0\n mstore [r5,+2] r6\n mov r6 0\n mstore [r5,+3] r6\n mload r6 [r9,-92]\n sstore r6 r5\n mload r5 [r9,-4]\n mstore [r9,-95] r5\n mov r1 4\n call heap_malloc\n mov r5 r0\n mstore [r9,-100] r5\n mov r5 1\n mload r6 [r9,-100]\n mstore [r6] r5\n mov r5 0\n mload r6 [r9,-100]\n mstore [r6,+1] r5\n mov r5 0\n mload r6 [r9,-100]\n mstore [r6,+2] r5\n mov r5 0\n mload r6 [r9,-100]\n mstore [r6,+3] r5\n mov r1 8\n call heap_malloc\n mov r5 r0\n mstore [r9,-102] r5\n mov r3 4\n mload r2 [r9,-102]\n mload r1 [r9,-100]\n call memcpy\n mov r3 4\n mload r5 [r9,-102]\n add r2 r5 4\n mload r1 [r9,-95]\n call memcpy\n mov r1 4\n call heap_malloc\n mov r5 r0\n mstore [r9,-114] r5\n mload r5 [r9,-102]\n poseidon r5 r5 8\n mstore [r9,-114] r5\n mload r5 [r9,-4]\n mstore [r9,-115] r5\n mov r1 4\n call heap_malloc\n mov r5 r0\n mstore [r9,-116] r5\n mov r5 1\n mload r6 [r9,-116]\n mstore [r6] r5\n mov r5 0\n mload r6 [r9,-116]\n mstore [r6,+1] r5\n mov r5 0\n mload r6 [r9,-116]\n mstore [r6,+2] r5\n mov r5 0\n mload r6 [r9,-116]\n mstore [r6,+3] r5\n mov r1 8\n call heap_malloc\n mov r5 r0\n mstore [r9,-124] r5\n mov r3 4\n mload r2 [r9,-124]\n mload r1 [r9,-116]\n call memcpy\n mov r3 4\n mload r5 [r9,-124]\n add r2 r5 4\n mload r1 [r9,-115]\n call memcpy\n mov r1 4\n call heap_malloc\n mov r5 r0\n mstore [r9,-136] r5\n mload r5 [r9,-124]\n poseidon r5 r5 8\n mstore [r9,-136] r5\n mov r1 4\n call heap_malloc\n mov r5 r0\n mload r6 [r9,-136]\n sload r6 r5\n mload r5 [r5]\n mload r6 [r9,-136]\n mload r6 [r6]\n add r6 r6 1\n mstore [r9,-5] r6\n mload r6 [r9,-5]\n mload r7 [r9,-136]\n mstore [r7] r6\n add r5 r5 1\n mstore [r9,-7] r5\n mload r5 [r9,-7]\n range r5\n mov r1 4\n call heap_malloc\n mov r5 r0\n mload r6 [r9,-7]\n mstore [r5] r6\n mov r6 0\n mstore [r5,+1] r6\n mov r6 0\n mstore [r5,+2] r6\n mov r6 0\n mstore [r5,+3] r6\n mload r6 [r9,-114]\n sstore r6 r5\n add r9 r9 -139\n ret\nusedNonces:\n.LBL25_0:\n add r9 r9 17\n mstore [r9,-2] r9\n mov r5 r1\n mstore [r9,-3] r5\n mload r5 [r9,-3]\n mstore [r9,-4] r5\n mov r1 4\n call heap_malloc\n mov r5 r0\n mstore [r9,-6] r5\n mov r5 1\n mload r6 [r9,-6]\n mstore [r6] r5\n mov r5 0\n mload r6 [r9,-6]\n mstore [r6,+1] r5\n mov r5 0\n mload r6 [r9,-6]\n mstore [r6,+2] r5\n mov r5 0\n mload r6 [r9,-6]\n mstore [r6,+3] r5\n mov r1 8\n call heap_malloc\n mov r5 r0\n mstore [r9,-9] r5\n mov r3 4\n mload r2 [r9,-9]\n mload r1 [r9,-6]\n call memcpy\n mov r3 4\n mload r5 [r9,-9]\n add r2 r5 4\n mload r1 [r9,-4]\n call memcpy\n mov r1 4\n call heap_malloc\n mov r5 r0\n mstore [r9,-16] r5\n mload r5 [r9,-9]\n poseidon r5 r5 8\n mstore [r9,-16] r5\n mov r1 4\n call heap_malloc\n mov r5 r0\n mload r6 [r9,-16]\n sload r6 r5\n mload r0 [r5]\n mload r5 [r9,-16]\n mload r5 [r5]\n add r5 r5 1\n mstore [r9,-5] r5\n mload r5 [r9,-5]\n mload r6 [r9,-16]\n mstore [r6] r5\n add r9 r9 -17\n ret\nfunction_dispatch:\n.LBL26_0:\n add r9 r9 5\n mstore [r9,-2] r9\n mov r2 r3\n mstore [r9,-3] r2\n mload r2 [r9,-3]\n eq r8 r1 3726813225\n cjmp r8 .LBL26_2\n eq r8 r1 3775522898\n cjmp r8 .LBL26_3\n eq r8 r1 1093482716\n cjmp r8 .LBL26_4\n eq r8 r1 3868785611\n cjmp r8 .LBL26_5\n jmp .LBL26_1\n.LBL26_1:\n ret\n.LBL26_2:\n call onlyEntrypointCall\n mov r1 1\n call heap_malloc\n mov r1 r0\n mov r2 0\n mstore [r1] r2\n tstore r1 1\n add r9 r9 -5\n ret\n.LBL26_3:\n add r1 r2 0\n mload r2 [r1,+4]\n call isNonceUsed\n mov r1 r0\n mstore [r9,-4] r1\n mov r1 2\n call heap_malloc\n mov r1 r0\n mload r2 [r9,-4]\n mstore [r1] r2\n mov r2 1\n mstore [r1,+1] r2\n tstore r1 2\n add r9 r9 -5\n ret\n.LBL26_4:\n add r1 r2 0\n mload r2 [r1,+4]\n call setNonce\n mov r1 1\n call heap_malloc\n mov r1 r0\n mov r2 0\n mstore [r1] r2\n tstore r1 1\n add r9 r9 -5\n ret\n.LBL26_5:\n add r1 r2 0\n call usedNonces\n mov r1 r0\n mstore [r9,-5] r1\n mov r1 2\n call heap_malloc\n mov r1 r0\n mload r2 [r9,-5]\n mstore [r1] r2\n mov r2 1\n mstore [r1,+1] r2\n tstore r1 2\n add r9 r9 -5\n ret\nmain:\n.LBL27_0:\n add r9 r9 8\n mstore [r9,-2] r9\n mov r1 13\n call heap_malloc\n mov r5 r0\n mov r6 1\n tload r5 r6 13\n mload r5 [r5]\n mstore [r9,-4] r5\n mov r1 14\n call heap_malloc\n mov r5 r0\n mov r6 1\n tload r5 r6 14\n mload r5 [r5]\n mstore [r9,-6] r5\n mload r5 [r9,-6]\n add r5 r5 14\n mstore [r9,-3] r5\n mload r1 [r9,-3]\n call heap_malloc\n mov r3 r0\n mov r5 1\n mload r6 [r9,-3]\n tload r3 r5 r6\n mload r2 [r9,-6]\n mload r1 [r9,-4]\n call function_dispatch\n add r9 r9 -8\n end\n", "prophets": [ { "label": ".PROPHET19_0", diff --git a/core/src/state/mod.rs b/core/src/state/mod.rs index cbe708f7..2209d6d8 100644 --- a/core/src/state/mod.rs +++ b/core/src/state/mod.rs @@ -1,5 +1,6 @@ use crate::crypto::hash::Hasher; use crate::merkle_tree::log::StorageQuery; +use crate::merkle_tree::log::StorageQuery; use crate::state::contracts::Contracts; use std::collections::BTreeMap; diff --git a/executor/src/lib.rs b/executor/src/lib.rs index 26bf807e..388319ad 100644 --- a/executor/src/lib.rs +++ b/executor/src/lib.rs @@ -8,6 +8,7 @@ use core::vm::memory::{MemoryTree, HP_START_ADDR, PSP_START_ADDR}; use core::merkle_tree::log::{StorageLog, StorageQuery}; use core::merkle_tree::log::{StorageLogKind, WitnessStorageLog}; +use core::merkle_tree::tree::AccountTree; use core::program::instruction::IMM_INSTRUCTION_LEN; use core::program::instruction::{ImmediateOrRegName, Opcode}; @@ -249,6 +250,7 @@ pub struct Process { impl Process { pub fn new() -> Self { Self { + block_timestamp: 0, block_timestamp: 0, env_idx: Default::default(), call_sc_cnt: Default::default(), @@ -1905,8 +1907,10 @@ impl Process { if op1_value.0 == GoldilocksField::ONE { append_caller_callee_addr(self, self.addr_storage, callee_address, self.addr_storage); + append_caller_callee_addr(self, self.addr_storage, callee_address, self.addr_storage); } else if op1_value.0 == GoldilocksField::ZERO { append_caller_callee_addr(self, self.addr_storage, callee_address, callee_address); + append_caller_callee_addr(self, self.addr_storage, callee_address, callee_address); } else { return Err(ProcessorError::ParseOpcodeError); } diff --git a/executor/src/load_tx.rs b/executor/src/load_tx.rs index 1b0b66fa..258aa3fb 100644 --- a/executor/src/load_tx.rs +++ b/executor/src/load_tx.rs @@ -86,9 +86,28 @@ load_ctx_to_tape!(load_tx_context, TxCtxInfo); // process.tp += GoldilocksField::from_canonical_u64(ctx_addr_len as u64); // } +// pub fn init_tape( +// process: &mut Process, +// mut calldata: Vec, +// caller_exe_addr: Address, +// callee_addr: Address, +// callee_exe_addr: Address, +// ctx_info: &TxCtxInfo, +// ) { +// let tp_start = load_tx_context(process, ctx_info); +// process.tp = GoldilocksField::from_canonical_u64(tp_start as u64); +// load_tx_calldata(process, &calldata); +// let ctx_addr_len = load_ctx_addr_info( +// process, +// &init_ctx_addr_info(caller_exe_addr, callee_addr, callee_exe_addr), +// ); +// process.tp += GoldilocksField::from_canonical_u64(ctx_addr_len as u64); +// } + pub fn init_tape( process: &mut Process, calldata: Vec, + calldata: Vec, caller_exe_addr: Address, callee_addr: Address, callee_exe_addr: Address, diff --git a/zk-vm/src/lib.rs b/zk-vm/src/lib.rs index d304617a..9a8f8e77 100644 --- a/zk-vm/src/lib.rs +++ b/zk-vm/src/lib.rs @@ -336,6 +336,7 @@ impl OlaVM { caller_addr, code_exe_addr, code_exe_addr, + code_exe_addr, &self.ctx_info, ); let mut program = Program::default(); @@ -464,6 +465,7 @@ impl OlaVM { } self.ola_state.txs_trace.insert(env_id, trace); self.ola_state.storage_queries.append(&mut storage_queries); + self.ola_state.storage_queries.append(&mut storage_queries); env_idx -= 1; process.tp = tp; process.tape = tape_tree; @@ -498,4 +500,13 @@ impl OlaVM { false, ) } + + pub fn finish_batch(&mut self, block_number: u32) -> Result<(), StateError> { + let entry_point_addr = [0, 0, 0, 32769].map(|l| GoldilocksField::from_canonical_u64(l)); + let calldata = [block_number as u64, 1, 2190639505] + .iter() + .map(|l| GoldilocksField::from_canonical_u64(*l)) + .collect(); + self.execute_tx(entry_point_addr, entry_point_addr, calldata, false) + } }