Skip to content

Commit b76b832

Browse files
authored
fix: use normal getter for chain tree (#2060)
# What ❔ use normal getter for chain tree ## Why ❔ auto-generated public mapping getter doesn't return struct's arrays ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated.
1 parent 84e5c59 commit b76b832

File tree

4 files changed

+74
-51
lines changed

4 files changed

+74
-51
lines changed

AllContractsHashes.json

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,13 +1391,13 @@
13911391
},
13921392
{
13931393
"contractName": "l1-contracts/L1MessageRoot",
1394-
"zkBytecodeHash": "0x0100076d6d98e60b357aa4ddd563bb52e2f8a3422a8a35dd502796ad0cde892b",
1394+
"zkBytecodeHash": "0x01000799957b9433031fec52f922a99032367bb8efe057e4a3c0b100cd784332",
13951395
"zkBytecodePath": "/l1-contracts/zkout/L1MessageRoot.sol/L1MessageRoot.json",
1396-
"evmBytecodeHash": "0x8fbe59ed5773b91b87e67d4c77efcbcf8a958df589c72457105b406a85a8ce55",
1396+
"evmBytecodeHash": "0x912bc4317cb26e14107c632c5d30747092daf06d38dd69741089848a0ca2da1c",
13971397
"evmBytecodePath": "/l1-contracts/out/L1MessageRoot.sol/L1MessageRoot.json",
1398-
"evmDeployedBytecodeHash": "0x4d070f0a2dfcd696b97e01895debd5bd12f3d72ce693a999c54817de027375fe",
1399-
"evmDeployedBytecodeBlakeHash": "0x8bc1cadd7734200d242ff1f660d938f7dbdb6f9c57ccb2b090165b7b93f4a426",
1400-
"evmDeployedBytecodeLength": 14762
1398+
"evmDeployedBytecodeHash": "0xb0e5073b42c3503cfcfc6131cccd79923913efb9f71510e73371459c407ef51b",
1399+
"evmDeployedBytecodeBlakeHash": "0x6bbb6378c042542635f90979521e5bffd78ae36979877f256505f4c803e25374",
1400+
"evmDeployedBytecodeLength": 15110
14011401
},
14021402
{
14031403
"contractName": "l1-contracts/L1Messenger",
@@ -1501,12 +1501,12 @@
15011501
},
15021502
{
15031503
"contractName": "l1-contracts/L2ComplexUpgrader",
1504-
"zkBytecodeHash": "0x0100026d83c8757ff33b98c3d561c1cdc810d896726714fe775a1502f485e1f1",
1504+
"zkBytecodeHash": "0x0100026d6d25d4617b48a10145c7f78499af6673de4d07cc4c2594c9b71f774e",
15051505
"zkBytecodePath": "/l1-contracts/zkout/L2ComplexUpgrader.sol/L2ComplexUpgrader.json",
1506-
"evmBytecodeHash": "0x0a41eaad051fa84948a774dff4159b1aa9776c693bafcefbb036df9a709c9d1c",
1506+
"evmBytecodeHash": "0x04103f3faeca02a257fc803cf6e3ad3aa7e85b8a414e744c07a197ea37e119c4",
15071507
"evmBytecodePath": "/l1-contracts/out/L2ComplexUpgrader.sol/L2ComplexUpgrader.json",
1508-
"evmDeployedBytecodeHash": "0x36acd3996ce455954407fa436cfb9eae465017c9265e8d5994d995b35743b5b7",
1509-
"evmDeployedBytecodeBlakeHash": "0x21423c7849d05645e65f234bca8bd778672805f416e8be4d333006f14e089bfe",
1508+
"evmDeployedBytecodeHash": "0x3f78185fc5ad662da118cd034202f2b0d0ac8ac8fdff8e2ac1e68d4dcbcacf2c",
1509+
"evmDeployedBytecodeBlakeHash": "0x9edda2070fae32496021e29d40828fdac49cc9acea97c12b679e675d0ddef1a1",
15101510
"evmDeployedBytecodeLength": 6240
15111511
},
15121512
{
@@ -1521,22 +1521,22 @@
15211521
},
15221522
{
15231523
"contractName": "l1-contracts/L2GenesisForceDeploymentsHelper",
1524-
"zkBytecodeHash": "0x010000076399c534e80b0008a1de8e991ec1a391fd337929778cdb746bae981d",
1524+
"zkBytecodeHash": "0x01000007e019b832ec2823e75c065755042f096e5a94fce68beaf4ba939271ae",
15251525
"zkBytecodePath": "/l1-contracts/zkout/L2GenesisForceDeploymentsHelper.sol/L2GenesisForceDeploymentsHelper.json",
1526-
"evmBytecodeHash": "0x41d61ba3c472fcfe2cfe1ea8477bc76837ee994b832ee6cb56b1c32480bdf931",
1526+
"evmBytecodeHash": "0xa2073dbac3fa20a43463cbd59b973e0e58fefa135014544282b39f1832a45c1b",
15271527
"evmBytecodePath": "/l1-contracts/out/L2GenesisForceDeploymentsHelper.sol/L2GenesisForceDeploymentsHelper.json",
1528-
"evmDeployedBytecodeHash": "0xeae84dece363c50f151509c9c92c487f988102f6130aae4ec5c31b9358d80885",
1529-
"evmDeployedBytecodeBlakeHash": "0x2f9845ef18bd1376ec7aab1bee6c7fb58e86a545bdab8cd09a9792ba8bc04ab0",
1528+
"evmDeployedBytecodeHash": "0x82537cb72b0f2ae1556364a5ce39a23dddc0c0a0e54738e529e4eb7cb00d984e",
1529+
"evmDeployedBytecodeBlakeHash": "0x5ce63d5ebadd1860f2995ddcfb263d0220737985a22c8cdfe9d8f3f222d94747",
15301530
"evmDeployedBytecodeLength": 85
15311531
},
15321532
{
15331533
"contractName": "l1-contracts/L2GenesisUpgrade",
1534-
"zkBytecodeHash": "0x010005f30209c885d324e5a84ad811bd5f20692749169d94aa0f54b9a3707f06",
1534+
"zkBytecodeHash": "0x010005f3ebaab584b253a14fe3da299bffa0adf4b471cf8577416779220794ef",
15351535
"zkBytecodePath": "/l1-contracts/zkout/L2GenesisUpgrade.sol/L2GenesisUpgrade.json",
1536-
"evmBytecodeHash": "0xafe39afa60c7dc23c0d4b732b8d6bd0ef0adf47fdbd031a2366de70487cf9f71",
1536+
"evmBytecodeHash": "0x96743453c0a7c956cac3a746061edcf06a5fd6da7d6f87efef0ed86adcfa24fc",
15371537
"evmBytecodePath": "/l1-contracts/out/L2GenesisUpgrade.sol/L2GenesisUpgrade.json",
1538-
"evmDeployedBytecodeHash": "0x0034bdad7cfe66394344ee136e42adf762e7222042d45baebb688e5ec06d027a",
1539-
"evmDeployedBytecodeBlakeHash": "0x261ef9e794410c79bc6ea227bda9e2d958a418a954252da9d3a3111a4a7bc3c0",
1538+
"evmDeployedBytecodeHash": "0x7494166b5c59378cb3792b354e2900711fe5e801334b17191436f2e09d8f2111",
1539+
"evmDeployedBytecodeBlakeHash": "0xf4c457e9467e5949190f6ef7661d5fe6933963d8f21df9190c77916f87ebfba0",
15401540
"evmDeployedBytecodeLength": 16713
15411541
},
15421542
{
@@ -1551,13 +1551,13 @@
15511551
},
15521552
{
15531553
"contractName": "l1-contracts/L2MessageRoot",
1554-
"zkBytecodeHash": "0x010005c519b2cd2bd3aa391ae84a658ea084859409b08a4db8dc53b64abb3f7f",
1554+
"zkBytecodeHash": "0x010005f36a29b2b86aab298864dc07a402557cf24f88949f3432aa33a07e72bf",
15551555
"zkBytecodePath": "/l1-contracts/zkout/L2MessageRoot.sol/L2MessageRoot.json",
1556-
"evmBytecodeHash": "0xf97cbf96af7bf69771ca2b8fda3675490bb825bac3c38382d7cd90daad1ddcec",
1556+
"evmBytecodeHash": "0xa6f4111b158d95c1bfc114b4335085c23c9f559d474429e495823eb867331207",
15571557
"evmBytecodePath": "/l1-contracts/out/L2MessageRoot.sol/L2MessageRoot.json",
1558-
"evmDeployedBytecodeHash": "0x6cdd6e74fce7e5e9ecf5abd45e4d11f5f72855d9338a6ee8d9719a73d7b764d5",
1559-
"evmDeployedBytecodeBlakeHash": "0x3bc3b6bd6b6c6acc4fe9f039f9ea6f7122fba81f0d98295c562c9a950980bffd",
1560-
"evmDeployedBytecodeLength": 11919
1558+
"evmDeployedBytecodeHash": "0x6e56990939716c8d3f8ada5ad4fbac6dcc1f135cdace946180d88f6ebeff3296",
1559+
"evmDeployedBytecodeBlakeHash": "0xe0667ed2ff28d58a56ca3c3c4dced36e36808096403568a52ecebedd895f8b3d",
1560+
"evmDeployedBytecodeLength": 12325
15611561
},
15621562
{
15631563
"contractName": "l1-contracts/L2MessageVerification",
@@ -1611,12 +1611,12 @@
16111611
},
16121612
{
16131613
"contractName": "l1-contracts/L2V30TestnetSystemProxiesUpgrade",
1614-
"zkBytecodeHash": "0x010002b12bec41f806b53d9913cb9a696599e2e6284d06014728fce47519de6a",
1614+
"zkBytecodeHash": "0x010002b13c2a709da30284d0922f17a38067ad1a57005bd9b9c755e12d081172",
16151615
"zkBytecodePath": "/l1-contracts/zkout/L2V30TestnetSystemProxiesUpgrade.sol/L2V30TestnetSystemProxiesUpgrade.json",
1616-
"evmBytecodeHash": "0x1d5b89e8063f913fcfce9f9dde334936aa56da523bad410deeb9de9d31d79f15",
1616+
"evmBytecodeHash": "0xed3e06d4c0733430e68bab8536d5a30c3a8752bcd6a39e4571f4bdac6c07ddf9",
16171617
"evmBytecodePath": "/l1-contracts/out/L2V30TestnetSystemProxiesUpgrade.sol/L2V30TestnetSystemProxiesUpgrade.json",
1618-
"evmDeployedBytecodeHash": "0xe0ca05063295186388ce78e3f77ef6ab2e067271ac1f732183f6925c9c0685f9",
1619-
"evmDeployedBytecodeBlakeHash": "0x0d3a9100883cbf175c704da59c1c5597442c7bef35f88c83d565e1fba184397f",
1618+
"evmDeployedBytecodeHash": "0x82dd3a03684ed734be60c4456dde12f623de48bc847c5a0cba56693a73d358c0",
1619+
"evmDeployedBytecodeBlakeHash": "0x4de819596be6ce148209f1d2f3c1ae2ce93583339c454c4b2c1afe227a7daa0c",
16201620
"evmDeployedBytecodeLength": 4516
16211621
},
16221622
{

l1-contracts/contracts/core/message-root/MessageRootBase.sol

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ abstract contract MessageRootBase is IMessageRootBase, ReentrancyGuard, Initiali
6767
/// @dev The incremental merkle tree storing the chain message roots.
6868
/// @dev On L1, these are empty leaves and are populated only during the addition of the chain
6969
/// are not updated thereafter.
70-
mapping(uint256 chainId => DynamicIncrementalMerkle.Bytes32PushTree tree) public chainTree;
70+
mapping(uint256 chainId => DynamicIncrementalMerkle.Bytes32PushTree tree) internal chainTree;
7171

7272
/// @notice The mapping from block number to the global message root.
7373
/// @dev Each block might have multiple txs that change the historical root. You can safely use the final root in the block,
@@ -347,4 +347,10 @@ abstract contract MessageRootBase is IMessageRootBase, ReentrancyGuard, Initiali
347347
uint256 index = chainIndex[_chainId];
348348
return sharedTree.merklePath(index);
349349
}
350+
351+
/// @dev Returns `chainTree` by chain id.
352+
/// @param _chainId Id of the chain to get tree for.
353+
function getChainTree(uint256 _chainId) external view returns (DynamicIncrementalMerkle.Bytes32PushTree memory) {
354+
return chainTree[_chainId];
355+
}
350356
}

