feat(networkconfig): CLI for custom SSV config generation#2156
Conversation
Codecov ReportAttention: Patch coverage is
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| type marshaledConfig struct { | ||
| DomainType string `json:"DomainType,omitempty" yaml:"DomainType,omitempty"` | ||
| RegistrySyncOffset *big.Int `json:"RegistrySyncOffset,omitempty" yaml:"RegistrySyncOffset,omitempty"` | ||
| RegistryContractAddr string `json:"RegistryContractAddr,omitempty" yaml:"RegistryContractAddr,omitempty"` | ||
| Bootnodes []string `json:"Bootnodes,omitempty" yaml:"Bootnodes,omitempty"` | ||
| DiscoveryProtocolID string `json:"DiscoveryProtocolID,omitempty" yaml:"DiscoveryProtocolID,omitempty"` | ||
| } |
There was a problem hiding this comment.
Since we are manually mapping SSVConfig <-> marshaledConfig fields it's probably a good idea to add a test that would check:
- unmarshal->marshal (both yaml and json representations) yields the same result
- and also to make sure newly added field is converted (and not missing) we maybe could hash string-representation of sample config and compare hash directly (so that if new field is added the actual hashed value would become different and we'll be notified by test failing)
although I guess that wouldn't work if the order of fields isn't preserved/sorted ... maybe we could enable sorting if that makes sense ?
I haven't checked for Yaml but looks like JSON marshaling applies sorting (from func description):
// Map values encode as JSON objects. The map's key type must either be a
// string, an integer type, or implement [encoding.TextMarshaler]. The map keys
// are sorted and used as JSON object keys by applying the following rules,
// subject to the UTF-8 coercion described for string values above:
// - keys of any string type are used directly
// - keys that implement [encoding.TextMarshaler] are marshaled
// - integer keys are converted to strings
There was a problem hiding this comment.
Pull Request Overview
This PR implements a CLI tool for generating custom SSV node configuration files and updates the network configurations by converting registry contract addresses from strings to ethcommon.Address. Key changes include:
- Updating the Options struct in operator/node.go with a new CustomNetwork field and deprecating CustomDomainType.
- Converting registry contract address fields from string to ethcommon.Address across various network configuration files.
- Adding a new CLI command (generate-config) and corresponding documentation for streamlined configuration generation.
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| operator/node.go | Introduces CustomNetwork field and deprecates CustomDomainType with updated comments. |
| networkconfig/test-network.go | Converts registry contract address to ethcommon.HexToAddress. |
| networkconfig/ssv.go | Changes RegistryContractAddr to ethcommon.Address and updates JSON/YAML marshaling. |
| networkconfig/sepolia.go | Uses ethcommon.HexToAddress for registry contract address conversion. |
| networkconfig/mainnet.go | Uses ethcommon.HexToAddress for registry contract address conversion. |
| networkconfig/local-testnet.go | Uses ethcommon.HexToAddress for registry contract address conversion. |
| networkconfig/hoodi.go | Uses ethcommon.HexToAddress for registry contract address conversion. |
| networkconfig/hoodi-stage.go | Uses ethcommon.HexToAddress for registry contract address conversion. |
| networkconfig/holesky.go | Uses ethcommon.HexToAddress for registry contract address conversion. |
| networkconfig/holesky-stage.go | Uses ethcommon.HexToAddress for registry contract address conversion. |
| networkconfig/holesky-e2e.go | Uses ethcommon.HexToAddress for registry contract address conversion. |
| cli/operator/node.go | Updates usage of the registry contract address and logs a warning for deprecated usage. |
| cli/generate_config.go | Adds a new CLI command that generates a configuration file based on passed flags. |
| cli/GENERATE_CONFIG.md | Provides documentation on using the new configuration generator command. |
…rate-ssv # Conflicts: # networkconfig/holesky-e2e.go # networkconfig/holesky-stage.go # networkconfig/holesky.go # networkconfig/hoodi-stage.go # networkconfig/hoodi.go # networkconfig/local-testnet.go # networkconfig/mainnet.go # networkconfig/sepolia.go # networkconfig/test-network.go
f601c0f
into
networkconfig-from-beacon-node
…de (#2153) * beacon/goclient: get beacon config from beacon node * use beacon config obtained from beacon node * log config as JSON * delete a comment * use Stringer to log node * guard beacon config reads with mutex * add a timeout log * delete hardcoded beacon configs * Revert "delete hardcoded beacon configs" This reverts commit c2e2f8f. * fix issues after merging * code review comments * unexport supportedSSVConfigs * fix a context bug * pass network config name * feat(networkconfig): CLI for custom SSV config generation (#2156) * networkconfig: CLI for custom SSV config generation * implement JSON marshaling and YAML marshaling/unmarshaling * remove TotalEthereumValidators * simplify marshaling/unmarshaling logic * fix markdown formatting * use yaml@v3 * add tests * simplify unmarshaling * fix linter * add missing fields to LocalTestnet
… interface (#2145) * networkconfig: split beacon and ssv configs * move most parameters outside of BeaconNetwork interface * get rid of BeaconNetwork interface * some leftovers * fix linter * fix message validation tests * fix linter again * leftovers after merging * fix issues after merging * fix network name bug * code review comments * fix issues after merging * update go.mod * fix ekm tests * remove unused import * update go.mod * fix issues after merging * format/imports * revert preparationSlots type change * use uint64 for amount of slots and epochs * use github.com/ssvlabs/eth2-key-manager@v1.5.5 * spec-alignment * feat(networkconfig,beacon/goclient): get beacon config from beacon node (#2153) * beacon/goclient: get beacon config from beacon node * use beacon config obtained from beacon node * log config as JSON * delete a comment * use Stringer to log node * guard beacon config reads with mutex * add a timeout log * delete hardcoded beacon configs * Revert "delete hardcoded beacon configs" This reverts commit c2e2f8f. * fix issues after merging * code review comments * unexport supportedSSVConfigs * fix a context bug * pass network config name * feat(networkconfig): CLI for custom SSV config generation (#2156) * networkconfig: CLI for custom SSV config generation * implement JSON marshaling and YAML marshaling/unmarshaling * remove TotalEthereumValidators * simplify marshaling/unmarshaling logic * fix markdown formatting * use yaml@v3 * add tests * simplify unmarshaling * fix linter * add missing fields to LocalTestnet * update go.mod * networkconfig: make hardcoded values configurable (#2164) * beacon/goclient: get beacon config from beacon node * use beacon config obtained from beacon node * log config as JSON * networkconfig: CLI for custom SSV config generation * implement JSON marshaling and YAML marshaling/unmarshaling * remove TotalEthereumValidators * simplify marshaling/unmarshaling logic * fix markdown formatting * use yaml@v3 * add tests * simplify unmarshaling * delete a comment * use Stringer to log node * guard beacon config reads with mutex * add a timeout log * delete hardcoded beacon configs * Revert "delete hardcoded beacon configs" This reverts commit c2e2f8f. * networkconfig: make hardcoded values configurable * fix issues after merging * code review comments * fix issues after merging * delete outer metrics for genesisForClient * rewrite modulo calculation * code review comments * unexport supportedSSVConfigs * revert the modulo calculation * add EpochDuration mock * G115 * fill missing fields in configs * add a comment about eth spec * fix error text * use genesis validators root from config in computeVoluntaryExitDomain * fix linter * fix a typo * remove redundant comments * fix a context bug * fix issues after merging * pass network config name * networkconfig: narrow config usage (#2172) * use SSV/Beacon configs instead of NetworkConfig where possible * fix linter * fix a comment * fix issues after merging * fix issues after merging * beacon,networkconfig: move fork handling from beacon to networkconfig (#2178) * beacon/goclient: get beacon config from beacon node * use beacon config obtained from beacon node * log config as JSON * networkconfig: CLI for custom SSV config generation * implement JSON marshaling and YAML marshaling/unmarshaling * remove TotalEthereumValidators * simplify marshaling/unmarshaling logic * fix markdown formatting * use yaml@v3 * add tests * simplify unmarshaling * delete a comment * use Stringer to log node * guard beacon config reads with mutex * add a timeout log * delete hardcoded beacon configs * Revert "delete hardcoded beacon configs" This reverts commit c2e2f8f. * networkconfig: make hardcoded values configurable * fix issues after merging * code review comments * fix issues after merging * delete outer metrics for genesisForClient * rewrite modulo calculation * code review comments * unexport supportedSSVConfigs * revert the modulo calculation * add EpochDuration mock * G115 * fill missing fields in configs * add a comment about eth spec * fix error text * use genesis validators root from config in computeVoluntaryExitDomain * beacon,networkconfig: move forks from beacon to networkconfig * get rid of using Genesis method * use ForkAtEpoch instead of DataVersion * generate mocks * fix linter * fix beacon tests * beacon: delete ForkAtEpoch * fix ekm tests * update go.mod * fix some TODOs * fix linter * fix a typo * remove redundant comments * remove Spec method * delete a comment * uncomment config print * fix a context bug * fix issues after merging * pass network config name * update go.mod * fix issues after merging * networkconfig: delete hardcoded beacon configs (#2183) * beacon/goclient: get beacon config from beacon node * use beacon config obtained from beacon node * log config as JSON * networkconfig: CLI for custom SSV config generation * implement JSON marshaling and YAML marshaling/unmarshaling * remove TotalEthereumValidators * simplify marshaling/unmarshaling logic * fix markdown formatting * use yaml@v3 * add tests * simplify unmarshaling * delete a comment * use Stringer to log node * guard beacon config reads with mutex * add a timeout log * delete hardcoded beacon configs * Revert "delete hardcoded beacon configs" This reverts commit c2e2f8f. * networkconfig: make hardcoded values configurable * fix issues after merging * code review comments * fix issues after merging * delete outer metrics for genesisForClient * rewrite modulo calculation * code review comments * unexport supportedSSVConfigs * revert the modulo calculation * add EpochDuration mock * G115 * fill missing fields in configs * add a comment about eth spec * fix error text * use genesis validators root from config in computeVoluntaryExitDomain * beacon,networkconfig: move forks from beacon to networkconfig * get rid of using Genesis method * use ForkAtEpoch instead of DataVersion * generate mocks * fix linter * fix beacon tests * beacon: delete ForkAtEpoch * fix ekm tests * update go.mod * fix some TODOs * networkconfig: delete mainnet beacon config * networkconfig: delete rest of configs * replace TestRealNetwork with TestNetwork * fix linter * fix a typo * remove redundant comments * remove Spec method * delete a comment * uncomment config print * fix a context bug * fix issues after merging * delete TestRealNetwork * pass network config name * update go.mod * fix issues after merging * fix issues after merging * rename BeaconName to NetworkName * refactor getting spec parameters * update go.mod * fix type assertion * fix spec align --------- Co-authored-by: y0sher <lyosher@gmail.com> Co-authored-by: Matus Kysel <matus@ssvlabs.io>
… interface (#2145) * networkconfig: split beacon and ssv configs * move most parameters outside of BeaconNetwork interface * get rid of BeaconNetwork interface * some leftovers * fix linter * fix message validation tests * fix linter again * leftovers after merging * fix issues after merging * fix network name bug * code review comments * fix issues after merging * update go.mod * fix ekm tests * remove unused import * update go.mod * fix issues after merging * format/imports * revert preparationSlots type change * use uint64 for amount of slots and epochs * use github.com/ssvlabs/eth2-key-manager@v1.5.5 * spec-alignment * feat(networkconfig,beacon/goclient): get beacon config from beacon node (#2153) * beacon/goclient: get beacon config from beacon node * use beacon config obtained from beacon node * log config as JSON * delete a comment * use Stringer to log node * guard beacon config reads with mutex * add a timeout log * delete hardcoded beacon configs * Revert "delete hardcoded beacon configs" This reverts commit c2e2f8f. * fix issues after merging * code review comments * unexport supportedSSVConfigs * fix a context bug * pass network config name * feat(networkconfig): CLI for custom SSV config generation (#2156) * networkconfig: CLI for custom SSV config generation * implement JSON marshaling and YAML marshaling/unmarshaling * remove TotalEthereumValidators * simplify marshaling/unmarshaling logic * fix markdown formatting * use yaml@v3 * add tests * simplify unmarshaling * fix linter * add missing fields to LocalTestnet * update go.mod * networkconfig: make hardcoded values configurable (#2164) * beacon/goclient: get beacon config from beacon node * use beacon config obtained from beacon node * log config as JSON * networkconfig: CLI for custom SSV config generation * implement JSON marshaling and YAML marshaling/unmarshaling * remove TotalEthereumValidators * simplify marshaling/unmarshaling logic * fix markdown formatting * use yaml@v3 * add tests * simplify unmarshaling * delete a comment * use Stringer to log node * guard beacon config reads with mutex * add a timeout log * delete hardcoded beacon configs * Revert "delete hardcoded beacon configs" This reverts commit c2e2f8f. * networkconfig: make hardcoded values configurable * fix issues after merging * code review comments * fix issues after merging * delete outer metrics for genesisForClient * rewrite modulo calculation * code review comments * unexport supportedSSVConfigs * revert the modulo calculation * add EpochDuration mock * G115 * fill missing fields in configs * add a comment about eth spec * fix error text * use genesis validators root from config in computeVoluntaryExitDomain * fix linter * fix a typo * remove redundant comments * fix a context bug * fix issues after merging * pass network config name * networkconfig: narrow config usage (#2172) * use SSV/Beacon configs instead of NetworkConfig where possible * fix linter * fix a comment * fix issues after merging * fix issues after merging * beacon,networkconfig: move fork handling from beacon to networkconfig (#2178) * beacon/goclient: get beacon config from beacon node * use beacon config obtained from beacon node * log config as JSON * networkconfig: CLI for custom SSV config generation * implement JSON marshaling and YAML marshaling/unmarshaling * remove TotalEthereumValidators * simplify marshaling/unmarshaling logic * fix markdown formatting * use yaml@v3 * add tests * simplify unmarshaling * delete a comment * use Stringer to log node * guard beacon config reads with mutex * add a timeout log * delete hardcoded beacon configs * Revert "delete hardcoded beacon configs" This reverts commit c2e2f8f. * networkconfig: make hardcoded values configurable * fix issues after merging * code review comments * fix issues after merging * delete outer metrics for genesisForClient * rewrite modulo calculation * code review comments * unexport supportedSSVConfigs * revert the modulo calculation * add EpochDuration mock * G115 * fill missing fields in configs * add a comment about eth spec * fix error text * use genesis validators root from config in computeVoluntaryExitDomain * beacon,networkconfig: move forks from beacon to networkconfig * get rid of using Genesis method * use ForkAtEpoch instead of DataVersion * generate mocks * fix linter * fix beacon tests * beacon: delete ForkAtEpoch * fix ekm tests * update go.mod * fix some TODOs * fix linter * fix a typo * remove redundant comments * remove Spec method * delete a comment * uncomment config print * fix a context bug * fix issues after merging * pass network config name * update go.mod * fix issues after merging * networkconfig: delete hardcoded beacon configs (#2183) * beacon/goclient: get beacon config from beacon node * use beacon config obtained from beacon node * log config as JSON * networkconfig: CLI for custom SSV config generation * implement JSON marshaling and YAML marshaling/unmarshaling * remove TotalEthereumValidators * simplify marshaling/unmarshaling logic * fix markdown formatting * use yaml@v3 * add tests * simplify unmarshaling * delete a comment * use Stringer to log node * guard beacon config reads with mutex * add a timeout log * delete hardcoded beacon configs * Revert "delete hardcoded beacon configs" This reverts commit c2e2f8f. * networkconfig: make hardcoded values configurable * fix issues after merging * code review comments * fix issues after merging * delete outer metrics for genesisForClient * rewrite modulo calculation * code review comments * unexport supportedSSVConfigs * revert the modulo calculation * add EpochDuration mock * G115 * fill missing fields in configs * add a comment about eth spec * fix error text * use genesis validators root from config in computeVoluntaryExitDomain * beacon,networkconfig: move forks from beacon to networkconfig * get rid of using Genesis method * use ForkAtEpoch instead of DataVersion * generate mocks * fix linter * fix beacon tests * beacon: delete ForkAtEpoch * fix ekm tests * update go.mod * fix some TODOs * networkconfig: delete mainnet beacon config * networkconfig: delete rest of configs * replace TestRealNetwork with TestNetwork * fix linter * fix a typo * remove redundant comments * remove Spec method * delete a comment * uncomment config print * fix a context bug * fix issues after merging * delete TestRealNetwork * pass network config name * update go.mod * fix issues after merging * fix issues after merging * rename BeaconName to NetworkName * refactor getting spec parameters * update go.mod * fix type assertion * fix spec align --------- Co-authored-by: y0sher <lyosher@gmail.com> Co-authored-by: Matus Kysel <matus@ssvlabs.io>
… interface (#2145) * networkconfig: split beacon and ssv configs * move most parameters outside of BeaconNetwork interface * get rid of BeaconNetwork interface * some leftovers * fix linter * fix message validation tests * fix linter again * leftovers after merging * fix issues after merging * fix network name bug * code review comments * fix issues after merging * update go.mod * fix ekm tests * remove unused import * update go.mod * fix issues after merging * format/imports * revert preparationSlots type change * use uint64 for amount of slots and epochs * use github.com/ssvlabs/eth2-key-manager@v1.5.5 * spec-alignment * feat(networkconfig,beacon/goclient): get beacon config from beacon node (#2153) * beacon/goclient: get beacon config from beacon node * use beacon config obtained from beacon node * log config as JSON * delete a comment * use Stringer to log node * guard beacon config reads with mutex * add a timeout log * delete hardcoded beacon configs * Revert "delete hardcoded beacon configs" This reverts commit c2e2f8f. * fix issues after merging * code review comments * unexport supportedSSVConfigs * fix a context bug * pass network config name * feat(networkconfig): CLI for custom SSV config generation (#2156) * networkconfig: CLI for custom SSV config generation * implement JSON marshaling and YAML marshaling/unmarshaling * remove TotalEthereumValidators * simplify marshaling/unmarshaling logic * fix markdown formatting * use yaml@v3 * add tests * simplify unmarshaling * fix linter * add missing fields to LocalTestnet * update go.mod * networkconfig: make hardcoded values configurable (#2164) * beacon/goclient: get beacon config from beacon node * use beacon config obtained from beacon node * log config as JSON * networkconfig: CLI for custom SSV config generation * implement JSON marshaling and YAML marshaling/unmarshaling * remove TotalEthereumValidators * simplify marshaling/unmarshaling logic * fix markdown formatting * use yaml@v3 * add tests * simplify unmarshaling * delete a comment * use Stringer to log node * guard beacon config reads with mutex * add a timeout log * delete hardcoded beacon configs * Revert "delete hardcoded beacon configs" This reverts commit c2e2f8f. * networkconfig: make hardcoded values configurable * fix issues after merging * code review comments * fix issues after merging * delete outer metrics for genesisForClient * rewrite modulo calculation * code review comments * unexport supportedSSVConfigs * revert the modulo calculation * add EpochDuration mock * G115 * fill missing fields in configs * add a comment about eth spec * fix error text * use genesis validators root from config in computeVoluntaryExitDomain * fix linter * fix a typo * remove redundant comments * fix a context bug * fix issues after merging * pass network config name * networkconfig: narrow config usage (#2172) * use SSV/Beacon configs instead of NetworkConfig where possible * fix linter * fix a comment * fix issues after merging * fix issues after merging * beacon,networkconfig: move fork handling from beacon to networkconfig (#2178) * beacon/goclient: get beacon config from beacon node * use beacon config obtained from beacon node * log config as JSON * networkconfig: CLI for custom SSV config generation * implement JSON marshaling and YAML marshaling/unmarshaling * remove TotalEthereumValidators * simplify marshaling/unmarshaling logic * fix markdown formatting * use yaml@v3 * add tests * simplify unmarshaling * delete a comment * use Stringer to log node * guard beacon config reads with mutex * add a timeout log * delete hardcoded beacon configs * Revert "delete hardcoded beacon configs" This reverts commit c2e2f8f. * networkconfig: make hardcoded values configurable * fix issues after merging * code review comments * fix issues after merging * delete outer metrics for genesisForClient * rewrite modulo calculation * code review comments * unexport supportedSSVConfigs * revert the modulo calculation * add EpochDuration mock * G115 * fill missing fields in configs * add a comment about eth spec * fix error text * use genesis validators root from config in computeVoluntaryExitDomain * beacon,networkconfig: move forks from beacon to networkconfig * get rid of using Genesis method * use ForkAtEpoch instead of DataVersion * generate mocks * fix linter * fix beacon tests * beacon: delete ForkAtEpoch * fix ekm tests * update go.mod * fix some TODOs * fix linter * fix a typo * remove redundant comments * remove Spec method * delete a comment * uncomment config print * fix a context bug * fix issues after merging * pass network config name * update go.mod * fix issues after merging * networkconfig: delete hardcoded beacon configs (#2183) * beacon/goclient: get beacon config from beacon node * use beacon config obtained from beacon node * log config as JSON * networkconfig: CLI for custom SSV config generation * implement JSON marshaling and YAML marshaling/unmarshaling * remove TotalEthereumValidators * simplify marshaling/unmarshaling logic * fix markdown formatting * use yaml@v3 * add tests * simplify unmarshaling * delete a comment * use Stringer to log node * guard beacon config reads with mutex * add a timeout log * delete hardcoded beacon configs * Revert "delete hardcoded beacon configs" This reverts commit c2e2f8f. * networkconfig: make hardcoded values configurable * fix issues after merging * code review comments * fix issues after merging * delete outer metrics for genesisForClient * rewrite modulo calculation * code review comments * unexport supportedSSVConfigs * revert the modulo calculation * add EpochDuration mock * G115 * fill missing fields in configs * add a comment about eth spec * fix error text * use genesis validators root from config in computeVoluntaryExitDomain * beacon,networkconfig: move forks from beacon to networkconfig * get rid of using Genesis method * use ForkAtEpoch instead of DataVersion * generate mocks * fix linter * fix beacon tests * beacon: delete ForkAtEpoch * fix ekm tests * update go.mod * fix some TODOs * networkconfig: delete mainnet beacon config * networkconfig: delete rest of configs * replace TestRealNetwork with TestNetwork * fix linter * fix a typo * remove redundant comments * remove Spec method * delete a comment * uncomment config print * fix a context bug * fix issues after merging * delete TestRealNetwork * pass network config name * update go.mod * fix issues after merging * fix issues after merging * rename BeaconName to NetworkName * refactor getting spec parameters * update go.mod * fix type assertion * fix spec align --------- Co-authored-by: y0sher <lyosher@gmail.com> Co-authored-by: Matus Kysel <matus@ssvlabs.io>
Part of PRs that will replace #1308
Based on #2153