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

OPSM: Deploy Superchain #11468

Closed
wants to merge 4 commits into from
Closed

OPSM: Deploy Superchain #11468

wants to merge 4 commits into from

Conversation

mds1
Copy link
Contributor

@mds1 mds1 commented Aug 14, 2024

Description

Adds DeploySuperchain.s.sol which deploys and configures the superchain contracts as described in Step 1 of ethereum-optimism/design-docs#60

This PR is focused on the in-memory version of the deployment (i.e. no file-based IO required) which is useful for e2e testing in Go. The interfaces for where files are wrapped around this core are scaffolded, but not implemented, in this PR, and will be implemented in a future PR.

This script and it's tests exist independently of the existing DeployConfig.s.sol, Deploy.s.sol, and Artifacts.s.sol contracts. This is intentional, so we can start with a clean slate here and avoid tech debt. We can integrate these deploy scripts into those ones as needed later, but I don't see a reason to pull them in yet.

Tests

A simple fuzz test is added that ensures the provided input configuration is respected, along with another concrete test to validate that zero addresses are not allowed for the role values.

Additional context

Please review the resulting Superchain architecture and ensure it's consistent with the current production architecture

@mds1 mds1 requested a review from a team as a code owner August 14, 2024 02:58
@mds1 mds1 requested a review from mbaxter August 14, 2024 02:58
_input;
_output;
outfile_;
require(false, "writeOutputFile not implemented");
Copy link
Contributor

@semgrep-app semgrep-app bot Aug 14, 2024

Choose a reason for hiding this comment

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

Malformed require statement style.

Ignore this finding from sol-style-malformed-require.

function parseInputFile(string memory _infile) public pure returns (Input memory input_) {
_infile;
input_;
require(false, "parseInputFile is not implemented");
Copy link
Contributor

Choose a reason for hiding this comment

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

Malformed require statement style.

Ignore this finding from sol-style-malformed-require.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be fixed by 233d5c2, @tynes do semgrep comments get resolved automatically once a fix commit is pushed? Seems like they don't

Input memory _input = parseInputFile(_infile);
output_ = runWithoutIO(_input);
outfile_ = writeOutputFile(_infile, _input, output_);
require(false, "run is not implemented");
Copy link
Contributor

Choose a reason for hiding this comment

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

Malformed require statement style.

Ignore this finding from sol-style-malformed-require.

}

/// @notice This entrypoint is useful for e2e testing purposes, and doesn't use any file I/O.
function runWithoutIO(Input memory _input) public returns (Output memory output_) {
Copy link
Contributor

@protolambda protolambda Aug 14, 2024

Choose a reason for hiding this comment

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

Instead of passing input/output as memory, it would be nice to have it structured as:

  • a SuperchainConfig contract that has the attributes of Input (as public getters), and a method to load config from a file.
  • a SuperchainDeployment contract with setters to write the results to, and a method that writes the final output as file to disk.

And then etch in each contract to some address that is a hash of the contract name, maybe combined with the sender address (so configs/deployments of different tests don't collide).

This would then work well with the Go forge execution, where I can insert precompiles to form the Go config + capture the outputs, without IO, by overriding these input/output contracts with Go.

Any unit-tests could read the addresses from the SuperchainDeployment contract, not that different from reading from a contract struct variable.

And, we can then Semver the input/output contracts; versioned deploy configuration would be very nice to have.

And the setters/getters of a contract would then all be "type safe" from an ABI standpoint, whereas a memory/calldata struct can have a layout with two swapped address fields and it would be hard to tell apart. The ABI signature here is: runWithoutIO(((address,address,address),bool,uint256,uint256)).

But instead it can be one ABI per config variable, and adding/removing configurables and deployment outputs would be much easier to keep compatible (not multiple struct definitions, but rather just additional getters/setters).

And, even better would be to standardize around something like check() on the config input contract and the deployment output contract, where we can do some invariant checks (ensure inputs are correct, and ensure outputs are complete/consistent). Edit: Putting a check() in the DeploySuperchain contract that uses the input/output would both be easier (no need to source the inputs to check outputs), and allow the check() to run even when the config/output are overridden.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Took a shot at this alternate approach in #11480 (though it doesn't have check() yet), keeping both PRs in draft pending a decision

@mds1 mds1 marked this pull request as draft August 14, 2024 17:56
@mds1
Copy link
Contributor Author

mds1 commented Aug 19, 2024

Closing in favor of #11480

@mds1 mds1 closed this Aug 19, 2024
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.

3 participants