fix some typo
This commit is contained in:
parent
d3380f6cf0
commit
ff08a6ad95
|
@ -1,14 +1,15 @@
|
||||||
import ../db/[db_chain, state_db], eth_common, chronicles, ../vm_state, ../vm_types, ../transaction, ranges,
|
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,
|
../vm_state_transactions, sugar, ../utils, eth_trie/db, ../tracer, ./executor, json,
|
||||||
eth_bloom, strutils
|
eth_bloom, strutils
|
||||||
|
|
||||||
type
|
type
|
||||||
# these types need to eradicated
|
# TODO: these types need to be removed
|
||||||
# once eth_bloom and eth_common sync'ed
|
# once eth_bloom and eth_common sync'ed
|
||||||
Bloom = eth_common.BloomFilter
|
Bloom = eth_common.BloomFilter
|
||||||
LogsBloom = eth_bloom.BloomFilter
|
LogsBloom = eth_bloom.BloomFilter
|
||||||
|
|
||||||
|
# TODO: move these three receipt procs below somewhere else more appropriate
|
||||||
func logsBloom(logs: openArray[Log]): LogsBloom =
|
func logsBloom(logs: openArray[Log]): LogsBloom =
|
||||||
for log in logs:
|
for log in logs:
|
||||||
result.incl log.address
|
result.incl log.address
|
||||||
|
@ -21,12 +22,17 @@ func createBloom*(receipts: openArray[Receipt]): Bloom =
|
||||||
bloom.value = bloom.value or logsBloom(receipt.logs).value
|
bloom.value = bloom.value or logsBloom(receipt.logs).value
|
||||||
result = bloom.value.toByteArrayBE
|
result = bloom.value.toByteArrayBE
|
||||||
|
|
||||||
proc makeReceipt(vmState: BaseVMState, stateRoot: Hash256, cumulativeGasUsed: GasInt): Receipt =
|
proc makeReceipt(vmState: BaseVMState, stateRoot: Hash256, cumulativeGasUsed: GasInt, fork = FkFrontier): Receipt =
|
||||||
# TODO: post byzantium fork use status instead of rootHash
|
if fork < FkByzantium:
|
||||||
# currently, vmState.rootHash vs stateDb.rootHash can be different
|
# TODO: which one: vmState.blockHeader.stateRoot or stateDb.rootHash?
|
||||||
|
# currently, vmState.blockHeader.stateRoot vs stateDb.rootHash can be different
|
||||||
# need to wait #188 solved
|
# need to wait #188 solved
|
||||||
#result.stateRootOrStatus = hashOrStatus(vmState.blockHeader.stateRoot)
|
|
||||||
result.stateRootOrStatus = hashOrStatus(stateRoot)
|
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.cumulativeGasUsed = cumulativeGasUsed
|
||||||
result.logs = vmState.getAndClearLogEntries()
|
result.logs = vmState.getAndClearLogEntries()
|
||||||
result.bloom = logsBloom(result.logs).value.toByteArrayBE
|
result.bloom = logsBloom(result.logs).value.toByteArrayBE
|
||||||
|
@ -91,7 +97,9 @@ method persistBlocks*(c: Chain, headers: openarray[BlockHeader], bodies: openarr
|
||||||
if tx.getSender(sender):
|
if tx.getSender(sender):
|
||||||
let txFee = processTransaction(stateDb, tx, sender, vmState)
|
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)
|
let gasUsed = (txFee div tx.gasPrice.u256).truncate(GasInt)
|
||||||
cumulativeGasUsed += gasUsed
|
cumulativeGasUsed += gasUsed
|
||||||
|
|
||||||
|
|
|
@ -458,7 +458,6 @@ proc setupEthRpc*(node: EthereumNode, chain: BaseChainDB, rpcsrv: RpcServer) =
|
||||||
let gasUsed = receipt.cumulativeGasUsed - prevGasUsed
|
let gasUsed = receipt.cumulativeGasUsed - prevGasUsed
|
||||||
prevGasUsed = receipt.cumulativeGasUsed
|
prevGasUsed = receipt.cumulativeGasUsed
|
||||||
if idx == txDetails.index:
|
if idx == txDetails.index:
|
||||||
echo idx
|
|
||||||
return populateReceipt(receipt, gasUsed, body.transactions[txDetails.index], txDetails.index, header)
|
return populateReceipt(receipt, gasUsed, body.transactions[txDetails.index], txDetails.index, header)
|
||||||
idx.inc
|
idx.inc
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue