Skip to content

[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

Merged
merged 16 commits into from
Apr 9, 2025

Conversation

maru-ava
Copy link
Contributor

@maru-ava maru-ava commented Mar 31, 2025

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

@maru-ava maru-ava added the testing This primarily focuses on testing label Mar 31, 2025
@maru-ava maru-ava self-assigned this Mar 31, 2025
@github-project-automation github-project-automation bot moved this to Backlog 🗄️ in avalanchego Mar 31, 2025
@maru-ava maru-ava moved this from Backlog 🗄️ to In Review 👀 in avalanchego Mar 31, 2025
@@ -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
Copy link
Contributor Author

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.

@@ -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
Copy link
Contributor Author

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.

@maru-ava maru-ava force-pushed the tmpnet-use-content-keys branch 2 times, most recently from e3f3c9d to c8ddf75 Compare March 31, 2025 21:14
@@ -110,65 +106,6 @@ func (n *Network) writeGenesis() error {
return nil
}

func (n *Network) GetChainConfigDir() string {
Copy link
Contributor Author

@maru-ava maru-ava Mar 31, 2025

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.
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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

@maru-ava maru-ava force-pushed the tmpnet-use-content-keys branch from c8ddf75 to 2143fe1 Compare April 1, 2025 00:11
@maru-ava maru-ava requested a review from felipemadero April 1, 2025 00:37
Copy link
Contributor

@qdm12 qdm12 left a 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 😉 !

maru-ava and others added 13 commits April 7, 2025 11:23
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>
@maru-ava maru-ava force-pushed the tmpnet-use-content-keys branch from 38e4eb5 to 9d3759a Compare April 7, 2025 18:23
Copy link
Contributor

@felipemadero felipemadero left a 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.

@maru-ava maru-ava force-pushed the tmpnet-use-content-keys branch from 1edd5c5 to 823336a Compare April 8, 2025 18:19
@maru-ava maru-ava added this pull request to the merge queue Apr 9, 2025
Merged via the queue into master with commit 7a4694a Apr 9, 2025
24 checks passed
@maru-ava maru-ava deleted the tmpnet-use-content-keys branch April 9, 2025 04:09
@github-project-automation github-project-automation bot moved this from In Review 👀 to Done ✅ in avalanchego Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing This primarily focuses on testing
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants