Fix logIndex offset bug
PR description
The ethereum json-rpc spec requires logIndex be a log's position within the block:
https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getfilterchanges
This is also what's described in the comments, but instead the current implementation of logIndex starts counting only from the beginning of the current transaction. This PR brings public transaction logs into conformance with the spec.
This does not include full support for changing logIndex to work the same way with private transactions, because this appears to require a change to the private state storage format. Partial support has been included for review, but commented out due to non-existent privateStateStorage.getTransactionReceipts(blockHash) method.
Maybe it's not possible to access other private tx's in the same block?
TODO: modify expected results for more tests, so that everything passes.
Fixed Issue(s)
Fixes #4114
Documentation
- [x] I thought about documentation and added the
doc-change-requiredlabel to this PR if updates are required.
Changelog
- [x] I thought about the changelog and included a changelog update if required.
Private transactions are an interesting case. Someone more familiar with the way they work will have to chime in but I don't think they can be indexed based on the position in the block. The main issue is working out what previous logs are counted, for example:
- Logs from public transactions - seems like should obviously be counted
- Logs from other private transactions from the same group - could be counted
- Logs from other private transactions from different groups this node has access to - could be counted but getting weird
- Logs from other private transactions from groups this node doesn't have access to - can't be counted as they're unknown
Notably logIndex for a private transaction wouldn't be unique within a block with any of these options because the logIndex generated for other public transactions in that block shouldn't include the logs from private transactions - otherwise a log from a public tx may reveal information about private transactions the node has access to.
@reductionista I'm closing this one as this ended up being resolved by this PR https://github.com/hyperledger/besu/pull/4355 - thanks for your interest in besu!