Skip to content

Commit

Permalink
Add effectiver percentage at l2 tx hash
Browse files Browse the repository at this point in the history
  • Loading branch information
ignasirv committed Nov 27, 2023
1 parent 13a353c commit dc1626f
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 60 deletions.
4 changes: 2 additions & 2 deletions src/processor-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,11 @@ function computeEffectiveGasPrice(gasPrice, effectivePercentage) {

/**
* Computes the L2 transaction hash from a transaction
* @param {Object} tx tx to compute l2 hash, must have nonce, gasPrice, gasLimit, to, value, data, from in hex string
* @param {Object} tx tx to compute l2 hash, must have nonce, gasPrice, gasLimit, to, value, data, from, effectivePercentage in hex string
* @returns computed l2 tx hash
*/
async function computeL2TxHash(tx) {
const txHash = await smtUtils.linearPoseidon(`0x${tx.nonce.slice(2)}${tx.gasPrice.slice(2)}${tx.gasLimit.slice(2)}${tx.to.slice(2)}${tx.value.slice(2)}${tx.data.slice(2)}${tx.from.slice(2)}`);
const txHash = await smtUtils.linearPoseidon(`0x${tx.nonce.slice(2)}${tx.gasPrice.slice(2)}${tx.gasLimit.slice(2)}${tx.to.slice(2)}${tx.value.slice(2)}${tx.data.slice(2)}${tx.from.slice(2)}${tx.effectivePercentage.slice(2)}`);

return txHash;
}
Expand Down
34 changes: 17 additions & 17 deletions test/helpers/test-vectors/block-info/block-info-batches.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
"rawTx": "0xf88a06843b9aca00830186a0941275fbb540c8efc58b812ba83b0d0b8b9917ae9880a4e9413d3800000000000000000000000000000000000000000000000000000000000000008207f4a098f56115cad149a409a86e7610863248799a31d80e87d46582d08a3c0933a40aa025455a74fa3ca2ada0bf39dac88a172d032583bfec15061f39184ef9f7012677"
}
],
"expectedNewRoot": "0xd7849584cc5b895a819dfc4e437050816843f12c6211961a3d5e1601d0d9fda0",
"expectedNewRoot": "0x1ea30a0faa282a8a776980b56e17a5a6bdb132695718e86c008f3e728e3e2dfb",
"expectedNewLeafs": {
"0x0000000000000000000000000000000000000000": {
"balance": "0",
Expand Down Expand Up @@ -208,7 +208,7 @@
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x01",
"0x0000000000000000000000000000000000000000000000000000000000000002": "0x01",
"0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0xf5c30bbb2b8a1bdd2b881cc575b2acbd13578c7cd64250fe8b6770fa95f915b3",
"0x0000000000000000000000000000000000000000000000000000000000000003": "0x45879a14835461f24e5d93a50a0a6419244402f363eabe35cf03901774dc179d"
"0x0000000000000000000000000000000000000000000000000000000000000003": "0x61bcc37f71c94afe08e4ebba4d622db1ba762991f025d1d8443e378975373b25"
}
}
},
Expand Down Expand Up @@ -347,17 +347,17 @@
"rawTx": "0xf88a0d843b9aca00830186a0941275fbb540c8efc58b812ba83b0d0b8b9917ae9880a4e9413d3800000000000000000000000000000000000000000000000000000000000000018207f3a068ad61295298051fac15519066926aad57ed5af83b351e586a0fbe70006c4829a05695cc59543fd10d4af41a8a266aef5efd2d691abc356fc679c66e2545fd9ef6"
}
],
"expectedNewRoot": "0xcf8f6f329ca92e74d6f77ce7e09342b04d30fd492a7dabb941ef79883a20d430",
"expectedNewRoot": "0xf606600981e9fbaeae9e82bba71c349851c1c73d7d196062ecc3919ef39538ef",
"expectedNewLeafs": {
"0x000000000000000000000000000000005ca1ab1e": {
"balance": "0",
"nonce": "0",
"storage": {
"0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0xf5c30bbb2b8a1bdd2b881cc575b2acbd13578c7cd64250fe8b6770fa95f915b3",
"0xcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f": "0xd7849584cc5b895a819dfc4e437050816843f12c6211961a3d5e1601d0d9fda0",
"0xcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f": "0x1ea30a0faa282a8a776980b56e17a5a6bdb132695718e86c008f3e728e3e2dfb",
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x02",
"0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af70",
"0x0000000000000000000000000000000000000000000000000000000000000003": "0xc4ab186e18fdd87db8971029c0fd5dac9f4a2e2d40bcae9a4c7306be5457f404"
"0x0000000000000000000000000000000000000000000000000000000000000003": "0xaa2f714e522bd5ca095f0c2607be65bca6e26997616e8414b02f2d7f15d916ee"
}
},
"0x4d5cf5032b2a844602278b01199ed191a86c93ff": {
Expand All @@ -373,7 +373,7 @@
"0x0000000000000000000000000000000000000000000000000000000000000003": "0x02",
"0x0000000000000000000000000000000000000000000000000000000000000005": "0xffffffff",
"0x0000000000000000000000000000000000000000000000000000000000000006": "0x03e8",
"0x0000000000000000000000000000000000000000000000000000000000000001": "0xd7849584cc5b895a819dfc4e437050816843f12c6211961a3d5e1601d0d9fda0"
"0x0000000000000000000000000000000000000000000000000000000000000001": "0x1ea30a0faa282a8a776980b56e17a5a6bdb132695718e86c008f3e728e3e2dfb"
}
},
"0x617b3a3528f9cdd6630fd3301b9c8911f7bf063d": {
Expand Down Expand Up @@ -410,18 +410,18 @@
"customRawTx": "0x0b0000000100000000"
}
],
"expectedNewRoot": "0xf30a9af945fcf96825066607444c0a3c45498112884060b084cdeef87129c75c",
"expectedNewRoot": "0x670f25d4b65fe8a89462957f38b071bbf9151e27fcb33703e67c61acea3f8b9d",
"expectedNewLeafs": {
"0x000000000000000000000000000000005ca1ab1e": {
"balance": "0",
"nonce": "0",
"storage": {
"0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0xf5c30bbb2b8a1bdd2b881cc575b2acbd13578c7cd64250fe8b6770fa95f915b3",
"0xcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f": "0xd7849584cc5b895a819dfc4e437050816843f12c6211961a3d5e1601d0d9fda0",
"0xcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f": "0x1ea30a0faa282a8a776980b56e17a5a6bdb132695718e86c008f3e728e3e2dfb",
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x03",
"0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af71",
"0x0000000000000000000000000000000000000000000000000000000000000003": "0xb6978509a958b6c7e0deeba5e98a5c78868190f1eafe89ba3f3a9859b7f37938",
"0xd9d16d34ffb15ba3a3d852f0d403e2ce1d691fb54de27ac87cd2f993f3ec330f": "0xcf8f6f329ca92e74d6f77ce7e09342b04d30fd492a7dabb941ef79883a20d430"
"0x0000000000000000000000000000000000000000000000000000000000000003": "0xffd9cbe85b79874f62772b854de2c2441f2ab87ebe7c7812c74d17595775b4c5",
"0xd9d16d34ffb15ba3a3d852f0d403e2ce1d691fb54de27ac87cd2f993f3ec330f": "0xf606600981e9fbaeae9e82bba71c349851c1c73d7d196062ecc3919ef39538ef"
}
},
"0x0000000000000000000000000000000000000000": {
Expand All @@ -446,7 +446,7 @@
"0x0000000000000000000000000000000000000000000000000000000000000003": "0x02",
"0x0000000000000000000000000000000000000000000000000000000000000005": "0xffffffff",
"0x0000000000000000000000000000000000000000000000000000000000000006": "0x03e8",
"0x0000000000000000000000000000000000000000000000000000000000000001": "0xd7849584cc5b895a819dfc4e437050816843f12c6211961a3d5e1601d0d9fda0"
"0x0000000000000000000000000000000000000000000000000000000000000001": "0x1ea30a0faa282a8a776980b56e17a5a6bdb132695718e86c008f3e728e3e2dfb"
}
},
"0x4d5cf5032b2a844602278b01199ed191a86c93ff": {
Expand Down Expand Up @@ -476,19 +476,19 @@
"customRawTx": "0x0b0000000100000000"
}
],
"expectedNewRoot": "0xe20481a4a3846e9845879c49b1b772f274eb62bf79862dbdc62e550667932e2e",
"expectedNewRoot": "0x91d3f0d5e1ec9b99488af8802ff2196baf82f199575efe2856fd3a7fdd945238",
"expectedNewLeafs": {
"0x000000000000000000000000000000005ca1ab1e": {
"balance": "0",
"nonce": "0",
"storage": {
"0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0xf5c30bbb2b8a1bdd2b881cc575b2acbd13578c7cd64250fe8b6770fa95f915b3",
"0xcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f": "0xd7849584cc5b895a819dfc4e437050816843f12c6211961a3d5e1601d0d9fda0",
"0xcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f": "0x1ea30a0faa282a8a776980b56e17a5a6bdb132695718e86c008f3e728e3e2dfb",
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x04",
"0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af72",
"0x0000000000000000000000000000000000000000000000000000000000000003": "0x2a77ee2d143e4ad7bcbec9c30cb0920622ecfcd8a481002a7ea80b0e29111bed",
"0xd9d16d34ffb15ba3a3d852f0d403e2ce1d691fb54de27ac87cd2f993f3ec330f": "0xcf8f6f329ca92e74d6f77ce7e09342b04d30fd492a7dabb941ef79883a20d430",
"0x7dfe757ecd65cbd7922a9c0161e935dd7fdbcc0e999689c7d31633896b1fc60b": "0xf30a9af945fcf96825066607444c0a3c45498112884060b084cdeef87129c75c"
"0x0000000000000000000000000000000000000000000000000000000000000003": "0x13f4a6d84fc33929de5f39814d3a69686b5f890b6e6467e64789339c4df870ad",
"0xd9d16d34ffb15ba3a3d852f0d403e2ce1d691fb54de27ac87cd2f993f3ec330f": "0xf606600981e9fbaeae9e82bba71c349851c1c73d7d196062ecc3919ef39538ef",
"0x7dfe757ecd65cbd7922a9c0161e935dd7fdbcc0e999689c7d31633896b1fc60b": "0x670f25d4b65fe8a89462957f38b071bbf9151e27fcb33703e67c61acea3f8b9d"
}
},
"0x0000000000000000000000000000000000000000": {
Expand All @@ -513,7 +513,7 @@
"0x0000000000000000000000000000000000000000000000000000000000000003": "0x02",
"0x0000000000000000000000000000000000000000000000000000000000000005": "0xffffffff",
"0x0000000000000000000000000000000000000000000000000000000000000006": "0x03e8",
"0x0000000000000000000000000000000000000000000000000000000000000001": "0xd7849584cc5b895a819dfc4e437050816843f12c6211961a3d5e1601d0d9fda0"
"0x0000000000000000000000000000000000000000000000000000000000000001": "0x1ea30a0faa282a8a776980b56e17a5a6bdb132695718e86c008f3e728e3e2dfb"
}
},
"0x4d5cf5032b2a844602278b01199ed191a86c93ff": {
Expand Down
4 changes: 2 additions & 2 deletions test/helpers/test-vectors/block-info/block-info.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
"rawTx": "0xf86a05843b9aca00830186a0941275fbb540c8efc58b812ba83b0d0b8b9917ae9880843408e4708207f4a0e255f868a61169a2330cb539671e1a66ee846bc06cc888ea8fcd7ae51cdc6294a00c6dec27e6f756dd84923bcebb1f85db125299c0b622eaa8d5722cb3dace239d"
}
],
"expectedNewRoot": "0x5ffda036fa0cb1c3a79e54e35660742a45039d96fbe54e5592e87fb759e835b4",
"expectedNewRoot": "0x37f738b77b704136cf09610e12dcfbb8b321d7239f7c7ae625c4d7bcff4f3d19",
"expectedNewLeafs": {
"0x0000000000000000000000000000000000000000": {
"balance": "0",
Expand Down Expand Up @@ -199,7 +199,7 @@
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x01",
"0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af6f",
"0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0xf5c30bbb2b8a1bdd2b881cc575b2acbd13578c7cd64250fe8b6770fa95f915b3",
"0x0000000000000000000000000000000000000000000000000000000000000003": "0xd37530ff32b8275740d24853ac75447ee7aa90044ed4fcab5903670c705a9046"
"0x0000000000000000000000000000000000000000000000000000000000000003": "0xdfce875e2b6e7c257682ab7d3951fd20654c51eb57324b8e7d1dbfedb877cbe9"
},
"hashBytecode": "0x0000000000000000000000000000000000000000000000000000000000000000",
"bytecodeLength": 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
"rawTx": "0xf9014f0480831e848094cfa773cc48fbde3ca4d24eecb19d224d697026b2880de0b6b3a7640000b8e4cd5865790000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c949254d682d8c9ad5682521675b8f43b102aec40000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000008207f3a022849420ce892ab01b2aab19a51c3fac9169b5a26c9789d9ee43041b1214048da05962de13a880e2b38309e41e7255e43bb5c5937dbb8270a7f6d990344b61a84e"
}
],
"expectedNewRoot": "0x4e4da4638c875f88800ed6f23d735e42503c9de735d82a48a2f58d65a0babd61",
"expectedNewRoot": "0x8cd26cf88420b79d07551400f38c79efa8567084c6b7fa77eb1cf649b8002557",
"expectedNewLeafs": {
"0xa40d5f56745a118d0906a34e69aec8c0db1cb8fa": {
"balance": "0",
Expand Down Expand Up @@ -345,7 +345,7 @@
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x01",
"0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af6f",
"0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0x24c02821c526d801fd1d6d99afd57fdf862f4d3e2109fc36eb85bd5e2f5c508e",
"0x0000000000000000000000000000000000000000000000000000000000000003": "0xae1fc5b314a605707c51ed5e727f8590a055d34bff113fbe0c4d081160032a3b"
"0x0000000000000000000000000000000000000000000000000000000000000003": "0x692c1af4c4e6856ac0d01c3f473d3a05a2cebedcb904df30b84c4872343409b6"
},
"hashBytecode": "0x0000000000000000000000000000000000000000000000000000000000000000",
"bytecodeLength": 0
Expand Down
10 changes: 5 additions & 5 deletions test/helpers/test-vectors/processor/state-transition-etrog.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
"customRawTx": "0x0b0000000100000002"
}
],
"expectedNewRoot": "0xfe1c484e849d892b043c9cba9a199a3a56e23f4322bfefdfea05b8ac71c4b862",
"expectedNewRoot": "0xd3b1689afbcde4c79ecdc35c67620a26553ef8893f9da215fe4259872e0a5031",
"expectedNewLeafs": {
"0xa40d5f56745a118d0906a34e69aec8c0db1cb8fa": {
"balance": "0",
Expand Down Expand Up @@ -162,8 +162,8 @@
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x02",
"0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af6f",
"0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0x4a9bfcb163ec91c5beb22e6aca41592433092c8c7821b01d37fd0de483f9265d",
"0x0000000000000000000000000000000000000000000000000000000000000003": "0x2a62e6550b06cea0af16998512f782eecdf2a59b802f67ef9a8d3945e28bb492",
"0xcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f": "0xb92c2163b0258c3e7de277101ae018c858da32daaf8f86341db03f34874ed2cb"
"0x0000000000000000000000000000000000000000000000000000000000000003": "0x1043c603b23708bdad6237e0331db97da2bebe0e0a2a473ea376f5560686eb02",
"0xcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f": "0xb49262182b5fda0f05d0355aff2969455d2e94dcff11db4a97a4d202f6b9409d"
},
"hashBytecode": "0x0000000000000000000000000000000000000000000000000000000000000000",
"bytecodeLength": 0
Expand Down Expand Up @@ -215,7 +215,7 @@
"customRawTx": "0xee80843b9aca00830186a0944d5cf5032b2a844602278b01199ed191a86c93ff88016345785d8a0000808203e880801cee7e01dc62f69a12c3510c6d64de04ee6346d84b6a017f3e786c7d87f963e75d8cc91fa983cd6d9cf55fff80d73bd26cd333b0f098acc1e58edb1fd484ad731bff"
}
],
"expectedNewRoot": "0x3555cfdd00a4c3fdc1e3208cd497fa2c71b75fdd1ddf02598a6bfaf383c4676f",
"expectedNewRoot": "0xff2ca64a7495cddb0a456164dae64a88cec2f7bb0cfed50d68d7cb8362923990",
"expectedNewLeafs": {
"0xa40d5f56745a118d0906a34e69aec8c0db1cb8fa": {
"balance": "0",
Expand Down Expand Up @@ -247,7 +247,7 @@
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x01",
"0x0000000000000000000000000000000000000000000000000000000000000002": "0x73e6af6f",
"0xa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49": "0x4a9bfcb163ec91c5beb22e6aca41592433092c8c7821b01d37fd0de483f9265d",
"0x0000000000000000000000000000000000000000000000000000000000000003": "0x59be1ffe20a12afb5385869afbc1d0e44b692fad07a5c02f809970b8c7f95f3d"
"0x0000000000000000000000000000000000000000000000000000000000000003": "0xb56675e00cbd4fd72add94bcbe129d25f27804b8069202834b3816742550549a"
},
"hashBytecode": "0x0000000000000000000000000000000000000000000000000000000000000000",
"bytecodeLength": 0
Expand Down
Loading

0 comments on commit dc1626f

Please sign in to comment.