OpenZeppelin / OpenZeppelin/openzeppelin-upgrades

Add support for Truffle dry run fork

Open
#241 7 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
658
Forks
286
PR merge metrics
No merged PRs in 30d

Description

Truffle has a dry run option on migration that forks the network to check the migration.

When deploying a contract with dry run skipped, and then attempting to do an upgrade with dry run, the upgrade fails with:

Error: Proxy admin is not the one registered in the network manifest
    at upgradeProxy

Using Box.sol and BoxV2.sol from https://forum.openzeppelin.com/t/openzeppelin-upgrades-step-by-step-tutorial-for-truffle/3579 and the deploy and upgrade migrations below:

2_deploy_box.js

// migrations/2_deploy_box.js
const Box = artifacts.require('Box');
 
const { deployProxy } = require('@openzeppelin/truffle-upgrades');
 
module.exports = async function (deployer) {
  await deployProxy(Box, [42], { deployer, initializer: 'store' });
};

3_upgrade_box.js

// migrations/3_upgrade_box.js
const Box = artifacts.require('Box');
const BoxV2 = artifacts.require('BoxV2');

const { upgradeProxy } = require('@openzeppelin/truffle-upgrades');
 
module.exports = async function (deployer) {
  const box = await Box.deployed();
  await upgradeProxy(box.address, BoxV2, { deployer });
};
$ npx truffle migrate --network rinkeby --to 2 --skip-dry-run
...
Starting migrations...
======================
> Network name:    'rinkeby'
> Network id:      4
> Block gas limit: 10000000 (0x989680)


1_initial_migration.js
...
2_deploy_box.js
===============

   Deploying 'Box'
   ---------------
   > transaction hash:    0x55fe331e1997c5ee4233fb9db21eb63bb12c0d9aac02ba21750cca487364e903
   > Blocks: 2            Seconds: 21
   > contract address:    0xE1a1b97E43362F8FE6F08Bc3A6EC250C35146E0F
...
   Deploying 'ProxyAdmin'
   ----------------------
   > transaction hash:    0x725e4486c35d4b6c812513a5705e9c04ea3b0ed19ebb6cedd443dc5c371709c6
   > Blocks: 1            Seconds: 17
   > contract address:    0xe34E320E784D56728aC0247005De168bdDA17beE
...
   Deploying 'AdminUpgradeabilityProxy'
   ------------------------------------
   > transaction hash:    0xc1210bfcb6381dd24ac590b3e93820ba49700207affcb6cea0550eb94318698a
   > Blocks: 1            Seconds: 17
   > contract address:    0xe2e88690f2F3CAC2534412AaA5C93e8b6368Ad98
...
$ npx truffle migrate --network rinkeby

Compiling your contracts...
===========================
...

Migrations dry-run (simulation)
===============================
> Network name:    'rinkeby-fork'
> Network id:      4
> Block gas limit: 10000000 (0x989680)


3_upgrade_box.js
================

Error: Proxy admin is not the one registered in the network manifest
    at upgradeProxy (/home/abcoathup/projects/forum/truffledryrun/node_modules/@openzeppelin/truffle-upgrades/src/upgrade-proxy.ts:76:11)
Truffle v5.1.54 (core: 5.1.54)
Node v10.22.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the two Truffle migration commands and the Box/BoxV2 example. Start at src/upgrade-proxy.ts:76, where the manifest proxy-admin check fails during the dry-run fork. Done means the upgrade migration succeeds after the initial deployment was run with --skip-dry-run, while preserving the existing network-manifest validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
blockchain, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.