Skip to content

Commit

Permalink
fix: upd deploy scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
DhairyaSethi committed Oct 22, 2024
1 parent 4cdc830 commit 3b8c822
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 54 deletions.
45 changes: 19 additions & 26 deletions contracts/script/ghoCcipMigration/ArbSepolia.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,17 @@ import {Script, console} from "forge-std/Script.sol";
import {TransparentUpgradeableProxy} from "solidity-utils/contracts/transparent-proxy/TransparentUpgradeableProxy.sol";
import {UpgradeableBurnMintTokenPool_ArbSepolia} from "../../src/v0.8/ccip/test/pools/GHO/fork/GhoTokenPoolMigrate1_4To1_5/LegacyTestnetTokenPools/UpgradeableBurnMintTokenPool_ArbSepolia.sol";

interface Vm {
function promptSecretUint(string memory) external returns (uint256);
}
/// Usage
/// Upgrade Implementation: forge script script/ghoCcipMigration/ArbSepolia.s.sol --fork-url arb_sepolia --sig "upgrade()" --etherscan-verifier-url https://api-sepolia.etherscan.io/api --account <ProxyAdminAccount>
/// Set Proxy Pool: forge script script/ghoCcipMigration/ArbSepolia.s.sol --fork-url arb_sepolia --sig "setProxyPool()" --account <TokenPoolOwnerAccount>

// forge script script/ghoCcipMigration/ArbSepolia.s.sol --fork-url arb_sepolia --sig "run(address)" 0x2BDbDCC0957E8d9f5Eb1Fe8E1Bc0d7F57AD1C897 --etherscan-verifier-url https://api-sepolia.arbiscan.io/api
contract TestnetMigration is Script {
struct StaticParams {
address token;
address armProxy;
bool allowListEnabled;
}

uint256 private proxyAdminPk;
uint256 private ownerPk;
UpgradeableBurnMintTokenPool_ArbSepolia private tokenPoolProxy;

address private constant PROXY_POOL = 0x2BDbDCC0957E8d9f5Eb1Fe8E1Bc0d7F57AD1C897; // match address
Expand All @@ -31,21 +28,10 @@ contract TestnetMigration is Script {
}

function setUp() public {
// proxyAdminPk = vm.envUint("proxyAdminPk");
// ownerPk = vm.envUint("ownerPk");
proxyAdminPk = Vm(address(vm)).promptSecretUint("proxyAdminPk");
ownerPk = Vm(address(vm)).promptSecretUint("ownerPk");

tokenPoolProxy = UpgradeableBurnMintTokenPool_ArbSepolia(0x3eC2b6F818B72442fc36561e9F930DD2b60957D2);

address proxyAdminAddress = address(
uint160(uint256(vm.load(address(tokenPoolProxy), bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1))))
);
if (vm.addr(proxyAdminPk) != proxyAdminAddress) revert InvalidSigner(vm.addr(proxyAdminPk), proxyAdminAddress);
if (vm.addr(ownerPk) != tokenPoolProxy.owner()) revert InvalidSigner(vm.addr(ownerPk), tokenPoolProxy.owner());
}