l1-contracts/selectors

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8041,14 +8041,14 @@ L1MessageRoot
80418041
|----------+----------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
80428042
| Function | chainRegistered(uint256) | 0xb8776d4d |
80438043
|----------+----------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
8044-
| Function | chainTree(uint256) | 0x2c3addb8 |
8045-
|----------+----------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
80468044
| Function | currentChainBatchNumber(uint256) | 0xf688e003 |
80478045
|----------+----------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
80488046
| Function | getAggregatedRoot() | 0x3977d71c |
80498047
|----------+----------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
80508048
| Function | getChainRoot(uint256) | 0x1e4fba05 |
80518049
|----------+----------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
8050+
| Function | getChainTree(uint256) | 0x75ffc96a |
8051+
|----------+----------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
80528052
| Function | getMerklePathForChain(uint256) | 0x9e59a37e |
80538053
|----------+----------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
80548054
| Function | getProofData(uint256,uint256,uint256,bytes32,bytes32[]) | 0x2f67101d |
@@ -9462,14 +9462,14 @@ L2MessageRoot
94629462
|----------+----------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
94639463
| Function | chainRegistered(uint256) | 0xb8776d4d |
94649464
|----------+----------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
9465-
| Function | chainTree(uint256) | 0x2c3addb8 |
9466-
|----------+----------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
94679465
| Function | currentChainBatchNumber(uint256) | 0xf688e003 |
94689466
|----------+----------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
94699467
| Function | getAggregatedRoot() | 0x3977d71c |
94709468
|----------+----------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
94719469
| Function | getChainRoot(uint256) | 0x1e4fba05 |
94729470
|----------+----------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
9471+
| Function | getChainTree(uint256) | 0x75ffc96a |
9472+
|----------+----------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
94739473
| Function | getMerklePathForChain(uint256) | 0x9e59a37e |
94749474
|----------+----------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
94759475
| Function | getProofData(uint256,uint256,uint256,bytes32,bytes32[]) | 0x2f67101d |
@@ -10656,14 +10656,14 @@ MessageRootBase
1065610656
|----------+----------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
1065710657
| Function | chainRegistered(uint256) | 0xb8776d4d |
1065810658
|----------+----------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
10659-
| Function | chainTree(uint256) | 0x2c3addb8 |
10660-
|----------+----------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
1066110659
| Function | currentChainBatchNumber(uint256) | 0xf688e003 |
1066210660
|----------+----------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
1066310661
| Function | getAggregatedRoot() | 0x3977d71c |
1066410662
|----------+----------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
1066510663
| Function | getChainRoot(uint256) | 0x1e4fba05 |
1066610664
|----------+----------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
10665+
| Function | getChainTree(uint256) | 0x75ffc96a |
10666+
|----------+----------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
1066710667
| Function | getMerklePathForChain(uint256) | 0x9e59a37e |
1066810668
|----------+----------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------|
1066910669
| Function | getProofData(uint256,uint256,uint256,bytes32,bytes32[]) | 0x2f67101d |

