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

Log index is counted per block, not per transaction #4355

Merged

Conversation

daniellehrner
Copy link
Contributor

Signed-off-by: Daniel Lehrner daniel.lehrner@consensys.net

PR description

The log index returned by eth_getLogs is currently counted on a transaction basis, which is incorrect. The correct way is to have it unique per block. This PR changes it to the correct behavior.

Fixed Issue(s)

fixes #4114

Documentation

  • I thought about documentation and added the doc-change-required label to this PR if
    updates are required.

Changelog

Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
Copy link
Contributor

@fab-10 fab-10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a couple of optimizations and suggested renaming

isQueryAlive);
final boolean removed = getRemoved(blockHash, isQueryAlive);

final AtomicInteger logIndexOffset = new AtomicInteger();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why an AtomicInteger here? it seems that a plain int is enough

@@ -83,16 +84,24 @@ public List<LogWithMetadata> matchingLogs(
final long blockNumber = blockHeader.get().getNumber();
final boolean removed = !blockchainQueries.blockIsOnCanonicalChain(blockHash);

final AtomicInteger logIndexOffset = new AtomicInteger();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@fab-10
Copy link
Contributor

fab-10 commented Sep 9, 2022

Please update the CHANGELOG

Copy link
Contributor

@fab-10 fab-10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a couple of optimizations and suggested renaming.
Consider my suggestions as non blocking for the merge of this PR

@mark-terry mark-terry enabled auto-merge (squash) October 5, 2022 15:48
@mark-terry mark-terry merged commit 4c2251b into hyperledger:main Oct 5, 2022
@macfarla macfarla mentioned this pull request Oct 6, 2022
2 tasks
eum602 pushed a commit to lacchain/besu that referenced this pull request Nov 3, 2023
* Log index is counted per block, not per transaction

Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
Co-authored-by: mark-terry <mark.terry@consensys.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Besu returns logs with incorrect logIndex (different behaviour than go-ethereum)
5 participants