Skip to content

Commit

Permalink
Merge pull request #382 from 0xPolygonHermez/feature/fix-final-A
Browse files Browse the repository at this point in the history
Feature/fix final a
  • Loading branch information
krlosMata committed Apr 18, 2024
2 parents 257d4be + 147d830 commit 1541b87
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
2 changes: 2 additions & 0 deletions main/main.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ clearPendingRestores_end:
SR => A ; newStateRoot at A
%FOUR_GOLDILOCKS => B
1 :LT4
; Recover A to 0
0 => A

; Set output registers
$ => RR :MLOAD(timestamp) ; Timestamp at RR
Expand Down
4 changes: 2 additions & 2 deletions main/process-tx.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,8 @@ callContract:
56 :MSTORE(arithB), CALL(divARITH); in: [arithA, arithB] out: [arithRes1: arithA/arithB, arithRes2: arithA%arithB]
$ => B :MLOAD(arithRes1)
%MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 1 - B :JMPN(outOfCountersPoseidon)
%MAX_CNT_PADDING_PG - CNT_PADDING_PG - 1 - B :JMPN(outOfCountersPadding)

%MAX_CNT_PADDING_PG - CNT_PADDING_PG - 1 - B :JMPN(outOfCountersPadding)
%MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary)
; get hash contract
$ => A :MLOAD(txDestAddr)
%SMT_KEY_SC_CODE => B
Expand Down
6 changes: 3 additions & 3 deletions main/utils.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ __MSTOREX_afterSave:

; E === 32 * RR + A (RCX)
; E - 32 * RR === A
; secure: E < MAX_MEM_EXPASION_BYTES < 32 bits, RR < 32 bits, 32*RR < 37 bits, all < 38 bits
; secure: E < MAX_MEM_EXPANSION_BYTES < 32 bits, RR < 32 bits, 32*RR < 37 bits, all < 38 bits
E - 32 * RR :ASSERT

RCX + %MEM_ALIGN_LEN * C + %MEM_ALIGN_LEFT_ALIGNMENT => C :JMP_EQ(%MEM_ALIGN_LEN * 32 + %MEM_ALIGN_LEFT_ALIGNMENT, __MSTORE32_offset0_len32)
Expand Down Expand Up @@ -225,7 +225,7 @@ __MLOAD32_restore:
__MSTOREX_len + E => E :RETURN

__MLOADX_len0:
0 => A :RETURN
0 => A :RESTORE, RETURN

__errorEmore32bits:
; path E >= 2**32 must be verified (dual path protection)
Expand Down Expand Up @@ -973,7 +973,6 @@ VAR GLOBAL linearPoseidonOutD
; @out D => resulting linear poseidon
hashPoseidonLinearFromMemory:
%MAX_CNT_STEPS - STEP - 50 :JMPN(outOfCountersStep)
%MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary)
A :SAVE(B,C,D,E,RCX,RR)
$ => E :MLOAD(memOffsetLinearPoseidon)
$ => C :MLOAD(memSizeLinearPoseidon)
Expand Down Expand Up @@ -1015,6 +1014,7 @@ hashPoseidonFinal:
A :HASHP(E)

hashPoseidonEnd:
%MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary)
$ => E :MLOAD(tmpContractHashId)
HASHPOS :HASHPLEN(E)
$ => D :HASHPDIGEST(E)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
},
"devDependencies": {
"@0xpolygonhermez/zkevm-commonjs": "github:0xPolygonHermez/zkevm-commonjs#v7.0.0-rc.1-fork.10",
"@0xpolygonhermez/zkevm-proverjs": "github:0xPolygonHermez/zkevm-proverjs#feature/renaming",
"@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#v7.0.0-rc.1-fork.10",
"@0xpolygonhermez/zkevm-proverjs": "github:0xPolygonHermez/zkevm-proverjs#feature/fix-batchHashData",
"@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#feature/fix-test",
"chai": "^4.3.6",
"chalk": "^3.0.0",
"eslint": "^8.25.0",
Expand Down
5 changes: 3 additions & 2 deletions tools/parallel-testing/gen-parallel-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ async function genTestsFiles() {
fs.mkdirSync(testsFolder);
}
for (const inputPath of inputs) {
const name = inputPath.split('/').slice(-1)[0].replace('json', 'test.js');
const fileName = path.basename(inputPath, '.json');
const folderName = path.basename(path.dirname(inputPath));
const sample = fs.readFileSync(sampleDir, 'utf-8');
let test = sample.replace('%%INPUT_PATH%%', `${inputPath}`);
// Replace skip vcounters flag
if (argv.skipVCounters) {
test = test.replace('%%SKIP_VCOUNTERS%%', 'yes');
}
fs.writeFileSync(`${testsFolder}/${name}`, test);
fs.writeFileSync(`${testsFolder}/${folderName}__${fileName}.test.js`, test);
}
expect(true).to.be.equal(true);
}
Expand Down

0 comments on commit 1541b87

Please sign in to comment.