From d8cd73d99b0491a4fd1535e7dc104517c5d82cac Mon Sep 17 00:00:00 2001 From: Uladzislau Hubar Date: Wed, 17 Apr 2024 17:42:35 +0200 Subject: [PATCH] Deployed V2 contract on Neuroweb Devnet, deployed Node Operator Fee Mechanism rework on Chiado Devnet, fixed deployment scripts --- .../017_deploy_node_operator_fees_storage.ts | 7 +- deploy/027_deploy_sharding_table_v2.ts | 19 ++++-- deployments/gnosis_chiado_dev_contracts.json | 28 ++++---- deployments/otp_devnet_contracts.json | 65 +++++++++++++------ 4 files changed, 76 insertions(+), 43 deletions(-) diff --git a/deploy/017_deploy_node_operator_fees_storage.ts b/deploy/017_deploy_node_operator_fees_storage.ts index a0a5c6a8..64204a0c 100644 --- a/deploy/017_deploy_node_operator_fees_storage.ts +++ b/deploy/017_deploy_node_operator_fees_storage.ts @@ -13,7 +13,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const nofcsAddress = hre.helpers.contractDeployments.contracts['NodeOperatorFeeChangesStorage']?.evmAddress; let nofcs = null; if (nofcsAddress) { - nofcs = await hre.ethers.getContractAt('NodeOperatorFeeChangesStorage', nofcsAddress, deployer); + const abi = hre.helpers.getAbi('LegacyNodeOperatorFeeChangesStorage'); + nofcs = await hre.ethers.getContractAt(abi, nofcsAddress, deployer); } if (nofcs !== null) { @@ -41,7 +42,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const pendingOperatorFee = await nofcs.operatorFeeChangeRequests(i); - if (pendingOperatorFee) { + if (!pendingOperatorFee.timestamp.eq(0)) { if (pendingOperatorFee.timestamp < operatorFees[0].effectiveDate) { operatorFees[0].effectiveDate = pendingOperatorFee.timestamp - 1; } @@ -55,7 +56,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { if (operatorFees.length > 0) { oldOperatorFees.push({ identityId: i, - operatorFees, + fees: operatorFees, }); } } diff --git a/deploy/027_deploy_sharding_table_v2.ts b/deploy/027_deploy_sharding_table_v2.ts index 9640cfde..b9f05055 100644 --- a/deploy/027_deploy_sharding_table_v2.ts +++ b/deploy/027_deploy_sharding_table_v2.ts @@ -17,6 +17,11 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { console.log('Deploying ShardingTable V2...'); + if (isMigration) { + console.log('And running migration of old ShardingTable...'); + delete hre.helpers.contractDeployments.contracts['ShardingTable'].migration; + } + const blockTimeNow = (await hre.ethers.provider.getBlock('latest')).timestamp; await hre.helpers.deploy({ @@ -25,7 +30,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { additionalArgs: [isMigration ? blockTimeNow + 3600 : blockTimeNow], }); - if (hre.helpers.contractDeployments.contracts['ShardingTable'].migration && hre.network.name.startsWith('otp')) { + if (isMigration && hre.network.name.startsWith('otp')) { const { deployer } = await hre.getNamedAccounts(); console.log(`Executing sharding table storage v1 to v2 migration`); @@ -37,15 +42,17 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { ); const oldShardingTable = await hre.ethers.getContractAt('ShardingTable', oldShardingTableAddress, deployer); - const newShardingTable = await hre.ethers.getContractAt('ShardingTable', newShardingTableAddress, deployer); + const newShardingTableABI = hre.helpers.getAbi('ShardingTableV2'); + const newShardingTable = await hre.ethers.getContractAt(newShardingTableABI, newShardingTableAddress, deployer); - const nodes = await oldShardingTable.getShardingTable(); + const nodes = await oldShardingTable['getShardingTable()'](); let identityId = nodes[0]?.identityId; console.log(`Found ${nodes.length} nodes in the old ShardingTable, starting identityId: ${identityId}`); const numberOfNodesInBatch = 10; let iteration = 1; + const oldShardingTableStorageAddress = await oldShardingTable.shardingTableStorage(); const encodedDataArray = []; while (identityId) { @@ -57,7 +64,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { newShardingTable.interface.encodeFunctionData('migrateOldShardingTable', [ identityId, numberOfNodesInBatch, - oldShardingTableAddress, + oldShardingTableStorageAddress, ]), ); @@ -68,9 +75,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { identityId = nodes[iteration * numberOfNodesInBatch]?.identityId; } - for (let i = 0; i < encodedDataArray.length; i++) { - hre.helpers.setParametersEncodedData.push(['ShardingTable', [encodedDataArray[i]]]); - } + hre.helpers.setParametersEncodedData.push(['ShardingTable', encodedDataArray]); } }; diff --git a/deployments/gnosis_chiado_dev_contracts.json b/deployments/gnosis_chiado_dev_contracts.json index 7b7491a2..710ab125 100644 --- a/deployments/gnosis_chiado_dev_contracts.json +++ b/deployments/gnosis_chiado_dev_contracts.json @@ -116,15 +116,6 @@ "deploymentTimestamp": 1707754843853, "deployed": true }, - "NodeOperatorFeeChangesStorage": { - "evmAddress": "0x3e833D19a4d1FF1B79c88A012B06EE56055914b7", - "version": "2.0.0", - "gitBranch": "main", - "gitCommitHash": "8877334d94d89edfa2fea5bff3cd7f367a8609ae", - "deploymentBlock": 8202425, - "deploymentTimestamp": 1707754853615, - "deployed": true - }, "ProfileStorage": { "evmAddress": "0x0BdB4dfA388682d5baCFfc52Df57712dCF3Af71B", "version": "1.0.0", @@ -202,12 +193,12 @@ "deployed": true }, "Staking": { - "evmAddress": "0x8e2e0095C60479501f98486B995019bc129f8247", + "evmAddress": "0x2b97Ce36e085D62403B51E7D8A08dd712B19016f", "version": "2.0.0", - "gitBranch": "main", - "gitCommitHash": "8877334d94d89edfa2fea5bff3cd7f367a8609ae", - "deploymentBlock": 8202434, - "deploymentTimestamp": 1707754897946, + "gitBranch": "release/4.2.6", + "gitCommitHash": "731dc92083f8c8e705050f9da8d8d9be649e7465", + "deploymentBlock": 9312156, + "deploymentTimestamp": 1713368482765, "deployed": true }, "Profile": { @@ -272,6 +263,15 @@ "deploymentBlock": 8868369, "deploymentTimestamp": 1711100974304, "deployed": true + }, + "NodeOperatorFeesStorage": { + "evmAddress": "0xbb3fAbF0d691Ce3a0840d496834c7E27921CaF48", + "version": "2.0.0", + "gitBranch": "release/4.2.6", + "gitCommitHash": "731dc92083f8c8e705050f9da8d8d9be649e7465", + "deploymentBlock": 9312155, + "deploymentTimestamp": 1713368476437, + "deployed": true } } } diff --git a/deployments/otp_devnet_contracts.json b/deployments/otp_devnet_contracts.json index 76a491c5..2c7fc249 100644 --- a/deployments/otp_devnet_contracts.json +++ b/deployments/otp_devnet_contracts.json @@ -181,27 +181,24 @@ "version": "1.1.1" }, "ShardingTable": { - "deployed": true, - "deploymentTimestamp": 1701163436129, - "evmAddress": "0x8B61b049628eeFe9070B15a2D1039f47690B835a", - "gitBranch": "main", - "gitCommitHash": "7c5fb6a77323e20d2a9be46e0533c9453300db4a", - "substrateAddress": "5EMjsczp6yL869TmhcM2xghQHsnAPB22Vt7SfJQQ1hB5Xv1N", - "version": "1.0.1" - }, - "ShardingTableStorage": { - "deployed": true, - "evmAddress": "0x822800D5eb7722bB22a06a28D1D7e2F51b829F18", - "substrateAddress": "5EMjscznFkx3G7xvHe6FyGSw6wuDGSuuBMwUs2Xdi6GWBZnc" + "evmAddress": "0x89822851D2A5b5256Fd19fa3b52538CAaE1f0acb", + "substrateAddress": "5EMjsczojCiGD9qj1tN9JPu3Q1NZzBq9e4fQmCRHarD5agFZ", + "version": "2.0.1", + "gitBranch": "release/4.2.6", + "gitCommitHash": "731dc92083f8c8e705050f9da8d8d9be649e7465", + "deploymentBlock": 4434349, + "deploymentTimestamp": 1713367726304, + "deployed": true }, "Staking": { - "deployed": true, - "deploymentTimestamp": 1701163460533, - "evmAddress": "0x1075658391Df7ae7bb97574589dD6a970F85A11E", - "gitBranch": "main", - "gitCommitHash": "7c5fb6a77323e20d2a9be46e0533c9453300db4a", - "substrateAddress": "5EMjsczPUQUX9ajYNSJp66THZ5Z835oB9Mk11BAHPumgspdK", - "version": "1.0.2" + "evmAddress": "0xC77cb206B1a08B68F207da98C613CF57B944a41A", + "substrateAddress": "5EMjsd129VjMzFmGv7SfWxy6K3juvrXBRG5wfrBhRz3gqmgH", + "version": "2.0.0", + "gitBranch": "release/4.2.6", + "gitCommitHash": "731dc92083f8c8e705050f9da8d8d9be649e7465", + "deploymentBlock": 4434351, + "deploymentTimestamp": 1713367748185, + "deployed": true }, "StakingStorage": { "deployed": true, @@ -222,6 +219,36 @@ "deployed": true, "evmAddress": "0xDcEbFfd3DC577705cAAbE2Bc65AA6aeEd0ef8b85", "substrateAddress": "5EMjsd16Sbx1X1f3SquRJm9Y2jbZVZQp2Z1qJmLaGKxBuNff" + }, + "LinearSum": { + "evmAddress": "0x8e06aaa718779638ed307c75E1DceD5F8aDf63f9", + "substrateAddress": "5EMjsczpdhqC2j6nAq53SZjKfjoaRSWNoiaQNqch2TsD9fKw", + "version": null, + "gitBranch": "release/4.2.6", + "gitCommitHash": "731dc92083f8c8e705050f9da8d8d9be649e7465", + "deploymentBlock": 4434343, + "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", + "version": "2.0.0", + "gitBranch": "release/4.2.6", + "gitCommitHash": "731dc92083f8c8e705050f9da8d8d9be649e7465", + "deploymentBlock": 4434347, + "deploymentTimestamp": 1713367700400, + "deployed": true } }, "deployedTimestamp": 1689863125519