wighawag / hardhat-deploy

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

The chainID field in transaction deploy using deterministicDeployment is none. #543

Closed Ghoulouis closed 1 month ago

Ghoulouis commented 2 months ago

Describe the bug The chainID field in transaction deploy create2 deployer using deterministicDeployment is none.

To Reproduce Steps to reproduce the behavior:

  1. execute I create a simple contract and try deploy it using deterministicDeployment

    const deploy: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
    const { deployments, getNamedAccounts } = hre;
    const { deploy } = deployments;
    const { deployer } = await getNamedAccounts();
    const tx = await deploy("Box", {
    from: deployer,
    args: [],
    log: true,
    deterministicDeployment: true,
    autoMine: true,
    });
    };

    The network I am interacting with is the Oasis sapphire testnet, transactions sent to this network need to have a chainID field. This is a private EVM network but I think they are unrelated to the deployment

    "sapphire-testnet": {
      url: "https://testnet.sapphire.oasis.dev",
      chainId: 23295,
      accounts,
      live: true,
      tags: ["sapphire-testnet"],
    },
  2. See error

    sending eth to create2 contract deployer address (0x3fab184622dc19b6109349b94811493bf2a45362) (tx: 0x75968e16754293b48a7e522b0630a16d2d9fb675bf3bd5b95e9a0f95b450db5c)...
    deploying create2 deployer contract (at 0x4e59b44847b379578588920ca78fbf26c0b4956c) using deterministic deployment (https://github.com/Arachnid/deterministic-deployment-proxy)An unexpected error occurred:
    ...
    { "code": -32000, "message": "client: transaction check failed: runtime error: module: core code: 1 message: malformed transaction: chain ID None, expected Some(23295)" }, payload={ "id": 98, "jsonrpc": "2.0", "method": "eth_sendRawTransaction", "params": [ "0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222" ] } 

    Expected behavior

I think this problem comes from reusing deployment Transaction (https://github.com/Arachnid/deterministic-deployment-proxy). The above project has been around for 5 years. and the chainId field is not in that signedTransaction. I hope to find a new example of deterministicDeployment via hardhat-deploy.

versions

"hardhat": "^2.22.3",
"hardhat-deploy": "^0.12.2",

Additional context

wighawag commented 2 months ago

Several new network choose to not support tx without chainId and as a result do not support the create2 factory used by many other chain.

hardhat-deploy can be configured to use a different factory, see : https://github.com/wighawag/hardhat-deploy?tab=readme-ov-file#4-deterministicdeployment-ability-to-specify-a-deployment-factory