-
Notifications
You must be signed in to change notification settings - Fork 2
/
milestone.go
354 lines (283 loc) · 7.77 KB
/
milestone.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
package types
import (
"strconv"
"sync"
)
// Disable followings after milestoneMercuryHeight
// 1. TransferToContractBlock
// 2. ChangeEvmDenomByProposal
// 3. BankTransferBlock
// 4. ibc
var (
MILESTONE_GENESIS_HEIGHT string
genesisHeight int64
MILESTONE_MERCURY_HEIGHT string
milestoneMercuryHeight int64
MILESTONE_VENUS_HEIGHT string
milestoneVenusHeight int64
MILESTONE_MARS_HEIGHT string
milestoneMarsHeight int64
MILESTONE_VENUS1_HEIGHT string
milestoneVenus1Height int64
MILESTONE_VENUS2_HEIGHT string
milestoneVenus2Height int64
MILESTONE_VENUS3_HEIGHT string
milestoneVenus3Height int64
MILESTONE_EARTH_HEIGHT string
milestoneEarthHeight int64
MILESTONE_VENUS4_HEIGHT string
milestoneVenus4Height int64
MILESTONE_VENUS5_HEIGHT string
milestoneVenus5Height int64
MILESTONE_Jupiter_HEIGHT string
milestoneJupiterHeight int64
MILESTONE_Comet_HEIGHT string
milestoneCometHeight int64
// note: it stores the earlies height of the node,and it is used by cli
nodePruneHeight int64
once sync.Once
)
const (
MainNet = "fbc-1230"
TestNet = "fbc-3021"
)
const (
MainNetJupiter1Height = 10762449
TestNetJupiterHeight = 10761449
MainNetCometHeight = 16911860
TestNetCometHeight = 16911860
MainNetVeneus1Height = 12988000
TestNetVeneus1Height = 12067000
MainNetVeneusHeight = 8200000
TestNetVeneusHeight = 8510000
MainNetMercuyHeight = 5150000
TestNetMercuryHeight = 5300000
MainNetGenesisHeight = 2322600
TestNetGenesisHeight = 1121818
TestNetChangeChainId = 2270901
TestNetChainName1 = "fbc-3021"
)
func init() {
once.Do(func() {
genesisHeight = string2number(MILESTONE_GENESIS_HEIGHT)
milestoneMercuryHeight = string2number(MILESTONE_MERCURY_HEIGHT)
milestoneVenusHeight = string2number(MILESTONE_VENUS_HEIGHT)
milestoneMarsHeight = string2number(MILESTONE_MARS_HEIGHT)
milestoneVenus1Height = string2number(MILESTONE_VENUS1_HEIGHT)
milestoneVenus2Height = string2number(MILESTONE_VENUS2_HEIGHT)
milestoneVenus3Height = string2number(MILESTONE_VENUS3_HEIGHT)
milestoneEarthHeight = string2number(MILESTONE_EARTH_HEIGHT)
milestoneVenus4Height = string2number(MILESTONE_VENUS4_HEIGHT)
milestoneVenus5Height = string2number(MILESTONE_VENUS5_HEIGHT)
milestoneJupiterHeight = string2number(MILESTONE_Jupiter_HEIGHT)
milestoneCometHeight = string2number(MILESTONE_Comet_HEIGHT)
})
}
func string2number(input string) int64 {
if len(input) == 0 {
input = "0"
}
res, err := strconv.ParseInt(input, 10, 64)
if err != nil {
panic(err)
}
return res
}
func SetupMainNetEnvironment(pruneH int64) {
milestoneVenusHeight = MainNetVeneusHeight
milestoneMercuryHeight = MainNetMercuyHeight
genesisHeight = MainNetGenesisHeight
nodePruneHeight = pruneH
milestoneVenus1Height = MainNetVeneus1Height
milestoneJupiterHeight = MainNetJupiter1Height
milestoneCometHeight = MainNetCometHeight
}
func SetupTestNetEnvironment(pruneH int64) {
milestoneVenusHeight = TestNetVeneusHeight
milestoneMercuryHeight = TestNetMercuryHeight
genesisHeight = TestNetGenesisHeight
nodePruneHeight = pruneH
milestoneVenus1Height = TestNetVeneus1Height
milestoneJupiterHeight = TestNetJupiterHeight
milestoneCometHeight = TestNetCometHeight
}
// depracate homstead signer support
func HigherThanMercury(height int64) bool {
if milestoneMercuryHeight == 0 {
// milestoneMercuryHeight not enabled
return false
}
return height > milestoneMercuryHeight
}
func HigherThanVenus(height int64) bool {
if milestoneVenusHeight == 0 {
return false
}
return height >= milestoneVenusHeight
}
// use MPT storage model to replace IAVL storage model
func HigherThanMars(height int64) bool {
if milestoneMarsHeight == 0 {
return false
}
return height > milestoneMarsHeight
}
// GetMilestoneVenusHeight returns milestoneVenusHeight
func GetMilestoneVenusHeight() int64 {
return milestoneVenusHeight
}
// 2322600 is mainnet GenesisHeight
func IsMainNet() bool {
return MILESTONE_GENESIS_HEIGHT == "0"
}
// 1121818 is testnet GenesisHeight
func IsTestNet() bool {
return MILESTONE_GENESIS_HEIGHT == "10742449"
}
func GetStartBlockHeight() int64 {
return genesisHeight
}
func GetNodePruneHeight() int64 {
return nodePruneHeight
}
func GetVenusHeight() int64 {
return milestoneVenusHeight
}
func GetMercuryHeight() int64 {
return milestoneMercuryHeight
}
func GetMarsHeight() int64 {
return milestoneMarsHeight
}
// can be used in unit test only
func UnittestOnlySetMilestoneVenusHeight(height int64) {
milestoneVenusHeight = height
}
// can be used in unit test only
func UnittestOnlySetMilestoneMarsHeight(height int64) {
milestoneMarsHeight = height
}
// ==================================
// =========== Venus1 ===============
func HigherThanVenus1(h int64) bool {
if milestoneVenus1Height == 0 {
return false
}
return h >= milestoneVenus1Height
}
func UnittestOnlySetMilestoneVenus1Height(h int64) {
milestoneVenus1Height = h
}
func GetVenus1Height() int64 {
return milestoneVenus1Height
}
// =========== Venus1 ===============
// ==================================
// ==================================
// =========== Venus2 ===============
func HigherThanVenus2(h int64) bool {
if milestoneVenus2Height == 0 {
return false
}
return h >= milestoneVenus2Height
}
func UnittestOnlySetMilestoneVenus2Height(h int64) {
milestoneVenus2Height = h
}
func GetVenus2Height() int64 {
return milestoneVenus2Height
}
// =========== Venus2 ===============
// ==================================
// ==================================
// =========== Venus3 ===============
func HigherThanVenus3(h int64) bool {
if milestoneVenus3Height == 0 {
return false
}
return h > milestoneVenus3Height
}
func UnittestOnlySetMilestoneVenus3Height(h int64) {
milestoneVenus3Height = h
}
func GetVenus3Height() int64 {
return milestoneVenus3Height
}
// =========== Venus3 ===============
// ==================================
// ==================================
// =========== Earth ===============
func UnittestOnlySetMilestoneEarthHeight(h int64) {
milestoneEarthHeight = h
}
func HigherThanEarth(h int64) bool {
if milestoneEarthHeight == 0 {
return false
}
return h >= milestoneEarthHeight
}
func GetEarthHeight() int64 {
return milestoneEarthHeight
}
// =========== Earth ===============
// ==================================
// ==================================
// =========== Venus3 ===============
func HigherThanVenus4(h int64) bool {
if milestoneVenus4Height == 0 {
return false
}
return h > milestoneVenus4Height
}
func UnittestOnlySetMilestoneVenus4Height(h int64) {
milestoneVenus4Height = h
}
func GetVenus4Height() int64 {
return milestoneVenus4Height
}
// =========== Venus4 ===============
// ==================================
// ==================================
// =========== Venus5 ===============
func HigherThanVenus5(h int64) bool {
if milestoneVenus5Height == 0 {
return false
}
return h > milestoneVenus5Height
}
func UnittestOnlySetMilestoneVenus5Height(h int64) {
milestoneVenus5Height = h
}
func GetVenus5Height() int64 {
return milestoneVenus5Height
}
// =========== Venus4 ===============
// ==================================
// =============== ===============
// =========== Jupiter ===============
func HigherThanJupiter(height int64) bool {
if milestoneJupiterHeight == 0 {
return false
}
return height >= milestoneJupiterHeight
}
func UnittestOnlySetMilestoneJupiterHeight(h int64) {
milestoneJupiterHeight = h
}
func GetJupiterHeight() int64 {
return milestoneJupiterHeight
}
// =============== ===============
// =========== Comet ===============
func HigherThanComet(height int64) bool {
if milestoneCometHeight == 0 {
return false
}
return height >= milestoneCometHeight
}
func UnittestOnlySetMilestoneCometHeight(h int64) {
milestoneJupiterHeight = h
}
func GetCometHeight() int64 {
return milestoneCometHeight
}