Skip to content

Commit

Permalink
feat: receive admin address at launch (#136)
Browse files Browse the repository at this point in the history
* receive admin address at launch

* comment
  • Loading branch information
beer-1 authored Feb 23, 2025
1 parent 7bb2292 commit 89d1bf8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
3 changes: 3 additions & 0 deletions contrib/launchtools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ minitiad launch $TARGET_NETWORK --with-config [path-to-config]
"enable_oracle": true
},
"system_keys": {
"admin": {
"l2_address": "init12z54lfqgp7zapzuuk2m4h6mjz84qzca8j0wm4x"
},
"validator": {
"l2_address": "init12z54lfqgp7zapzuuk2m4h6mjz84qzca8j0wm4x",
"mnemonic": "digital kingdom slim fall cereal aspect expose trade once antique treat spatial unfair trip silver diesel other friend invest valve human blouse decrease salt"
Expand Down
12 changes: 12 additions & 0 deletions contrib/launchtools/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ func (gas *GenesisAccounts) Finalize(systemKeys SystemKeys) error {
}

type SystemKeys struct {
Admin *SystemAccount `json:"admin,omitempty"`
Validator *SystemAccount `json:"validator,omitempty"`
BridgeExecutor *SystemAccount `json:"bridge_executor,omitempty"`
OutputSubmitter *SystemAccount `json:"output_submitter,omitempty"`
Expand Down Expand Up @@ -463,8 +464,19 @@ func (systemKeys *SystemKeys) Finalize(buf *bufio.Reader, batchSubmissionTarget
Mnemonic: mnemonic,
}
}
if systemKeys.Admin == nil {
// use validator account as admin account if not set
systemKeys.Admin = &SystemAccount{
L1Address: systemKeys.Validator.L2Address,
L2Address: systemKeys.Validator.L2Address,
Mnemonic: systemKeys.Validator.Mnemonic,
}
}

// validate all accounts
if systemKeys.Admin.L2Address == "" {
return errors.New("admin account not initialized")
}
if systemKeys.Validator.L2Address == "" || systemKeys.Validator.Mnemonic == "" {
return errors.New("validator account not initialized")
}
Expand Down
9 changes: 6 additions & 3 deletions contrib/launchtools/steps/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,17 @@ func initializeGenesis(
// Add fee whitelist to genesis
// whitelist specific operators for fee exemption
log.Info("adding fee whitelists",
"whitelist-len", 3,
"whitelist-len", 4,
"whitelists", strings.Join([]string{
config.SystemKeys.Admin.L2Address,
config.SystemKeys.Validator.L2Address,
config.SystemKeys.BridgeExecutor.L2Address,
config.SystemKeys.Challenger.L2Address,
}, ","),
)

opChildState, err = addFeeWhitelists(cdc, genesisAppState, []string{
config.SystemKeys.Admin.L2Address,
config.SystemKeys.Validator.L2Address,
config.SystemKeys.BridgeExecutor.L2Address,
config.SystemKeys.Challenger.L2Address,
Expand All @@ -200,10 +203,10 @@ func initializeGenesis(
// Step 5 -------------------------------------------------------------------------------------------
// Set admin address in the genesis parameter
log.Info("setting admin address",
"admin", config.SystemKeys.Validator.L2Address,
"admin", config.SystemKeys.Admin.L2Address,
)

opChildState, err = setOpChildAdminAddress(cdc, genesisAppState, config.SystemKeys.Validator.L2Address)
opChildState, err = setOpChildAdminAddress(cdc, genesisAppState, config.SystemKeys.Admin.L2Address)
if err != nil {
return nil, errors.Wrap(err, "failed to set bridge executor address")
}
Expand Down

0 comments on commit 89d1bf8

Please sign in to comment.