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

Generic contract deployment middleware / Cross-chain create2 factory #2232

Closed
nambrot opened this issue May 11, 2023 · 12 comments
Closed

Generic contract deployment middleware / Cross-chain create2 factory #2232

nambrot opened this issue May 11, 2023 · 12 comments
Labels

Comments

@nambrot
Copy link
Contributor

nambrot commented May 11, 2023

To deploy contracts on multiple chains today, developers need a funded EOA on all chain. For example the Router abstraction tooling as well as hyperlane-deploy itself require that as well. For applications building on top of Hyperlane, you could imagine a generic contract deployment middleware to be useful. Thus the scope of this issue is to create a simple Router application looking somewhat similar to this:

interface GenericContractDeploymentMiddleware {
  function deployContract(uint32 destination, bytes bytecode, bytes32 salt)
  function deployContractAndInit(uint32 destination, bytes bytecode, bytes32 salt, bytes initCode)
}

On the sending side, it would just dispatch a message to the remote router whose handle basically just deploys a contract via a Create2Factory like this one (The create2 part of it is not strictly necessary, tho also follow foundry-rs/foundry#2638.) It would probably be secured by a RoutingISM similar to interchain accounts to allow senders to specify the ISM to be used (which allows them to not have attackers squat the address it wants if using Create2)

This allows developers to just have a balance on one chain but deploy contracts on multiple chains.

@armanthepythonguy
Copy link
Contributor

I would like to work on this. I have experience in this. I worked on something very similar in ScalingETH hackathon for my custom solution. Can you please assign me?

@nambrot
Copy link
Contributor Author

nambrot commented May 15, 2023

Go for it!

@nambrot
Copy link
Contributor Author

nambrot commented Jul 11, 2023

Probably blocked by #2512

@nambrot
Copy link
Contributor Author

nambrot commented Mar 1, 2024

Unblocked now

@lmcorbalan
Copy link

Hi @nambrot, I'm Lisandro from @BootNodeDev
We've been researching about Hyperlane and we think this issue would be a good contribution so we would like to give this a try.

  • We see the issue is quite old, so do you think changes on Hyperlane since it was created may affect in some way the description?
  • Do you see this as something added to this repo? If so, where would be the best place to add it?
  • We would like to make this work with Create2 so we were thinking about adding something like this for preventing an address to be squat by attackers. WDYT? What about having chain redeploy protection also?

@nambrot
Copy link
Contributor Author

nambrot commented Aug 30, 2024

Thanks @lmcorbalan for researching this one. I would say the bounty is still pretty applicable as it stands. It has become easier due to the lack of message limit now.

You can also check out @Destiner who has build this at Ethglobal london this year https://github.com/Destiner/hyperdeploy-contracts/blob/main/src/BytecodeRouter.sol

This work doesn't have to be added to this repo and is probably easier to do standalone. I would say that part of the bounty completion should be some basic script to deploy it on any Hyperlane chain (and allow contracts to be initiated from any other Hyperlane chain). For that, like we had mentioned on the description, we need a way to prevent squatting. IMO the easiest way to do that is to add the origin domain, the origin chain sender, as well as the ISM as part of the salt, the referenced solution imo sounds more complex than that

@lmcorbalan
Copy link

lmcorbalan commented Sep 4, 2024

Hey @nambrot I already have a simple version of a router working, Could you please take a look at https://github.com/BootNodeDev/hyperlane-create2-factory-router/tree/feat/create2-factory and let me know what you think?

Once it is finished I'll be adding some scripts for deploying and using the router, also some more doc about how to use.

@nambrot
Copy link
Contributor Author

nambrot commented Sep 9, 2024

Thanks for the update @lmcorbalan! On first look, it looks quite good, but I'm wondering if there is any way to have the key files in a PR somehow so that we can have PR comments on specific lines? I'm also wondering if you were able to test this remotely or the unit tests the main testing so far?

@lmcorbalan
Copy link

@nambrot There is a PR submitted where you could make you comments, this one BootNodeDev/hyperlane-create2-factory-router#1

Regarding testing this remotely, I have deployed the routers on Sepolia and Op Sepolia and tested deploying a contract on Sepolia from Op Sepolia, here are the txs links

And the deployed contract https://sepolia.etherscan.io/address/0xa546323EAA93eB4bA2484C3f789AA86A2260DFF0#code

@nambrot
Copy link
Contributor Author

nambrot commented Sep 12, 2024

Thank you for your patience again, left 2 small comments on the PR (sorry for missing that the first time around). Should be very close!

@pablofullana
Copy link

hey @nambrot wondering if you have any feedback on the changes based on your feedback. thanks!

@nambrot
Copy link
Contributor Author

nambrot commented Oct 11, 2024

I think that is, approved, and happy to close this bounty!

@nambrot nambrot closed this as completed Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants