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

feat(cast create2): Added --caller flag #6363

Merged
merged 5 commits into from
Nov 20, 2023

Conversation

RedaOps
Copy link
Contributor

@RedaOps RedaOps commented Nov 20, 2023

See #6353 for full motivation.

The --caller flag just picks the first 20 bytes (address) of the salt to be used in different CREATE2 factories that require such a protection.

Motivation

closes #6353

Solution

The salt generation will now start from the 24th byte of the 32 byte salt, instead of the first byte.

If the flag is empty, the first 20 bytes of the salt will be left empty. If not, the first 20 bytes will be filled with the address and the next 4 bytes will always be empty (the pointer offset is 24 and not 20 so the address of the usize object it's being cast to stays aligned)

I have also written unit tests for this flag.

Also, @DaniPopes please double check that the program remains memory safe. The loop should still need to fill up an entire u32/u64 object in order to overflow, like in the previous state (https://github.com/foundry-rs/foundry/pull/6212/files#r1382238402), but just to be sure.

@RedaOps
Copy link
Contributor Author

RedaOps commented Nov 20, 2023

Clippy broke in #6360.

crates/cast/bin/cmd/create2.rs Outdated Show resolved Hide resolved
crates/cast/bin/cmd/create2.rs Show resolved Hide resolved
Copy link
Member

@DaniPopes DaniPopes left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@DaniPopes DaniPopes merged commit 8329549 into foundry-rs:master Nov 20, 2023
19 checks passed
@RedaOps RedaOps deleted the cast-caller branch November 20, 2023 14:05
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.

cast create2 should add --caller arg
2 participants