function run(address proxyPool) public onlyArbSepolia {
function upgrade() public onlyArbSepolia {
StaticParams memory params = StaticParams({
token: address(tokenPoolProxy.getToken()),
armProxy: tokenPoolProxy.getArmProxy(),
Expand All @@ -59,22 +45,29 @@ contract TestnetMigration is Script {
console.log("StaticParams.allowListEnabled:", params.allowListEnabled);

// deploy implementation
vm.broadcast(ownerPk);
vm.broadcast();
address newPool = _deployBurnMintTokenPool(params);
console.log("newPool: \t\t\t", newPool);

// sanity storage check
assert(tokenPoolProxy.getRouter() == router);
// static params checks
assert(address(tokenPoolProxy.getToken()) == params.token);
assert(tokenPoolProxy.getArmProxy() == params.armProxy);
assert(tokenPoolProxy.getAllowListEnabled() == params.allowListEnabled);

// upgrade proxy
vm.broadcast(proxyAdminPk);
vm.broadcast();
TransparentUpgradeableProxy(payable(address(tokenPoolProxy))).upgradeTo(newPool);
}

// set proxyPool
vm.broadcast(ownerPk);
tokenPoolProxy.setProxyPool(proxyPool);
function setProxyPool() public onlyArbSepolia {
console.log("Setting proxy pool to:", PROXY_POOL);

assert(tokenPoolProxy.getProxyPool() == proxyPool);
vm.broadcast();
tokenPoolProxy.setProxyPool(PROXY_POOL);

// sanity storage check
assert(tokenPoolProxy.getRouter() == router);
assert(tokenPoolProxy.getProxyPool() == PROXY_POOL);
}

function _deployBurnMintTokenPool(StaticParams memory params) internal returns (address) {
Expand Down
52 changes: 24 additions & 28 deletions contracts/script/ghoCcipMigration/Sepolia.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import {Script, console} from "forge-std/Script.sol";
import {TransparentUpgradeableProxy} from "solidity-utils/contracts/transparent-proxy/TransparentUpgradeableProxy.sol";
import {UpgradeableLockReleaseTokenPool_Sepolia} from "../../src/v0.8/ccip/test/pools/GHO/fork/GhoTokenPoolMigrate1_4To1_5/LegacyTestnetTokenPools/UpgradeableLockReleaseTokenPool_Sepolia.sol";

interface Vm {
function promptSecretUint(string memory) external returns (uint256);
}

// forge script script/ghoCcipMigration/Sepolia.s.sol --fork-url sepolia --sig "run(address)" 0x14A3298f667CCB3ad4B77878d80b353f6A10F183 --etherscan-verifier-url https://api-sepolia.etherscan.io/api
/// Usage
/// Upgrade Implementation: forge script script/ghoCcipMigration/Sepolia.s.sol --fork-url sepolia --sig "upgrade()" --etherscan-verifier-url https://api-sepolia.etherscan.io/api --account <ProxyAdminAccount>
/// Set Proxy Pool: forge script script/ghoCcipMigration/Sepolia.s.sol --fork-url sepolia --sig "setProxyPool()" --account <TokenPoolOwnerAccount>
contract TestnetMigration is Script {
struct StaticParams {
address token;
Expand All @@ -17,8 +15,6 @@ contract TestnetMigration is Script {
bool acceptLiquidity;
}

uint256 private proxyAdminPk;
uint256 private ownerPk;
UpgradeableLockReleaseTokenPool_Sepolia private tokenPoolProxy;

address private constant PROXY_POOL = 0x14A3298f667CCB3ad4B77878d80b353f6A10F183; // match address
Expand All @@ -32,21 +28,10 @@ contract TestnetMigration is Script {
}

function setUp() public {
// proxyAdminPk = vm.envUint("proxyAdminPk");
// ownerPk = vm.envUint("ownerPk");
proxyAdminPk = Vm(address(vm)).promptSecretUint("proxyAdminPk");
ownerPk = Vm(address(vm)).promptSecretUint("ownerPk");

tokenPoolProxy = UpgradeableLockReleaseTokenPool_Sepolia(0x7768248E1Ff75612c18324bad06bb393c1206980);

address proxyAdminAddress = address(
uint160(uint256(vm.load(address(tokenPoolProxy), bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1))))
);
if (vm.addr(proxyAdminPk) != proxyAdminAddress) revert InvalidSigner(vm.addr(proxyAdminPk), proxyAdminAddress);
if (vm.addr(ownerPk) != tokenPoolProxy.owner()) revert InvalidSigner(vm.addr(ownerPk), tokenPoolProxy.owner());
}

function run(address proxyPool) public onlySepolia {
function upgrade() public onlySepolia {
StaticParams memory params = StaticParams({
token: address(tokenPoolProxy.getToken()),
armProxy: tokenPoolProxy.getArmProxy(),
Expand All @@ -63,23 +48,34 @@ contract TestnetMigration is Script {
console.log("StaticParams.acceptLiquidity: ", params.acceptLiquidity);

// deploy implementation
vm.broadcast(ownerPk);
vm.broadcast();
address newPool = _deployLockReleaseTokenPool(params);
console.log("newPool: \t\t\t", newPool);

// sanity storage checks
assert(tokenPoolProxy.getCurrentBridgedAmount() == bridgedAmount);
assert(tokenPoolProxy.getRouter() == router);
// static params checks
assert(address(tokenPoolProxy.getToken()) == params.token);
assert(tokenPoolProxy.getArmProxy() == params.armProxy);
assert(tokenPoolProxy.getAllowListEnabled() == params.allowListEnabled);
assert(tokenPoolProxy.canAcceptLiquidity() == params.acceptLiquidity);

// upgrade proxy
vm.broadcast(proxyAdminPk);
vm.broadcast();
TransparentUpgradeableProxy(payable(address(tokenPoolProxy))).upgradeTo(newPool);

// set proxyPool
vm.broadcast(ownerPk);
tokenPoolProxy.setProxyPool(proxyPool);
address proxyPool = tokenPoolProxy.getProxyPool();
console.log("proxyPool: \t\t\t", proxyPool);
}

assert(tokenPoolProxy.getProxyPool() == proxyPool);
function setProxyPool() public onlySepolia {
console.log("Setting proxy pool to:", PROXY_POOL);

// sanity storage checks
assert(tokenPoolProxy.getCurrentBridgedAmount() == bridgedAmount);
assert(tokenPoolProxy.getRouter() == router);
vm.broadcast();
tokenPoolProxy.setProxyPool(PROXY_POOL);

assert(tokenPoolProxy.getProxyPool() == PROXY_POOL);
}

function _deployLockReleaseTokenPool(StaticParams memory params) internal returns (address) {
Expand Down

0 comments on commit 3b8c822

Please sign in to comment.