From 1cd9353faaa7255f6c08cf3acf87f8456db0dfb8 Mon Sep 17 00:00:00 2001 From: andri lim Date: Thu, 30 Jan 2020 17:26:08 +0700 Subject: [PATCH] simplify computation --- nimbus/vm/computation.nim | 16 ---------------- nimbus/vm_state.nim | 3 --- nimbus/vm_state_transactions.nim | 4 ++-- 3 files changed, 2 insertions(+), 21 deletions(-) diff --git a/nimbus/vm/computation.nim b/nimbus/vm/computation.nim index ee7fa062f..87d4f870f 100644 --- a/nimbus/vm/computation.nim +++ b/nimbus/vm/computation.nim @@ -337,26 +337,10 @@ proc execSelfDestruct*(c: Computation, beneficiary: EthAddress) = proc addLogEntry*(c: Computation, log: Log) {.inline.} = c.logEntries.add(log) -proc getSuicides*(c: Computation): HashSet[EthAddress] = - if c.isSuccess: - result = c.suicides - proc getGasRefund*(c: Computation): GasInt = if c.isSuccess: result = c.gasMeter.gasRefunded -proc getGasUsed*(c: Computation): GasInt = - if c.shouldBurnGas: - result = c.msg.gas - else: - result = max(0, c.msg.gas - c.gasMeter.gasRemaining) - -proc getGasRemaining*(c: Computation): GasInt = - if c.shouldBurnGas: - result = 0 - else: - result = c.gasMeter.gasRemaining - proc refundSelfDestruct*(c: Computation) = let cost = gasFees[c.fork][RefundSelfDestruct] c.gasMeter.refundGas(cost * c.suicides.len) diff --git a/nimbus/vm_state.nim b/nimbus/vm_state.nim index f11258ac7..0a0cd1a4f 100644 --- a/nimbus/vm_state.nim +++ b/nimbus/vm_state.nim @@ -106,9 +106,6 @@ proc getTracingResult*(vmState: BaseVMState): JsonNode = doAssert(vmState.tracingEnabled) vmState.tracer.trace -proc addLogs*(vmState: BaseVMState, logs: seq[Log]) = - shallowCopy(vmState.logEntries, logs) - proc getAndClearLogEntries*(vmState: BaseVMState): seq[Log] = shallowCopy(result, vmState.logEntries) vmState.logEntries = @[] diff --git a/nimbus/vm_state_transactions.nim b/nimbus/vm_state_transactions.nim index 14cf84ed0..32bded340 100644 --- a/nimbus/vm_state_transactions.nim +++ b/nimbus/vm_state_transactions.nim @@ -82,8 +82,8 @@ proc execComputation*(c: Computation) = if c.isSuccess: c.refundSelfDestruct() - c.vmState.suicides = c.getSuicides() - c.vmState.addLogs(c.logEntries) + shallowCopy(c.vmState.suicides, c.suicides) + shallowCopy(c.vmState.logEntries, c.logEntries) c.vmstate.status = c.isSuccess