Skip to content

Commit 0fa83df

Browse files
authored
Merge pull request #18 from push-protocol/17-deployment-scripts-and-set-up
17 deployment scripts and set up
2 parents 4eb8650 + e96460b commit 0fa83df

File tree

9 files changed

+133
-42
lines changed

9 files changed

+133
-42
lines changed

foundry.toml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,25 @@ ffi = true
1616
ast = true
1717
build_info = true
1818
extra_output = ["storageLayout"]
19+
20+
# RPC Configuration
21+
[rpc_endpoints]
22+
pushchain = "https://evm.rpc-testnet-donut-node1.push.org/"
23+
pushlocalnet = "http://127.0.0.1:8545"
24+
sepolia = "https://sepolia.infura.io/v3/${INFURA_PROJECT_ID}"
25+
mainnet = "https://mainnet.infura.io/v3/${INFURA_PROJECT_ID}"
26+
27+
# Private Keys
28+
[profile.env]
29+
PRIVATE = "${PRIVATE_KEY}"
30+
1931
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
2032
[fmt]
21-
bracket_spacing = true
22-
int_types = "long"
23-
line_length = 120
24-
multiline_func_header = "all"
25-
number_underscore = "thousands"
26-
quote_style = "double"
27-
tab_width = 4
28-
wrap_comments = true
33+
bracket_spacing = true
34+
int_types = "long"
35+
line_length = 120
36+
multiline_func_header = "all"
37+
number_underscore = "thousands"
38+
quote_style = "double"
39+
tab_width = 4
40+
wrap_comments = true

hardhat.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module.exports = {
3333
},
3434

3535
pushchain: {
36-
url: "https://evm.pn1.dev.push.org",
36+
url: "https://evm.rpc-testnet-donut-node1.push.org/",
3737
accounts: [process.env.PRIVATE]
3838
,
3939
},
@@ -47,6 +47,10 @@ module.exports = {
4747
url: `https://sepolia.infura.io/v3/${process.env.INFURA_PROJECT_ID}`,
4848
accounts: [process.env.PRIVATE]
4949

50+
},
51+
mainnet: {
52+
url: `https://mainnet.infura.io/v3/${process.env.INFURA_PROJECT_ID}`,
53+
accounts: [process.env.PRIVATE]
5054
}
5155
},
5256
};

script/legacyDeployment/DeployRelease.js renamed to script/deploy/HardhatDeployRelease.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ async function main() {
2727
main().catch((err) => {
2828
console.error("Error in deploy script:", err);
2929
process.exit(1);
30-
});
30+
});

script/legacyDeployment/DeployLocker.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

script/testUtils/getPoof.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const whitelist = require("../../output/claims.json");
1+
const whitelist = require("../../output/migration-list.json");
22
const { getProof } = require("../utils/merkle");
33

44
const user = whitelist[0];
5-
const proof = getProof(user.address, user.amount, whitelist);
5+
const proof = getProof(user.address, user.amount, user.epoch, whitelist);
66
console.log("Merkle Proof for user:", user.address);
77
console.log(proof);

script/testUtils/proofArray.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
const whitelist = require("../../output/claims.json");
1+
const whitelist = require("../../output/migration-list.json");
22
const { getProof, verify } = require("../utils/merkle");
33

44
for (const user of whitelist) {
5-
const proof = getProof(user.address, user.amount, whitelist);
6-
const valid = verify(user.address, user.amount, whitelist);
5+
const proof = getProof(user.address, user.amount, user.epoch, whitelist);
6+
const valid = verify(user.address, user.amount, user.epoch, whitelist);
77

88
console.log("User:", user.address);
99
console.log("Proof:", proof);

script/testUtils/verify.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const whitelist = require("../../output/claims.json");
1+
const whitelist = require("../../output/migration-list.json");
22
const { verify } = require("../utils/merkle");
33

44
const user = whitelist[0];
5-
const isValid = verify(user.address, user.amount, whitelist);
5+
const isValid = verify(user.address, user.amount, user.epoch, whitelist);
66
console.log("Proof valid?", isValid);

script/upgrade/UpgradeLocker.s.sol

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// SPDX-License-Identifier: SEE LICENSE IN LICENSE
2+
pragma solidity 0.8.29;
3+
4+
import "forge-std/Script.sol";
5+
import "../../src/MigrationLocker.sol";
6+
import { ITransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
7+
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
8+
9+
/**
10+
* @title UpgradeLocker
11+
* @dev Upgrade script for MigrationLocker contract
12+
* This script handles:
13+
* 1. Deployment of the new implementation contract
14+
* 2. Upgrading the proxy to point to the new implementation
15+
*/
16+
contract UpgradeLockerScript is Script {
17+
// Storage slot for ProxyAdmin in TransparentUpgradeableProxy
18+
bytes32 constant PROXY_ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
19+
20+
function run() external {
21+
// Get private key from environment
22+
uint256 deployerPrivateKey = vm.envUint("DEPLOYER_OWNER");
23+
address deployerAddress = vm.addr(deployerPrivateKey);
24+
25+
// Get proxy address from environment
26+
address proxyAddress = 0xEf9898A2476bd7b3801e9D257d4c39279eF1583c;
27+
28+
vm.startBroadcast(deployerPrivateKey);
29+
30+
console.log("Upgrading contracts with address:", deployerAddress);
31+
console.log("Current proxy address:", proxyAddress);
32+
33+
// Deploy new implementation
34+
MigrationLocker newImplementation = new MigrationLocker();
35+
console.log("New MigrationLocker implementation deployed at:", address(newImplementation));
36+
37+
// Get the proxy admin contract from storage slot
38+
address proxyAdminAddress = address(uint160(uint256(vm.load(proxyAddress, PROXY_ADMIN_SLOT))));
39+
ProxyAdmin proxyAdmin = ProxyAdmin(proxyAdminAddress);
40+
console.log("ProxyAdmin address:", proxyAdminAddress);
41+
42+
// Upgrade the proxy to point to the new implementation
43+
proxyAdmin.upgradeAndCall(
44+
ITransparentUpgradeableProxy(payable(proxyAddress)), address(newImplementation), bytes("")
45+
);
46+
console.log("Proxy upgraded to new implementation");
47+
48+
vm.stopBroadcast();
49+
}
50+
}

script/upgrade/UpgradeRelease.s.sol

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// SPDX-License-Identifier: SEE LICENSE IN LICENSE
2+
pragma solidity 0.8.29;
3+
4+
import "forge-std/Script.sol";
5+
import "../../src/MigrationRelease.sol";
6+
import { ITransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
7+
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
8+
9+
/**
10+
* @title UpgradeRelease
11+
* @dev Upgrade script for MigrationRelease contract
12+
* This script handles:
13+
* 1. Deployment of the new implementation contract
14+
* 2. Upgrading the proxy to point to the new implementation
15+
*/
16+
contract UpgradeReleaseScript is Script {
17+
// Storage slot for ProxyAdmin in TransparentUpgradeableProxy
18+
bytes32 constant PROXY_ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
19+
20+
function run() external {
21+
// Get private key from environment
22+
uint256 deployerPrivateKey = vm.envUint("DEPLOYER_OWNER");
23+
address deployerAddress = vm.addr(deployerPrivateKey);
24+
25+
// Get proxy address from environment
26+
address proxyAddress = 0x95CFE535e2Eea0EB1620fa1d10549b67e284Ba52;
27+
28+
vm.startBroadcast(deployerPrivateKey);
29+
30+
console.log("Upgrading contracts with address:", deployerAddress);
31+
console.log("Current proxy address:", proxyAddress);
32+
33+
// Deploy new implementation
34+
MigrationRelease newImplementation = new MigrationRelease();
35+
console.log("New MigrationRelease implementation deployed at:", address(newImplementation));
36+
37+
// Get the proxy admin contract from storage slot
38+
address proxyAdminAddress = address(uint160(uint256(vm.load(proxyAddress, PROXY_ADMIN_SLOT))));
39+
ProxyAdmin proxyAdmin = ProxyAdmin(proxyAdminAddress);
40+
console.log("ProxyAdmin address:", proxyAdminAddress);
41+
42+
// Upgrade the proxy to point to the new implementation
43+
proxyAdmin.upgradeAndCall(
44+
ITransparentUpgradeableProxy(payable(proxyAddress)), address(newImplementation), bytes("")
45+
);
46+
console.log("Proxy upgraded to new implementation");
47+
48+
vm.stopBroadcast();
49+
}
50+
}

0 commit comments

Comments
 (0)