-
Notifications
You must be signed in to change notification settings - Fork 20.1k
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
get_TransactionReceipt logIndex and transactionIndex is not correct #2028
Comments
The problem is that this definition is impractical. If the logIndex is based on the log position in the block, then it is impossible to identify a specific log without fetching all transactions in a block and looping to count the number of logs preceding the particular log. In fact, this is the point of having a transactionIndex. The logIndex should instead be the index of within the particular transaction. Given a txhash and logIndex, here's the difference:
logIndex as position within transaction
In summary, when logIndex tracks the position of the log within the block, it actually combines the txIndex and logIndex into a single confusing parameter. Instead, the bias of txIndex should be removed, so logIndex doesn't need to know anything about its containing block, only the transaction |
Pinging @frozeman for his input |
I agree with @tgerring here, it doesn't make real sense to make it block specific, as this makes the log index rather useless. Im not sure how this is implemented in cpp @debris |
I've been looking into this carefully between geth and parity. Geth and parity both report transactionIndexes starting from '0' within a block. Parity (at least its latest version) reports logIndexes per transaction starting with '0'. Geth (prior to 1.5.x) reports logIndexes per block starting with '1' So there's more than one different inconsistencies. The docs say that each item is an 'integer of the [item]'s index position in the block. null when its pending'. I agree with tgerring, that the transactionIndex should be per block (because transactions are data members of blocks), and the logIndex should be per transaction (because logs are conceptually part of a transaction). Both should index starting with '0' not '1', but in either case, both should index starting with the same number. Fixing this will be a breaking change for existing apps using either transactionIndex or logIndex (whichever gets changed), and the docs will have to be fixed. I think it's also important to track that this gets made consistent between Parity and geth so as to make switching RPC providers painless. |
Fixing this would be a breaking change. However, this would make
Perhaps it could be done for the next major version? |
+1 I think, that logIndex should be transaction specific. It is really useful in many cases. |
I just ran into this because it seemed strange geth indexed the logs as a position within the block, but I had to call (Incidentally what I was trying to do with create a buffered channel of |
@bas-vk are you still working on this? I'm going to remove the in-progress label. |
We can do a similar fix to Parity. Then the API doesn't break, but the functionality gets shipped openethereum/parity-ethereum#3995 |
Feature request added: #18407 |
OMG can somebody take care of this finally? |
Feel free to take care of it.
|
But I am not premine beneficiary... |
Then find someone who is I guess.
|
Ok, so we don't get what the issue here is. The receipt returned an array of logs. If you access |
@karalabe right, but I think that's incorrect because logs need to be indexed to the block not indexed to the transaction? return values from eth_getFilterChanges: So if txn[0] has 2 logs, and txn[1] has 3 logs the proper
but instead geth returns:
|
Working on a private chain, I noticed that logIndex seems to follow be the order of a transaction and transactionIndex not set to what it should be. For example, note the below block with 2 transactions, each containing 1 log. The "position" of these logs in the chain should be 7494.0.0 and 7494.1.0 where the format is BlockIndex.TransactionIndex.LogIndex, each as a subset of the other. Instead, go-ethereum reports the position as 7494.0.1 and 7494.0/1.1. The second receipt actually has conflicting information, with the transactionIndex being reported at "1" on the transaction itself but "0" on the composed log.
The positional values should be defined as follows:
BlockHeight (in main chain)
Transaction index (within the block)
Log index (within the transaction)
Receipt 350fb0:
Receipt dce4c5:
The text was updated successfully, but these errors were encountered: