-
Notifications
You must be signed in to change notification settings - Fork 747
[tmpnet] Provide genesis, subnet and chain config via content flags #3857
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
Conversation
@@ -50,6 +50,9 @@ func DefaultTestFlags() FlagsMap { | |||
func DefaultTmpnetFlags() FlagsMap { | |||
// Supply only non-default configuration to ensure that default values will be used. | |||
flags := FlagsMap{ | |||
// Default to dynamic port allocation |
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.
This used to be set every time a node started, but is more properly a network default.
tests/fixture/tmpnet/network.go
Outdated
@@ -101,6 +105,9 @@ type Network struct { | |||
// Genesis for the network. If nil, NetworkID must be non-zero | |||
Genesis *genesis.UnparsedConfig | |||
|
|||
// Configuration for primary subnets | |||
PrimarySubnetConfigs map[ids.ID]subnets.Config |
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.
Previously the only way to provide a subnet config was to create a file [network dir]/subnets/[subnet id].json
after a network was already created. Now it's possible to configure this in code without touching the filesystem.
e3f3c9d
to
c8ddf75
Compare
@@ -110,65 +106,6 @@ func (n *Network) writeGenesis() error { | |||
return nil | |||
} | |||
|
|||
func (n *Network) GetChainConfigDir() string { |
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.
Chain configuration is now written to the filesystem separate from the subnet configuration files
@@ -51,32 +51,12 @@ type Chain struct { | |||
PreFundedKey *secp256k1.PrivateKey | |||
} | |||
|
|||
// Write the chain configuration to the specified directory. |
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.
Subnet configuration for avalanchego is no longer written to the filesystem
@@ -22,21 +22,8 @@ func (n *Node) GetFlagsPath() string { | |||
return filepath.Join(n.GetDataDir(), "flags.json") | |||
} | |||
|
|||
func (n *Node) readFlags() error { |
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.
Previously flags.json was the only way that node flags were stored. Now non-default node flags are stored in the node configuration file (config.json) and flags.json is write-only and written every time a node is started
@@ -154,6 +155,11 @@ func ReadNodes(networkDir string, includeEphemeral bool) ([]*Node, error) { | |||
continue | |||
} | |||
|
|||
// Ensure the node ID is set | |||
if err := node.EnsureNodeID(); err != nil { |
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.
Ensuring the node ID is derived from the keys was previously done by Node.readFlags
c8ddf75
to
2143fe1
Compare
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.
Nice 👍 Just leaving a few nitpicky comments which you can ignore as well 😉 !
Previously supplied genesis, subnet and chain config to nodes via `--*-file-content` flags pointing to files on disk. Switching to use the equivalent `--*-content` flags simplifies configuring nodes deployed to kube where configuration via files is more complicated. To support this, Node.Flags is now used only for generated configuration like keys and user-supplied node-specific config. Network defaults and automatic configuration (like bootstrap IPs/IDs) are not included. Instead, flags.json for each node is generated each time a node is started to ensure that the configuration is up-to-date.
Co-authored-by: Quentin McGaw <quentin.mcgaw@avalabs.org> Signed-off-by: maru <maru.newby@avalabs.org>
Co-authored-by: Quentin McGaw <quentin.mcgaw@avalabs.org> Signed-off-by: maru <maru.newby@avalabs.org>
Co-authored-by: Quentin McGaw <quentin.mcgaw@avalabs.org> Signed-off-by: maru <maru.newby@avalabs.org>
Co-authored-by: Quentin McGaw <quentin.mcgaw@avalabs.org> Signed-off-by: maru <maru.newby@avalabs.org>
Co-authored-by: Quentin McGaw <quentin.mcgaw@avalabs.org> Signed-off-by: maru <maru.newby@avalabs.org>
Co-authored-by: Quentin McGaw <quentin.mcgaw@avalabs.org> Signed-off-by: maru <maru.newby@avalabs.org>
Co-authored-by: Quentin McGaw <quentin.mcgaw@avalabs.org> Signed-off-by: maru <maru.newby@avalabs.org>
Co-authored-by: Quentin McGaw <quentin.mcgaw@avalabs.org> Signed-off-by: maru <maru.newby@avalabs.org>
Co-authored-by: Quentin McGaw <quentin.mcgaw@avalabs.org> Signed-off-by: maru <maru.newby@avalabs.org>
Co-authored-by: Quentin McGaw <quentin.mcgaw@avalabs.org> Signed-off-by: maru <maru.newby@avalabs.org>
Co-authored-by: Quentin McGaw <quentin.mcgaw@avalabs.org> Signed-off-by: maru <maru.newby@avalabs.org>
38e4eb5
to
9d3759a
Compare
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.
Overall LGTM. Just a naming nit and a couple of suggestions which scope anyway may belong to a different PR.
1edd5c5
to
823336a
Compare
PR Chain: tmpnet+kube
This PR chain enables tmpnet to deploy temporary networks to Kubernetes. Early PRs refactor tmpnet to support the addition in #3615 of a new tmpnet node runtime for kube.
Why this should be merged
Previously supplied genesis, subnet and chain config to nodes via
--*-file-content
flags pointing to files on disk. Switching to use the equivalent--*-content
flags simplifies configuring nodes deployed to kube where configuration via files is more complicated.To support this, Node.Flags is now used only for generated configuration like keys and user-supplied node-specific config. Network defaults and automatic configuration (like bootstrap IPs/IDs) are not included. Instead, flags.json for each node is generated each time a node is started to ensure that the configuration is up-to-date.
How this was tested
CI, local validation of
tmpnetctl start-network
Need to be documented in RELEASES.md?
N/A