-
Notifications
You must be signed in to change notification settings - Fork 2k
feat: vm.mineSalt
cheat code
#2359
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
I would like to work on this one please. |
Right now So this issue is separate from cast and would allow for mining the salt create2 contracts directly in a To your point, we could add this directly to cast and then use ffi to access in a script, but personally I prefer a dedicated cheatcode (and eventually cast support also) because ffi can be dangerous since it executes arbitrary commands. @onbjerg @mattsse let me know if you have any thoughts/objections here 🙂 |
I see your point, and didn't knew that Maybe we could add a Also, if we add the |
I think |
I have a slight preference of this being implemented in |
Just curious as to why you prefer a wrapper method that uses ffi? IMO a cheatcode is preferable for common actions like this to avoid introducing the security risks of ffi. Assuming the wrapper method would be part of forge-std, I believe it would also be the first method in forge-std that uses ffi which i dont love for the same reason. |
What about adding a feature to manually choose which directory has the right to run ffi to mitigate security issues ? |
+1, that's the most straightforward solution |
Happy to concede and go with that approach, but do want to understand why it's preferable given #2359 (comment) 😅 Both the cast command and cheatcode should be able to use the same underlying method + not needing |
Another idea here if people don't like the idea of a |
Strongly agree here! Would be nice to avoid having to ffi unless absolutely needed. Is there a lot of overhead involved with adding as a cheatcode if the code is already there for cast?
I really like this idea and I think it would be a valuable addition to Foundry for scripting. There are plenty of use cases where "slower execution, but we can keep our dev environment simple and all in Solidity" is a good tradeoff. I will say that mining salts is an extremely common use case, so a rust-based cheat code specifically for it would be nice, as would a cast command. But I think the ability to stop/start gas metering is broadly useful as well. I guess what I'm saying is, I want both 😅 |
@mds1 It is a lot more complex to do |
People are already doing this wiht FFI at this point FWIW e.g. https://github.com/antoncoding/grappa/blob/master/script/Deploy.sol#L70-L98 Let's do a cheatcode, the gas metering stuff seems like a big pain. |
@mattsse Mind reopening this? We now have create2 support in cast, but don't actually have a forge cheatcode yet |
Just curious as to why you prefer a wrapper method that uses ffi? IMO a
cheatcode is preferable for common actions like this to avoid introducing
the security risks of ffi.
Assuming the wrapper method would be part of forge-std, I believe it would
also be the first method in forge-std that uses ffi which i dont love for
the same reason.
…On Mon, Jul 25, 2022 at 9:16 AM Mark Tyneway ***@***.***> wrote:
I have a slight preference of this being implemented in cast and then
writing a simple solidity library that wraps cast with ffi instead of
adding an additional cheatcode here
—
Reply to this email directly, view it on GitHub
<#2359 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEC6NVFMZSUWY5TMCJDJVBTVV24V5ANCNFSM532UEIXQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Cheatcode 👍 |
This |
Another script to mine salts by calling It feels a little odd to call cast over ffi and to parse the string output, I would much rather use a cheatcode |
When I wanted to implement the cheatcode, I was limited by a circular dependency issue. Can eventually give it another go. |
Since the ticket was raised most developers use https://github.com/0age/create2crunch for finding efficient salts, often hiring a GPU cluster in the cloud. Having this be part of running the script flow as a cheatcode seems a bit redundant to me. |
using create2crunch is much more involved though. It's great when you want to mine 14 zeroes for Seaport, but sometimes all you need is a cute selector with a given prefix. Having a convenient option to do that locally is nice without having to go rent a GPU |
I see - that makes sense, I was only considering the leading 0 case
Hi @iFrostizz, would you be interested in picking this ticket back up? |
Hi @zerosnacks , I am not anymore, will unassign me ! Not sure about your philosophy around cheatcode, imo they should be added sparingly, only when working around it is not possible. |
Closing given the niche use case and the already available |
Component
Forge
Describe the feature you would like
It's common to want to deploy with vanity addresses, which can be done two ways:
Right now with approach 2 it's easy to mine a 4 character salt in a solidity script with a simple
for
loop, however you run out of gas (exceeds the u64 limit) if you try e.g. 8 characters. A cheat code for approach 1 isn't in consideration here since you'd need to fund the address mid-script and that feels clunky.While of course you can do all the mining outside of the script, for short vanity addresses it's convenient to do this in the script, and without needing to rely on
ffi
or worry about the gas limit.Proposed UX:
Above, the user provides:
--matching
flag usesAnd it returns the computed salt and the resulting address.
Additional context
No response
The text was updated successfully, but these errors were encountered: