Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/audit touched #413

Open
wants to merge 1 commit into
base: develop-durian
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions counters/countersConstants.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ CONST %OPCODECOPY_CNT_PADDING_PG = 0
CONST %OPCODECOPY_CNT_POSEIDON_G = 0
; opEXTCODECOPY - COMPLEX - hardcoded values at test
CONST %OPEXTCODECOPY_STEP = 2000
CONST %OPEXTCODECOPY_CNT_BINARY = 105
CONST %OPEXTCODECOPY_CNT_BINARY = 103
CONST %OPEXTCODECOPY_CNT_ARITH = 4
CONST %OPEXTCODECOPY_CNT_KECCAK_F = 0
CONST %OPEXTCODECOPY_CNT_MEM_ALIGN = 43
Expand All @@ -257,15 +257,15 @@ CONST %OPCREATE2_CNT_PADDING_PG = 0
CONST %OPCREATE2_CNT_POSEIDON_G = 27
; opCALL - COMPLEX - hardcoded values at test
CONST %OPCALL_STEP = 600
CONST %OPCALL_CNT_BINARY = 28
CONST %OPCALL_CNT_BINARY = 26
CONST %OPCALL_CNT_ARITH = 3
CONST %OPCALL_CNT_KECCAK_F = 0
CONST %OPCALL_CNT_MEM_ALIGN = 0
CONST %OPCALL_CNT_PADDING_PG = 0
CONST %OPCALL_CNT_POSEIDON_G = 14
; opCALLCODE - COMPLEX - hardcoded values at test
CONST %OPCALLCODE_STEP = 600
CONST %OPCALLCODE_CNT_BINARY = 27
CONST %OPCALLCODE_CNT_BINARY = 25
CONST %OPCALLCODE_CNT_ARITH = 3
CONST %OPCALLCODE_CNT_KECCAK_F = 0
CONST %OPCALLCODE_CNT_MEM_ALIGN = 0
Expand All @@ -289,15 +289,15 @@ CONST %OPREVERT_CNT_PADDING_PG = 0
CONST %OPREVERT_CNT_POSEIDON_G = 0
; opDELEGATECALL - COMPLEX - hardcoded values at test
CONST %OPDELEGATECALL_STEP = 600
CONST %OPDELEGATECALL_CNT_BINARY = 24
CONST %OPDELEGATECALL_CNT_BINARY = 22
CONST %OPDELEGATECALL_CNT_ARITH = 3
CONST %OPDELEGATECALL_CNT_KECCAK_F = 0
CONST %OPDELEGATECALL_CNT_MEM_ALIGN = 0
CONST %OPDELEGATECALL_CNT_PADDING_PG = 0
CONST %OPDELEGATECALL_CNT_POSEIDON_G = 6
; opSTATICCALL - COMPLEX - hardcoded values at test
CONST %OPSTATICCALL_STEP = 600
CONST %OPSTATICCALL_CNT_BINARY = 24
CONST %OPSTATICCALL_CNT_BINARY = 22
CONST %OPSTATICCALL_CNT_ARITH = 3
CONST %OPSTATICCALL_CNT_KECCAK_F = 0
CONST %OPSTATICCALL_CNT_MEM_ALIGN = 0
Expand Down
5 changes: 2 additions & 3 deletions main/precompiled/selector.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,5 @@ selectorPrecompiled:
A - 8 :JMPN(funcEcMul)
A - 9 :JMPN(funcEcPairing)
A - 10 :JMPN(revertPrecompiled) ;:JMPN(BLAKE2F)

selectorPrecompiledP256Verify:
:JMP(funcP256VERIFY)
A - 256 :JMPZ(funcP256VERIFY)
:JMP(callContract)
4 changes: 1 addition & 3 deletions main/process-tx.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,7 @@ txType:
; Check zero address since zero address is not a precompiled contract
0 => B
$ :EQ, JMPC(callContract)
0x100 => B
$ :EQ, JMPC(selectorPrecompiledP256Verify)
10 => B
0x101 => B
$ :LT, JMPC(selectorPrecompiled, callContract)

;;;;;;;;;;;;;;;;;;
Expand Down
15 changes: 7 additions & 8 deletions main/touched.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,20 @@ revertTouched:
isColdAddress:
; checks zk-counters
%MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep)
%MAX_CNT_BINARY - CNT_BINARY - 4 :JMPN(outOfCountersBinary)
%MAX_CNT_BINARY - CNT_BINARY - 2 :JMPN(outOfCountersBinary)
%MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - %MAX_CNT_POSEIDON_SLOAD_SSTORE*2 :JMPN(outOfCountersPoseidon)
; store previous registers values temporary
B :MSTORE(tmpB)
C :MSTORE(tmpC)
E :MSTORE(tmpE)

; if address is a zero address check if it is warm
0 => B
$ :EQ, JMPC(checkWarmed)
; if address is a precompiled considered as warm address
10 => B
$ :LT, JMPC(finishColdPrecompiled)
0x100 => B
$ :EQ, JMPC(finishColdPrecompiled)
0x101 => B
$ :LT, JMPNC(checkWarmed)
; if address is a zero address check if it is warm (A <= 256)
A :JMPZ(checkWarmed)
A - 0x100 :JMPZ(finishColdPrecompiled)
A - 10 :JMPN(finishColdPrecompiled)

checkWarmed:
; save current state root & load touched root
Expand Down
Loading