Error during upgrade: No AST nodes of type ContractDefinition with id 419 found

I am trying to upgrade a contract instance on kovan. I added a single function and then used the cli tool to upgrade the contracts. This is the steps that I took

oz compile
*selected kovan network
*selected contract instance
*picked the instance to upgrade

Then I get this error message:

No AST nodes of type ContractDefinition with id 419 found.

:computer: Environment

running on mac, these are my deps from package.json:
“@openzeppelin/contracts-ethereum-package”: “2.5.0”,
“@openzeppelin/upgrades”: “^2.6.0”,
“@openzeppelin/cli”: “2.8.2”,
“openzeppelin-solidity”: “^3.0.1”,

Compiling gives me some warnings but it shows a checkmark and says contracts have been compiled successfully.

Any help would be appreciated!

1 Like

I have tried deleting both the build and the artifacts folder and that didn’t help.

1 Like

Hi @elliot,

Welcome to the community forum :wave:
Thanks for posting here.

Are you able to share your contract (or a cut down version) so that I can reproduce?

Hi @elliot,

Thanks for letting me know that you can’t share your contract.

I am not sure what is causing the error.

You have “@openzeppelin/contracts-ethereum-package”: “2.5.0” which is the upgradeable version of OpenZeppelin Contracts using Solidity 0.5
You also have “openzeppelin-solidity”: “^3.0.1” which is OpenZeppelin Contracts using Solidity 0.6.

I assume that you are using Solidity 0.5, so you don’t need to have openzeppelin-solidity (the old name for @openzeppelin/contracts) as a dependency.

You may want to try going through the simple example in the Learn guides to rule out anything in your config: https://docs.openzeppelin.com/learn/upgrading-smart-contracts#upgrading-a-contract-via-cli

Are you able to share the imports of your contract so that I can try to reproduce? If not, I suggest creating a new project with a simple contract with your imports to see if that is causing the issue.

I removed “openzeppelin-solidity”: “^3.0.1” and now none of the dependency solidity files are being properly imported. I deleted package-lock.json, removed build folder, removed node_modules, did a fresh npm install and it is saying other openzeppelin dependencies (ownable) cannot be found.

These are all of my dependencies in package.json:

"dependencies": {
    "@hq20/fixidity": "0.1.0-alpha.2",
    "@openzeppelin/cli": "2.8.2",
    "@openzeppelin/test-helpers": "0.5.4",
    "@openzeppelin/upgrades": "^2.6.0",
    "@truffle/hdwallet-provider": "^1.0.26",
    "dotenv": "^6.2.0",
    "solc": "^0.5.16",
    "solidity-docgen": "^0.5.3",
    "truffle-hdwallet-provider-privkey": "^1.0.3",
    "truffle-security": "^1.7.1"
},
"devDependencies": {
    "@gnosis.pm/mock-contract": "^3.0.8",
    "@openzeppelin/contracts-ethereum-package": "2.5.0",
    "@truffle/config": "^1.2.18",
    "chai": "^4.2.0",
    "codecov": "^3.6.1",
    "eth-gas-reporter": "^0.2.17",
    "inquirer": "^7.1.0",
    "ora": "^4.0.4",
    "solidity-coverage": "^0.7.0",
    "truffle": "^5.1.26",
    "@nomiclabs/buidler": "^1.3.4",
    "@nomiclabs/buidler-ethers": "^1.3.0",
    "@nomiclabs/buidler-ganache": "^1.3.0",
    "@nomiclabs/buidler-truffle5": "^1.3.0",
    "@nomiclabs/buidler-waffle": "^1.3.0",
    "@nomiclabs/buidler-web3": "^1.3.0"
}
1 Like

I figured out the issue. I had two versions of a contract in my build folder which was causing deployments to fail.

1 Like

Hi @elliot,

I’m glad you were able to track it down.

This error should only happen on partial compilations.
Deleting build/contracts directory and recompiling should resolve the issue.