5.0 TransparentUpgradeableProxy upgradeAndCall error

:1234: Code to reproduce

I'm writing a Solidity deploy script using Foundry.

  1. I'm executing the Deploy using this command
forge script script/Deployer.s.sol:DeployerScript --rpc-url http://127.0.0.1:8545 --private-key $env:PRIVATE_KEY --broadcast -vvvvv

github code: fishcake-contracts/script/Deployer.s.sol at main ยท WarriorFromLongAgo/fishcake-contracts (github.com)

  1. Upgrade investorSalePool contract
forge script script/UpgradeInvestorSalePoolDeployer.s.sol:UpgradeInvestorSalePoolDeployer --rpc-url http://127.0.0.1:8545 --private-key $env:PRIVATE_KEY --broadcast -vvvv

github code: fishcake-contracts/script/UpgradeInvestorSalePoolDeployer.s.sol at main ยท WarriorFromLongAgo/fishcake-contracts (github.com)

3, deploy err log

== Logs ==
  New InvestorSalePool implementation deployed at: 0x0613c549d358fB743037bE6De52E4348AdA96Ad0
  proxyAdmin  deployed at: 0x5094103dE460dF9BC1A0F2D69d6D6547cc97c050
  proxyAdmin owner deployed at: 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720
  deployerAddress deployed at: 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720
  run 1 msg.sender deployed at: 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720
Error:
script failed: <empty revert data>

4๏ผŒ deploy err stack

  [1458402] UpgradeInvestorSalePoolDeployer::run()
    โ”œโ”€ [0] VM::envUint("PRIVATE_KEY") [staticcall]
    โ”‚   โ””โ”€ โ† [Return] <env var value>
    โ”œโ”€ [0] VM::addr(<pk>) [staticcall]
    โ”‚   โ””โ”€ โ† [Return] 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720
    โ”œโ”€ [0] VM::startBroadcast(<pk>)
    โ”‚   โ””โ”€ โ† [Return]
    โ”œโ”€ [1394180] โ†’ new InvestorSalePool@0x0613c549d358fB743037bE6De52E4348AdA96Ad0
    โ”‚   โ”œโ”€ emit Initialized(version: 18446744073709551615 [1.844e19])
    โ”‚   โ””โ”€ โ† [Return] 6821 bytes of code
    โ”œโ”€ [0] console::log("New InvestorSalePool implementation deployed at:", InvestorSalePool: [0x0613c549d358fB743037bE6De52E4348AdA96Ad0]) [staticcall]
    โ”‚   โ””โ”€ โ† [Stop]
    โ”œโ”€ [0] console::log("proxyAdmin  deployed at:", 0x5094103dE460dF9BC1A0F2D69d6D6547cc97c050) [staticcall]
    โ”‚   โ””โ”€ โ† [Stop]
    โ”œโ”€ [2298] 0x5094103dE460dF9BC1A0F2D69d6D6547cc97c050::owner() [staticcall]
    โ”‚   โ””โ”€ โ† [Return] 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720
    โ”œโ”€ [0] console::log("proxyAdmin owner deployed at:", 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720) [staticcall]
    โ”‚   โ””โ”€ โ† [Stop]
    โ”œโ”€ [0] console::log("deployerAddress deployed at:", 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720) [staticcall]
    โ”‚   โ””โ”€ โ† [Stop]
    โ”œโ”€ [298] 0x5094103dE460dF9BC1A0F2D69d6D6547cc97c050::owner() [staticcall]
    โ”‚   โ””โ”€ โ† [Return] 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720
    โ”œโ”€ [0] console::log("run 1 msg.sender deployed at:", 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720) [staticcall]
    โ”‚   โ””โ”€ โ† [Stop]
    โ”œโ”€ [9510] 0x5094103dE460dF9BC1A0F2D69d6D6547cc97c050::upgradeAndCall(0x0D8694F47cDC22Bb8C6D2668a38d07a439F378F9, InvestorSalePool: [0x0613c549d358fB743037bE6De52E4348AdA96Ad0], 0xc4d66de8000000000000000000000000a0ee7a142d267c1f36714e4a8f75612f20a79720)
    โ”‚   โ”œโ”€ [5568] 0x0D8694F47cDC22Bb8C6D2668a38d07a439F378F9::upgradeToAndCall(InvestorSalePool: [0x0613c549d358fB743037bE6De52E4348AdA96Ad0], 0xc4d66de8000000000000000000000000a0ee7a142d267c1f36714e4a8f75612f20a79720)
    โ”‚   โ”‚   โ”œโ”€ [696] 0xA922C3227149D9bc5001D796aA418b590D0C4a7B::upgradeToAndCall(InvestorSalePool: [0x0613c549d358fB743037bE6De52E4348AdA96Ad0], 0xc4d66de8000000000000000000000000a0ee7a142d267c1f36714e4a8f75612f20a79720) [delegatecall]
    โ”‚   โ”‚   โ”‚   โ””โ”€ โ† [Revert] EvmError: Revert
    โ”‚   โ”‚   โ””โ”€ โ† [Revert] EvmError: Revert
    โ”‚   โ””โ”€ โ† [Revert] EvmError: Revert
    โ””โ”€ โ† [Revert] EvmError: Revert

:computer: Environment

I'm writing a Solidity deploy script using Foundry.

When creating the TransparentUpgradeableProxy, the second parameter of the constructor that you are calling here should be the initialOwner that you want to use (e.g. deployerAddress in your example), not the proxy admin address.

With OpenZeppelin Contracts 5.0, the TransparentUpgradeableProxy deploys its own ProxyAdmin using that initialOwner as the owner of the ProxyAdmin -- don't pre-deploy your own ProxyAdmin first.

Also, you may want to check out the Foundry Upgrades plugin to help with upgradeable deployments.

1 Like

Thanks!!!

Thank you for your response! After several attempts, Upgrades resolved the deployment and upgrade issues.


Resolution Guide:

README.md (executing command)

https://github.com/WarriorFromLongAgo/fishcake-contracts/blob/main/README.md

use upgrades Deployer

https://github.com/WarriorFromLongAgo/fishcake-contracts/blob/main/script/DeployerV2.s.sol

use upgrades Upgrade

https://github.com/WarriorFromLongAgo/fishcake-contracts/blob/main/script/UpgradeInvestorSalePoolDeployerV2.s.sol