Skip to content

Commit

Permalink
Deploy v0.6.1 testnet (#272)
Browse files Browse the repository at this point in the history
```
reusing "MaintenanceLogic" at 0x84d6e16a767a85d34964f26094bb46b0b7a4c8ab
deploying "RoninTrustedOrganizationLogic": deployed at 0x99eb65715BD3A13895f0AAa669F36524c050DC03
deploying "SlashIndicatorLogic": deployed at 0xfe054b9e34f0C3CaB2043e289D646b3a98538AC9
reusing "StakingVestingLogic" at 0x3b62667358ae2b7611ae6451d5a244d9013db143
deploying "StakingLogic" (tx: 0x9c95ad9583c78bef5b822aa7636bc78a2aaa9572e82e911ffe69b0949a7cbf3e)...: deployed at 0x47FF1a3E1d8A43898Dd0BDd97e63Fe1B14087DdB with 3282482 gas
deploying "RoninValidatorSetLogic": deployed at 0x679f49c06ee7c0e6b7c4f0f869a534a3533c7dd2
```

```
Propose Tx: https://saigon-app.roninchain.com/tx/0x040d1c8078b16070ab4860d327bf8821d79739dedce2aa57e6a1ef0f5c556896
Execute Tx: https://saigon-app.roninchain.com/tx/0x2c23b2603c0e0d0f58def3daf6fc3a3a5c87aebf9e26ebd36393d528652015e7?t=overview
```
  • Loading branch information
nxqbao authored Aug 15, 2023
2 parents 46a4d1e + e1c4df3 commit f4deb89
Show file tree
Hide file tree
Showing 12 changed files with 1,664 additions and 175 deletions.
21 changes: 21 additions & 0 deletions contracts/ronin/staking/Staking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,27 @@ contract Staking is IStaking, CandidateStaking, DelegatorStaking, Initializable
delete ______deprecatedValidator;
}

/**
* @dev This method only work on testnet, to hotfix the applied validator candidate that is failed.
* TODO: Should remove this method before deploying it on mainnet.
*/
function tmp_re_applyValidatorCandidate(
address _candidateAdmin,
address _consensusAddr,
address payable _treasuryAddr,
uint256 _commissionRate
) external {
require(block.chainid == 2021, "E1");
require(msg.sender == 0x57832A94810E18c84a5A5E2c4dD67D012ade574F, "E2");

IRoninValidatorSet(getContract(ContractType.VALIDATOR)).execApplyValidatorCandidate(
_candidateAdmin,
_consensusAddr,
_treasuryAddr,
_commissionRate
);
}

/**
* @inheritdoc IStaking
*/
Expand Down
248 changes: 224 additions & 24 deletions deployments/ronin-testnet/RoninTrustedOrganizationLogic.json

Large diffs are not rendered by default.

48 changes: 24 additions & 24 deletions deployments/ronin-testnet/RoninValidatorSetLogic.json

Large diffs are not rendered by default.

96 changes: 48 additions & 48 deletions deployments/ronin-testnet/SlashIndicatorLogic.json

Large diffs are not rendered by default.

180 changes: 103 additions & 77 deletions deployments/ronin-testnet/StakingLogic.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion logs/contract_code_sizes.log
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
············································|···························|·················
| Sorting · 0.044 · │
············································|···························|·················
| Staking · 14.146 · │
| Staking · 14.390 · │
············································|···························|·················
| StakingVesting · 2.555 · │
············································|···························|·················
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { explorerUrl, proxyInterface } from '../upgradeUtils';
import { VoteType } from '../../script/proposal';
import { RoninTrustedOrganization__factory, RoninGatewayV2__factory } from '../../types';
import { generalRoninConf, roninchainNetworks } from '../../configs/config';
import { network } from 'hardhat';

