Skip to content

Commit

Permalink
remove old config (#114)
Browse files Browse the repository at this point in the history
* remove old config

* update PR template
  • Loading branch information
shrimalmadhur authored Apr 24, 2024
1 parent 7655062 commit daed8cd
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 93 deletions.
16 changes: 2 additions & 14 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
Fixes # .

### Motivation
<!--
Does this solve a bug? Enable a new use-case? Improve an existing behavior? Concrete examples are helpful here.
-->

### Solution
<!--
What is the solution here from a high level. What are the key technical decisions and why were they made?
-->

### Open questions
<!--
(optional) Any open questions or feedback on design desired?
-->
### What Changed?
<! -- Describe the changes you made in this PR -->
49 changes: 4 additions & 45 deletions pkg/operator/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ import (
"encoding/json"
"fmt"
"math/big"
"os"
"os/user"
"strings"

eigensdkTypes "github.com/Layr-Labs/eigensdk-go/types"
eigenSdkUtils "github.com/Layr-Labs/eigensdk-go/utils"

"gopkg.in/yaml.v2"

"github.com/Layr-Labs/eigensdk-go/chainio/txmgr"
"github.com/Layr-Labs/eigensdk-go/signerv2"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
Expand Down Expand Up @@ -175,7 +172,7 @@ func expandTilde(path string) (string, error) {
}

func validateAndReturnConfig(configurationFilePath string) (*types.OperatorConfigNew, error) {
operatorCfg, err := validateAndMigrateConfigFile(configurationFilePath)
operatorCfg, err := readConfigFile(configurationFilePath)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -223,51 +220,13 @@ func validateAndReturnConfig(configurationFilePath string) (*types.OperatorConfi
return operatorCfg, nil
}

func validateAndMigrateConfigFile(path string) (*types.OperatorConfigNew, error) {
operatorCfg := types.OperatorConfigNew{}
var operatorCfgOld types.OperatorConfig
err := utils.ReadYamlConfig(path, &operatorCfgOld)
func readConfigFile(path string) (*types.OperatorConfigNew, error) {
var operatorCfg types.OperatorConfigNew
err := utils.ReadYamlConfig(path, &operatorCfg)
if err != nil {
return nil, err
}
if operatorCfgOld.ELSlasherAddress != "" || operatorCfgOld.BlsPublicKeyCompendiumAddress != "" {
fmt.Printf("%s Old config detected, migrating to new config\n", utils.EmojiCheckMark)
chainIDInt := operatorCfgOld.ChainId.Int64()
chainMetadata, ok := utils.ChainMetadataMap[chainIDInt]
if !ok {
return nil, fmt.Errorf("chain ID %d not supported", chainIDInt)
}
operatorCfg = types.OperatorConfigNew{
Operator: operatorCfgOld.Operator,
ELDelegationManagerAddress: chainMetadata.ELDelegationManagerAddress,
EthRPCUrl: operatorCfgOld.EthRPCUrl,
PrivateKeyStorePath: operatorCfgOld.PrivateKeyStorePath,
SignerType: operatorCfgOld.SignerType,
ChainId: operatorCfgOld.ChainId,
}

fmt.Printf("%s Backing up old config file to %s", utils.EmojiWait, path+".old")
err := os.Rename(path, path+".old")
if err != nil {
return nil, err
}
fmt.Printf("\r%s Old Config file backed up at %s\n", utils.EmojiCheckMark, path+".old")
fmt.Printf("Writing new config to %s", path)
yamlData, err := yaml.Marshal(&operatorCfg)
if err != nil {
return nil, err
}
err = os.WriteFile(path, yamlData, 0o644)
if err != nil {
return nil, err
}
fmt.Printf("\r%s New config file written to %s\n", utils.EmojiCheckMark, path)
} else {
err = utils.ReadYamlConfig(path, &operatorCfg)
if err != nil {
return nil, err
}
}
elAVSDirectoryAddress, err := getAVSDirectoryAddress(operatorCfg.ChainId)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/operator/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func StatusCmd(p utils.Prompter) *cli.Command {
}

configurationFilePath := args.Get(0)
operatorCfg, err := validateAndMigrateConfigFile(configurationFilePath)
operatorCfg, err := readConfigFile(configurationFilePath)
if err != nil {
return err
}
Expand Down
33 changes: 0 additions & 33 deletions pkg/types/operator_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,6 @@ const (
LocalKeystoreSigner SignerType = "local_keystore"
)

type OperatorConfig struct {
Operator eigensdkTypes.Operator `yaml:"operator"`
ELSlasherAddress string `yaml:"el_slasher_address"`
BlsPublicKeyCompendiumAddress string `yaml:"bls_public_key_compendium_address"`
EthRPCUrl string `yaml:"eth_rpc_url"`
PrivateKeyStorePath string `yaml:"private_key_store_path"`
SignerType SignerType `yaml:"signer_type"`
BlsPrivateKeyStorePath string `yaml:"bls_private_key_store_path"`
ChainId big.Int `yaml:"chain_id"`
}

func (config OperatorConfig) MarshalYAML() (interface{}, error) {
return struct {
Operator eigensdkTypes.Operator `yaml:"operator"`
ELSlasherAddress string `yaml:"el_slasher_address"`
BlsPublicKeyCompendiumAddress string `yaml:"bls_public_key_compendium_address"`
EthRPCUrl string `yaml:"eth_rpc_url"`
PrivateKeyStorePath string `yaml:"private_key_store_path"`
SignerType SignerType `yaml:"signer_type"`
BlsPrivateKeyStorePath string `yaml:"bls_private_key_store_path"`
ChainID int64 `yaml:"chain_id"`
}{
Operator: config.Operator,
ELSlasherAddress: config.ELSlasherAddress,
BlsPublicKeyCompendiumAddress: config.BlsPublicKeyCompendiumAddress,
EthRPCUrl: config.EthRPCUrl,
PrivateKeyStorePath: config.PrivateKeyStorePath,
SignerType: config.SignerType,
BlsPrivateKeyStorePath: config.BlsPrivateKeyStorePath,
ChainID: config.ChainId.Int64(),
}, nil
}

type OperatorConfigNew struct {
Operator eigensdkTypes.Operator `yaml:"operator"`
ELDelegationManagerAddress string `yaml:"el_delegation_manager_address"`
Expand Down

0 comments on commit daed8cd

Please sign in to comment.