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

Deploy with CREATE3 for Deterministic Addresses to Resolve Cyclical Dependencies in Contract Deployment #124

Merged
merged 7 commits into from
Apr 18, 2024

Conversation

kingster-will
Copy link

Description:

This PR introduces the use of CREATE3 for deploying our smart contracts, an update aimed at resolving the challenges posed by cyclical dependencies during the deployment phase. By leveraging CREATE3, we can deploy contracts to deterministic addresses using a predefined salt. This approach has several advantages and key implementations as detailed below:

  1. Deterministic Deployment: Utilize CREATE3 to ensure all contracts with cyclical dependencies are deployed to known, deterministic addresses. This method uses only a salt for address derivation, making the process more predictable and secure.
  2. Immutable Storage: By directly passing these deterministic addresses to the constructors of dependent contracts, we can store them as immutable variables within the contracts. This not only enhances security but also improves the efficiency of contract interactions.
  3. Simplification of Protocol: With the addresses being hardcoded and immutable, the need for post-deployment governance functions to set these addresses is eliminated. This significantly simplifies our protocol by reducing the layers of interaction required and minimizing the potential for human error.

Benefits:

  • Robust Contract Interaction: Hardcoding addresses as immutable variables reduces the risk of address manipulation and ensures more robust interactions between interconnected contracts.
  • Protocol Streamlining: Eliminates the need for manual interventions in the form of governance actions to set contract addresses after deployment, thereby streamlining operations and reducing the scope for errors.

Tests Plane

All changes are covered by existing automation tests.

Related Issues

Closes #106

@kingster-will kingster-will changed the title Implement CREATE3 for Deterministic Addresses to Resolve Cyclical Dependencies in Contract Deployment Deploy with CREATE3 for Deterministic Addresses to Resolve Cyclical Dependencies in Contract Deployment Apr 17, 2024
Copy link

@jdubpark jdubpark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, comments:

  • Should we validate the addresses passed in constructors? (We've been doing zero address validation for access manager in initializers)
  • This change requires upgrading contracts if any immutable address needs to be changed (new proxy).

@kingster-will
Copy link
Author

Added check for empty address in the constructors.

Copy link

@Ramarti Ramarti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@LeoHChen LeoHChen merged commit a5d572c into storyprotocol:main Apr 18, 2024
3 checks passed
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.

Resolve Cyclical Dependencies in Contract Deployment Using CREATE3
4 participants