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

[Merged by Bors] - testnet with 1 day settinng and 1024 labels per unit #4987

Closed
wants to merge 7 commits into from
Closed
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
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion config/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type LoggerConfig struct {
VMLogLevel string `mapstructure:"vm"`
}

func defaultLoggingConfig() LoggerConfig {
func DefaultLoggingConfig() LoggerConfig {
return LoggerConfig{
Encoder: ConsoleLogEncoder,
AppLoggerLevel: defaultLoggingLevel.String(),
Expand Down
2 changes: 1 addition & 1 deletion config/mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions config/presets/presets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,4 @@ func TestCanGeneratePOST(t *testing.T) {
}

t.Run("fastnet", runTest(fastnet()))

t.Run("testnet", runTest(testnet()))
}
172 changes: 122 additions & 50 deletions config/presets/testnet.go
Original file line number Diff line number Diff line change
@@ -1,73 +1,145 @@
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() {
register("testnet", testnet())
}

func testnet() config.Config {
conf := config.DefaultConfig()
p2pconfig := p2p.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,
},
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 {
smeshing.ProvingOpts.Threads = 1

Check warning on line 41 in config/presets/testnet.go

View check run for this annotation

Codecov / codecov/patch

config/presets/testnet.go#L41

Added line #L41 was not covered by tests
}
home, err := os.UserHomeDir()
if err != nil {
panic("can't read homedir: " + err.Error())

Check warning on line 45 in config/presets/testnet.go

View check run for this annotation

Codecov / codecov/patch

config/presets/testnet.go#L45

Added line #L45 was not covered by tests
}
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.LayerAvgSize = 50
conf.LayerDuration = 120 * time.Second
conf.LayersPerEpoch = 60

conf.Tortoise.Hdist = 60
conf.Tortoise.Zdist = 10
conf.Tortoise.BadBeaconVoteDelayLayers = 30
LayerDuration: 5 * time.Minute,
LayerAvgSize: 50,
LayersPerEpoch: 288,

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
TxsPerProposal: 700, // https://github.com/spacemeshos/go-spacemesh/issues/4559
BlockGasLimit: 100107000, // 3000 of spends

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
OptFilterThreshold: 90,

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
TickSize: 666514,
PoETServers: []string{},
},
Genesis: &config.GenesisConfig{
GenesisTime: "2023-09-13T18:00:00Z",
ExtraData: "0000000000000000000000c76c58ebac180989673fd6d237b40e66ed5c976ec3",
},

return conf
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: 5 * time.Second,
MaxRequestRetries: 10,
},
POST: activation.PostConfig{
MinNumUnits: 2,
MaxNumUnits: math.MaxUint32,
LabelsPerUnit: 1024,
K1: 26,
K2: 37,
K3: 37,
PowDifficulty: activation.DefaultPostConfig().PowDifficulty,
},
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(),
}
}
1 change: 1 addition & 0 deletions node/adminservice_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 1 addition & 0 deletions node/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading