Skip to content

Commit

Permalink
fix(cli): fix deployer warning (#2683)
Browse files Browse the repository at this point in the history
  • Loading branch information
holic authored Apr 17, 2024
1 parent 8a751da commit 632a752
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-apes-explain.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 2 additions & 2 deletions packages/cli/src/deploy/create2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
2 changes: 1 addition & 1 deletion packages/cli/src/deploy/create2/deployment.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"signerAddress": "3fab184622dc19b6109349b94811493bf2a45362",
"transaction": "f8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222",
"address": "4e59b44847b379578588920ca78fbf26c0b4956c",
"bytecode": "604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"
"creationCode": "604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"
}
8 changes: 4 additions & 4 deletions packages/cli/src/deploy/ensureDeployer.ts
Original file line number Diff line number Diff line change
@@ -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<Transport, Chain | undefined, Account>): Promise<Address> {
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`,
);
Expand Down Expand Up @@ -53,7 +53,7 @@ export async function ensureDeployer(client: Client<Transport, Chain | undefined
debug("deploying CREATE2 deployer");
return sendTransaction(client, {
chain: client.chain ?? null,
data: deployerBytecode,
data: `0x${deployment.creationCode}`,
});
}
throw error;
Expand Down

0 comments on commit 632a752

Please sign in to comment.