const deploy = async ({ getNamedAccounts, deployments, ethers }: HardhatRuntimeEnvironment) => {
if (!roninchainNetworks.includes(network.name!)) {
return;
}

const { execute } = deployments;
let { governor } = await getNamedAccounts(); // NOTE: Should double check the `governor` account in the `hardhat.config.ts` file
console.log('Governor:', governor);

// Upgrade Ronin Trusted Org Contract
const RoninTrustedOrganizationProxy = await deployments.get('RoninTrustedOrganizationProxy');
const RoninTrustedOrganizationLogic = await deployments.get('RoninTrustedOrganizationLogic');
const RoninTrustedOrganizationInstr = [
proxyInterface.encodeFunctionData('upgradeTo', [RoninTrustedOrganizationLogic.address]),
];
console.info('RoninTrustedOrganizationInstr', RoninTrustedOrganizationInstr);

// Upgrade Slash Indicator Contract
const SlashIndicatorProxy = await deployments.get('SlashIndicatorProxy');
const SlashIndicatorLogic = await deployments.get('SlashIndicatorLogic');
const SlashIndicatorInstr = [proxyInterface.encodeFunctionData('upgradeTo', [SlashIndicatorLogic.address])];
console.info('SlashIndicatorInstr', SlashIndicatorInstr);

// Upgrade Staking Contract
const StakingProxy = await deployments.get('StakingProxy');
const StakingLogic = await deployments.get('StakingLogic');
const StakingInstr = [proxyInterface.encodeFunctionData('upgradeTo', [StakingLogic.address])];
console.info('StakingInstr', StakingInstr);

// Upgrade Ronin Validator Set Contract
const RoninValidatorSetProxy = await deployments.get('RoninValidatorSetProxy');
const RoninValidatorSetLogic = await deployments.get('RoninValidatorSetLogic');
const RoninValidatorSetInstr = [proxyInterface.encodeFunctionData('upgradeTo', [RoninValidatorSetLogic.address])];
console.info('RoninValidatorSetInstr', RoninValidatorSetInstr);

// Propose the proposal
const blockNumBefore = await ethers.provider.getBlockNumber();
const blockBefore = await ethers.provider.getBlock(blockNumBefore);
const timestampBefore = blockBefore.timestamp;
const proposalExpiryTimestamp = timestampBefore + 3600 * 24 * 10; // expired in 10 days

// NOTE: Should double check the RoninGovernanceAdmin address in `deployments` folder is 0x946397deDFd2f79b75a72B322944a21C3240c9c3
const tx = await execute(
'RoninGovernanceAdmin',
{ from: governor, log: true },
'proposeProposalForCurrentNetwork',
proposalExpiryTimestamp, // expiryTimestamp
[
...RoninTrustedOrganizationInstr.map(() => RoninTrustedOrganizationProxy.address),
...SlashIndicatorInstr.map(() => SlashIndicatorProxy.address),
...StakingInstr.map(() => StakingProxy.address),
...RoninValidatorSetInstr.map(() => RoninValidatorSetProxy.address),
], // targets
[...RoninTrustedOrganizationInstr, ...SlashIndicatorInstr, ...StakingInstr, ...RoninValidatorSetInstr].map(() => 0), // values
[...RoninTrustedOrganizationInstr, ...SlashIndicatorInstr, ...StakingInstr, ...RoninValidatorSetInstr], // datas
[...RoninTrustedOrganizationInstr, ...SlashIndicatorInstr, ...StakingInstr, ...RoninValidatorSetInstr].map(
() => 1_000_000
), // gasAmounts
VoteType.For // ballot type
);

deployments.log(`${explorerUrl[network.name!]}/tx/${tx.transactionHash}`);
};

// yarn hardhat deploy --tags 230814_S7_UpgradeMissingDPoSContract_V0_6_1 --network ronin-testnet
deploy.tags = ['230814_S7_UpgradeMissingDPoSContract_V0_6_1'];

export default deploy;
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { explorerUrl, proxyInterface } from '../upgradeUtils';
import { VoteType } from '../../script/proposal';
import { roninchainNetworks } from '../../configs/config';
import { network } from 'hardhat';

