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