@@ -18,7 +18,11 @@ const (
18
18
maxChainAge = 100 * 365 * 24 * 60 * 60
19
19
)
20
20
21
- var _ configuration.Config = & Config {}
21
+ var (
22
+ _ configuration.Config = & Config {}
23
+ _ configuration.Config = & GnosisConfig {}
24
+ _ configuration.Config = & GnosisContractsConfig {}
25
+ )
22
26
23
27
func NewConfig () * Config {
24
28
c := & Config {}
@@ -28,7 +32,7 @@ func NewConfig() *Config {
28
32
29
33
func (c * Config ) Init () {
30
34
c .P2P = p2p .NewConfig ()
31
- c .Gnosis = configuration . NewEthnodeConfig ()
35
+ c .Gnosis = NewGnosisConfig ()
32
36
c .Shuttermint = kprconfig .NewShuttermintConfig ()
33
37
c .Metrics = metricsserver .NewConfig ()
34
38
}
@@ -40,32 +44,19 @@ type Config struct {
40
44
HTTPEnabled bool
41
45
HTTPListenAddress string
42
46
47
+ Gnosis * GnosisConfig
43
48
P2P * p2p.Config
44
- Gnosis * configuration.EthnodeConfig
45
49
Shuttermint * kprconfig.ShuttermintConfig
46
50
Metrics * metricsserver.MetricsConfig
47
-
48
- // TODO: put these in a child config
49
- GnosisContracts * GnosisContracts `shconfig:",required"`
50
- EncryptedGasLimit uint64 `shconfig:",required"`
51
- MinGasPerTransaction uint64 `shconfig:",required"`
52
- SecondsPerSlot uint64 `shconfig:",required"`
53
- GenesisSlotTimestamp uint64 `shconfig:",required"`
54
- }
55
-
56
- type GnosisContracts struct {
57
- KeyperSetManager common.Address `shconfig:",required"`
58
- KeyBroadcastContract common.Address `shconfig:",required"`
59
- Sequencer common.Address `shconfig:",required"`
60
51
}
61
52
62
53
func (c * Config ) Validate () error {
63
- if c .SecondsPerSlot > maxSecondsPerSlot {
64
- return errors .Errorf ("seconds per slot is too big (%d > %d)" , c .SecondsPerSlot , maxSecondsPerSlot )
54
+ if c .Gnosis . SecondsPerSlot > maxSecondsPerSlot {
55
+ return errors .Errorf ("seconds per slot is too big (%d > %d)" , c .Gnosis . SecondsPerSlot , maxSecondsPerSlot )
65
56
}
66
57
maxGenesisSlotTime := uint64 (math .MaxInt64 - maxChainAge )
67
- if c .GenesisSlotTimestamp > maxGenesisSlotTime {
68
- return errors .Errorf ("genesis slot timestamp is too big (%d > %d)" , c .GenesisSlotTimestamp , maxGenesisSlotTime )
58
+ if c .Gnosis . GenesisSlotTimestamp > maxGenesisSlotTime {
59
+ return errors .Errorf ("genesis slot timestamp is too big (%d > %d)" , c .Gnosis . GenesisSlotTimestamp , maxGenesisSlotTime )
69
60
}
70
61
return nil
71
62
}
@@ -77,13 +68,8 @@ func (c *Config) Name() string {
77
68
func (c * Config ) SetDefaultValues () error {
78
69
c .HTTPEnabled = false
79
70
c .HTTPListenAddress = ":3000"
80
- c .GnosisContracts = & GnosisContracts {
81
- KeyperSetManager : common.Address {},
82
- KeyBroadcastContract : common.Address {},
83
- Sequencer : common.Address {},
84
- }
85
- c .EncryptedGasLimit = 1_000_000
86
- c .MinGasPerTransaction = 21_000
71
+ c .Gnosis .EncryptedGasLimit = 1_000_000
72
+ c .Gnosis .MinGasPerTransaction = 21_000
87
73
return nil
88
74
}
89
75
@@ -103,5 +89,95 @@ func (c Config) TOMLWriteHeader(_ io.Writer) (int, error) {
103
89
}
104
90
105
91
func (c * Config ) GetAddress () common.Address {
106
- return c .Gnosis .PrivateKey .EthereumAddress ()
92
+ return c .Gnosis .Node .PrivateKey .EthereumAddress ()
93
+ }
94
+
95
+ type GnosisConfig struct {
96
+ Node * configuration.EthnodeConfig `shconfig:",required"`
97
+ Contracts * GnosisContractsConfig `shconfig:",required"`
98
+ EncryptedGasLimit uint64 `shconfig:",required"`
99
+ MinGasPerTransaction uint64 `shconfig:",required"`
100
+ SecondsPerSlot uint64 `shconfig:",required"`
101
+ GenesisSlotTimestamp uint64 `shconfig:",required"`
102
+ }
103
+
104
+ func NewGnosisConfig () * GnosisConfig {
105
+ c := & GnosisConfig {
106
+ Node : configuration .NewEthnodeConfig (),
107
+ Contracts : NewGnosisContractsConfig (),
108
+ EncryptedGasLimit : 0 ,
109
+ MinGasPerTransaction : 0 ,
110
+ SecondsPerSlot : 0 ,
111
+ GenesisSlotTimestamp : 0 ,
112
+ }
113
+ c .Init ()
114
+ return c
115
+ }
116
+
117
+ func (c * GnosisConfig ) Init () {
118
+ c .Node .Init ()
119
+ c .Contracts .Init ()
120
+ }
121
+
122
+ func (c * GnosisConfig ) Name () string {
123
+ return "gnosis"
124
+ }
125
+
126
+ func (c * GnosisConfig ) Validate () error {
127
+ if c .SecondsPerSlot == 0 {
128
+ return errors .Errorf ("seconds per slot must not be zero" )
129
+ }
130
+ return nil
131
+ }
132
+
133
+ func (c * GnosisConfig ) SetDefaultValues () error {
134
+ return nil
135
+ }
136
+
137
+ func (c * GnosisConfig ) SetExampleValues () error {
138
+ c .EncryptedGasLimit = 1_000_000
139
+ c .MinGasPerTransaction = 21_000
140
+ c .SecondsPerSlot = 5
141
+ c .GenesisSlotTimestamp = 1665410700
142
+ return nil
143
+ }
144
+
145
+ func (c * GnosisConfig ) TOMLWriteHeader (_ io.Writer ) (int , error ) {
146
+ return 0 , nil
147
+ }
148
+
149
+ type GnosisContractsConfig struct {
150
+ KeyperSetManager common.Address `shconfig:",required"`
151
+ KeyBroadcastContract common.Address `shconfig:",required"`
152
+ Sequencer common.Address `shconfig:",required"`
153
+ }
154
+
155
+ func NewGnosisContractsConfig () * GnosisContractsConfig {
156
+ return & GnosisContractsConfig {
157
+ KeyperSetManager : common.Address {},
158
+ KeyBroadcastContract : common.Address {},
159
+ Sequencer : common.Address {},
160
+ }
161
+ }
162
+
163
+ func (c * GnosisContractsConfig ) Init () {}
164
+
165
+ func (c * GnosisContractsConfig ) Name () string {
166
+ return "gnosiscontracts"
167
+ }
168
+
169
+ func (c * GnosisContractsConfig ) Validate () error {
170
+ return nil
171
+ }
172
+
173
+ func (c * GnosisContractsConfig ) SetDefaultValues () error {
174
+ return nil
175
+ }
176
+
177
+ func (c * GnosisContractsConfig ) SetExampleValues () error {
178
+ return nil
179
+ }
180
+
181
+ func (c * GnosisContractsConfig ) TOMLWriteHeader (_ io.Writer ) (int , error ) {
182
+ return 0 , nil
107
183
}
0 commit comments