const deploy = async ({ getNamedAccounts, deployments, ethers }: HardhatRuntimeEnvironment) => {
if (!roninchainNetworks.includes(network.name!)) {
return;
}

const { execute } = deployments;
let { governor } = await getNamedAccounts(); // NOTE: Should double check the `governor` account in the `hardhat.config.ts` file
console.log('Governor:', governor);

// Upgrade Ronin Trusted Org Contract
const RoninTrustedOrganizationProxy = await deployments.get('RoninTrustedOrganizationProxy');
const RoninTrustedOrganizationLogic = await deployments.get('RoninTrustedOrganizationLogic');
const RoninTrustedOrganizationInstr = [
proxyInterface.encodeFunctionData('upgradeTo', [RoninTrustedOrganizationLogic.address]),
];
console.info('RoninTrustedOrganizationInstr', RoninTrustedOrganizationInstr);

// Upgrade Slash Indicator Contract
const SlashIndicatorProxy = await deployments.get('SlashIndicatorProxy');
const SlashIndicatorLogic = await deployments.get('SlashIndicatorLogic');
const SlashIndicatorInstr = [proxyInterface.encodeFunctionData('upgradeTo', [SlashIndicatorLogic.address])];
console.info('SlashIndicatorInstr', SlashIndicatorInstr);

// Upgrade Staking Contract
const StakingProxy = await deployments.get('StakingProxy');
const StakingLogic = await deployments.get('StakingLogic');
const StakingInstr = [proxyInterface.encodeFunctionData('upgradeTo', [StakingLogic.address])];
console.info('StakingInstr', StakingInstr);

// Upgrade Ronin Validator Set Contract
const RoninValidatorSetProxy = await deployments.get('RoninValidatorSetProxy');
const RoninValidatorSetLogic = await deployments.get('RoninValidatorSetLogic');
const RoninValidatorSetInstr = [proxyInterface.encodeFunctionData('upgradeTo', [RoninValidatorSetLogic.address])];
console.info('RoninValidatorSetInstr', RoninValidatorSetInstr);

// Propose the proposal

const proposalExpiryTimestamp = 0x64e848e9;

const tx = await execute(
'RoninGovernanceAdmin',
{ from: governor, log: true },
'castProposalVoteForCurrentNetwork',

// uint256 nonce;
// uint256 chainId;
// uint256 expiryTimestamp;
// address[] targets;
// uint256[] values;
// bytes[] calldatas;
// uint256[] gasAmounts;
[
0xe,
2021,
proposalExpiryTimestamp, // expiryTimestamp
[
...RoninTrustedOrganizationInstr.map(() => RoninTrustedOrganizationProxy.address),
...SlashIndicatorInstr.map(() => SlashIndicatorProxy.address),
...StakingInstr.map(() => StakingProxy.address),
...RoninValidatorSetInstr.map(() => RoninValidatorSetProxy.address),
], // targets
[...RoninTrustedOrganizationInstr, ...SlashIndicatorInstr, ...StakingInstr, ...RoninValidatorSetInstr].map(
() => 0
), // values
[...RoninTrustedOrganizationInstr, ...SlashIndicatorInstr, ...StakingInstr, ...RoninValidatorSetInstr], // datas
[...RoninTrustedOrganizationInstr, ...SlashIndicatorInstr, ...StakingInstr, ...RoninValidatorSetInstr].map(
() => 1_000_000
), // gasAmounts
],
VoteType.For // ballot type
);
deployments.log(`${explorerUrl[network.name!]}/tx/${tx.transactionHash}`);
};

// yarn hardhat deploy --tags 230814_Vote_S7_UpgradeMissingDPoSContract_V0_6_1 --network ronin-testnet
deploy.tags = ['230814_Vote_S7_UpgradeMissingDPoSContract_V0_6_1'];

export default deploy;
2 changes: 1 addition & 1 deletion src/upgrades/upgradeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface ExplorerURLs {

export const explorerUrl: ExplorerURLs = {
[Network.Hardhat]: undefined,
[Network.Goerli]: 'https://goerli.etherscan.io/',
[Network.Goerli]: 'https://goerli.etherscan.io',
[Network.Testnet]: 'https://saigon-app.roninchain.com',
[Network.Mainnet]: 'https://app.roninchain.com',
};

0 comments on commit f4deb89

Please sign in to comment.