@@ -13,6 +13,7 @@ import (
1313 ktfs "github.com/ethereum-optimism/optimism/devnet-sdk/kt/fs"
1414 "github.com/ethereum-optimism/optimism/devnet-sdk/types"
1515 "github.com/ethereum-optimism/optimism/op-chain-ops/devkeys"
16+ "github.com/ethereum-optimism/optimism/op-node/rollup"
1617 "github.com/ethereum/go-ethereum/common"
1718 "github.com/ethereum/go-ethereum/common/hexutil"
1819 "github.com/ethereum/go-ethereum/core"
@@ -28,6 +29,7 @@ const (
2829 defaultGenesisArtifactName = "el_cl_genesis_data"
2930 defaultMnemonicName = "mnemonics.yaml"
3031 defaultGenesisNameTemplate = "genesis-{{.ChainID}}.json"
32+ defaultRollupNameTemplate = "rollup-{{.ChainID}}.json"
3133 defaultL1GenesisName = "genesis.json"
3234)
3335
@@ -38,11 +40,12 @@ type DeploymentAddresses map[string]types.Address
3840type DeploymentStateAddresses map [string ]DeploymentAddresses
3941
4042type DeploymentState struct {
41- L1Addresses DeploymentAddresses `json:"l1_addresses"`
42- L2Addresses DeploymentAddresses `json:"l2_addresses"`
43- L1Wallets WalletList `json:"l1_wallets"`
44- L2Wallets WalletList `json:"l2_wallets"`
45- Config * params.ChainConfig `json:"chain_config"`
43+ L1Addresses DeploymentAddresses `json:"l1_addresses"`
44+ L2Addresses DeploymentAddresses `json:"l2_addresses"`
45+ L1Wallets WalletList `json:"l1_wallets"`
46+ L2Wallets WalletList `json:"l2_wallets"`
47+ Config * params.ChainConfig `json:"chain_config"`
48+ RollupConfig * rollup.Config `json:"rollup_config"`
4649}
4750
4851type DeployerState struct {
@@ -83,6 +86,7 @@ type Deployer struct {
8386 genesisArtifactName string
8487 l1ValidatorMnemonicName string
8588 l2GenesisNameTemplate string
89+ l2RollupNameTemplate string
8690 l1GenesisName string
8791}
8892
@@ -124,6 +128,12 @@ func WithGenesisNameTemplate(name string) DeployerOption {
124128 }
125129}
126130
131+ func WithRollupNameTemplate (name string ) DeployerOption {
132+ return func (d * Deployer ) {
133+ d .l2RollupNameTemplate = name
134+ }
135+ }
136+
127137func NewDeployer (enclave string , opts ... DeployerOption ) * Deployer {
128138 d := & Deployer {
129139 enclave : enclave ,
@@ -133,6 +143,7 @@ func NewDeployer(enclave string, opts ...DeployerOption) *Deployer {
133143 genesisArtifactName : defaultGenesisArtifactName ,
134144 l1ValidatorMnemonicName : defaultMnemonicName ,
135145 l2GenesisNameTemplate : defaultGenesisNameTemplate ,
146+ l2RollupNameTemplate : defaultRollupNameTemplate ,
136147 l1GenesisName : defaultL1GenesisName ,
137148 }
138149
@@ -354,6 +365,29 @@ func (d *Deployer) ExtractData(ctx context.Context) (*DeployerData, error) {
354365
355366 // Store the genesis data in the deployment state
356367 deployment .Config = genesis .Config
368+
369+ rollupBuffer := bytes .NewBuffer (nil )
370+ rollupName , err := d .renderRollupNameTemplate (id )
371+ if err != nil {
372+ return nil , err
373+ }
374+
375+ if err := deployerArtifact .ExtractFiles (
376+ ktfs .NewArtifactFileWriter (rollupName , rollupBuffer ),
377+ ); err != nil {
378+ return nil , err
379+ }
380+
381+ // Parse the genesis file JSON into a core.Genesis struct
382+ var rollupCfg rollup.Config
383+ if err := json .NewDecoder (rollupBuffer ).Decode (& rollupCfg ); err != nil {
384+ return nil , fmt .Errorf ("failed to parse rollup file %s in artifact %s for chain ID %s: %w" , rollupName , d .deployerArtifactName , id , err )
385+ }
386+
387+ // Store the data in the deployment state
388+ deployment .Config = genesis .Config
389+ deployment .RollupConfig = & rollupCfg
390+
357391 state .Deployments [id ] = deployment
358392 }
359393
@@ -381,15 +415,23 @@ func (d *Deployer) ExtractData(ctx context.Context) (*DeployerData, error) {
381415}
382416
383417func (d * Deployer ) renderGenesisNameTemplate (chainID string ) (string , error ) {
384- tmpl , err := template .New ("genesis" ).Parse (d .l2GenesisNameTemplate )
418+ return d .renderNameTemplate (d .l2GenesisNameTemplate , chainID )
419+ }
420+
421+ func (d * Deployer ) renderRollupNameTemplate (chainID string ) (string , error ) {
422+ return d .renderNameTemplate (d .l2RollupNameTemplate , chainID )
423+ }
424+
425+ func (d * Deployer ) renderNameTemplate (t , chainID string ) (string , error ) {
426+ tmpl , err := template .New ("" ).Parse (t )
385427 if err != nil {
386- return "" , fmt .Errorf ("failed to compile genesis name template %s: %w" , d . l2GenesisNameTemplate , err )
428+ return "" , fmt .Errorf ("failed to compile name template %s: %w" , t , err )
387429 }
388430
389431 var buf bytes.Buffer
390432 err = tmpl .Execute (& buf , map [string ]string {"ChainID" : chainID })
391433 if err != nil {
392- return "" , fmt .Errorf ("failed to execute name template %s: %w" , d . l2GenesisNameTemplate , err )
434+ return "" , fmt .Errorf ("failed to execute name template %s: %w" , t , err )
393435 }
394436
395437 return buf .String (), nil
0 commit comments