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
ff138022
Commit
ff138022
authored
Nov 20, 2020
by
caopingcp
Committed by
vipwzw
Dec 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
evm support tx group
parent
e7c1e4ab
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
8 deletions
+30
-8
chain33.para.toml
chain33.para.toml
+1
-0
exec.go
plugin/dapp/evm/executor/exec.go
+23
-5
util_test.go
plugin/dapp/evm/executor/tests/util_test.go
+1
-1
evm.go
plugin/dapp/evm/types/evm.go
+3
-2
types.go
plugin/dapp/evm/types/types.go
+2
-0
No files found.
chain33.para.toml
View file @
ff138022
...
...
@@ -269,6 +269,7 @@ ForkEVMABI=0
ForkEVMFrozen
=
0
ForkEVMKVHash
=
0
ForkEVMYoloV1
=
0
ForkEVMTxGroup
=
0
[fork.sub.blackwhite]
Enable
=
0
...
...
plugin/dapp/evm/executor/exec.go
View file @
ff138022
...
...
@@ -5,8 +5,8 @@
package
executor
import
(
"encoding/hex"
"fmt"
"strings"
log
"github.com/33cn/chain33/common/log/log15"
...
...
@@ -23,11 +23,12 @@ import (
func
(
evm
*
EVMExecutor
)
Exec
(
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
evm
.
CheckInit
()
// 先转换消息
msg
,
err
:=
evm
.
GetMessage
(
tx
)
msg
,
err
:=
evm
.
GetMessage
(
tx
,
index
)
if
err
!=
nil
{
return
nil
,
err
}
return
evm
.
innerExec
(
msg
,
tx
.
Hash
(),
index
,
tx
.
Fee
,
false
)
return
evm
.
innerExec
(
msg
,
tx
.
Hash
(),
index
,
evm
.
GetTxFee
(
tx
,
index
),
false
)
}
// 通用的EVM合约执行逻辑封装
...
...
@@ -166,7 +167,7 @@ func (evm *EVMExecutor) CheckInit() {
}
// GetMessage 目前的交易中,如果是coins交易,金额是放在payload的,但是合约不行,需要修改Transaction结构
func
(
evm
*
EVMExecutor
)
GetMessage
(
tx
*
types
.
Transaction
)
(
msg
*
common
.
Message
,
err
error
)
{
func
(
evm
*
EVMExecutor
)
GetMessage
(
tx
*
types
.
Transaction
,
index
int
)
(
msg
*
common
.
Message
,
err
error
)
{
var
action
evmtypes
.
EVMContractAction
err
=
types
.
Decode
(
tx
.
Payload
,
&
action
)
if
err
!=
nil
{
...
...
@@ -182,7 +183,7 @@ func (evm *EVMExecutor) GetMessage(tx *types.Transaction) (msg *common.Message,
gasLimit
:=
action
.
GasLimit
gasPrice
:=
action
.
GasPrice
if
gasLimit
==
0
{
gasLimit
=
uint64
(
tx
.
Fee
)
gasLimit
=
uint64
(
evm
.
GetTxFee
(
tx
,
index
)
)
}
if
gasPrice
==
0
{
gasPrice
=
uint32
(
1
)
...
...
@@ -224,6 +225,23 @@ func (evm *EVMExecutor) calcKVHash(addr common.Address, logs []*types.ReceiptLog
return
nil
}
// GetTxFee 获取交易手续费,支持交易组
func
(
evm
*
EVMExecutor
)
GetTxFee
(
tx
*
types
.
Transaction
,
index
int
)
int64
{
fee
:=
tx
.
Fee
cfg
:=
evm
.
GetAPI
()
.
GetConfig
()
if
fee
==
0
&&
cfg
.
IsDappFork
(
evm
.
GetHeight
(),
"evm"
,
evmtypes
.
ForkEVMTxGroup
)
{
if
tx
.
GroupCount
>=
2
{
txs
,
err
:=
evm
.
GetTxGroup
(
index
)
if
err
!=
nil
{
log
.
Error
(
"evm GetTxFee"
,
"get tx group fail"
,
err
,
"hash"
,
hex
.
EncodeToString
(
tx
.
Hash
()))
return
0
}
fee
=
txs
[
0
]
.
Fee
}
}
return
fee
}
func
getDataHashKey
(
addr
common
.
Address
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
"mavl-%v-data-hash:%v"
,
evmtypes
.
ExecutorName
,
addr
))
}
...
...
plugin/dapp/evm/executor/tests/util_test.go
View file @
ff138022
...
...
@@ -264,7 +264,7 @@ func createContract(mdb *db.GoMemDB, tx types.Transaction, maxCodeSize int) (ret
api
,
_
:=
client
.
New
(
q
.
Client
(),
nil
)
inst
.
SetAPI
(
api
)
inst
.
CheckInit
()
msg
,
_
:=
inst
.
GetMessage
(
&
tx
)
msg
,
_
:=
inst
.
GetMessage
(
&
tx
,
0
)
inst
.
SetEnv
(
10
,
0
,
uint64
(
10
))
statedb
=
inst
.
GetMStateDB
()
...
...
plugin/dapp/evm/types/evm.go
View file @
ff138022
...
...
@@ -6,9 +6,8 @@ package types
import
(
"encoding/json"
"strings"
"errors"
"strings"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/address"
...
...
@@ -45,6 +44,8 @@ func InitFork(cfg *types.Chain33Config) {
cfg
.
RegisterDappFork
(
ExecutorName
,
ForkEVMFrozen
,
1300000
)
// EEVM 黄皮v1分叉高度
cfg
.
RegisterDappFork
(
ExecutorName
,
ForkEVMYoloV1
,
9500000
)
// EVM合约支持交易组
cfg
.
RegisterDappFork
(
ExecutorName
,
ForkEVMTxGroup
,
0
)
}
//InitExecutor ...
...
...
plugin/dapp/evm/types/types.go
View file @
ff138022
...
...
@@ -42,6 +42,8 @@ const (
ForkEVMFrozen
=
"ForkEVMFrozen"
// ForkEVMYoloV1 YoloV1虚拟机指令分叉
ForkEVMYoloV1
=
"ForkEVMYoloV1"
//ForkEVMTxGroup 交易组中的交易通过GAS检查
ForkEVMTxGroup
=
"ForkEVMTxGroup"
)
var
(
...
...
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