Can’t deploy contracts to my Azure PoA Ethereum because the dependencies are too large

So, as I said above (Connecting the OpenZeppelin CLI to an Azure PoA Network), I can’t deploy contracts to my Azure PoA Ethereum because the dependencies are too large (see example below).

The Azure team said that there is a 48KB limit.

How can I get these dependencies deployed?

$ oz create
Nothing to compile, all contracts are up to date.
? Pick a contract to instantiate @openzeppelin/contracts-ethereum-package/StandaloneERC20
? Pick a network azure
? One or more linked dependencies are not yet deployed on dev-103098097.
Do you want to deploy them now? Yes
✖ Deploying openzeppelin-eth dependency to network dev-103098097
✖ Deploying @openzeppelin/contracts-ethereum-package dependency to network dev-103098097
Failed deployment of dependency openzeppelin-eth with error: The contract code couldn't be stored, please check your gas limit.
Failed deployment of dependency @openzeppelin/contracts-ethereum-package with error: The contract code couldn't be stored, please check your gas limit.
$

Thanks in advance – Mark

1 Like

Hi @MWaser,

I get the same issue when attempting to deploy a StandaloneERC20 using OpenZeppelin Contracts Ethereum Package 2.4 using OpenZeppelin CLI 2.7 to your PoA network.

$ npx oz create
No contracts found to compile.
? Pick a contract to instantiate @openzeppelin/contracts-ethereum-package/StandaloneERC20
? Pick a network poa
? One or more linked dependencies are not yet deployed on dev-103098097.
Do you want to deploy them now? Yes
✖ Deploying @openzeppelin/contracts-ethereum-package dependency to network dev-103098097
Failed deployment of dependency @openzeppelin/contracts-ethereum-package with error: VM execution error.

I suspect this may be related to this:

