-
Notifications
You must be signed in to change notification settings - Fork 212
/
config.go
74 lines (68 loc) · 3.55 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package beacon
import (
"math/big"
"time"
"github.com/spacemeshos/go-spacemesh/common/types"
)
// Config is the configuration of the beacon.
type Config struct {
Kappa int `mapstructure:"beacon-kappa"` // Security parameter (for calculating ATX threshold)
Q *big.Rat `mapstructure:"beacon-q"` // Ratio of dishonest spacetime (for calculating ATX threshold). It should be a string representing a rational number.
RoundsNumber types.RoundID `mapstructure:"beacon-rounds-number"` // Amount of rounds in every epoch
GracePeriodDuration time.Duration `mapstructure:"beacon-grace-period-duration"` // Grace period duration
ProposalDuration time.Duration `mapstructure:"beacon-proposal-duration"` // Proposal phase duration
FirstVotingRoundDuration time.Duration `mapstructure:"beacon-first-voting-round-duration"` // First voting round duration
VotingRoundDuration time.Duration `mapstructure:"beacon-voting-round-duration"` // Voting round duration
WeakCoinRoundDuration time.Duration `mapstructure:"beacon-weak-coin-round-duration"` // Weak coin round duration
Theta *big.Rat `mapstructure:"beacon-theta"` // Ratio of votes for reaching consensus
VotesLimit uint32 `mapstructure:"beacon-votes-limit"` // Maximum allowed number of votes to be sent
BeaconSyncWeightUnits int `mapstructure:"beacon-sync-weight-units"` // Numbers of layers to wait before determining beacon values from ballots when the node didn't participate in previous epoch.
}
// DefaultConfig returns the default configuration for the beacon.
func DefaultConfig() Config {
return Config{
Kappa: 40,
Q: big.NewRat(1, 3),
RoundsNumber: 300,
GracePeriodDuration: 2 * time.Minute,
ProposalDuration: 2 * time.Minute,
FirstVotingRoundDuration: 1 * time.Hour,
VotingRoundDuration: 30 * time.Minute,
WeakCoinRoundDuration: 1 * time.Minute,
Theta: big.NewRat(1, 4),
VotesLimit: 100, // TODO: around 100, find the calculation in the forum
BeaconSyncWeightUnits: 800, // at least 1 cluster of 800 weight units
}
}
// UnitTestConfig returns the unit test configuration for the beacon.
func UnitTestConfig() Config {
return Config{
Kappa: 40,
Q: big.NewRat(1, 3),
RoundsNumber: 10,
GracePeriodDuration: 20 * time.Millisecond,
ProposalDuration: 20 * time.Millisecond,
FirstVotingRoundDuration: 40 * time.Millisecond,
VotingRoundDuration: 20 * time.Millisecond,
WeakCoinRoundDuration: 20 * time.Millisecond,
Theta: big.NewRat(1, 25000),
VotesLimit: 100,
BeaconSyncWeightUnits: 2,
}
}
// NodeSimUnitTestConfig returns configuration for the beacon the unit tests with node simulation .
func NodeSimUnitTestConfig() Config {
return Config{
Kappa: 40,
Q: big.NewRat(1, 3),
RoundsNumber: 2,
GracePeriodDuration: 200 * time.Millisecond,
ProposalDuration: 500 * time.Millisecond,
FirstVotingRoundDuration: time.Second,
VotingRoundDuration: 500 * time.Millisecond,
WeakCoinRoundDuration: 200 * time.Millisecond,
Theta: big.NewRat(1, 25000),
VotesLimit: 100,
BeaconSyncWeightUnits: 10,
}
}