Skip to content

Commit b9481fe

Browse files
authored
script: add migration script for release/v0.3.4 (#198)
2 parents c96a4d6 + b413651 commit b9481fe

File tree

49 files changed

+1177
-606
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1177
-606
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ docs/
2020
node_modules/
2121
yarn-error.log
2222
.yarn
23-
.yarnrc.yml
23+
.yarnrc.yml
24+
script/data/*

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@
2222
[submodule "lib/foundry-deployment-kit"]
2323
path = lib/foundry-deployment-kit
2424
url = https://github.com/axieinfinity/foundry-deployment-kit
25+
[submodule "lib/contract-libs"]
26+
path = lib/contract-libs
27+
url = https://github.com/axieinfinity/contract-libs

config.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ loadConfig() {
2828
ERC721_BATCH_TRANSFER=0x2368dfed532842db89b470fde9fd584d48d4f644
2929

3030
if [ "$MODE" == "broadcast" ]; then
31-
PK=$TESTNET_PK
31+
PK=$MAINNET_PK
3232
fi
3333
else
3434
RPC=$TESTNET_URL
@@ -37,18 +37,20 @@ loadConfig() {
3737
ERC721_BATCH_TRANSFER=0x2e889348bd37f192063bfec8ff39bd3635949e20
3838

3939
if [ "$MODE" == "broadcast" ]; then
40-
PK=$MAINNET_PK
40+
PK=$TESTNET_PK
4141
fi
4242
fi
4343

4444
if [ "$MODE" == "broadcast" ]; then
45-
CURRENT_NONCE=$(cast nonce --rpc-url $RPC $FROM)
4645
CURRENT_GAS_PRICE=$(cast gas-price --rpc-url $RPC)
4746

4847
if [[ "$PK" == op://* ]]; then
4948
PK=$(op read "$PK")
5049
fi
5150
fi
51+
52+
CURRENT_NONCE=$(cast nonce --rpc-url $RPC $FROM)
53+
echo "Current nonce: $CURRENT_NONCE"
5254
}
5355

5456
# Function to load address from deployment file

debug.sh

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1 @@
1-
# Source (or "dot") the .env file to load environment variables
2-
if [ -f .env ]; then
3-
source .debug.env
4-
else
5-
echo "Error: .debug.env file not found."
6-
fi
7-
8-
verify_arg=""
9-
extra_argument=""
10-
op_command=""
11-
12-
for arg in "$@"; do
13-
case $arg in
14-
--trezor)
15-
op_command=""
16-
extra_argument+=trezor@
17-
;;
18-
--broadcast)
19-
op_command="op run --env-file="./.env" --"
20-
;;
21-
--log)
22-
set -- "${@/#--log/}"
23-
extra_argument+=log@
24-
;;
25-
*) ;;
26-
esac
27-
done
28-
29-
# Remove the @ character from the end of extra_argument
30-
extra_argument="${extra_argument%%@}"
31-
32-
echo Debug Tx...
33-
echo From: ${FROM}
34-
echo To: ${TO}
35-
echo Value: ${VALUE}
36-
echo Calldata:
37-
cast pretty-calldata ${CALLDATA}
38-
calldata=$(cast calldata 'debug(uint256,address,address,uint256,bytes)' ${BLOCK} ${FROM} ${TO} ${VALUE} ${CALLDATA})
39-
${op_command} forge script ${verify_arg} --legacy ${@} script/Debug.s.sol --sig 'run(bytes,string)' ${calldata} "${extra_argument}"
1+
source lib/foundry-deployment-kit/debug.sh

foundry.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ bracket_spacing = true
1919
[rpc_endpoints]
2020
ethereum = "https://eth.llamarpc.com"
2121
goerli = "https://ethereum-goerli.publicnode.com"
22-
ronin-mainnet = "https://api.roninchain.com/rpc"
22+
ronin-mainnet = "https://api-partner.roninchain.com/rpc"
2323
ronin-testnet = "https://saigon-archive.roninchain.com/rpc"
2424
localhost = "http://localhost:8545"
2525

lib/contract-libs

Submodule contract-libs added at f177e3b

lib/foundry-deployment-kit

run.sh

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1 @@
1-
verify_arg=""
2-
extra_argument=""
3-
op_command="op run --env-file="./.env" --"
4-
5-
for arg in "$@"; do
6-
case $arg in
7-
--trezor)
8-
op_command=""
9-
extra_argument+=trezor@
10-
;;
11-
--broadcast)
12-
op_command="op run --env-file="./.env" --"
13-
# verify_arg="--verify --verifier sourcify --verifier-url https://sourcify.roninchain.com/server/"
14-
;;
15-
--log)
16-
set -- "${@/#--log/}"
17-
extra_argument+=log@
18-
;;
19-
*) ;;
20-
esac
21-
done
22-
23-
# Remove the @ character from the end of extra_argument
24-
extra_argument="${extra_argument%%@}"
25-
26-
calldata=$(cast calldata 'run()')
27-
${op_command} forge script ${verify_arg} --legacy ${@} --sig 'run(bytes,string)' ${calldata} "${extra_argument}"
1+
source lib/foundry-deployment-kit/run.sh

script/20231015-deploy/20231015_Deploy.s.sol

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.19;
33

4-
import { console2 } from "forge-std/console2.sol";
4+
import { console2 as console } from "forge-std/console2.sol";
55
import { StdStyle } from "forge-std/StdStyle.sol";
66
import { Math } from "@openzeppelin/contracts/utils/math/Math.sol";
77
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
88
import { LibRNSDomain } from "@rns-contracts/libraries/LibRNSDomain.sol";
9-
import { ContractKey } from "foundry-deployment-kit/configs/ContractConfig.sol";
9+
import { Contract } from "script/utils/Contract.sol";
1010
import {
1111
RONRegistrarController, RONRegistrarControllerDeploy
1212
} from "script/contracts/RONRegistrarControllerDeploy.s.sol";
@@ -16,12 +16,16 @@ import { NameChecker, NameCheckerDeploy } from "script/contracts/NameCheckerDepl
1616
import { RNSDomainPrice, RNSDomainPriceDeploy } from "script/contracts/RNSDomainPriceDeploy.s.sol";
1717
import { PublicResolver, PublicResolverDeploy } from "script/contracts/PublicResolverDeploy.s.sol";
1818
import { RNSReverseRegistrar, RNSReverseRegistrarDeploy } from "script/contracts/RNSReverseRegistrarDeploy.s.sol";
19-
import { INSDomainPrice, RNSDeploy } from "../RNSDeploy.s.sol";
19+
import { DefaultNetwork, Migration } from "../Migration.s.sol";
20+
import { INSDomainPrice } from "script/interfaces/ISharedArgument.sol";
2021

21-
contract Migration__20231015_Deploy is RNSDeploy {
22+
contract Migration__20231015_Deploy is Migration {
2223
using Strings for *;
2324
using LibRNSDomain for string;
2425

26+
uint256 internal _ronId;
27+
uint256 internal _addrReverseId;
28+
2529
RNSUnified internal _rns;
2630
RNSAuction internal _auction;
2731
NameChecker internal _nameChecker;
@@ -32,7 +36,7 @@ contract Migration__20231015_Deploy is RNSDeploy {
3236

3337
string[] internal _blacklistedWords;
3438

35-
function run() public trySetUp {
39+
function run() public onlyOn(DefaultNetwork.RoninTestnet.key()) {
3640
_rns = new RNSUnifiedDeploy().run();
3741
_auction = new RNSAuctionDeploy().run();
3842
_nameChecker = new NameCheckerDeploy().run();
@@ -48,35 +52,34 @@ contract Migration__20231015_Deploy is RNSDeploy {
4852
}
4953
uint256[] memory packedWords = _nameChecker.packBulk(_blacklistedWords);
5054

51-
vm.resumeGasMetering();
5255
vm.startBroadcast(admin);
5356

5457
_rns.grantRole(_rns.CONTROLLER_ROLE(), address(_auction));
5558
_rns.grantRole(_rns.RESERVATION_ROLE(), address(_auction));
5659
_rns.grantRole(_rns.CONTROLLER_ROLE(), address(_ronController));
5760

58-
(, uint256 ronId) = _rns.mint(0x0, "ron", address(0), admin, _rns.MAX_EXPIRY());
61+
(, _ronId) = _rns.mint(0x0, "ron", address(0), admin, _rns.MAX_EXPIRY());
5962
(, uint256 reverseId) = _rns.mint(0x0, "reverse", address(0), admin, _rns.MAX_EXPIRY());
60-
(, uint256 addrReverseId) = _rns.mint(reverseId, "addr", address(0), admin, _rns.MAX_EXPIRY());
63+
(, _addrReverseId) = _rns.mint(reverseId, "addr", address(0), admin, _rns.MAX_EXPIRY());
6164

6265
_rns.setApprovalForAll(address(_auction), true);
6366
_rns.setApprovalForAll(address(_ronController), true);
64-
_rns.approve(address(_reverseRegistrar), addrReverseId);
67+
_rns.approve(address(_reverseRegistrar), _addrReverseId);
6568

6669
_reverseRegistrar.setDefaultResolver(_publicResolver);
6770
_nameChecker.setForbiddenWords({ packedWords: packedWords, shouldForbid: true });
6871

6972
vm.stopBroadcast();
70-
vm.pauseGasMetering();
73+
}
7174

75+
function _postCheck() internal override {
7276
_validateAuction();
7377
_validateController();
7478
_validateDomainPrice();
7579
_validateReverseRegistrar();
7680
_validateNameChecker();
77-
_validateRNSUnified(ronId, addrReverseId);
78-
79-
console2.log(StdStyle.green(unicode"✅ All checks are passed"));
81+
_validateRNSUnified(_ronId, _addrReverseId);
82+
console.log(unicode"✅ All checks are passed");
8083
}
8184

8285
function _validateController() internal logFn("_validateController") {
@@ -90,7 +93,7 @@ contract Migration__20231015_Deploy is RNSDeploy {
9093
_ronController.computeCommitment(domain, user.addr, duration, secret, address(_publicResolver), data, true);
9194

9295
(, uint256 ronPrice) = _ronController.rentPrice(domain, duration);
93-
console2.log("domain price:", ronPrice);
96+
console.log("domain price:", ronPrice);
9497
vm.deal(user.addr, ronPrice);
9598

9699
vm.startPrank(user.addr);
@@ -103,7 +106,7 @@ contract Migration__20231015_Deploy is RNSDeploy {
103106

104107
uint256 expectedId = uint256(string.concat(domain, ".ron").namehash());
105108
assertEq(_rns.ownerOf(expectedId), user.addr);
106-
console2.log(unicode"✅ Controller checks are passed");
109+
console.log(unicode"✅ Controller checks are passed");
107110
}
108111

109112
function _validateRNSUnified(uint256 ronId, uint256 addrReverseId) internal logFn("validateRNSUnified") {
@@ -113,7 +116,7 @@ contract Migration__20231015_Deploy is RNSDeploy {
113116
assertTrue(_rns.hasRole(_rns.RESERVATION_ROLE(), address(_auction)), "grant reservation role failed");
114117
assertEq(address(_ronController.getPriceOracle()), address(_domainPrice), "set price oracle failed");
115118

116-
console2.log(unicode"✅ RNSUnified checks are passed");
119+
console.log(unicode"✅ RNSUnified checks are passed");
117120
}
118121

119122
function _validateReverseRegistrar() internal logFn("validateReverseRegistrar") {
@@ -146,7 +149,7 @@ contract Migration__20231015_Deploy is RNSDeploy {
146149
assertTrue(_auction.reserved(id), "invalid bulkRegister");
147150
assertEq(_rns.getRecord(id).mut.expiry, _rns.MAX_EXPIRY(), "invalid expiry time");
148151

149-
console2.log(unicode"✅ Auction checks are passed");
152+
console.log(unicode"✅ Auction checks are passed");
150153
}
151154

152155
function _validateDomainPrice() internal logFn("validateDomainPrice") {
@@ -191,12 +194,12 @@ contract Migration__20231015_Deploy is RNSDeploy {
191194

192195
vm.stopPrank();
193196

194-
console2.log("Tax Raio:", _domainPrice.getTaxRatio());
195-
console2.log("Converting 1 USD (18 decimals) to RON:", _domainPrice.convertUSDToRON(1e18));
196-
console2.log("Converting 1 RON to USD (18 decimals):", _domainPrice.convertRONToUSD(1 ether));
197-
console2.log("Converting 1m USD (18 decimals) to RON:", _domainPrice.convertUSDToRON(1e18 * 1e6));
198-
console2.log("Converting 1m RON to USD (18 decimals):", _domainPrice.convertRONToUSD(1 ether * 1e6));
199-
console2.log(unicode"✅ Domain price checks are passed");
197+
console.log("Tax Raio:", _domainPrice.getTaxRatio());
198+
console.log("Converting 1 USD (18 decimals) to RON:", _domainPrice.convertUSDToRON(1e18));
199+
console.log("Converting 1 RON to USD (18 decimals):", _domainPrice.convertRONToUSD(1 ether));
200+
console.log("Converting 1m USD (18 decimals) to RON:", _domainPrice.convertUSDToRON(1e18 * 1e6));
201+
console.log("Converting 1m RON to USD (18 decimals):", _domainPrice.convertRONToUSD(1 ether * 1e6));
202+
console.log(unicode"✅ Domain price checks are passed");
200203
}
201204

202205
function _validateNameChecker() internal logFn("validateNameChecker") {
@@ -208,9 +211,9 @@ contract Migration__20231015_Deploy is RNSDeploy {
208211
uint256 expectedMax;
209212
uint256 expectedMin = type(uint256).max;
210213

211-
console2.log(StdStyle.blue("Blacklisted words count"), blacklistedWords.length);
212-
console2.log(StdStyle.blue("Word"), "RONRegistrarController::valid()", "NameChecker::forbidden()");
213-
console2.log(StdStyle.blue("Word Range"), string.concat("min: ", min.toString(), " ", "max: ", max.toString()));
214+
console.log(StdStyle.blue("Blacklisted words count"), blacklistedWords.length);
215+
console.log(StdStyle.blue("Word"), "RONRegistrarController::valid()", "NameChecker::forbidden()");
216+
console.log(StdStyle.blue("Word Range"), string.concat("min: ", min.toString(), " ", "max: ", max.toString()));
214217

215218
for (uint256 i; i < blacklistedWords.length;) {
216219
word = blacklistedWords[i];
@@ -220,7 +223,7 @@ contract Migration__20231015_Deploy is RNSDeploy {
220223
forbidden = _nameChecker.forbidden(word);
221224

222225
if (i % 50 == 0) {
223-
console2.log(StdStyle.blue(word), valid ? unicode"" : unicode"", forbidden ? unicode"" : unicode"");
226+
console.log(StdStyle.blue(word), valid ? unicode"" : unicode"", forbidden ? unicode"" : unicode"");
224227
}
225228

226229
assertTrue(!valid);
@@ -234,6 +237,6 @@ contract Migration__20231015_Deploy is RNSDeploy {
234237
assertEq(min, expectedMin);
235238
assertEq(max, expectedMax);
236239

237-
console2.log(unicode"✅ NameChecker checks are passed");
240+
console.log(unicode"✅ NameChecker checks are passed");
238241
}
239242
}

0 commit comments

Comments
 (0)