-
Notifications
You must be signed in to change notification settings - Fork 473
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
Netgoal: Update netgoal generate flags and variables #4656
Changes from 23 commits
51c9404
4b75143
cf872aa
acce502
d496746
9120552
c484ad3
df8e6ce
48783f6
ff3f3c8
d9d55e2
03859ee
a275f3f
a917262
bc2fc9b
87a6796
b39a770
96356e7
43234dc
a484f16
c7fcfc3
b6b7e0d
58e3410
af0c57a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Netgoal | ||
|
||
## netgoal generate | ||
`--participation-host-machines (-N)` and `--npn-host-machines (-X)` are optional parameters and they default to `--participation-algod-nodes (-n)` and `--npn-algod-nodes (-x)` respectively, i.e. defaults to a machine per algod node. | ||
|
||
### Long-Form Flags Example | ||
- Wallets: The command below will generate 100 wallets for the 100 participation algod nodes. By default each npn gets one wallet each. If there are more wallets than nodes, it will get split across the participation algod nodes. | ||
- Relays: 8 Relays and 8 machines to host the relays will be generated | ||
- Participation Nodes: 100 particiipation algod nodes will be distributed across 20 host machines. | ||
- Non-Participation Nodes (NPNs): 10 non-participation algod nodes will be distributed across 5 host machines. | ||
|
||
``` | ||
netgoal generate -t net -r /tmp/wat -o net.json --wallets 100 --relays 8 --participation-host-machines 20 --participation-algod-nodes 100 --npn-host-machines 5 --npn-algod-nodes 10 --node-template node.json --relay-template relay.json --non-participating-node-template nonPartNode.json | ||
``` | ||
|
||
### Short-Form Flags Example | ||
The following will result in the same outcome as the command above. | ||
``` | ||
netgoal generate -t net -r /tmp/wat -o net.json -w 100 -R 8 -N 20 -n 100 -X 5 -x 10 --node-template node.json --relay-template relay.json --non-participating-node-template nonPartNode.json | ||
``` | ||
## Flags | ||
``` | ||
netgoal generate -h | ||
|
||
Usage: | ||
netgoal generate [flags] | ||
|
||
Flags: | ||
--bal stringArray Application Count | ||
-h, --help help for generate | ||
--naccounts uint Account count (default 31) | ||
--napps uint Application Count (default 7) | ||
--nassets uint Asset count (default 5) | ||
--node-template string json for one node | ||
--non-participating-node-template string json for non participating node | ||
-x, --npn-algod-nodes int Total non-participation algod nodes to generate | ||
-X, --npn-host-machines int Host machines to generate for non-participation algod nodes, default=npn-algod-nodes | ||
--ntxns uint Transaction count (default 17) | ||
-o, --outputfile string Output filename | ||
-n, --participation-algod-nodes int Total participation algod nodes to generate (default -1) | ||
-N, --participation-host-machines int Host machines to generate for participation algod nodes, default=participation-algod-nodes (default -1) | ||
--relay-template string json for a relay node | ||
-R, --relays int Relays to generate (default -1) | ||
--rounds uint Number of rounds (default 13) | ||
-t, --template string Template to generate | ||
--wallet-name string Source wallet name | ||
-w, --wallets int Wallets to generate (default -1) | ||
|
||
Global Flags: | ||
-m, --modifier string Override Genesis Version Modifier (eg 'v1') | ||
-r, --rootdir string Root directory for the private network directories | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,10 +37,10 @@ import ( | |
var outputFilename string | ||
var templateToGenerate string | ||
var relaysToGenerate int | ||
var nodesToGenerate int | ||
var nodeHostsToGenerate int | ||
var nonPartnodesToGenerate int | ||
var nonPartnodesHostsToGenerate int | ||
var participationAlgodNodes int | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This variable renaming is great! |
||
var participationHostMachines int | ||
var npnAlgodNodes int | ||
var npnHostMachines int | ||
var walletsToGenerate int | ||
var nodeTemplatePath string | ||
var nonParticipatingNodeTemplatePath string | ||
|
@@ -63,10 +63,10 @@ func init() { | |
|
||
generateCmd.Flags().IntVarP(&walletsToGenerate, "wallets", "w", -1, "Wallets to generate") | ||
generateCmd.Flags().IntVarP(&relaysToGenerate, "relays", "R", -1, "Relays to generate") | ||
generateCmd.Flags().IntVarP(&nodeHostsToGenerate, "node-hosts", "N", -1, "Node-hosts to generate, default=nodes") | ||
generateCmd.Flags().IntVarP(&nodesToGenerate, "nodes", "n", -1, "Nodes to generate") | ||
generateCmd.Flags().IntVarP(&nonPartnodesToGenerate, "non-participating-nodes", "X", 0, "Non participating nodes to generate") | ||
generateCmd.Flags().IntVarP(&nonPartnodesHostsToGenerate, "non-participating-nodes-hosts", "H", 0, "Non participating nodes hosts to generate") | ||
generateCmd.Flags().IntVarP(&participationAlgodNodes, "participation-algod-nodes", "n", -1, "Total participation algod nodes to generate") | ||
generateCmd.Flags().IntVarP(&participationHostMachines, "participation-host-machines", "N", -1, "Host machines to generate for participation algod nodes, default=participation-algod-nodes") | ||
generateCmd.Flags().IntVarP(&npnAlgodNodes, "npn-algod-nodes", "x", 0, "Total non-participation algod nodes to generate") | ||
generateCmd.Flags().IntVarP(&npnHostMachines, "npn-host-machines", "X", 0, "Host machines to generate for non-participation algod nodes, default=npn-algod-nodes") | ||
Comment on lines
+68
to
+69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. might get some questions about these, since this does make it breaking. on the other hand, it does make it more consistent. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah I posted these changes in #performance and #devops. I think they're the only ones who really know about the new X flag anyways. Not sure what else I should do besides answer questions if it comes up. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also updated all of the recipes' Makefiles in go-algorand, so hopefully that will help. |
||
generateCmd.Flags().StringVarP(&nodeTemplatePath, "node-template", "", "", "json for one node") | ||
generateCmd.Flags().StringVarP(&nonParticipatingNodeTemplatePath, "non-participating-node-template", "", "", "json for non participating node") | ||
generateCmd.Flags().StringVarP(&relayTemplatePath, "relay-template", "", "", "json for a relay node") | ||
|
@@ -149,24 +149,27 @@ template modes for -t:`, | |
if walletsToGenerate < 0 { | ||
reportErrorf("must specify number of wallets with -w") | ||
} | ||
err = generateWalletGenesis(outputFilename, walletsToGenerate, nonPartnodesToGenerate) | ||
err = generateWalletGenesis(outputFilename, walletsToGenerate, npnAlgodNodes) | ||
case "net", "network", "goalnet": | ||
if walletsToGenerate < 0 { | ||
reportErrorf("must specify number of wallets with -w") | ||
} | ||
if nodesToGenerate < 0 { | ||
if participationAlgodNodes < 0 { | ||
reportErrorf("must specify number of nodes with -n") | ||
} | ||
if nodeHostsToGenerate < 0 { | ||
nodeHostsToGenerate = nodesToGenerate | ||
if participationHostMachines < 0 { | ||
participationHostMachines = participationAlgodNodes | ||
} | ||
if (npnAlgodNodes >= 0) && (npnHostMachines == 0) { | ||
npnHostMachines = npnAlgodNodes | ||
} | ||
if relaysToGenerate < 0 { | ||
reportErrorf("must specify number of relays with -R") | ||
} | ||
if templateType == "goalnet" { | ||
err = generateNetworkGoalTemplate(outputFilename, walletsToGenerate, relaysToGenerate, nodesToGenerate, nonPartnodesHostsToGenerate) | ||
err = generateNetworkGoalTemplate(outputFilename, walletsToGenerate, relaysToGenerate, participationAlgodNodes, npnAlgodNodes) | ||
} else { | ||
err = generateNetworkTemplate(outputFilename, walletsToGenerate, relaysToGenerate, nodeHostsToGenerate, nodesToGenerate, nonPartnodesHostsToGenerate, nonPartnodesToGenerate, baseNode, baseNonParticipatingNode, baseRelay) | ||
err = generateNetworkTemplate(outputFilename, walletsToGenerate, relaysToGenerate, participationHostMachines, participationAlgodNodes, npnHostMachines, npnAlgodNodes, baseNode, baseNonParticipatingNode, baseRelay) | ||
} | ||
case "otwt": | ||
err = generateNetworkTemplate(outputFilename, 1000, 10, 20, 100, 0, 0, baseNode, baseNonParticipatingNode, baseRelay) | ||
|
@@ -234,9 +237,9 @@ func pickNodeConfig(alt []remote.NodeConfig, name string) remote.NodeConfig { | |
return alt[0] | ||
} | ||
|
||
func generateNetworkGoalTemplate(templateFilename string, wallets, relays, nodes, npnHosts int) error { | ||
func generateNetworkGoalTemplate(templateFilename string, wallets, relays, nodes, npnNodes int) error { | ||
template := netdeploy.NetworkTemplate{} | ||
template.Nodes = make([]remote.NodeConfigGoal, 0, relays+nodes+npnHosts) | ||
template.Nodes = make([]remote.NodeConfigGoal, 0, relays+nodes+npnNodes) | ||
template.Genesis = generateWalletGenesisData(walletsToGenerate, 0) | ||
for i := 0; i < relays; i++ { | ||
name := "relay" + strconv.Itoa(i+1) | ||
|
@@ -257,7 +260,7 @@ func generateNetworkGoalTemplate(templateFilename string, wallets, relays, nodes | |
template.Nodes = append(template.Nodes, newNode) | ||
} | ||
|
||
for i := 0; i < npnHosts; i++ { | ||
for i := 0; i < npnNodes; i++ { | ||
name := "nonParticipatingNode" + strconv.Itoa(i+1) | ||
newNode := remote.NodeConfigGoal{ | ||
Name: name, | ||
|
@@ -286,8 +289,8 @@ func generateNetworkGoalTemplate(templateFilename string, wallets, relays, nodes | |
} | ||
} | ||
|
||
if npnHosts > 0 { | ||
for walletIndex < npnHosts { | ||
if npnNodes > 0 { | ||
for walletIndex < npnNodes { | ||
for nodei, node := range template.Nodes { | ||
if node.Name[0:4] != "nonP" { | ||
continue | ||
|
@@ -298,11 +301,11 @@ func generateNetworkGoalTemplate(templateFilename string, wallets, relays, nodes | |
} | ||
template.Nodes[nodei].Wallets = append(template.Nodes[nodei].Wallets, wallet) | ||
walletIndex++ | ||
if walletIndex >= npnHosts { | ||
if walletIndex >= npnNodes { | ||
break | ||
} | ||
} | ||
if walletIndex >= npnHosts { | ||
if walletIndex >= npnNodes { | ||
break | ||
} | ||
} | ||
|
@@ -478,18 +481,18 @@ func saveGoalTemplateToDisk(template netdeploy.NetworkTemplate, filename string) | |
return err | ||
} | ||
|
||
func generateWalletGenesisData(wallets, npnHosts int) gen.GenesisData { | ||
func generateWalletGenesisData(wallets, npnNodes int) gen.GenesisData { | ||
ratZero := big.NewRat(int64(0), int64(1)) | ||
ratHundred := big.NewRat(int64(100), int64(1)) | ||
data := gen.DefaultGenesis | ||
totalWallets := wallets + npnHosts | ||
totalWallets := wallets + npnNodes | ||
data.Wallets = make([]gen.WalletData, totalWallets) | ||
participatingNodeStake := big.NewRat(int64(100), int64(wallets)) | ||
nonParticipatingNodeStake := ratZero | ||
if npnHosts > 0 { | ||
if npnNodes > 0 { | ||
// split participating an non participating stake evenly | ||
participatingNodeStake = big.NewRat(int64(50), int64(wallets)) | ||
nonParticipatingNodeStake = big.NewRat(int64(50), int64(npnHosts)) | ||
nonParticipatingNodeStake = big.NewRat(int64(50), int64(npnNodes)) | ||
} | ||
|
||
stake := ratZero | ||
|
@@ -519,8 +522,8 @@ func generateWalletGenesisData(wallets, npnHosts int) gen.GenesisData { | |
return data | ||
} | ||
|
||
func generateWalletGenesis(filename string, wallets, npnHosts int) error { | ||
data := generateWalletGenesisData(wallets, npnHosts) | ||
func generateWalletGenesis(filename string, wallets, npnNodes int) error { | ||
data := generateWalletGenesisData(wallets, npnNodes) | ||
return saveGenesisDataToDisk(data, filename) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Recipes | ||
|
||
Most of the recipes' net.json and genesis.json use one of the following methods to call `netgoal generate`: | ||
1. `Makefile` | ||
2. `python3 {GO_ALGORAND_PATH}/test/testdata/deployednettemplates/generate-recipe/generate_network.py -f {PATH_TO}/network-tpl.json` | ||
|
||
Details for netgoal generate could be found in the binary with: | ||
``` | ||
netgoal generate -h | ||
``` | ||
|
||
Source code for netgoal can be found in `{GO_ALGORAND_PATH}/cmd/netgoal/generate.go` | ||
Documentation: https://github.com/algorand/go-algorand/tree/master/cmd/netgoal/README.md | ||
algobarb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Make sure you set the PATH and GOPATH variables to the netgoal binary's path. | ||
|
||
## Custom Recipe | ||
Leverages the generate_network.py script and has unique instructions found in the README: | ||
https://github.com/algorand/go-algorand/tree/master/test/testdata/deployednettemplates/recipes/custom |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
"network": { | ||
"wallets": 6, | ||
"nodes": 3, | ||
"npn": 5, | ||
"ConsensusProtocol": "future" | ||
}, | ||
"instances": { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
"network": { | ||
"wallets": 6, | ||
"nodes": 3, | ||
"npn": 5, | ||
"ConsensusProtocol": "future" | ||
}, | ||
"instances": { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
{ | ||
"network": { | ||
"wallets": 100, | ||
"nodes": 50 | ||
"nodes": 50, | ||
"npn": 10 | ||
}, | ||
"instances": { | ||
"relays": { | ||
|
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.
hmm, it's still using shorthand flags here in readme. Should we set a better example by using long form flags?
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.
The long form flags example is right above the shorthand flags in the readme.
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.
Might be easier to read in this format: https://github.com/algorand/go-algorand/blob/af0c57a67fc3cb6a88990f69d56f4565d6f79725/cmd/netgoal/README.md