forked from ava-labs/avalanchego
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconstants.go
262 lines (225 loc) · 7.58 KB
/
constants.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
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package version
import (
"encoding/json"
"time"
_ "embed"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/utils/constants"
)
const (
Client = "avalanchego"
// RPCChainVMProtocol should be bumped anytime changes are made which
// require the plugin vm to upgrade to latest avalanchego release to be
// compatible.
RPCChainVMProtocol uint = 35
)
// These are globals that describe network upgrades and node versions
var (
Current = &Semantic{
Major: 1,
Minor: 11,
Patch: 8,
}
CurrentApp = &Application{
Name: Client,
Major: Current.Major,
Minor: Current.Minor,
Patch: Current.Patch,
}
MinimumCompatibleVersion = &Application{
Name: Client,
Major: 1,
Minor: 11,
Patch: 0,
}
PrevMinimumCompatibleVersion = &Application{
Name: Client,
Major: 1,
Minor: 10,
Patch: 0,
}
CurrentDatabase = DatabaseVersion1_4_5
PrevDatabase = DatabaseVersion1_0_0
DatabaseVersion1_4_5 = &Semantic{
Major: 1,
Minor: 4,
Patch: 5,
}
DatabaseVersion1_0_0 = &Semantic{
Major: 1,
Minor: 0,
Patch: 0,
}
//go:embed compatibility.json
rpcChainVMProtocolCompatibilityBytes []byte
// RPCChainVMProtocolCompatibility maps RPCChainVMProtocol versions to the
// set of avalanchego versions that supported that version. This is not used
// by avalanchego, but is useful for downstream libraries.
RPCChainVMProtocolCompatibility map[uint][]*Semantic
DefaultUpgradeTime = time.Date(2020, time.December, 5, 5, 0, 0, 0, time.UTC)
ApricotPhase1Times = map[uint32]time.Time{
constants.MainnetID: time.Date(2021, time.March, 31, 14, 0, 0, 0, time.UTC),
constants.FujiID: time.Date(2021, time.March, 26, 14, 0, 0, 0, time.UTC),
}
ApricotPhase2Times = map[uint32]time.Time{
constants.MainnetID: time.Date(2021, time.May, 10, 11, 0, 0, 0, time.UTC),
constants.FujiID: time.Date(2021, time.May, 5, 14, 0, 0, 0, time.UTC),
}
ApricotPhase3Times = map[uint32]time.Time{
constants.MainnetID: time.Date(2021, time.August, 24, 14, 0, 0, 0, time.UTC),
constants.FujiID: time.Date(2021, time.August, 16, 19, 0, 0, 0, time.UTC),
}
ApricotPhase4Times = map[uint32]time.Time{
constants.MainnetID: time.Date(2021, time.September, 22, 21, 0, 0, 0, time.UTC),
constants.FujiID: time.Date(2021, time.September, 16, 21, 0, 0, 0, time.UTC),
}
ApricotPhase4MinPChainHeight = map[uint32]uint64{
constants.MainnetID: 793005,
constants.FujiID: 47437,
}
ApricotPhase5Times = map[uint32]time.Time{
constants.MainnetID: time.Date(2021, time.December, 2, 18, 0, 0, 0, time.UTC),
constants.FujiID: time.Date(2021, time.November, 24, 15, 0, 0, 0, time.UTC),
}
ApricotPhasePre6Times = map[uint32]time.Time{
constants.MainnetID: time.Date(2022, time.September, 5, 1, 30, 0, 0, time.UTC),
constants.FujiID: time.Date(2022, time.September, 6, 20, 0, 0, 0, time.UTC),
}
ApricotPhase6Times = map[uint32]time.Time{
constants.MainnetID: time.Date(2022, time.September, 6, 20, 0, 0, 0, time.UTC),
constants.FujiID: time.Date(2022, time.September, 6, 20, 0, 0, 0, time.UTC),
}
ApricotPhasePost6Times = map[uint32]time.Time{
constants.MainnetID: time.Date(2022, time.September, 7, 3, 0, 0, 0, time.UTC),
constants.FujiID: time.Date(2022, time.September, 7, 6, 0, 0, 0, time.UTC),
}
BanffTimes = map[uint32]time.Time{
constants.MainnetID: time.Date(2022, time.October, 18, 16, 0, 0, 0, time.UTC),
constants.FujiID: time.Date(2022, time.October, 3, 14, 0, 0, 0, time.UTC),
}
CortinaTimes = map[uint32]time.Time{
constants.MainnetID: time.Date(2023, time.April, 25, 15, 0, 0, 0, time.UTC),
constants.FujiID: time.Date(2023, time.April, 6, 15, 0, 0, 0, time.UTC),
}
CortinaXChainStopVertexID = map[uint32]ids.ID{
// The mainnet stop vertex is well known. It can be verified on any
// fully synced node by looking at the parentID of the genesis block.
//
// Ref: https://subnets.avax.network/x-chain/block/0
constants.MainnetID: ids.FromStringOrPanic("jrGWDh5Po9FMj54depyunNixpia5PN4aAYxfmNzU8n752Rjga"),
// The fuji stop vertex is well known. It can be verified on any fully
// synced node by looking at the parentID of the genesis block.
//
// Ref: https://subnets-test.avax.network/x-chain/block/0
constants.FujiID: ids.FromStringOrPanic("2D1cmbiG36BqQMRyHt4kFhWarmatA1ighSpND3FeFgz3vFVtCZ"),
}
DurangoTimes = map[uint32]time.Time{
constants.MainnetID: time.Date(2024, time.March, 6, 16, 0, 0, 0, time.UTC),
constants.FujiID: time.Date(2024, time.February, 13, 16, 0, 0, 0, time.UTC),
}
EUpgradeTimes = map[uint32]time.Time{
constants.MainnetID: time.Date(10000, time.December, 1, 0, 0, 0, 0, time.UTC),
constants.FujiID: time.Date(10000, time.December, 1, 0, 0, 0, 0, time.UTC),
}
)
func init() {
var parsedRPCChainVMCompatibility map[uint][]string
err := json.Unmarshal(rpcChainVMProtocolCompatibilityBytes, &parsedRPCChainVMCompatibility)
if err != nil {
panic(err)
}
RPCChainVMProtocolCompatibility = make(map[uint][]*Semantic)
for rpcChainVMProtocol, versionStrings := range parsedRPCChainVMCompatibility {
versions := make([]*Semantic, len(versionStrings))
for i, versionString := range versionStrings {
version, err := Parse(versionString)
if err != nil {
panic(err)
}
versions[i] = version
}
RPCChainVMProtocolCompatibility[rpcChainVMProtocol] = versions
}
}
func GetApricotPhase1Time(networkID uint32) time.Time {
if upgradeTime, exists := ApricotPhase1Times[networkID]; exists {
return upgradeTime
}
return DefaultUpgradeTime
}
func GetApricotPhase2Time(networkID uint32) time.Time {
if upgradeTime, exists := ApricotPhase2Times[networkID]; exists {
return upgradeTime
}
return DefaultUpgradeTime
}
func GetApricotPhase3Time(networkID uint32) time.Time {
if upgradeTime, exists := ApricotPhase3Times[networkID]; exists {
return upgradeTime
}
return DefaultUpgradeTime
}
func GetApricotPhase4Time(networkID uint32) time.Time {
if upgradeTime, exists := ApricotPhase4Times[networkID]; exists {
return upgradeTime
}
return DefaultUpgradeTime
}
func GetApricotPhase5Time(networkID uint32) time.Time {
if upgradeTime, exists := ApricotPhase5Times[networkID]; exists {
return upgradeTime
}
return DefaultUpgradeTime
}
func GetApricotPhasePre6Time(networkID uint32) time.Time {
if upgradeTime, exists := ApricotPhasePre6Times[networkID]; exists {
return upgradeTime
}
return DefaultUpgradeTime
}
func GetApricotPhase6Time(networkID uint32) time.Time {
if upgradeTime, exists := ApricotPhase6Times[networkID]; exists {
return upgradeTime
}
return DefaultUpgradeTime
}
func GetApricotPhasePost6Time(networkID uint32) time.Time {
if upgradeTime, exists := ApricotPhasePost6Times[networkID]; exists {
return upgradeTime
}
return DefaultUpgradeTime
}
func GetBanffTime(networkID uint32) time.Time {
if upgradeTime, exists := BanffTimes[networkID]; exists {
return upgradeTime
}
return DefaultUpgradeTime
}
func GetCortinaTime(networkID uint32) time.Time {
if upgradeTime, exists := CortinaTimes[networkID]; exists {
return upgradeTime
}
return DefaultUpgradeTime
}
func GetDurangoTime(networkID uint32) time.Time {
if upgradeTime, exists := DurangoTimes[networkID]; exists {
return upgradeTime
}
return DefaultUpgradeTime
}
func GetEUpgradeTime(networkID uint32) time.Time {
if upgradeTime, exists := EUpgradeTimes[networkID]; exists {
return upgradeTime
}
return DefaultUpgradeTime
}
func GetCompatibility(networkID uint32) Compatibility {
return NewCompatibility(
CurrentApp,
MinimumCompatibleVersion,
GetDurangoTime(networkID),
PrevMinimumCompatibleVersion,
)
}