Unverified Commit 3e8e0836 authored by yann300's avatar yann300 Committed by GitHub

fix gasUsed in the receipt (#1542)

Make sure the receipt `gasUsed` is the actual amount of gas used, not the `gasLimit`.
parent e42389bc
...@@ -144,8 +144,9 @@ export class Web3VmProvider { ...@@ -144,8 +144,9 @@ export class Web3VmProvider {
if (lastOp) { if (lastOp) {
lastOp.error = lastOp.op !== 'RETURN' && lastOp.op !== 'STOP' && lastOp.op !== 'DESTRUCT' lastOp.error = lastOp.op !== 'RETURN' && lastOp.op !== 'STOP' && lastOp.op !== 'DESTRUCT'
} }
this.vmTraces[this.processingHash].gas = '0x' + data.gasUsed.toString(16) const gasUsed = '0x' + data.gasUsed.toString(16)
this.vmTraces[this.processingHash].gas = gasUsed
this.txsReceipt[this.processingHash].gasUsed = gasUsed
const logs = [] const logs = []
for (const l in data.execResult.logs) { for (const l in data.execResult.logs) {
const log = data.execResult.logs[l] const log = data.execResult.logs[l]
......
...@@ -102,8 +102,8 @@ export class Transactions { ...@@ -102,8 +102,8 @@ export class Transactions {
transactionIndex: '0x00', transactionIndex: '0x00',
blockHash: '0x' + txBlock.hash().toString('hex'), blockHash: '0x' + txBlock.hash().toString('hex'),
blockNumber: '0x' + txBlock.header.number.toString('hex'), blockNumber: '0x' + txBlock.header.number.toString('hex'),
gasUsed: Web3.utils.toHex(receipt.gas), gasUsed: receipt.gasUsed,
cumulativeGasUsed: Web3.utils.toHex(receipt.gas), cumulativeGasUsed: receipt.gasUsed, // only 1 tx per block
contractAddress: receipt.contractAddress, contractAddress: receipt.contractAddress,
logs: receipt.logs, logs: receipt.logs,
status: receipt.status, status: receipt.status,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment