wighawag / hardhat-deploy

hardhat deployment plugin
MIT License
1.17k stars 283 forks source link

Cannot reuse deployed contracts on zksync #462

Open ofumbi opened 1 year ago

ofumbi commented 1 year ago

Describe the bug Initial deployment works fine and contracts are saved, Reruning deployments on zksync throws an error To Reproduce Steps to reproduce the behavior:

  1. Rerun deployment script with save deployments on.
  2. See error
    
    Warning: 61 contracts exceed the size limit for mainnet deployment (24.000 KiB).
    An unexpected error occurred:

Error: ERROR processing /Users/steve/sites/sleepfinance-contracts/deploy/airdrop/Airdrop.js: Error: invalid rlp data (argument="data", value=Uint8Array(0x9c4d535b000000000000000000000000000000000000000000000000000000000000000001000691b530d33f3caba5fc77f92cecb793a2efa4018f4820a012393f75845100000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000), code=INVALID_ARGUMENT, version=rlp/5.7.0) at Logger.makeError (/Users/steve/sites/sleepfinance-contracts/node_modules/@ethersproject/logger/src.ts/index.ts:269:28) at Logger.throwError (/Users/steve/sites/sleepfinance-contracts/node_modules/@ethersproject/logger/src.ts/index.ts:281:20) at Logger.throwArgumentError (/Users/steve/sites/sleepfinance-contracts/node_modules/@ethersproject/logger/src.ts/index.ts:285:21) at Object.decode (/Users/steve/sites/sleepfinance-contracts/node_modules/@ethersproject/rlp/src.ts/index.ts:151:16) at _parse (/Users/steve/sites/sleepfinance-contracts/node_modules/@ethersproject/transactions/src.ts/index.ts:412:29) at Object.parse (/Users/steve/sites/sleepfinance-contracts/node_modules/@ethersproject/transactions/src.ts/index.ts:482:37) at Object.parseTransaction (/Users/steve/sites/sleepfinance-contracts/node_modules/zksync-web3/build/src/utils.js:237:31) at fetchIfDifferent (/Users/steve/sites/sleepfinance-contracts/node_modules/hardhat-deploy/src/helpers.ts:969:40) at processTicksAndRejections (node:internal/process/task_queues:95:5) at _deployOne (/Users/steve/sites/sleepfinance-contracts/node_modules/hardhat-deploy/src/helpers.ts:1013:24) at DeploymentsManager.executeDeployScripts (/Users/steve/sites/sleepfinance-contracts/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1229:19) at processTicksAndRejections (node:internal/process/task_queues:95:5) at DeploymentsManager.runDeploy (/Users/steve/sites/sleepfinance-contracts/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1059:5) at SimpleTaskDefinition.action (/Users/steve/sites/sleepfinance-contracts/node_modules/hardhat-deploy/src/index.ts:438:5) at Environment._runTaskDefinition (/Users/steve/sites/sleepfinance-contracts/node_modules/hardhat/src/internal/core/runtime-environment.ts:333:14) at Environment.run (/Users/steve/sites/sleepfinance-contracts/node_modules/hardhat/src/internal/core/runtime-environment.ts:166:14) at SimpleTaskDefinition.action (/Users/steve/sites/sleepfinance-contracts/node_modules/hardhat-deploy/src/index.ts:584:32) at Environment._runTaskDefinition (/Users/steve/sites/sleepfinance-contracts/node_modules/hardhat/src/internal/core/runtime-environment.ts:333:14) at Environment.run (/Users/steve/sites/sleepfinance-contracts/node_modules/hardhat/src/internal/core/runtime-environment.ts:166:14) at SimpleTaskDefinition.action (/Users/steve/sites/sleepfinance-contracts/node_modules/hardhat-deploy/src/index.ts:669:5) steve@Stephens-MacBook-Pro sleepfinance-contracts %


**Expected behavior**
should work normal

**versions**
````json
  "devDependencies": {
        "@matterlabs/hardhat-zksync-solc": "^0.4.0",
        "@nomicfoundation/hardhat-toolbox": "^1.0.2",
        "@nomiclabs/hardhat-ethers": "^2.1.0",
        "@nomiclabs/hardhat-web3": "^2.0.0",
        "@openzeppelin/contracts": "^4.8.3",
        "@openzeppelin/hardhat-upgrades": "^1.21.0",
        "@openzeppelin/test-helpers": "^0.5.15",
        "dotenv": "^16.0.3",
        "eip712-codegen": "^4.0.3",
        "eslint": "^8.20.0",
        "eth-sig-util": "^3.0.1",
        "ethers": "^5.6.9",
        "hardhat": "^2.12.0",
        "hardhat-abi-exporter": "^2.10.0",
        "hardhat-contract-sizer": "^2.6.1",
        "hardhat-deploy": "^0.11.34",
        "hardhat-gas-reporter": "^1.0.8",
        "hardhat-preprocessor": "^0.1.5",
        "hardhat-spdx-license-identifier": "^2.0.3",
        "prettier": "^2.7.1",
        "prettier-plugin-solidity": "^1.0.0-dev.23",
        "solhint-plugin-prettier": "^0.0.5",
        "uniswap-v2-deploy-plugin": "^0.0.4",
        "web3": "^1.8.0"
    },
    "dependencies": {
        "@chainlink/contracts": "^0.4.1",
        "@layerzerolabs/solidity-examples": "^0.0.8",
        "@matterlabs/hardhat-zksync-deploy": "^0.6.3",
        "@matterlabs/hardhat-zksync-verify": "^0.1.8",
        "@metamask/eth-sig-util": "^4.0.1",
        "@openzeppelin/contracts-upgradeable": "^4.7.0",
        "@uniswap/v2-core": "^1.0.1",
        "@uniswap/v2-sdk": "^3.0.1",
        "ethereumjs-wallet": "^1.0.2",
        "glob-promise": "^5.0.0",
        "hardhat-log-remover": "^2.0.2",
        "merkletreejs": "^0.3.0",
        "solhint": "^3.3.7",
        "uniswap-v2-deploy-plugin": "^0.0.4",
        "uniswap-v2-periphery": "^1.1.0"
    }

