Add interface for CrosschainDeployAdapter#5
Conversation
|
@mpetrunic @lastperson |
…lable deployment targets as a mapping for easier use
…tas instead of a mapping to save gas on explicit conversions
…l it within the deploy function, returning the list of contract addresses
mpetrunic
left a comment
There was a problem hiding this comment.
Looking better now, maybe create some test script that extends it and deploys some sample contract on multiple networks to ensure it works? :)
…o reset the deployment networks if they want
|
There should be more test cases, especially regarding constructor args and initDatas. For example when initData is submitted for one chain bot not other |
* update the adapter to be able to set custom salts * update the generateSalt function so that it checks if the salt has been overridden by the user. * update integration test to use `vm.expectCall` for the contract verification.
For this, is it enough to check if the adapter is called with different arguments or should I check if the upstream contracts are actually instantiated with different arguments? |
src/CrosschainDeployScript.sol
Outdated
| * @param chainId the ID of the chain on which to deploy the contract | ||
| * @return Address where the contract will be deployed on this chain. | ||
| */ | ||
| function computeAddressForChain(address sender, bytes32 salt, bool isUniquePerChain, uint256 chainId) |
There was a problem hiding this comment.
Maybe also useful to have this function with network name instead of chainId?
There was a problem hiding this comment.
YEah, that's a good idea. Changed it.
it enough that adapter is called with different args |
* Add an integration test that adds 2 deployment targets * modify simple contract to have a constructor that takes and arg, so that this can be tested as well. * Add new functions to simple contract so that it has a function that takes an argument and one that does not. * Add these function calls to the integration test so that there is a check to see that multiple deployment targets with different constructorArgs and initDatas works.
|
@mpetrunic @lastperson
I checked if there was a way users could maybe pass in the argument list in a series of strings to a script, but there's a problem with that approach (this is for when we have to build a script to wrap around this so users don't have to write abi.encode all the time), and there's no way that I can find that foundry could do something like If this PR looks fine so far, let me know and I'll rebase all the commits so you can have a final look. @lastperson I'm not sure what I should do with the |
README.md
Outdated
| contract SampleContract { | ||
| function deployMultichain public payable() { | ||
| // Remember that forge "builds" the contracts and stores them and their ABI in the root level of `out` so you'd just need to use the contract file name and the contract name and forge gets it from the ABI. | ||
| CrosschainDeployScript crosschainDeployScript = new CrosschainDeployScript("SimpleContract.sol:SimpleContract"); |
There was a problem hiding this comment.
shouldn't it make more sense for SampleContract to "extend" CrosschainDeployScript instead?
There was a problem hiding this comment.
Anything that's inheriting Script cannot be deployed. It runs locally, which is why the cheatcodes work there. So users would have to do something like use forge script and provide the contract name and the ABI code for the init variables (using cast abi-encode perhaps) to get those values and then pass them on, or use it this way, which seems much cleaner to be honest.
There was a problem hiding this comment.
But foundry recommends deploying using Script: https://book.getfoundry.sh/tutorials/solidity-scripting#writing-the-script
we don't want CrosschainDeployScript to end up being deployed (just ran locally) so when user is scripting deployment he would create DeployMyContract.sol which will extend ˙ScriptandCrosschainDeployScript` and script deployment
There was a problem hiding this comment.
I'm confused I think. Isn't that what the test case shows? I'll write up the script in the next PR that shows how users will be using this library, where they will be making a Script that calls their contract and uses the deploy script to call the upstream contract. I'd have written that here, but I thought this PR was growing big as it is and that could have been separate.
There was a problem hiding this comment.
I'm just disagreen with the sample here that instantiates CrosschainDeployScript instead of extending it
Co-authored-by: Marin Petrunić <mpetrunic@users.noreply.github.com>
…script and publish a contract instead of creating a new instance of it.
mpetrunic
left a comment
There was a problem hiding this comment.
Have you tried deploying on testnet?
… (from constructor) Signed-off-by: Marin Petrunic <marin.petrunic@gmail.com>
Signed-off-by: Marin Petrunic <marin.petrunic@gmail.com>
Signed-off-by: Marin Petrunic <marin.petrunic@gmail.com>
| addDeploymentTarget("sepolia", constructorArgs, initData); | ||
| deploy{value: msg.value}(50000, false); | ||
| addDeploymentTarget("holesky", constructorArgs, initData); | ||
| deploy{value: msg.value}("SimpleContract.sol:SimpleContract", 50000, false); |
There was a problem hiding this comment.
I thought about this but would it make sense to setup the constructorargs and initdatas before the contract itself? Because these are tied to the contract so it doesn't make sense that the contract name is something users have to supply in the deploy function, does it? Is there a scenario where a user would have to provide the same arguments to the same networks to another contract? But at that point, the deployment target queue is reset in the deploy function, isn't it?
(Sorry, was on the flight and saw these commits, wanted to understand more)
There was a problem hiding this comment.
Honestly, contructor thing was wierd. You could have script that deploy more than one contract multichain, this ensures that you can do that
There was a problem hiding this comment.
But it's still weird, isn't it? You add deployment targets against a particular contract, but it would make sense to "fix" the contract before queuing up the arguments to its later functions. Now if someone messes up the contract name, it's a waste.
How about we give a step saying setContractString instead? And check that it has been set when someone adds deployment targets, and then set that string to "" after deploy so that our script is ready to use again?
There was a problem hiding this comment.
But you can now do:
contract SampleScript is CrosschainDeployScript {
run() {
addDeploymentTarget("sepolia", constructorArgs, initData);
addDeploymentTarget("holesky", constructorArgs, initData);
deploy("SampleContract:Contract1")
addDeploymentTarget("sepolia", constructorArgs2, initData2);
addDeploymentTarget("holesky", constructorArgs2, initData2);
deploy("SampleContract:SomeOtherContract")
}
}why would this be weird?
|
I'm thinking of it like a classical function in computer programming
paradigm I guess.
We're setting up the arguments to a function and the "machine" on which to
run it before we declare the "module" from which to call the function.
😅 But you're more used to solidity, so if this is normal then that makes
more sense.
…On Thu, 8 Feb 2024, 18:56 Marin Petrunić, ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In README.md
<#5 (comment)>
:
> addDeploymentTarget("sepolia", constructorArgs, initData);
- deploy{value: msg.value}(50000, false);
+ addDeploymentTarget("holesky", constructorArgs, initData);
+ deploy{value: msg.value}("SimpleContract.sol:SimpleContract", 50000, false);
But you can now do:
contract SampleScript is CrosschainDeployScript {
run() {
addDeploymentTarget("sepolia", constructorArgs, initData);
addDeploymentTarget("holesky", constructorArgs, initData);
deploy("SampleContract:Contract1")
addDeploymentTarget("sepolia", constructorArgs2, initData2);
addDeploymentTarget("holesky", constructorArgs2, initData2);
deploy("SampleContract:SomeOtherContract")
}
}
why would this be weird?
—
Reply to this email directly, view it on GitHub
<#5 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACXSLC4BNNXZO3UVJEY3PBTYSTG7DAVCNFSM6AAAAABB4L44JGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTQNZQGIZDKMJSGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Addresses foundry-rs/foundry#2