Skip to content

Commit

Permalink
Add upgrade script
Browse files Browse the repository at this point in the history
  • Loading branch information
karim-en committed Aug 5, 2024
1 parent 02d3f22 commit d44af96
Show file tree
Hide file tree
Showing 4 changed files with 221 additions and 1 deletion.
169 changes: 169 additions & 0 deletions eth-custodian/.openzeppelin/sepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,175 @@
]
}
}
},
"11c941e83dcf4b3077416195d38866dd6a19bfa50b4b6f48b442e18bd8d9a69a": {
"address": "0x47996EC1CE791225DcA05fDC7d7eB74e552c05e6",
"txHash": "0x647557339ffd586f4de322a9b23915952cb61c421530a6211fac13e864849db9",
"layout": {
"solcVersion": "0.8.20",
"storage": [
{
"label": "__gap",
"offset": 0,
"slot": "0",
"type": "t_array(t_uint256)50_storage",
"contract": "ProofKeeperGap",
"src": "contracts/ProofKeeperGap.sol:7"
},
{
"label": "_pausedFlags",
"offset": 0,
"slot": "50",
"type": "t_uint256",
"contract": "SelectivePausableUpgradable",
"src": "contracts/SelectivePausableUpgradable.sol:37"
},
{
"label": "preMigrationProducerAccount",
"offset": 0,
"slot": "51",
"type": "t_bytes_storage",
"contract": "EthCustodianProxy",
"src": "contracts/EthCustodianProxy.sol:33"
},
{
"label": "migrationBlockHeight",
"offset": 0,
"slot": "52",
"type": "t_uint64",
"contract": "EthCustodianProxy",
"src": "contracts/EthCustodianProxy.sol:34"
},
{
"label": "ethCustodianImpl",
"offset": 8,
"slot": "52",
"type": "t_contract(EthCustodian)2368",
"contract": "EthCustodianProxy",
"src": "contracts/EthCustodianProxy.sol:36"
}
],
"types": {
"t_address": {
"label": "address",
"numberOfBytes": "20"
},
"t_bool": {
"label": "bool",
"numberOfBytes": "1"
},
"t_bytes32": {
"label": "bytes32",
"numberOfBytes": "32"
},
"t_mapping(t_address,t_bool)": {
"label": "mapping(address => bool)",
"numberOfBytes": "32"
},
"t_mapping(t_bytes32,t_struct(RoleData)25_storage)": {
"label": "mapping(bytes32 => struct AccessControlUpgradeable.RoleData)",
"numberOfBytes": "32"
},
"t_struct(AccessControlStorage)35_storage": {
"label": "struct AccessControlUpgradeable.AccessControlStorage",
"members": [
{
"label": "_roles",
"type": "t_mapping(t_bytes32,t_struct(RoleData)25_storage)",
"offset": 0,
"slot": "0"
}
],
"numberOfBytes": "32"
},
"t_struct(InitializableStorage)95_storage": {
"label": "struct Initializable.InitializableStorage",
"members": [
{
"label": "_initialized",
"type": "t_uint64",
"offset": 0,
"slot": "0"
},
{
"label": "_initializing",
"type": "t_bool",
"offset": 8,
"slot": "0"
}
],
"numberOfBytes": "32"
},
"t_struct(RoleData)25_storage": {
"label": "struct AccessControlUpgradeable.RoleData",
"members": [
{
"label": "hasRole",
"type": "t_mapping(t_address,t_bool)",
"offset": 0,
"slot": "0"
},
{
"label": "adminRole",
"type": "t_bytes32",
"offset": 0,
"slot": "1"
}
],
"numberOfBytes": "64"
},
"t_uint64": {
"label": "uint64",
"numberOfBytes": "8"
},
"t_array(t_uint256)50_storage": {
"label": "uint256[50]",
"numberOfBytes": "1600"
},
"t_bytes_storage": {
"label": "bytes",
"numberOfBytes": "32"
},
"t_contract(EthCustodian)2368": {
"label": "contract EthCustodian",
"numberOfBytes": "20"
},
"t_uint256": {
"label": "uint256",
"numberOfBytes": "32"
}
},
"namespaces": {
"erc7201:openzeppelin.storage.AccessControl": [
{
"contract": "AccessControlUpgradeable",
"label": "_roles",
"type": "t_mapping(t_bytes32,t_struct(RoleData)25_storage)",
"src": "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol:61",
"offset": 0,
"slot": "0"
}
],
"erc7201:openzeppelin.storage.Initializable": [
{
"contract": "Initializable",
"label": "_initialized",
"type": "t_uint64",
"src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:69",
"offset": 0,
"slot": "0"
},
{
"contract": "Initializable",
"label": "_initializing",
"type": "t_bool",
"src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:73",
"offset": 8,
"slot": "0"
}
]
}
}
}
}
}
3 changes: 3 additions & 0 deletions eth-custodian/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ eth-deploy-contracts:
eth-deploy-proxy:
yarn hardhat run --network ${NETWORK} scripts/eth_deploy_proxy.js

eth-upgrade-proxy:
yarn hardhat run --network ${NETWORK} scripts/eth_upgrade_proxy.js

update-admin-legacy:
yarn hardhat --network ${NETWORK} update-admin-legacy --new-admin ${ETH_CUSTODIAN_PROXY}

Expand Down
47 changes: 47 additions & 0 deletions eth-custodian/scripts/eth_upgrade_proxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const hre = require('hardhat');
const ethereumConfig = require("./json/ethereum-config.json");

async function main() {
const [signer] = await hre.ethers.getSigners();
console.log("Upgrading contracts with the account:", signer.address);
console.log(
"Account balance:",
(await signer.provider.getBalance(signer.address)).toString()
);

const EthCustodianProxy = (
await hre.ethers.getContractFactory("EthCustodianProxy")
).connect(signer);

const proxyAddress = ethereumConfig.proxyAddress;
console.log(
"Current implementation address:",
await hre.upgrades.erc1967.getImplementationAddress(proxyAddress)
);
console.log(
"Upgrade EthCustodianProxy contract, proxy address",
proxyAddress
);
const proxy = await hre.upgrades.upgradeProxy(
proxyAddress,
EthCustodianProxy,
{
gasLimit: 6000000,
}
);
await proxy.waitForDeployment();

console.log(
"EthCustodianProxy impl deployed to: ",
await hre.upgrades.erc1967.getImplementationAddress(
await proxy.getAddress()
)
);
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
3 changes: 2 additions & 1 deletion eth-custodian/scripts/json/ethereum-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"clientAddress": "0x202cdf10bfa45a3d2190901373edd864f071d707",
"ethConnectorAddress": "0xe0320b199863D7f6D5bBa62741aACB312110DEf7",
"nearEvmAccount": "aurora",
"bridgeFactoryAccount": "factory.sepolia.testnet"
"bridgeFactoryAccount": "factory.sepolia.testnet",
"proxyAddress": "0x4C8afA2fD22dB1c6091A96c382e6546529475B5c"
}

0 comments on commit d44af96

Please sign in to comment.