Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Migrate networks to yml file (1 of 2) #459
base: master
Are you sure you want to change the base?
feat: Migrate networks to yml file (1 of 2) #459
Changes from all commits
21785c0
cef7336
7bc1aba
782ff8f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like a great opportunity to use
type NetworksConfig []*config.NetworkInfo
.You'll have to remove the
networks:
piece from the smartnode-install .yml file and just have the list be top-level.but then, instead of:
defaultNetworks.Networks = append(defaultNetworks.Networks, extraNetworks.Networks...)
below you can ergonmicallyreturn append(defaultNetworks, extraNetworks...)
and you can kill off
func (nc *NetworksConfig) GetNetworks() []*config.NetworkInfo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thought here was future proofing: We may want other information about that config file rather than just an array of NetworkInfo at some point.
I don't feel strongly though. Let me know if you prefer though the flat array and I can change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, it's easier to extend if the root level is an object. I kind of am leaning towards:
now... that way we get the extensibility of the file format and can simplify the ABI here to remove GetNetworks().
If we ever have to add more fields in memory and change the
NetworkConfigs
type down the line, the compiler will yell at us about the surface area, so it's any easy upgrade path.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on another discussion I've now added
func (nc *NetworksConfig) GetNetwork(name config.Network) *config.NetworkInfo
to do the lookup of the network in the map. This adds more utility toNetworksConfig
. I renamed the oldGetNetworks()
toAllNetworks()
and it is only used in one spot.So with this in mind I think it's okay. What about you?
Sorry to be going back and forth, I promise I'm not trying to be argumentative! 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a good option as well. I think this one is ready for @0xfornax but i'll give it one last pass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kinda seems like
NewRocketPoolConfig
should handle this.filepath.Dir(path)
gets stored incfg.RocketPoolDirectory
on alloc, and then incfg.Deserialize
you can parse the new yml.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've looked into this again and I prefer passing it into New for two reasons...
NewRocketPoolConfig
callsNewSmartnodeConfig
which loads a list of network options so it requires networks to be available already.There is also a place in the client creates a fresh config without deserializing that would require some patching after it is created to even have a valid config. So I think it's more correct to have networks passed in.
Let me know if I'm missing something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we meet in the middle and have
NewRocketPoolConfig
parse the files just before callingNewSmartnodeConfig
?In both places NewRocketPoolConfig is called it uses the same path as the previous LoadNetworksFromeFile call
edit: you will, of course, have to turn NewRocketPoolConfig into a function that returns an error, though. Maybe parsing the networks first is not so bad...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:) I agree with your edit.
There is a third place where that
NewRocketPoolConfig
that actually doesn't require reading the networks: https://github.com/activescott/smartnode/blob/cef7336fc59d22944c1a5de56fbec89b862a18c7/shared/services/rocketpool/client.go#L230After reviewing this, I prefer the way it is now. Let me know what you prefer though. I'm open.