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(cheatcodes): recorded created account during broadcast #6527

Merged
merged 1 commit into from
Dec 5, 2023

Conversation

Inphi
Copy link
Contributor

@Inphi Inphi commented Dec 5, 2023

Motivation

Deployed address is incorrect when broadcasting. Fixes #6514.

Solution

The EVM behavior is slightly different when broadcast, vm.startBroadcast(), is enabled. During broadcast, the deployer address is set to the configured wallet. Previously, the record access cheatcode would always use the current EVM caller to compute the created address. This patch ensures that the appropriate caller is used.

Ensure that the appropriate caller is used to compute the deployed
address during a CREATE/CREATE2 operation. As such, during broadcast,
the configured wallet address is used rather than the current EVM caller.
// allow cheatcodes from the address of the new contract
// Compute the address *after* any possible broadcast updates, so it's based on the updated
// call inputs
let address = self.allow_cheatcodes_on_create(data, call);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that this changes the old, possibly incorrect, behavior. It might not matter, but now wallet deployed accounts are now allowed to executed cheatcodes.

Copy link
Member

@Evalir Evalir left a comment

Choose a reason for hiding this comment

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

lgtm. This only applies to the computed address, so its fine.

@Evalir Evalir merged commit fdad9fb into foundry-rs:master Dec 5, 2023
19 checks passed
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

Successfully merging this pull request may close these issues.

StateDiffRecording incorrect recording of deployment addresses when pranking/broadcasting
2 participants