From 2efd8fe85f04b1e98017701bfec5967758802d8b Mon Sep 17 00:00:00 2001 From: krlosMata Date: Thu, 8 Feb 2024 17:02:23 +0100 Subject: [PATCH 1/4] blockGasLimit to 2^50 --- package.json | 2 +- src/constants.js | 2 +- test/contract-utils.test.js | 2 +- .../block-info/block-info-batches.json | 52 +++++------ .../test-vectors/block-info/block-info.json | 8 +- .../end-to-end/state-transition-e2e.json | 6 +- .../inputs-executor/input_executor.json | 2 +- .../processor/state-transition-etrog.json | 16 ++-- .../processor/state-transition.json | 86 +++++++++---------- .../selfdestruct/selfdestruct.json | 6 +- .../test-vectors/zkevm-db/recursive.json | 16 ++-- .../zkevm-db/state-transition.json | 4 +- test/zkevm-db.test.js | 2 +- 13 files changed, 102 insertions(+), 102 deletions(-) diff --git a/package.json b/package.json index 7f354c42..54d30b63 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@0xpolygonhermez/zkevm-commonjs", "description": "Javascript library implementing common utilities for zkevm", - "version": "3.0.0", + "version": "5.0.0", "main": "index.js", "scripts": { "setup": "npm i", diff --git a/src/constants.js b/src/constants.js index 9e5e4862..f2a7372c 100644 --- a/src/constants.js +++ b/src/constants.js @@ -58,7 +58,7 @@ module.exports.ADDRESS_BRIDGE = '0x9D98DeAbC42dd696Deb9e40b4f1CAB7dDBF55988'; module.exports.ADDRESS_GLOBAL_EXIT_ROOT_MANAGER_L2 = '0xa40D5f56745a118D0906a34E69aeC8C0Db1cB8fA'; module.exports.GLOBAL_EXIT_ROOT_STORAGE_POS = 0; module.exports.LOCAL_EXIT_ROOT_STORAGE_POS = 1; -module.exports.BLOCK_GAS_LIMIT = Scalar.e('18446744073709551615'); // 2**64 - 1 +module.exports.BLOCK_GAS_LIMIT = 1125899906842624; module.exports.TX_GAS_LIMIT = 30000000; module.exports.BATCH_DIFFICULTY = 0; module.exports.ADDRESS_SYSTEM = '0x000000000000000000000000000000005ca1ab1e'; diff --git a/test/contract-utils.test.js b/test/contract-utils.test.js index 340a4562..40b09c44 100644 --- a/test/contract-utils.test.js +++ b/test/contract-utils.test.js @@ -13,7 +13,7 @@ describe('contractUtils', function () { const expectedBatchHashData = '0x5e7875ab198c4d93379c92990a5d0111af59a0e62b2c4a0e3898e5bd24a18e58'; // TODO: input taken from pil-stark const expectedStarkHashExecutor = '0xcfae2cfa3b8f3f12abce1bccd90e9b203dfdbe56c0c412114f2d3e67c9a897db'; - const expectedSnarkInputHash = '18866106746266856524258279357742200690030828045012096945213758495992135252470'; + const expectedSnarkInputHash = '14261007919052674347941079765745619634521069459113175679360275962408703057507'; before(async () => { testVector = JSON.parse(fs.readFileSync(path.join(pathTestVectors, 'inputs-executor/input_executor.json'))); diff --git a/test/helpers/test-vectors/block-info/block-info-batches.json b/test/helpers/test-vectors/block-info/block-info-batches.json index 98ae603a..ac610476 100644 --- a/test/helpers/test-vectors/block-info/block-info-batches.json +++ b/test/helpers/test-vectors/block-info/block-info-batches.json @@ -3,7 +3,7 @@ "id": 0, "description": "Get timestamp", "chainID": 1000, - "forkID": 7, + "forkID": 8, "sequencerAddress": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D", "sequencerPvtKey": "0x28b2b0318721be8c8339199172cd7cc8f5e273800a35616ec893083a4b32c02e", "genesis": [ @@ -171,7 +171,7 @@ "rawTx": "0xf88a06843b9aca00830186a0941275fbb540c8efc58b812ba83b0d0b8b9917ae9880a4e9413d3800000000000000000000000000000000000000000000000000000000000000008207f4a098f56115cad149a409a86e7610863248799a31d80e87d46582d08a3c0933a40aa025455a74fa3ca2ada0bf39dac88a172d032583bfec15061f39184ef9f7012677" } ], - "expectedNewRoot": "0x1d698dc6485125fbe80cd9b06a9e55989bb69e68e5204774728bbbbe77f080e3", + "expectedNewRoot": "0x96ce4b302af46b96e74392e9e8e22f2950340b55570d6a22a4c323b36d24948e", "expectedNewLeafs": { "0x0000000000000000000000000000000000000000": { "balance": "0", @@ -192,7 +192,7 @@ "0x0000000000000000000000000000000000000000000000000000000000000000": "0x617b3a3528f9cdd6630fd3301b9c8911f7bf063d", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x01", "0x0000000000000000000000000000000000000000000000000000000000000003": "0x01", - "0x0000000000000000000000000000000000000000000000000000000000000005": "0xffffffffffffffff", + "0x0000000000000000000000000000000000000000000000000000000000000005": "0x04000000000000", "0x0000000000000000000000000000000000000000000000000000000000000006": "0x03e8", "0x0000000000000000000000000000000000000000000000000000000000000001": "0xf5c30bbb2b8a1bdd2b881cc575b2acbd13578c7cd64250fe8b6770fa95f915b3" } @@ -208,7 +208,7 @@ "0x0000000000000000000000000000000000000000000000000000000000000000": "0x01", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x01", "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0xf5c30bbb2b8a1bdd2b881cc575b2acbd13578c7cd64250fe8b6770fa95f915b3", - "0x0000000000000000000000000000000000000000000000000000000000000003": "0xbd53cdc8bcd08193d699e5105f0a47dd62dced0c397ae5fb3f8fcf82a6541652" + "0x0000000000000000000000000000000000000000000000000000000000000003": "0x54720bc642f2b7cbcba5250253b9a28c8e11228168ecb0f34b6852e3da630b98" } } }, @@ -349,17 +349,17 @@ "rawTx": "0xf88a0d843b9aca00830186a0941275fbb540c8efc58b812ba83b0d0b8b9917ae9880a4e9413d3800000000000000000000000000000000000000000000000000000000000000018207f3a068ad61295298051fac15519066926aad57ed5af83b351e586a0fbe70006c4829a05695cc59543fd10d4af41a8a266aef5efd2d691abc356fc679c66e2545fd9ef6" } ], - "expectedNewRoot": "0xe3413eb2b723d51a5b33a27f7d52dee33730b960ea549c6d2fe4f5a6e91c3927", + "expectedNewRoot": "0xaabcd3d4d752f17f916fc8cffac078a1cdfef910e8e5b647c225615e70d1b12a", "expectedNewLeafs": { "0x000000000000000000000000000000005ca1ab1e": { "balance": "0", "nonce": "0", "storage": { "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0xf5c30bbb2b8a1bdd2b881cc575b2acbd13578c7cd64250fe8b6770fa95f915b3", - "0xcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f": "0x1d698dc6485125fbe80cd9b06a9e55989bb69e68e5204774728bbbbe77f080e3", + "0xcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f": "0x96ce4b302af46b96e74392e9e8e22f2950340b55570d6a22a4c323b36d24948e", "0x0000000000000000000000000000000000000000000000000000000000000000": "0x02", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af70", - "0x0000000000000000000000000000000000000000000000000000000000000003": "0x4b5ce675e3ea87e981f2ec7e81610a26db428c1a01175156d8532798fc381482" + "0x0000000000000000000000000000000000000000000000000000000000000003": "0xa4d578832c1f2fed93cb2516837ff6ad42c23172556e81fed99164c66839da31" } }, "0x4d5cf5032b2a844602278b01199ed191a86c93ff": { @@ -373,9 +373,9 @@ "0x0000000000000000000000000000000000000000000000000000000000000000": "0x617b3a3528f9cdd6630fd3301b9c8911f7bf063d", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af70", "0x0000000000000000000000000000000000000000000000000000000000000003": "0x02", - "0x0000000000000000000000000000000000000000000000000000000000000005": "0xffffffffffffffff", + "0x0000000000000000000000000000000000000000000000000000000000000005": "0x04000000000000", "0x0000000000000000000000000000000000000000000000000000000000000006": "0x03e8", - "0x0000000000000000000000000000000000000000000000000000000000000001": "0x1d698dc6485125fbe80cd9b06a9e55989bb69e68e5204774728bbbbe77f080e3" + "0x0000000000000000000000000000000000000000000000000000000000000001": "0x96ce4b302af46b96e74392e9e8e22f2950340b55570d6a22a4c323b36d24948e" } }, "0x617b3a3528f9cdd6630fd3301b9c8911f7bf063d": { @@ -412,18 +412,18 @@ "customRawTx": "0x0b0000000100000000" } ], - "expectedNewRoot": "0x29f416b5771027b22283e213cc87906be27621c0a4a2fd40c36bd531736ad44f", + "expectedNewRoot": "0x636d12d0f53b99446f873dbead70268af689129a018b7d13a51a26f62c84e347", "expectedNewLeafs": { "0x000000000000000000000000000000005ca1ab1e": { "balance": "0", "nonce": "0", "storage": { "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0xf5c30bbb2b8a1bdd2b881cc575b2acbd13578c7cd64250fe8b6770fa95f915b3", - "0xcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f": "0x1d698dc6485125fbe80cd9b06a9e55989bb69e68e5204774728bbbbe77f080e3", + "0xcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f": "0x96ce4b302af46b96e74392e9e8e22f2950340b55570d6a22a4c323b36d24948e", "0x0000000000000000000000000000000000000000000000000000000000000000": "0x03", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af71", - "0x0000000000000000000000000000000000000000000000000000000000000003": "0x1e05b73b3be8038c31b04ffa198db44768bd790b3837728b0eb604a75c7347c1", - "0xd9d16d34ffb15ba3a3d852f0d403e2ce1d691fb54de27ac87cd2f993f3ec330f": "0xe3413eb2b723d51a5b33a27f7d52dee33730b960ea549c6d2fe4f5a6e91c3927" + "0x0000000000000000000000000000000000000000000000000000000000000003": "0x9a7c75df0c10c23602288afdd3118b07f1e78b341bcd0c3ed997aa5fbe301b7d", + "0xd9d16d34ffb15ba3a3d852f0d403e2ce1d691fb54de27ac87cd2f993f3ec330f": "0xaabcd3d4d752f17f916fc8cffac078a1cdfef910e8e5b647c225615e70d1b12a" } }, "0x0000000000000000000000000000000000000000": { @@ -446,9 +446,9 @@ "0x0000000000000000000000000000000000000000000000000000000000000000": "0x617b3a3528f9cdd6630fd3301b9c8911f7bf063d", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af70", "0x0000000000000000000000000000000000000000000000000000000000000003": "0x02", - "0x0000000000000000000000000000000000000000000000000000000000000005": "0xffffffffffffffff", + "0x0000000000000000000000000000000000000000000000000000000000000005": "0x04000000000000", "0x0000000000000000000000000000000000000000000000000000000000000006": "0x03e8", - "0x0000000000000000000000000000000000000000000000000000000000000001": "0x1d698dc6485125fbe80cd9b06a9e55989bb69e68e5204774728bbbbe77f080e3" + "0x0000000000000000000000000000000000000000000000000000000000000001": "0x96ce4b302af46b96e74392e9e8e22f2950340b55570d6a22a4c323b36d24948e" } }, "0x4d5cf5032b2a844602278b01199ed191a86c93ff": { @@ -478,19 +478,19 @@ "customRawTx": "0x0b0000000100000000" } ], - "expectedNewRoot": "0x43e437eeefa47f2e48d2a207a50e976ee32706b4f06dbbab729c482b38c67cf7", + "expectedNewRoot": "0x15f660be04fea3803d9884d6253f2b4e9284064cddca12029e4af254383b706f", "expectedNewLeafs": { "0x000000000000000000000000000000005ca1ab1e": { "balance": "0", "nonce": "0", "storage": { "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0xf5c30bbb2b8a1bdd2b881cc575b2acbd13578c7cd64250fe8b6770fa95f915b3", - "0xcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f": "0x1d698dc6485125fbe80cd9b06a9e55989bb69e68e5204774728bbbbe77f080e3", + "0xcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f": "0x96ce4b302af46b96e74392e9e8e22f2950340b55570d6a22a4c323b36d24948e", "0x0000000000000000000000000000000000000000000000000000000000000000": "0x04", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af72", - "0x0000000000000000000000000000000000000000000000000000000000000003": "0x223d8c60df010229721330d53d96883984c966e7095df7352d8b8a3ea3d286a4", - "0xd9d16d34ffb15ba3a3d852f0d403e2ce1d691fb54de27ac87cd2f993f3ec330f": "0xe3413eb2b723d51a5b33a27f7d52dee33730b960ea549c6d2fe4f5a6e91c3927", - "0x7dfe757ecd65cbd7922a9c0161e935dd7fdbcc0e999689c7d31633896b1fc60b": "0x29f416b5771027b22283e213cc87906be27621c0a4a2fd40c36bd531736ad44f" + "0x0000000000000000000000000000000000000000000000000000000000000003": "0x53d2065c33d482349f2807380246d7baa7166886cc4fcb96aa11578e353a85e9", + "0xd9d16d34ffb15ba3a3d852f0d403e2ce1d691fb54de27ac87cd2f993f3ec330f": "0xaabcd3d4d752f17f916fc8cffac078a1cdfef910e8e5b647c225615e70d1b12a", + "0x7dfe757ecd65cbd7922a9c0161e935dd7fdbcc0e999689c7d31633896b1fc60b": "0x636d12d0f53b99446f873dbead70268af689129a018b7d13a51a26f62c84e347" } }, "0x0000000000000000000000000000000000000000": { @@ -513,9 +513,9 @@ "0x0000000000000000000000000000000000000000000000000000000000000000": "0x617b3a3528f9cdd6630fd3301b9c8911f7bf063d", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af70", "0x0000000000000000000000000000000000000000000000000000000000000003": "0x02", - "0x0000000000000000000000000000000000000000000000000000000000000005": "0xffffffffffffffff", + "0x0000000000000000000000000000000000000000000000000000000000000005": "0x04000000000000", "0x0000000000000000000000000000000000000000000000000000000000000006": "0x03e8", - "0x0000000000000000000000000000000000000000000000000000000000000001": "0x1d698dc6485125fbe80cd9b06a9e55989bb69e68e5204774728bbbbe77f080e3" + "0x0000000000000000000000000000000000000000000000000000000000000001": "0x96ce4b302af46b96e74392e9e8e22f2950340b55570d6a22a4c323b36d24948e" } }, "0x4d5cf5032b2a844602278b01199ed191a86c93ff": { @@ -536,7 +536,7 @@ "id": 1, "description": "Verify skip flags", "chainID": 1000, - "forkID": 7, + "forkID": 8, "sequencerAddress": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D", "sequencerPvtKey": "0x28b2b0318721be8c8339199172cd7cc8f5e273800a35616ec893083a4b32c02e", "genesis": [ @@ -828,7 +828,7 @@ "id": 2, "description": "Previous batch partition in just one batch", "chainID": 1000, - "forkID": 7, + "forkID": 8, "sequencerAddress": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D", "sequencerPvtKey": "0x28b2b0318721be8c8339199172cd7cc8f5e273800a35616ec893083a4b32c02e", "genesis": [ @@ -930,7 +930,7 @@ "rawTx": "0xf86a02843b9aca00830186a0941275fbb540c8efc58b812ba83b0d0b8b9917ae9880846d6516c08207f4a0db91fc325e867faa9625a5c7c152dfaf207a992b6eea855fcabe264f489b043aa0431f20ba77bd0269a6aedb6287118d383305d0dd677478209e60f6d3af3b1720" } ], - "expectedNewRoot": "0x0338190efe6ddd933641ac5f63a19d22386600d13fe4ca463ab0de2224ac6a39", + "expectedNewRoot": "0x22a747086c81f3ad54571fd45e3fe233e0c56109e81404699452194bd38d6cab", "expectedNewLeafs": { "0x0000000000000000000000000000000000000000": { "balance": "0", @@ -964,7 +964,7 @@ "0x0000000000000000000000000000000000000000000000000000000000000000": "0x01", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x01", "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0xf5c30bbb2b8a1bdd2b881cc575b2acbd13578c7cd64250fe8b6770fa95f915b3", - "0x0000000000000000000000000000000000000000000000000000000000000003": "0xc3b1702cec31571337583b33aff1de6c39819514cb924dfb475190df8105445f" + "0x0000000000000000000000000000000000000000000000000000000000000003": "0xe8c309ac00a57ae243e2425b71b846dab7b7cce930d242bae613f2c27fb363e6" } } }, diff --git a/test/helpers/test-vectors/block-info/block-info.json b/test/helpers/test-vectors/block-info/block-info.json index d7ccd87f..83fda880 100644 --- a/test/helpers/test-vectors/block-info/block-info.json +++ b/test/helpers/test-vectors/block-info/block-info.json @@ -3,7 +3,7 @@ "id": 0, "description": "Get timestamp", "chainID": 1000, - "forkID": 7, + "forkID": 8, "sequencerAddress": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D", "sequencerPvtKey": "0x28b2b0318721be8c8339199172cd7cc8f5e273800a35616ec893083a4b32c02e", "genesis": [ @@ -149,7 +149,7 @@ "rawTx": "0xf86a05843b9aca00830186a0941275fbb540c8efc58b812ba83b0d0b8b9917ae9880843408e4708207f4a0e255f868a61169a2330cb539671e1a66ee846bc06cc888ea8fcd7ae51cdc6294a00c6dec27e6f756dd84923bcebb1f85db125299c0b622eaa8d5722cb3dace239d" } ], - "expectedNewRoot": "0x4295549e07af74c7c223f5e1a0e317aba14bb424c79b63feaf0186539660fbcf", + "expectedNewRoot": "0xc0977690cbf20eb6572fbb5e985645202d11ff2a72eb4de0f8f27681d5a66286", "expectedNewLeafs": { "0x0000000000000000000000000000000000000000": { "balance": "0", @@ -179,7 +179,7 @@ "0x0000000000000000000000000000000000000000000000000000000000000000": "0x617b3a3528f9cdd6630fd3301b9c8911f7bf063d", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af6f", "0x0000000000000000000000000000000000000000000000000000000000000003": "0x01", - "0x0000000000000000000000000000000000000000000000000000000000000005": "0xffffffffffffffff", + "0x0000000000000000000000000000000000000000000000000000000000000005": "0x04000000000000", "0x0000000000000000000000000000000000000000000000000000000000000006": "0x03e8" }, "hashBytecode": "0x3683afc3f35fba06b75ccdf2603d9a3c09f9dbda7b17994fc6cfc3e5f3cf40ef", @@ -199,7 +199,7 @@ "0x0000000000000000000000000000000000000000000000000000000000000000": "0x01", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af6f", "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0xf5c30bbb2b8a1bdd2b881cc575b2acbd13578c7cd64250fe8b6770fa95f915b3", - "0x0000000000000000000000000000000000000000000000000000000000000003": "0x6ff400dc5448288507bc3a8d940bd429617651a513a41c03f830fe4ac2c5c150" + "0x0000000000000000000000000000000000000000000000000000000000000003": "0x81cc6788f89024054025830f27649b2aad385ce3b2dc5ee3dd29ee5c7811afaf" }, "hashBytecode": "0x0000000000000000000000000000000000000000000000000000000000000000", "bytecodeLength": 0 diff --git a/test/helpers/test-vectors/end-to-end/state-transition-e2e.json b/test/helpers/test-vectors/end-to-end/state-transition-e2e.json index 913c009a..d98f1a34 100644 --- a/test/helpers/test-vectors/end-to-end/state-transition-e2e.json +++ b/test/helpers/test-vectors/end-to-end/state-transition-e2e.json @@ -4,7 +4,7 @@ "description": "Test end to end", "bridgeDeployed": true, "chainID": 1000, - "forkID": 7, + "forkID": 8, "sequencerAddress": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D", "sequencerPvtKey": "0x28b2b0318721be8c8339199172cd7cc8f5e273800a35616ec893083a4b32c02e", "genesis": [ @@ -237,7 +237,7 @@ "rawTx": "0xf9014f0480831e848094cfa773cc48fbde3ca4d24eecb19d224d697026b2880de0b6b3a7640000b8e4cd5865790000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c949254d682d8c9ad5682521675b8f43b102aec40000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000008207f3a022849420ce892ab01b2aab19a51c3fac9169b5a26c9789d9ee43041b1214048da05962de13a880e2b38309e41e7255e43bb5c5937dbb8270a7f6d990344b61a84e" } ], - "expectedNewRoot": "0x570ee7d168f2f230571952d9a4e772f93efeb0cf9154fa277130c1caf5b8a702", + "expectedNewRoot": "0x3fd1a09dfeaae2d1d4dda0d6c5dcad3f1efdc24299facb2b809ffb84ac568859", "expectedNewLeafs": { "0xa40d5f56745a118d0906a34e69aec8c0db1cb8fa": { "balance": "0", @@ -345,7 +345,7 @@ "0x0000000000000000000000000000000000000000000000000000000000000000": "0x01", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af6f", "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0x24c02821c526d801fd1d6d99afd57fdf862f4d3e2109fc36eb85bd5e2f5c508e", - "0x0000000000000000000000000000000000000000000000000000000000000003": "0xeefc6363cc1bd529b9915c6971722d526180b2fa735843b0ab2c5577b3626e26" + "0x0000000000000000000000000000000000000000000000000000000000000003": "0xace48443aa3874d0081c16ea85d424dfa679f416d489dc0bd03874e15099f3eb" }, "hashBytecode": "0x0000000000000000000000000000000000000000000000000000000000000000", "bytecodeLength": 0 diff --git a/test/helpers/test-vectors/inputs-executor/input_executor.json b/test/helpers/test-vectors/inputs-executor/input_executor.json index 123c65b4..e14d7ff5 100644 --- a/test/helpers/test-vectors/inputs-executor/input_executor.json +++ b/test/helpers/test-vectors/inputs-executor/input_executor.json @@ -7,7 +7,7 @@ "oldNumBatch": 0, "newNumBatch": 1, "chainID": 1000, - "forkID": 7, + "forkID": 8, "forcedBlockHashL1": "0x0000000000000000000000000000000000000000000000000000000000000000", "batchL2Data": "0x0b73e6af6e00000001ee80843b9aca00830186a0944d5cf5032b2a844602278b01199ed191a86c93ff88016345785d8a0000808203e880801cee7e01dc62f69a12c3510c6d64de04ee6346d84b6a017f3e786c7d87f963e75d8cc91fa983cd6d9cf55fff80d73bd26cd333b0f098acc1e58edb1fd484ad731bff0b0000000100000002", "l1InfoRoot": "0x462ed3d694d640f04f637e5e3893e8d12f407a53f50201401fd992bb5ab0faf0", diff --git a/test/helpers/test-vectors/processor/state-transition-etrog.json b/test/helpers/test-vectors/processor/state-transition-etrog.json index 62969785..5439c1e4 100644 --- a/test/helpers/test-vectors/processor/state-transition-etrog.json +++ b/test/helpers/test-vectors/processor/state-transition-etrog.json @@ -3,7 +3,7 @@ "id": 0, "description": "2 accounts and 1 valid transaction.", "chainID": 1000, - "forkID": 7, + "forkID": 8, "sequencerAddress": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D", "timestampLimit": 1944498031, "forcedBlockHashL1": "0x0000000000000000000000000000000000000000000000000000000000000000", @@ -129,7 +129,7 @@ "customRawTx": "0x0b0000000100000002" } ], - "expectedNewRoot": "0xcfd26b2ea6459214d13032686f4ab82da680a53730a71dd66622cab679fc1b4e", + "expectedNewRoot": "0x53b1926609705e334d90d991debad57d2d26dce6a1498c7dd2ef05c3f7f5ae50", "expectedNewLeafs": { "0xa40d5f56745a118d0906a34e69aec8c0db1cb8fa": { "balance": "0", @@ -162,8 +162,8 @@ "0x0000000000000000000000000000000000000000000000000000000000000000": "0x02", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af6f", "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0x4a9bfcb163ec91c5beb22e6aca41592433092c8c7821b01d37fd0de483f9265d", - "0x0000000000000000000000000000000000000000000000000000000000000003": "0xcc723c90f3a6972d60da879ed3c4e67df3e406dcf8547f57f26a4d7ad415128a", - "0xcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f": "0x1a489f5cceee3c901a54d4e9448624e47798a15b6d9bbf3e1e57b26b131c32af" + "0x0000000000000000000000000000000000000000000000000000000000000003": "0x85e9c18a017b997c6b778f0f22938fa3ecf9be2b7ae4f23beaeced0c27dc1eae", + "0xcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f": "0xf183d38e6464599399550b503e7d34dbfcb7e78ec3e310760c94ea822778b4fd" }, "hashBytecode": "0x0000000000000000000000000000000000000000000000000000000000000000", "bytecodeLength": 0 @@ -181,7 +181,7 @@ "id": 1, "description": "Forced batch: 2 accounts and 1 valid transaction", "chainID": 1000, - "forkID": 7, + "forkID": 8, "sequencerAddress": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D", "timestampLimit": 1944498031, "forcedBlockHashL1": "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3", @@ -215,7 +215,7 @@ "customRawTx": "0xee80843b9aca00830186a0944d5cf5032b2a844602278b01199ed191a86c93ff88016345785d8a0000808203e880801cee7e01dc62f69a12c3510c6d64de04ee6346d84b6a017f3e786c7d87f963e75d8cc91fa983cd6d9cf55fff80d73bd26cd333b0f098acc1e58edb1fd484ad731bff" } ], - "expectedNewRoot": "0xe901d18ce137479cf6b85e7e0911c889cc8621f7957f4b25d9fff606a11a01d8", + "expectedNewRoot": "0x2c213c6303950389ff98e1226fabf5e48a622b5fcebfb84d247802b55be29629", "expectedNewLeafs": { "0xa40d5f56745a118d0906a34e69aec8c0db1cb8fa": { "balance": "0", @@ -247,7 +247,7 @@ "0x0000000000000000000000000000000000000000000000000000000000000000": "0x01", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af6f", "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0x4a9bfcb163ec91c5beb22e6aca41592433092c8c7821b01d37fd0de483f9265d", - "0x0000000000000000000000000000000000000000000000000000000000000003": "0x412e8641edca3815cc1509a1f515c9a57b20b2c24072c98cdb4f72c00ea8b5c8" + "0x0000000000000000000000000000000000000000000000000000000000000003": "0xc69f62da6469c60bba98bc2113aee05d0a574038a2b171f14a2b6a0b5fd13afd" }, "hashBytecode": "0x0000000000000000000000000000000000000000000000000000000000000000", "bytecodeLength": 0 @@ -265,7 +265,7 @@ "id": 2, "description": "Forced batch: starts with changeL2Block --> invalid batch", "chainID": 1000, - "forkID": 7, + "forkID": 8, "sequencerAddress": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D", "timestampLimit": 1944498031, "forcedBlockHashL1": "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3", diff --git a/test/helpers/test-vectors/processor/state-transition.json b/test/helpers/test-vectors/processor/state-transition.json index 920f0c74..d96f25b9 100644 --- a/test/helpers/test-vectors/processor/state-transition.json +++ b/test/helpers/test-vectors/processor/state-transition.json @@ -3,7 +3,7 @@ "id": 0, "description": "2 accounts and 1 valid transaction.", "chainID": 1000, - "forkID": 7, + "forkID": 8, "sequencerAddress": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D", "timestampLimit": 1944498031, "genesis": [ @@ -48,7 +48,7 @@ "customRawTx": "0xee80843b9aca00830186a0944d5cf5032b2a844602278b01199ed191a86c93ff88016345785d8a0000808203e880801cee7e01dc62f69a12c3510c6d64de04ee6346d84b6a017f3e786c7d87f963e75d8cc91fa983cd6d9cf55fff80d73bd26cd333b0f098acc1e58edb1fd484ad731bff" } ], - "expectedNewRoot": "0x7419a71f9923fca08275c77c2603de4ecec62f37f4c1d00229b38e17424320ba", + "expectedNewRoot": "0x5fc97a9a6ea9918f4b26e2dd52b27a688621cd4d2ff5c624c2df0cd1986d3b41", "expectedNewLeafs": { "0x617b3a3528f9cdd6630fd3301b9c8911f7bf063d": { "balance": "99900000000000000000", @@ -71,7 +71,7 @@ "0x0000000000000000000000000000000000000000000000000000000000000000": "0x01", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af6f", "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0x4a9bfcb163ec91c5beb22e6aca41592433092c8c7821b01d37fd0de483f9265d", - "0x0000000000000000000000000000000000000000000000000000000000000003": "0x9675adb76a5d1a0776067b07073f74735f2cb4a55732e6396c1322c143c4bc68" + "0x0000000000000000000000000000000000000000000000000000000000000003": "0x3a309dd643ff8f4ad879f589db391b02f1ecba32ca7596996f23de84313f4e05" }, "hashBytecode": "0x0000000000000000000000000000000000000000000000000000000000000000", "bytecodeLength": 0 @@ -89,7 +89,7 @@ "id": 1, "description": "5 accounts. 2 valid tx, 3 invalid tx (same amount as balance, invalid nonce, invalid chain id 1)", "chainID": 1000, - "forkID": 7, + "forkID": 8, "sequencerAddress": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D", "genesis": [ { @@ -203,7 +203,7 @@ "rawTx": "0xf86c80843b9aca00830186a094abcced19d7f290b84608fec510bee872cc8f5112880de0b6b3a7640000801ba02c92035bc11227e9e94ba066a6d77a65c43d29dfb4a855c9464e1b60fabd6334a07171c6dc84816ffcf025040cd6193ecef3928a0c4e4964ddba320826b76c725d" } ], - "expectedNewRoot": "0x4369f0637a7da0ff4c671a84ce53198a8203e697d350dd75ab64f9041ba4e876", + "expectedNewRoot": "0x1f7bc8a70aea2383d32dbc5a1ed6f0923175b16dbd4ec1139a78963b58bd0736", "expectedNewLeafs": { "0x617b3a3528f9cdd6630fd3301b9c8911f7bf063d": { "balance": "99900021000000000000", @@ -247,7 +247,7 @@ "0x0000000000000000000000000000000000000000000000000000000000000000": "0x01", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af6f", "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0x76b362a9afd679ea13a456ab103786492c65946be653589c1fd627841d0c6fdd", - "0x0000000000000000000000000000000000000000000000000000000000000003": "0xad44dbf296830f69ee8c761c6efe3534ee86ee65e0ee70ae532f56d4f1bb7df1" + "0x0000000000000000000000000000000000000000000000000000000000000003": "0xb17d6bb600805b247aeb3749c1cc2df8d49abbedead409c353979233af219628" }, "hashBytecode": "0x0000000000000000000000000000000000000000000000000000000000000000", "bytecodeLength": 0 @@ -266,7 +266,7 @@ "id": 2, "description": "2 accounts and 1 invalid tx (tx with more value than balance). Old root equals new root.", "chainID": 1000, - "forkID": 7, + "forkID": 8, "sequencerAddress": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D", "genesis": [ { @@ -310,7 +310,7 @@ "customRawTx": "0xf080843b9aca00830186a0944d5cf5032b2a844602278b01199ed191a86c93ff8a021e19e0c9bab2400000808203e8808069d48cb9ade9de851379987aa0f7f677cdaee1152ec785a3d3009f094c889be9368c3d198cdfe5b1e0100fe110ea60e77b1eb65e9363d96f7fb9c2b84a37c9b01cff" } ], - "expectedNewRoot": "0xd1f3634407a983d709cc769c47f73252671b02d3a5ac8d37aed5ef344633bd2d", + "expectedNewRoot": "0xe07a5a89dc8ce12f6d6bb24d98c0e8d74becf90becd77eabf82f9f6c8c871bc3", "expectedNewLeafs": { "0x000000000000000000000000000000005ca1ab1e": { "balance": "0", @@ -319,7 +319,7 @@ "0x0000000000000000000000000000000000000000000000000000000000000000": "0x01", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af6f", "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0x4a9bfcb163ec91c5beb22e6aca41592433092c8c7821b01d37fd0de483f9265d", - "0x0000000000000000000000000000000000000000000000000000000000000003": "0x3ebe99d151d7aac9a9b2302d188e0b7751fb3af804eecfbd96e639c25c466778" + "0x0000000000000000000000000000000000000000000000000000000000000003": "0x3cbe55c24c7d48ca769fa5bd050c118ab339e1236e7fc8c8a178072d6d437fd9" }, "hashBytecode": "0x0000000000000000000000000000000000000000000000000000000000000000", "bytecodeLength": 0 @@ -348,7 +348,7 @@ "id": 3, "description": "2 accounts and 4 invalid transactions. Two of the transactions have invalid from and to address so no rawTx is provided for them, can be ignored.Tx with same amount than balance and tx with invalid chain id (different chain id than sequencer). Old root equals new root", "chainID": 1000, - "forkID": 7, + "forkID": 8, "sequencerAddress": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D", "genesis": [ { @@ -427,7 +427,7 @@ "customRawTx": "0xef80843b9aca00830186a0944d5cf5032b2a844602278b01199ed191a86c93ff89056bc75e2d63100000808203e880806fac51f437890686cea7fc4d478e01f4650284d8b0c447d3a049ad799a938e855d76085acbdd3af82e205f070fd3f333d3f069ab3936323ac347003f07d9418a1bff" } ], - "expectedNewRoot": "0xd1f3634407a983d709cc769c47f73252671b02d3a5ac8d37aed5ef344633bd2d", + "expectedNewRoot": "0xe07a5a89dc8ce12f6d6bb24d98c0e8d74becf90becd77eabf82f9f6c8c871bc3", "expectedNewLeafs": { "0x000000000000000000000000000000005ca1ab1e": { "balance": "0", @@ -436,7 +436,7 @@ "0x0000000000000000000000000000000000000000000000000000000000000000": "0x01", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af6f", "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0x4a9bfcb163ec91c5beb22e6aca41592433092c8c7821b01d37fd0de483f9265d", - "0x0000000000000000000000000000000000000000000000000000000000000003": "0x3ebe99d151d7aac9a9b2302d188e0b7751fb3af804eecfbd96e639c25c466778" + "0x0000000000000000000000000000000000000000000000000000000000000003": "0x3cbe55c24c7d48ca769fa5bd050c118ab339e1236e7fc8c8a178072d6d437fd9" }, "hashBytecode": "0x0000000000000000000000000000000000000000000000000000000000000000", "bytecodeLength": 0 @@ -465,7 +465,7 @@ "id": 4, "description": "2 accounts and 1 invalid transaction. Wrong encode of the tx (invalid signature). Old root equals new root", "chainID": 1000, - "forkID": 7, + "forkID": 8, "sequencerAddress": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D", "genesis": [ { @@ -536,7 +536,7 @@ "id": 5, "description": "2 accounts and 1 valid transaction, from and to are the same", "chainID": 1000, - "forkID": 7, + "forkID": 8, "sequencerAddress": "0x4d5Cf5032B2a844602278b01199ED191A86c93ff", "genesis": [ { @@ -580,7 +580,7 @@ "customRawTx": "0xee80843b9aca00830186a094617b3a3528f9cdd6630fd3301b9c8911f7bf063d88016345785d8a0000808203e88080cca9bd00c0a9af18cdc17e693951b88b293bae8ed236ff7dcf2684c478bc0b6a19cc9ed09ee5e1e2750abbea7ec8d2ed31df90c7d364d4e2f36c31eb410c10451bff" } ], - "expectedNewRoot": "0xb6ec7fba1559383c498889017b2abc2afb850ef45389a4ddf1def2050c77b6d5", + "expectedNewRoot": "0x965b1824c63e2753e4453fa99e3d9b2cd2ca121fcce21dfd184f06b9f4d81920", "expectedNewLeafs": { "0x617b3a3528f9cdd6630fd3301b9c8911f7bf063d": { "balance": "99999979000000000000", @@ -603,7 +603,7 @@ "0x0000000000000000000000000000000000000000000000000000000000000000": "0x01", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af6f", "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0x4a9bfcb163ec91c5beb22e6aca41592433092c8c7821b01d37fd0de483f9265d", - "0x0000000000000000000000000000000000000000000000000000000000000003": "0x6949f6c1c685502276ad7d99e964931f55877fe99e7c6226d6274a6050830d6b" + "0x0000000000000000000000000000000000000000000000000000000000000003": "0xb8f08dfabc84bdac3d056511c3ffbad64dea8fcb109c49769695969de9c9650c" }, "hashBytecode": "0x0000000000000000000000000000000000000000000000000000000000000000", "bytecodeLength": 0 @@ -622,7 +622,7 @@ "id": 6, "description": "2 accounts. 1 valid tx, 3 invalid tx (same amount as balance, invalid nonce, invalid chain id", "chainID": 1000, - "forkID": 7, + "forkID": 8, "sequencerAddress": "0x4d5Cf5032B2a844602278b01199ED191A86c93ff", "genesis": [ { @@ -705,7 +705,7 @@ "rawTx": "0xf86c80843b9aca00830186a0944d5cf5032b2a844602278b01199ed191a86c93ff880de0b6b3a7640000801ba077f76b76aca6161db28545aa742536370e4f57f9a71651688631a423abcbe04aa0131474e130abe8bcc9ef39a44a877eb64b2d43132cb0907abe547aa605b641b8" } ], - "expectedNewRoot": "0xdc82291cd8cb5607c00e5b8c96f48afdf4e73e6925eed1f0ed300b605dc88af3", + "expectedNewRoot": "0x5f80166855e023f531a61906078d1fc6cbc269e17f243d5b3aed38bb20abb37c", "expectedNewLeafs": { "0x617b3a3528f9cdd6630fd3301b9c8911f7bf063d": { "balance": "99899979000000000000", @@ -728,7 +728,7 @@ "0x0000000000000000000000000000000000000000000000000000000000000000": "0x01", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af6f", "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0x4a9bfcb163ec91c5beb22e6aca41592433092c8c7821b01d37fd0de483f9265d", - "0x0000000000000000000000000000000000000000000000000000000000000003": "0x5a84cde29990c2be13af332ddf51e6513184f8e0114810bd9c0c8c877b6b154d" + "0x0000000000000000000000000000000000000000000000000000000000000003": "0x351aa016b93766b196ec23b47c9a0aa252363dd4cb9a08b581990f0f72fec4ac" }, "hashBytecode": "0x0000000000000000000000000000000000000000000000000000000000000000", "bytecodeLength": 0 @@ -747,7 +747,7 @@ "id": 7, "description": "2 accounts and 1 valid transaction, from, to and sequencer are the same", "chainID": 1000, - "forkID": 7, + "forkID": 8, "sequencerAddress": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D", "genesis": [ { @@ -791,7 +791,7 @@ "customRawTx": "0xee80843b9aca00830186a094617b3a3528f9cdd6630fd3301b9c8911f7bf063d88016345785d8a0000808203e88080cca9bd00c0a9af18cdc17e693951b88b293bae8ed236ff7dcf2684c478bc0b6a19cc9ed09ee5e1e2750abbea7ec8d2ed31df90c7d364d4e2f36c31eb410c10451bff" } ], - "expectedNewRoot": "0xdcbc4f7af20a522c9bae09dfa040f5689d8aa0157ad89e53bec6f0b82c0e568d", + "expectedNewRoot": "0xa0498e7c0a65d76336880b71a8478fd4d2dc9d0329bcf5177e132a4a36b70f1e", "expectedNewLeafs": { "0x617b3a3528f9cdd6630fd3301b9c8911f7bf063d": { "balance": "100000000000000000000", @@ -814,7 +814,7 @@ "0x0000000000000000000000000000000000000000000000000000000000000000": "0x01", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af6f", "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0x4a9bfcb163ec91c5beb22e6aca41592433092c8c7821b01d37fd0de483f9265d", - "0x0000000000000000000000000000000000000000000000000000000000000003": "0x5ba4d7b4f761bc8971885fdd21a89cb3d7b4568547e121adcb0702b247d00955" + "0x0000000000000000000000000000000000000000000000000000000000000003": "0xb478fb0fb208ed22aea134356a763ce77ba82c338a37650e38d095eca3b6dcc7" }, "hashBytecode": "0x0000000000000000000000000000000000000000000000000000000000000000", "bytecodeLength": 0 @@ -833,7 +833,7 @@ "id": 8, "description": "2 accounts and 2 valid transaction, sequencer is able to do the transaction because the fees are payed at the end of every tx", "chainID": 1000, - "forkID": 7, + "forkID": 8, "sequencerAddress": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D", "genesis": [ { @@ -890,7 +890,7 @@ "customRawTx": "0xee80843b9aca00830186a0944d5cf5032b2a844602278b01199ed191a86c93ff8806f05b59d3b20000808203e880809990717b4c80d955cacf4a765d3bfefd707511d66e0a482510906d119fa285c7232ccd442c5b618558b62175f01d9f45ff655d480f36394ea50a0b7dc52bc3331cff" } ], - "expectedNewRoot": "0x0f12a433d39c8cec7e1108a29f4c9865d5b9456125bf7bfea97908ec8bf2d052", + "expectedNewRoot": "0xdbe70b407c411c954cbe9f7d44a21731889e432fa1bfe216749150c29968bcd6", "expectedNewLeafs": { "0x617b3a3528f9cdd6630fd3301b9c8911f7bf063d": { "balance": "499999000000000000", @@ -913,7 +913,7 @@ "0x0000000000000000000000000000000000000000000000000000000000000000": "0x01", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af6f", "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0x8397a02db0909df274170a8a1a4e45f6d7f24e66606976cd00960d8c6c850c97", - "0x0000000000000000000000000000000000000000000000000000000000000003": "0x98ad0c4b5bfef92bb43500be67992aa85a9028674235ffdc4b1634eb27d47a33" + "0x0000000000000000000000000000000000000000000000000000000000000003": "0x81f1f73209a7caaa47dc6914c36fef91784c3c44016545791be24f7713123165" }, "hashBytecode": "0x0000000000000000000000000000000000000000000000000000000000000000", "bytecodeLength": 0 @@ -932,7 +932,7 @@ "id": 9, "description": "2 accounts and 4 valid transaction, 4 transactions from the same account", "chainID": 1000, - "forkID": 7, + "forkID": 8, "sequencerAddress": "0x4d5Cf5032B2a844602278b01199ED191A86c93ff", "genesis": [ { @@ -1015,7 +1015,7 @@ "rawTx": "0xf86e03843b9aca00830186a094617b3a3528f9cdd6630fd3301b9c8911f7bf063d8806f05b59d3b20000808207f3a047b4f7d735dfadefc585bf24d9bd2267438f9bc92d1ab4f65fa9a6d90cc33858a00720a7da26cad22c05bf1358011c95caec969b8b9177af91c0e90dac3d02f6b3" } ], - "expectedNewRoot": "0x0b22205fce7b2fb49fc26835c3e955ec7a3f65d6ffbc44e0bfb2fa847fef32e3", + "expectedNewRoot": "0xe58cab1766ae4c387f94204ee0cfeecf67feb084beeab454daaa0b05992bd27f", "expectedNewLeafs": { "0x617b3a3528f9cdd6630fd3301b9c8911f7bf063d": { "balance": "99799916000000000000", @@ -1038,7 +1038,7 @@ "0x0000000000000000000000000000000000000000000000000000000000000000": "0x01", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af6f", "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0x4a9bfcb163ec91c5beb22e6aca41592433092c8c7821b01d37fd0de483f9265d", - "0x0000000000000000000000000000000000000000000000000000000000000003": "0x0fded60cdefdc3623ccc961f7cfa792dc45a2cc431cfcff56daf42304a370784" + "0x0000000000000000000000000000000000000000000000000000000000000003": "0x51d0fddee818fc8aa4192c3c8082a9702428ac50ecc4db22d400b87983a8094b" }, "hashBytecode": "0x0000000000000000000000000000000000000000000000000000000000000000", "bytecodeLength": 0 @@ -1057,7 +1057,7 @@ "id": 10, "description": "2 accounts + 1 contract + and 2 valid transaction.", "chainID": 1000, - "forkID": 7, + "forkID": 8, "sequencerAddress": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D", "sequencerPvtKey": "0x28b2b0318721be8c8339199172cd7cc8f5e273800a35616ec893083a4b32c02e", "genesis": [ @@ -1132,7 +1132,7 @@ "rawTx": "0xf86e80843b9aca00830186a0944d5cf5032b2a844602278b01199ed191a86c93ff88016345785d8a0000808207f3a01cee7e01dc62f69a12c3510c6d64de04ee6346d84b6a017f3e786c7d87f963e7a05d8cc91fa983cd6d9cf55fff80d73bd26cd333b0f098acc1e58edb1fd484ad73" } ], - "expectedNewRoot": "0xde1b21bb54454eb5605cd6258aad7ed38259e5296a38db6ad628d3f5f71a47b6", + "expectedNewRoot": "0x05d83c9fcbe1e7c672b400807077c81eb0f0cf8acc18cbf3cf694c285336984c", "expectedNewLeafs": { "0x617b3a3528f9cdd6630fd3301b9c8911f7bf063d": { "balance": "99900026624000000000", @@ -1165,7 +1165,7 @@ "0x0000000000000000000000000000000000000000000000000000000000000000": "0x01", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af6f", "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0x7281dd8612498e474632eabb78a60346362053c5313a496edd646ca6db4f62ad", - "0x0000000000000000000000000000000000000000000000000000000000000003": "0xe4b586258e26e086db37b0165631b2d431dd3442daa9b8654c94c562867e7be5" + "0x0000000000000000000000000000000000000000000000000000000000000003": "0xce6c7ac1685d02967057cb24aa532bdd645ed581cee394077cceaa2ad407a7b9" }, "hashBytecode": "0x0000000000000000000000000000000000000000000000000000000000000000", "bytecodeLength": 0 @@ -1184,7 +1184,7 @@ "id": 11, "description": "2 accounts + 2 contract + and 1 tx to contract + contract call ", "chainID": 1000, - "forkID": 7, + "forkID": 8, "sequencerAddress": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D", "sequencerPvtKey": "0x28b2b0318721be8c8339199172cd7cc8f5e273800a35616ec893083a4b32c02e", "genesis": [ @@ -1257,7 +1257,7 @@ "rawTx": "0xf8ab01843b9aca00830186a0941275fbb540c8efc58b812ba83b0d0b8b9917ae9880b844494e4bc30000000000000000000000004d5cf5032b2a844602278b01199ed191a86c93ff00000000000000000000000000000000000000000000000000038d7ea4c680008207f3a0c83069009c51e411569ca78a660bbcb64e4e6709909eb99c28395fb4c787da4ca02b846bf51fcf891fb293e36a0cf5f4efd1fe7c19b2c8a1220b8308b195e80156" } ], - "expectedNewRoot": "0x3d766e5d597071269b99b0908f5ef05109c14656e2d358efd5ff3c4ee8cab2ff", + "expectedNewRoot": "0x53481ab2675847113e8d027cad664822fdbfa0701f5f90c6c0ed913368aa5aaf", "expectedNewLeafs": { "0x617b3a3528f9cdd6630fd3301b9c8911f7bf063d": { "balance": "99900000000000000000", @@ -1287,7 +1287,7 @@ "0x0000000000000000000000000000000000000000000000000000000000000000": "0x01", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af6f", "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0x144bac90dd26abcbd923370ec5155b2416fac64f542d21ad0d5a50dc15598c78", - "0x0000000000000000000000000000000000000000000000000000000000000003": "0xf09dc267642bcb752471cbdfbd3f917de6f8dabdb86848dd3061365c5bc00da2" + "0x0000000000000000000000000000000000000000000000000000000000000003": "0xea8cd4a1087196a7795f7d0d29c91c540f25679ca76b53d4e83c22e055a8055d" }, "hashBytecode": "0x0000000000000000000000000000000000000000000000000000000000000000", "bytecodeLength": 0 @@ -1306,7 +1306,7 @@ "id": 12, "description": "2 accounts + 2 contract with constructor + and 1 tx to contract + 1 contract call", "chainID": 1000, - "forkID": 7, + "forkID": 8, "sequencerAddress": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D", "sequencerPvtKey": "0x28b2b0318721be8c8339199172cd7cc8f5e273800a35616ec893083a4b32c02e", "genesis": [ @@ -1388,7 +1388,7 @@ "rawTx": "0xf88a01843b9aca00830186a0941275fbb540c8efc58b812ba83b0d0b8b9917ae9880a4027e5d610000000000000000000000004d5cf5032b2a844602278b01199ed191a86c93ff8207f3a0a04c0969f64f440a2c91e29bf9ea0b1cc8db9f33bda47c2c6899840ae46d36d7a00212c0a9f1bb015890ed0830c7fea6c52adaf85b0bf3d64448d3300c12c1bb16" } ], - "expectedNewRoot": "0xee14110cd26fc40b64d04218798351ff0349e9c7f8ff228eb5d5be97796970c6", + "expectedNewRoot": "0x0abbcbc0ea36cf39624153774976e73a387dca25b6e06ab182bd1204958f1aba", "expectedNewLeafs": { "0x617b3a3528f9cdd6630fd3301b9c8911f7bf063d": { "balance": "99900000000000000000", @@ -1420,7 +1420,7 @@ "0x0000000000000000000000000000000000000000000000000000000000000000": "0x01", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af6f", "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0x2535fbb1a1509a05832eb23bd775b7bb726f6a24183283935b5fb1096ff88c28", - "0x0000000000000000000000000000000000000000000000000000000000000003": "0x6f4d686b12318729b6cd2480f7f2a7b17aa81dcac73c5fdffcbd623e9e459942" + "0x0000000000000000000000000000000000000000000000000000000000000003": "0x78b18289716414804d3d175565678255ff05407fe5651d70209600b31fb78e2b" }, "hashBytecode": "0x0000000000000000000000000000000000000000000000000000000000000000", "bytecodeLength": 0 @@ -1439,7 +1439,7 @@ "id": 13, "description": "2 accounts + and 1 tx to contract deploy + 1 call to deplyed contract", "chainID": 1000, - "forkID": 7, + "forkID": 8, "sequencerAddress": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D", "sequencerPvtKey": "0x28b2b0318721be8c8339199172cd7cc8f5e273800a35616ec893083a4b32c02e", "genesis": [ @@ -1521,7 +1521,7 @@ "rawTx": "0xf88a02843b9aca00830186a0941275fbb540c8efc58b812ba83b0d0b8b9917ae9880a4027e5d610000000000000000000000004d5cf5032b2a844602278b01199ed191a86c93ff8207f3a028e62eb40661fd098322a7211dca25a6b56f60eefb24ede9607d2603a09e4c65a03be289b7a729a18336e2f9f4a4f52c4fadc4274d1fd42dd8965deeb8634ddddc" } ], - "expectedNewRoot": "0x01b475532f1c21dd6368afe41c183a46dad4cab8ad07c510a97f1db7a285df73", + "expectedNewRoot": "0x6ebf09c4f76ca7d209a559551a6b2c11a84c398fbcef54ddd97350e7644a7260", "expectedNewLeafs": { "0x617b3a3528f9cdd6630fd3301b9c8911f7bf063d": { "balance": "99900000000000000000", @@ -1544,7 +1544,7 @@ "0x0000000000000000000000000000000000000000000000000000000000000000": "0x01", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af6f", "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0x5321e97596347ed38932cf308e5346af6208deaaf459b5ecc18ca2b23d97d15c", - "0x0000000000000000000000000000000000000000000000000000000000000003": "0x2ed4faabe72c26cd1c53ced7f851eb534d003a4a285c07602db9534611eb9dee" + "0x0000000000000000000000000000000000000000000000000000000000000003": "0x8c8b5ecec07fa721d124789f0e517bbba033a53d9b14a667b21656fdda6bb6d2" }, "hashBytecode": "0x0000000000000000000000000000000000000000000000000000000000000000", "bytecodeLength": 0 @@ -1572,7 +1572,7 @@ "id": 14, "description": "2 accounts and 3 valid transactions", "chainID": 1000, - "forkID": 7, + "forkID": 8, "sequencerAddress": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D", "timestampLimit": 1944498031, "genesis": [ @@ -1643,7 +1643,7 @@ "customRawTx": "0xee02843b9aca00830186a0944d5cf5032b2a844602278b01199ed191a86c93ff880429d069189e0000808203e88080dc5f4215d7bf1d48547ffbe35e57dadcb338fc8cc7e3e8bb6a686becf1eea3eb56a0ac4b56810a3394ddff7345987ba3b324cd2c1def30a952e6c54ac300966b1cff" } ], - "expectedNewRoot": "0x0d55bff80b7de0b95e870cb522b5d2602a0ea134ae7b2d2b75301abb41ae7210", + "expectedNewRoot": "0xefe9c8e74abe784726e24abfce552dad9e848aa092aee51f43672f2ae914dbff", "expectedNewLeafs": { "0x617b3a3528f9cdd6630fd3301b9c8911f7bf063d": { "balance": "99400000000000000000", @@ -1666,7 +1666,7 @@ "0x0000000000000000000000000000000000000000000000000000000000000000": "0x01", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af6f", "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0x4a9bfcb163ec91c5beb22e6aca41592433092c8c7821b01d37fd0de483f9265d", - "0x0000000000000000000000000000000000000000000000000000000000000003": "0x2adb1117c355d5a4dfa41637699d0570e0bd6fc82fa5a8210c0e7deb7c381115" + "0x0000000000000000000000000000000000000000000000000000000000000003": "0xa5e42c8d7380cd03df36dd3e85d598d9e1e694826df09910dff7ff34ae5eec91" }, "hashBytecode": "0x0000000000000000000000000000000000000000000000000000000000000000", "bytecodeLength": 0 diff --git a/test/helpers/test-vectors/selfdestruct/selfdestruct.json b/test/helpers/test-vectors/selfdestruct/selfdestruct.json index 9aa6dca2..4ae70017 100644 --- a/test/helpers/test-vectors/selfdestruct/selfdestruct.json +++ b/test/helpers/test-vectors/selfdestruct/selfdestruct.json @@ -3,7 +3,7 @@ "id": 0, "description": "Selfdestruct", "chainID": 1000, - "forkID": 7, + "forkID": 8, "sequencerAddress": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D", "sequencerPvtKey": "0x28b2b0318721be8c8339199172cd7cc8f5e273800a35616ec893083a4b32c02e", "genesis": [ @@ -103,7 +103,7 @@ "rawTx": "0xf86a02843b9aca00830186a0941275fbb540c8efc58b812ba83b0d0b8b9917ae9880842b68b9c68207f4a0f5b684b995dd9549bb5fd2ed23d3b388f75f559b14110277b4ae7de5bd7775efa01be51078330d1ef03f0e4fe0271e8e2502b6e98c1f7664a5e2aeae3ab04156d4" } ], - "expectedNewRoot": "0xedfb77387de7337aec167cb12bb76fd83c5684fb8c9bbddd333ad1c43e18fab6", + "expectedNewRoot": "0x895f95fa944da09237bb1b9711a0e66f7bc3fd27b08eb4e2b2b94726d0b2d0cd", "expectedNewLeafs": { "0x0000000000000000000000000000000000000000": { "balance": "0", @@ -150,7 +150,7 @@ "0x0000000000000000000000000000000000000000000000000000000000000000": "0x01", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af6f", "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0x2761798d338f390fa233a5ff12c7fd6a50ab8a82e559c25e2895516c3e4213c6", - "0x0000000000000000000000000000000000000000000000000000000000000003": "0xfd69b7a318f4364e754a190077df534a246874151a3534bd4100dcd5456fef21" + "0x0000000000000000000000000000000000000000000000000000000000000003": "0xec9a95baade06355dff5723669ed4dec0b8c7404f8a36146ce93dd31235a48ec" }, "hashBytecode": "0x0000000000000000000000000000000000000000000000000000000000000000", "bytecodeLength": 0 diff --git a/test/helpers/test-vectors/zkevm-db/recursive.json b/test/helpers/test-vectors/zkevm-db/recursive.json index 13bdd19c..b32ede2f 100644 --- a/test/helpers/test-vectors/zkevm-db/recursive.json +++ b/test/helpers/test-vectors/zkevm-db/recursive.json @@ -3,7 +3,7 @@ "id": 0, "description": "2 accounts and 1 valid transaction.", "chainID": 1000, - "forkID": 7, + "forkID": 8, "sequencerAddress": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D", "l1InfoRoot": "0x090bcaf734c4f06c93954a827b45a6e8c67b8e0fd1e0a35a1c5982d6961828f9", "oldAccInputHash": "0x0000000000000000000000000000000000000000000000000000000000000000", @@ -53,7 +53,7 @@ "customRawTx": "0xee80843b9aca00830186a0944d5cf5032b2a844602278b01199ed191a86c93ff880de0b6b3a7640000808203e880803317280d96c3ed303a42d9da2638805301351c96cad135380ffa544d3c2bc96a6a55cef2d3827323f134976dd99a33bebef27b5e99c454fb1f8d4a4861ac4e0f1cff" } ], - "expectedNewRoot": "0x417009b96894880b4250c10704c85d58b559dd6ed140e21fb4cd499eb6d7f75d", + "expectedNewRoot": "0xdce3cbabb38e22f9b4faa7f146e03234f770efd5e034f0ea34c428378653981d", "expectedNewAccInputHash": "0xc478ed467ed45d537089ac7e88e9af0d0e242858c05d89a74886658b6d0ee40b", "expoectNewLocalExitRoot": "", "expectedNewLocalExitRoot": "0x0000000000000000000000000000000000000000000000000000000000000000", @@ -109,7 +109,7 @@ "0x0000000000000000000000000000000000000000000000000000000000000000": "0x01", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af6f", "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0x4a9bfcb163ec91c5beb22e6aca41592433092c8c7821b01d37fd0de483f9265d", - "0x0000000000000000000000000000000000000000000000000000000000000003": "0x5ff276a04f43372f8431b011b607690b6fda137c2dd51cbddde1413dac51c63c" + "0x0000000000000000000000000000000000000000000000000000000000000003": "0x0627f99dd3b4b9410a7c6e9de8140a3a3a43501c5017e0942db84cb9cc0590d3" }, "hashBytecode": "0x0000000000000000000000000000000000000000000000000000000000000000", "bytecodeLength": 0 @@ -144,7 +144,7 @@ "customRawTx": "0xee01843b9aca00830186a0944d5cf5032b2a844602278b01199ed191a86c93ff881bc16d674ec80000808203e88080bf1d7a420018877e3b781282465de4f3d6f2a5e678ce36fb694832a59ec437504c2dd20a8be59f26a3a84739512cafef34449d4008340ecebc9aea69dff382c31cff" } ], - "expectedNewRoot": "0xa21692acd4333bf04de4d7dd60d20dd9f52df168d0bc46dd9ad380acfca2bacb", + "expectedNewRoot": "0x980788a678a534114fc2946998687ba7cbba11c91bc0809f8bdf0e63c04cbac0", "expectedNewAccInputHash": "0xe2d4571827432a99c09609d8f95dc8b207bfd6010b08e22462cf717597f788ff", "expoectNewLocalExitRoot": "", "expectedNewLocalExitRoot": "0x0000000000000000000000000000000000000000000000000000000000000000", @@ -185,10 +185,10 @@ "nonce": "0", "storage": { "0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0x4a9bfcb163ec91c5beb22e6aca41592433092c8c7821b01d37fd0de483f9265d", - "0xcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f": "0x417009b96894880b4250c10704c85d58b559dd6ed140e21fb4cd499eb6d7f75d", + "0xcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f": "0xdce3cbabb38e22f9b4faa7f146e03234f770efd5e034f0ea34c428378653981d", "0x0000000000000000000000000000000000000000000000000000000000000000": "0x02", "0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af70", - "0x0000000000000000000000000000000000000000000000000000000000000003": "0xea015e0b42f0390bf497632e6f94de6612db0de6401ab337cdfce16100836640" + "0x0000000000000000000000000000000000000000000000000000000000000003": "0x900056265820a6a724fd7dcb9758bdd0f663ce83341ee9d06ec77189a90b969e" }, "hashBytecode": "0x0000000000000000000000000000000000000000000000000000000000000000", "bytecodeLength": 0 @@ -210,10 +210,10 @@ } } ], - "finalStateRoot": "0xa21692acd4333bf04de4d7dd60d20dd9f52df168d0bc46dd9ad380acfca2bacb", + "finalStateRoot": "0x980788a678a534114fc2946998687ba7cbba11c91bc0809f8bdf0e63c04cbac0", "finalLocalExitRoot": "0x0000000000000000000000000000000000000000000000000000000000000000", "finalAccInputHash": "0xe2d4571827432a99c09609d8f95dc8b207bfd6010b08e22462cf717597f788ff", "finalNumBatch": 2, - "inputSnark": "0x231e6317cbd164e13e4a3537980f82da5659073d7efbc54bf62d8a16d035af00" + "inputSnark": "0x059181879f1d1f7392a2f874ba1047eb8ba64ee1ea2e92a547f5ca0bb4a3cbf9" } ] \ No newline at end of file diff --git a/test/helpers/test-vectors/zkevm-db/state-transition.json b/test/helpers/test-vectors/zkevm-db/state-transition.json index f3f6b00f..13cd707a 100644 --- a/test/helpers/test-vectors/zkevm-db/state-transition.json +++ b/test/helpers/test-vectors/zkevm-db/state-transition.json @@ -3,7 +3,7 @@ "id": 0, "description": "2 accounts and 1 valid transaction.", "chainID": 1000, - "forkID": 7, + "forkID": 8, "sequencerAddress": "0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D", "genesis": [ { @@ -47,7 +47,7 @@ "customRawTx": "0xee80843b9aca00830186a0944d5cf5032b2a844602278b01199ed191a86c93ff88016345785d8a0000808203e880801cee7e01dc62f69a12c3510c6d64de04ee6346d84b6a017f3e786c7d87f963e75d8cc91fa983cd6d9cf55fff80d73bd26cd333b0f098acc1e58edb1fd484ad731bff" } ], - "expectedNewRoot": "0x7419a71f9923fca08275c77c2603de4ecec62f37f4c1d00229b38e17424320ba", + "expectedNewRoot": "0x5fc97a9a6ea9918f4b26e2dd52b27a688621cd4d2ff5c624c2df0cd1986d3b41", "expectedNewLeafs": { "0x617b3a3528f9cdd6630fd3301b9c8911f7bf063d": { "balance": "99900000000000000000", diff --git a/test/zkevm-db.test.js b/test/zkevm-db.test.js index 999581c4..9d445799 100644 --- a/test/zkevm-db.test.js +++ b/test/zkevm-db.test.js @@ -46,7 +46,7 @@ describe('ZkEVMDB', function () { const genesis = []; const db = new MemDB(F); const chainID = 1000; - const forkID = 1; + const forkID = 8; // create a zkEVMDB and build a batch const zkEVMDB = await ZkEVMDB.newZkEVM( From 831bf9331574b969b79241d993084077c1df1e46 Mon Sep 17 00:00:00 2001 From: Ignasi Date: Mon, 19 Feb 2024 17:47:46 +0100 Subject: [PATCH 2/4] Update vcounters for elderberry --- src/processor.js | 14 ++++----- src/virtual-counters-manager.js | 55 ++++++++++++++++++++------------- test/block-info.test.js | 2 +- 3 files changed, 41 insertions(+), 30 deletions(-) diff --git a/src/processor.js b/src/processor.js index 11630079..857b6252 100644 --- a/src/processor.js +++ b/src/processor.js @@ -366,6 +366,12 @@ module.exports = class Processor { // Compute rlp parsing counters for (let i = 0; i < this.decodedTxs.length; i++) { if (this.decodedTxs[i].tx.type === Constants.TX_CHANGE_L2_BLOCK) { + // If is forced and it contains a changeL2Block, invalid batch + if (this.isForced) { + this.isInvalid = true; + + return; + } this.vcm.computeFunctionCounters('decodeChangeL2BlockTx'); } else { const txDataLen = this.decodedTxs[i].tx.data ? (this.decodedTxs[i].tx.data.length - 2) / 2 : 0; @@ -402,6 +408,7 @@ module.exports = class Processor { return; } } + const currentTx = currentDecodedTx.tx; // If it is a forced batch, we create a changeL2Block at the beginning if (i === 0 && this.isForced) { @@ -415,14 +422,7 @@ module.exports = class Processor { if (currentDecodedTx.isInvalid) { continue; } else { - const currentTx = currentDecodedTx.tx; if (currentTx.type === Constants.TX_CHANGE_L2_BLOCK) { - // If it is forced batch, invalidate - if (this.isForced) { - this.isInvalid = true; - - return; - } // Final function call that saves internal DB storage keys const err = await this._processChangeL2BlockTx(currentTx); if (err) { diff --git a/src/virtual-counters-manager.js b/src/virtual-counters-manager.js index ebde9d36..c2de1442 100644 --- a/src/virtual-counters-manager.js +++ b/src/virtual-counters-manager.js @@ -18,6 +18,7 @@ const { expectedModExpCounters } = require('./virtual-counters-manager-utils'); const FPEC = Scalar.e('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F'); const FNEC = Scalar.e('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141'); const FNEC_MINUS_ONE = Scalar.sub(FNEC, Scalar.e(1)); +const spentCountersByFunction = {}; module.exports = class VirtualCountersManager { /** @@ -130,6 +131,14 @@ module.exports = class VirtualCountersManager { }); this._verbose(spentCounters); this.currentCountersSnapshot = spentCounters; + // Fill counters consumption by function + if (!spentCountersByFunction[this.calledFunc]) { + spentCountersByFunction[this.calledFunc] = spentCounters; + } else { + Object.keys(this.currentCountersSnapshot).forEach((counter) => { + spentCountersByFunction[this.calledFunc][counter] = spentCountersByFunction[this.calledFunc][counter] + spentCounters[counter]; + }); + } return spentCounters; } @@ -939,9 +948,10 @@ module.exports = class VirtualCountersManager { _checkJumpDest(input) { this._checkInput(input, ['isCreate', 'isDeploy']); this._reduceCounters(10, 'S'); + this._reduceCounters(1, 'B'); if (input.isCreate) { - this._reduceCounters(1, 'B'); if (input.isDeploy) { + this._reduceCounters(1, 'B'); this._mLoadX(); } } @@ -980,7 +990,7 @@ module.exports = class VirtualCountersManager { _opLog(input) { this._opcode(input); this._checkInput(input, ['inputSize']); - this._reduceCounters(30 + 8 * 4, 'S'); // Count steps as if topics is 4 + this._reduceCounters(34 + 7 * 4, 'S'); // Count steps as if topics is 4 this._saveMem({ length: input.inputSize }); this._mulArith(); this._divArith(); @@ -1134,9 +1144,8 @@ module.exports = class VirtualCountersManager { _opPush(input) { this._opcode(input); this._checkInput(input, ['pushBytes', 'isCreate', 'isDeploy']); - this._reduceCounters(4, 'S'); + this._reduceCounters(2, 'S'); if (input.isCreate || input.isDeploy) { - this._reduceCounters(1, 'B'); if (input.isCreate) { this._reduceCounters(20, 'S'); this._mLoadX(); @@ -1145,7 +1154,6 @@ module.exports = class VirtualCountersManager { this._reduceCounters(10, 'S'); for (let i = 0; i < input.pushBytes; i++) { this._reduceCounters(10, 'S'); - this._SHLarith(); } } } else { @@ -1392,23 +1400,25 @@ module.exports = class VirtualCountersManager { _readPush(input) { this._checkInput(input, ['pushBytes']); - this._reduceCounters(15, 'S'); - this._reduceCounters(1, 'B'); - - const numBlocks = Math.ceil(input.pushBytes / 4); - const leftBytes = input.pushBytes % 4; - - for (let i = 0; i <= numBlocks; i++) { - this._reduceCounters(20, 'S'); - this._reduceCounters(1, 'B'); - for (let j = i - 1; j > 0; j--) { - this._reduceCounters(8, 'S'); - } - } - - for (let i = 0; i < leftBytes; i++) { - this._reduceCounters(40, 'S'); - this._reduceCounters(4, 'B'); + switch (input.pushBytes) { + case 1: + this._reduceCounters(2, 'S'); + break; + case 2: + this._reduceCounters(4, 'S'); + break; + case 3: + this._reduceCounters(5, 'S'); + break; + case 4: + this._reduceCounters(6, 'S'); + break; + case 32: + this._reduceCounters(45, 'S'); + break; + default: + this._reduceCounters(6 + input.pushBytes * 2, 'S'); // approx value, is a bit less + break; } } @@ -1648,6 +1658,7 @@ module.exports = class VirtualCountersManager { // MCP + 100S + divArith + batchL2DataLength/136K + K this._reduceCounters(100, 'S'); this._reduceCounters(MCP, 'P'); + this._reduceCounters(2, 'B'); this._divArith(); this._reduceCounters(Math.ceil((batchL2DataLength + 1) / 136), 'K'); } diff --git a/test/block-info.test.js b/test/block-info.test.js index 1cc76ffc..3eb173ee 100644 --- a/test/block-info.test.js +++ b/test/block-info.test.js @@ -455,8 +455,8 @@ describe('Block info tests', function () { logIndex += logs.length; // Consolidate block blockInfoRoot = await setBlockGasUsed(smt, blockInfoRoot, cumulativeGasUsed); - expect(smtUtils.h4toString(blockInfoRoot)).to.be.equal(blockInfoTree[i].finalBlockInfoRoot); } + expect(smtUtils.h4toString(blockInfoRoot)).to.be.equal(blockInfoTree[i].finalBlockInfoRoot); } }); }); From e202701b4722a472a399162b8dd3ca904436703d Mon Sep 17 00:00:00 2001 From: Lua Date: Wed, 21 Feb 2024 17:21:51 +0100 Subject: [PATCH 3/4] update vm monorepo --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 54d30b63..1e022646 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "@ethereumjs/block": "^3.6.2", "@ethereumjs/tx": "^3.4.0", "@polygon-hermez/common": "2.6.4", - "@polygon-hermez/vm": "6.0.11", + "@polygon-hermez/vm": "6.0.12", "ethereumjs-util": "^7.1.4", "ethers": "^5.5.4", "ffjavascript": "^0.2.55", From 6de80b80da0cbbe7ac06996432e87826ce9e3fe5 Mon Sep 17 00:00:00 2001 From: krlosMata Date: Thu, 29 Feb 2024 22:49:31 +0100 Subject: [PATCH 4/4] eslint fix --- src/virtual-counters-manager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/virtual-counters-manager.js b/src/virtual-counters-manager.js index c2de1442..143c86e1 100644 --- a/src/virtual-counters-manager.js +++ b/src/virtual-counters-manager.js @@ -136,7 +136,7 @@ module.exports = class VirtualCountersManager { spentCountersByFunction[this.calledFunc] = spentCounters; } else { Object.keys(this.currentCountersSnapshot).forEach((counter) => { - spentCountersByFunction[this.calledFunc][counter] = spentCountersByFunction[this.calledFunc][counter] + spentCounters[counter]; + spentCountersByFunction[this.calledFunc][counter] += spentCounters[counter]; }); }