Skip to content

Commit

Permalink
Merge pull request #235 from 0xPolygonHermez/feature/add-tests-blob
Browse files Browse the repository at this point in the history
first tests blob
  • Loading branch information
krlosMata committed Mar 28, 2024
2 parents 8299b99 + a9a6fbe commit 1cc1345
Show file tree
Hide file tree
Showing 11 changed files with 429 additions and 13 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ on:
branches:
- main
- develop
- feature/fork-etrog
- develop-feijoa
pull_request:
branches:
- main
- develop
- feature/fork-etrog

- develop-feijoa
jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -44,8 +43,8 @@ jobs:
run: npm run test:st:calldata
- name: check smt
run: npm run test:smt
- name: check contracts
run: npm run test:contracts
# - name: check contracts
# run: npm run test:contracts
- name: check mt bridge
run: npm run test:mt:bridge
# - name: check test e2e
Expand Down
50 changes: 50 additions & 0 deletions inputs-executor-blob/blob-inner-data-0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"oldBlobStateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"oldBlobAccInputHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"oldNumBlob": 0,
"oldStateRoot": "0x799c98013da3f7a43b6e8086d0cedd89bd6a9bfef7179ce30755b27f7e9be302",
"forkID": 10,
"y": "0x0000000000000000000000000000000000000000000000000000000000000000",
"z": "0x0000000000000000000000000000000000000000000000000000000000000000",
"blobType": 0,
"sequencerAddr": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D",
"zkGasLimit": "1000000000000000000",
"forcedHashData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"blobL2HashData": "0x4eb19ebc0bf8c1370f2e028d488a61f1b09e0790c2a93a2229269bbb61b61146",
"newBlobStateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"newBlobAccInputHash": "0x9ad44c8e3b7970cf4a983fae82271fee03faf087a73596ede6538dc278ca68fb",
"newNumBlob": 1,
"finalAccBatchHashData": "0xa78cd7278eb8b48a40e791486985ad6290af374ca45ad962ed08cc83b2e184ba",
"localExitRootFromBlob": "0x0000000000000000000000000000000000000000000000000000000000000000",
"isInvalid": false,
"timestampLimit": "1944498031",
"lastL1InfoTreeIndex": 42,
"lastL1InfoTreeRoot": "0x4242424242424242424242424242424242424242424242424242424242424242",
"blobData": "0x000000007e0000007a0b73e6af6f00000000ee80843b9aca00830186a0944d5cf5032b2a844602278b01199ed191a86c93ff88016345785d8a0000808203e880801cee7e01dc62f69a12c3510c6d64de04ee6346d84b6a017f3e786c7d87f963e75d8cc91fa983cd6d9cf55fff80d73bd26cd333b0f098acc1e58edb1fd484ad731bff",
"db": {
"0x799c98013da3f7a43b6e8086d0cedd89bd6a9bfef7179ce30755b27f7e9be302": [
"d4b99d5e267cec20",
"2411ee82c58136a0",
"6f22c92ea5923ea9",
"3dbcd178cbe3b0c6",
"d074b8cee5dcf415",
"2346a1b4c0f390e8",
"47969c1f5a6a25b1",
"da62fdf84a21108e",
"0000000000000001",
"0000000000000000",
"0000000000000000",
"0000000000000000"
],
"0xda62fdf84a21108e47969c1f5a6a25b12346a1b4c0f390e8d074b8cee5dcf415": [
"0000000000000001",
"0000000000000000",
"0000000000000000",
"0000000000000000",
"0000000000000000",
"0000000000000000",
"0000000000000000",
"0000000000000000"
]
}
}
50 changes: 50 additions & 0 deletions inputs-executor-blob/blob-inner-data-1.json

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions inputs-executor-blob/blob-invalid-0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"oldBlobStateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"oldBlobAccInputHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"oldNumBlob": 0,
"oldStateRoot": "0x799c98013da3f7a43b6e8086d0cedd89bd6a9bfef7179ce30755b27f7e9be302",
"forkID": 10,
"y": "0x0000000000000000000000000000000000000000000000000000000000000000",
"z": "0x0000000000000000000000000000000000000000000000000000000000000000",
"blobType": 0,
"sequencerAddr": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D",
"zkGasLimit": "99",
"forcedHashData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"blobL2HashData": "0x4eb19ebc0bf8c1370f2e028d488a61f1b09e0790c2a93a2229269bbb61b61146",
"newBlobStateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"newBlobAccInputHash": "0x16a732fdf8b663112fa30baa38f484ca298e87d563601eace4a3d9e1620960ee",
"newNumBlob": 1,
"finalAccBatchHashData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"localExitRootFromBlob": "0x0000000000000000000000000000000000000000000000000000000000000001",
"isInvalid": true,
"timestampLimit": "1944498031",
"lastL1InfoTreeIndex": 42,
"lastL1InfoTreeRoot": "0x4242424242424242424242424242424242424242424242424242424242424242",
"blobData": "0x000000007e0000007a0b73e6af6f00000000ee80843b9aca00830186a0944d5cf5032b2a844602278b01199ed191a86c93ff88016345785d8a0000808203e880801cee7e01dc62f69a12c3510c6d64de04ee6346d84b6a017f3e786c7d87f963e75d8cc91fa983cd6d9cf55fff80d73bd26cd333b0f098acc1e58edb1fd484ad731bff",
"db": {
"0x799c98013da3f7a43b6e8086d0cedd89bd6a9bfef7179ce30755b27f7e9be302": [
"d4b99d5e267cec20",
"2411ee82c58136a0",
"6f22c92ea5923ea9",
"3dbcd178cbe3b0c6",
"d074b8cee5dcf415",
"2346a1b4c0f390e8",
"47969c1f5a6a25b1",
"da62fdf84a21108e",
"0000000000000001",
"0000000000000000",
"0000000000000000",
"0000000000000000"
],
"0xda62fdf84a21108e47969c1f5a6a25b12346a1b4c0f390e8d074b8cee5dcf415": [
"0000000000000001",
"0000000000000000",
"0000000000000000",
"0000000000000000",
"0000000000000000",
"0000000000000000",
"0000000000000000",
"0000000000000000"
]
}
}
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"test:st:calldata": "npx mocha ./test/state-transition/calldata/st-all.test.js",
"test:mt:bridge": "npx mocha ./test/mt-bridge/**.test.js",
"test:e2e": "npx mocha ./test/state-transition/e2e/e2e.test.js",
"test:blob": "npx mocha ./tools-inputs/generators/blob-calldata-gen-input.js",
"update:mt:bridge": "npx mocha ./test/mt-bridge/**.test.js --update",
"update:st:calldata": "cd ./tools-inputs/tools-calldata && ./gen-all.sh",
"update:st:no-data": "npx mocha ./test/state-transition/no-data/st-all.test.js --update && npx mocha ./test/state-transition/separate-batches/separate-batches.test.js --update && npx mocha ./test/state-transition/batch-header-timestamp/header-timestamp.test.js --update",
Expand All @@ -22,6 +23,7 @@
"update:eth-tests": "cd ./tools-inputs/tools-eth && ./update-tests-general.sh",
"update:forcedtx": "cd ./tools-inputs/generate-test-forced && ./gen-forced.sh",
"update:stateoverride": "cd ./tools-inputs/generators && node stateoverride-gen-inputs.js",
"update:blob": "npx mocha ./tools-inputs/generators/blob-calldata-gen-input.js --update --geninput",
"test:contracts": "npx mocha ./test/state-transition/no-data/contracts.test.js --exit",
"update:all": "npm run update:smt && npm run update:mt:bridge && npm run update:st:calldata && npm run update:st:no-data && npm run update:e2e && npm run update:error-rlp && npm run update:eth-tests",
"regen-tests": "sh regen-tests.sh",
Expand All @@ -35,11 +37,12 @@
"keywords": [],
"author": "0xPolygonHermez",
"files": [
"inputs-executor"
"inputs-executor",
"inputs-executor-blob"
],
"license": "pending",
"devDependencies": {
"@0xpolygonhermez/zkevm-commonjs": "github:0xPolygonHermez/zkevm-commonjs#feature/feijoa-batch",
"@0xpolygonhermez/zkevm-commonjs": "github:0xPolygonHermez/zkevm-commonjs#develop-feijoa",
"@0xpolygonhermez/zkevm-contracts": "github:0xPolygonHermez/zkevm-contracts#feature/fork-etrog",
"@grpc/grpc-js": "^1.6.10",
"@nomiclabs/hardhat-ethers": "^2.0.5",
Expand Down
1 change: 0 additions & 1 deletion test/state-transition/calldata/st-all.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const Common = require('@ethereumjs/common').default;
const { Hardfork } = require('@ethereumjs/common');
const { BN, toBuffer } = require('ethereumjs-util');
const { ethers } = require('ethers');
const { Scalar } = require('ffjavascript');

const zkcommonjs = require('@0xpolygonhermez/zkevm-commonjs');
const { expect } = require('chai');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ async function revertToSnapshot(snapshotId) {
return revert;
}

async function setNextBlockTimestamp(timestamp) {
return (ethers.provider.send('evm_setNextBlockTimestamp', [timestamp]));
}
// async function setNextBlockTimestamp(timestamp) {
// return (ethers.provider.send('evm_setNextBlockTimestamp', [timestamp]));
// }

const configTestvectors = require('../../../tools-inputs/testvectors.config.json');

Expand Down
74 changes: 74 additions & 0 deletions tools-inputs/data/blob/blob-inner-data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
[
{
"id": 0,
"description": "blob type 0, one valid batch",
"preExecution": {
"initLocalExitRoot": "0x0000000000000000000000000000000000000000000000000000000000000001"
},
"inputBlob": {
"publics": {
"oldBlobStateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"oldBlobAccInputHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"oldNumBlob": 0,
"oldStateRoot": "0x799c98013da3f7a43b6e8086d0cedd89bd6a9bfef7179ce30755b27f7e9be302"
},
"private": {
"lastL1InfoTreeIndex": 42,
"lastL1InfoTreeRoot": "0x4242424242424242424242424242424242424242424242424242424242424242",
"timestampLimit": "1944498031",
"sequencerAddress": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D",
"blobType": 0,
"zkGasLimit": "1000000000000000000",
"forcedHashData": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
},
"batchesData": [
"0x0b73e6af6f00000000ee80843b9aca00830186a0944d5cf5032b2a844602278b01199ed191a86c93ff88016345785d8a0000808203e880801cee7e01dc62f69a12c3510c6d64de04ee6346d84b6a017f3e786c7d87f963e75d8cc91fa983cd6d9cf55fff80d73bd26cd333b0f098acc1e58edb1fd484ad731bff"
],
"expected": {
"newBlobStateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"newBlobAccInputHash": "0x9ad44c8e3b7970cf4a983fae82271fee03faf087a73596ede6538dc278ca68fb",
"newNumBlob": 1,
"finalAccBatchHashData": "0xa78cd7278eb8b48a40e791486985ad6290af374ca45ad962ed08cc83b2e184ba",
"localExitRootFromBlob": "0x0000000000000000000000000000000000000000000000000000000000000000",
"isInvalid": false
},
"forkID": 10
},
{
"id": 1,
"description": "blob type 1, one valid batch",
"preExecution": {
"initLocalExitRoot": "0x0000000000000000000000000000000000000000000000000000000000000001"
},
"inputBlob": {
"publics": {
"oldBlobStateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"oldBlobAccInputHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"oldNumBlob": 0,
"oldStateRoot": "0x799c98013da3f7a43b6e8086d0cedd89bd6a9bfef7179ce30755b27f7e9be302"
},
"private": {
"lastL1InfoTreeIndex": 42,
"lastL1InfoTreeRoot": "0x4242424242424242424242424242424242424242424242424242424242424242",
"timestampLimit": "1944498031",
"sequencerAddress": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D",
"blobType": 1,
"zkGasLimit": "1000000000000000000",
"forcedHashData": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
},
"batchesData": [
"0x0b73e6af6f00000000ee80843b9aca00830186a0944d5cf5032b2a844602278b01199ed191a86c93ff88016345785d8a0000808203e880801cee7e01dc62f69a12c3510c6d64de04ee6346d84b6a017f3e786c7d87f963e75d8cc91fa983cd6d9cf55fff80d73bd26cd333b0f098acc1e58edb1fd484ad731bff"
],
"expected": {
"newBlobStateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"newBlobAccInputHash": "0x6504d7f29a8efc70fcb2e6921b40e2c4f395ea94856649d1ab692c6e9a1e4acc",
"newNumBlob": 1,
"finalAccBatchHashData": "0xa78cd7278eb8b48a40e791486985ad6290af374ca45ad962ed08cc83b2e184ba",
"localExitRootFromBlob": "0x0000000000000000000000000000000000000000000000000000000000000000",
"isInvalid": false
},
"forkID": 10
}
]
38 changes: 38 additions & 0 deletions tools-inputs/data/blob/blob-invalid.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[
{
"id": 0,
"description": "blob type 0, one valid batch, invalid blob due to zkGasLimit",
"preExecution": {
"initLocalExitRoot": "0x0000000000000000000000000000000000000000000000000000000000000001"
},
"inputBlob": {
"publics": {
"oldBlobStateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"oldBlobAccInputHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"oldNumBlob": 0,
"oldStateRoot": "0x799c98013da3f7a43b6e8086d0cedd89bd6a9bfef7179ce30755b27f7e9be302"
},
"private": {
"lastL1InfoTreeIndex": 42,
"lastL1InfoTreeRoot": "0x4242424242424242424242424242424242424242424242424242424242424242",
"timestampLimit": "1944498031",
"sequencerAddress": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D",
"blobType": 0,
"zkGasLimit": "99",
"forcedHashData": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
},
"batchesData": [
"0x0b73e6af6f00000000ee80843b9aca00830186a0944d5cf5032b2a844602278b01199ed191a86c93ff88016345785d8a0000808203e880801cee7e01dc62f69a12c3510c6d64de04ee6346d84b6a017f3e786c7d87f963e75d8cc91fa983cd6d9cf55fff80d73bd26cd333b0f098acc1e58edb1fd484ad731bff"
],
"expected": {
"newBlobStateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"newBlobAccInputHash": "0x16a732fdf8b663112fa30baa38f484ca298e87d563601eace4a3d9e1620960ee",
"newNumBlob": 1,
"finalAccBatchHashData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"localExitRootFromBlob": "0x0000000000000000000000000000000000000000000000000000000000000001",
"isInvalid": true
},
"forkID": 10
}
]
Loading

0 comments on commit 1cc1345

Please sign in to comment.