Skip to content
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

add account balance range #2771

Merged
merged 1 commit into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions cmd/netgoal/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var roundTxnCount uint64
var accountsCount uint64
var assetsCount uint64
var applicationCount uint64
var balRange []string

func init() {
rootCmd.AddCommand(generateCmd)
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -516,6 +529,7 @@ func generateAccountsLoadingFileTemplate(templateFilename, sourceWallet string,
GeneratedAssetsCount: assetsCount,
GeneratedApplicationCount: applicationCount,
SourceWalletName: sourceWallet,
BalanceRange: []int64{min, max},
}
return saveLoadingFileDataToDisk(data, templateFilename)
}
Expand Down
13 changes: 7 additions & 6 deletions netdeploy/remote/bootstrappedNetwork.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion netdeploy/remote/deployedNetwork.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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
]
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"NetworkName": "",
"VersionModifier": "",
"ConsensusProtocol": "future",
"ConsensusProtocol": "",
"FirstPartKeyRound": 0,
"LastPartKeyRound": 3000000,
"PartKeyDilution": 0,
Expand Down Expand Up @@ -1009,5 +1009,6 @@
],
"FeeSink": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ",
"RewardsPool": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ",
"DevMode": false,
"Comment": ""
}