Commit 614c36d2 authored by hezhengjun's avatar hezhengjun Committed by 33cn

set gaslimit to tx fee after message is created

parent 003c1b1c
...@@ -30,12 +30,12 @@ func (evm *EVMExecutor) Exec(tx *types.Transaction, index int) (*types.Receipt, ...@@ -30,12 +30,12 @@ func (evm *EVMExecutor) Exec(tx *types.Transaction, index int) (*types.Receipt,
return nil, err return nil, err
} }
return evm.innerExec(msg, tx.Hash(), index, evm.GetTxFee(tx, index), false) return evm.innerExec(msg, tx.Hash(), index, msg.GasLimit(), false)
} }
// 通用的EVM合约执行逻辑封装 // 通用的EVM合约执行逻辑封装
// readOnly 是否只读调用,仅执行evm abi查询时为true // readOnly 是否只读调用,仅执行evm abi查询时为true
func (evm *EVMExecutor) innerExec(msg *common.Message, txHash []byte, index int, txFee int64, readOnly bool) (receipt *types.Receipt, err error) { func (evm *EVMExecutor) innerExec(msg *common.Message, txHash []byte, index int, txFee uint64, readOnly bool) (receipt *types.Receipt, err error) {
// 获取当前区块的上下文信息构造EVM上下文 // 获取当前区块的上下文信息构造EVM上下文
context := evm.NewEVMContext(msg, txHash) context := evm.NewEVMContext(msg, txHash)
cfg := evm.GetAPI().GetConfig() cfg := evm.GetAPI().GetConfig()
...@@ -115,7 +115,7 @@ func (evm *EVMExecutor) innerExec(msg *common.Message, txHash []byte, index int, ...@@ -115,7 +115,7 @@ func (evm *EVMExecutor) innerExec(msg *common.Message, txHash []byte, index int,
// 计算消耗了多少费用(实际消耗的费用) // 计算消耗了多少费用(实际消耗的费用)
usedFee, overflow := common.SafeMul(usedGas, uint64(msg.GasPrice())) usedFee, overflow := common.SafeMul(usedGas, uint64(msg.GasPrice()))
// 费用消耗溢出,执行失败 // 费用消耗溢出,执行失败
if overflow || usedFee > uint64(txFee) { if overflow || usedFee > txFee {
// 如果操作没有回滚,则在这里处理 // 如果操作没有回滚,则在这里处理
if curVer != nil && snapshot >= curVer.GetID() && curVer.GetID() > -1 { if curVer != nil && snapshot >= curVer.GetID() && curVer.GetID() > -1 {
evm.mStateDB.RevertToSnapshot(snapshot) evm.mStateDB.RevertToSnapshot(snapshot)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment