diff --git a/contracts/v2/ShardingTable.sol b/contracts/v2/ShardingTable.sol index 77f1458e..6d5becfb 100644 --- a/contracts/v2/ShardingTable.sol +++ b/contracts/v2/ShardingTable.sol @@ -85,11 +85,15 @@ contract ShardingTableV2 is Named, Versioned, ContractStatus, Initializable { ShardingTableStructsV1.Node[] memory nodes = stsv1.getMultipleNodes(startingIdentityId, numberOfNodes); - for (uint i = 0; i < nodes.length; i++) { - if (!stsv2.nodeExists(nodes[i].identityId)) { + for (uint i; i < nodes.length; ) { + if (nodes[i].identityId != 0 && !stsv2.nodeExists(nodes[i].identityId)) { uint256 nodeHashRingPosition = uint256(profileStorage.getNodeAddress(nodes[i].identityId, 1)); _insertNode(_binarySearchForIndex(nodeHashRingPosition), nodes[i].identityId, nodeHashRingPosition); } + + unchecked { + i++; + } } } diff --git a/deploy/027_deploy_sharding_table_v2.ts b/deploy/027_deploy_sharding_table_v2.ts index b9f05055..f7227dd6 100644 --- a/deploy/027_deploy_sharding_table_v2.ts +++ b/deploy/027_deploy_sharding_table_v2.ts @@ -71,8 +71,9 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { console.log( `Migration COMPLETED iteration: ${iteration} with starting identityId: ${identityId}, number of nodes in batch: ${numberOfNodesInBatch}, ShardingTableStorage: ${shardingTableStorageAddress}`, ); - iteration += 1; + identityId = nodes[iteration * numberOfNodesInBatch]?.identityId; + iteration += 1; } hre.helpers.setParametersEncodedData.push(['ShardingTable', encodedDataArray]); diff --git a/deployments/otp_devnet_contracts.json b/deployments/otp_devnet_contracts.json index 2c7fc249..f93de13c 100644 --- a/deployments/otp_devnet_contracts.json +++ b/deployments/otp_devnet_contracts.json @@ -181,13 +181,13 @@ "version": "1.1.1" }, "ShardingTable": { - "evmAddress": "0x89822851D2A5b5256Fd19fa3b52538CAaE1f0acb", - "substrateAddress": "5EMjsczojCiGD9qj1tN9JPu3Q1NZzBq9e4fQmCRHarD5agFZ", + "evmAddress": "0x92B7d406B7A7E85Ed2A52708Ea9b5310107abb20", + "substrateAddress": "5EMjsczqaEXFUVk3yEJEfSzYevmKxnKouhEehGjygJis2RGQ", "version": "2.0.1", - "gitBranch": "release/4.2.6", - "gitCommitHash": "731dc92083f8c8e705050f9da8d8d9be649e7465", - "deploymentBlock": 4434349, - "deploymentTimestamp": 1713367726304, + "gitBranch": "fix/sharding-table-migration", + "gitCommitHash": "9c6aeb3ff3314be26cc75b10578a95cb594c7e54", + "deploymentBlock": 4439394, + "deploymentTimestamp": 1713430498176, "deployed": true }, "Staking": { @@ -230,16 +230,6 @@ "deploymentTimestamp": 1713367652683, "deployed": true }, - "ShardingTableStorage": { - "evmAddress": "0xe1B302A7cAC8241620ED0e901aA0f76529C31864", - "substrateAddress": "5EMjsd17Q8ApLnR56hxkhH6pDpBz4u83wZLk3sB4um7jutVC", - "version": "2.0.0", - "gitBranch": "release/4.2.6", - "gitCommitHash": "731dc92083f8c8e705050f9da8d8d9be649e7465", - "deploymentBlock": 4434345, - "deploymentTimestamp": 1713367674764, - "deployed": true - }, "NodeOperatorFeesStorage": { "evmAddress": "0x74982203A596469c252E12dE91571d3A2a65Ac73", "substrateAddress": "5EMjsczjY9RSBkFnCVKPrP2QvtyvKNKuCsSZ4W7S2AMVKPDr", @@ -249,6 +239,16 @@ "deploymentBlock": 4434347, "deploymentTimestamp": 1713367700400, "deployed": true + }, + "ShardingTableStorage": { + "evmAddress": "0x72837c4842601Ac4a2b30c50427Ef1798ffCDf57", + "substrateAddress": "5EMjsczj7xwtqtcMxW6csrBVKGbfdz1hqqxbgKB3QXa6sxiy", + "version": "2.0.0", + "gitBranch": "fix/sharding-table-migration", + "gitCommitHash": "9c6aeb3ff3314be26cc75b10578a95cb594c7e54", + "deploymentBlock": 4439392, + "deploymentTimestamp": 1713430472547, + "deployed": true } }, "deployedTimestamp": 1689863125519