Environment
“@openzeppelin/truffle-upgrades”: “^1.5.0”,
“truffle”: “^5.1.67”,
“@openzeppelin/contracts-ethereum-package”: “^3.0.0”,
“@openzeppelin/contracts-upgradeable”: “^3.4.0”
Details
I am trying to add test to cover the workaround (adding InitializableGap) on upgrade from contracts-ethereum-package to contracts-upgradeable on existing contract.
Here’s the upgradeProxy code that try to upgrade an existing contract on mainnet.
eTH2Staking = await upgradeProxy("0xf3310e1D7d732D3700ecB5d13F07A566a6c98aA0", ETH2Staking);
The test was running on local network with mainnet fork. Tried both ganache and hardhat node with unlocked admin account but both raised raised Error: Proxy admin is not the one registered in the network manifest. Any ideas?
Code to reproduce
1 Like
Hi @leckylao,
When you test an upgrade on the fork (without first doing a deploy), the ProxyAdmin for your proxy isn’t registered in your network file.
To test an upgrade, you can do a deployProxy and then an upgradeProxy. The deployProxy will deploy the implementation contract, the ProxyAdmin and the proxy. The upgradeProxy will deploy the new implementation contract and update the proxy with the new implementation contract address. See: https://docs.openzeppelin.com/upgrades-plugins/1.x/truffle-upgrades#test-usage
For an example test, see BoxV2.proxy.test.js in: OpenZeppelin Upgrades: Step by Step Tutorial for Truffle
As mentioned on Is it safe to upgrade from contracts-ethereum-package to contracts-upgradeable on existing contract. The new deployProxy wouldn't work with old contract that written in contracts-ethereum-package. Which would raise The requested contract was not found. So have to use the existing deployed one.
Where's the network file? Is there a way to register it manually?
1 Like