Skip to content

Commit

Permalink
REP-02, REP-03: Proposal on mainnet (#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
nxqbao authored Oct 19, 2023
2 parents 7fbe538 + f173ec7 commit bb1d310
Show file tree
Hide file tree
Showing 26 changed files with 5,798 additions and 308 deletions.
2,910 changes: 2,910 additions & 0 deletions deployments/ethereum/MainchainGatewayV3Logic.json

Large diffs are not rendered by default.

636 changes: 636 additions & 0 deletions deployments/ethereum/solcInputs/f9f5036294d35a88da21dae55fc8b26c.json

Large diffs are not rendered by default.

156 changes: 78 additions & 78 deletions deployments/ronin-mainnet/BridgeRewardProxy.json

Large diffs are not rendered by default.

116 changes: 58 additions & 58 deletions deployments/ronin-mainnet/BridgeSlashProxy.json

Large diffs are not rendered by default.

112 changes: 54 additions & 58 deletions deployments/ronin-mainnet/BridgeTrackingProxy.json

Large diffs are not rendered by default.

168 changes: 84 additions & 84 deletions deployments/ronin-mainnet/RoninBridgeManager.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ const config: HardhatUserConfig = {
enabled: true,
runs: 10,
},
metadata: {
useLiteralContent: true,
},
},
},
},
Expand All @@ -140,13 +143,14 @@ const config: HardhatUserConfig = {
outDir: 'src/types',
},
paths: {
deploy: ['src/deploy', 'src/upgrades'],
deploy: ['src/deploy', 'src/upgrades', 'src/dashboard'],
tests: 'test/hardhat_test',
},
namedAccounts: {
deployer: 0,
governor: 0,
// governor: '0x00000000000000000000000000000000deadbeef',
// governor: 'privatekey://0x00000000000000000000000000000000deadbeef000000000000000000sample',
// governor: 'trezor://0x0000000000000000000000000000000000000000',
},
networks: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { RoninGovernanceAdmin } from "@ronin/contracts/ronin/RoninGovernanceAdmi
import { RoninGatewayV3 } from "@ronin/contracts/ronin/gateway/RoninGatewayV3.sol";
import { MainchainGatewayV3 } from "@ronin/contracts/mainchain/MainchainGatewayV3.sol";
import { Staking } from "@ronin/contracts/ronin/staking/Staking.sol";
import { Maintenance } from "@ronin/contracts/ronin/Maintenance.sol";
import { BridgeTracking } from "@ronin/contracts/ronin/gateway/BridgeTracking.sol";
import { SlashIndicator } from "@ronin/contracts/ronin/slash-indicator/SlashIndicator.sol";
import { RoninTrustedOrganization } from "@ronin/contracts/multi-chains/RoninTrustedOrganization.sol";
Expand Down Expand Up @@ -42,10 +43,22 @@ contract Simulation__20231003_UpgradeREP002AndREP003_Base is BaseDeploy, MappedT
BridgeReward internal _bridgeReward;
RoninBridgeManager internal _roninBridgeManager;

uint256 _depositCount;

function _injectDependencies() internal virtual override {
_setDependencyDeployScript(ContractKey.Profile, new ProfileDeploy());
}

function _hookSetDepositCount() internal pure virtual returns (uint256) {
return 42127; // fork-block-number 28139075
}

function _hookPrankOperator() internal virtual returns (address) {
return makeAccount("detach-operator-1").addr;
}

function _afterDepositForOnlyOnRonin(Transfer.Receipt memory) internal virtual {}

function run() public virtual trySetUp {
{
address mockPrecompile = _deployLogic(ContractKey.MockPrecompile);
Expand All @@ -64,6 +77,9 @@ contract Simulation__20231003_UpgradeREP002AndREP003_Base is BaseDeploy, MappedT
_config.getAddressFromCurrentNetwork(ContractKey.FastFinalityTracking)
);
_roninGovernanceAdmin = RoninGovernanceAdmin(_config.getAddressFromCurrentNetwork(ContractKey.GovernanceAdmin));
_roninBridgeManager = RoninBridgeManager(_config.getAddressFromCurrentNetwork(ContractKey.RoninBridgeManager));

_depositCount = _hookSetDepositCount();
}

function _depositForOnBothChain(string memory userName) internal {
Expand Down Expand Up @@ -100,14 +116,12 @@ contract Simulation__20231003_UpgradeREP002AndREP003_Base is BaseDeploy, MappedT
// switch rpc to ronin mainnet
_config.switchTo(Network.RoninMainnet);

address operator = 0x4b3844A29CFA5824F53e2137Edb6dc2b54501BeA;
address operator = _hookPrankOperator();
vm.label(operator, "bridge-operator");
vm.prank(operator);
_roninGateway.depositFor(receipt);
}

// uint256 _depositCount = 42127; // fork-block-number 28139075
uint256 _depositCount = 42213; // fork-block-number 28327195
function _depositForOnlyOnRonin(string memory userName) internal {
Account memory user = makeAccount(userName);
vm.makePersistent(user.addr);
Expand All @@ -129,11 +143,10 @@ contract Simulation__20231003_UpgradeREP002AndREP003_Base is BaseDeploy, MappedT
);
receipt.mainchain.chainId = 1;

// address operator = 0x4b3844A29CFA5824F53e2137Edb6dc2b54501BeA;
// vm.label(operator, "bridge-operator");
// vm.prank(operator);
vm.prank(makeAccount("detach-operator-1").addr);
vm.prank(_hookPrankOperator());
_roninGateway.depositFor(receipt);

_afterDepositForOnlyOnRonin(receipt);
}

function _dummySwitchNetworks() internal {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,32 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
pragma solidity ^0.8.19;

import { RoninGovernanceAdmin } from "@ronin/contracts/ronin/RoninGovernanceAdmin.sol";
import { MainchainBridgeManager } from "@ronin/contracts/mainchain/MainchainBridgeManager.sol";
import { MainchainGatewayV3 } from "@ronin/contracts/mainchain/MainchainGatewayV3.sol";
import { TransparentUpgradeableProxyV2 } from "@ronin/contracts/extensions/TransparentUpgradeableProxyV2.sol";

import { MappedTokenConsumer } from "@ronin/contracts/interfaces/consumers/MappedTokenConsumer.sol";
import { console2, BaseDeploy, ContractKey, Network } from "../BaseDeploy.s.sol";

contract Simulation__20231003_UpgradeREP002AndREP003_ETH is BaseDeploy, MappedTokenConsumer {
RoninGovernanceAdmin internal _mainchainGovernanceAdmin;
MainchainGatewayV3 internal _mainchainGatewayV3;
MainchainBridgeManager internal _mainchainBridgeManager;

function run() public virtual trySetUp {
_mainchainGatewayV3 = MainchainGatewayV3(_config.getAddressFromCurrentNetwork(ContractKey.MainchainGatewayV3));
_mainchainBridgeManager = MainchainBridgeManager(
_config.getAddressFromCurrentNetwork(ContractKey.MainchainBridgeManager)
);
_mainchainGovernanceAdmin = RoninGovernanceAdmin(_config.getAddressFromCurrentNetwork(ContractKey.GovernanceAdmin));

_upgradeProxy(
ContractKey.MainchainGatewayV3,
abi.encodeCall(MainchainGatewayV3.initializeV2, (address(_mainchainBridgeManager)))
);
vm.startPrank(address(_mainchainGovernanceAdmin));
TransparentUpgradeableProxyV2(payable(address(_mainchainGatewayV3))).changeAdmin(address(_mainchainBridgeManager));
vm.stopPrank();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ contract Simulation__20231003_UpgradeREP002AndREP003_RON_NonConditional is
_upgradeProxy(ContractKey.StakingVesting, abi.encodeCall(StakingVesting.initializeV2, ()));
_stakingVesting.initializeV3(50); // 5%
}
}


{
// upgrade `Maintenance`
// bump `Maintenance` to V2
_upgradeProxy(ContractKey.Maintenance, abi.encodeCall(Maintenance.initializeV2, ()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import { TransparentUpgradeableProxyV2 } from "@ronin/contracts/extensions/Trans
contract Simulation_20231003_REP002AndREP003_RON_NonConditional_GatewayUpgrade is
Simulation__20231003_UpgradeREP002AndREP003_RON_NonConditional_Wrapup2Periods
{
function _hookSetDepositCount() internal pure override returns (uint256) {
return 42213; // fork-block-number 28327195
}

function run() public virtual override trySetUp {
Simulation__20231003_UpgradeREP002AndREP003_Base.run();

Expand All @@ -34,7 +38,7 @@ contract Simulation_20231003_REP002AndREP003_RON_NonConditional_GatewayUpgrade i
_upgradeDPoSContracts();
_upgradeGatewayContracts();
_callInitREP2InGatewayContracts();
// _changeAdminOfGatewayContracts();
_changeAdminOfGatewayContracts();

// -- done execute proposal

Expand Down Expand Up @@ -146,11 +150,14 @@ contract Simulation_20231003_REP002AndREP003_RON_NonConditional_GatewayUpgrade i
console2.log("> ", StdStyle.blue("_upgradeGatewayContracts"), "...");

{
// upgrade `RoninGatewayV3` and bump to V2
_upgradeProxy(ContractKey.RoninGatewayV3, abi.encodeCall(RoninGatewayV3.initializeV2, ()));
// bump `RoninGatewayV3` to V3
_roninGateway.initializeV3(address(_roninBridgeManager));
}

{
// bump `BridgeTracking` to V3
_bridgeTracking.initializeV3({
bridgeManager: address(_roninBridgeManager),
bridgeSlash: address(_bridgeSlash),
Expand All @@ -161,16 +168,26 @@ contract Simulation_20231003_REP002AndREP003_RON_NonConditional_GatewayUpgrade i
}

function _callInitREP2InGatewayContracts() internal {
console2.log("> ", StdStyle.blue("_callInitREP2InGatewayContracts"), "...");

vm.startPrank(address(_roninGovernanceAdmin));
TransparentUpgradeableProxyV2(payable(address(_bridgeReward))).functionDelegateCall(
abi.encodeCall(BridgeReward.initializeREP2, ())
);
TransparentUpgradeableProxyV2(payable(address(_bridgeTracking))).functionDelegateCall(
abi.encodeCall(BridgeReward.initializeREP2, ())
abi.encodeCall(BridgeTracking.initializeREP2, ())
);
TransparentUpgradeableProxyV2(payable(address(_bridgeSlash))).functionDelegateCall(
abi.encodeCall(BridgeReward.initializeREP2, ())
abi.encodeCall(BridgeSlash.initializeREP2, ())
);
vm.stopPrank();
}

function _changeAdminOfGatewayContracts() internal {
console2.log("> ", StdStyle.blue("_changeAdminOfGatewayContracts"), "...");

vm.startPrank(address(_roninGovernanceAdmin));
TransparentUpgradeableProxyV2(payable(address(_roninGateway))).changeAdmin(address(_roninBridgeManager));
vm.stopPrank();
}
}

Large diffs are not rendered by default.

Loading

0 comments on commit bb1d310

Please sign in to comment.