-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nest upgrade script: add more checks to deployment, remove test & get private key from env. #94
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,57 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.25; | ||
|
||
import { AggregateToken } from "../src/AggregateToken.sol"; | ||
import { AggregateTokenProxy } from "../src/proxy/AggregateTokenProxy.sol"; | ||
import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; | ||
import { Script } from "forge-std/Script.sol"; | ||
import { Test } from "forge-std/Test.sol"; | ||
import { console2 } from "forge-std/console2.sol"; | ||
|
||
import { AggregateToken } from "../src/AggregateToken.sol"; | ||
import { AggregateTokenProxy } from "../src/proxy/AggregateTokenProxy.sol"; | ||
|
||
contract UpgradeNestContracts is Script, Test { | ||
contract UpgradeNestContracts is Script { | ||
|
||
address private constant NEST_ADMIN_ADDRESS = 0xb015762405De8fD24d29A6e0799c12e0Ea81c1Ff; | ||
|
||
UUPSUpgradeable private constant AGGREGATE_TOKEN_PROXY = | ||
UUPSUpgradeable(payable(0x659619AEdf381c3739B0375082C2d61eC1fD8835)); | ||
|
||
function test() public { } | ||
|
||
function run() external { | ||
vm.startBroadcast(NEST_ADMIN_ADDRESS); | ||
|
||
AggregateToken newAggregateTokenImpl = new AggregateToken(); | ||
assertGt(address(newAggregateTokenImpl).code.length, 0, "AggregateToken should be deployed"); | ||
console2.log("New AggregateToken Implementation deployed to:", address(newAggregateTokenImpl)); | ||
// Get private key from environment | ||
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); | ||
address deployer = vm.addr(deployerPrivateKey); | ||
|
||
console2.log("Deploying with address:", deployer); | ||
|
||
if (deployer == NEST_ADMIN_ADDRESS) { | ||
AggregateToken newAggregateTokenImpl = new AggregateToken(); | ||
address newImplAddress = address(newAggregateTokenImpl); | ||
|
||
require(address(newAggregateTokenImpl).code.length > 0, "Implementation contract 0 byte code"); | ||
|
||
console2.log("New AggregateToken Implementation deployed to:", address(newAggregateTokenImpl)); | ||
|
||
AGGREGATE_TOKEN_PROXY.upgradeToAndCall(address(newAggregateTokenImpl), ""); | ||
|
||
// Get implementation address after upgrade | ||
address implAddress = address( | ||
uint160( | ||
uint256( | ||
vm.load( | ||
address(AGGREGATE_TOKEN_PROXY), | ||
// ERC1967 IMPLEMENTATION storage slot | ||
0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you make this into a constant? |
||
) | ||
) | ||
) | ||
); | ||
|
||
require(implAddress == newImplAddress, "Implementation address mismatch"); | ||
|
||
AGGREGATE_TOKEN_PROXY.upgradeToAndCall(address(newAggregateTokenImpl), ""); | ||
console2.log("Upgrade completed successfully"); | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should already automatically fail because |
||
console2.log("we need NEST_ADMIN_ADDRESS PK to upgrade AggregateToken, please try again with correct PK."); | ||
} | ||
|
||
vm.stopBroadcast(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should keep the
test()
so it doesn't show up inforge coverage
as untested?