Add instructions on how to verify to Upgrades Plugins step by step guides

I would kindly ask to add the verification step to this tutorial: OpenZeppelin Upgrades: Step by Step Tutorial for Truffle

Noticed the repos contain some not so DRY code: https://github.com/OpenZeppelin/openzeppelin-upgrades/issues/198


Another observation

$ npx truffle migrate --network rinkeby

Compiling your contracts...
===========================
> Compiling .\contracts\Box.sol
> Compiling .\contracts\Migrations.sol
> Artifacts written to C:\Users\MichalStefan_1oo6qh4\Documents\Code\oze2e\build\contracts
> Compiled successfully using:
   - solc: 0.7.0+commit.9e61f92b.Emscripten.clang



Starting migrations...
======================
> Network name:    'rinkeby'
> Network id:      4
> Block gas limit: 10071170 (0x99ac82)


1_initial_migration.js
======================

   Deploying 'Migrations'
   ----------------------
   > transaction hash:    0x245ab45ac49d6cd3d386cee3924a5c328633648388f3d9c7618325d6d4e5de7f
- Blocks: 0            Seconds: 0
   > Blocks: 1            Seconds: 12
   > contract address:    0x8d11f5D53f8eFc86bE553d5298a4115B6b3C224A
   > block number:        7374253
   > block timestamp:     1602770856
   > account:             0xBAE8E5F877E15df0a1Ec36bFa6a9903B837d003a
   > balance:             0.16626098
   > gas used:            186951 (0x2da47)
   > gas price:           20 gwei
   > value sent:          0 ETH
   > total cost:          0.00373902 ETH

   Pausing for 1 confirmations...
   ------------------------------
   > confirmation number: 1 (block: 7374253)

- Saving migration to chain.
   > Saving migration to chain.
   > Saving artifacts
   -------------------------------------
   > Total cost:          0.00373902 ETH


2_deploy_box.js
===============

   Deploying 'Box'
   ---------------
   > transaction hash:    0xe19d08a475f6114054891717e8356235d96373a3132b1574dfb54e8154685c84
- Blocks: 0            Seconds: 0
   > Blocks: 0            Seconds: 8
   > contract address:    0xC5097C49f4f59C1df18B4320bDa9C7A74031A3D8
   > block number:        7374255
   > block timestamp:     1602770886
   > account:             0xBAE8E5F877E15df0a1Ec36bFa6a9903B837d003a
   > balance:             0.16324894
   > gas used:            108267 (0x1a6eb)
   > gas price:           20 gwei
   > value sent:          0 ETH
   > total cost:          0.00216534 ETH

   Pausing for 1 confirmations...
   ------------------------------
   > confirmation number: 1 (block: 7374256)

   Deploying 'ProxyAdmin'
   ----------------------
   > transaction hash:    0xefdcdc6ef2ce289cc397beb501c09e5ba0237485b2321ba4fe627b339db34a3b
- Blocks: 0            Seconds: 0
   > Blocks: 0            Seconds: 8
   > contract address:    0x899fc2cB368DaA3FE1Ff852BA367A9e2f9BB1AFa
   > block number:        7374257
   > block timestamp:     1602770916
   > account:             0xBAE8E5F877E15df0a1Ec36bFa6a9903B837d003a
   > balance:             0.1456497
   > gas used:            879962 (0xd6d5a)
   > gas price:           20 gwei
   > value sent:          0 ETH
   > total cost:          0.01759924 ETH

   Pausing for 1 confirmations...
   ------------------------------
   > confirmation number: 1 (block: 7374258)

   Deploying 'AdminUpgradeabilityProxy'
   ------------------------------------
   > transaction hash:    0xc34aaf4e233d5fc0924dd853b2c8ef4c8d4868c5d9040b7b998830f8cc126a90
- Blocks: 0            Seconds: 0
   > Blocks: 0            Seconds: 4
   > contract address:    0x35937192e3185bd137a899F85d5F2543bc881bC1
   > block number:        7374259
   > block timestamp:     1602770946
   > account:             0xBAE8E5F877E15df0a1Ec36bFa6a9903B837d003a
   > balance:             0.13323616
   > gas used:            620677 (0x97885)
   > gas price:           20 gwei
   > value sent:          0 ETH
   > total cost:          0.01241354 ETH

   Pausing for 1 confirmations...
   ------------------------------
   > confirmation number: 1 (block: 7374259)

- Saving migration to chain.
   > Saving migration to chain.
   > Saving artifacts
   -------------------------------------
   > Total cost:          0.03217812 ETH


Summary
=======
> Total deployments:   4
> Final cost:          0.03591714 ETH

I have no idea why the auto-verified source code is 0.6.8 not 0.7.0?

Not mission critical for me to know right now, but dev curious in general :sunglasses:

  • Migrations: https://rinkeby.etherscan.io/address/0x8d11f5d53f8efc86be553d5298a4115b6b3c224a#code (0.7.0, manually verified)

  • Box: https://rinkeby.etherscan.io/address/0xc5097c49f4f59c1df18b4320bda9c7a74031a3d8#code (0.7.0, manually verified)

  • ProxyAdmin: https://rinkeby.etherscan.io/address/0x899fc2cb368daa3fe1ff852ba367a9e2f9bb1afa#code (0.6.8, automagically verified)

  • AdminUpgradeabilityProxy: https://rinkeby.etherscan.io/address/0x35937192e3185bd137a899f85d5f2543bc881bc1#code (0.6.8, automagically verified)

1 Like

Hi @marsxr,

Welcome to the community :wave:

Thanks for the feedback. I recommend multi-file verification (easier to read, maintains licenses, maintains imports), and currently the best way to do this is with Buidler Etherscan plugin.

Multi-file verification should be coming to Truffle, see this open issue: https://github.com/rkalis/truffle-plugin-verify/issues/37

Once Truffle supports this I can add to the tutorial.

You should only need to verify the implementation contract, as generally the proxy and the ProxyAdmin should be verified on most public networks. (if not, let me know and I can verify).

Etherscan has support for proxies: Etherscan does have support for correctly showing OpenZeppelin proxies and their implementations


As for the proxy and the ProxyAdmin, they are precompiled with Solidity 0.6.8 currently, so when you deploy an upgradeable contract, you are only compiling your implementation contract with whatever Solidity version you want to use, whilst the precompiled versions of the proxy and ProxyAdmin are deployed.

I recommend multi-file verification (easier to read, maintains licenses, maintains imports)

Yeah. Makes sense. I need to upgrade my workflow!

Back in a day it was only a single flat file :slight_smile:

As for the proxy and the ProxyAdmin, they are precompiled with Solidity 0.6.8 currently, so when you deploy an upgradeable contract, you are only compiling your implementation contract with whatever Solidity version you want to use, whilst the precompiled versions

I see clearly now!

Compiling your contracts...
===========================
> Compiling .\contracts\Box.sol
> Compiling .\contracts\Migrations.sol

Definitely not obvious. Is it because of the security? Not dropping exploits into the Proxy code?

Thank you for explaining. That helps me a lot :slight_smile:

1 Like

Hi @marsxr,

Using precompiled versions of the proxy and ProxyAdmin allows projects to use any Solidity version to compile their implementation contract, along with any other contracts in their project. So projects can be compiled with Solidity 0.6 or Solidity 0.7 whilst the proxy and ProxyAdmin were compiled with a fixed version of Solidity.