feat(cast create2
): Added --caller
flag
#6363
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.