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

op-chain-ops/interopgen: experimental interop genesis-state generation #11589

Closed
wants to merge 1 commit into from

Conversation

protolambda
Copy link
Contributor

Description

Experimental draft of interop multi-L2 devnet genesis state generation code.

This can largely be cleaned up after the L2 chain deployment part of OPSM lands:

  • Inputs will be statically typed, no need for partial deploy-config hack
  • Outputs will be statically typed, no need for dynamic map of addresses (deploy-registry hack)
  • FP deployment will be cleaner, no need for workarounds
  • Deployment steps will be more succinct, no need to workaround legacy deployment step issues
  • Diff with Artifacts can be dropped, as we don't use the legacy deployment anymore at that point

But for now, just need to get a working genesis deployment, so these temporary workarounds will have to do.

Tests

recipe_test.go turns a basic interop recipe into an expanded WorldConfig, which can then be deployed into a WorldDeployment (address data) and WorldOutput (genesis configs and state).

Metadata

Fix #11493

@@ -25,9 +26,107 @@ struct Deployment {
/// @notice Useful for accessing deployment artifacts from within scripts.
/// When a contract is deployed, call the `save` function to write its name and
/// contract address to disk. Inspired by `forge-deploy`.
/// @dev This uses the DeploymentRegistry contract, to load/store deployments,
Copy link
Contributor

Choose a reason for hiding this comment

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

Prefer @notice over @dev in natspec comments

Ignore this finding from sol-style-notice-over-dev-natspec.

Copy link
Contributor

semgrep-app bot commented Aug 23, 2024

Semgrep found 3 sol-style-return-arg-fmt findings:

Named return arguments to functions must be appended with an underscore (_)

Ignore this finding from sol-style-return-arg-fmt.

@protolambda protolambda self-assigned this Aug 23, 2024
@protolambda protolambda added this to the Interop: Devnet 1 milestone Aug 23, 2024
@protolambda protolambda mentioned this pull request Aug 23, 2024
2 tasks
Copy link
Contributor

@axelKingsley axelKingsley left a comment

Choose a reason for hiding this comment

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

Bunch of questions for my own benefit, and a couple of code cleanliness/ comment opportunities.

op-chain-ops/devkeys/devkeys.go Show resolved Hide resolved
op-chain-ops/genesis/config.go Show resolved Hide resolved
if c.ChainID == nil {
return errors.New("missing L1 chain ID")
}
// nothing to check on c.DevL1DeployConfig
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume nothing to check on Prefund as well?

return nil
}

type SuperchainConfig struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would love comments over these structs that show the different purpose of:

  • L1Config
  • SuperchainConfig
  • L2Config

My intuition is that there's One L1, One Superchain, and N L2s, but I don't see the SuperchainConfig linked into the L1 config in any way. Rather they're linked to a genesis....Config

Comment on lines +73 to +77
type WorldConfig struct {
L1 *L1Config
Superchain *SuperchainConfig
L2s map[string]*L2Config
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I think this answers one of my earlier questions about how these configs interplay.

Comment on lines +403 to +405
// Insert an empty beaconchain deposit contract with valid empty-tree prestate.
// This is part of dev-genesis, but not part of scripts yet.
beaconDepositAddr := common.HexToAddress("0x1111111111111111111111111111111111111111")
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the relevance of 0x1111... here? Any value in making this configurable?

}, nil
}

func completeL2(l2Host *script.Host, cfg *L2Config, l1Block *types.Block, deployment *L2Deployment) (*L2Output, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could use function comments to highlight the difference between deploying an L2 and completing it.

Comment on lines +116 to +117
// Padded chain ID, hex encoded, prefixed with 0xff like inboxes, then 0x02 to signify devnet.
batchInboxAddress := common.HexToAddress(fmt.Sprintf("0xff02%016x", l2ChainID))
Copy link
Contributor

Choose a reason for hiding this comment

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

Would love more explanation on the relationship between 0x02 and Devnet

},
FaultProofDeployConfig: genesis.FaultProofDeployConfig{
UseFaultProofs: true,
FaultGameAbsolutePrestate: common.HexToHash("0x03c7ae758795765c6664a5d39bf63841c71ff191e9189522bad8ebff5d4eca98"),
Copy link
Contributor

Choose a reason for hiding this comment

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

What's this hex about? The other ones look obvious but I don't see any special value here.

Comment on lines +35 to +42
require.NoError(t, err)
enc := json.NewEncoder(os.Stdout)
enc.SetIndent(" ", " ")
require.NoError(t, enc.Encode(worldDeployment))
logger.Info("L1 output", "accounts", len(worldOutput.L1.Genesis.Alloc))
for id, l2Output := range worldOutput.L2s {
logger.Info("L2 output", "chain", &id, "accounts", len(l2Output.Genesis.Alloc))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Mostly we're just looking for no errors when Deploying? is there any testing you'd want to do on these emitted logs?

@protolambda
Copy link
Contributor Author

Closing in favor of interopgen2, here: #11702

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

op-chain-ops: generate L1 and L2 genesis by running forge script in Go
2 participants