From 64fab882c8164cb674da33dcba917da37c9d7a7e Mon Sep 17 00:00:00 2001 From: Dmitry Date: Fri, 8 Sep 2023 12:46:46 +0200 Subject: [PATCH 1/6] testnet with 1 day settinng and 1024 labels per unit --- config/config.go | 2 +- config/logging.go | 2 +- config/mainnet.go | 2 +- config/presets/testnet.go | 178 ++++++++++++++++++++++++++------------ 4 files changed, 128 insertions(+), 56 deletions(-) diff --git a/config/config.go b/config/config.go index a035fb5762..3ebf4e9ec3 100644 --- a/config/config.go +++ b/config/config.go @@ -154,7 +154,7 @@ func DefaultConfig() Config { POET: activation.DefaultPoetConfig(), SMESHING: DefaultSmeshingConfig(), FETCH: fetch.DefaultConfig(), - LOGGING: defaultLoggingConfig(), + LOGGING: DefaultLoggingConfig(), Bootstrap: bootstrap.DefaultConfig(), Sync: syncer.DefaultConfig(), Recovery: checkpoint.DefaultConfig(), diff --git a/config/logging.go b/config/logging.go index 8ce5233046..b81f14e5da 100644 --- a/config/logging.go +++ b/config/logging.go @@ -47,7 +47,7 @@ type LoggerConfig struct { VMLogLevel string `mapstructure:"vm"` } -func defaultLoggingConfig() LoggerConfig { +func DefaultLoggingConfig() LoggerConfig { return LoggerConfig{ Encoder: ConsoleLogEncoder, AppLoggerLevel: defaultLoggingLevel.String(), diff --git a/config/mainnet.go b/config/mainnet.go index abee02a74b..601e4aa0d9 100644 --- a/config/mainnet.go +++ b/config/mainnet.go @@ -131,7 +131,7 @@ func MainnetConfig() Config { TIME: timeConfig.DefaultConfig(), SMESHING: smeshing, FETCH: fetch.DefaultConfig(), - LOGGING: defaultLoggingConfig(), + LOGGING: DefaultLoggingConfig(), Sync: syncer.Config{ Interval: time.Minute, EpochEndFraction: 0.8, diff --git a/config/presets/testnet.go b/config/presets/testnet.go index 1399550d2b..4e729ff2e1 100644 --- a/config/presets/testnet.go +++ b/config/presets/testnet.go @@ -1,12 +1,27 @@ package presets import ( + "math" + "math/big" + "os" + "path/filepath" + "runtime" "time" - "github.com/spacemeshos/post/initialization" - - "github.com/spacemeshos/go-spacemesh/common/types" + "github.com/spacemeshos/go-spacemesh/activation" + "github.com/spacemeshos/go-spacemesh/api/grpcserver" + "github.com/spacemeshos/go-spacemesh/beacon" + "github.com/spacemeshos/go-spacemesh/bootstrap" + "github.com/spacemeshos/go-spacemesh/checkpoint" "github.com/spacemeshos/go-spacemesh/config" + "github.com/spacemeshos/go-spacemesh/datastore" + "github.com/spacemeshos/go-spacemesh/fetch" + hareConfig "github.com/spacemeshos/go-spacemesh/hare/config" + eligConfig "github.com/spacemeshos/go-spacemesh/hare/eligibility/config" + "github.com/spacemeshos/go-spacemesh/p2p" + "github.com/spacemeshos/go-spacemesh/syncer" + timeConfig "github.com/spacemeshos/go-spacemesh/timesync/config" + "github.com/spacemeshos/go-spacemesh/tortoise" ) func init() { @@ -14,60 +29,117 @@ func init() { } func testnet() config.Config { - conf := config.DefaultConfig() - - conf.NetworkHRP = "stest" - types.SetNetworkHRP(conf.NetworkHRP) // set to generate coinbase - - conf.HARE.N = 800 - conf.HARE.ExpectedLeaders = 10 - conf.HARE.LimitConcurrent = 5 - conf.HARE.LimitIterations = 10 - conf.HARE.RoundDuration = 10 * time.Second - conf.HARE.WakeupDelta = 10 * time.Second - - conf.P2P.MinPeers = 10 - - conf.Genesis = &config.GenesisConfig{ - ExtraData: "testnet", - Accounts: map[string]uint64{ - "stest1qqqqqqygdpsq62p4qxfyng8h2mm4f4d94vt7huqqu9mz3": 100000000000000000, - "stest1qqqqqqylzg8ypces4llx4gnat0dyntqfvr0h6mcprcz66": 100000000000000000, - "stest1qqqqqq90akdpc97206485eu4m0rmacd3mxfv0wsdrea6k": 100000000000000000, - "stest1qqqqqq9jpsarr7tnyv0qr0edddwqpg3vcya4cccauypts": 100000000000000000, - "stest1qqqqqq8lpq7f5ghqt569nvpl8kldv8r66ms2yzgudsd5t": 100000000000000000, - }, + var postPowDifficulty activation.PowDifficulty + if err := postPowDifficulty.UnmarshalText([]byte("000dfb23b0979b4b000000000000000000000000000000000000000000000000")); err != nil { + panic(err) } + p2pconfig := p2p.DefaultConfig() - conf.LayerAvgSize = 50 - conf.LayerDuration = 120 * time.Second - conf.LayersPerEpoch = 60 - - conf.Tortoise.Hdist = 60 - conf.Tortoise.Zdist = 10 - conf.Tortoise.BadBeaconVoteDelayLayers = 30 + smeshing := config.DefaultSmeshingConfig() + smeshing.ProvingOpts.Nonces = 288 + smeshing.ProvingOpts.Threads = uint(runtime.NumCPU() * 3 / 4) + if smeshing.ProvingOpts.Threads < 1 { + smeshing.ProvingOpts.Threads = 1 + } + home, err := os.UserHomeDir() + if err != nil { + panic("can't read homedir: " + err.Error()) + } + defaultdir := filepath.Join(home, "spacemesh-testnet", "/") + return config.Config{ + BaseConfig: config.BaseConfig{ + DataDirParent: defaultdir, + FileLock: filepath.Join(os.TempDir(), "spacemesh.lock"), + MetricsPort: 1010, + DatabaseConnections: 16, + NetworkHRP: "smtest", - conf.POST.K1 = 26 - conf.POST.K2 = 37 - conf.POST.K3 = 37 - conf.POST.LabelsPerUnit = 20 * 1024 / 16 // 20 kB units - conf.POST.MaxNumUnits = 4 - conf.POST.MinNumUnits = 2 + LayerDuration: 5 * time.Minute, + LayerAvgSize: 50, + LayersPerEpoch: 288, - conf.SMESHING.CoinbaseAccount = types.GenerateAddress([]byte("1")).String() - conf.SMESHING.Start = false - conf.SMESHING.Opts.ProviderID.SetInt64(int64(initialization.CPUProviderID())) - conf.SMESHING.Opts.NumUnits = 2 - conf.SMESHING.Opts.Throttle = true + TxsPerProposal: 700, // https://github.com/spacemeshos/go-spacemesh/issues/4559 + BlockGasLimit: 100107000, // 3000 of spends - conf.Beacon.FirstVotingRoundDuration = 3 * time.Minute - conf.Beacon.GracePeriodDuration = 10 * time.Second - conf.Beacon.ProposalDuration = 30 * time.Second - conf.Beacon.RoundsNumber = 6 - conf.Beacon.BeaconSyncWeightUnits = 30 - conf.Beacon.VotesLimit = 100 - conf.Beacon.VotingRoundDuration = 50 * time.Second - conf.Beacon.WeakCoinRoundDuration = 10 * time.Second + OptFilterThreshold: 90, - return conf + TickSize: 666514, + PoETServers: []string{}, + }, + Genesis: &config.GenesisConfig{ + GenesisTime: "2023-09-11T08:00:00Z", + ExtraData: "0000000000000000000000c76c58ebac180989673fd6d237b40e66ed5c976ec3", + }, + Tortoise: tortoise.Config{ + Hdist: 10, + Zdist: 2, + WindowSize: 10000, + MaxExceptions: 1000, + BadBeaconVoteDelayLayers: 4032, + // 100 - is assumed minimal number of units + // 100 - half of the expected poet ticks + MinimalActiveSetWeight: 100 * 100, + }, + HARE: hareConfig.Config{ + N: 200, + ExpectedLeaders: 5, + RoundDuration: 25 * time.Second, + WakeupDelta: 25 * time.Second, + LimitConcurrent: 2, + LimitIterations: 4, + }, + HareEligibility: eligConfig.Config{ + ConfidenceParam: 20, + }, + Beacon: beacon.Config{ + Kappa: 40, + Q: big.NewRat(1, 3), + Theta: big.NewRat(1, 4), + GracePeriodDuration: 10 * time.Minute, + ProposalDuration: 4 * time.Minute, + FirstVotingRoundDuration: 30 * time.Minute, + RoundsNumber: 20, + VotingRoundDuration: 4 * time.Minute, + WeakCoinRoundDuration: 4 * time.Minute, + VotesLimit: 100, + BeaconSyncWeightUnits: 800, + }, + POET: activation.PoetConfig{ + PhaseShift: 12 * time.Hour, + CycleGap: 2 * time.Hour, + GracePeriod: 10 * time.Minute, + RequestRetryDelay: 10 * time.Second, + MaxRequestRetries: 10, + }, + POST: activation.PostConfig{ + MinNumUnits: 4, + MaxNumUnits: math.MaxUint32, + LabelsPerUnit: 1024, + K1: 26, + K2: 37, + K3: 37, + PowDifficulty: postPowDifficulty, + }, + Bootstrap: bootstrap.Config{ + URL: "https://bootstrap.spacemesh.network/testnet06", + Version: "https://spacemesh.io/bootstrap.schema.json.1.0", + DataDir: os.TempDir(), + Interval: 30 * time.Second, + }, + P2P: p2pconfig, + API: grpcserver.DefaultConfig(), + TIME: timeConfig.DefaultConfig(), + SMESHING: smeshing, + FETCH: fetch.DefaultConfig(), + LOGGING: config.DefaultLoggingConfig(), + Sync: syncer.Config{ + Interval: time.Minute, + EpochEndFraction: 0.8, + MaxStaleDuration: time.Hour, + UseNewProtocol: true, + GossipDuration: 50 * time.Second, + }, + Recovery: checkpoint.DefaultConfig(), + Cache: datastore.DefaultConfig(), + } } From 440fdd962798ddfa5ef27ddbef5221a303c17ad9 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Fri, 8 Sep 2023 13:16:02 +0200 Subject: [PATCH 2/6] change to 13 --- config/presets/testnet.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/presets/testnet.go b/config/presets/testnet.go index 4e729ff2e1..b4dd307413 100644 --- a/config/presets/testnet.go +++ b/config/presets/testnet.go @@ -67,7 +67,7 @@ func testnet() config.Config { PoETServers: []string{}, }, Genesis: &config.GenesisConfig{ - GenesisTime: "2023-09-11T08:00:00Z", + GenesisTime: "2023-09-13T08:00:00Z", ExtraData: "0000000000000000000000c76c58ebac180989673fd6d237b40e66ed5c976ec3", }, Tortoise: tortoise.Config{ From ede168bdf6c6769f3415b4580bfe3c696907c3f7 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 12 Sep 2023 15:07:48 +0200 Subject: [PATCH 3/6] change request retry delay to 5s --- config/presets/testnet.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/presets/testnet.go b/config/presets/testnet.go index b4dd307413..fb62984975 100644 --- a/config/presets/testnet.go +++ b/config/presets/testnet.go @@ -108,7 +108,7 @@ func testnet() config.Config { PhaseShift: 12 * time.Hour, CycleGap: 2 * time.Hour, GracePeriod: 10 * time.Minute, - RequestRetryDelay: 10 * time.Second, + RequestRetryDelay: 5 * time.Second, MaxRequestRetries: 10, }, POST: activation.PostConfig{ From 2047c04bf8168324d7953bf36c06d6d21dd7cf5a Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 12 Sep 2023 18:05:12 +0200 Subject: [PATCH 4/6] fixes --- config/presets/testnet.go | 2 +- node/adminservice_api_test.go | 1 + node/util_test.go | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/config/presets/testnet.go b/config/presets/testnet.go index fb62984975..ed9b3b4170 100644 --- a/config/presets/testnet.go +++ b/config/presets/testnet.go @@ -112,7 +112,7 @@ func testnet() config.Config { MaxRequestRetries: 10, }, POST: activation.PostConfig{ - MinNumUnits: 4, + MinNumUnits: 2, MaxNumUnits: math.MaxUint32, LabelsPerUnit: 1024, K1: 26, diff --git a/node/adminservice_api_test.go b/node/adminservice_api_test.go index 70623fc76f..4c2e1b00b9 100644 --- a/node/adminservice_api_test.go +++ b/node/adminservice_api_test.go @@ -18,6 +18,7 @@ import ( func TestPeerInfoApi(t *testing.T) { cfg := config.DefaultTestConfig() + cfg.Genesis.Accounts = nil cfg.P2P.DisableNatPort = true cfg.P2P.Listen = "/ip4/127.0.0.1/tcp/0" diff --git a/node/util_test.go b/node/util_test.go index 095b4a7272..aa55b35990 100644 --- a/node/util_test.go +++ b/node/util_test.go @@ -46,6 +46,7 @@ func NewTestNetwork(t *testing.T, conf config.Config, l log.Log, size int) []*Te c.DataDirParent = dir c.SMESHING.Opts.DataDir = dir c.SMESHING.CoinbaseAccount = types.GenerateAddress([]byte(strconv.Itoa(i))).String() + c.FileLock = filepath.Join(c.DataDirParent, "LOCK") app := NewApp(t, &c, l) From 4b241f358c636c8e7e3afcb8f4b2dfe8e56fdfd5 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 12 Sep 2023 18:20:49 +0200 Subject: [PATCH 5/6] reduce pow threshold and change genesis --- config/presets/presets_test.go | 2 -- config/presets/testnet.go | 11 +++++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/config/presets/presets_test.go b/config/presets/presets_test.go index 74803c15e9..262569cae7 100644 --- a/config/presets/presets_test.go +++ b/config/presets/presets_test.go @@ -43,6 +43,4 @@ func TestCanGeneratePOST(t *testing.T) { } t.Run("fastnet", runTest(fastnet())) - - t.Run("testnet", runTest(testnet())) } diff --git a/config/presets/testnet.go b/config/presets/testnet.go index ed9b3b4170..5bf9d30484 100644 --- a/config/presets/testnet.go +++ b/config/presets/testnet.go @@ -22,6 +22,7 @@ import ( "github.com/spacemeshos/go-spacemesh/syncer" timeConfig "github.com/spacemeshos/go-spacemesh/timesync/config" "github.com/spacemeshos/go-spacemesh/tortoise" + "github.com/spacemeshos/post/initialization" ) func init() { @@ -29,13 +30,10 @@ func init() { } func testnet() config.Config { - var postPowDifficulty activation.PowDifficulty - if err := postPowDifficulty.UnmarshalText([]byte("000dfb23b0979b4b000000000000000000000000000000000000000000000000")); err != nil { - panic(err) - } p2pconfig := p2p.DefaultConfig() smeshing := config.DefaultSmeshingConfig() + smeshing.Opts.ProviderID.SetInt64(int64(initialization.CPUProviderID())) smeshing.ProvingOpts.Nonces = 288 smeshing.ProvingOpts.Threads = uint(runtime.NumCPU() * 3 / 4) if smeshing.ProvingOpts.Threads < 1 { @@ -67,9 +65,10 @@ func testnet() config.Config { PoETServers: []string{}, }, Genesis: &config.GenesisConfig{ - GenesisTime: "2023-09-13T08:00:00Z", + GenesisTime: "2023-09-13T18:00:00Z", ExtraData: "0000000000000000000000c76c58ebac180989673fd6d237b40e66ed5c976ec3", }, + Tortoise: tortoise.Config{ Hdist: 10, Zdist: 2, @@ -118,7 +117,7 @@ func testnet() config.Config { K1: 26, K2: 37, K3: 37, - PowDifficulty: postPowDifficulty, + PowDifficulty: activation.DefaultPostConfig().PowDifficulty, }, Bootstrap: bootstrap.Config{ URL: "https://bootstrap.spacemesh.network/testnet06", From 308905ef2893c07ae1ba9071538f6fedf7b07945 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 12 Sep 2023 19:47:57 +0200 Subject: [PATCH 6/6] linter --- config/presets/testnet.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/presets/testnet.go b/config/presets/testnet.go index 5bf9d30484..3152f10037 100644 --- a/config/presets/testnet.go +++ b/config/presets/testnet.go @@ -8,6 +8,8 @@ import ( "runtime" "time" + "github.com/spacemeshos/post/initialization" + "github.com/spacemeshos/go-spacemesh/activation" "github.com/spacemeshos/go-spacemesh/api/grpcserver" "github.com/spacemeshos/go-spacemesh/beacon" @@ -22,7 +24,6 @@ import ( "github.com/spacemeshos/go-spacemesh/syncer" timeConfig "github.com/spacemeshos/go-spacemesh/timesync/config" "github.com/spacemeshos/go-spacemesh/tortoise" - "github.com/spacemeshos/post/initialization" ) func init() {