Skip to content

Commit

Permalink
Merge pull request #176 from 0xPolygonHermez/feature/comment-comp
Browse files Browse the repository at this point in the history
Comments comparison opcodes
  • Loading branch information
krlosMata authored Nov 28, 2022
2 parents 71e3d51 + a3563fb commit 2248432
Show file tree
Hide file tree
Showing 8 changed files with 528 additions and 250 deletions.
4 changes: 3 additions & 1 deletion main/constants.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@ CONST %MAX_CNT_KECCAK_F = (%MAX_CNT_STEPS / 158418) * 9
CONST %MAX_CNT_PADDING_PG = (%MAX_CNT_STEPS / 56)
CONST %MAX_CNT_POSEIDON_G = (%MAX_CNT_STEPS / 30)
CONST %MIN_CNT_KECCAK_BATCH = 1 ; minimum necessary keccaks to compute global hash

; ETHEREUM CONSTANTS
CONSTL %MAX_NONCE = 0xffffffffffffffffn
CONSTL %MAX_NONCE = 0xffffffffffffffffn
CONSTL %MAX_UINT_256 = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn
2 changes: 1 addition & 1 deletion main/map-opcodes.zkasm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
INCLUDE "opcodes/arithmetic.zkasm"
INCLUDE "opcodes/block.zkasm"
INCLUDE "opcodes/comparision.zkasm"
INCLUDE "opcodes/comparison.zkasm"
INCLUDE "opcodes/context-information.zkasm"
INCLUDE "opcodes/create-terminate-context.zkasm"
INCLUDE "opcodes/crypto.zkasm"
Expand Down
9 changes: 4 additions & 5 deletions main/opcodes/arithmetic.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ opADD:
$ => A :MLOAD(SP--) ; [a => A]
$ => B :MLOAD(SP) ; [b => B]

; call arith state machine and push to the stack
$ :ADD, MSTORE(SP++) ; [a + b => SP]
; call binary:add state machine and push to the stack
$ :ADD, MSTORE(SP++)

; continue read bytecode
:JMP(readCode)
Expand Down Expand Up @@ -252,7 +252,7 @@ opMULMOD:
C :MSTORE(SP++)
:JMP(readCode)

opEXP: ; //TODO: test exp == 0
opEXP:

%MAX_CNT_BINARY - CNT_BINARY - 5 :JMPN(outOfCountersBinary)
%MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep)
Expand Down Expand Up @@ -280,7 +280,6 @@ opSIGNEXTEND: ; following this impl https://github.com/ethereumjs/ethereumjs-mon
$ => D :MLOAD(SP) ; number to convert
30 => A
$ :LT, JMPC(opSIGNEXTENDEnd); if signByte is 31 or more, means basically let the number as it is
; TODO we could divide this opcode in a table with constants, only 31 cases
B * 8 + 7 => D ; B is less than 31, no need for binary
D*2 => RR
zkPC+2 :MSTORE(tmpSHXZkPC)
Expand All @@ -297,7 +296,7 @@ opSIGNEXTEND: ; following this impl https://github.com/ethereumjs/ethereumjs-mon
0 => A
$ :EQ, JMPC(opSIGNEXTENDPositive) ; If 0 means the sign bit was 0 --> positive
C => A ; mask
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn => B
%MAX_UINT_256 => B
$ => B :XOR ; not mask
D => A
$ => D :OR
Expand Down
234 changes: 0 additions & 234 deletions main/opcodes/comparision.zkasm

This file was deleted.

Loading

0 comments on commit 2248432

Please sign in to comment.