Skip to content

Commit

Permalink
Merge pull request #255 from OriginTrail/mainnet-deployment/4.2.7
Browse files Browse the repository at this point in the history
Fixed deployment script for NodeOperatorFeesStorage, redeployed contracts on Gnosis/Neuroweb Mainnet
  • Loading branch information
u-hubar authored Apr 30, 2024
2 parents cdd0902 + dc71ec3 commit 114fabd
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 120 deletions.
12 changes: 6 additions & 6 deletions deploy/026_deploy_sharding_table_v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,34 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
if (isMigration) {
console.log('And running migration of old ShardingTable...');
delete hre.helpers.contractDeployments.contracts['ShardingTable'].migration;
hre.helpers.contractDeployments.contracts['OldShardingTable'] =
hre.helpers.contractDeployments.contracts['ShardingTable'];
}

const blockTimeNow = (await hre.ethers.provider.getBlock('latest')).timestamp;

await hre.helpers.deploy({
const newShardingTable = await hre.helpers.deploy({
newContractName: 'ShardingTableV2',
newContractNameInHub: 'ShardingTable',
additionalArgs: [isMigration ? blockTimeNow + 3600 : blockTimeNow],
additionalArgs: [isMigration ? blockTimeNow + 86400 : blockTimeNow],
});

if (isMigration && hre.network.name.startsWith('otp')) {
const { deployer } = await hre.getNamedAccounts();

console.log(`Executing sharding table storage v1 to v2 migration`);
const newShardingTableAddress = hre.helpers.contractDeployments.contracts['ShardingTable'].evmAddress;
const shardingTableStorageAddress = hre.helpers.contractDeployments.contracts['ShardingTableStorage'].evmAddress;

console.log(
`Old ShardingTable: ${oldShardingTableAddress}, New ShardingTable: ${newShardingTableAddress}, ShardingTableStorage: ${shardingTableStorageAddress}`,
`Old ShardingTable: ${oldShardingTableAddress}, New ShardingTable: ${newShardingTable.address}, ShardingTableStorage: ${shardingTableStorageAddress}`,
);

const oldShardingTable = await hre.ethers.getContractAt('ShardingTable', oldShardingTableAddress, deployer);
const newShardingTableABI = hre.helpers.getAbi('ShardingTableV2');
const newShardingTable = await hre.ethers.getContractAt(newShardingTableABI, newShardingTableAddress, deployer);

const nodes = await oldShardingTable['getShardingTable()']();
let identityId = nodes[0]?.identityId;
console.log(`Found ${nodes.length} nodes in the old ShardingTable, starting identityId: ${identityId}`);
console.log(`Full list of migrated nodes: ${JSON.stringify(nodes)}`);

const numberOfNodesInBatch = 10;
let iteration = 1;
Expand Down
22 changes: 18 additions & 4 deletions deploy/028_deploy_node_operator_fees_storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,19 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

const { deployer } = await hre.getNamedAccounts();

const shardingTableAddress = hre.helpers.contractDeployments.contracts['ShardingTable'].evmAddress;
const ShardingTable = await hre.ethers.getContractAt('ShardingTable', shardingTableAddress, deployer);
let shardingTableABI;
let shardingTableAddress;
if (Object.keys(hre.helpers.contractDeployments.contracts).includes('OldShardingTable')) {
shardingTableABI = hre.helpers.getAbi('ShardingTable');
shardingTableAddress = hre.helpers.contractDeployments.contracts['OldShardingTable'].evmAddress;
delete hre.helpers.contractDeployments.contracts['OldShardingTable'];
console.log(`Found V1 ShardingTable address: ${shardingTableAddress}`);
} else {
shardingTableABI = hre.helpers.getAbi('ShardingTableV2');
shardingTableAddress = hre.helpers.contractDeployments.contracts['ShardingTable'].evmAddress;
console.log(`Found V2 ShardingTable address: ${shardingTableAddress}`);
}
const ShardingTable = await hre.ethers.getContractAt(shardingTableABI, shardingTableAddress, deployer);

const stakingStorageAddress = hre.helpers.contractDeployments.contracts['StakingStorage'].evmAddress;
const StakingStorage = await hre.ethers.getContractAt('StakingStorage', stakingStorageAddress, deployer);
Expand All @@ -28,6 +39,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
nofcs = await hre.ethers.getContractAt(abi, nofcsAddress, deployer);
}

console.log(`Getting list of nodes in Sharding Table...`);
const nodes: ShardingTableStructsV1.NodeInfoStructOutput[] = await ShardingTable['getShardingTable()']();
const identityIds = nodes.map((node) => node.identityId);

Expand Down Expand Up @@ -78,13 +90,15 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

delete hre.helpers.contractDeployments.contracts['NodeOperatorFeeChangesStorage'];

console.log(`Full list of migrated operator fees: ${JSON.stringify(oldOperatorFees)}`);

const NodeOperatorFeesStorage = await hre.helpers.deploy({
newContractName: 'NodeOperatorFeesStorage',
additionalArgs: [timestampNow + 300],
additionalArgs: [timestampNow + 86400],
});

const chunkSize = 10;
const encodedDataArray: string[] = oldOperatorFees.reduce<string[]>((acc, currentValue, currentIndex, array) => {
const encodedDataArray: string[] = oldOperatorFees.reduce<string[]>((acc, _, currentIndex, array) => {
if (currentIndex % chunkSize === 0) {
// Encode and push the function data for a slice of the array
acc.push(
Expand Down
4 changes: 4 additions & 0 deletions deploy/999_save_deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
if (hre.network.config.environment !== 'development') {
if (Object.keys(hre.helpers.contractDeployments.contracts).includes('OldShardingTable')) {
delete hre.helpers.contractDeployments.contracts['OldShardingTable'];
}

hre.helpers.saveDeploymentsJson('deployments');
}
};
Expand Down
38 changes: 19 additions & 19 deletions deployments/gnosis_mainnet_contracts.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,6 @@
"deploymentTimestamp": 1707908502792,
"deployed": true
},
"NodeOperatorFeeChangesStorage": {
"evmAddress": "0x1DB35c492dfe89AF6e808c3c85B694983Bb372c9",
"version": "2.0.0",
"gitBranch": "main",
"gitCommitHash": "26881f1a79eaf41f13d1c48a2c5952d0a1d14274",
"deploymentBlock": 32446839,
"deploymentTimestamp": 1707908520006,
"deployed": true
},
"ProfileStorage": {
"evmAddress": "0x5b52765a7A46196f7a8c7dBec234D3Df23248BB4",
"version": "1.0.0",
Expand Down Expand Up @@ -210,12 +201,12 @@
"deployed": true
},
"Staking": {
"evmAddress": "0x34fdD017567300b0891Fa03673338E14b564C3CC",
"version": "2.0.0",
"evmAddress": "0xDF52514120baF7aD08cecd23d24e683CDbDD58a3",
"version": "2.0.1",
"gitBranch": "main",
"gitCommitHash": "26881f1a79eaf41f13d1c48a2c5952d0a1d14274",
"deploymentBlock": 32446895,
"deploymentTimestamp": 1707908831259,
"gitCommitHash": "cdd09025ee035eb72c4322639cefe1848dd90ecb",
"deploymentBlock": 33607133,
"deploymentTimestamp": 1713968688686,
"deployed": true
},
"Profile": {
Expand Down Expand Up @@ -273,12 +264,21 @@
"deployed": true
},
"ContentAsset": {
"evmAddress": "0x9bbaf939c850289e51920736c266C60034F44b01",
"version": "1.0.3",
"evmAddress": "0x9c0A591B9909Be8d3Fc62AC32Ae7ad8b7156398e",
"version": "1.0.4",
"gitBranch": "main",
"gitCommitHash": "b610b9bcf8dcd83d959816d290e635ba61fd83d2",
"deploymentBlock": 33058743,
"deploymentTimestamp": 1711112881483,
"gitCommitHash": "cdd09025ee035eb72c4322639cefe1848dd90ecb",
"deploymentBlock": 33607136,
"deploymentTimestamp": 1713968703122,
"deployed": true
},
"NodeOperatorFeesStorage": {
"evmAddress": "0x5adAC1b63407C490aC0Fb80E85CE7014101c8610",
"version": "2.0.0",
"gitBranch": "mainnet-deployment/4.2.7",
"gitCommitHash": "8839a0e5c92a413b06d20fa15335950bb625f890",
"deploymentBlock": 33619390,
"deploymentTimestamp": 1714031946358,
"deployed": true
}
}
Expand Down
Loading

0 comments on commit 114fabd

Please sign in to comment.