trufflesuite / ganache-cli-archive

Fast Ethereum RPC client for testing and development. See https://github.com/trufflesuite/ganache for current development.
https://www.trufflesuite.com/ganache
MIT License
3.36k stars 695 forks source link

Transaction Receipts do not include logsBloom #440

Closed elenadimitrova closed 6 years ago

elenadimitrova commented 6 years ago

The transaction receipts are missing the logsBloom property. Below are outputs from a non-specific transaction using testrpc and parity where the property is available.

Test with testrpc

truffle(development)> web3.eth.getTransactionReceipt("0x14e5bd5756ce051493736bb003e1ac9c738d276aa6b732accf90b636c6d2e5c8")
{ transactionHash: '0x14e5bd5756ce051493736bb003e1ac9c738d276aa6b732accf90b636c6d2e5c8',
  transactionIndex: 0,
  blockHash: '0xddb832236ccc486adbdae6282432b2363dd9995ded167573d950c9c9e11568ef',
  blockNumber: 57,
  gasUsed: 2401314,
  cumulativeGasUsed: 2401314,
  contractAddress: null,
  logs:
   [ { logIndex: 0,
       transactionIndex: 0,
       transactionHash: '0x14e5bd5756ce051493736bb003e1ac9c738d276aa6b732accf90b636c6d2e5c8',
       blockHash: '0xddb832236ccc486adbdae6282432b2363dd9995ded167573d950c9c9e11568ef',
       blockNumber: 57,
       address: '0x09a8c3968b660d9c9646aefe420f741a5e891e1b',
       data: '0x0',
       topics: [Array],
       type: 'mined' },
     { logIndex: 1,
       transactionIndex: 0,
       transactionHash: '0x14e5bd5756ce051493736bb003e1ac9c738d276aa6b732accf90b636c6d2e5c8',
       blockHash: '0xddb832236ccc486adbdae6282432b2363dd9995ded167573d950c9c9e11568ef',
       blockNumber: 57,
       address: '0x557227efe117a5fd3ba0f0df559694fb8cbb9e0b',
       data: '0x0',
       topics: [Array],
       type: 'mined' },
     { logIndex: 2,
       transactionIndex: 0,
       transactionHash: '0x14e5bd5756ce051493736bb003e1ac9c738d276aa6b732accf90b636c6d2e5c8',
       blockHash: '0xddb832236ccc486adbdae6282432b2363dd9995ded167573d950c9c9e11568ef',
       blockNumber: 57,
       address: '0x09a8c3968b660d9c9646aefe420f741a5e891e1b',
       data: '0x0',
       topics: [Array],
       type: 'mined' },
     { logIndex: 3,
       transactionIndex: 0,
       transactionHash: '0x14e5bd5756ce051493736bb003e1ac9c738d276aa6b732accf90b636c6d2e5c8',
       blockHash: '0xddb832236ccc486adbdae6282432b2363dd9995ded167573d950c9c9e11568ef',
       blockNumber: 57,
       address: '0x1fd3a85a88ea6b1416024017f8fc32bf2f92bab1',
       data: '0x0',
       topics: [Array],
       type: 'mined' },
     { logIndex: 4,
       transactionIndex: 0,
       transactionHash: '0x14e5bd5756ce051493736bb003e1ac9c738d276aa6b732accf90b636c6d2e5c8',
       blockHash: '0xddb832236ccc486adbdae6282432b2363dd9995ded167573d950c9c9e11568ef',
       blockNumber: 57,
       address: '0x557227efe117a5fd3ba0f0df559694fb8cbb9e0b',
       data: '0x0',
       topics: [Array],
       type: 'mined' },
     { logIndex: 5,
       transactionIndex: 0,
       transactionHash: '0x14e5bd5756ce051493736bb003e1ac9c738d276aa6b732accf90b636c6d2e5c8',
       blockHash: '0xddb832236ccc486adbdae6282432b2363dd9995ded167573d950c9c9e11568ef',
       blockNumber: 57,
       address: '0x1fd3a85a88ea6b1416024017f8fc32bf2f92bab1',
       data: '0x0',
       topics: [Array],
       type: 'mined' } ],
  status: 1 }

Test against Parity:

truffle(development)> web3.eth.getTransactionReceipt("0x0ecedc318e0650f6c9e4c209866dac3f6629b6f9b3f0e663f061531add4e3b87")
{ blockHash: '0xdf268557e3ab89c4312f1f6b2b479a0a8d2bcc8e61310b6652a20afb2d7e0de9',
  blockNumber: 3928,
  contractAddress: null,
  cumulativeGasUsed: 2401314,
  gasUsed: 2401314,
  logs:
   [ { address: '0x9d62edd98de4b87b5a533b9a25b0087128f92ac3',
       blockHash: '0xdf268557e3ab89c4312f1f6b2b479a0a8d2bcc8e61310b6652a20afb2d7e0de9',
       blockNumber: 3928,
       data: '0x',
       logIndex: 0,
       topics: [Array],
       transactionHash: '0x0ecedc318e0650f6c9e4c209866dac3f6629b6f9b3f0e663f061531add4e3b87',
       transactionIndex: 0,
       transactionLogIndex: '0x0',
       type: 'mined' },
     { address: '0xfe70de0ed1c5b77be4f1c3fd70cfd5ec3c61b810',
       blockHash: '0xdf268557e3ab89c4312f1f6b2b479a0a8d2bcc8e61310b6652a20afb2d7e0de9',
       blockNumber: 3928,
       data: '0x',
       logIndex: 1,
       topics: [Array],
       transactionHash: '0x0ecedc318e0650f6c9e4c209866dac3f6629b6f9b3f0e663f061531add4e3b87',
       transactionIndex: 0,
       transactionLogIndex: '0x1',
       type: 'mined' },
     { address: '0x9d62edd98de4b87b5a533b9a25b0087128f92ac3',
       blockHash: '0xdf268557e3ab89c4312f1f6b2b479a0a8d2bcc8e61310b6652a20afb2d7e0de9',
       blockNumber: 3928,
       data: '0x',
       logIndex: 2,
       topics: [Array],
       transactionHash: '0x0ecedc318e0650f6c9e4c209866dac3f6629b6f9b3f0e663f061531add4e3b87',
       transactionIndex: 0,
       transactionLogIndex: '0x2',
       type: 'mined' },
     { address: '0x7d3f80eaadbc9df1e2f0a5142473f8e6502d2cef',
       blockHash: '0xdf268557e3ab89c4312f1f6b2b479a0a8d2bcc8e61310b6652a20afb2d7e0de9',
       blockNumber: 3928,
       data: '0x',
       logIndex: 3,
       topics: [Array],
       transactionHash: '0x0ecedc318e0650f6c9e4c209866dac3f6629b6f9b3f0e663f061531add4e3b87',
       transactionIndex: 0,
       transactionLogIndex: '0x3',
       type: 'mined' },
     { address: '0xfe70de0ed1c5b77be4f1c3fd70cfd5ec3c61b810',
       blockHash: '0xdf268557e3ab89c4312f1f6b2b479a0a8d2bcc8e61310b6652a20afb2d7e0de9',
       blockNumber: 3928,
       data: '0x',
       logIndex: 4,
       topics: [Array],
       transactionHash: '0x0ecedc318e0650f6c9e4c209866dac3f6629b6f9b3f0e663f061531add4e3b87',
       transactionIndex: 0,
       transactionLogIndex: '0x4',
       type: 'mined' },
     { address: '0x7d3f80eaadbc9df1e2f0a5142473f8e6502d2cef',
       blockHash: '0xdf268557e3ab89c4312f1f6b2b479a0a8d2bcc8e61310b6652a20afb2d7e0de9',
       blockNumber: 3928,
       data: '0x',
       logIndex: 5,
       topics: [Array],
       transactionHash: '0x0ecedc318e0650f6c9e4c209866dac3f6629b6f9b3f0e663f061531add4e3b87',
       transactionIndex: 0,
       transactionLogIndex: '0x5',
       type: 'mined' } ],
  logsBloom: '0x08000800040000000000000000000000000000200000020000000001000000000000000040050000000020010000000000000000000000080000000000000000000001000000000000000000000000000000000000080000000000000000000000000000000000000000000000008000000000000001000000000000000800020000000000000000000000000002000000000000000000000040000000000080100000000000000000000000000000000000000000000000000000000080000000000000000000020000000020000000000000001000000000000000000000000000000800000000000000000000000000000000000000000000000000000000',
  root: '0x265e46500c11b96b190c6284b9e8aae8ff6f0d1f0516898450a569db74916c62',
  transactionHash: '0x0ecedc318e0650f6c9e4c209866dac3f6629b6f9b3f0e663f061531add4e3b87',
  transactionIndex: 0 }

The property is otherwise available on the block using testrpc.

truffle(development)> web3.eth.getBlock(57)
{ number: 57,
  hash: '0x6bfae935b6405c854aa743c7cbbc084def16feb0c7891de2a48ca49b94ad4219',
  parentHash: '0xd1eb4098b32f0340a90c03f7806f592c2c77f868b9545f9cde619a8abf3a813e',
  nonce: '0x0',
  sha3Uncles: '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347',
  logsBloom: '0x00000000001000000000000000000000000000000000020000000000000100000000000000000000000020010000000000000240000000080004000000000800000000000000000000000000000000000000000000080001000002000000000000000000000000000000000000000000000000000000002000400000000001020000000000000000000000000000000000000000000000000000000000000100000000000000002000000009000000500000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000100000000000000000400000000000000000000000000',
  transactionsRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
  stateRoot: '0x25d0fdcd5c9fafc00f7a7f474cdb223fe383feaf8b55370abf7430ddfc0f98cb',
  receiptsRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
  miner: '0x0000000000000000000000000000000000000000',
  difficulty: BigNumber { s: 1, e: 0, c: [ 0 ] },
  totalDifficulty: BigNumber { s: 1, e: 0, c: [ 0 ] },
  extraData: '0x0',
  size: 1000,
  gasLimit: 6721975,
  gasUsed: 2401314,
  timestamp: 1512294320,
  transactions:
   [ '0x322b5c0eed38e5f226881b366bef40709125eeeab3f3216b42cc8a220aa02106' ],
  uncles: [] }

According to the yellow paper, both the block and the transaction receipt define logsBloom in their properties.

benjamincburns commented 6 years ago

@elenadimitrova per the JSON RPC wiki, the logsBloom field is meant to be defined on the eth_getBlock* responses, but not on eth_getTransactionReceipt.

That said, I'm still uncertain as to how much we should treat that wiki page as a spec. Further, I need to balance the goal of adhering to the spec (weakly-defined as it is) so that people write dapps which are portable across ethereum clients, against supplying people what they need in order to test their Dapps adequately for their environments.

As a rule, we usually do our best to follow the RPC wiki page unless there's disagreement amongst major client implementations. In that case, we tend to take the intersection of functionality between Parity and geth rather than the union.

To help me make the decision:

elenadimitrova commented 6 years ago

It is breaking for ethers which expects this in the transaction receipt https://github.com/ethers-io/ethers.js/blob/511fff1390ba56ba56237053fd00ae0ec87b1e7b/providers/provider.js#L296

As for geth this also returns logsBloom in the transaction receipt:

truffle(development)> web3.eth.getTransactionReceipt('0x485bacde24723e24c6eb278000c08cb95094f0c69e205aa39cfa9353f97db869')
{ blockHash: '0x2d43d6141761537eef97e00eb4f919cd8da4d27fa580cbc6f02981d77756a468',
  blockNumber: 5317,
  contractAddress: '0xab56c45847c68007cffe7d80cabdb24043d1b08f',
  cumulativeGasUsed: 630488,
  from: '0xc46fbd443feca41354c6ebfd36cea7d89c555bea',
  gasUsed: 630488,
  logs:
   [ { address: '0xab56c45847c68007cffe7d80cabdb24043d1b08f',
       topics: [Array],
       data: '0x',
       blockNumber: 5317,
       transactionHash: '0x485bacde24723e24c6eb278000c08cb95094f0c69e205aa39cfa9353f97db869',
       transactionIndex: 0,
       blockHash: '0x2d43d6141761537eef97e00eb4f919cd8da4d27fa580cbc6f02981d77756a468',
       logIndex: 0,
       removed: false } ],
  logsBloom: '0x00000002000000000010000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000080000000000000000000004000000000000000000000000000000000000000000002000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
  root: '0x8c78a5f75f32094b64befcd08b1890c05c6d6f64a33557289ebd3548bb1b7fe3',
  to: null,
  transactionHash: '0x485bacde24723e24c6eb278000c08cb95094f0c69e205aa39cfa9353f97db869',
  transactionIndex: 0 }

This points to omission in the JSON RPC wiki but the yellow paper clearly defines it.

benjamincburns commented 6 years ago

That's good enough for me, then - we'll go ahead and add it.

benjamincburns commented 6 years ago

From comparison of both objects you submitted, it seems we also don't respond with the root field.

elenadimitrova commented 6 years ago

As per the JSON RPC this is actually correct as it states the transaction receipt returns either the root (pre Byzantium) or the status. The latter is returned in testrpc.

To enable that in parity we had to switch to 1.8.3-beta and turn the "eip658Transition": 0 parameter in config. We haven't tried in geth yet.

benjamincburns commented 6 years ago

@elenadimitrova what version of geth was that output from above? It seems strange that it also has the root field but is missing the status field. Looks like I need to fire up a light client for myself...

elenadimitrova commented 6 years ago

I'm on geth Version: 1.7.3-stable

benjamincburns commented 6 years ago

Fixed in develop branch now. Will go out with latest release. Thanks for reporting this, @elenadimitrova!

benjamincburns commented 6 years ago

@elenadimitrova I've actually just pushed out a beta release of ganache-core 3.0.0 and ganache-cli 7.0.0. This change will be in there amongst other major things like websockets support, fixing #417, and fixes for other various race condition and stability bugs, including the pesky "key not found" db error. I hope that you'll find it to be a much better experience.

naddison36 commented 6 years ago

I've installed Ganache v1.2.0-beta.0 and I am still getting this problem when using Ethers.js Should this fix be included in the v1.20 release? Thanks

benjamincburns commented 6 years ago

I caught up with @naddison36 offline, but for those reading along, this is in the v1.1.0-beta.1 release which is up now.

naddison36 commented 6 years ago

Thanks, @benjamincburns. I can confirm that the new version fixed this problem