Forge cheatcode for explicit contract deployment address #4645
Replies: 2 comments 2 replies
-
There are solutions to your issue that don't require a new cheat code:
|
Beta Was this translation helpful? Give feedback.
-
Would this method not add unnecessary overhead when making production deployments? If the address making a mainnet deployment of the Controller is an EOA then the create2 calculation code inside of the Workers would just be for the sake of a working test environment and will have to be pruned to make the contract production ready. At that point, I think just an external method on the Worker to set the Controller address at runtime would be a less convoluted solution, but this again requires overhead that would be obsolete with a cheatcode like the one I described. I may just be completely misunderstanding something however as I am admittedly somewhat of a solidity newbie. Thanks for the help Matt. |
Beta Was this translation helpful? Give feedback.
-
A cheatcode to specify an address of a deployment inside of forge would be extremely useful imo. I have a contract (lets call this the "worker") that can only be called from another contract (the "controller"). Currently, ownership is hard-coded into the worker contract to save gas. This is where the bug was introduced, when a collaborator set this address to the deployment address of the controller that they observed on their machine, all of the tests broke on my machine. Since deployment addresses are not constant across environments, having a cheatcode to explicitly set the address of a deployment like
vm.deploy(<contract>, <address>)
orvm.bind(<contract>, <address>)
would greatly improve developer experience as less configuration is needed between environments and less ambiguity when reasoning about "where" your contracts reside in forge.Beta Was this translation helpful? Give feedback.
All reactions