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

TransactionIndex changes based on the RPC request #521

Open
cll-gg opened this issue Oct 17, 2023 · 6 comments
Open

TransactionIndex changes based on the RPC request #521

cll-gg opened this issue Oct 17, 2023 · 6 comments

Comments

@cll-gg
Copy link

cll-gg commented Oct 17, 2023

Describe the bug
When doing a eth_getLogs request in one way, the returned transactionIndex field gets a different value than when doing the eth_getLogs request in a different way. Everything else (block hash, transaction hash, log index, etc.) stays the same.

Unfortunately, it doesn't seem to happen for each log or transaction.

To Reproduce
Steps to reproduce the behavior:

  1. Run this to get the logs for transaction 0x6780bd14d08bf0064a7ba90a327f1dd356637a7a6b50fa463745adee56629edc in block 0x0003b336000008bd319e42ed2b7fd2d7f74a90cf5e3ac169c54546abbce57aa6 (number 69422930):
curl -s '<fantom-mainnet-node>' -X POST -H 'Content-Type: application/json' --data '{ "jsonrpc":"2.0", "method":"eth_getLogs", "params":[{"blockHash":"0x0003b336000008bd319e42ed2b7fd2d7f74a90cf5e3ac169c54546abbce57aa6"}], "id":1 }' | jq '.result | .[] | select(.transactionHash == "0x6780bd14d08bf0064a7ba90a327f1dd356637a7a6b50fa463745adee56629edc") | .transactionIndex'
  1. This returns:
"0x2"
"0x2"
"0x2"
  1. Run this to get the logs for certain topics in block 69422930, which are the logs in transaction 0x6780bd14d08bf0064a7ba90a327f1dd356637a7a6b50fa463745adee56629edc:
curl -s '<fantom-mainnet-node>' -X POST -H 'Content-Type: application/json' --data '{ "jsonrpc":"2.0", "method":"eth_getLogs", "params":[{"fromBlock":"0x4234f52", "toBlock": "0x4234f52", "topics": [["0x0559884fd3a460db3073b7fc896cc77986f16e378210ded43186175bf646fc5f", "0x0109fc6f55cf40689f02fbaad7af7fe7bbac8a3d2186600afc7d3e10cac60271", "0xf6a97944f31ea060dfde0566e4167c1a1082551e64b60ecb14d599a9d023d451"]]}], "id":1 }' | jq '.result | .[] | .transactionIndex'
  1. This returns:
"0x1"
"0x1"
"0x1"

Expected behavior
The same transactionIndex should be returned.
If you remove the .transactionIndex from the jq command then it's clear that the returned objects are exactly the same except for the transactionIndex.

Desktop (please complete the following information):

  • OS: Mac OSX 14.0
  • Browser: N/A
  • Curl version:
~/: curl -V
curl 8.1.2 (x86_64-apple-darwin23.0) libcurl/8.1.2 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.55.1
Release-Date: 2023-05-30
@cll-gg
Copy link
Author

cll-gg commented Oct 26, 2023

Hi team, would you have an ETA for somebody taking a look at this issue? Thanks!

This was referenced Oct 28, 2023
@ozgrakkurt
Copy link

ozgrakkurt commented Jan 11, 2024

Also might be related, there is a bug in rpc where if I get block with transactions and then I do eth_getTransactionReceipt for each tx, there are transaction_index mismatch sometimes so for example the log inside the tx receipt has tx_index as 1 but when I do getBlockByNumber, that tx has index 0.

This bug happens on tx 0x27fa98452dcca7714bc89c571e6460936e73feaca2b4a40acb4666b609b4a670 on our node for example but happens on different transactions/blocks on different providers.

@rus-alex
Copy link
Contributor

@cll-gg , @ozgrakkurt , which version exactly (go-opera commit) do you use?

I've tried the case on our rpc ($URL in https://rpc.ftm.tools/, https://rpc.fantom.network/, https://rpc.eu-north-1.gateway.fm/v4/fantom/non-archival/mainnet )
and got the same transactionIndex by both kind of "eth_getLogs" and "transactionIndex" methods:

echo "- EXAMPLE 1"

echo "--- By block:"
curl ${URL} \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"blockHash":"0x0003b336000008bd319e42ed2b7fd2d7f74a90cf5e3ac169c54546abbce57aa6"}],
    "id":1}' \
  | jq '.result | .[] | select(.transactionHash == "0x6780bd14d08bf0064a7ba90a327f1dd356637a7a6b50fa463745adee56629edc") | .transactionIndex'


