fix some typo

This commit is contained in:
andri lim 2018-12-11 16:01:26 +07:00 committed by zah
parent d3380f6cf0
commit ff08a6ad95
2 changed files with 17 additions and 10 deletions

View File

@ -1,14 +1,15 @@
import ../db/[db_chain, state_db], eth_common, chronicles, ../vm_state, ../vm_types, ../transaction, ranges,
../vm/[computation, interpreter_dispatch, message], ../constants, stint, nimcrypto,
../vm/[computation, interpreter_dispatch, message, interpreter/vm_forks], ../constants, stint, nimcrypto,
../vm_state_transactions, sugar, ../utils, eth_trie/db, ../tracer, ./executor, json,
eth_bloom, strutils
type
# these types need to eradicated
# TODO: these types need to be removed
# once eth_bloom and eth_common sync'ed
Bloom = eth_common.BloomFilter
LogsBloom = eth_bloom.BloomFilter
# TODO: move these three receipt procs below somewhere else more appropriate
func logsBloom(logs: openArray[Log]): LogsBloom =
for log in logs:
result.incl log.address
@ -21,12 +22,17 @@ func createBloom*(receipts: openArray[Receipt]): Bloom =
bloom.value = bloom.value or logsBloom(receipt.logs).value
result = bloom.value.toByteArrayBE
proc makeReceipt(vmState: BaseVMState, stateRoot: Hash256, cumulativeGasUsed: GasInt): Receipt =
# TODO: post byzantium fork use status instead of rootHash
# currently, vmState.rootHash vs stateDb.rootHash can be different
# need to wait #188 solved
#result.stateRootOrStatus = hashOrStatus(vmState.blockHeader.stateRoot)
result.stateRootOrStatus = hashOrStatus(stateRoot)
proc makeReceipt(vmState: BaseVMState, stateRoot: Hash256, cumulativeGasUsed: GasInt, fork = FkFrontier): Receipt =
if fork < FkByzantium:
# TODO: which one: vmState.blockHeader.stateRoot or stateDb.rootHash?
# currently, vmState.blockHeader.stateRoot vs stateDb.rootHash can be different
# need to wait #188 solved
result.stateRootOrStatus = hashOrStatus(stateRoot)
else:
# TODO: post byzantium fork use status instead of rootHash
let vmStatus = true # success or failure
result.stateRootOrStatus = hashOrStatus(vmStatus)
result.cumulativeGasUsed = cumulativeGasUsed
result.logs = vmState.getAndClearLogEntries()
result.bloom = logsBloom(result.logs).value.toByteArrayBE
@ -91,7 +97,9 @@ method persistBlocks*(c: Chain, headers: openarray[BlockHeader], bodies: openarr
if tx.getSender(sender):
let txFee = processTransaction(stateDb, tx, sender, vmState)
# perhaps this can be moved somewhere else
# perhaps this can be altered somehow
# or processTransaction return only gasUsed
# a `div` here is ugly and possibly div by zero
let gasUsed = (txFee div tx.gasPrice.u256).truncate(GasInt)
cumulativeGasUsed += gasUsed

View File

@ -458,7 +458,6 @@ proc setupEthRpc*(node: EthereumNode, chain: BaseChainDB, rpcsrv: RpcServer) =
let gasUsed = receipt.cumulativeGasUsed - prevGasUsed
prevGasUsed = receipt.cumulativeGasUsed
if idx == txDetails.index:
echo idx
return populateReceipt(receipt, gasUsed, body.transactions[txDetails.index], txDetails.index, header)
idx.inc