Skip to content

Commit

Permalink
fixes etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
darioush committed Jul 29, 2022
1 parent afcc29e commit 5e1bf79
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/control/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ func restartNodeFunc(cmd *cobra.Command, args []string) error {
if err := json.Unmarshal([]byte(upgradeConfigs), &upgradeConfigsMap); err != nil {
return err
}
opts = append(opts, client.WithChainConfigs(upgradeConfigsMap))
opts = append(opts, client.WithUpgradeConfigs(upgradeConfigsMap))
}

ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
Expand Down
19 changes: 12 additions & 7 deletions local/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ func init() {
defaultNetworkConfig.NodeConfigs[i].ChainConfigFiles = map[string]string{
"C": string(cChainConfig),
}
defaultNetworkConfig.NodeConfigs[i].UpgradeConfigFiles = map[string]string{}
defaultNetworkConfig.NodeConfigs[i].IsBeacon = true
}

Expand Down Expand Up @@ -1207,28 +1208,32 @@ func writeFiles(genesis []byte, nodeRootDir string, nodeConfig *node.Config) ([]
return nil, fmt.Errorf("couldn't write file at %q: %w", f.path, err)
}
}
if nodeConfig.ChainConfigFiles != nil {
// only one flag and multiple files
chainConfigDir := filepath.Join(nodeRootDir, chainConfigSubDir)

chainConfigDir := filepath.Join(nodeRootDir, chainConfigSubDir)
if nodeConfig.ChainConfigFiles != nil || nodeConfig.UpgradeConfigFiles != nil {
// only specify this flag once
flags = append(flags, fmt.Sprintf("--%s=%s", config.ChainConfigDirKey, chainConfigDir))
}

// add the config files for all specified chains
if nodeConfig.ChainConfigFiles != nil {
for chainAlias, chainConfigFile := range nodeConfig.ChainConfigFiles {
chainConfigPath := filepath.Join(chainConfigDir, chainAlias, configFileName)
if err := createFileAndWrite(chainConfigPath, []byte(chainConfigFile)); err != nil {
return nil, fmt.Errorf("couldn't write file at %q: %w", chainConfigPath, err)
}
}
}

// add the upgrade files for all specified chains
if nodeConfig.UpgradeConfigFiles != nil {
// only one flag and multiple files
chainConfigDir := filepath.Join(nodeRootDir, chainConfigSubDir)
// TODO: only need to specify this flag once
flags = append(flags, fmt.Sprintf("--%s=%s", config.ChainConfigDirKey, chainConfigDir))
for chainAlias, upgradeChainFile := range nodeConfig.UpgradeConfigFiles {
upgradeConfigPath := filepath.Join(chainConfigDir, chainAlias, upgradeConfigFileName)
if err := createFileAndWrite(upgradeConfigPath, []byte(upgradeChainFile)); err != nil {
return nil, fmt.Errorf("couldn't write file at %q: %w", upgradeConfigPath, err)
}
}
}

return flags, nil
}
1 change: 1 addition & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,7 @@ func (s *server) AddNode(ctx context.Context, req *rpcpb.AddNodeRequest) (*rpcpb
RedirectStderr: s.cfg.RedirectNodesOutput,
}
nodeConfig.ChainConfigFiles = map[string]string{}
nodeConfig.UpgradeConfigFiles = map[string]string{}
for k, v := range s.network.chainConfigs {
nodeConfig.ChainConfigFiles[k] = v
}
Expand Down

0 comments on commit 5e1bf79

Please sign in to comment.