Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create2 deployment type should make use of Create2Factory #1543

Open
dutterbutter opened this issue Nov 14, 2024 · 0 comments
Open

Create2 deployment type should make use of Create2Factory #1543

dutterbutter opened this issue Nov 14, 2024 · 0 comments
Assignees

Comments

@dutterbutter
Copy link
Contributor

🐛 Bug Report for hardaht-zksync plugins

💥 Plugin name

hardhat-zksync-deploy

📝 Description

Deploying the same create2 contract with different deployer wallets should result in the same deterministic address. For example, deploying to zksync-testnet and abstract-testnet with two different accounts should still result in the same address.

zksync-testnet

bunx hardhat deploy-zksync:contract --deployment-type create2 --salt 0x7935910912126667836566922594852029127629416664760357073852948630 --network zksync-testnet --contract-name Counter

abstract-testnet

bunx hardhat deploy-zksync:contract --deployment-type create2 --salt 0x7935910912126667836566922594852029127629416664760357073852948630 --network abstract-testnet --contract-name Counter

Using different deployer wallets here will result in two distinct create2 addresses. We should make use of Create2Factory so the deployer wallet is not accounted for. Example script below can be used to determine create2 address regardless of deployer wallet.

import { HardhatRuntimeEnvironment } from "hardhat/types";
import { utils } from "zksync-ethers";
import { hexlify } from "ethers";

const deployScript = async function (hre: HardhatRuntimeEnvironment) {
  console.info(`Running deploy script for the Counter contract`);

  const artifact = await hre.deployer.loadArtifact("Counter");
  const counterBytecodeHash = hexlify(utils.hashBytecode(artifact.bytecode));
  const salt =
    "0x7935910912126667836566922594852029127629416664760357073852948630";
  const create2FactoryAddress = "0x0000000000000000000000000000000000010000";

  const deterministicAddress = utils.create2Address(
    create2FactoryAddress,
    counterBytecodeHash,
    salt,
    "0x"
  );
  console.log("Counter contract address: ", deterministicAddress);
};

export default deployScript;

Rather then having to use the above script, it would be nice to make use of the above mentioned command.

It seems it takes account the deployer address

🔄 Reproduction Steps

  1. Deploy Counter contract using create2 with "wallet A" on zksync-testnet observe the address
  2. Deploy the same contract using create2 with "wallet B" on abstract-testnet observe the address

🤔 Expected Behavior

Deterministic address regardless of deployer wallet

😯 Current Behavior

Different address due to different deployer wallets being used

🖥️ Environment

  • Node version: [e.g., Node 18.16.1]
  • Operating System & Version: [e.g., Ubuntu 20.04]
  • Other relevant environment details:

📋 Additional Context

📎 Log Output

Paste any relevant log output here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants