Skip to content

Commit

Permalink
Add deployment scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike-CZ committed Nov 27, 2024
1 parent e36a4cd commit 15a6907
Show file tree
Hide file tree
Showing 9 changed files with 368 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
TESTNET_RPC_URL=http://localhost:8545/
TESTNET_PRIVATE_KEY_DEPLOY=0x0000000000000000000000000000000000000000
11 changes: 8 additions & 3 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { HardhatUserConfig } from 'hardhat/config';
import * as dotenv from 'dotenv';
import '@nomicfoundation/hardhat-chai-matchers';
import '@nomicfoundation/hardhat-ethers';
import "@nomicfoundation/hardhat-ignition";
import '@openzeppelin/hardhat-upgrades';
import '@typechain/hardhat';
import 'hardhat-contract-sizer';
Expand All @@ -22,9 +23,13 @@ const config: HardhatUserConfig = {
},
},
networks: {
hardhat: {
allowUnlimitedContractSize: true,
},
hardhat: {},
testnet: {
url: process.env.TESTNET_RPC_URL!,
accounts: [
process.env.TESTNET_PRIVATE_KEY_DEPLOY!,
],
}
},
gasReporter: {
currency: 'USD',
Expand Down
41 changes: 41 additions & 0 deletions ignition/modules/ConstantsManager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { buildModule } from "@nomicfoundation/hardhat-ignition/modules";

// npx hardhat ignition deploy ./ignition/modules/ConstantsManager.ts --network testnet --parameters ignition/params.json

export default buildModule("ConstantsManager", (m) => {
const deployAccount = m.getAccount(0);

const minSelfStake = m.getParameter('minSelfStake');
const maxDelegatedRatio = m.getParameter('maxDelegatedRatio');
const validatorCommissions = m.getParameter('validatorCommissions');
const burntFeeShare = m.getParameter('burntFeeShare');
const treasuryFeeShare = m.getParameter('treasuryFeeShare');
const withdrawalPeriodEpochs = m.getParameter('withdrawalPeriodEpochs');
const withdrawalPeriodTime = m.getParameter('withdrawalPeriodTime');
const baseRewardPerSecond = m.getParameter('baseRewardPerSecond');
const offlinePenaltyThresholdTime = m.getParameter('offlinePenaltyThresholdTime');
const offlinePenaltyThresholdBlocksNumber = m.getParameter('offlinePenaltyThresholdBlocksNumber');
const targetGasPowerPerSecond = m.getParameter('targetGasPowerPerSecond');
const gasPriceBalancingCounterweights = m.getParameter('gasPriceBalancingCounterweights');
const averageUptimeEpochWindow = m.getParameter('averageUptimeEpochWindow');
const updateMinAverageUptime = m.getParameter('updateMinAverageUptime');

const constantsManager = m.contract("ConstantsManager", [deployAccount]);

m.call(constantsManager, "updateMinSelfStake", [minSelfStake], {from: deployAccount});
m.call(constantsManager, "updateMaxDelegatedRatio", [maxDelegatedRatio], {from: deployAccount});
m.call(constantsManager, "updateValidatorCommission", [validatorCommissions], {from: deployAccount});
m.call(constantsManager, "updateBurntFeeShare", [burntFeeShare], {from: deployAccount});
m.call(constantsManager, "updateTreasuryFeeShare", [treasuryFeeShare], {from: deployAccount});
m.call(constantsManager, "updateWithdrawalPeriodEpochs", [withdrawalPeriodEpochs], {from: deployAccount});
m.call(constantsManager, "updateWithdrawalPeriodTime", [withdrawalPeriodTime], {from: deployAccount});
m.call(constantsManager, "updateBaseRewardPerSecond", [baseRewardPerSecond], {from: deployAccount});
m.call(constantsManager, "updateOfflinePenaltyThresholdTime", [offlinePenaltyThresholdTime], {from: deployAccount});
m.call(constantsManager, "updateOfflinePenaltyThresholdBlocksNum", [offlinePenaltyThresholdBlocksNumber], {from: deployAccount});
m.call(constantsManager, "updateTargetGasPowerPerSecond", [targetGasPowerPerSecond], {from: deployAccount});
m.call(constantsManager, "updateGasPriceBalancingCounterweight", [gasPriceBalancingCounterweights], {from: deployAccount});
m.call(constantsManager, "updateAverageUptimeEpochWindow", [averageUptimeEpochWindow], {from: deployAccount});
m.call(constantsManager, "updateMinAverageUptime", [updateMinAverageUptime], {from: deployAccount});

return { constantsManager };
});
8 changes: 8 additions & 0 deletions ignition/modules/NodeDriver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { buildModule } from "@nomicfoundation/hardhat-ignition/modules";

// npx hardhat ignition deploy ./ignition/modules/NodeDriver.ts --network testnet --parameters ignition/params.json

export default buildModule("NodeDriver", (m) => {
const nodeDriver = m.contract("NodeDriver");
return { nodeDriver };
});
8 changes: 8 additions & 0 deletions ignition/modules/NodeDriverAuth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { buildModule } from "@nomicfoundation/hardhat-ignition/modules";

// npx hardhat ignition deploy ./ignition/modules/NodeDriverAuth.ts --network testnet --parameters ignition/params.json

export default buildModule("NodeDriverAuth", (m) => {
const NodeDriverAuth = m.contract("NodeDriverAuth");
return { NodeDriverAuth };
});
8 changes: 8 additions & 0 deletions ignition/modules/SFC.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { buildModule } from "@nomicfoundation/hardhat-ignition/modules";

// npx hardhat ignition deploy ./ignition/modules/SFC.ts --network testnet --parameters ignition/params.json

export default buildModule("SFC", (m) => {
const sfc = m.contract("SFC");
return { sfc };
});
18 changes: 18 additions & 0 deletions ignition/params.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"ConstantsManager": {
"minSelfStake": "500000000000000000000000n",
"maxDelegatedRatio": "16000000000000000000n",
"validatorCommissions" : "150000000000000000n",
"burntFeeShare": "200000000000000000n",
"treasuryFeeShare": "100000000000000000n",
"withdrawalPeriodEpochs": 3,
"withdrawalPeriodTime": 604800,
"baseRewardPerSecond": "2668658453701531600n",
"offlinePenaltyThresholdTime": 432000,
"offlinePenaltyThresholdBlocksNumber": 1000,
"targetGasPowerPerSecond": 2000000,
"gasPriceBalancingCounterweights": 3600,
"averageUptimeEpochWindow": 100,
"updateMinAverageUptime": 0
}
}
Loading

0 comments on commit 15a6907

Please sign in to comment.