openzeppelin-upgrades: Importing Interfaces breaks deployProxy

Updated the Box contract used on https://docs.openzeppelin.com/upgrades-plugins/1.x/truffle-upgrades Importing a simple interface. Makes the migrate command to throw the following contract Error: The requested contract was not found. Make sure the source code is available for compilation

When an interface is imported, checkForImportIdConsistency removes a contract from the input, output validated.

https://github.com/OpenZeppelin/openzeppelin-upgrades/blob/master/packages/plugin-truffle/src/validate.ts#L84-L105

.

@openzeppelin/truffle-upgrades/dist/validate.js

// contracts/Box.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;

import "contracts/Itest.sol";
 
contract Box {
    uint256 private value;
 
    // Emitted when the stored value changes
    event ValueChanged(uint256 newValue);
 
    // Stores a new value in the contract
    function store(uint256 newValue) public {
        value = newValue;
        emit ValueChanged(newValue);
    }
 
    // Reads the last stored value
    function retrieve() public view returns (uint256) {
        return value;
    }

    function testing() public pure returns(bool) {
      return false;

    }

    function test() public view returns (bool) {
      Itest temp = Itest(address(this));
      return temp.testing();
    }
}

Oddly enough putting an inline interface presents works fine.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 19 (8 by maintainers)

Most upvoted comments

Hi I’m using @openzeppelin/truffle-upgrades ^1.7.0 and my Computer is macbook air(m1, 2020), macOs BigSur.

I’m using truffle version of v5.3.6 and before using @openzeppelin/truffle-upgrades, it compiled and migrated well. However, when I tried to deploy my contract with deployProxy which is provided by @openzeppelin/truffle-upgrades packages, I encountered with the error like below

The requested contract was not found. Make sure the source code is available for compilation
    at getContractNameAndRunValidation

The error occured for the contracts that import other contract like below

import "./SafeMath.sol";

Thank you for reading 👍

Thanks. I just tryied to reproduce on a new ubuntu vm and couldn’t reproduce the issue. Seems to be some kind of local issue I haven’t figured out yet.

@ccolorado Can you try using a relative import? As in: import "./Itest.sol";.

Note you are currently using import "contracts/Itest.sol";, this is an unusual import format that can cause issues sometimes.

@ccolorado A screen recording shouldn’t be necessary. I’ll take a look at this and get back to you.

I see, I’ll try to reproduce on another system. I am using 64 bit Linux (key sensitive). If I am able to reproduce it on a different system, would a screen recording gif be any help?