simplify cash
This commit is contained in:
parent
109f841a9e
commit
d9991b1e8b
|
@ -18,7 +18,7 @@ proc processTransaction*(tx: Transaction, sender: EthAddress, vmState: BaseVMSta
|
||||||
gasUsed = tx.gasLimit
|
gasUsed = tx.gasLimit
|
||||||
var c = setupComputation(vmState, tx, sender, fork)
|
var c = setupComputation(vmState, tx, sender, fork)
|
||||||
vmState.mutateStateDB:
|
vmState.mutateStateDB:
|
||||||
db.subBalance(sender, vmState.gasCost)
|
db.subBalance(sender, tx.gasLimit.u256 * tx.gasPrice.u256)
|
||||||
execComputation(c)
|
execComputation(c)
|
||||||
if not c.shouldBurnGas:
|
if not c.shouldBurnGas:
|
||||||
gasUsed = c.refundGas(tx, sender)
|
gasUsed = c.refundGas(tx, sender)
|
||||||
|
|
|
@ -12,9 +12,7 @@ import
|
||||||
./vm/[computation, interpreter]
|
./vm/[computation, interpreter]
|
||||||
|
|
||||||
proc validateTransaction*(vmState: BaseVMState, tx: Transaction, sender: EthAddress, fork: Fork): bool =
|
proc validateTransaction*(vmState: BaseVMState, tx: Transaction, sender: EthAddress, fork: Fork): bool =
|
||||||
let
|
let account = vmState.readOnlyStateDB.getAccount(sender)
|
||||||
account = vmState.readOnlyStateDB.getAccount(sender)
|
|
||||||
gasLimit = tx.gasLimit.u256
|
|
||||||
|
|
||||||
if vmState.cumulativeGasUsed + tx.gasLimit > vmState.blockHeader.gasLimit:
|
if vmState.cumulativeGasUsed + tx.gasLimit > vmState.blockHeader.gasLimit:
|
||||||
debug "invalid tx: block header gasLimit reached",
|
debug "invalid tx: block header gasLimit reached",
|
||||||
|
@ -23,8 +21,7 @@ proc validateTransaction*(vmState: BaseVMState, tx: Transaction, sender: EthAddr
|
||||||
addition=tx.gasLimit
|
addition=tx.gasLimit
|
||||||
return
|
return
|
||||||
|
|
||||||
vmState.gasCost = gasLimit * tx.gasPrice.u256
|
let totalCost = tx.gasLimit.u256 * tx.gasPrice.u256 + tx.value
|
||||||
let totalCost = vmState.gasCost + tx.value
|
|
||||||
if totalCost > account.balance:
|
if totalCost > account.balance:
|
||||||
debug "invalid tx: not enough cash",
|
debug "invalid tx: not enough cash",
|
||||||
available=account.balance,
|
available=account.balance,
|
||||||
|
|
|
@ -35,7 +35,6 @@ type
|
||||||
txGasPrice* : GasInt
|
txGasPrice* : GasInt
|
||||||
gasCosts* : GasCosts
|
gasCosts* : GasCosts
|
||||||
fork* : Fork
|
fork* : Fork
|
||||||
gasCost* : Uint256
|
|
||||||
|
|
||||||
AccessLogs* = ref object
|
AccessLogs* = ref object
|
||||||
reads*: Table[string, string]
|
reads*: Table[string, string]
|
||||||
|
|
Loading…
Reference in New Issue