-
Notifications
You must be signed in to change notification settings - Fork 671
/
constants.go
208 lines (178 loc) · 5.84 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
// Copyright (C) 2019-2023, 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"
)
// RPCChainVMProtocol should be bumped anytime changes are made which require
// the plugin vm to upgrade to latest avalanchego release to be compatible.
const RPCChainVMProtocol uint = 30
// These are globals that describe network upgrades and node versions
var (
Current = &Semantic{
Major: 1,
Minor: 10,
Patch: 15,
}
CurrentApp = &Application{
Major: Current.Major,
Minor: Current.Minor,
Patch: Current.Patch,
}
MinimumCompatibleVersion = &Application{
Major: 1,
Minor: 10,
Patch: 0,
}
PrevMinimumCompatibleVersion = &Application{
Major: 1,
Minor: 9,
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)
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),
}
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),
}
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
// TODO: update this before release
DTimes = 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
}
// 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
mainnetXChainStopVertexID, err := ids.FromString("jrGWDh5Po9FMj54depyunNixpia5PN4aAYxfmNzU8n752Rjga")
if err != nil {
panic(err)
}
// 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
fujiXChainStopVertexID, err := ids.FromString("2D1cmbiG36BqQMRyHt4kFhWarmatA1ighSpND3FeFgz3vFVtCZ")
if err != nil {
panic(err)
}
CortinaXChainStopVertexID = map[uint32]ids.ID{
constants.MainnetID: mainnetXChainStopVertexID,
constants.FujiID: fujiXChainStopVertexID,
}
}
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 GetApricotPhase6Time(networkID uint32) time.Time {
if upgradeTime, exists := ApricotPhase6Times[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 GetDTime(networkID uint32) time.Time {
if upgradeTime, exists := DTimes[networkID]; exists {
return upgradeTime
}
return DefaultUpgradeTime
}
func GetCompatibility(networkID uint32) Compatibility {
return NewCompatibility(
CurrentApp,
MinimumCompatibleVersion,
GetCortinaTime(networkID),
PrevMinimumCompatibleVersion,
)
}