l1-contracts/zkstack-out/MessageRootBase.sol/MessageRootBase.json

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@
175175
},
176176
{
177177
"type": "function",
178-
"name": "chainTree",
178+
"name": "currentChainBatchNumber",
179179
"inputs": [
180180
{
181181
"name": "chainId",
@@ -185,7 +185,7 @@
185185
],
186186
"outputs": [
187187
{
188-
"name": "_nextLeafIndex",
188+
"name": "currentChainBatchNumber",
189189
"type": "uint256",
190190
"internalType": "uint256"
191191
}
@@ -194,27 +194,27 @@
194194
},
195195
{
196196
"type": "function",
197-
"name": "currentChainBatchNumber",
198-
"inputs": [
199-
{
200-
"name": "chainId",
201-
"type": "uint256",
202-
"internalType": "uint256"
203-
}
204-
],
197+
"name": "getAggregatedRoot",
198+
"inputs": [],
205199
"outputs": [
206200
{
207-
"name": "currentChainBatchNumber",
208-
"type": "uint256",
209-
"internalType": "uint256"
201+
"name": "",
202+
"type": "bytes32",
203+
"internalType": "bytes32"
210204
}
211205
],
212206
"stateMutability": "view"
213207
},
214208
{
215209
"type": "function",
216-
"name": "getAggregatedRoot",
217-
"inputs": [],
210+
"name": "getChainRoot",
211+
"inputs": [
212+
{
213+
"name": "_chainId",
214+
"type": "uint256",
215+
"internalType": "uint256"
216+
}
217+
],
218218
"outputs": [
219219
{
220220
"name": "",
@@ -226,7 +226,7 @@
226226
},
227227
{
228228
"type": "function",
229-
"name": "getChainRoot",
229+
"name": "getChainTree",
230230
"inputs": [
231231
{
232232
"name": "_chainId",
@@ -237,8 +237,25 @@
237237
"outputs": [
238238
{
239239
"name": "",
240-
"type": "bytes32",
241-
"internalType": "bytes32"
240+
"type": "tuple",
241+
"internalType": "struct DynamicIncrementalMerkle.Bytes32PushTree",
242+
"components": [
243+
{
244+
"name": "_nextLeafIndex",
245+
"type": "uint256",
246+
"internalType": "uint256"
247+
},
248+
{
249+
"name": "_sides",
250+
"type": "bytes32[]",
251+
"internalType": "bytes32[]"
252+
},
253+
{
254+
"name": "_zeros",
255+
"type": "bytes32[]",
256+
"internalType": "bytes32[]"
257+
}
258+
]
242259
}
243260
],
244261
"stateMutability": "view"

0 commit comments

Comments
 (0)