The last compiler version that had byzantium as default was 0.5.4 (https://solidity.readthedocs.io/en/v0.5.4/using-the-compiler.html#target-options)

OpenZeppelin Ethereum Contracts 2.2.3 was compiled using solc 0.5.7, so the EVM version will be different.

You may want to look at the advanced options in Ethereum settings to see if you can specify the EVM version.


I can deploy a non-upgradeable (regular) ERC20 token

In a new project install OpenZeppelin CLI 2.8 Release Candidate and OpenZeppelin Contracts

npm install @openzeppelin/cli@rc
npm install @openzeppelin/contracts

SimpleToken.sol

pragma solidity ^0.5.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol";

/**
 * @title SimpleToken
 * @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the creator.
 * Note they can later distribute these tokens as they wish using `transfer` and other
 * `ERC20` functions.
 */
contract SimpleToken is ERC20, ERC20Detailed {

    /**
     * @dev Constructor that gives msg.sender all of existing tokens.
     */
    constructor () public ERC20Detailed("SimpleToken", "SIM", 18) {
        _mint(msg.sender, 10000 * (10 ** uint256(decimals())));
    }
}

I need to compile using solc 0.5.4

$ npx oz compile --solc-version 0.5.4
✓ Compiled contracts with solc 0.5.4 (commit.9549d8ff)

$ npx oz deploy
Nothing to compile, all contracts are up to date.
? Choose the kind of deployment regular
? Pick a network poa
? Pick a contract to deploy SimpleToken
✓ Deployed instance of SimpleToken
0x159b2396c75C97539b53cEbC69467d06908151c5

If I compile using solc 0.5.5 deployment fails.

$ npx oz compile --solc-version 0.5.5
✓ Compiled contracts with solc 0.5.5 (commit.47a71e8f)

$ npx oz deploy
Nothing to compile, all contracts are up to date.
? Choose the kind of deployment regular
? Pick a network poa
? Pick a contract to deploy SimpleToken
✖ Deploying an instance of SimpleToken
Error: The execution failed due to an exception.

Once again, thank you so much for your assistance. I had tried the nonupgradeable token as well but when it failed with a different error, I decided not to bring it up since it would only have “clouded the issue with facts” :wink:

I’ll research the EVM update and post the results. I’m pretty sure that it is changeable and I’d be more comfortable keeping it up to date.

Thanks! Mark

1 Like

I got the same result but a really different error message.
You got “Error: The execution failed due to an exception.”
I got “The contract code couldn’t be stored, please check your gas limit.”

My gas limit was 50000000. Adding 1 to put it at 50000001 went over the maximum allowed.
Maybe your exception is a gas limit error?

mwaser@DESKTOP-AUSCT6L:~/test$ oz compile --solc-version 0.5.4
✓ Compiled contracts with solc 0.5.4 (commit.9549d8ff)

mwaser@DESKTOP-AUSCT6L:~/test$ npx oz deploy
Nothing to compile, all contracts are up to date.
? Choose the kind of deployment regular
? Pick a network azure
? Pick a contract to deploy SimpleToken
✓ Deployed instance of SimpleToken
0x3463e0E6e65ACa2b590Ed0879d324c7F1dA19bEB

mwaser@DESKTOP-AUSCT6L:~/test$ oz compile --solc-version 0.5.5
✓ Compiled contracts with solc 0.5.5 (commit.47a71e8f)

mwaser@DESKTOP-AUSCT6L:~/test$ npx oz deploy
Nothing to compile, all contracts are up to date.
? Choose the kind of deployment regular
? Pick a network azure
? Pick a contract to deploy SimpleToken
✖ Deploying an instance of SimpleToken
The contract code couldn't be stored, please check your gas limit.
1 Like

Since we changed to the release candidate CLI, I just had to try the upgradeable with that (I suspect that you might have as well). Unfortunately, that ran into the gas limit error while compiling with both 0.5.4 and 0.5.5. :frowning:

SimpleToken2.sol

pragma solidity ^0.5.0;

import "../node_modules/@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/StandaloneERC20.sol";

/** 
 * @title SimpleToken2
 */

contract simpletoken2 is StandaloneERC20 {

}

==============================================================

mkdir test
cd test
mkdir contracts
cp ../networks.js .
cp ../simpletoken2.sol contracts
npm init -y
npm install truffle-hdwallet-provider
npm install @openzeppelin/cli@rc
npm install @openzeppelin/contracts-ethereum-package
oz init

$ oz compile --solc-version 0.5.4
✓ Compiled contracts with solc 0.5.4 (commit.9549d8ff)

mwaser@DESKTOP-AUSCT6L:~/test$ npx oz deploy
Nothing to compile, all contracts are up to date.
? Choose the kind of deployment upgradeable
? Pick a network azure
? Pick a contract to deploy simpletoken2
- Variables _minters (MinterRole), _pausers (PauserRole) contain a struct or enum. These are not automatically checked for storage compatibility in the current version. See https://docs.openzeppelin.com/upgrades/2.6//writing-upgradeable#modifying-your-contracts for more info.
✓ Contract simpletoken2 deployed
All implementations have been deployed
? Call a function to initialize the instance after creating it? Yes
? Select which function * initialize(name: string, symbol: string, decimals: uint8)
? name: string: DUMMY
? symbol: string: DUM
? decimals: uint8: 2
✖ Creating instance for contract at 0x946f757EC04A921c5A83d63761cDdb21a5B4F5b0 and calling 'initialize' with:
- name (string): "DUMMY"
- symbol (string): "DUM"
- decimals (uint8): "2"
The contract code couldn't be stored, please check your gas limit.
1 Like

A post was split to a new topic: Questions on upgradeable contracts and events

Hi @MWaser,

The issue appears that the POA network you are using is Byzantium.
Have you tried creating a new POA network with a later EVM version?

We can use OpenZeppelin CLI to compile and deploy regular contracts (using CLI 2.8 Release Candidate) for EVM version Byzantium (use solc 0.5.4 or earlier).

Upgradeable contracts deploy a Proxy and a Proxy Admin, and these would need to be compiled for Byzantium.

We created a CLI version with Byzantium Proxy and Proxy Admin last year. (Deploying a token that uses 'contracts-ethereum-package' to Ethereum Classic)

In a new project install the CLI Byzantium version.

$ npm i @openzeppelin/cli@byzantium

We can deploy Box.sol from the Upgrading a Contract using the CLI guide.

$ npx oz compile --solc-version 0.5.3 --evm-version byzantium
✓ Compiled contracts with solc 0.5.3 (commit.10d17f24)

$ npx oz create
Nothing to compile, all contracts are up to date.
? Pick a contract to instantiate Box
? Pick a network poa
✓ Added contract Box
✓ Contract Box deployed
All contracts have been deployed
? Call a function to initialize the instance after creating it? No
✓ Setting everything up to create contract instances
✓ Instance created at 0x67d8C554136D28EF517F1854e57568eE6e38a0d4
0x67d8C554136D28EF517F1854e57568eE6e38a0d4

$ npx oz send-tx
? Pick a network poa
? Pick an instance Box at 0x67d8C554136D28EF517F1854e57568eE6e38a0d4
? Select which function store(newValue: uint256)
? newValue (uint256): 42
✓ Transaction successful. Transaction hash: 0xd875c9223711a8f6a8fca3e8b87a6507c48fc34eadc7d4bd4b86b2b223a13c7f
Events emitted:
 - ValueChanged(42)

We can then upgrade the contract:

$ npx oz compile --solc-version 0.5.3 --evm-version byzantium
✓ Compiled contracts with solc 0.5.3 (commit.10d17f24)

$ npx oz upgrade
? Pick a network poa
Nothing to compile, all contracts are up to date.
✓ Contract Box deployed
All contracts have been deployed
? Which instances would you like to upgrade? Choose by address
? Pick an instance to upgrade Box at 0x67d8C554136D28EF517F1854e57568eE6e38a0d4
? Call a function on the instance after upgrading it? No
✓ Instance upgraded at 0x67d8C554136D28EF517F1854e57568eE6e38a0d4. Transaction receipt: 0xde92fb818f61e314d02b0c6ce37bb3cec51cfe83b96c91b8a1677e3b4a01af38
✓ Instance at 0x67d8C554136D28EF517F1854e57568eE6e38a0d4 upgraded

We can install OpenZeppelin Contracts Ethereum Package (as long as we can compile with solc 0.5.4). We can’t link as this would require an EVM later than Byzantium.

$ npm i @openzeppelin/contracts-ethereum-package

We can then deploy an ERC20 token inheriting from OpenZeppelin Contracts Ethereum Package:

SimpleToken

pragma solidity ^0.5.0;

import "@openzeppelin/upgrades/contracts/Initializable.sol";

import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20Detailed.sol";

/**
 * @title SimpleToken
 * @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the sender.
 * Note they can later distribute these tokens as they wish using `transfer` and other
 * `ERC20` functions.
 */
contract SimpleToken is Initializable, ERC20, ERC20Detailed {

    /**
     * @dev initialize that gives msg.sender all of existing tokens.
     */
    function initialize(address sender) public initializer {
        ERC20Detailed.initialize("Token", "TKN", 18);
        _mint(sender, 1000000 * (10 ** uint256(decimals())));
    }
}

We can then compile and create SimpleToken, and then interact with it.

$ npx oz compile --solc-version 0.5.3 --evm-version byzantium
✓ Compiled contracts with solc 0.5.3 (commit.10d17f24)

$ npx oz create
Nothing to compile, all contracts are up to date.
? Pick a contract to instantiate SimpleToken
? Pick a network poa
✓ Contract SimpleToken deployed
All contracts have been deployed
? Call a function to initialize the instance after creating it? Yes
? Select which function * initialize(sender: address)
? sender (address): 0x8616f9c6d59b86CEbf5b653d6f153D4c2E9441C5
✓ Setting everything up to create contract instances
✓ Instance created at 0x344Df09d15B479eD1C2cbBa30bbEddC765F5fBBD
0x344Df09d15B479eD1C2cbBa30bbEddC765F5fBBD

$ npx oz call
? Pick a network poa
? Pick an instance SimpleToken at 0x344Df09d15B479eD1C2cbBa30bbEddC765F5fBBD
? Select which function totalSupply()
✓ Method 'totalSupply()' returned: 1000000000000000000000000
1000000000000000000000000

NICE! That worked (thank you, thank you, thank you).

One oddity in that it didn’t work the first time I tried it but not sure what that means other than to look out for similar reports. For now, I am definitely good to proceed.

Thanks!
Mark

1 Like