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

Inconsistent logIndex between eth_getLogs and eth_getTransactionReceipt #12254

Closed
5 of 11 tasks
ilyalukyanov opened this issue Jul 17, 2024 · 8 comments · Fixed by #12269
Closed
5 of 11 tasks

Inconsistent logIndex between eth_getLogs and eth_getTransactionReceipt #12254

ilyalukyanov opened this issue Jul 17, 2024 · 8 comments · Fixed by #12269
Assignees
Labels
area/eth-api kind/bug Kind: Bug P1 P1: Must be resolved

Comments

@ilyalukyanov
Copy link

Checklist

  • This is not a security-related bug/issue. If it is, please follow please follow the security policy.
  • I have searched on the issue tracker and the lotus forum, and there is no existing related issue or discussion.
  • I am running the Latest release, the most recent RC(release canadiate) for the upcoming release or the dev branch(master), or have an issue updating to any of these.
  • I did not make any code changes to lotus.

Lotus component

  • lotus daemon - chain sync
  • lotus fvm/fevm - Lotus FVM and FEVM interactions
  • lotus miner/worker - sealing
  • lotus miner - proving(WindowPoSt/WinningPoSt)
  • lotus JSON-RPC API
  • lotus message management (mpool)
  • Other

Lotus Version

N/A

Repro Steps

  1. For a recent transaction that emitted logs call, e.g. {"method":"eth_getTransactionReceipt","params":["0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a"],"id":1,"jsonrpc":"2.0"}
  2. For the block of that transaction call, e.g. {"jsonrpc":"2.0","method":"eth_getLogs","params":[{"fromBlock": "0x3E8872", "toBlock": "0x3E8872"}],"id":1}
  3. The same log in both responses has different values of logIndex

Describe the Bug

As per repro steps:

  • The request {"method":"eth_getTransactionReceipt","params":["0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a"],"id":1,"jsonrpc":"2.0"} returns logs with logIndex ranging from 0x0 to 0xd.
  • The request {"jsonrpc":"2.0","method":"eth_getLogs","params":[{"fromBlock": "0x3E8872", "toBlock": "0x3E8872"}],"id":1} returns logs with logIndex ranging from 0x74 to 0x81
  • The same logs should have the same logIndex regardless of which method returned them.
  • The indexing should be consistent with standard EVM behaviour, i.e.: index is relative to the block (tipset).

The issue is reproducible via these RPCs:

Logging Information

N/A
@ilyalukyanov ilyalukyanov added the kind/bug Kind: Bug label Jul 17, 2024
@jennijuju jennijuju added area/eth-api P1 P1: Must be resolved labels Jul 17, 2024
@jennijuju
Copy link
Member

@rvagg @aarshkshah1992 - axelar is hitting this issue, could you please invest if it’s one of the bugs that were fixed and need to get deployed on RPC provider nodes - or a different one?

@jennijuju jennijuju added this to FilOz Jul 17, 2024
@rvagg
Copy link
Member

rvagg commented Jul 18, 2024

Going to capture the output of these two while my splitstore still has a record of them:

eth_getTransactionReceipt
{"id":1,"jsonrpc":"2.0","result":{"transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","transactionIndex":"0x61","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872","from":"0xe81678de308c783471489e4c9caa51d1f4e7cb3d","to":"0xc4dcea20265fb62bcd4a77d31fa0351c0d19353c","root":"0x0000000000000000000000000000000000000000000000000000000000000000","status":"0x1","contractAddress":null,"cumulativeGasUsed":"0x0","gasUsed":"0x16415062","effectiveGasPrice":"0xf8e64","logsBloom":"0x000100000000000400000000000000000000000001000100040000000000000000000800800000010800020a0000000000000000000120000000000000200000000a00000000200800081008000040000000000000000000000000008000000000000000020000000080008000000810000000000008000000600010000800000000000000400000000000020000000000000001000000800400000000000020020400000000000000000000000000001000008000000000001000000000000000000002040082010000000000000000000000000000000001000000011020008010000000000000000000000000000000000000000000400000000880000000","logs":[{"address":"0x60e1773636cf5e4a227d9ac24f20feca034ee25a","data":"0x0000000000000000000000000000000000000000000000016bfd734946ec7468","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x0000000000000000000000000000000000000000000000000000000000000000","0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c"],"removed":false,"logIndex":"0x0","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"},{"address":"0x60e1773636cf5e4a227d9ac24f20feca034ee25a","data":"0x0000000000000000000000000000000000000000000000016bfd734946ec7468","topics":["0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c","0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c"],"removed":false,"logIndex":"0x1","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"},{"address":"0x60e1773636cf5e4a227d9ac24f20feca034ee25a","data":"0x0000000000000000000000000000000000000000000000016bfd734946ec7468","topics":["0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925","0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c","0x00000000000000000000000017e495e6c8c0675af62bc6ed5f259e0f3895993c"],"removed":false,"logIndex":"0x2","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"},{"address":"0x57e3bb9f790185cfe70cc2c15ed5d6b84dcf4adb","data":"0x0000000000000000000000000000000000000000000000015bea42a80d02e639","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x000000000000000000000000443a6243a36ef0ae1c46523d563c15abd787f4e9","0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c"],"removed":false,"logIndex":"0x3","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"},{"address":"0x60e1773636cf5e4a227d9ac24f20feca034ee25a","data":"0x0000000000000000000000000000000000000000000000016bfd734946ec7468","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c","0x000000000000000000000000443a6243a36ef0ae1c46523d563c15abd787f4e9"],"removed":false,"logIndex":"0x4","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"},{"address":"0x443a6243a36ef0ae1c46523d563c15abd787f4e9","data":"0xfffffffffffffffffffffffffffffffffffffffffffffffea415bd57f2fd19c70000000000000000000000000000000000000000000000016bfd734946ec7468000000000000000000000000000000000000000105744b2596af8ca9adbbf08f0000000000000000000000000000000000000000003eafef35583db9096b125b00000000000000000000000000000000000000000000000000000000000001a5","topics":["0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67","0x00000000000000000000000017e495e6c8c0675af62bc6ed5f259e0f3895993c","0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c"],"removed":false,"logIndex":"0x5","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"},{"address":"0x57e3bb9f790185cfe70cc2c15ed5d6b84dcf4adb","data":"0x0000000000000000000000000000000000000000000000015bea42a80d02e639","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c","0x0000000000000000000000000000000000000000000000000000000000000000"],"removed":false,"logIndex":"0x6","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"},{"address":"0xaaa93ac72becfbbc9149f293466bbdaa4b5ef68c","data":"0x000000000000000000000000000000000000000000000001a7931245f199aa1f","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x00000000000000000000000057e3bb9f790185cfe70cc2c15ed5d6b84dcf4adb","0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c"],"removed":false,"logIndex":"0x7","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"},{"address":"0xaaa93ac72becfbbc9149f293466bbdaa4b5ef68c","data":"0x0000000000000000000000000000000000000000000000015bea42a80d02e638","topics":["0x9d9c909296d9c674451c0c24f02cb64981eb3b727f99865939192f880a755dcb","0x00000000000000000000000057e3bb9f790185cfe70cc2c15ed5d6b84dcf4adb","0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c"],"removed":false,"logIndex":"0x8","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"},{"address":"0xaaa93ac72becfbbc9149f293466bbdaa4b5ef68c","data":"0x000000000000000000000000000000000000000000000001a78ef6889661ca1d000000000000000000000000000000000000000000000001a7912839114676a80000000000000000000000000000000000000000000000015be6e2c7a4e25e8d","topics":["0x8b2a1e1ad5e0578c3dd82494156e985dade827a87c573b5c1c7716a32162ad64","0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c"],"removed":false,"logIndex":"0x9","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"},{"address":"0xd51cb0fa9a91f156a80188a18f039140704b8df7","data":"0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c0000000000000000000000000000000000000000000000016e45f7485569e78b000000000000000000000000000000000000000000000001a78ef6889661ca1e00000000000000000000000051a2d500506a56e53c5c04a5435800ca88d60fe5","topics":["0xa4b3513a5f822f3e098a6a12338b3f07613cb130b75c90a250ab181402f4bb87"],"removed":false,"logIndex":"0xa","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"},{"address":"0x763b29b97e75fb54923325d46bab2807ac8c43c5","data":"0x0000000000000000000000000000000000000000000000016e45f7485569e78b000000000000000000000000000000000000000000000001a78ef6889661ca1e","topics":["0xf154a899b3b867021c992026539485521c86f83735a958729ab118b9ce7a6407","0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c"],"removed":false,"logIndex":"0xb","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"},{"address":"0xaaa93ac72becfbbc9149f293466bbdaa4b5ef68c","data":"0x00000000000000000000000000000000000000000000000000041bbd5b37e002","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c","0x000000000000000000000000e81678de308c783471489e4c9caa51d1f4e7cb3d"],"removed":false,"logIndex":"0xc","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"},{"address":"0xaaa93ac72becfbbc9149f293466bbdaa4b5ef68c","data":"0x00000000000000000000000000000000000000000000000000035fe0682087ab","topics":["0x9d9c909296d9c674451c0c24f02cb64981eb3b727f99865939192f880a755dcb","0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c","0x000000000000000000000000e81678de308c783471489e4c9caa51d1f4e7cb3d"],"removed":false,"logIndex":"0xd","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"}],"type":"0x2"}}
eth_getLogs
{"id":1,"jsonrpc":"2.0","result":[{"address":"0x60e1773636cf5e4a227d9ac24f20feca034ee25a","data":"0x0000000000000000000000000000000000000000000000016bfd734946ec7468","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x0000000000000000000000000000000000000000000000000000000000000000","0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c"],"removed":false,"logIndex":"0x74","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"},{"address":"0x60e1773636cf5e4a227d9ac24f20feca034ee25a","data":"0x0000000000000000000000000000000000000000000000016bfd734946ec7468","topics":["0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c","0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c"],"removed":false,"logIndex":"0x75","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"},{"address":"0x60e1773636cf5e4a227d9ac24f20feca034ee25a","data":"0x0000000000000000000000000000000000000000000000016bfd734946ec7468","topics":["0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925","0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c","0x00000000000000000000000017e495e6c8c0675af62bc6ed5f259e0f3895993c"],"removed":false,"logIndex":"0x76","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"},{"address":"0x57e3bb9f790185cfe70cc2c15ed5d6b84dcf4adb","data":"0x0000000000000000000000000000000000000000000000015bea42a80d02e639","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x000000000000000000000000443a6243a36ef0ae1c46523d563c15abd787f4e9","0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c"],"removed":false,"logIndex":"0x77","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"},{"address":"0x60e1773636cf5e4a227d9ac24f20feca034ee25a","data":"0x0000000000000000000000000000000000000000000000016bfd734946ec7468","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c","0x000000000000000000000000443a6243a36ef0ae1c46523d563c15abd787f4e9"],"removed":false,"logIndex":"0x78","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"},{"address":"0x443a6243a36ef0ae1c46523d563c15abd787f4e9","data":"0xfffffffffffffffffffffffffffffffffffffffffffffffea415bd57f2fd19c70000000000000000000000000000000000000000000000016bfd734946ec7468000000000000000000000000000000000000000105744b2596af8ca9adbbf08f0000000000000000000000000000000000000000003eafef35583db9096b125b00000000000000000000000000000000000000000000000000000000000001a5","topics":["0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67","0x00000000000000000000000017e495e6c8c0675af62bc6ed5f259e0f3895993c","0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c"],"removed":false,"logIndex":"0x79","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"},{"address":"0x57e3bb9f790185cfe70cc2c15ed5d6b84dcf4adb","data":"0x0000000000000000000000000000000000000000000000015bea42a80d02e639","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c","0x0000000000000000000000000000000000000000000000000000000000000000"],"removed":false,"logIndex":"0x7a","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"},{"address":"0xaaa93ac72becfbbc9149f293466bbdaa4b5ef68c","data":"0x000000000000000000000000000000000000000000000001a7931245f199aa1f","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x00000000000000000000000057e3bb9f790185cfe70cc2c15ed5d6b84dcf4adb","0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c"],"removed":false,"logIndex":"0x7b","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"},{"address":"0xaaa93ac72becfbbc9149f293466bbdaa4b5ef68c","data":"0x0000000000000000000000000000000000000000000000015bea42a80d02e638","topics":["0x9d9c909296d9c674451c0c24f02cb64981eb3b727f99865939192f880a755dcb","0x00000000000000000000000057e3bb9f790185cfe70cc2c15ed5d6b84dcf4adb","0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c"],"removed":false,"logIndex":"0x7c","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"},{"address":"0xaaa93ac72becfbbc9149f293466bbdaa4b5ef68c","data":"0x000000000000000000000000000000000000000000000001a78ef6889661ca1d000000000000000000000000000000000000000000000001a7912839114676a80000000000000000000000000000000000000000000000015be6e2c7a4e25e8d","topics":["0x8b2a1e1ad5e0578c3dd82494156e985dade827a87c573b5c1c7716a32162ad64","0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c"],"removed":false,"logIndex":"0x7d","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"},{"address":"0xd51cb0fa9a91f156a80188a18f039140704b8df7","data":"0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c0000000000000000000000000000000000000000000000016e45f7485569e78b000000000000000000000000000000000000000000000001a78ef6889661ca1e00000000000000000000000051a2d500506a56e53c5c04a5435800ca88d60fe5","topics":["0xa4b3513a5f822f3e098a6a12338b3f07613cb130b75c90a250ab181402f4bb87"],"removed":false,"logIndex":"0x7e","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"},{"address":"0x763b29b97e75fb54923325d46bab2807ac8c43c5","data":"0x0000000000000000000000000000000000000000000000016e45f7485569e78b000000000000000000000000000000000000000000000001a78ef6889661ca1e","topics":["0xf154a899b3b867021c992026539485521c86f83735a958729ab118b9ce7a6407","0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c"],"removed":false,"logIndex":"0x7f","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"},{"address":"0xaaa93ac72becfbbc9149f293466bbdaa4b5ef68c","data":"0x00000000000000000000000000000000000000000000000000041bbd5b37e002","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c","0x000000000000000000000000e81678de308c783471489e4c9caa51d1f4e7cb3d"],"removed":false,"logIndex":"0x80","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"},{"address":"0xaaa93ac72becfbbc9149f293466bbdaa4b5ef68c","data":"0x00000000000000000000000000000000000000000000000000035fe0682087ab","topics":["0x9d9c909296d9c674451c0c24f02cb64981eb3b727f99865939192f880a755dcb","0x000000000000000000000000c4dcea20265fb62bcd4a77d31fa0351c0d19353c","0x000000000000000000000000e81678de308c783471489e4c9caa51d1f4e7cb3d"],"removed":false,"logIndex":"0x81","transactionIndex":"0x61","transactionHash":"0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a","blockHash":"0xda1ba218adc163101801dd8894a7378abe5fdc4c62dc7056dcc96ec5f039ef64","blockNumber":"0x3e8872"}]}

