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

feat: deterministic deployment scripts #5

Draft
wants to merge 46 commits into
base: main
Choose a base branch
from

Conversation

Thegaram
Copy link
Contributor

@Thegaram Thegaram commented Jul 9, 2024

Migrated from scroll-tech/scroll#1303.

Problem: The current deployment scripts are slow and error-prone. We need to predict the deployment addresses of some contracts (e.g. for preallocating funds to L2ScrollMessenger in L2 genesis), but currently the addresses depend on the deployer private key and the order of deployment. If one transaction fails, subsequent transactions will lead to different addresses.

Solution:

  • Use https://github.com/Arachnid/deterministic-deployment-proxy to make contract addresses much more predictable.
  • Use a single Foundry script for deployment and initialization on L1 and L2 (basically merge the previous 5 scripts).
  • Move genesis generation into the Foundry script. Previously this was a complex combination of Javascript, Rush, and bash scripts.
  • Provide convenient Docker images. This makes deployment much more robust (we enforce a fixed Foundry version known to be working), and fast (compilation done in the build phase, no need to recompile when running the container).
  • Use a TOML configuration file.

Caveats:

  • Some of the deployed addresses still depend on the deployer account. The reason is that some contracts take the owner as a constructor argument, and the initial owner is the deployer account, so changing this also changes the create2 deterministic address. But the addresses do not depend on deployment order anymore.

@Thegaram Thegaram requested a review from yiweichi July 9, 2024 13:55
@yiweichi yiweichi marked this pull request as ready for review July 10, 2024 13:58
@Thegaram Thegaram marked this pull request as draft July 10, 2024 14:56
@zimpha zimpha self-requested a review July 17, 2024 03:40
docker/scripts/deploy.sh Outdated Show resolved Hide resolved
@yiweichi yiweichi force-pushed the feat-deterministic-deployment branch from 187563f to 65c5b4e Compare August 20, 2024 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants