-
Notifications
You must be signed in to change notification settings - Fork 39
/
revision.go
167 lines (138 loc) · 4.33 KB
/
revision.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
/*
* Copyright 2021 ICON Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package icmodule
import "github.com/icon-project/goloop/module"
const (
Revision0 = iota
Revision1
Revision2
Revision3
Revision4
Revision5
Revision6
Revision7
Revision8
Revision9
Revision10
Revision11
Revision12
Revision13
Revision14
Revision15
Revision16
Revision17
Revision18
Revision19
Revision20
Revision21
Revision22
Revision23
Revision24
Revision25
RevisionReserved
)
const (
DefaultRevision = Revision1
MaxRevision = RevisionReserved - 1
LatestRevision = MaxRevision
)
const (
RevisionIISS = Revision5
RevisionDecentralize = Revision6
RevisionFixTotalDelegated = Revision7
RevisionFixBugDisabledPRep = Revision8
RevisionIISS2 = Revision9
RevisionFixBurnEventSignature = Revision9
RevisionMultipleUnstakes = Revision9
RevisionFixEmailValidation = Revision9
RevisionDelegationSlotMaxTo100 = Revision9
RevisionSystemSCORE = Revision9
RevisionSetIRepViaNetworkProposal = Revision9
RevisionPreventDuplicatedEndpoint = Revision9
// RevisionLockAddress = Revision10
RevisionFixInvalidUnstake = Revision11
RevisionBurnV2 = Revision12
RevisionICON2R0 = Revision13
RevisionFixClaimIScore = Revision13
RevisionFixSetDelegation = Revision13
RevisionFixRLPBug = Revision13
RevisionResetPenaltyMask = Revision13
RevisionEnableBondAPIs = Revision13
RevisionFixIllegalDelegation = Revision13
RevisionStopICON1Support = Revision13
RevisionICON2R1 = Revision14
RevisionEnableIISS3 = Revision14
RevisionEnableFee3 = Revision14
RevisionBlockAccounts = Revision14
RevisionICON2R2 = Revision15
RevisionEnableJavaEE = Revision15
RevisionFixIGlobal = Revision16
RevisionICON2R3 = Revision17
RevisionEnableSetScoreOwner = Revision17
RevisionExtraMainPReps = Revision17
RevisionFixVotingReward = Revision17
RevisionFixTransferRewardFund = Revision18
RevisionJavaPurgeEnumCache = Revision19
RevisionJavaFixMapValues = Revision20
RevisionBTP2 = Revision21
RevisionBlockAccounts2 = Revision21
RevisionUpdatePRepStats = Revision22
RevisionBlockAccountAPI = Revision22
RevisionFixJCLSteps = Revision23
RevisionIISS4R0 = Revision24
RevisionChainScoreEventLog = Revision24
RevisionIISS4R1 = Revision25
)
var revisionFlags []module.Revision
var toggleFlagsOnRevision = []struct {
value int
flags module.Revision
}{
{Revision0, module.UseChainID | module.UseMPTOnEvents | module.UseCompactAPIInfo | module.LegacyFeeCharge | module.LegacyFallbackCheck | module.LegacyContentCount | module.LegacyBalanceCheck | module.LegacyNoTimeout},
{Revision2, module.AutoAcceptGovernance},
{Revision3, module.LegacyInputJSON | module.LegacyFallbackCheck | module.LegacyContentCount | module.LegacyBalanceCheck},
{Revision13, module.LegacyFeeCharge | module.LegacyNoTimeout},
{Revision14, module.LegacyInputJSON | module.InputCostingWithJSON},
{Revision18, module.FixLostFeeByDeposit},
{RevisionJavaPurgeEnumCache, module.PurgeEnumCache},
{RevisionJavaFixMapValues, module.FixMapValues},
{RevisionBTP2, module.MultipleFeePayers},
{RevisionFixJCLSteps, module.FixJCLSteps},
{RevisionChainScoreEventLog, module.ReportConfigureEvents},
{RevisionIISS4R1, module.ReportDoubleSign},
}
func init() {
flags := make([]module.Revision, MaxRevision+1)
for _, e := range toggleFlagsOnRevision {
flags[e.value] |= e.flags
}
var revSum module.Revision
for idx, rev := range flags {
revSum ^= rev
flags[idx] = revSum
}
revisionFlags = flags
}
func ValueToRevision(v int) module.Revision {
if v < Revision1 {
return revisionFlags[0]
}
if v >= len(revisionFlags) {
return module.Revision(v) + revisionFlags[len(revisionFlags)-1]
} else {
return module.Revision(v) + revisionFlags[v]
}
}