echo "--- By topics:"
curl ${URL} \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"fromBlock":"0x4234f52", "toBlock": "0x4234f52",
    "topics":[["0x0559884fd3a460db3073b7fc896cc77986f16e378210ded43186175bf646fc5f", "0x0109fc6f55cf40689f02fbaad7af7fe7bbac8a3d2186600afc7d3e10cac60271", "0xf6a97944f31ea060dfde0566e4167c1a1082551e64b60ecb14d599a9d023d451"]]}],
    "id":1}' \
  | jq '.result | .[] | .transactionIndex'

echo "--- By tx:"
curl ${URL} \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"jsonrpc":"2.0","method":"eth_getTransactionReceipt","params":["0x6780bd14d08bf0064a7ba90a327f1dd356637a7a6b50fa463745adee56629edc"],
    "id":1}' \
  | jq '.result.logs | .[] | .transactionIndex'


echo "- EXAMPLE 2"

echo "--- By block:"
curl ${URL} \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"blockHash":"0x0003f2f000000e4405461909e9a2fdb9e46858037a629bd4eed9ad01e8d0fb88"}],
    "id":1}' \
  | jq '.result | .[] | select(.transactionHash == "0x27fa98452dcca7714bc89c571e6460936e73feaca2b4a40acb4666b609b4a670") | .transactionIndex'


echo "--- By topics:"
curl ${URL} \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"fromBlock":"0x46a1b45", "toBlock": "0x46a1b45",
    "topics":[["0xe9149e1b5059238baed02fa659dbf4bd932fbcf760a431330df4d934bc942f37"]]}],
    "id":1}' \
  | jq '.result | .[] | .transactionIndex'

echo "--- By tx:"
curl ${URL} \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"jsonrpc":"2.0","method":"eth_getTransactionReceipt","params":["0x27fa98452dcca7714bc89c571e6460936e73feaca2b4a40acb4666b609b4a670"],
    "id":1}' \
  | jq '.result.logs | .[] | .transactionIndex'

@cll-gg
Copy link
Author

cll-gg commented May 1, 2024

@rus-alex: sorry for the late response.

Here's the version of the chain client for which I've observed the issue again roughly 2 hours ago:

curl -s ${RPC_URL} -X POST -H 'Content-Type: application/json' --data '{ "jsonrpc":"2.0", "method":"web3_clientVersion", "id":1 }'
{"jsonrpc":"2.0","id":1,"result":"go-opera/v1.1.3-rc.5-ace95a8a-1697285461/linux-amd64/go1.18.10"}

The issue seems to be resolving after some time, e.g. I saw our application retrieve the following mismatch but I can't reproduce this manually 2 hours later:

curl -s ${RPC_URL} -X POST -H 'Content-Type: application/json' --data '{ "jsonrpc":"2.0", "method":"eth_getLogs", "params":[{"blockHash":"0x0004441e00000f9c9593ed7dcb890c5089d628ffcdd1be1fee23e9d966b4ced9"}], "id":1 }' | jq '.result | .[] | select(.transactionHash == "0xef3fb9c17e328eb06a9a2b75f3e1eaccf2a9e0dd14926e8b9758af040f9dd93c") | .transactionIndex'

0x1
0x1
0x1
 curl -s ${RPC_URL} -X POST -H 'Content-Type: application/json' --data '{ "jsonrpc":"2.0", "method":"eth_getLogs", "params":[{"fromBlock":"0x4c88b9b", "toBlock": "0x4c88b9b", "topics": [["0xf6a97944f31ea060dfde0566e4167c1a1082551e64b60ecb14d599a9d023d451"]]}], "id":1 }' | jq '.result | .[] | .transactionIndex'

0x0

When I try to reproduce it manually, the first curl also returns 0x0 now.

@rus-alex
Copy link
Contributor

@cll-gg , is your chain client instance configured with option below ?

[Opera] 
TxIndex = false

If so, then eth_getLogs should not search by "topics" at all. Then I see the bug is in LLR which enables the search ignoring TxIndex = false.

@cll-gg
Copy link
Author

cll-gg commented May 27, 2024

@rus-alex, to be honest, I'm just using curl against a bespoke RPC endpoint, I'm not sure about its configuration.

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.

3 participants