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

fix(cli): fix deployer warning #2683

Merged
merged 3 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the 14?

Copy link
Member Author

@holic holic Apr 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basically the opcodes to create the contract + constructor stuff

image

holic marked this conversation as resolved.
Show resolved Hide resolved
alvrs marked this conversation as resolved.
Show resolved Hide resolved
`\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
Loading