Hardhat config

require("@nomicfoundation/hardhat-toolbox");
require("@nomiclabs/hardhat-web3");
require("uniswap-v2-deploy-plugin");
require('hardhat-contract-sizer');
require("hardhat-gas-reporter");
require("hardhat-abi-exporter");
require('hardhat-deploy');
require('hardhat-spdx-license-identifier');
require('hardhat-log-remover');
require('./tasks/verifier.js')
require('./tasks/nftVerify.js')
require("@matterlabs/hardhat-zksync-deploy");
require("@matterlabs/hardhat-zksync-solc");
require("@matterlabs/hardhat-zksync-verify");

require('dotenv').config({ path: __dirname + '/.env' })
const { removeConsoleLog } = require("hardhat-preprocessor");
/** @type import('hardhat/config').HardhatUserConfig */
const accounts = {
    mnemonic: process.env.MNEMONIC,
    path: "m/44'/60'/0'/0", //0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
    initialIndex: 0,
    count: 20,
    passphrase: "",
}
module.exports = {
    zksolc: {
        version: "latest", // Uses latest available in https://github.com/matter-labs/zksolc-bin/
        settings: {
            isSystem: true,
            optimizer: {
                enabled: true,
                mode: 'z'
            }
        },
    },
    preprocess: {
        eachLine: removeConsoleLog((bre) => bre.network.name !== "hardhat" && bre.network.name !== "localhost"),
    },
    paths: {
        artifacts: "artifacts",
        cache: "cache",
        deploy: "deploy",
        deployments: "deployments",
        imports: "imports",
        sources: "contracts",
        tests: "test",
    },
    spdxLicenseIdentifier: {
        overwrite: false,
        runOnCompile: true,
    },
    solidity: {
        version: "0.8.12",
        settings: {
            optimizer: {
                enabled: true,
                runs: 200,
            },
        },
    },
    contractSizer: {
        alphaSort: false,
        runOnCompile: true,
        disambiguatePaths: false,
    },
    defaultNetwork: 'hardhat',
    verify: {
        skipContracts: [],
        etherscan: {
            apiKey: process.env.ETHERSCAN_KEY,
        }
    },
    namedAccounts: {
        deployer: {
            default: 0,
        },
        oracle: {
            default: 1,
        },
    },
    networks: {
        hardhat: {
            chainId: 30008,
            forking: {
                url: `https://mainnet.infura.io/v3/${process.env.INFURA_KEY}`,
                blockNumber: 15725355
            },
            accounts,
        },
       goerli: {
            url: `https://goerli.infura.io/v3/${process.env.INFURA_KEY}`,
            accounts,
            chainId: 5,
            live: true,
            saveDeployments: true,
            verify: {
                skipContracts: [],
                etherscan: {
                    apiKey: process.env.ETHERSCAN_KEY,
                    apiUrl: 'https://api-goerli.etherscan.io'
                }
            }
        }, 
        zksyncTestnet: {
            url: "https://zksync2-testnet.zksync.dev",
            ethNetwork: 'goerli',
            zksync: true,
            allowUnlimitedContractSize: true,
            accounts,
            chainId: 280,
            live: true,
            saveDeployments: true
        }

    },
    gasReporter: {
        enabled: true,
        currency: 'USD',
        gasPrice: 1,
        coinmarketcap: '',
        token: 'ETH',
        gasPriceApi: "https://api-optimistic.etherscan.io/api?module=proxy&action=eth_gasPrice&apikey="
    }
};
ofumbi commented 1 year ago

Deleting all deployments starts a fresh install and everything works fine, BUT it reinstalls everything afresh

donghua-wang commented 7 months ago

I'm also having the same issue with the upgrade contract on zksync. But it works to use version 0.11.27.

boyuanx commented 4 months ago

Still having this issue with "@matterlabs/hardhat-zksync-deploy": "1.2.0" and "hardhat-deploy": "^0.12.1"

byshape commented 3 months ago

I'm also having problems re-deploying contracts on zkSync with 0.12.2 version.

novaknole commented 2 months ago

Here I am as well, having the same problem. Seems like hardhat-deploy has a bug. Any solutions ?