diff --git a/.changeset/proud-apes-explain.md b/.changeset/proud-apes-explain.md new file mode 100644 index 0000000000..e6ef77caeb --- /dev/null +++ b/.changeset/proud-apes-explain.md @@ -0,0 +1,5 @@ +--- +"@latticexyz/cli": patch +--- + +Fixed an issue where deploys were warning about mismatched bytecode when the bytecode was correct and what we expect. diff --git a/packages/cli/src/deploy/create2/README.md b/packages/cli/src/deploy/create2/README.md index beb5c9f8bf..6e56503779 100644 --- a/packages/cli/src/deploy/create2/README.md +++ b/packages/cli/src/deploy/create2/README.md @@ -7,7 +7,7 @@ git checkout b3bb19c npm install npm run build cd output -jq --arg bc "$(cat bytecode.txt)" '. + {bytecode: $bc}' deployment.json > deployment-with-bytecode.json -mv deployment-with-bytecode.json deployment.json +jq --arg bc "$(cat bytecode.txt)" '. + {creationCode: $bc}' deployment.json > deployment-with-creationCode.json +mv deployment-with-creationCode.json deployment.json cp deployment.json ../path/to/this/dir ``` diff --git a/packages/cli/src/deploy/create2/deployment.json b/packages/cli/src/deploy/create2/deployment.json index 21d97ff780..bd070c9be4 100644 --- a/packages/cli/src/deploy/create2/deployment.json +++ b/packages/cli/src/deploy/create2/deployment.json @@ -4,5 +4,5 @@ "signerAddress": "3fab184622dc19b6109349b94811493bf2a45362", "transaction": "f8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222", "address": "4e59b44847b379578588920ca78fbf26c0b4956c", - "bytecode": "604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3" + "creationCode": "604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3" } diff --git a/packages/cli/src/deploy/ensureDeployer.ts b/packages/cli/src/deploy/ensureDeployer.ts index 92c7c136b0..86f59ccd18 100644 --- a/packages/cli/src/deploy/ensureDeployer.ts +++ b/packages/cli/src/deploy/ensureDeployer.ts @@ -1,16 +1,16 @@ -import { Account, Address, Chain, Client, Transport } from "viem"; +import { Account, Address, Chain, Client, Transport, sliceHex } from "viem"; import { getBalance, getBytecode, sendRawTransaction, sendTransaction, waitForTransactionReceipt } from "viem/actions"; import deployment from "./create2/deployment.json"; import { debug } from "./debug"; const deployer = `0x${deployment.address}` as const; -const deployerBytecode = `0x${deployment.bytecode}` as const; export async function ensureDeployer(client: Client): Promise
{ const bytecode = await getBytecode(client, { address: deployer }); if (bytecode) { debug("found CREATE2 deployer at", deployer); - if (bytecode !== deployerBytecode) { + // check if deployed bytecode is the same as the expected bytecode (minus 14-bytes creation code prefix) + if (bytecode !== sliceHex(`0x${deployment.creationCode}`, 14)) { console.warn( `\n ⚠️ Bytecode for deployer at ${deployer} did not match the expected CREATE2 bytecode. You may have unexpected results.\n`, ); @@ -53,7 +53,7 @@ export async function ensureDeployer(client: Client