diff --git a/cmd/netgoal/generate.go b/cmd/netgoal/generate.go index 015fb42073..7564440e4a 100644 --- a/cmd/netgoal/generate.go +++ b/cmd/netgoal/generate.go @@ -50,6 +50,7 @@ var roundTxnCount uint64 var accountsCount uint64 var assetsCount uint64 var applicationCount uint64 +var balRange []string func init() { rootCmd.AddCommand(generateCmd) @@ -73,6 +74,7 @@ func init() { generateCmd.Flags().Uint64VarP(&accountsCount, "naccounts", "", 31, "Account count") generateCmd.Flags().Uint64VarP(&assetsCount, "nassets", "", 5, "Asset count") generateCmd.Flags().Uint64VarP(&applicationCount, "napps", "", 7, "Application Count") + generateCmd.Flags().StringArrayVar(&balRange, "bal", []string{}, "Application Count") longParts := make([]string, len(generateTemplateLines)+1) longParts[0] = generateCmd.Long @@ -174,8 +176,10 @@ template modes for -t:`, if sourceWallet == "" { reportErrorf("must specify source wallet name with -wname.") } - - err = generateAccountsLoadingFileTemplate(outputFilename, sourceWallet, rounds, roundTxnCount, accountsCount, assetsCount, applicationCount) + if len(balRange) < 2 { + reportErrorf("must specify account balance range with --bal.") + } + err = generateAccountsLoadingFileTemplate(outputFilename, sourceWallet, rounds, roundTxnCount, accountsCount, assetsCount, applicationCount, balRange) default: reportInfoln("Please specify a valid template name.\nSupported templates are:") for _, line := range generateTemplateLines { @@ -507,7 +511,16 @@ func saveGenesisDataToDisk(genesisData gen.GenesisData, filename string) error { return err } -func generateAccountsLoadingFileTemplate(templateFilename, sourceWallet string, rounds, roundTxnCount, accountsCount, assetsCount, applicationCount uint64) error { +func generateAccountsLoadingFileTemplate(templateFilename, sourceWallet string, rounds, roundTxnCount, accountsCount, assetsCount, applicationCount uint64, balRange []string) error { + + min, err := strconv.ParseInt(balRange[0], 0, 64) + if err != nil { + return err + } + max, err := strconv.ParseInt(balRange[1], 0, 64) + if err != nil { + return err + } var data = remote.BootstrappedNetwork{ NumRounds: rounds, @@ -516,6 +529,7 @@ func generateAccountsLoadingFileTemplate(templateFilename, sourceWallet string, GeneratedAssetsCount: assetsCount, GeneratedApplicationCount: applicationCount, SourceWalletName: sourceWallet, + BalanceRange: []int64{min, max}, } return saveLoadingFileDataToDisk(data, templateFilename) } diff --git a/netdeploy/remote/bootstrappedNetwork.go b/netdeploy/remote/bootstrappedNetwork.go index 374d857801..9cdf934fed 100644 --- a/netdeploy/remote/bootstrappedNetwork.go +++ b/netdeploy/remote/bootstrappedNetwork.go @@ -23,12 +23,13 @@ import ( //BootstrappedNetwork contains the specs for generating db files type BootstrappedNetwork struct { - NumRounds uint64 `json:"numRounds"` - RoundTransactionsCount uint64 `json:"roundTransactionsCount"` - GeneratedAccountsCount uint64 `json:"generatedAccountsCount"` - GeneratedAssetsCount uint64 `json:"generatedAssetsCount"` - GeneratedApplicationCount uint64 `json:"generatedApplicationCount"` - SourceWalletName string `json:"sourceWalletName"` + NumRounds uint64 `json:"numRounds"` + RoundTransactionsCount uint64 `json:"roundTransactionsCount"` + GeneratedAccountsCount uint64 `json:"generatedAccountsCount"` + GeneratedAssetsCount uint64 `json:"generatedAssetsCount"` + GeneratedApplicationCount uint64 `json:"generatedApplicationCount"` + SourceWalletName string `json:"sourceWalletName"` + BalanceRange []int64 `json:"acctBalanceRange"` } // LoadBootstrappedData loads a bootstrappedFile structure from a json file diff --git a/netdeploy/remote/deployedNetwork.go b/netdeploy/remote/deployedNetwork.go index 331a101c0b..36b4618f58 100644 --- a/netdeploy/remote/deployedNetwork.go +++ b/netdeploy/remote/deployedNetwork.go @@ -414,7 +414,11 @@ func (cfg DeployedNetwork) GenerateDatabaseFiles(fileCfgs BootstrappedNetwork, g } //fund src account with enough funding - bootstrappedNet.fundPerAccount = basics.MicroAlgos{Raw: uint64(bootstrappedNet.nAssets) * params.MinBalance * 2} + rand.Seed(time.Now().UnixNano()) + min := fileCfgs.BalanceRange[0] + max := fileCfgs.BalanceRange[1] + bal := rand.Int63n(max-min) + min + bootstrappedNet.fundPerAccount = basics.MicroAlgos{Raw: uint64(bal)} totalFunds := accounts[src].MicroAlgos.Raw + bootstrappedNet.fundPerAccount.Raw*bootstrappedNet.nAccounts + bootstrappedNet.roundTxnCnt*fileCfgs.NumRounds accounts[src] = basics.MakeAccountData(basics.Online, basics.MicroAlgos{Raw: totalFunds}) diff --git a/test/testdata/deployednettemplates/recipes/bootstrappedScenario/Makefile b/test/testdata/deployednettemplates/recipes/bootstrappedScenario/Makefile index ee48014b60..626f3ff85e 100644 --- a/test/testdata/deployednettemplates/recipes/bootstrappedScenario/Makefile +++ b/test/testdata/deployednettemplates/recipes/bootstrappedScenario/Makefile @@ -1,5 +1,5 @@ PARAMS=-w 100 -R 8 -N 20 -n 100 -H 10 --node-template node.json --relay-template relay.json --non-participating-node-template nonPartNode.json -FILEPARAMS=--rounds 5000 --ntrx 1000 --naccounts 3000000 --nassets 20000 --napps 20000 --wallet-name "wallet1" +FILEPARAMS=--rounds 5000 --ntxns 1000 --naccounts 3000000 --nassets 20000 --napps 20000 --wallet-name "wallet1" --bal 100000 --bal 1000000 all: net.json genesis.json boostrappedFile.json diff --git a/test/testdata/deployednettemplates/recipes/bootstrappedScenario/boostrappedFile.json b/test/testdata/deployednettemplates/recipes/bootstrappedScenario/boostrappedFile.json index 7e63535ffc..82ebb6b3f7 100644 --- a/test/testdata/deployednettemplates/recipes/bootstrappedScenario/boostrappedFile.json +++ b/test/testdata/deployednettemplates/recipes/bootstrappedScenario/boostrappedFile.json @@ -1,8 +1,12 @@ { - "numRounds":65000, + "numRounds": 5000, "roundTransactionsCount": 1000, - "generatedAccountsCount": 7000000, - "generatedAssetsCount": 200000, - "generatedApplicationCount": 1000000, - "sourceWalletName": "wallet1" + "generatedAccountsCount": 30000000, + "generatedAssetsCount": 20000, + "generatedApplicationCount": 20000, + "sourceWalletName": "wallet1", + "acctBalanceRange": [ + 100000, + 1000000 + ] } diff --git a/test/testdata/deployednettemplates/recipes/bootstrappedScenario/genesis.json b/test/testdata/deployednettemplates/recipes/bootstrappedScenario/genesis.json index 77a347e277..9e37558fa0 100644 --- a/test/testdata/deployednettemplates/recipes/bootstrappedScenario/genesis.json +++ b/test/testdata/deployednettemplates/recipes/bootstrappedScenario/genesis.json @@ -1,7 +1,7 @@ { "NetworkName": "", "VersionModifier": "", - "ConsensusProtocol": "future", + "ConsensusProtocol": "", "FirstPartKeyRound": 0, "LastPartKeyRound": 3000000, "PartKeyDilution": 0, @@ -1009,5 +1009,6 @@ ], "FeeSink": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ", "RewardsPool": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ", + "DevMode": false, "Comment": "" }