From 1668a1b65f441e8c1c88c2d134c48527db14381e Mon Sep 17 00:00:00 2001 From: zkronos73 Date: Fri, 13 Jan 2023 15:54:56 +0000 Subject: [PATCH 1/2] add pil constraint Main.zPC[0] = 0 and Storage.pc[0] = 0 --- pil/main.pil | 6 ++++-- pil/storage.pil | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pil/main.pil b/pil/main.pil index 3f3e7ea8..d2575611 100644 --- a/pil/main.pil +++ b/pil/main.pil @@ -335,6 +335,8 @@ namespace Main(%N); // if elseAddr wasn't specified on zkasm, compiler put current address + 1 zkPC' = doJMP * (finalJmpAddr - nextNoJmpZkPC) + elseJMP * (finalElseAddr - nextNoJmpZkPC) + nextNoJmpZkPC; + zKPC * Global.L1 = 0; + (A0-op0)*assert = 0; (A1-op1)*assert = 0; (A2-op2)*assert = 0; @@ -523,13 +525,13 @@ namespace Main(%N); { CONST0, CONST1, CONST2, CONST3, CONST4, CONST5, CONST6, CONST7, inA, inB, inC, inROTL_C, inD, inE, inSR, inFREE, - inCTX, inSP, inPC, inGAS, inMAXMEM, inHASHPOS, inSTEP, inRR, inHASHPOS, inRCX, + inCTX, inSP, inPC, inGAS, inMAXMEM, inHASHPOS, inSTEP, inRR, inRCX, inCntArith, inCntBinary, inCntKeccakF, inCntMemAlign, inCntPaddingPG, inCntPoseidonG, operations, offset, incStack, binOpcode, jmpAddr, elseAddr, zkPC } in { Rom.CONST0, Rom.CONST1, Rom.CONST2, Rom.CONST3, Rom.CONST4, Rom.CONST5, Rom.CONST6, Rom.CONST7, Rom.inA, Rom.inB, Rom.inC, Rom.inROTL_C, Rom.inD, Rom.inE, Rom.inSR, Rom.inFREE, - Rom.inCTX, Rom.inSP, Rom.inPC, Rom.inGAS, Rom.inMAXMEM, Rom.inHASHPOS, Rom.inSTEP, Rom.inRR, Rom.inHASHPOS, Rom.inRCX, + Rom.inCTX, Rom.inSP, Rom.inPC, Rom.inGAS, Rom.inMAXMEM, Rom.inHASHPOS, Rom.inSTEP, Rom.inRR, Rom.inRCX, Rom.inCntArith, Rom.inCntBinary, Rom.inCntKeccakF, Rom.inCntMemAlign, Rom.inCntPaddingPG, Rom.inCntPoseidonG, Rom.operations, Rom.offset, Rom.incStack, Rom.binOpcode, Rom.jmpAddr, Rom.elseAddr, Rom.line }; diff --git a/pil/storage.pil b/pil/storage.pil index 48cf7dcd..6cbefd9a 100644 --- a/pil/storage.pil +++ b/pil/storage.pil @@ -217,6 +217,7 @@ namespace Storage(%N); opIsZero*op0 = 0; pol doJump = iJmp + iJmpz*opIsZero; pc' = doJump*(iAddress - pc - 1) + pc + 1; + pc * Global.L1 = 0; // Last pc' must return to be pc=0 in order to close the program loop // Once the work is done, the rest of instructions must be: From 1902598c2716604f1a250f5e8c23e079291fd654 Mon Sep 17 00:00:00 2001 From: zkronos73 Date: Mon, 16 Jan 2023 08:11:08 +0000 Subject: [PATCH 2/2] fix typo --- pil/main.pil | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pil/main.pil b/pil/main.pil index d2575611..47a452f9 100644 --- a/pil/main.pil +++ b/pil/main.pil @@ -335,7 +335,7 @@ namespace Main(%N); // if elseAddr wasn't specified on zkasm, compiler put current address + 1 zkPC' = doJMP * (finalJmpAddr - nextNoJmpZkPC) + elseJMP * (finalElseAddr - nextNoJmpZkPC) + nextNoJmpZkPC; - zKPC * Global.L1 = 0; + zkPC * Global.L1 = 0; (A0-op0)*assert = 0; (A1-op1)*assert = 0;