-
Notifications
You must be signed in to change notification settings - Fork 0
/
sta
243 lines (243 loc) · 11.8 KB
/
sta
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
warning: LF will be replaced by CRLF in consensus/genaro/extra_managerment.go.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in core/state/state_object.go.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in core/vm/instructions.go.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in core/vm/jump_table.go.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in core/vm/opcodes.go.
The file will have its original line endings in your working directory.
[1mdiff --git a/consensus/genaro/extra_managerment.go b/consensus/genaro/extra_managerment.go[m
[1mindex 7ef6edc..0514a64 100644[m
[1m--- a/consensus/genaro/extra_managerment.go[m
[1m+++ b/consensus/genaro/extra_managerment.go[m
[36m@@ -10,7 +10,7 @@[m [mimport ([m
// TODO re-design the struct to speed up[m
type ExtraData struct {[m
CommitteeRank []common.Address `json:"committeeRank"` // rank of committee[m
[31m- sentinelHeft uint64 `json:"sentinelHeft"` //sentinelHeft[m
[32m+[m [32mSentinelHeft uint64 `json:"sentinelHeft"` //sentinelHeft[m
Signature []byte `json:"signature"` // the signature of block broadcaster[m
}[m
[m
[36m@@ -31,7 +31,7 @@[m [mfunc ResetHeaderSignature(header *types.Header) {[m
[m
func SetHeaderSentinelHeft(header *types.Header, sentinelHeft uint64) {[m
extraData := UnmarshalToExtra(header)[m
[31m- extraData.sentinelHeft = sentinelHeft[m
[32m+[m [32mextraData.SentinelHeft = sentinelHeft[m
extraByte, _ := json.Marshal(extraData)[m
header.Extra = make([]byte, len(extraByte))[m
copy(header.Extra, extraByte)[m
[36m@@ -39,7 +39,7 @@[m [mfunc SetHeaderSentinelHeft(header *types.Header, sentinelHeft uint64) {[m
[m
func GetHeaderSentinelHeft(header *types.Header) uint64{[m
extraData := UnmarshalToExtra(header)[m
[31m- return extraData.sentinelHeft[m
[32m+[m [32mreturn extraData.SentinelHeft[m
}[m
[m
func SetHeaderSignature(header *types.Header, signature []byte) {[m
[1mdiff --git a/core/vm/instructions.go b/core/vm/instructions.go[m
[1mindex e999aa8..2e027e7 100644[m
[1m--- a/core/vm/instructions.go[m
[1m+++ b/core/vm/instructions.go[m
[36m@@ -484,15 +484,34 @@[m [mfunc opCodeCopy(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack[m
}[m
[m
//todo 实现自定义指令对应函数功能[m
[31m-func opSenc(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {[m
[31m- return nil, nil[m
[31m-}[m
[31m-[m
func opDataVerisonRead(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {[m
[32m+[m [32m//address,fileName,dataVersion := stack.pop(),stack.pop(),stack.pop()[m
[32m+[m [32maddress, offset1, size1,offset2,size2 := stack.pop(),stack.pop(),stack.pop(),stack.pop(),stack.pop()[m
[32m+[m [32mfileName := string(memory.Get(offset1.Int64(),size1.Int64()))[m
[32m+[m [32mdataVersion := string(memory.Get(offset2.Int64(),size2.Int64()))[m
[32m+[m[32m txLog,err := evm.StateDB.TxLogByDataVersionRead(common.BigToAddress(address),fileName,dataVersion)[m
[32m+[m [32mif err == nil {[m
[32m+[m [32mconvertPara :=evm.interpreter.intPool.get()[m
[32m+[m [32mconvertPara.SetString(txLog,62)[m
[32m+[m [32mstack.push(convertPara)[m
[32m+[m [32m}else{[m
[32m+[m [32mstack.push(evm.interpreter.intPool.getZero())[m
[32m+[m [32m}[m
return nil, nil[m
}[m
[m
func opDataVerisonUpdate(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {[m
[32m+[m [32m//address,fileName,switchValue := stack.pop(),stack.pop(),stack.pop()[m
[32m+[m [32maddress, offset, size ,switchValue := stack.pop(),stack.pop(),stack.pop(),stack.pop()[m
[32m+[m [32mfileName := string(memory.Get(offset.Int64(),size.Int64()))[m
[32m+[m [32mvar switchV bool[m
[32m+[m [32m//switchVlaue (int => bool)[m
[32m+[m [32mif switchValue.Cmp(new(big.Int).SetUint64(0)) == 0 {[m
[32m+[m [32mswitchV = true[m
[32m+[m [32m}else {[m
[32m+[m [32mswitchV = false[m
[32m+[m [32m}[m
[32m+[m [32mevm.StateDB.TxLogBydataVersionUpdate(common.BigToAddress(address),fileName,switchV)[m
return nil, nil[m
}[m
[m
[36m@@ -517,8 +536,10 @@[m [mfunc opGasprice(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack[m
[m
//todo 实现自定义指令对应函数功能[m
func opStorageGasprice(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {[m
[31m- address,fileName := stack.pop(),stack.pop()[m
[31m- storageGasPrice,err := evm.StateDB.GetStorageGasPrice(common.BigToAddress(address),string(fileName.Bytes()))[m
[32m+[m [32m//address, buckerId := stack.pop(),stack.pop()[m
[32m+[m [32maddress, offset, size := stack.pop(),stack.pop(),stack.pop()[m
[32m+[m [32mbucketId := string(memory.Get(offset.Int64(),size.Int64()))[m
[32m+[m [32mstorageGasPrice,err := evm.StateDB.GetStorageGasPrice(common.BigToAddress(address),bucketId)[m
if err == nil {[m
stack.push(evm.interpreter.intPool.get().SetUint64(storageGasPrice))[m
}else{[m
[36m@@ -566,8 +587,10 @@[m [mfunc opGasLimit(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack[m
}[m
[m
func opStorageGasUsed(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {[m
[31m- address,fileName := stack.pop(),stack.pop()[m
[31m- storageGasUsed,err := evm.StateDB.GetStorageGasUsed(common.BigToAddress(address),string(fileName.Bytes()))[m
[32m+[m [32m//address, bucketId := stack.pop(),stack.pop()[m
[32m+[m [32maddress, offset, size := stack.pop(),stack.pop(),stack.pop()[m
[32m+[m [32mbucketId := string(memory.Get(offset.Int64(),size.Int64()))[m
[32m+[m [32mstorageGasUsed,err := evm.StateDB.GetStorageGasUsed(common.BigToAddress(address),bucketId)[m
if err == nil {[m
stack.push(evm.interpreter.intPool.get().SetUint64(storageGasUsed))[m
}else{[m
[36m@@ -678,8 +701,10 @@[m [mfunc opMsize(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *St[m
[m
//todo 实现自定义指令对应函数功能[m
func opSsize(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {[m
[31m- address,fileName := stack.pop(),stack.pop()[m
[31m- sSize,err := evm.StateDB.GetStorageSize(common.BigToAddress(address),string(fileName.Bytes()))[m
[32m+[m [32m//address, bucketId := stack.pop(),stack.pop()[m
[32m+[m [32maddress, offset, size := stack.pop(),stack.pop(),stack.pop()[m
[32m+[m [32mbucketId := string(memory.Get(offset.Int64(),size.Int64()))[m
[32m+[m [32msSize,err := evm.StateDB.GetStorageSize(common.BigToAddress(address),bucketId)[m
if err == nil {[m
stack.push(evm.interpreter.intPool.get().SetUint64(sSize))[m
}else{[m
[36m@@ -696,8 +721,10 @@[m [mfunc opGas(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stac[m
// todo 实现自定义指令对应函数功能[m
// 获取交易的StorageGas,获取后压入栈中[m
func opStorageGas(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {[m
[31m- address,fileName := stack.pop(),stack.pop()[m
[31m- storageGas,err := evm.StateDB.GetStorageGas(common.BigToAddress(address),string(fileName.Bytes()))[m
[32m+[m [32m//address, bucketId := stack.pop(),stack.pop()[m
[32m+[m [32maddress, offset, size := stack.pop(),stack.pop(),stack.pop()[m
[32m+[m [32mbucketId := string(memory.Get(offset.Int64(),size.Int64()))[m
[32m+[m [32mstorageGas,err := evm.StateDB.GetStorageGas(common.BigToAddress(address),bucketId)[m
if err == nil {[m
stack.push(evm.interpreter.intPool.get().SetUint64(storageGas))[m
}else{[m
[1mdiff --git a/core/vm/jump_table.go b/core/vm/jump_table.go[m
[1mindex f568d69..c889c92 100644[m
[1m--- a/core/vm/jump_table.go[m
[1m+++ b/core/vm/jump_table.go[m
[36m@@ -348,24 +348,17 @@[m [mfunc NewFrontierInstructionSet() [256]operation {[m
memorySize: memoryCodeCopy,[m
valid: true,[m
},[m
[31m- SENC: {[m
[31m- execute: opSenc,[m
[31m- gasCost: constGasFunc(GasQuickStep),[m
[31m- validateStack: makeStackFunc(4, 0),[m
[31m- memorySize: memoryCodeCopy,[m
[31m- valid: true,[m
[31m- },[m
DATA_VERSION_READ: {[m
execute: opDataVerisonRead,[m
gasCost: constGasFunc(GasQuickStep),[m
[31m- validateStack: makeStackFunc(1, 0),[m
[32m+[m [32mvalidateStack: makeStackFunc(5, 1),[m
memorySize: memoryCodeCopy,[m
valid: true,[m
},[m
DATA_VERSION_UPDATE: {[m
execute: opDataVerisonUpdate,[m
gasCost: constGasFunc(GasQuickStep),[m
[31m- validateStack: makeStackFunc(1, 0),[m
[32m+[m [32mvalidateStack: makeStackFunc(5, 0),[m
memorySize: memoryCodeCopy,[m
valid: true,[m
},[m
[36m@@ -378,7 +371,7 @@[m [mfunc NewFrontierInstructionSet() [256]operation {[m
STORAGE_GAS_PRICE: {[m
execute: opStorageGasprice,[m
gasCost: constGasFunc(GasQuickStep),[m
[31m- validateStack: makeStackFunc(0, 1),[m
[32m+[m [32mvalidateStack: makeStackFunc(3, 1),[m
valid: true,[m
},[m
EXTCODESIZE: {[m
[36m@@ -433,13 +426,13 @@[m [mfunc NewFrontierInstructionSet() [256]operation {[m
STORAGE_GAS_USED: {[m
execute: opStorageGasUsed,[m
gasCost: constGasFunc(GasQuickStep),[m
[31m- validateStack: makeStackFunc(0, 1),[m
[32m+[m [32mvalidateStack: makeStackFunc(3, 1),[m
valid: true,[m
},[m
SENTINEL_HEFT: {[m
execute: opSentinelHeft,[m
gasCost: constGasFunc(GasQuickStep),[m
[31m- validateStack: makeStackFunc(0, 1),[m
[32m+[m [32mvalidateStack: makeStackFunc(1, 1),[m
valid: true,[m
},[m
POP: {[m
[36m@@ -512,7 +505,7 @@[m [mfunc NewFrontierInstructionSet() [256]operation {[m
SSIZE: {[m
execute: opSsize,[m
gasCost: constGasFunc(GasQuickStep),[m
[31m- validateStack: makeStackFunc(0, 1),[m
[32m+[m [32mvalidateStack: makeStackFunc(3, 1),[m
valid: true,[m
},[m
GAS: {[m
[36m@@ -524,7 +517,7 @@[m [mfunc NewFrontierInstructionSet() [256]operation {[m
STORAGE_GAS: {[m
execute: opStorageGas,[m
gasCost: constGasFunc(GasQuickStep),[m
[31m- validateStack: makeStackFunc(0, 1),[m
[32m+[m [32mvalidateStack: makeStackFunc(3, 1),[m
valid: true,[m
},[m
JUMPDEST: {[m
[1mdiff --git a/core/vm/opcodes.go b/core/vm/opcodes.go[m
[1mindex faddf52..47bbaa8 100644[m
[1m--- a/core/vm/opcodes.go[m
[1m+++ b/core/vm/opcodes.go[m
[36m@@ -72,8 +72,8 @@[m [mconst ([m
[m
const ([m
// 0x21 range - user-defined opcode[m
[31m- SENC OpCode = 0x21 + iota[m
[31m- DATA_VERSION_READ[m
[32m+[m [32m//SENC OpCode = 0x21 + iota[m
[32m+[m [32mDATA_VERSION_READ OpCode = 0x21 + iota[m
DATA_VERSION_UPDATE[m
)[m
[m
[36m@@ -268,7 +268,7 @@[m [mvar opCodeToString = map[OpCode]string{[m
// 0x20 range - crypto[m
SHA3: "SHA3",[m
// user-defined opcode[m
[31m- SENC: "SENC",[m
[32m+[m [32m//SENC: "SENC",[m
DATA_VERSION_READ: "DATA_VERSION_READ",[m
DATA_VERSION_UPDATE: "DATA_VERSION_UPDATE",[m
[m
[36m@@ -562,7 +562,7 @@[m [mvar stringToOp = map[string]OpCode{[m
"SENTINEL_HEFT": SENTINEL_HEFT,[m
"STORAGE_GAS_USED": STORAGE_GAS_USED,[m
"STORAGE_GAS_PRICE": STORAGE_GAS_PRICE,[m
[31m- "SENC": SENC,[m
[32m+[m [32m//"SENC": SENC,[m
"DATA_VERSION_READ": DATA_VERSION_READ,[m
"DATA_VERSION_UPDATE": DATA_VERSION_UPDATE,[m
"STORAGE_GAS": STORAGE_GAS,[m