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

Deploying the P256Verifier contract on a new EVM chain #46

Open
yohanelly95 opened this issue Jul 25, 2024 · 7 comments
Open

Deploying the P256Verifier contract on a new EVM chain #46

yohanelly95 opened this issue Jul 25, 2024 · 7 comments

Comments

@yohanelly95
Copy link

Running the same script and deploying the same contract with the same salt (ie, 0) deploys to a new contract address and not the deterministic address 0xc2b78104907F722DABAc4C69f826a522B2754De4 .

I also used the same optimizer runs as well. Do you know what is being missed here?

@yohanelly95
Copy link
Author

Note: CREATE2 does exist on the chain. For eg, even using anvil where the Create2 Factory is deployed does not deploy the contract to the same deterministic address @nalinbhardwaj

@nalinbhardwaj nalinbhardwaj closed this as not planned Won't fix, can't repro, duplicate, stale Jul 25, 2024
@nalinbhardwaj nalinbhardwaj reopened this Jul 25, 2024
@nalinbhardwaj
Copy link
Member

nalinbhardwaj commented Jul 25, 2024

Sorry, misunderstood your second comment:

Are you using the same version of Foundry / solc (0.8.21) as the repository?

It may also be simpler to replay our deployment transaction so you don't have to replicate the repo set up exactly.

@yohanelly95
Copy link
Author

Sorry, misunderstood your second comment:

Are you using the same version of Foundry / solc (0.8.21) as the repository?

It may also be simpler to replay our deployment transaction so you don't have to replicate the repo set up exactly.

Yes using the same solc version, specified it in the foundry toml along with the optimizer runs as well.

I see, so this txn is a call to the Create2 factory contract. I would like to deploy this contract on anvil for now, so technically if the foundry toml matches and the contract matches (including the same salt) then it should deploy to the deterministic address? Not sure why that's not working currently for me

@yohanelly95
Copy link
Author

@nalinbhardwaj actually not using the same foundry version, I am on forge 0.2.0 (62cdea8 2024-07-23T00:18:49.756549000Z). Would this matter though for the deployment? Since we are using the Create2 factory to deploy the contract.

@thomasknauth
Copy link

thomasknauth commented Aug 27, 2024

One thing I recently discovered is that if you just "forge build" you will not arrive at the same address because the bytecode differs. Apparently, the final portion of the bytecode encodes metadata (i.e., hashes) of the build configuration. Unless the build configuration matches exactly (compiler version is just one moving piece among many that can change the final hash; in my case, I suspect additional remappings which forge inserts automatically) with what was used originally (and it does not match out of the box, unfortunately) you will not arrive at the same address. I was actually going to create an issue and suggest the repo should at least mention somewhere that it is not sufficient to just run "forge build" to arrive at the same bytecode/deploy address.

@yohanelly95
Copy link
Author

One thing I recently discovered is that if you just "forge build" you will not arrive at the same address because the bytecode differs. Apparently, the final portion of the bytecode encodes metadata (i.e., hashes) of the build configuration. Unless the build configuration matches exactly (compiler version is just one moving piece among many that can change the final hash; in my case, I suspect additional remappings which forge inserts automatically) with what was used originally (and it does not match out of the box, unfortunately) you will not arrive at the same address. I was actually going to create an issue and suggest the repo should at least mention somewhere that it is not sufficient to just run "forge build" to arrive at the same bytecode/deploy address.

I agree, the repo should add this as a side-note. For now I have forked the repo and updated the address on the forked repo.

@holic
Copy link

holic commented Sep 24, 2024

might make sense for them to check in the compiled bytecode + init code and an alternative deploy script that uses that for deployment rather than the local foundry's compiled output (which may differ due to above)

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

4 participants