Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
1c444966
Commit
1c444966
authored
Nov 20, 2018
by
Litian
Committed by
33cn
Nov 20, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix vet
parent
857935cb
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
13 additions
and
18 deletions
+13
-18
exec.go
plugin/dapp/evm/executor/exec.go
+3
-3
hooks.go
plugin/dapp/evm/executor/hooks.go
+1
-1
gen_test.go
plugin/dapp/evm/executor/tests/gen_test.go
+2
-2
interpreter.go
plugin/dapp/evm/executor/vm/runtime/interpreter.go
+1
-1
logger.go
plugin/dapp/evm/executor/vm/runtime/logger.go
+0
-1
account.go
plugin/dapp/evm/executor/vm/state/account.go
+2
-2
evm.go
plugin/dapp/evm/types/evm.go
+0
-4
types.go
plugin/dapp/evm/types/types.go
+4
-4
No files found.
plugin/dapp/evm/executor/exec.go
View file @
1c444966
...
@@ -98,9 +98,9 @@ func (evm *EVMExecutor) Exec(tx *types.Transaction, index int) (*types.Receipt,
...
@@ -98,9 +98,9 @@ func (evm *EVMExecutor) Exec(tx *types.Transaction, index int) (*types.Receipt,
// 从状态机中获取数据变更和变更日志
// 从状态机中获取数据变更和变更日志
data
,
logs
:=
evm
.
mStateDB
.
GetChangedData
(
curVer
.
GetId
())
data
,
logs
:=
evm
.
mStateDB
.
GetChangedData
(
curVer
.
GetId
())
contractReceipt
:=
&
evmtypes
.
ReceiptEVMContract
{
msg
.
From
()
.
String
(),
execName
,
contractAddr
.
String
(),
usedGas
,
ret
}
contractReceipt
:=
&
evmtypes
.
ReceiptEVMContract
{
Caller
:
msg
.
From
()
.
String
(),
ContractName
:
execName
,
ContractAddr
:
contractAddr
.
String
(),
UsedGas
:
usedGas
,
Ret
:
ret
}
logs
=
append
(
logs
,
&
types
.
ReceiptLog
{
evmtypes
.
TyLogCallContract
,
types
.
Encode
(
contractReceipt
)})
logs
=
append
(
logs
,
&
types
.
ReceiptLog
{
Ty
:
evmtypes
.
TyLogCallContract
,
Log
:
types
.
Encode
(
contractReceipt
)})
logs
=
append
(
logs
,
evm
.
mStateDB
.
GetReceiptLogs
(
contractAddr
.
String
())
...
)
logs
=
append
(
logs
,
evm
.
mStateDB
.
GetReceiptLogs
(
contractAddr
.
String
())
...
)
if
types
.
IsDappFork
(
evm
.
GetHeight
(),
"evm"
,
"ForkEVMKVHash"
)
{
if
types
.
IsDappFork
(
evm
.
GetHeight
(),
"evm"
,
"ForkEVMKVHash"
)
{
...
@@ -190,7 +190,7 @@ func (evm *EVMExecutor) calcKVHash(addr common.Address, logs []*types.ReceiptLog
...
@@ -190,7 +190,7 @@ func (evm *EVMExecutor) calcKVHash(addr common.Address, logs []*types.ReceiptLog
if
len
(
hashes
)
>
0
{
if
len
(
hashes
)
>
0
{
hash
:=
common
.
ToHash
(
hashes
)
hash
:=
common
.
ToHash
(
hashes
)
return
&
types
.
KeyValue
{
getDataHashKey
(
addr
),
hash
.
Bytes
()}
return
&
types
.
KeyValue
{
Key
:
getDataHashKey
(
addr
),
Value
:
hash
.
Bytes
()}
}
}
return
nil
return
nil
}
}
...
...
plugin/dapp/evm/executor/hooks.go
View file @
1c444966
...
@@ -27,7 +27,7 @@ func Transfer(db state.StateDB, sender, recipient common.Address, amount uint64)
...
@@ -27,7 +27,7 @@ func Transfer(db state.StateDB, sender, recipient common.Address, amount uint64)
func
GetHashFn
(
api
client
.
QueueProtocolAPI
)
func
(
blockHeight
uint64
)
common
.
Hash
{
func
GetHashFn
(
api
client
.
QueueProtocolAPI
)
func
(
blockHeight
uint64
)
common
.
Hash
{
return
func
(
blockHeight
uint64
)
common
.
Hash
{
return
func
(
blockHeight
uint64
)
common
.
Hash
{
if
api
!=
nil
{
if
api
!=
nil
{
reply
,
err
:=
api
.
GetBlockHash
(
&
types
.
ReqInt
{
int64
(
blockHeight
)})
reply
,
err
:=
api
.
GetBlockHash
(
&
types
.
ReqInt
{
Height
:
int64
(
blockHeight
)})
if
nil
!=
err
{
if
nil
!=
err
{
log
.
Error
(
"Call GetBlockHash Failed."
,
err
)
log
.
Error
(
"Call GetBlockHash Failed."
,
err
)
}
}
...
...
plugin/dapp/evm/executor/tests/gen_test.go
View file @
1c444966
...
@@ -79,11 +79,11 @@ func scanTestData(basePath string) {
...
@@ -79,11 +79,11 @@ func scanTestData(basePath string) {
// 检查两个文件是否都存在
// 检查两个文件是否都存在
if
_
,
err
:=
os
.
Stat
(
keyFile
);
os
.
IsNotExist
(
err
)
{
if
_
,
err
:=
os
.
Stat
(
keyFile
);
os
.
IsNotExist
(
err
)
{
fmt
.
Errorf
(
"test template file:%s, not exists!"
,
keyFile
)
fmt
.
Println
(
fmt
.
Errorf
(
"test template file:%s, not exists!"
,
keyFile
)
)
return
nil
return
nil
}
}
if
_
,
err
:=
os
.
Stat
(
dataFile
);
os
.
IsNotExist
(
err
)
{
if
_
,
err
:=
os
.
Stat
(
dataFile
);
os
.
IsNotExist
(
err
)
{
fmt
.
Errorf
(
"test data file:%s, not exists!"
,
dataFile
)
fmt
.
Println
(
fmt
.
Errorf
(
"test data file:%s, not exists!"
,
dataFile
)
)
return
nil
return
nil
}
}
testmap
[
keyFile
]
=
dataFile
testmap
[
keyFile
]
=
dataFile
...
...
plugin/dapp/evm/executor/vm/runtime/interpreter.go
View file @
1c444966
...
@@ -201,7 +201,7 @@ func (in *Interpreter) Run(contract *Contract, input []byte) (ret []byte, err er
...
@@ -201,7 +201,7 @@ func (in *Interpreter) Run(contract *Contract, input []byte) (ret []byte, err er
// 目前只按需构造必要的参数,理论上GasFun进行Gas计算时可以使用Contract中的所有参数
// 目前只按需构造必要的参数,理论上GasFun进行Gas计算时可以使用Contract中的所有参数
// 后继视需要修改GasParam结构
// 后继视需要修改GasParam结构
func
buildGasParam
(
contract
*
Contract
)
*
params
.
GasParam
{
func
buildGasParam
(
contract
*
Contract
)
*
params
.
GasParam
{
return
&
params
.
GasParam
{
contract
.
Gas
,
contract
.
Address
()}
return
&
params
.
GasParam
{
Gas
:
contract
.
Gas
,
Address
:
contract
.
Address
()}
}
}
// 从EVM构造参数传递给GasFunc逻辑使用
// 从EVM构造参数传递给GasFunc逻辑使用
...
...
plugin/dapp/evm/executor/vm/runtime/logger.go
View file @
1c444966
...
@@ -72,7 +72,6 @@ func (logger *JSONLogger) CaptureState(env *EVM, pc uint64, op OpCode, gas, cost
...
@@ -72,7 +72,6 @@ func (logger *JSONLogger) CaptureState(env *EVM, pc uint64, op OpCode, gas, cost
func
formatStack
(
data
[]
*
big
.
Int
)
(
res
[]
string
)
{
func
formatStack
(
data
[]
*
big
.
Int
)
(
res
[]
string
)
{
for
_
,
v
:=
range
data
{
for
_
,
v
:=
range
data
{
res
=
append
(
res
,
v
.
Text
(
16
))
res
=
append
(
res
,
v
.
Text
(
16
))
v
.
String
()
}
}
return
return
}
}
...
...
plugin/dapp/evm/executor/vm/state/account.go
View file @
1c444966
...
@@ -248,7 +248,7 @@ func (self *ContractAccount) BuildDataLog() (log *types.ReceiptLog) {
...
@@ -248,7 +248,7 @@ func (self *ContractAccount) BuildDataLog() (log *types.ReceiptLog) {
log15
.
Error
(
"marshal contract data error!"
,
"addr"
,
self
.
Addr
,
"error"
,
err
)
log15
.
Error
(
"marshal contract data error!"
,
"addr"
,
self
.
Addr
,
"error"
,
err
)
return
return
}
}
return
&
types
.
ReceiptLog
{
evmtypes
.
TyLogContractData
,
datas
}
return
&
types
.
ReceiptLog
{
Ty
:
evmtypes
.
TyLogContractData
,
Log
:
datas
}
}
}
// 构建变更日志
// 构建变更日志
...
@@ -259,7 +259,7 @@ func (self *ContractAccount) BuildStateLog() (log *types.ReceiptLog) {
...
@@ -259,7 +259,7 @@ func (self *ContractAccount) BuildStateLog() (log *types.ReceiptLog) {
return
return
}
}
return
&
types
.
ReceiptLog
{
evmtypes
.
TyLogContractState
,
datas
}
return
&
types
.
ReceiptLog
{
Ty
:
evmtypes
.
TyLogContractState
,
Log
:
datas
}
}
}
func
(
self
*
ContractAccount
)
GetDataKey
()
[]
byte
{
func
(
self
*
ContractAccount
)
GetDataKey
()
[]
byte
{
...
...
plugin/dapp/evm/types/evm.go
View file @
1c444966
...
@@ -54,7 +54,6 @@ func (evm EvmType) ActionName(tx *types.Transaction) string {
...
@@ -54,7 +54,6 @@ func (evm EvmType) ActionName(tx *types.Transaction) string {
}
else
{
}
else
{
return
"callEvmContract"
return
"callEvmContract"
}
}
return
"unknown"
}
}
func
(
evm
*
EvmType
)
GetTypeMap
()
map
[
string
]
int32
{
func
(
evm
*
EvmType
)
GetTypeMap
()
map
[
string
]
int32
{
...
@@ -79,7 +78,6 @@ func (evm EvmType) Amount(tx *types.Transaction) (int64, error) {
...
@@ -79,7 +78,6 @@ func (evm EvmType) Amount(tx *types.Transaction) (int64, error) {
func
(
evm
EvmType
)
CreateTx
(
action
string
,
message
json
.
RawMessage
)
(
*
types
.
Transaction
,
error
)
{
func
(
evm
EvmType
)
CreateTx
(
action
string
,
message
json
.
RawMessage
)
(
*
types
.
Transaction
,
error
)
{
elog
.
Debug
(
"evm.CreateTx"
,
"action"
,
action
)
elog
.
Debug
(
"evm.CreateTx"
,
"action"
,
action
)
var
tx
*
types
.
Transaction
if
action
==
"CreateCall"
{
if
action
==
"CreateCall"
{
var
param
CreateCallTx
var
param
CreateCallTx
err
:=
json
.
Unmarshal
(
message
,
&
param
)
err
:=
json
.
Unmarshal
(
message
,
&
param
)
...
@@ -91,8 +89,6 @@ func (evm EvmType) CreateTx(action string, message json.RawMessage) (*types.Tran
...
@@ -91,8 +89,6 @@ func (evm EvmType) CreateTx(action string, message json.RawMessage) (*types.Tran
}
else
{
}
else
{
return
nil
,
types
.
ErrNotSupport
return
nil
,
types
.
ErrNotSupport
}
}
return
tx
,
nil
}
}
func
(
evm
*
EvmType
)
GetLogMap
()
map
[
int64
]
*
types
.
LogInfo
{
func
(
evm
*
EvmType
)
GetLogMap
()
map
[
int64
]
*
types
.
LogInfo
{
...
...
plugin/dapp/evm/types/types.go
View file @
1c444966
...
@@ -42,9 +42,9 @@ var (
...
@@ -42,9 +42,9 @@ var (
UserPrefix
=
[]
byte
(
EvmPrefix
)
UserPrefix
=
[]
byte
(
EvmPrefix
)
logInfo
=
map
[
int64
]
*
types
.
LogInfo
{
logInfo
=
map
[
int64
]
*
types
.
LogInfo
{
TyLogCallContract
:
{
reflect
.
TypeOf
(
ReceiptEVMContract
{}),
"LogCallContract"
},
TyLogCallContract
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptEVMContract
{}),
Name
:
"LogCallContract"
},
TyLogContractData
:
{
reflect
.
TypeOf
(
EVMContractData
{}),
"LogContractData"
},
TyLogContractData
:
{
Ty
:
reflect
.
TypeOf
(
EVMContractData
{}),
Name
:
"LogContractData"
},
TyLogContractState
:
{
reflect
.
TypeOf
(
EVMContractState
{}),
"LogContractState"
},
TyLogContractState
:
{
Ty
:
reflect
.
TypeOf
(
EVMContractState
{}),
Name
:
"LogContractState"
},
TyLogEVMStateChangeItem
:
{
reflect
.
TypeOf
(
EVMStateChangeItem
{}),
"LogEVMStateChangeItem"
},
TyLogEVMStateChangeItem
:
{
Ty
:
reflect
.
TypeOf
(
EVMStateChangeItem
{}),
Name
:
"LogEVMStateChangeItem"
},
}
}
)
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment