diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 2f1ca5e0e..56048382a 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -580,14 +580,21 @@ impl BlockChainClient for Client where V: Verifier { let block_number = tx.block_number.clone(); let transaction_hash = tx.hash(); let transaction_index = tx.transaction_index; + let prior_gas_used = match tx.transaction_index { + 0 => U256::zero(), + i => { + let prior_address = TransactionAddress { block_hash: address.block_hash, index: i - 1 }; + let prior_receipt = self.chain.transaction_receipt(&prior_address).expect("Transaction receipt at `address` exists; `prior_address` has lower index in same block; qed"); + prior_receipt.gas_used + } + }; Some(LocalizedReceipt { transaction_hash: tx.hash(), transaction_index: tx.transaction_index, block_hash: tx.block_hash, block_number: tx.block_number, - // TODO: to fix this, query all previous transaction receipts and retrieve their gas usage cumulative_gas_used: receipt.gas_used, - gas_used: receipt.gas_used, + gas_used: receipt.gas_used - prior_gas_used, contract_address: match tx.action { Action::Call(_) => None, Action::Create => Some(contract_address(&tx.sender().unwrap(), &tx.nonce)) diff --git a/ethcore/src/types/receipt.rs b/ethcore/src/types/receipt.rs index cc83e2f97..f07a12212 100644 --- a/ethcore/src/types/receipt.rs +++ b/ethcore/src/types/receipt.rs @@ -91,9 +91,9 @@ pub struct LocalizedReceipt { pub block_hash: H256, /// Block number. pub block_number: BlockNumber, - /// Cumulative gas used. + /// The total gas used in the block following execution of the transaction. pub cumulative_gas_used: U256, - /// Gas used. + /// The gas used in the execution of the transaction. Note the difference of meaning to `Receipt::gas_used`. pub gas_used: U256, /// Contract address. pub contract_address: Option
, diff --git a/parity/cli.rs b/parity/cli.rs index 05f991239..89cadbc41 100644 --- a/parity/cli.rs +++ b/parity/cli.rs @@ -117,10 +117,10 @@ Sealing/Mining Options: Footprint Options: --tracing BOOL Indicates if full transaction tracing should be - enabled. Works only if client had been fully synced with - tracing enabled. BOOL may be one of auto, on, off. - auto uses last used value of this option (off if it does - not exist) [default: auto]. + enabled. Works only if client had been fully synced + with tracing enabled. BOOL may be one of auto, on, + off. auto uses last used value of this option (off + if it does not exist) [default: auto]. --pruning METHOD Configure pruning of the state/storage trie. METHOD may be one of auto, archive, fast, basic, light: archive - keep all state trie data. No pruning.