@rvagg
Copy link
Member

rvagg commented Jul 18, 2024

Also a good chance to capture some timing data:

$ time curl http://localhost:1234/rpc/v1 -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"fromBlock": "0x3E8872", "toBlock": "0x3E8872"}],"id":1}'
...
real    0m3.377s

That's not great.

@rvagg
Copy link
Member

rvagg commented Jul 18, 2024

Taking the speed question to #12255 where I think we can do significantly better.

But on the specifics of this bug, the difference is in the path we take to get the logs. For eth_getTransactionReceipt we end up collecting events off the chain message receipts:

var events []types.Event
if rct := lookup.Receipt; rct.EventsRoot != nil {
events, err = ca.ChainGetEvents(ctx, *rct.EventsRoot)
if err != nil {
// Fore-recompute, we must have enabled the Event APIs after computing this
// tipset.
if _, _, err := sa.StateManager.RecomputeTipSetState(ctx, ts); err != nil {
return api.EthTxReceipt{}, xerrors.Errorf("failed get events: %w", err)
}
// Try again
events, err = ca.ChainGetEvents(ctx, *rct.EventsRoot)
if err != nil {
return api.EthTxReceipt{}, xerrors.Errorf("failed get events: %w", err)
}
}
}
if len(events) > 0 {
receipt.Logs = make([]ethtypes.EthLog, 0, len(events))
for i, evt := range events {
l := ethtypes.EthLog{
Removed: false,
LogIndex: ethtypes.EthUint64(i),
for a particular message. i.e. we look up a specific message:

lotus/node/impl/full/eth.go

Lines 410 to 420 in 2714a84

c, err := a.EthTxHashManager.TransactionHashLookup.GetCidFromHash(txHash)
if err != nil {
log.Debug("could not find transaction hash %s in lookup table", txHash.String())
}
// This isn't an eth transaction we have the mapping for, so let's look it up as a filecoin message
if c == cid.Undef {
c = txHash.ToCid()
}
msgLookup, err := a.StateAPI.StateSearchMsg(ctx, types.EmptyTSK, c, limit, true)
then get the receipt for it and load its events.

But for eth_getLogs we use the EventIdx that's calculated when the events are collected for the whole tipset:

eventCount := 0
// iterate over all executed messages in this tipset and insert them into the database if they
// don't exist, otherwise mark them as not reverted
for msgIdx, em := range ems {
for _, ev := range em.Events() {
addr, found := addressLookups[ev.Emitter]
if !found {
var ok bool
addr, ok = resolver(ctx, ev.Emitter, te.rctTs)
if !ok {
// not an address we will be able to match against
continue
}
addressLookups[ev.Emitter] = addr
}
// check if this event already exists in the database
var entryID sql.NullInt64
err = tx.Stmt(ei.stmtEventExists).QueryRow(
te.msgTs.Height(), // height
te.msgTs.Key().Bytes(), // tipset_key
tsKeyCid.Bytes(), // tipset_key_cid
addr.Bytes(), // emitter_addr
eventCount, // event_index
em.Message().Cid().Bytes(), // message_cid
msgIdx, // message_index
).Scan(&entryID)
if err != nil {
return xerrors.Errorf("error checking if event exists: %w", err)
}
if !entryID.Valid {
// event does not exist, lets insert it
res, err := tx.Stmt(ei.stmtInsertEvent).Exec(
te.msgTs.Height(), // height
te.msgTs.Key().Bytes(), // tipset_key
tsKeyCid.Bytes(), // tipset_key_cid
addr.Bytes(), // emitter_addr
eventCount, // event_index
- this behaviour was only recently fixed in #11952 to address #11630

The eth_getLogs behaviour is correct and we should be returning the same index for eth_getTransactionReceipt. The two solutions I can think of are:

  • eth_getTransactionReceipt could load the whole tipset's messages and figure out index. Downside: quite inefficient.
  • eth_getTransactionReceipt could, instead of loading the events from the blockstore, just make a query to the event index db for the specific events it wants. Downside: eth_getTransactionReceipt would require the event index feature to be turned on for it to work. But maybe that's not such a big deal because if you're using that then you likely are turning on all Eth features anyway.

@rvagg
Copy link
Member

rvagg commented Jul 19, 2024

I'm going to try out the patch, but first here's a quick dump of the problem here:

curl http://localhost:1234/rpc/v1 -X POST -H "Content-Type: application/json" --data '{"method":"eth_getTransactionReceipt","params":["0x29ef3cd631c072f2ab3650f0e20a4b678e11c711786004583aa2f071c8cfb74a"],"id":1,"jsonrpc":"2.0"}' | jq .result.logs > /tmp/transaction_receipt.logs
curl http://localhost:1234/rpc/v1 -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"fromBlock": "0x3E8872", "toBlock": "0x3E8872"}],"id":1}' | jq .result > /tmp/get_logs.logs
diff /tmp/get_logs.logs  /tmp/transaction_receipt.logs
11c11
<     "logIndex": "0x74",
---
>     "logIndex": "0x0",
25c25
<     "logIndex": "0x75",
---
>     "logIndex": "0x1",
40c40
<     "logIndex": "0x76",
---
>     "logIndex": "0x2",
55c55
<     "logIndex": "0x77",
---
>     "logIndex": "0x3",
70c70
<     "logIndex": "0x78",
---
>     "logIndex": "0x4",
85c85
<     "logIndex": "0x79",
---
>     "logIndex": "0x5",
100c100
<     "logIndex": "0x7a",
---
>     "logIndex": "0x6",
115c115
<     "logIndex": "0x7b",
---
>     "logIndex": "0x7",
130c130
<     "logIndex": "0x7c",
---
>     "logIndex": "0x8",
144c144
<     "logIndex": "0x7d",
---
>     "logIndex": "0x9",
157c157
<     "logIndex": "0x7e",
---
>     "logIndex": "0xa",
171c171
<     "logIndex": "0x7f",
---
>     "logIndex": "0xb",
186c186
<     "logIndex": "0x80",
---
>     "logIndex": "0xc",
201c201
<     "logIndex": "0x81",
---
>     "logIndex": "0xd",

@rvagg
Copy link
Member

rvagg commented Jul 19, 2024

Deploying my mainnet node with #12265 (libp2p) #12261 (events db perf improvements) and #12265 (attempted fix for this) the good news is that my db perf improvements are working well. eth_getLogs is down from 0m3.109s to 0m0.011s for this query. But we still haven't tackled the core problem and are off by a few. The above diff is now:

11c11
<     "logIndex": "0x74",
---
>     "logIndex": "0x8e",
25c25
<     "logIndex": "0x75",
---
>     "logIndex": "0x8f",
40c40
<     "logIndex": "0x76",
---
>     "logIndex": "0x90",
55c55
<     "logIndex": "0x77",
---
>     "logIndex": "0x91",
...

Something about the ordering of messages going into this I think. We either have to get to the bottom of that and match them, or just resort to using the events db for canonical indexing.

@rvagg
Copy link
Member

rvagg commented Jul 19, 2024

Oh, and eth_getTransactionReceipt is 0m0.321s here to get this. As theorised, we can get the events db to be significantly faster than loading all of the messages, receipts and events AMTs from the blockstore just to count them.

@rvagg
Copy link
Member

rvagg commented Jul 19, 2024

Interesting to note about the diff is that it's getLogs that's behind and getTransactionRecept that's ahead. I've tried reworking some of the code in #12265 to match how they're loaded for the events db (

func (m *EventFilterManager) loadExecutedMessages(ctx context.Context, msgTs, rctTs *types.TipSet) ([]executedMessage, error) {
) but got the same result.

I think we have one bug here in our events db index calculation, it should increment the event count regardless:

if !ok {
// not an address we will be able to match against
continue
}

But that's not the problem here, if I add in the check as suggested here: #12262 (comment) I don't find the msg. So we're counting up all events and using that as our start. I'm not sure why we can't find the message though yet.

@rjan90 rjan90 moved this to 🎉 Done in FilOz Jul 23, 2024
@rjan90 rjan90 moved this from 🎉 Done to ☑️Done (Archive) in FilOz Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/eth-api kind/bug Kind: Bug P1 P1: Must be resolved
Projects
Status: ☑️ Done (Archive)
4 participants