Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect logIndex in eth_getReceipt responses #6204

Closed
ajsutton opened this issue Nov 23, 2023 · 1 comment · Fixed by #6206
Closed

Incorrect logIndex in eth_getReceipt responses #6204

ajsutton opened this issue Nov 23, 2023 · 1 comment · Fixed by #6206

Comments

@ajsutton
Copy link
Contributor

Description

This is a variant on #4114 that was fixed a while back but using eth_getReceipt instead of eth_getLogs.

On Mainnet when you query besu with:

curl -XPOST --data '{"id":1,"jsonrpc":"2.0","method":"eth_getTransactionReceipt","params":["0x44b738650c4686cbda63061f4b5304ebc0efc56eb23b53f4a27424df454e76ed"]}'

which is getting the receipt for https://etherscan.io/tx/0x44b738650c4686cbda63061f4b5304ebc0efc56eb23b53f4a27424df454e76ed

It gives:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "blockHash": "0x22bc2e6d0767ce30d93dec83f122416e31e28af41a4ecf649819e6987c04dff8",
    "blockNumber": "0x11c4b9a",
    "contractAddress": null,
    "cumulativeGasUsed": "0x430d0",
    "from": "0x64ad3f5944ef64df67726956d5829d90ae84c67d",
    "gasUsed": "0x2783b",
    "effectiveGasPrice": "0xb7ea063ae",
    "logs": [
      {
        "address": "0xc3960227e41c3f54e9b399ce216149dea5315c34",
        "topics": [
          "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
          "0x0000000000000000000000007a5bef8c4b1d511bc076a416b097eea798247301",
          "0x000000000000000000000000a18d5eceb5fe22ee3cc228fb9c32b65adcedfa13"
        ],
        "data": "0x000000000000000000000000000000000000000000000000000611c0e8c75821",
        "blockNumber": "0x11c4b9a",
        "transactionHash": "0x44b738650c4686cbda63061f4b5304ebc0efc56eb23b53f4a27424df454e76ed",
        "transactionIndex": "0x1",
        "blockHash": "0x22bc2e6d0767ce30d93dec83f122416e31e28af41a4ecf649819e6987c04dff8",
        "logIndex": "0x0",
        "removed": false
      },
      {
        "address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
        "topics": [
          "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
          "0x000000000000000000000000a18d5eceb5fe22ee3cc228fb9c32b65adcedfa13",
          "0x000000000000000000000000166191ccb056a39585e4fc2aba1da3d76fb4f4d2"
        ],
        "data": "0x000000000000000000000000000000000000000000000000095cb3372ab4bd74",
        "blockNumber": "0x11c4b9a",
        "transactionHash": "0x44b738650c4686cbda63061f4b5304ebc0efc56eb23b53f4a27424df454e76ed",
        "transactionIndex": "0x1",
        "blockHash": "0x22bc2e6d0767ce30d93dec83f122416e31e28af41a4ecf649819e6987c04dff8",
        "logIndex": "0x1",
        "removed": false
      },
      {
        "address": "0xa18d5eceb5fe22ee3cc228fb9c32b65adcedfa13",
        "topics": [
          "0x1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1"
        ],
        "data": "0x000000000000000000000000000000000000000000000004268dcdfa2cce1e2600000000000000000000000000000000000000000000000002b4d8327e1c8c4f",
        "blockNumber": "0x11c4b9a",
        "transactionHash": "0x44b738650c4686cbda63061f4b5304ebc0efc56eb23b53f4a27424df454e76ed",
        "transactionIndex": "0x1",
        "blockHash": "0x22bc2e6d0767ce30d93dec83f122416e31e28af41a4ecf649819e6987c04dff8",
        "logIndex": "0x2",
        "removed": false
      },
      {
        "address": "0xa18d5eceb5fe22ee3cc228fb9c32b65adcedfa13",
        "topics": [
          "0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822",
          "0x000000000000000000000000166191ccb056a39585e4fc2aba1da3d76fb4f4d2",
          "0x000000000000000000000000166191ccb056a39585e4fc2aba1da3d76fb4f4d2"
        ],
        "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000611c0e8c75821000000000000000000000000000000000000000000000000095cb3372ab4bd740000000000000000000000000000000000000000000000000000000000000000",
        "blockNumber": "0x11c4b9a",
        "transactionHash": "0x44b738650c4686cbda63061f4b5304ebc0efc56eb23b53f4a27424df454e76ed",
        "transactionIndex": "0x1",
        "blockHash": "0x22bc2e6d0767ce30d93dec83f122416e31e28af41a4ecf649819e6987c04dff8",
        "logIndex": "0x3",
        "removed": false
      },
      {
        "address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
        "topics": [
          "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
          "0x000000000000000000000000166191ccb056a39585e4fc2aba1da3d76fb4f4d2",
          "0x0000000000000000000000007a5bef8c4b1d511bc076a416b097eea798247301"
        ],
        "data": "0x000000000000000000000000000000000000000000000000094048aebddc2f63",
        "blockNumber": "0x11c4b9a",
        "transactionHash": "0x44b738650c4686cbda63061f4b5304ebc0efc56eb23b53f4a27424df454e76ed",
        "transactionIndex": "0x1",
"blockHash": "0x22bc2e6d0767ce30d93dec83f122416e31e28af41a4ecf649819e6987c04dff8",
        "logIndex": "0x4",
        "removed": false
      },
      {
        "address": "0x7a5bef8c4b1d511bc076a416b097eea798247301",
        "topics": [
          "0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67",
          "0x000000000000000000000000166191ccb056a39585e4fc2aba1da3d76fb4f4d2",
          "0x000000000000000000000000a18d5eceb5fe22ee3cc228fb9c32b65adcedfa13"
        ],
        "data": "0x000000000000000000000000000000000000000000000000094048aebddc2f63fffffffffffffffffffffffffffffffffffffffffffffffffff9ee3f1738a7df00000000000000000000000000000000000000000d0122ada13d6847cf88842f00000000000000000000000000000000000000000000000093b3abc7a6eb0507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff172f",
        "blockNumber": "0x11c4b9a",
        "transactionHash": "0x44b738650c4686cbda63061f4b5304ebc0efc56eb23b53f4a27424df454e76ed",
        "transactionIndex": "0x1",
        "blockHash": "0x22bc2e6d0767ce30d93dec83f122416e31e28af41a4ecf649819e6987c04dff8",
        "logIndex": "0x5",
        "removed": false
      }
    ],
    "logsBloom": "0x00200002000000000000000080008000000000000000000000000000000000000000000000000000000000000000000002000000080020000000000000000000000000008000000800000008000000200000002000000000008000000000000000000000000000000040000020000000004002000000000000000010000800000080000000000000000000000000000000080000000001080000004100000000000000000000000000000000000000000000000000000000000000000000000000000002002000000000000000040000000000000000001000000000000000000000200000000000000000000000000000000410000000000000000001000000",
    "status": "0x1",
    "to": "0x166191ccb056a39585e4fc2aba1da3d76fb4f4d2",
    "transactionHash": "0x44b738650c4686cbda63061f4b5304ebc0efc56eb23b53f4a27424df454e76ed",
    "transactionIndex": "0x1",
    "type": "0x2"
  }
}

The key thing being that the first log has "logIndex": "0x0", whereas this is the second transaction in the block and logIndex should be relative to the block, not the transaction. Geth reports the first log entry as index 0x3:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "transactionHash": "0x44b738650c4686cbda63061f4b5304ebc0efc56eb23b53f4a27424df454e76ed",
    "blockHash": "0x22bc2e6d0767ce30d93dec83f122416e31e28af41a4ecf649819e6987c04dff8",
    "blockNumber": "0x11c4b9a",
    "logs": [
      {
        "transactionHash": "0x44b738650c4686cbda63061f4b5304ebc0efc56eb23b53f4a27424df454e76ed",
        "address": "0xc3960227e41c3f54e9b399ce216149dea5315c34",
        "blockHash": "0x22bc2e6d0767ce30d93dec83f122416e31e28af41a4ecf649819e6987c04dff8",
        "blockNumber": "0x11c4b9a",
        "data": "0x000000000000000000000000000000000000000000000000000611c0e8c75821",
        "logIndex": "0x3",
        "removed": false,
....
@Wetitpig
Copy link
Contributor

I have drafted a PR for this bug.
Any tests of this change would be highly appreciated as I have to test another branch.

Wetitpig added a commit to Wetitpig-cross-chain/besu that referenced this issue Nov 28, 2023
fab-10 pushed a commit that referenced this issue Nov 29, 2023
* [#6204] Fix log index in transaction receipt

Signed-off-by: Wetitpig <[email protected]>

* Update CHANGELOG.md

Add to bug fixes.

Signed-off-by: Wetitpig <[email protected]>

* Update tests

Signed-off-by: Wetitpig <[email protected]>

* Directly sum log size with known index

Signed-off-by: Wetitpig <[email protected]>

* Minor change to gasUsed

Signed-off-by: Wetitpig <[email protected]>

* Place hash and index first

Signed-off-by: Wetitpig <[email protected]>

* Test without parallel()

Signed-off-by: Wetitpig <[email protected]>

* Rewrite header hash as map chain

Signed-off-by: Wetitpig <[email protected]>

---------

Signed-off-by: Wetitpig <[email protected]>
jflo pushed a commit to jflo/besu that referenced this issue Dec 4, 2023
* [hyperledger#6204] Fix log index in transaction receipt

Signed-off-by: Wetitpig <[email protected]>

* Update CHANGELOG.md

Add to bug fixes.

Signed-off-by: Wetitpig <[email protected]>

* Update tests

Signed-off-by: Wetitpig <[email protected]>

* Directly sum log size with known index

Signed-off-by: Wetitpig <[email protected]>

* Minor change to gasUsed

Signed-off-by: Wetitpig <[email protected]>

* Place hash and index first

Signed-off-by: Wetitpig <[email protected]>

* Test without parallel()

Signed-off-by: Wetitpig <[email protected]>

* Rewrite header hash as map chain

Signed-off-by: Wetitpig <[email protected]>

---------

Signed-off-by: Wetitpig <[email protected]>
Signed-off-by: Justin Florentine <[email protected]>
jflo pushed a commit to jflo/besu that referenced this issue Dec 4, 2023
* [hyperledger#6204] Fix log index in transaction receipt

Signed-off-by: Wetitpig <[email protected]>

* Update CHANGELOG.md

Add to bug fixes.

Signed-off-by: Wetitpig <[email protected]>

* Update tests

Signed-off-by: Wetitpig <[email protected]>

* Directly sum log size with known index

Signed-off-by: Wetitpig <[email protected]>

* Minor change to gasUsed

Signed-off-by: Wetitpig <[email protected]>

* Place hash and index first

Signed-off-by: Wetitpig <[email protected]>

* Test without parallel()

Signed-off-by: Wetitpig <[email protected]>

* Rewrite header hash as map chain

Signed-off-by: Wetitpig <[email protected]>

---------

Signed-off-by: Wetitpig <[email protected]>
jflo pushed a commit to jflo/besu that referenced this issue Dec 4, 2023
* [hyperledger#6204] Fix log index in transaction receipt

Signed-off-by: Wetitpig <[email protected]>

* Update CHANGELOG.md

Add to bug fixes.

Signed-off-by: Wetitpig <[email protected]>

* Update tests

Signed-off-by: Wetitpig <[email protected]>

* Directly sum log size with known index

Signed-off-by: Wetitpig <[email protected]>

* Minor change to gasUsed

Signed-off-by: Wetitpig <[email protected]>

* Place hash and index first

Signed-off-by: Wetitpig <[email protected]>

* Test without parallel()

Signed-off-by: Wetitpig <[email protected]>

* Rewrite header hash as map chain

Signed-off-by: Wetitpig <[email protected]>

---------

Signed-off-by: Wetitpig <[email protected]>
Signed-off-by: Justin Florentine <[email protected]>
gfukushima pushed a commit to gfukushima/besu that referenced this issue Dec 15, 2023
* [hyperledger#6204] Fix log index in transaction receipt

Signed-off-by: Wetitpig <[email protected]>

* Update CHANGELOG.md

Add to bug fixes.

Signed-off-by: Wetitpig <[email protected]>

* Update tests

Signed-off-by: Wetitpig <[email protected]>

* Directly sum log size with known index

Signed-off-by: Wetitpig <[email protected]>

* Minor change to gasUsed

Signed-off-by: Wetitpig <[email protected]>

* Place hash and index first

Signed-off-by: Wetitpig <[email protected]>

* Test without parallel()

Signed-off-by: Wetitpig <[email protected]>

* Rewrite header hash as map chain

Signed-off-by: Wetitpig <[email protected]>

---------

Signed-off-by: Wetitpig <[email protected]>
Signed-off-by: Gabriel Fukushima <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants