From 2acacdb6529d0707e8d35b361414a2eba942a6f1 Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Fri, 14 Oct 2022 09:18:47 -0400 Subject: [PATCH 01/19] tmp --- data/bookkeeping/genesis_test.go | 21 +++++++++++++++++++++ gen/generate.go | 7 ++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/data/bookkeeping/genesis_test.go b/data/bookkeeping/genesis_test.go index 9ca60bd5e1..b6b85ec486 100644 --- a/data/bookkeeping/genesis_test.go +++ b/data/bookkeeping/genesis_test.go @@ -56,6 +56,7 @@ func TestGenesis_Balances(t *testing.T) { } } goodAddr := makeAddr(100) + zeroAddr := makeAddr(0) allocation1 := acctWith(1000, makeAddr(1).String()) allocation2 := acctWith(2000, makeAddr(2).String()) badAllocation := acctWith(1234, "El Toro Loco") @@ -63,6 +64,7 @@ func TestGenesis_Balances(t *testing.T) { Allocation []GenesisAllocation FeeSink string RewardsPool string + DevMode bool } tests := []struct { name string @@ -139,6 +141,24 @@ func TestGenesis_Balances(t *testing.T) { }, wantErr: containsErrorFunc("repeated allocation to"), }, + { + name: "dev mode", + fields: fields{ + Allocation: []GenesisAllocation{allocation1}, + FeeSink: goodAddr.String(), + RewardsPool: zeroAddr.String(), + DevMode: true, + }, + want: GenesisBalances{ + Balances: map[basics.Address]basics.AccountData{ + mustAddr(allocation1.Address): allocation1.State, + }, + FeeSink: goodAddr, + RewardsPool: zeroAddr, + Timestamp: 0, + }, + wantErr: assert.NoError, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -146,6 +166,7 @@ func TestGenesis_Balances(t *testing.T) { Allocation: tt.fields.Allocation, FeeSink: tt.fields.FeeSink, RewardsPool: tt.fields.RewardsPool, + DevMode: true, } got, err := genesis.Balances() if tt.wantErr(t, err, fmt.Sprintf("Balances()")) { diff --git a/gen/generate.go b/gen/generate.go index 15eb091032..cde3bffd1f 100644 --- a/gen/generate.go +++ b/gen/generate.go @@ -44,6 +44,7 @@ var schemaID = "v1" var defaultSinkAddr = basics.Address{0x7, 0xda, 0xcb, 0x4b, 0x6d, 0x9e, 0xd1, 0x41, 0xb1, 0x75, 0x76, 0xbd, 0x45, 0x9a, 0xe6, 0x42, 0x1d, 0x48, 0x6d, 0xa3, 0xd4, 0xef, 0x22, 0x47, 0xc4, 0x9, 0xa3, 0x96, 0xb8, 0x2e, 0xa2, 0x21} var defaultPoolAddr = basics.Address{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff} +var zeroAddr = basics.Address{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // The number of MicroAlgos in the incentive pool at genesis. var defaultIncentivePoolBalanceAtInception uint64 = 125e6 * 1e6 @@ -83,7 +84,11 @@ func setupGenerateGenesisFiles(genesisData *GenesisData, consensus config.Consen genesisData.FeeSink = defaultSinkAddr } if (genesisData.RewardsPool == basics.Address{}) { - genesisData.RewardsPool = defaultPoolAddr + if genesisData.DevMode { + genesisData.RewardsPool = zeroAddr + } else { + genesisData.RewardsPool = defaultPoolAddr + } } var ok bool From 1eaef6240a7f9908fd52b3cefdcf5c25c02ad183 Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Fri, 14 Oct 2022 09:28:28 -0400 Subject: [PATCH 02/19] set balance to 0 --- gen/generate.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gen/generate.go b/gen/generate.go index cde3bffd1f..b486a29bf2 100644 --- a/gen/generate.go +++ b/gen/generate.go @@ -335,9 +335,15 @@ func generateGenesisFiles(outDir string, protoVersion protocol.ConsensusVersion, Status: basics.NotParticipating, MicroAlgos: basics.MicroAlgos{Raw: protoParams.MinBalance}, } + + rewardBalance := defaultIncentivePoolBalanceAtInception + if devmode { + rewardBalance = 0 + } + records["RewardsPool"] = basics.AccountData{ Status: basics.NotParticipating, - MicroAlgos: basics.MicroAlgos{Raw: defaultIncentivePoolBalanceAtInception}, + MicroAlgos: basics.MicroAlgos{Raw: rewardBalance}, } sinkAcct := genesisAllocation{ From d79453e4efec23f44ebb987894638d607d1f5501 Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Fri, 14 Oct 2022 09:32:53 -0400 Subject: [PATCH 03/19] set alloc --- gen/generate.go | 2 +- gen/generate_test.go | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gen/generate.go b/gen/generate.go index b486a29bf2..8067e04162 100644 --- a/gen/generate.go +++ b/gen/generate.go @@ -353,7 +353,7 @@ func generateGenesisFiles(outDir string, protoVersion protocol.ConsensusVersion, } poolAcct := genesisAllocation{ Name: "RewardsPool", - Stake: defaultIncentivePoolBalanceAtInception, + Stake: rewardBalance, Online: basics.NotParticipating, } diff --git a/gen/generate_test.go b/gen/generate_test.go index fbffe94678..6f526ae489 100644 --- a/gen/generate_test.go +++ b/gen/generate_test.go @@ -114,3 +114,18 @@ func TestGenesisRoundoff(t *testing.T) { require.NoError(t, err) require.True(t, strings.Contains(verbosity.String(), "roundoff")) } + +func TestGenesisDevMode(t *testing.T) { + partitiontest.PartitionTest(t) + verbosity := strings.Builder{} + genesisData := DefaultGenesis + genesisData.DevMode = true + genesisData.NetworkName = "wat" + genesisData.ConsensusProtocol = protocol.ConsensusCurrentVersion // TODO: also check ConsensusFuture ? + genesisData.Wallets = []WalletData{ + {Name: "Wallet1", Stake: 100}, + } + _, _, alloc, err := setupGenerateGenesisFiles(&genesisData, config.Consensus, &verbosity) + require.NoError(t, err) + t.Logf("%+v", alloc) +} From 9f18a0157a02f7474ec34d9e04154ff08bb3e684 Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Fri, 14 Oct 2022 09:52:02 -0400 Subject: [PATCH 04/19] Try min bal --- gen/generate.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gen/generate.go b/gen/generate.go index 8067e04162..8b5e05df21 100644 --- a/gen/generate.go +++ b/gen/generate.go @@ -338,7 +338,7 @@ func generateGenesisFiles(outDir string, protoVersion protocol.ConsensusVersion, rewardBalance := defaultIncentivePoolBalanceAtInception if devmode { - rewardBalance = 0 + rewardBalance = protoParams.MinBalance } records["RewardsPool"] = basics.AccountData{ From 21508a1a1b93862abed8c749d5e60718f5271fef Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Fri, 14 Oct 2022 10:07:38 -0400 Subject: [PATCH 05/19] set reward pool to min allocation when in dev mode --- gen/generate.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/gen/generate.go b/gen/generate.go index 15eb091032..c309071d30 100644 --- a/gen/generate.go +++ b/gen/generate.go @@ -44,6 +44,7 @@ var schemaID = "v1" var defaultSinkAddr = basics.Address{0x7, 0xda, 0xcb, 0x4b, 0x6d, 0x9e, 0xd1, 0x41, 0xb1, 0x75, 0x76, 0xbd, 0x45, 0x9a, 0xe6, 0x42, 0x1d, 0x48, 0x6d, 0xa3, 0xd4, 0xef, 0x22, 0x47, 0xc4, 0x9, 0xa3, 0x96, 0xb8, 0x2e, 0xa2, 0x21} var defaultPoolAddr = basics.Address{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff} +var zeroAddr = basics.Address{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // The number of MicroAlgos in the incentive pool at genesis. var defaultIncentivePoolBalanceAtInception uint64 = 125e6 * 1e6 @@ -83,7 +84,11 @@ func setupGenerateGenesisFiles(genesisData *GenesisData, consensus config.Consen genesisData.FeeSink = defaultSinkAddr } if (genesisData.RewardsPool == basics.Address{}) { - genesisData.RewardsPool = defaultPoolAddr + if genesisData.DevMode { + genesisData.RewardsPool = zeroAddr + } else { + genesisData.RewardsPool = defaultPoolAddr + } } var ok bool @@ -326,13 +331,18 @@ func generateGenesisFiles(outDir string, protoVersion protocol.ConsensusVersion, fmt.Fprintln(verboseOut, protoVersion, protoParams.MinBalance) } + rewardBalance := defaultIncentivePoolBalanceAtInception + if devmode { + rewardBalance = protoParams.MinBalance + } + records["FeeSink"] = basics.AccountData{ Status: basics.NotParticipating, MicroAlgos: basics.MicroAlgos{Raw: protoParams.MinBalance}, } records["RewardsPool"] = basics.AccountData{ Status: basics.NotParticipating, - MicroAlgos: basics.MicroAlgos{Raw: defaultIncentivePoolBalanceAtInception}, + MicroAlgos: basics.MicroAlgos{Raw: rewardBalance}, } sinkAcct := genesisAllocation{ @@ -342,7 +352,7 @@ func generateGenesisFiles(outDir string, protoVersion protocol.ConsensusVersion, } poolAcct := genesisAllocation{ Name: "RewardsPool", - Stake: defaultIncentivePoolBalanceAtInception, + Stake: rewardBalance, Online: basics.NotParticipating, } From 345c99d1a3093aa0fcec10be082fa10616685298 Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Fri, 14 Oct 2022 10:47:46 -0400 Subject: [PATCH 06/19] dont define reward pool as zero address --- gen/generate.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/gen/generate.go b/gen/generate.go index c309071d30..e7af2c4b8b 100644 --- a/gen/generate.go +++ b/gen/generate.go @@ -44,7 +44,6 @@ var schemaID = "v1" var defaultSinkAddr = basics.Address{0x7, 0xda, 0xcb, 0x4b, 0x6d, 0x9e, 0xd1, 0x41, 0xb1, 0x75, 0x76, 0xbd, 0x45, 0x9a, 0xe6, 0x42, 0x1d, 0x48, 0x6d, 0xa3, 0xd4, 0xef, 0x22, 0x47, 0xc4, 0x9, 0xa3, 0x96, 0xb8, 0x2e, 0xa2, 0x21} var defaultPoolAddr = basics.Address{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff} -var zeroAddr = basics.Address{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // The number of MicroAlgos in the incentive pool at genesis. var defaultIncentivePoolBalanceAtInception uint64 = 125e6 * 1e6 @@ -84,11 +83,7 @@ func setupGenerateGenesisFiles(genesisData *GenesisData, consensus config.Consen genesisData.FeeSink = defaultSinkAddr } if (genesisData.RewardsPool == basics.Address{}) { - if genesisData.DevMode { - genesisData.RewardsPool = zeroAddr - } else { - genesisData.RewardsPool = defaultPoolAddr - } + genesisData.RewardsPool = defaultPoolAddr } var ok bool From 305e1e169b80d843b559cf740b69996d8c7ec638 Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Wed, 19 Oct 2022 09:00:56 -0400 Subject: [PATCH 07/19] adding another flag to the gen.GenesisData struct to allow more exact specification of the no-reward setup --- cmd/goal/network.go | 4 +++- gen/generate.go | 25 +++++++++++++++++------ gen/walletData.go | 1 + netdeploy/network.go | 6 +++++- test/framework/fixtures/libgoalFixture.go | 2 +- 5 files changed, 29 insertions(+), 9 deletions(-) diff --git a/cmd/goal/network.go b/cmd/goal/network.go index ff4b7005ba..05a3de03ea 100644 --- a/cmd/goal/network.go +++ b/cmd/goal/network.go @@ -35,6 +35,7 @@ var startNode string var noImportKeys bool var noClean bool var devModeOverride bool +var noRewardOverride bool func init() { networkCmd.AddCommand(networkCreateCmd) @@ -47,6 +48,7 @@ func init() { networkCreateCmd.Flags().BoolVarP(&noImportKeys, "noimportkeys", "K", false, "Do not import root keys when creating the network (by default will import)") networkCreateCmd.Flags().BoolVar(&noClean, "noclean", false, "Prevents auto-cleanup on error - for diagnosing problems") networkCreateCmd.Flags().BoolVar(&devModeOverride, "devMode", false, "Forces the configuration to enable DevMode, returns an error if the template is not compatible with DevMode.") + networkCreateCmd.Flags().BoolVar(&noRewardOverride, "noReward", false, "Forces the configuration to disable Rewards") networkStartCmd.Flags().StringVarP(&startNode, "node", "n", "", "Specify the name of a specific node to start") @@ -101,7 +103,7 @@ var networkCreateCmd = &cobra.Command{ consensus, _ = config.PreloadConfigurableConsensusProtocols(dataDir) } - network, err := netdeploy.CreateNetworkFromTemplate(networkName, networkRootDir, networkTemplateFile, binDir, !noImportKeys, nil, consensus, devModeOverride) + network, err := netdeploy.CreateNetworkFromTemplate(networkName, networkRootDir, networkTemplateFile, binDir, !noImportKeys, nil, consensus, devModeOverride, noRewardOverride) if err != nil { if noClean { reportInfof(" ** failed ** - Preserving network rootdir '%s'", networkRootDir) diff --git a/gen/generate.go b/gen/generate.go index e7af2c4b8b..1f2cc7f908 100644 --- a/gen/generate.go +++ b/gen/generate.go @@ -149,14 +149,27 @@ func GenerateGenesisFiles(genesisData GenesisData, consensus config.ConsensusPro return fmt.Errorf("couldn't make output directory '%s': %v", outDir, err.Error()) } - return generateGenesisFiles(outDir, proto, consensusParams, genesisData.NetworkName, genesisData.VersionModifier, allocation, genesisData.FirstPartKeyRound, genesisData.LastPartKeyRound, genesisData.PartKeyDilution, genesisData.FeeSink, genesisData.RewardsPool, genesisData.Comment, genesisData.DevMode, verboseOut) + return generateGenesisFiles( + proto, consensusParams, allocation, genesisData, outDir, verboseOut, + ) } -func generateGenesisFiles(outDir string, protoVersion protocol.ConsensusVersion, protoParams config.ConsensusParams, netName string, schemaVersionModifier string, - allocation []genesisAllocation, firstWalletValid uint64, lastWalletValid uint64, partKeyDilution uint64, feeSink, rewardsPool basics.Address, comment string, devmode bool, verboseOut io.Writer) (err error) { +func generateGenesisFiles(protoVersion protocol.ConsensusVersion, protoParams config.ConsensusParams, allocation []genesisAllocation, genData GenesisData, outDir string, verboseOut io.Writer) (err error) { - genesisAddrs := make(map[string]basics.Address) - records := make(map[string]basics.AccountData) + var ( + netName = genData.NetworkName + schemaVersionModifier = genData.VersionModifier + firstWalletValid = genData.FirstPartKeyRound + lastWalletValid = genData.LastPartKeyRound + partKeyDilution = genData.LastPartKeyRound + feeSink, rewardsPool = genData.FeeSink, genData.RewardsPool + devmode = genData.DevMode + noRewards = genData.NoRewards + comment = genData.Comment + + genesisAddrs = make(map[string]basics.Address) + records = make(map[string]basics.AccountData) + ) if partKeyDilution == 0 { partKeyDilution = protoParams.DefaultKeyDilution @@ -327,7 +340,7 @@ func generateGenesisFiles(outDir string, protoVersion protocol.ConsensusVersion, } rewardBalance := defaultIncentivePoolBalanceAtInception - if devmode { + if noRewards { rewardBalance = protoParams.MinBalance } diff --git a/gen/walletData.go b/gen/walletData.go index 95c508c271..f52d957df2 100644 --- a/gen/walletData.go +++ b/gen/walletData.go @@ -49,6 +49,7 @@ type GenesisData struct { Wallets []WalletData FeeSink basics.Address RewardsPool basics.Address + NoRewards bool DevMode bool Comment string } diff --git a/netdeploy/network.go b/netdeploy/network.go index 78a665b789..03fc944881 100644 --- a/netdeploy/network.go +++ b/netdeploy/network.go @@ -58,7 +58,7 @@ type Network struct { // CreateNetworkFromTemplate uses the specified template to deploy a new private network // under the specified root directory. -func CreateNetworkFromTemplate(name, rootDir, templateFile, binDir string, importKeys bool, nodeExitCallback nodecontrol.AlgodExitErrorCallback, consensus config.ConsensusProtocols, overrideDevMode bool) (Network, error) { +func CreateNetworkFromTemplate(name, rootDir, templateFile, binDir string, importKeys bool, nodeExitCallback nodecontrol.AlgodExitErrorCallback, consensus config.ConsensusProtocols, overrideDevMode, overrideNoRewards bool) (Network, error) { n := Network{ rootDir: rootDir, nodeExitCallback: nodeExitCallback, @@ -74,6 +74,10 @@ func CreateNetworkFromTemplate(name, rootDir, templateFile, binDir string, impor template.Nodes[0].IsRelay = false } } + if overrideNoRewards { + template.Genesis.NoRewards = true + } + err = template.Validate() } if err != nil { diff --git a/test/framework/fixtures/libgoalFixture.go b/test/framework/fixtures/libgoalFixture.go index 746a0c2f94..e3e9dd8195 100644 --- a/test/framework/fixtures/libgoalFixture.go +++ b/test/framework/fixtures/libgoalFixture.go @@ -96,7 +96,7 @@ func (f *LibGoalFixture) setup(test TestingTB, testName string, templateFile str os.RemoveAll(f.rootDir) templateFile = filepath.Join(f.testDataDir, templateFile) importKeys := false // Don't automatically import root keys when creating folders, we'll import on-demand - network, err := netdeploy.CreateNetworkFromTemplate("test", f.rootDir, templateFile, f.binDir, importKeys, f.nodeExitWithError, f.consensus, false) + network, err := netdeploy.CreateNetworkFromTemplate("test", f.rootDir, templateFile, f.binDir, importKeys, f.nodeExitWithError, f.consensus, false, false) f.failOnError(err, "CreateNetworkFromTemplate failed: %v") f.network = network From 5b428a87e022c59525e55ae585a8b9e730373546 Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Wed, 19 Oct 2022 09:21:44 -0400 Subject: [PATCH 08/19] fix part key assignement --- gen/generate.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gen/generate.go b/gen/generate.go index 1f2cc7f908..9f2344168d 100644 --- a/gen/generate.go +++ b/gen/generate.go @@ -161,8 +161,9 @@ func generateGenesisFiles(protoVersion protocol.ConsensusVersion, protoParams co schemaVersionModifier = genData.VersionModifier firstWalletValid = genData.FirstPartKeyRound lastWalletValid = genData.LastPartKeyRound - partKeyDilution = genData.LastPartKeyRound - feeSink, rewardsPool = genData.FeeSink, genData.RewardsPool + partKeyDilution = genData.PartKeyDilution + feeSink = genData.FeeSink + rewardsPool = genData.RewardsPool devmode = genData.DevMode noRewards = genData.NoRewards comment = genData.Comment From d4d1cfebda45f2b80a6d72f83926c7ea42d09ae5 Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Tue, 25 Oct 2022 08:23:30 -0400 Subject: [PATCH 09/19] rename flag to make it clear this is just an initial condition --- cmd/goal/network.go | 6 +++--- gen/generate.go | 2 +- gen/walletData.go | 2 +- netdeploy/network.go | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/goal/network.go b/cmd/goal/network.go index 05a3de03ea..d1b4649a73 100644 --- a/cmd/goal/network.go +++ b/cmd/goal/network.go @@ -35,7 +35,7 @@ var startNode string var noImportKeys bool var noClean bool var devModeOverride bool -var noRewardOverride bool +var noInitialRewardsOverride bool func init() { networkCmd.AddCommand(networkCreateCmd) @@ -48,7 +48,7 @@ func init() { networkCreateCmd.Flags().BoolVarP(&noImportKeys, "noimportkeys", "K", false, "Do not import root keys when creating the network (by default will import)") networkCreateCmd.Flags().BoolVar(&noClean, "noclean", false, "Prevents auto-cleanup on error - for diagnosing problems") networkCreateCmd.Flags().BoolVar(&devModeOverride, "devMode", false, "Forces the configuration to enable DevMode, returns an error if the template is not compatible with DevMode.") - networkCreateCmd.Flags().BoolVar(&noRewardOverride, "noReward", false, "Forces the configuration to disable Rewards") + networkCreateCmd.Flags().BoolVar(&noInitialRewardsOverride, "noReward", false, "Forces the configuration to initialize Rewards pool account to have 0 balance.") networkStartCmd.Flags().StringVarP(&startNode, "node", "n", "", "Specify the name of a specific node to start") @@ -103,7 +103,7 @@ var networkCreateCmd = &cobra.Command{ consensus, _ = config.PreloadConfigurableConsensusProtocols(dataDir) } - network, err := netdeploy.CreateNetworkFromTemplate(networkName, networkRootDir, networkTemplateFile, binDir, !noImportKeys, nil, consensus, devModeOverride, noRewardOverride) + network, err := netdeploy.CreateNetworkFromTemplate(networkName, networkRootDir, networkTemplateFile, binDir, !noImportKeys, nil, consensus, devModeOverride, noInitialRewardsOverride) if err != nil { if noClean { reportInfof(" ** failed ** - Preserving network rootdir '%s'", networkRootDir) diff --git a/gen/generate.go b/gen/generate.go index 9f2344168d..00a6f53846 100644 --- a/gen/generate.go +++ b/gen/generate.go @@ -165,7 +165,7 @@ func generateGenesisFiles(protoVersion protocol.ConsensusVersion, protoParams co feeSink = genData.FeeSink rewardsPool = genData.RewardsPool devmode = genData.DevMode - noRewards = genData.NoRewards + noRewards = genData.NoInitialRewards comment = genData.Comment genesisAddrs = make(map[string]basics.Address) diff --git a/gen/walletData.go b/gen/walletData.go index f52d957df2..a251d4bcc5 100644 --- a/gen/walletData.go +++ b/gen/walletData.go @@ -49,7 +49,7 @@ type GenesisData struct { Wallets []WalletData FeeSink basics.Address RewardsPool basics.Address - NoRewards bool + NoInitialRewards bool DevMode bool Comment string } diff --git a/netdeploy/network.go b/netdeploy/network.go index 03fc944881..66fdf143d9 100644 --- a/netdeploy/network.go +++ b/netdeploy/network.go @@ -58,7 +58,7 @@ type Network struct { // CreateNetworkFromTemplate uses the specified template to deploy a new private network // under the specified root directory. -func CreateNetworkFromTemplate(name, rootDir, templateFile, binDir string, importKeys bool, nodeExitCallback nodecontrol.AlgodExitErrorCallback, consensus config.ConsensusProtocols, overrideDevMode, overrideNoRewards bool) (Network, error) { +func CreateNetworkFromTemplate(name, rootDir, templateFile, binDir string, importKeys bool, nodeExitCallback nodecontrol.AlgodExitErrorCallback, consensus config.ConsensusProtocols, overrideDevMode, overrideNoInitialRewards bool) (Network, error) { n := Network{ rootDir: rootDir, nodeExitCallback: nodeExitCallback, @@ -74,8 +74,8 @@ func CreateNetworkFromTemplate(name, rootDir, templateFile, binDir string, impor template.Nodes[0].IsRelay = false } } - if overrideNoRewards { - template.Genesis.NoRewards = true + if overrideNoInitialRewards { + template.Genesis.NoInitialRewards = true } err = template.Validate() From 80f3ce031f2113cc6fc120208c8ba5155fc3903f Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Thu, 27 Oct 2022 07:22:49 -0400 Subject: [PATCH 10/19] remove flag from create, add field to genesis template for rewards pool balance --- cmd/goal/network.go | 4 +--- gen/generate.go | 12 +++++----- gen/walletData.go | 29 ++++++++++++----------- netdeploy/network.go | 5 +--- test/framework/fixtures/libgoalFixture.go | 2 +- 5 files changed, 24 insertions(+), 28 deletions(-) diff --git a/cmd/goal/network.go b/cmd/goal/network.go index d1b4649a73..ff4b7005ba 100644 --- a/cmd/goal/network.go +++ b/cmd/goal/network.go @@ -35,7 +35,6 @@ var startNode string var noImportKeys bool var noClean bool var devModeOverride bool -var noInitialRewardsOverride bool func init() { networkCmd.AddCommand(networkCreateCmd) @@ -48,7 +47,6 @@ func init() { networkCreateCmd.Flags().BoolVarP(&noImportKeys, "noimportkeys", "K", false, "Do not import root keys when creating the network (by default will import)") networkCreateCmd.Flags().BoolVar(&noClean, "noclean", false, "Prevents auto-cleanup on error - for diagnosing problems") networkCreateCmd.Flags().BoolVar(&devModeOverride, "devMode", false, "Forces the configuration to enable DevMode, returns an error if the template is not compatible with DevMode.") - networkCreateCmd.Flags().BoolVar(&noInitialRewardsOverride, "noReward", false, "Forces the configuration to initialize Rewards pool account to have 0 balance.") networkStartCmd.Flags().StringVarP(&startNode, "node", "n", "", "Specify the name of a specific node to start") @@ -103,7 +101,7 @@ var networkCreateCmd = &cobra.Command{ consensus, _ = config.PreloadConfigurableConsensusProtocols(dataDir) } - network, err := netdeploy.CreateNetworkFromTemplate(networkName, networkRootDir, networkTemplateFile, binDir, !noImportKeys, nil, consensus, devModeOverride, noInitialRewardsOverride) + network, err := netdeploy.CreateNetworkFromTemplate(networkName, networkRootDir, networkTemplateFile, binDir, !noImportKeys, nil, consensus, devModeOverride) if err != nil { if noClean { reportInfof(" ** failed ** - Preserving network rootdir '%s'", networkRootDir) diff --git a/gen/generate.go b/gen/generate.go index 00a6f53846..fd5b38d908 100644 --- a/gen/generate.go +++ b/gen/generate.go @@ -165,7 +165,7 @@ func generateGenesisFiles(protoVersion protocol.ConsensusVersion, protoParams co feeSink = genData.FeeSink rewardsPool = genData.RewardsPool devmode = genData.DevMode - noRewards = genData.NoInitialRewards + rewardsBalance = genData.RewardsPoolBalance comment = genData.Comment genesisAddrs = make(map[string]basics.Address) @@ -340,9 +340,9 @@ func generateGenesisFiles(protoVersion protocol.ConsensusVersion, protoParams co fmt.Fprintln(verboseOut, protoVersion, protoParams.MinBalance) } - rewardBalance := defaultIncentivePoolBalanceAtInception - if noRewards { - rewardBalance = protoParams.MinBalance + if rewardsBalance == 0 { + // Needs to at least have min balance + rewardsBalance += protoParams.MinBalance } records["FeeSink"] = basics.AccountData{ @@ -351,7 +351,7 @@ func generateGenesisFiles(protoVersion protocol.ConsensusVersion, protoParams co } records["RewardsPool"] = basics.AccountData{ Status: basics.NotParticipating, - MicroAlgos: basics.MicroAlgos{Raw: rewardBalance}, + MicroAlgos: basics.MicroAlgos{Raw: rewardsBalance}, } sinkAcct := genesisAllocation{ @@ -361,7 +361,7 @@ func generateGenesisFiles(protoVersion protocol.ConsensusVersion, protoParams co } poolAcct := genesisAllocation{ Name: "RewardsPool", - Stake: rewardBalance, + Stake: rewardsBalance, Online: basics.NotParticipating, } diff --git a/gen/walletData.go b/gen/walletData.go index a251d4bcc5..e0b3d2bf6d 100644 --- a/gen/walletData.go +++ b/gen/walletData.go @@ -27,8 +27,9 @@ import ( // DefaultGenesis should be used as the default initial state for any GenesisData // instance (because we have no ctors...) var DefaultGenesis = GenesisData{ - FirstPartKeyRound: 0, - LastPartKeyRound: 3000000, + FirstPartKeyRound: 0, + LastPartKeyRound: 3000000, + RewardsPoolBalance: defaultIncentivePoolBalanceAtInception, } // WalletData represents a wallet's name, percent stake, and initial online status for a genesis.json file @@ -40,18 +41,18 @@ type WalletData struct { // GenesisData represents the genesis data for creating a genesis.json and wallets type GenesisData struct { - NetworkName string - VersionModifier string - ConsensusProtocol protocol.ConsensusVersion - FirstPartKeyRound uint64 - LastPartKeyRound uint64 - PartKeyDilution uint64 - Wallets []WalletData - FeeSink basics.Address - RewardsPool basics.Address - NoInitialRewards bool - DevMode bool - Comment string + NetworkName string + VersionModifier string + ConsensusProtocol protocol.ConsensusVersion + FirstPartKeyRound uint64 + LastPartKeyRound uint64 + PartKeyDilution uint64 + Wallets []WalletData + FeeSink basics.Address + RewardsPool basics.Address + RewardsPoolBalance uint64 + DevMode bool + Comment string } // LoadGenesisData loads a GenesisData structure from a json file diff --git a/netdeploy/network.go b/netdeploy/network.go index 66fdf143d9..07700ad0a7 100644 --- a/netdeploy/network.go +++ b/netdeploy/network.go @@ -58,7 +58,7 @@ type Network struct { // CreateNetworkFromTemplate uses the specified template to deploy a new private network // under the specified root directory. -func CreateNetworkFromTemplate(name, rootDir, templateFile, binDir string, importKeys bool, nodeExitCallback nodecontrol.AlgodExitErrorCallback, consensus config.ConsensusProtocols, overrideDevMode, overrideNoInitialRewards bool) (Network, error) { +func CreateNetworkFromTemplate(name, rootDir, templateFile, binDir string, importKeys bool, nodeExitCallback nodecontrol.AlgodExitErrorCallback, consensus config.ConsensusProtocols, overrideDevMode bool) (Network, error) { n := Network{ rootDir: rootDir, nodeExitCallback: nodeExitCallback, @@ -74,9 +74,6 @@ func CreateNetworkFromTemplate(name, rootDir, templateFile, binDir string, impor template.Nodes[0].IsRelay = false } } - if overrideNoInitialRewards { - template.Genesis.NoInitialRewards = true - } err = template.Validate() } diff --git a/test/framework/fixtures/libgoalFixture.go b/test/framework/fixtures/libgoalFixture.go index e3e9dd8195..746a0c2f94 100644 --- a/test/framework/fixtures/libgoalFixture.go +++ b/test/framework/fixtures/libgoalFixture.go @@ -96,7 +96,7 @@ func (f *LibGoalFixture) setup(test TestingTB, testName string, templateFile str os.RemoveAll(f.rootDir) templateFile = filepath.Join(f.testDataDir, templateFile) importKeys := false // Don't automatically import root keys when creating folders, we'll import on-demand - network, err := netdeploy.CreateNetworkFromTemplate("test", f.rootDir, templateFile, f.binDir, importKeys, f.nodeExitWithError, f.consensus, false, false) + network, err := netdeploy.CreateNetworkFromTemplate("test", f.rootDir, templateFile, f.binDir, importKeys, f.nodeExitWithError, f.consensus, false) f.failOnError(err, "CreateNetworkFromTemplate failed: %v") f.network = network From 2812d8904ea5681296402f5ddf6981eb6c81ce58 Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Thu, 27 Oct 2022 07:27:57 -0400 Subject: [PATCH 11/19] fix possible bug with balance between 0 and min bal --- gen/generate.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gen/generate.go b/gen/generate.go index fd5b38d908..b8c018267c 100644 --- a/gen/generate.go +++ b/gen/generate.go @@ -340,9 +340,9 @@ func generateGenesisFiles(protoVersion protocol.ConsensusVersion, protoParams co fmt.Fprintln(verboseOut, protoVersion, protoParams.MinBalance) } - if rewardsBalance == 0 { + if rewardsBalance < protoParams.MinBalance { // Needs to at least have min balance - rewardsBalance += protoParams.MinBalance + rewardsBalance += protoParams.MinBalance - rewardsBalance } records["FeeSink"] = basics.AccountData{ From 1bae82bb2211c0083d216c1073fdc9a2b06c9bb5 Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Thu, 27 Oct 2022 12:27:43 -0400 Subject: [PATCH 12/19] Update gen/generate.go Co-authored-by: Michael Diamant --- gen/generate.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gen/generate.go b/gen/generate.go index b8c018267c..b2795209d2 100644 --- a/gen/generate.go +++ b/gen/generate.go @@ -342,7 +342,7 @@ func generateGenesisFiles(protoVersion protocol.ConsensusVersion, protoParams co if rewardsBalance < protoParams.MinBalance { // Needs to at least have min balance - rewardsBalance += protoParams.MinBalance - rewardsBalance + rewardsBalance = protoParams.MinBalance } records["FeeSink"] = basics.AccountData{ From ceff9e566af0e083457b17c6b543c7b7e3417c05 Mon Sep 17 00:00:00 2001 From: michaeldiamant Date: Thu, 27 Oct 2022 22:02:15 -0400 Subject: [PATCH 13/19] Add tests confirming genesis.json generation --- gen/generate.go | 8 +- gen/generate_test.go | 119 ++++++++++++ gen/resources/genesis-balance.json | 290 +++++++++++++++++++++++++++++ gen/resources/genesis-base.json | 290 +++++++++++++++++++++++++++++ gen/walletData.go | 2 +- 5 files changed, 702 insertions(+), 7 deletions(-) create mode 100644 gen/resources/genesis-balance.json create mode 100644 gen/resources/genesis-base.json diff --git a/gen/generate.go b/gen/generate.go index b2795209d2..4ce5aa9d68 100644 --- a/gen/generate.go +++ b/gen/generate.go @@ -355,14 +355,10 @@ func generateGenesisFiles(protoVersion protocol.ConsensusVersion, protoParams co } sinkAcct := genesisAllocation{ - Name: "FeeSink", - Stake: protoParams.MinBalance, - Online: basics.NotParticipating, + Name: "FeeSink", } poolAcct := genesisAllocation{ - Name: "RewardsPool", - Stake: rewardsBalance, - Online: basics.NotParticipating, + Name: "RewardsPool", } alloc2 := make([]genesisAllocation, 0, len(allocation)+2) diff --git a/gen/generate_test.go b/gen/generate_test.go index fbffe94678..e970cf6fb2 100644 --- a/gen/generate_test.go +++ b/gen/generate_test.go @@ -17,7 +17,13 @@ package gen import ( + "encoding/json" "fmt" + "github.com/algorand/go-algorand/crypto" + "github.com/algorand/go-algorand/data/bookkeeping" + "github.com/stretchr/testify/assert" + "io" + "os" "path/filepath" "strings" "sync" @@ -114,3 +120,116 @@ func TestGenesisRoundoff(t *testing.T) { require.NoError(t, err) require.True(t, strings.Contains(verbosity.String(), "roundoff")) } + +// `TestGenesisJsonCreation` defends against regressions to `genesis.json` generation by comparing a known, valid `genesis.json` against a version generated during test invocation. +// +// * For each `testCase`, there is a corresponding `genesis.json` in `gen/resources representing the known, valid output. +// * When adding test cases, it's assumed folks peer review new artifacts in `gen/resources`. +// * Since _some_ `genesis.json` values are non-deterministic, the test replaces these values with static values to facilitate equality checks. +func TestGenesisJsonCreation(t *testing.T) { + partitiontest.PartitionTest(t) + t.Parallel() + + type testCase struct { + name string + gd GenesisData + } + + // `base` is a canonical test confirming `devnet.json` generates the intended `genesis.json`. + base := func() testCase { + jsonBytes, err := os.ReadFile("devnet.json") + require.NoError(t, err) + + gd := DefaultGenesis + err = json.Unmarshal(jsonBytes, &gd) + require.NoError(t, err) + + return testCase{"base", gd} + } + + // `balance` extends `base` to confirm overriding the rewards pool balance works. + balance := func() testCase { + gd := base().gd + gd.RewardsPoolBalance = 0 // Expect generated balance == MinBalance + return testCase{"balance", gd} + } + + // `blotOutRandomValues` replaces random values with static values to support equality checks. + blotOutRandomValues := func(as []bookkeeping.GenesisAllocation) { + deterministicAddresses := []string{"FeeSink", "RewardsPool"} + + isNondeterministicAddress := func(name string) bool { + for _, address := range deterministicAddresses { + if name == address { + return false + } + } + return true + } + + for i := range as { + require.Len(t, as[i].State.VoteID, 32) + as[i].State.VoteID = crypto.OneTimeSignatureVerifier{} + require.Len(t, as[i].State.VoteID, 32) + as[i].State.SelectionID = crypto.VRFVerifier{} + + if isNondeterministicAddress(as[i].Comment) { + require.Len(t, as[i].Address, 58) + as[i].Address = "" + } + } + } + + saveGeneratedGenesisJson := func(filename, artifactName string) { + src, err := os.Open(filename) + require.NoError(t, err) + defer src.Close() + + dst, err := os.CreateTemp("", "*-"+artifactName) + require.NoError(t, err) + defer dst.Close() + + _, err = io.Copy(dst, src) + require.NoError(t, err) + + t.Log("generated genesis.json = " + dst.Name()) + } + + // Since `t.TempDir` deletes the generated dir, retain generated `genesis.json` on test failure. + saveOnFailure := func(result bool, generatedFilename, artifactName string) { + if !result { + saveGeneratedGenesisJson(generatedFilename, artifactName) + t.FailNow() + } + } + + for _, tc := range []testCase{ + base(), + balance(), + } { + t.Run(fmt.Sprintf("name=%v", tc.name), func(t *testing.T) { + gd := tc.gd + gd.LastPartKeyRound = 10 // Ensure quick test execution by reducing rounds. + + outDir := t.TempDir() + err := GenerateGenesisFiles(gd, config.Consensus, outDir, nil) + require.NoError(t, err) + + artifactName := fmt.Sprintf("genesis-%v.json", tc.name) + generatedFilename := fmt.Sprintf("%v/genesis.json", outDir) + saveOnFailure := func(result bool) { + saveOnFailure(result, generatedFilename, artifactName) + } + + roundtrip, err := bookkeeping.LoadGenesisFromFile(generatedFilename) + require.NoError(t, err) + + expected, err := bookkeeping.LoadGenesisFromFile("resources/" + artifactName) + saveOnFailure(assert.NoError(t, err)) + + blotOutRandomValues(expected.Allocation) + blotOutRandomValues(roundtrip.Allocation) + saveOnFailure(assert.Equal(t, expected, roundtrip)) + }) + } +} diff --git a/gen/resources/genesis-balance.json b/gen/resources/genesis-balance.json new file mode 100644 index 0000000000..53fc497b7b --- /dev/null +++ b/gen/resources/genesis-balance.json @@ -0,0 +1,290 @@ +{ + "alloc": [ + { + "addr": "7777777777777777777777777777777777777777777777777774MSJUVU", + "comment": "RewardsPool", + "state": { + "algo": 100000, + "onl": 2 + } + }, + { + "addr": "A7NMWS3NT3IUDMLVO26ULGXGIIOUQ3ND2TXSER6EBGRZNOBOUIQXHIBGDE", + "comment": "FeeSink", + "state": { + "algo": 100000, + "onl": 2 + } + }, + { + "addr": "LL5I5MBVV6LU26ENXVZ733A3IKUUTYMG6ZRCJB7G4GZIPSVFPHCCK2YKME", + "comment": "Wallet1", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "Tk6dVeLp2jkpR4GqTkUqmg4b7wwkgYshXpQ6FvWkJbQ=", + "vote": "DMXQB3LRyCznSDwFY7QhG+v6vrhaRR5DmcVBkiojGAw=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "LMSUTQYZ6PVSFF2UC2Y5BQQ6BPZPEEP4TJDZZAFGWFD7NR6JUIWYOBB7FA", + "comment": "Wallet10", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "FGmOjAOiA5WS36RbQqgW0R8+/7hNhr4d01w57E2Rj98=", + "vote": "rwRNmKNCR21GR7fGx0JscZFxAqDDntddmGPBrcPM3uM=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "IRLTNUT6N4RJPWHKHTGEFCC7XZPYXWUEQ3KPQDIPDOM4QCHMERLDCKB5BA", + "comment": "Wallet11", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "o3HGYpY+Cgon0G8h+LXt+x51iblyDAjU+UVh3i83QE0=", + "vote": "OisiREqsWPCCp/DQAAv/zv3t1cZuk9/EpHFTge45n9g=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "BL6N224XD2AO3UFAL3FYT4XV6TT225THQN2WZEVK2SZ2EN65MOWKOUHPCE", + "comment": "Wallet12", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "9t88h4TvAKqMIlRoLW9lfEIUZHkkeTeZNkxhf6cwBk4=", + "vote": "M2t4hO2Oe2cM0luPVQQjKFJUdUAve//NJLu31+AjSf8=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "7QAXF4XTPDNNP7IQXY2GAPU54SWOAEYN3KFNYZNYIT2TGTIATQYVYX34EE", + "comment": "Wallet13", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "EDectK5ACzkRBdTaK2jTJ3p2LRWVdIr2yqhw7vgLBAQ=", + "vote": "bD/yb+z+7TenZqd0G950WdDibXWcnH+5tLAUx6UWG28=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "EMOKFY3CUL5N63QL3K35AED5V23GLHFOCK247DW352NJQ2L7RX67TXBKLI", + "comment": "Wallet14", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "gFAz62RY4LPBD2TYmkKkm3RM0sE7kDH7XsA2nTjEMxU=", + "vote": "ZgVdTpahN5PgVcTsmNoLW8clsoHne2nfXnx7+jHbAeI=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "VHPOCATOURTR5Q4CCCSHFMDED2DJNQOSHIK5ZYRTWWXQ2NQHIFVVKC7IGM", + "comment": "Wallet15", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "faGqWez33n/hffAoQb1Mhiveb4SraHFUaXeBSTbDvtY=", + "vote": "i77hs2kcwF02SElbT7Bz9Pf75IYgF5nhqxhd8nQZ1y8=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "ZRTQWKBBNEGRYFDGVLVSI3FJHKIBQ7K527IWKXH75VTFCXMZVZGD4XA75E", + "comment": "Wallet16", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "0lQOFHTrORZmsJaFi3VbWtQM3eqIQuYtSiWm4UFI0/I=", + "vote": "mNQRvebWl6fHaO2icPtI4jv62UuaZXRFlz6PUvSXLjI=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "MFS6B3P3R7FOKMAU4FLMMMOKQVWTZCFYKEPE6SW66A5OJDWFFRFPMSO6AU", + "comment": "Wallet17", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "XKWnu0OXX1IaFYpm+IB00UXN83ap2d3uJqoSygqQyZE=", + "vote": "owK+kZlEr0VuFJZJMslXwpWHbnOdvRxQWLB3N4jpRt0=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "OLUNBJRRR2N4RSLIYNKAQNJIW7FK7M23AOPMIHER6RECHMGUINAV2WAXYA", + "comment": "Wallet18", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "c0Fku3FF4VxiDPxdTJ30+aoR9UdPkQ/iDV0DiKLjCh0=", + "vote": "eNwVkHYORjGE1Qme1D9o842cgFAn4nidryN35CgK78s=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "7VQYT4PAQBABDR3QODW5MUB3RU6MQ5MIWVIUR2HN3CSPA5H64TVQY4NT64", + "comment": "Wallet19", + "state": { + "algo": 400000000000000, + "onl": 1, + "sel": "TlelrGjnKdubOuRRMo2Mum2uUAP6UkG2ANDD+BZKOTo=", + "vote": "LWlAr9lRXcolQ9h4fX2DTw3LU8/KI6Eix6tJ+o8fsho=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "BSJ5G7YEOVTEKKDJZZKULAJPBH26SPIV4RJLV5AUSYZ36ELRN3JHZTZX2E", + "comment": "Wallet2", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "D3aE+VywLz4HA8NPX7mEB3m33FOer4L2ZBRa0qT/1fI=", + "vote": "ITColZ7Roe/p+qQXX8yk6FKibhN6sShNWFdvgDk3kGY=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "ETMCXHLEI7KOTMPVIOZAAPMQGQTST3CPZP4YG25HBCFB6XY3IIGH3YYUSE", + "comment": "Wallet20", + "state": { + "algo": 400000000000000, + "onl": 1, + "sel": "4Hg5XgcvEQsPiI7eaNE3hZgKZIvBl93CCKZZ8GZIDps=", + "vote": "HOecVUnX8xe86+Rrt237Z+jXFILhBM2I7GvyxCWxpbY=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "TQYRDSG5BS5XR6USGROXP5DSUAHJHKUTE5GBLENHBGWKAK2YNLEANQ7ELM", + "comment": "Wallet3", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "hOfLlBV0eDcF1lV7cUxMfo7dKBmCBflrgNJ1NxDv1KQ=", + "vote": "AgpySx7yp2177QjUueEJ+HN1xpQTW8Uf6sTu6lCHq2w=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "BOKSOEFFJE4RUPFMZHPQRJBEORY3W5BJNR5YUEYGOWKN6IZP4XLMHPLBCQ", + "comment": "Wallet4", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "arO4hIghNSwWvmr+hNHItYFniImOiCjGo4IwPDEBENg=", + "vote": "QLeClCU8nw2hHPA9YnrhWSlZ0Nc5awyk5WI/RhipGrU=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "VIMND5G6N6BYICGLXPBBKJNOO36K22HHUDV4KCKOS2STO225AKKGWNLOOM", + "comment": "Wallet5", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "sTAHT53hHEAMC/NXj+N6sAXvBrJzIU3QeIiD8YdyHN8=", + "vote": "qXu3+DUAPs71xZtugIxYOOFh4pxQ1zOD/wDvACmNAOo=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "6GQNPBPISA6YUSLIHCKFGNARGA36PPFEI3G77MVFZRLBB5T7ENOFLUIOM4", + "comment": "Wallet6", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "DVqDBjuBNwqDgn/Srl0M0iAhY4F7OaYlPM6Mksqag7s=", + "vote": "wwy76l2W220L/T7NxYu0RwkCtgZopwAby7+Ufo3FroE=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "HLBHM4N2YBRERHGBRMSBJ2H374X3UGLPB3EFGQ42P5HJ3AGOZPBZMNLHWI", + "comment": "Wallet7", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "HLNbmSEJe1ToTIT6QJ7xymrJlC9DPX00Ebw3MMyKb9Q=", + "vote": "D4+2cKNIhuAv0Rum9x5Tw5RT1/SsmuPpuxB8eQ4OrS8=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "M5O226M5GLGRHVQ3CWFFZBFUB4GPLK7RPSCGU25VY2Z5STSQI6D7LLXCQE", + "comment": "Wallet8", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "HgmAAyQuxjdD5dYW6QORoKL756+8PLfFckbtEtd6Qms=", + "vote": "+2NoVf0UHCM6+xf2crgh03vXHW4/rvJbvV1kgU6eb8A=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "66UUTNSIJMQJRM7GPNBDBNWQSLPDRX5MFRZYZDDILCATHB6EWFZVJEGC5M", + "comment": "Wallet9", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "74oS0XpjjqpTB+6nKj0bMl4ZMHN5HLvpSCnczSfkX0Q=", + "vote": "BWTZ9sJJVzjo20iFWBeCTrc1nxETWHP1IBAzjR+TtC8=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "HHDJTAQXM35CDYBVD5YB3ZYXZ3SA2G7EPX377CLYWSA4OAQTQ3JLS7GJJQ", + "comment": "bank", + "state": { + "algo": 100000000000000, + "onl": 1, + "sel": "UMIH8ldIewQ9K0dKs1iWIwLBNsS2+9GEaZh7/wkvPmI=", + "vote": "MSgY48yyvE+XHdeJGj7Muh17rn+JqNt0NMtzOBCM4yU=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "IVRXBBY53IKQW4I5M7CYRCE6W37TYIB4IIR73KBDWTROMVAOGPT5K75E3Y", + "comment": "pp1", + "state": { + "algo": 50000000000000 + } + }, + { + "addr": "UDMWNUYTV4AU6Y76RCNHMTWVZ6QYACYFJP4PAZNBMRWRFZKRNE6V7SBG7Q", + "comment": "pp2", + "state": { + "algo": 50000000000000 + } + } + ], + "fees": "A7NMWS3NT3IUDMLVO26ULGXGIIOUQ3ND2TXSER6EBGRZNOBOUIQXHIBGDE", + "id": "v1.0", + "proto": "https://github.com/algorand/spec/tree/a26ed78ed8f834e2b9ccb6eb7d3ee9f629a6e622", + "rwd": "7777777777777777777777777777777777777777777777777774MSJUVU" +} diff --git a/gen/resources/genesis-base.json b/gen/resources/genesis-base.json new file mode 100644 index 0000000000..16cef5b980 --- /dev/null +++ b/gen/resources/genesis-base.json @@ -0,0 +1,290 @@ +{ + "alloc": [ + { + "addr": "7777777777777777777777777777777777777777777777777774MSJUVU", + "comment": "RewardsPool", + "state": { + "algo": 125000000000000, + "onl": 2 + } + }, + { + "addr": "A7NMWS3NT3IUDMLVO26ULGXGIIOUQ3ND2TXSER6EBGRZNOBOUIQXHIBGDE", + "comment": "FeeSink", + "state": { + "algo": 100000, + "onl": 2 + } + }, + { + "addr": "5P7SSF6IRMBZKQBH4KJLZMKNK3VB5SHK3ZEUJAUD4NODLLXJLOCJPY6GWA", + "comment": "Wallet1", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "R3ZILpY0ZOgcRbb3spZyXBtwt4Q9oeP4JkGmLWvp1wM=", + "vote": "fjzsjb8BcM4KhDPQyf7qxisv8mWzb6t+nv9eZnPbq3w=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "23PVZMF53OVWQ5YRJDG75P774AAQDOWMGT2YRRO3ZVCAMV7P6WQDUHTHSY", + "comment": "Wallet10", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "M/NhvAm8FfFxgcEynZ2XyiedqA0ZXsYPpQAT9j8UStg=", + "vote": "3QrVWdEk/JU5+W3KsOqZQWwqBP+3syw3jWkra5UlRyY=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "5GWNQULH2QB7IAMX7XAIYU6VQT7S4JTZZE2MVCO7HNWGFHM6GTGUCFVEIY", + "comment": "Wallet11", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "lEHWhsPoBlboeK+m9ASMV+eHe6aMWFr2wDFtW7BhZps=", + "vote": "m9hkZTh3JZtipCgRMQlxvjLHEBlPWI5rzi0a62nYmn4=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "MXEYXXM74MXMOJ7VCDDHYUIDELZBLETSB6ZUCR2K4OLCFKYPVBTJ7Q3WXA", + "comment": "Wallet12", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "dRgwg+/Q0WhqJu4pzVmFN15czLEwpzGbFHnqsGktRjk=", + "vote": "idEmvipGvNuebDonCSLcFJhaxjpft/1MZqxGzM0MOnY=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "MDPD6UI4D7CRJO2QP3OA4GJAZXMGE5LY5XV2FQ36RJ5MKKRLNT3NPXFM4Y", + "comment": "Wallet13", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "teFS7YWTutxUvxSWXHzuS8wwkX5ueR9CEanNR0IhsHM=", + "vote": "FpRYYVxA2I72a0m3+bJ+4fzD+wcsgRbMXzPrX+ihZKo=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "NW3ARRUBZDSTXH5FXI54LZUATS5QHYZGQHONXJFZWUQCU6EYVM57KQCSGU", + "comment": "Wallet14", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "3vwiEtd2C0wm89P9vex9nud8nM4rdgCd8OAT7SUWfpA=", + "vote": "dXoHsQvvUY6HiRIR2JUaTFR21RROq+tzA3ApYL8lw7I=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "54Q7QENDL6GRX7XOBONV3AY2OHD62IGQPEFNUCKL4IH6XD2HGSJETIR22Y", + "comment": "Wallet15", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "b0hfKTC81csTjO/x21E6w4OpDlcVNCZBWky0gwpo2qo=", + "vote": "T9UBwWaOpUnq4azO1yyaH8rTHWXzfanIHib0RxI9N+c=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "DU4LJRJKBIIREB7CKKWCOUP6NHUM5HKKVYH6LU2ZE63D67PZRL7VSHNADI", + "comment": "Wallet16", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "JIdWGPjyKJZCfC5Y+IYxqC1oDEa2pXePQ3TSBQ3v+K0=", + "vote": "nYIVrFrNAf4lWvt1RiLR2Nv/EzaxH5us/7prSQqbFgM=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "Z745PXKLO7EJOBMUYKMZQXZJQD2NOI2ZC5CUUVZYQDL6S5FCMG2RTDR43U", + "comment": "Wallet17", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "29+iADCFdA+wltMu0ZgCPzAogbbp5kr5zRRJteB2mdE=", + "vote": "vzXs2Ebue388Ya3vVgEZ2JX6IJaZuIn2MIcl1N1T0lk=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "PA2FWPXRLKGKDRTP5JFYWWM3PBE77SINTRZ5BQCCKAK363TMMVFUJOM3OA", + "comment": "Wallet18", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "fKYC8BIRXI/4s0E52wDYd0jSiOgvStdA+8Vr7fTh0TA=", + "vote": "+jaGxdKU5PpxQxp7XRCYhc0Oss6josumZW7GNhl9Kkg=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "R24KUNIHRTSDYEWVJVJMHJ2IYE3NXBTSE3NQXOHPG5ULJJ4YEP6DXLWIQM", + "comment": "Wallet19", + "state": { + "algo": 400000000000000, + "onl": 1, + "sel": "J1yWsrjAlqi0/HXQ++yK03+iFuPPu9q0HZVWp2V5gjU=", + "vote": "db7v7DZeGSeI9t3eXXoO0DxMghAGmidVh3bGBOeqcC8=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "WLEX5HDAKMEA35NKY2QUXFXIFIKMOF6PHLMNDD25KLNNTPXRRO7TPAP6SQ", + "comment": "Wallet2", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "AYda5HHpJpFnpbQ/oeqvc9eSKPccHldGczvqwsJzWiE=", + "vote": "HjXz+GAo7yqeKRsOB+RQNr2V5vjwS/bMynMTr37T8D8=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "XSQO4QZQZLFSAM7GOGYIOFH3EKTYC3WVO3CND7V4QQ7KXOQBD2OYRCCARE", + "comment": "Wallet20", + "state": { + "algo": 400000000000000, + "onl": 1, + "sel": "joC7f9011hnDVa87WsaRSD/+Z8HyJ6tPT8NCQJJKNQ4=", + "vote": "BRVqGnSjJZnBM2MdHs3YkApVB9iR6nd6VVTx2kvPQjw=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "KE2HQAZHGJDKZUKRBDBQTBQOSVSCDROUC7UFJZ27KTNHBKON6GKFBDD5MY", + "comment": "Wallet3", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "lb/5w4Q/6KE3g2+KeRc4GrslWubT/2QkKQX9pJqBwWA=", + "vote": "gs5MFqUUn/IDBb0kb4VJiv6gIOUVIcSSmpdaLteAKmw=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "7SCSRGS3YLKORJLJI6AGJOBEQYOVEMCPF52F3TK6KZZRZVZQCKCFGOGWIY", + "comment": "Wallet4", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "ImC3tocbWRoTdd90owSbskgsvnNpyFW1c79CNJl2mjU=", + "vote": "xFrT7tp0Yth3j39XJJKtKxxMaXDiFRbXtzoOjQnavFY=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "2FCYNSOOK6HGVK4ZJZ3ROAV6S3Y6KYY5467BY7JQEVTT75RNSIM3D6WK5M", + "comment": "Wallet5", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "aEKSz4Hqi6JY82890qxqAUhkiQ2YvDYNrQBjq6UOgwU=", + "vote": "Gxyf2lPDSVhLrfUOtS6vS0fvrV9g22XHR/uUl7uzzsw=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "6SUHM22SBOZ4O4E7VQIB2FWHGCFLBCDOZAQ6AWXV3CTEDVB45UZGX2GZ2U", + "comment": "Wallet6", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "OXOkW9CbraU2UM1IjDkkpS3zGlBCjm0SHc3mFgZrUdE=", + "vote": "ssh7jRwaim+vTO4W9F2tw+j5BoFOqTTTy1DOZfqIXwY=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "H2A6ALQ6U7P2JSABWPRLG3IRRKH3AAUJFZXLI7YHCBZ7K6DOTHWBVGFIZM", + "comment": "Wallet7", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "B9rVwMkp9YAbdOz3vOK2K7UyDBsHBGeHUEcErioligA=", + "vote": "MyheCHyiz464tL3rdZkztIl/fx7ARYPvEv8xuFozCfM=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "5ZBBKATPM6HM56TOGQOSPFMIOVUZJJAZAAUATNPVCB6SKQYVIMRUOC454Q", + "comment": "Wallet8", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "g/995Lmd4y+IhbDCD6CXLyuIMs+GhFbXbmvVSCwG9RU=", + "vote": "SJ0Hj+Xau09OB97nfbktnTnA5K4MqRzQCwDR1BN4R+8=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "UPL2Q6OLQHLAZWXBEP7DTN3225ISOJ45DACXEDCNJ2UBCPR7EWUCPMW3KE", + "comment": "Wallet9", + "state": { + "algo": 500000000000000, + "onl": 1, + "sel": "X8Df4E1SSkCEoWYfDOGMPTSoecc6FaHTzDRNYpOVL7I=", + "vote": "ZUkY2tLQ3XmcG6aVWjJLdJvWjWfoPI7EliAq/ZYaIUg=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "N6TENNVOWAILNAZIOT3RFX6C4DPC2HEYOQD5KBBGFDE77FUNZU7NMWBIKA", + "comment": "bank", + "state": { + "algo": 100000000000000, + "onl": 1, + "sel": "vBIkGS3JImg7DVRGr6L3ZLuzFe9EXSDedvZkHRgAGEQ=", + "vote": "NoVimVCKTiIntOa/q9zUcVEN5erCIdD0c5G2eIAzBL4=", + "voteKD": 10000, + "voteLst": 10 + } + }, + { + "addr": "XHV5PYJARUBZA6EMG6ERYAL4ROXVTLVHMC2W52LDGVOVQNCQOAFNLTG32U", + "comment": "pp1", + "state": { + "algo": 50000000000000 + } + }, + { + "addr": "4EDQJQLPFX5CBWHJJ2GQXKMV6UQC2O553PGZVID6QVB7JZT3XBQ5MCSD2Q", + "comment": "pp2", + "state": { + "algo": 50000000000000 + } + } + ], + "fees": "A7NMWS3NT3IUDMLVO26ULGXGIIOUQ3ND2TXSER6EBGRZNOBOUIQXHIBGDE", + "id": "v1.0", + "proto": "https://github.com/algorand/spec/tree/a26ed78ed8f834e2b9ccb6eb7d3ee9f629a6e622", + "rwd": "7777777777777777777777777777777777777777777777777774MSJUVU" +} diff --git a/gen/walletData.go b/gen/walletData.go index e0b3d2bf6d..7790e9a6be 100644 --- a/gen/walletData.go +++ b/gen/walletData.go @@ -50,7 +50,7 @@ type GenesisData struct { Wallets []WalletData FeeSink basics.Address RewardsPool basics.Address - RewardsPoolBalance uint64 + RewardsPoolBalance uint64 // Values < `ConsensusParams.MinBalance` are adjusted to `ConsensusParams.MinBalance` DevMode bool Comment string } From 075711f5e43c2d13467039828ef510d02945ba68 Mon Sep 17 00:00:00 2001 From: michaeldiamant Date: Thu, 27 Oct 2022 22:08:55 -0400 Subject: [PATCH 14/19] Fix comment --- gen/generate_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gen/generate_test.go b/gen/generate_test.go index e970cf6fb2..c64ddf1c3b 100644 --- a/gen/generate_test.go +++ b/gen/generate_test.go @@ -123,7 +123,7 @@ func TestGenesisRoundoff(t *testing.T) { // `TestGenesisJsonCreation` defends against regressions to `genesis.json` generation by comparing a known, valid `genesis.json` against a version generated during test invocation. // -// * For each `testCase`, there is a corresponding `genesis.json` in `gen/resources representing the known, valid output. +// * For each `testCase`, there is a corresponding `genesis.json` in `gen/resources` representing the known, valid output. // * When adding test cases, it's assumed folks peer review new artifacts in `gen/resources`. // * Since _some_ `genesis.json` values are non-deterministic, the test replaces these values with static values to facilitate equality checks. func TestGenesisJsonCreation(t *testing.T) { From 7cea01f9e3d94e510b6428195540cdb0abb74096 Mon Sep 17 00:00:00 2001 From: michaeldiamant Date: Fri, 28 Oct 2022 08:51:26 -0400 Subject: [PATCH 15/19] Fix reviewdog errors --- gen/generate_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gen/generate_test.go b/gen/generate_test.go index c64ddf1c3b..10fa7834f1 100644 --- a/gen/generate_test.go +++ b/gen/generate_test.go @@ -180,7 +180,7 @@ func TestGenesisJsonCreation(t *testing.T) { } } - saveGeneratedGenesisJson := func(filename, artifactName string) { + saveGeneratedGenesisJSON := func(filename, artifactName string) { src, err := os.Open(filename) require.NoError(t, err) defer src.Close() @@ -198,7 +198,7 @@ func TestGenesisJsonCreation(t *testing.T) { // Since `t.TempDir` deletes the generated dir, retain generated `genesis.json` on test failure. saveOnFailure := func(result bool, generatedFilename, artifactName string) { if !result { - saveGeneratedGenesisJson(generatedFilename, artifactName) + saveGeneratedGenesisJSON(generatedFilename, artifactName) t.FailNow() } } From cd39c5e71f7e20d1cea8366cb6b10430b6d30426 Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Mon, 31 Oct 2022 07:39:43 -0400 Subject: [PATCH 16/19] Update netdeploy/network.go --- netdeploy/network.go | 1 - 1 file changed, 1 deletion(-) diff --git a/netdeploy/network.go b/netdeploy/network.go index 07700ad0a7..78a665b789 100644 --- a/netdeploy/network.go +++ b/netdeploy/network.go @@ -74,7 +74,6 @@ func CreateNetworkFromTemplate(name, rootDir, templateFile, binDir string, impor template.Nodes[0].IsRelay = false } } - err = template.Validate() } if err != nil { From 019df3e9752c4cedb627ce127ae023e787af9d22 Mon Sep 17 00:00:00 2001 From: Michael Diamant Date: Tue, 1 Nov 2022 11:35:41 -0400 Subject: [PATCH 17/19] Update gen/generate.go Co-authored-by: Will Winder --- gen/generate.go | 1 + 1 file changed, 1 insertion(+) diff --git a/gen/generate.go b/gen/generate.go index 4ce5aa9d68..8b07c107ba 100644 --- a/gen/generate.go +++ b/gen/generate.go @@ -354,6 +354,7 @@ func generateGenesisFiles(protoVersion protocol.ConsensusVersion, protoParams co MicroAlgos: basics.MicroAlgos{Raw: rewardsBalance}, } + // Add FeeSink and RewardsPool to allocation slice to be handled with other allocations. sinkAcct := genesisAllocation{ Name: "FeeSink", } From 5193c93f6910381f28c1135f3797d3c644dc918d Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Tue, 1 Nov 2022 11:46:40 -0400 Subject: [PATCH 18/19] group imports --- gen/generate_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gen/generate_test.go b/gen/generate_test.go index 6f526ae489..c9d0615e91 100644 --- a/gen/generate_test.go +++ b/gen/generate_test.go @@ -23,13 +23,13 @@ import ( "sync" "testing" + "github.com/stretchr/testify/require" + "github.com/algorand/go-algorand/config" "github.com/algorand/go-algorand/data/account" "github.com/algorand/go-algorand/protocol" - "github.com/algorand/go-algorand/util/db" - "github.com/algorand/go-algorand/test/partitiontest" - "github.com/stretchr/testify/require" + "github.com/algorand/go-algorand/util/db" ) func TestLoadMultiRootKeyConcurrent(t *testing.T) { From d4db8509b883b569b23494b7c67310e051467a77 Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Tue, 1 Nov 2022 12:28:44 -0400 Subject: [PATCH 19/19] remove unintended merge changes --- data/bookkeeping/genesis_test.go | 21 --------------------- gen/generate.go | 7 +------ 2 files changed, 1 insertion(+), 27 deletions(-) diff --git a/data/bookkeeping/genesis_test.go b/data/bookkeeping/genesis_test.go index b6b85ec486..9ca60bd5e1 100644 --- a/data/bookkeeping/genesis_test.go +++ b/data/bookkeeping/genesis_test.go @@ -56,7 +56,6 @@ func TestGenesis_Balances(t *testing.T) { } } goodAddr := makeAddr(100) - zeroAddr := makeAddr(0) allocation1 := acctWith(1000, makeAddr(1).String()) allocation2 := acctWith(2000, makeAddr(2).String()) badAllocation := acctWith(1234, "El Toro Loco") @@ -64,7 +63,6 @@ func TestGenesis_Balances(t *testing.T) { Allocation []GenesisAllocation FeeSink string RewardsPool string - DevMode bool } tests := []struct { name string @@ -141,24 +139,6 @@ func TestGenesis_Balances(t *testing.T) { }, wantErr: containsErrorFunc("repeated allocation to"), }, - { - name: "dev mode", - fields: fields{ - Allocation: []GenesisAllocation{allocation1}, - FeeSink: goodAddr.String(), - RewardsPool: zeroAddr.String(), - DevMode: true, - }, - want: GenesisBalances{ - Balances: map[basics.Address]basics.AccountData{ - mustAddr(allocation1.Address): allocation1.State, - }, - FeeSink: goodAddr, - RewardsPool: zeroAddr, - Timestamp: 0, - }, - wantErr: assert.NoError, - }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -166,7 +146,6 @@ func TestGenesis_Balances(t *testing.T) { Allocation: tt.fields.Allocation, FeeSink: tt.fields.FeeSink, RewardsPool: tt.fields.RewardsPool, - DevMode: true, } got, err := genesis.Balances() if tt.wantErr(t, err, fmt.Sprintf("Balances()")) { diff --git a/gen/generate.go b/gen/generate.go index fcb4c00147..9274da4203 100644 --- a/gen/generate.go +++ b/gen/generate.go @@ -44,7 +44,6 @@ var schemaID = "v1" var defaultSinkAddr = basics.Address{0x7, 0xda, 0xcb, 0x4b, 0x6d, 0x9e, 0xd1, 0x41, 0xb1, 0x75, 0x76, 0xbd, 0x45, 0x9a, 0xe6, 0x42, 0x1d, 0x48, 0x6d, 0xa3, 0xd4, 0xef, 0x22, 0x47, 0xc4, 0x9, 0xa3, 0x96, 0xb8, 0x2e, 0xa2, 0x21} var defaultPoolAddr = basics.Address{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff} -var zeroAddr = basics.Address{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // The number of MicroAlgos in the incentive pool at genesis. var defaultIncentivePoolBalanceAtInception uint64 = 125e6 * 1e6 @@ -84,11 +83,7 @@ func setupGenerateGenesisFiles(genesisData *GenesisData, consensus config.Consen genesisData.FeeSink = defaultSinkAddr } if (genesisData.RewardsPool == basics.Address{}) { - if genesisData.DevMode { - genesisData.RewardsPool = zeroAddr - } else { - genesisData.RewardsPool = defaultPoolAddr - } + genesisData.RewardsPool = defaultPoolAddr } var ok bool