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
eb7ced13
Commit
eb7ced13
authored
Jul 31, 2020
by
harrylee
Committed by
33cn
Aug 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix a bug for test
parent
96cd55dd
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
12 deletions
+19
-12
abi_test.go
plugin/dapp/evm/executor/abi/abi_test.go
+0
-0
type_test.go
plugin/dapp/evm/executor/abi/type_test.go
+9
-9
unpack.go
plugin/dapp/evm/executor/abi/unpack.go
+1
-1
unpack_test.go
plugin/dapp/evm/executor/abi/unpack_test.go
+0
-0
instructions.go
plugin/dapp/evm/executor/vm/runtime/instructions.go
+0
-1
jump_table.go
plugin/dapp/evm/executor/vm/runtime/jump_table.go
+9
-1
No files found.
plugin/dapp/evm/executor/abi/abi_test.go
View file @
eb7ced13
This diff is collapsed.
Click to expand it.
plugin/dapp/evm/executor/abi/type_test.go
View file @
eb7ced13
...
@@ -21,10 +21,8 @@ import (
...
@@ -21,10 +21,8 @@ import (
"reflect"
"reflect"
"testing"
"testing"
"github.com/davecgh/go-spew/spew"
"github.com/holiman/uint256"
"github.com/33cn/plugin/plugin/dapp/evm/executor/vm/common"
"github.com/33cn/plugin/plugin/dapp/evm/executor/vm/common"
"github.com/davecgh/go-spew/spew"
)
)
// typeWithoutStringer is a alias for the Type type which simply doesn't implement
// typeWithoutStringer is a alias for the Type type which simply doesn't implement
...
@@ -213,10 +211,11 @@ func TestTypeCheck(t *testing.T) {
...
@@ -213,10 +211,11 @@ func TestTypeCheck(t *testing.T) {
{
"uint16[3]"
,
nil
,
[
4
]
uint16
{
1
,
2
,
3
},
"abi: cannot use [4]uint16 as type [3]uint16 as argument"
},
{
"uint16[3]"
,
nil
,
[
4
]
uint16
{
1
,
2
,
3
},
"abi: cannot use [4]uint16 as type [3]uint16 as argument"
},
{
"uint16[3]"
,
nil
,
[]
uint16
{
1
,
2
,
3
},
""
},
{
"uint16[3]"
,
nil
,
[]
uint16
{
1
,
2
,
3
},
""
},
{
"uint16[3]"
,
nil
,
[]
uint16
{
1
,
2
,
3
,
4
},
"abi: cannot use [4]uint16 as type [3]uint16 as argument"
},
{
"uint16[3]"
,
nil
,
[]
uint16
{
1
,
2
,
3
,
4
},
"abi: cannot use [4]uint16 as type [3]uint16 as argument"
},
{
"address[]"
,
nil
,
[]
common
.
Address
{
common
.
Uint256ToAddress
(
uint256
.
NewInt
()
.
SetUint64
(
1
))},
""
},
//转化为chain33中evm下Hash160Address 合约地址
{
"address[1]"
,
nil
,
[]
common
.
Address
{
common
.
Uint256ToAddress
(
uint256
.
NewInt
()
.
SetUint64
(
1
))},
""
},
{
"address[]"
,
nil
,
[]
common
.
Hash160Address
{{
1
}},
""
},
{
"address[1]"
,
nil
,
[
1
]
common
.
Address
{
common
.
Uint256ToAddress
(
uint256
.
NewInt
()
.
SetUint64
(
1
))},
""
},
{
"address[1]"
,
nil
,
[]
common
.
Hash160Address
{{
1
}},
""
},
{
"address[2]"
,
nil
,
[
1
]
common
.
Address
{
common
.
Uint256ToAddress
(
uint256
.
NewInt
()
.
SetUint64
(
1
))},
"abi: cannot use [1]array as type [2]array as argument"
},
{
"address[1]"
,
nil
,
[
1
]
common
.
Hash160Address
{{
1
}},
""
},
{
"address[2]"
,
nil
,
[
1
]
common
.
Hash160Address
{{
1
}},
"abi: cannot use [1]array as type [2]array as argument"
},
{
"bytes32"
,
nil
,
[
32
]
byte
{},
""
},
{
"bytes32"
,
nil
,
[
32
]
byte
{},
""
},
{
"bytes31"
,
nil
,
[
31
]
byte
{},
""
},
{
"bytes31"
,
nil
,
[
31
]
byte
{},
""
},
{
"bytes30"
,
nil
,
[
30
]
byte
{},
""
},
{
"bytes30"
,
nil
,
[
30
]
byte
{},
""
},
...
@@ -261,9 +260,10 @@ func TestTypeCheck(t *testing.T) {
...
@@ -261,9 +260,10 @@ func TestTypeCheck(t *testing.T) {
{
"string"
,
nil
,
[]
byte
{},
"abi: cannot use slice as type string as argument"
},
{
"string"
,
nil
,
[]
byte
{},
"abi: cannot use slice as type string as argument"
},
{
"bytes32[]"
,
nil
,
[][
32
]
byte
{{}},
""
},
{
"bytes32[]"
,
nil
,
[][
32
]
byte
{{}},
""
},
{
"function"
,
nil
,
[
24
]
byte
{},
""
},
{
"function"
,
nil
,
[
24
]
byte
{},
""
},
{
"bytes20"
,
nil
,
common
.
Address
{},
""
},
//转化为chain33中evm下Hash160Address 合约地址
{
"bytes20"
,
nil
,
common
.
Hash160Address
{},
""
},
{
"address"
,
nil
,
[
20
]
byte
{},
""
},
{
"address"
,
nil
,
[
20
]
byte
{},
""
},
{
"address"
,
nil
,
common
.
Address
{},
""
},
{
"address"
,
nil
,
common
.
Hash160
Address
{},
""
},
{
"bytes32[]]"
,
nil
,
""
,
"invalid arg type in abi"
},
{
"bytes32[]]"
,
nil
,
""
,
"invalid arg type in abi"
},
{
"invalidType"
,
nil
,
""
,
"unsupported arg type: invalidType"
},
{
"invalidType"
,
nil
,
""
,
"unsupported arg type: invalidType"
},
{
"invalidSlice[]"
,
nil
,
""
,
"unsupported arg type: invalidSlice"
},
{
"invalidSlice[]"
,
nil
,
""
,
"unsupported arg type: invalidSlice"
},
...
...
plugin/dapp/evm/executor/abi/unpack.go
View file @
eb7ced13
...
@@ -235,7 +235,7 @@ func toGoType(index int, t Type, output []byte) (interface{}, error) {
...
@@ -235,7 +235,7 @@ func toGoType(index int, t Type, output []byte) (interface{}, error) {
case
BoolTy
:
case
BoolTy
:
return
readBool
(
returnOutput
)
return
readBool
(
returnOutput
)
case
AddressTy
:
case
AddressTy
:
return
common
.
BytesToAddress
(
returnOutput
),
nil
return
common
.
BytesTo
Hash160
Address
(
returnOutput
),
nil
case
HashTy
:
case
HashTy
:
return
common
.
BytesToHash
(
returnOutput
),
nil
return
common
.
BytesToHash
(
returnOutput
),
nil
case
BytesTy
:
case
BytesTy
:
...
...
plugin/dapp/evm/executor/abi/unpack_test.go
View file @
eb7ced13
This diff is collapsed.
Click to expand it.
plugin/dapp/evm/executor/vm/runtime/instructions.go
View file @
eb7ced13
...
@@ -458,7 +458,6 @@ func opBlockhash(pc *uint64, evm *EVM, callContext *callCtx) ([]byte, error) {
...
@@ -458,7 +458,6 @@ func opBlockhash(pc *uint64, evm *EVM, callContext *callCtx) ([]byte, error) {
// 获取区块打包者地址
// 获取区块打包者地址
func
opCoinbase
(
pc
*
uint64
,
evm
*
EVM
,
callContext
*
callCtx
)
([]
byte
,
error
)
{
func
opCoinbase
(
pc
*
uint64
,
evm
*
EVM
,
callContext
*
callCtx
)
([]
byte
,
error
)
{
// 需要注意coinbase可能为空的情况,这时将返回合约的创建者作为coinbase
// 需要注意coinbase可能为空的情况,这时将返回合约的创建者作为coinbase
callContext
.
stack
.
Push
(
new
(
uint256
.
Int
)
.
SetBytes
(
evm
.
Coinbase
.
Bytes
()))
if
evm
.
Coinbase
==
nil
{
if
evm
.
Coinbase
==
nil
{
callContext
.
stack
.
Push
(
new
(
uint256
.
Int
)
.
SetBytes
(
callContext
.
contract
.
CallerAddress
.
Bytes
()))
callContext
.
stack
.
Push
(
new
(
uint256
.
Int
)
.
SetBytes
(
callContext
.
contract
.
CallerAddress
.
Bytes
()))
}
else
{
}
else
{
...
...
plugin/dapp/evm/executor/vm/runtime/jump_table.go
View file @
eb7ced13
...
@@ -96,6 +96,14 @@ func NewYoloV1InstructionSet() JumpTable {
...
@@ -96,6 +96,14 @@ func NewYoloV1InstructionSet() JumpTable {
}
}
// create2 不支持
// create2 不支持
// chainID 不支持
// chainID 不支持
//PUSH1 指令变更
instructionSet
[
PUSH1
]
=
Operation
{
Execute
:
opPush1
,
GasCost
:
gas
.
Push
,
ValidateStack
:
mm
.
MakeStackFunc
(
0
,
1
),
Valid
:
true
,
}
return
instructionSet
return
instructionSet
}
}
...
@@ -519,7 +527,7 @@ func NewFrontierInstructionSet() [256]Operation {
...
@@ -519,7 +527,7 @@ func NewFrontierInstructionSet() [256]Operation {
Valid
:
true
,
Valid
:
true
,
},
},
PUSH1
:
{
PUSH1
:
{
Execute
:
opPush1
,
Execute
:
makePush
(
1
,
1
)
,
GasCost
:
gas
.
Push
,
GasCost
:
gas
.
Push
,
ValidateStack
:
mm
.
MakeStackFunc
(
0
,
1
),
ValidateStack
:
mm
.
MakeStackFunc
(
0
,
1
),
Valid
:
true
,
Valid
:
true
,
...
...
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