-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from ronin-chain/release/v3.2.2
release: v3.2.2-testnet
- Loading branch information
Showing
7 changed files
with
472 additions
and
67 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
100 changes: 100 additions & 0 deletions
100
script/20240612-maptoken-nft-sepolia/20240613-maptoken-erc1155-ronin.s.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import { console2 } from "forge-std/console2.sol"; | ||
import { StdStyle } from "forge-std/StdStyle.sol"; | ||
import { RoninBridgeManager } from "@ronin/contracts/ronin/gateway/RoninBridgeManager.sol"; | ||
import { IMainchainGatewayV3 } from "@ronin/contracts/interfaces/IMainchainGatewayV3.sol"; | ||
import { GlobalProposal } from "@ronin/contracts/libraries/GlobalProposal.sol"; | ||
import { LibTokenInfo, TokenStandard } from "@ronin/contracts/libraries/LibTokenInfo.sol"; | ||
import { Contract } from "../utils/Contract.sol"; | ||
import { Network } from "../utils/Network.sol"; | ||
import { Contract } from "../utils/Contract.sol"; | ||
import "@ronin/contracts/mainchain/MainchainBridgeManager.sol"; | ||
import { IRoninGatewayV3 } from "@ronin/contracts/interfaces/IRoninGatewayV3.sol"; | ||
import "@ronin/contracts/libraries/Proposal.sol"; | ||
import "@ronin/contracts/libraries/Ballot.sol"; | ||
|
||
import { MockUSDC } from "@ronin/contracts/mocks/token/MockUSDC.sol"; | ||
import { USDCDeploy } from "@ronin/script/contracts/token/USDCDeploy.s.sol"; | ||
import { MainchainBridgeAdminUtils } from "test/helpers/MainchainBridgeAdminUtils.t.sol"; | ||
|
||
import "../Migration.s.sol"; | ||
|
||
contract Migration__20240613_MapERC1155SepoliaRoninchain is Migration { | ||
RoninBridgeManager internal _roninBridgeManager; | ||
IRoninGatewayV3 internal _roninGatewayV3; | ||
|
||
MainchainBridgeAdminUtils _mainchainProposalUtils; | ||
|
||
function setUp() public override { | ||
super.setUp(); | ||
|
||
_roninBridgeManager = RoninBridgeManager(0x8AaAD4782890eb879A0fC132A6AdF9E5eE708faF); | ||
_roninGatewayV3 = IRoninGatewayV3(0xCee681C9108c42C710c6A8A949307D5F13C9F3ca); | ||
} | ||
|
||
function run() public { | ||
address[] memory mainchainTokens = new address[](1); | ||
address[] memory roninTokens = new address[](1); | ||
TokenStandard[] memory standards = new TokenStandard[](1); | ||
uint256[] memory chainIds = new uint256[](1); | ||
uint256[][4] memory thresholds; | ||
thresholds[0] = new uint256[](1); | ||
thresholds[1] = new uint256[](1); | ||
thresholds[2] = new uint256[](1); | ||
thresholds[3] = new uint256[](1); | ||
|
||
uint256 expiredTime = block.timestamp + 10 days; | ||
address[] memory targets = new address[](1); | ||
uint256[] memory values = new uint256[](1); | ||
bytes[] memory calldatas = new bytes[](1); | ||
uint256[] memory gasAmounts = new uint256[](1); | ||
|
||
mainchainTokens[0] = address(0xFBb71EEE2B420ea88e663B91722b41966E1C5F17); | ||
roninTokens[0] = address(0xDBB04B4BdBb385EB14cb3ea3C7B1FCcA55ea9160); | ||
standards[0] = TokenStandard.ERC1155; | ||
chainIds[0] = 11155111; | ||
|
||
// ================ USDC ERC-20 ====================== | ||
// function mapTokens( | ||
// address[] calldata _roninTokens, | ||
// address[] calldata _mainchainTokens, | ||
// uint256[] calldata chainIds, | ||
// TokenStandard[] calldata _standards | ||
// ) | ||
bytes memory innerData = abi.encodeCall(IRoninGatewayV3.mapTokens, (roninTokens, mainchainTokens, chainIds, standards)); | ||
bytes memory proxyData = abi.encodeWithSignature("functionDelegateCall(bytes)", innerData); | ||
|
||
targets[0] = address(_roninGatewayV3); | ||
values[0] = 0; | ||
calldatas[0] = proxyData; | ||
gasAmounts[0] = 1_000_000; | ||
|
||
// ================ VERIFY AND EXECUTE PROPOSAL =============== | ||
|
||
address[] memory governors = new address[](4); | ||
governors[3] = 0xd24D87DDc1917165435b306aAC68D99e0F49A3Fa; | ||
governors[2] = 0xb033ba62EC622dC54D0ABFE0254e79692147CA26; | ||
governors[0] = 0x087D08e3ba42e64E3948962dd1371F906D1278b9; | ||
governors[1] = 0x52ec2e6BBcE45AfFF8955Da6410bb13812F4289F; | ||
|
||
vm.broadcast(governors[0]); | ||
_roninBridgeManager.proposeProposalForCurrentNetwork(expiredTime, address(0), targets, values, calldatas, gasAmounts, Ballot.VoteType.For); | ||
|
||
uint nonce = 1; | ||
for (uint i = 1; i <= 2; ++i) { | ||
vm.broadcast(governors[i]); | ||
_roninBridgeManager.castProposalVoteForCurrentNetwork(Proposal.ProposalDetail({ | ||
nonce: nonce, | ||
chainId: 2021, | ||
expiryTimestamp: expiredTime, | ||
executor: address(0), | ||
targets: targets, | ||
values: values, | ||
calldatas: calldatas, | ||
gasAmounts: gasAmounts | ||
}), Ballot.VoteType.For); | ||
} | ||
} | ||
} |
118 changes: 118 additions & 0 deletions
118
script/20240612-maptoken-nft-sepolia/20240613-maptoken-erc1155-sepolia.s.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import { console2 } from "forge-std/console2.sol"; | ||
import { StdStyle } from "forge-std/StdStyle.sol"; | ||
import { RoninBridgeManager } from "@ronin/contracts/ronin/gateway/RoninBridgeManager.sol"; | ||
import { IMainchainGatewayV3 } from "@ronin/contracts/interfaces/IMainchainGatewayV3.sol"; | ||
import { GlobalProposal } from "@ronin/contracts/libraries/GlobalProposal.sol"; | ||
import { LibTokenInfo, TokenStandard } from "@ronin/contracts/libraries/LibTokenInfo.sol"; | ||
import { Contract } from "../utils/Contract.sol"; | ||
import { Network } from "../utils/Network.sol"; | ||
import { Contract } from "../utils/Contract.sol"; | ||
import "@ronin/contracts/mainchain/MainchainBridgeManager.sol"; | ||
import "@ronin/contracts/mainchain/MainchainGatewayV3.sol"; | ||
import "@ronin/contracts/libraries/Proposal.sol"; | ||
import "@ronin/contracts/libraries/Ballot.sol"; | ||
|
||
import { MockUSDC } from "@ronin/contracts/mocks/token/MockUSDC.sol"; | ||
import { USDCDeploy } from "@ronin/script/contracts/token/USDCDeploy.s.sol"; | ||
import { MainchainBridgeAdminUtils } from "test/helpers/MainchainBridgeAdminUtils.t.sol"; | ||
|
||
import "../Migration.s.sol"; | ||
|
||
contract Migration__20240613_MapERC1155SepoliaMainchain is Migration { | ||
address internal _mainchainPauseEnforcer; | ||
address internal _mainchainGatewayV3; | ||
address internal _mainchainBridgeManager; | ||
|
||
MainchainBridgeAdminUtils _mainchainProposalUtils; | ||
|
||
function setUp() public override { | ||
super.setUp(); | ||
|
||
_mainchainPauseEnforcer = 0x61eC0ebf966AE84C414BDA715E17CeF657e039DF; | ||
_mainchainGatewayV3 = 0x06855f31dF1d3D25cE486CF09dB49bDa535D2a9e; | ||
_mainchainBridgeManager = 0x603075B625cc2cf69FbB3546C6acC2451FE792AF; | ||
} | ||
|
||
function run() public { | ||
address[] memory mainchainTokens = new address[](1); | ||
address[] memory roninTokens = new address[](1); | ||
TokenStandard[] memory standards = new TokenStandard[](1); | ||
uint256[][4] memory thresholds; | ||
thresholds[0] = new uint256[](1); | ||
thresholds[1] = new uint256[](1); | ||
thresholds[2] = new uint256[](1); | ||
thresholds[3] = new uint256[](1); | ||
|
||
uint256 expiredTime = block.timestamp + 10 days; | ||
address[] memory targets = new address[](1); | ||
uint256[] memory values = new uint256[](1); | ||
bytes[] memory calldatas = new bytes[](1); | ||
uint256[] memory gasAmounts = new uint256[](1); | ||
|
||
// ================ USDC ERC-20 ====================== | ||
|
||
mainchainTokens[0] = address(0xFBb71EEE2B420ea88e663B91722b41966E1C5F17); | ||
roninTokens[0] = address(0xDBB04B4BdBb385EB14cb3ea3C7B1FCcA55ea9160); | ||
standards[0] = TokenStandard.ERC1155; | ||
thresholds[0][0] = 0; | ||
thresholds[1][0] = 0; | ||
thresholds[2][0] = 0; | ||
thresholds[3][0] = 0; | ||
|
||
bytes memory innerData = abi.encodeCall(IMainchainGatewayV3.mapTokensAndThresholds, (mainchainTokens, roninTokens, standards, thresholds)); | ||
|
||
vm.prank(_mainchainBridgeManager); | ||
address(_mainchainGatewayV3).call(abi.encodeWithSignature("functionDelegateCall(bytes)", innerData)); | ||
|
||
// return; | ||
|
||
bytes memory proxyData = abi.encodeWithSignature("functionDelegateCall(bytes)", innerData); | ||
|
||
targets[0] = _mainchainGatewayV3; | ||
values[0] = 0; | ||
calldatas[0] = proxyData; | ||
gasAmounts[0] = 1_000_000; | ||
|
||
// ================ VERIFY AND EXECUTE PROPOSAL =============== | ||
|
||
uint256[] memory governorPKs = new uint256[](4); | ||
governorPKs[3] = 0x00; | ||
governorPKs[2] = 0x00; | ||
governorPKs[0] = 0x00; | ||
governorPKs[1] = 0x00; | ||
|
||
address[] memory governors = new address[](4); | ||
governors[3] = 0xd24D87DDc1917165435b306aAC68D99e0F49A3Fa; | ||
governors[2] = 0xb033ba62EC622dC54D0ABFE0254e79692147CA26; | ||
governors[0] = 0x087D08e3ba42e64E3948962dd1371F906D1278b9; | ||
governors[1] = 0x52ec2e6BBcE45AfFF8955Da6410bb13812F4289F; | ||
|
||
_mainchainProposalUtils = new MainchainBridgeAdminUtils(2021, governorPKs, MainchainBridgeManager(_mainchainBridgeManager), governors[0]); | ||
|
||
Proposal.ProposalDetail memory proposal = Proposal.ProposalDetail({ | ||
nonce: MainchainBridgeManager(_mainchainBridgeManager).round(11155111) + 1, | ||
chainId: block.chainid, | ||
expiryTimestamp: expiredTime, | ||
executor: address(0), | ||
targets: targets, | ||
values: values, | ||
calldatas: calldatas, | ||
gasAmounts: gasAmounts | ||
}); | ||
|
||
Ballot.VoteType[] memory supports_ = new Ballot.VoteType[](4); | ||
supports_[0] = Ballot.VoteType.For; | ||
supports_[1] = Ballot.VoteType.For; | ||
supports_[2] = Ballot.VoteType.For; | ||
supports_[3] = Ballot.VoteType.For; | ||
|
||
SignatureConsumer.Signature[] memory signatures = _mainchainProposalUtils.generateSignatures(proposal, governorPKs); | ||
|
||
vm.broadcast(governors[0]); | ||
// 2_000_000 to assure tx.gasleft is bigger than the gas of the proposal. | ||
MainchainBridgeManager(_mainchainBridgeManager).relayProposal{gas: 2_000_000}(proposal, supports_, signatures); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
script/20240619-upgrade-sepolia/20240619-operators-key.s.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
contract Migration__20240619_GovernorsKey { | ||
function _loadGovernorPKs() internal pure returns (uint256[] memory res) { | ||
res = new uint256[](4); | ||
|
||
res[0] = 0x00; | ||
res[1] = 0x00; | ||
res[2] = 0x00; | ||
res[3] = 0x00; | ||
} | ||
} |
109 changes: 109 additions & 0 deletions
109
script/20240619-upgrade-sepolia/20240619-p3-upgrade-bridge-main-chain.s.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import { console2 } from "forge-std/console2.sol"; | ||
import { StdStyle } from "forge-std/StdStyle.sol"; | ||
import { MainchainBridgeManager } from "@ronin/contracts/mainchain/MainchainBridgeManager.sol"; | ||
import { IMainchainGatewayV3 } from "@ronin/contracts/interfaces/IMainchainGatewayV3.sol"; | ||
import { GlobalProposal } from "@ronin/contracts/libraries/GlobalProposal.sol"; | ||
import { LibTokenInfo, TokenStandard } from "@ronin/contracts/libraries/LibTokenInfo.sol"; | ||
import { Contract } from "../utils/Contract.sol"; | ||
import { Network } from "../utils/Network.sol"; | ||
import { Contract } from "../utils/Contract.sol"; | ||
import { ISharedArgument } from "../interfaces/ISharedArgument.sol"; | ||
import "@ronin/contracts/mainchain/MainchainBridgeManager.sol"; | ||
import "@ronin/contracts/mainchain/MainchainGatewayV3.sol"; | ||
import "@ronin/contracts/libraries/Proposal.sol"; | ||
import "@ronin/contracts/libraries/Ballot.sol"; | ||
|
||
import { LibProxy } from "@fdk/libraries/LibProxy.sol"; | ||
import { DefaultContract } from "@fdk/utils/DefaultContract.sol"; | ||
import { MockSLP } from "@ronin/contracts/mocks/token/MockSLP.sol"; | ||
import { SLPDeploy } from "@ronin/script/contracts/token/SLPDeploy.s.sol"; | ||
import { MainchainBridgeAdminUtils } from "test/helpers/MainchainBridgeAdminUtils.t.sol"; | ||
import "@ronin/script/contracts/MainchainBridgeManagerDeploy.s.sol"; | ||
import "@ronin/script/contracts/MainchainWethUnwrapperDeploy.s.sol"; | ||
|
||
import "../20240411-upgrade-v3.2.0-testnet/20240411-helper.s.sol"; | ||
import "./20240619-operators-key.s.sol"; | ||
import "../Migration.s.sol"; | ||
|
||
contract Migration__20240619_P3_UpgradeBridgeMainchain is Migration, Migration__20240619_GovernorsKey { | ||
MainchainBridgeManager _mainchainBridgeManager; | ||
MainchainBridgeAdminUtils _mainchainProposalUtils; | ||
|
||
address private _governor; | ||
address[] private _voters; | ||
|
||
address TESTNET_ADMIN = 0x968D0Cd7343f711216817E617d3f92a23dC91c07; | ||
|
||
function setUp() public virtual override { | ||
super.setUp(); | ||
} | ||
|
||
function run() public virtual onlyOn(Network.Sepolia.key()) { | ||
CONFIG.setAddress(network(), DefaultContract.ProxyAdmin.key(), TESTNET_ADMIN); | ||
|
||
_mainchainBridgeManager = MainchainBridgeManager(config.getAddressFromCurrentNetwork(Contract.MainchainBridgeManager.key())); | ||
|
||
_governor = 0xd24D87DDc1917165435b306aAC68D99e0F49A3Fa; | ||
_voters.push(0xb033ba62EC622dC54D0ABFE0254e79692147CA26); | ||
_voters.push(0x087D08e3ba42e64E3948962dd1371F906D1278b9); | ||
_voters.push(0x52ec2e6BBcE45AfFF8955Da6410bb13812F4289F); | ||
|
||
_upgradeBridgeMainchain(); | ||
} | ||
|
||
function _upgradeBridgeMainchain() internal { | ||
address mainchainGatewayV3Logic = _deployLogic(Contract.MainchainGatewayV3.key()); | ||
address mainchainGatewayV3Proxy = config.getAddressFromCurrentNetwork(Contract.MainchainGatewayV3.key()); | ||
|
||
ISharedArgument.SharedParameter memory param; | ||
param.mainchainBridgeManager.callbackRegisters = new address[](1); | ||
param.mainchainBridgeManager.callbackRegisters[0] = config.getAddressFromCurrentNetwork(Contract.MainchainGatewayV3.key()); | ||
|
||
uint256 expiredTime = block.timestamp + 14 days; | ||
uint N = 1; | ||
address[] memory targets = new address[](N); | ||
uint256[] memory values = new uint256[](N); | ||
bytes[] memory calldatas = new bytes[](N); | ||
uint256[] memory gasAmounts = new uint256[](N); | ||
|
||
targets[0] = mainchainGatewayV3Proxy; | ||
calldatas[0] = abi.encodeWithSignature("upgradeTo(address)", mainchainGatewayV3Logic); | ||
gasAmounts[0] = 1_000_000; | ||
|
||
// ================ VERIFY AND EXECUTE PROPOSAL =============== | ||
|
||
address[] memory governors = new address[](4); | ||
governors[3] = 0xd24D87DDc1917165435b306aAC68D99e0F49A3Fa; | ||
governors[2] = 0xb033ba62EC622dC54D0ABFE0254e79692147CA26; | ||
governors[0] = 0x087D08e3ba42e64E3948962dd1371F906D1278b9; | ||
governors[1] = 0x52ec2e6BBcE45AfFF8955Da6410bb13812F4289F; | ||
|
||
_mainchainProposalUtils = new MainchainBridgeAdminUtils(2021, _loadGovernorPKs(), MainchainBridgeManager(_mainchainBridgeManager), governors[0]); | ||
|
||
Proposal.ProposalDetail memory proposal = Proposal.ProposalDetail({ | ||
nonce: MainchainBridgeManager(_mainchainBridgeManager).round(block.chainid) + 1, | ||
chainId: block.chainid, | ||
expiryTimestamp: expiredTime, | ||
executor: address(0), | ||
targets: targets, | ||
values: values, | ||
calldatas: calldatas, | ||
gasAmounts: gasAmounts | ||
}); | ||
|
||
Ballot.VoteType[] memory supports_ = new Ballot.VoteType[](4); | ||
supports_[0] = Ballot.VoteType.For; | ||
supports_[1] = Ballot.VoteType.For; | ||
supports_[2] = Ballot.VoteType.For; | ||
supports_[3] = Ballot.VoteType.For; | ||
|
||
SignatureConsumer.Signature[] memory signatures = _mainchainProposalUtils.generateSignatures(proposal, _loadGovernorPKs()); | ||
|
||
vm.broadcast(governors[0]); | ||
// 2_000_000 to assure tx.gasleft is bigger than the gas of the proposal. | ||
MainchainBridgeManager(_mainchainBridgeManager).relayProposal{gas: 2_000_000}(proposal, supports_, signatures); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters