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

Fix eth_getlogs not returning error when receipt is unavailable #4056

Merged
merged 4 commits into from
May 29, 2022

Conversation

asdacap
Copy link
Contributor

@asdacap asdacap commented May 25, 2022

Fixes #3983

Changes:

  • Added HasBlock method to IReceiptStorage.
    • ReceiptPersistentStorage implemented it by checking its cache first, then the blocks column.
  • LogFinder will check HasBlock on first and last block and will throw ResourceNotFoundException if receipt not found.
  • EthRpcModule will return resource not found code when ResourceNotFoundException is encountered.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Other (please describe):

Testing

  • [ X] Yes
  • No

In case you checked yes, did you write tests??

  • [ X] Yes
  • No

Comments about testing , should you have some (optional)

  • Tested by running a clean DB. During fast sync after header was downloaded, query for block where the header already download. Confirmed error is returned.
  • Queried again after full sync. Confirmed logs was returned.

@asdacap asdacap requested a review from LukaszRozmej May 25, 2022 04:28
@LukaszRozmej
Copy link
Member

Generally fine, but I think here we are clipping to block, do we want to do that?
https://github.com/NethermindEth/nethermind/blob/master/src/Nethermind/Nethermind.Blockchain/Find/LogFinder.cs#L69

Other small thing not sure if it should be ResourceNotFound or ResourceUnavailable?

@asdacap
Copy link
Contributor Author

asdacap commented May 25, 2022

Missed the clip thing.

As for the ResourceNotFound or ResourceUnavailable, it seems that other RPC that can't run when state is unavailable respond with ResourceUnavailable, but currently, if the block is not found (as in header not found, not just receipt), it returns, resourceNotFound. So.. I don't know.

src/Nethermind/Nethermind.Blockchain/Find/LogFinder.cs Outdated Show resolved Hide resolved
@@ -63,18 +63,29 @@ public class LogFinder : ILogFinder
public IEnumerable<FilterLog> FindLogs(LogFilter filter, CancellationToken cancellationToken = default)
{
BlockHeader FindHeader(BlockParameter blockParameter, string name, bool headLimit) =>
_blockFinder.FindHeader(blockParameter, headLimit) ?? throw new ArgumentException("Block not found.", name);
_blockFinder.FindHeader(blockParameter, headLimit) ?? throw new ResourceNotFoundException($"Block not found: {name}");
Copy link
Member

Choose a reason for hiding this comment

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

Can we also include BlockParameter in error message?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems to already do it via the name parameter.

Copy link
Member

Choose a reason for hiding this comment

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

No its just nameof(filter.ToBlock), lets add what was that what we are missing (blocknumber, hash)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I suppose a simple .ToString() is enough?

Copy link
Member

Choose a reason for hiding this comment

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

yes just drop it somewhere in the pattern in some good way

@asdacap asdacap force-pushed the fix/eth_getlogs_unavailable_receipt_xalidation branch from baf2c64 to 5584d97 Compare May 27, 2022 14:09
@LukaszRozmej LukaszRozmej merged commit 6eade35 into master May 29, 2022
@LukaszRozmej LukaszRozmej deleted the fix/eth_getlogs_unavailable_receipt_xalidation branch May 29, 2022 19:01
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 this pull request may close these issues.

Fix eth_getLogs - return error when syncing/receipt not available
2 participants