go-spacemesh
go-spacemesh copied to clipboard
Cleanup p2p configuration structures
Motivation
The existing configuration structures are a bit messy. Some fields are doubled - they exist both in the "main" config struct for p2p as well as in the submodule's config structures (for example, fields for the book check logic).
Changes
- cleaned up this duplication by using the submodule's config structures as subfields of the "main" p2p config struct.
- removed fields that are not part of the configuration (they cannot be configured by user) out from
Configstructs. NowConfigstructs contain only settings configurable either by a config file (config.toml) or flags. - removed
config.tomlfields that don't exist and moved the ones that changed their place in config structures.
Test Plan
unittests
DevOps Notes
- [x] This PR does not require configuration changes (e.g., environment variables, GitHub secrets, VM resources)
- [x] This PR does not affect public APIs
- [x] This PR does not rely on a new version of external services (PoET, elasticsearch, etc.)
- [x] This PR does not make changes to log messages (which monitoring infrastructure may rely on)
@dshulyak
i don't think that operator should be aware that we have p2p.bootstrap component or p2p.pubsub, it can get removed or updated and it will require changes in the config structure
I absolutely understand your point and I actually agree :) I think there is a middle point where we can meet with this. My intent was to remove duplication and have a single source of truth for the settings that are configurable by an operator. In order to hide the implementation details from the config, I can embed these structures in the main p2p Config instead of having separate fields.
In order to hide the implementation details from the config, I can embed these structures in the main p2p Config instead of having separate fields.
i don't know if parsing will work without subgroups (there was some special code in cmd/base.go), but in general sounds good
In order to hide the implementation details from the config, I can embed these structures in the main p2p Config instead of having separate fields.
i don't know if parsing will work without subgroups (there was some special code in cmd/base.go), but in general sounds good
It should work with a squash mapstructure tag. But I will need to rename the structs (they are named just Config now) to avoid name collision when embedded in a single struct.
@dshulyak, I embedded pubsub, discovery and bootstrap to hide them from an operator.