Skip to content

EIP-4444: Add RPC errors for pruned blocks#8501

Closed
brbrr wants to merge 5 commits into
masterfrom
add/eip-4444-rpc-error
Closed

EIP-4444: Add RPC errors for pruned blocks#8501
brbrr wants to merge 5 commits into
masterfrom
add/eip-4444-rpc-error

Conversation

@brbrr

@brbrr brbrr commented Apr 9, 2025

Copy link
Copy Markdown
Contributor

Fixes Closes Resolves #8493

Please choose one of the keywords above to refer to the issue this PR solves followed by the issue number (e.g. Fixes #000). If no issue number, remove the line. Also, remove everything marked optional that is not applicable. Remove this note after reading.

Changes

  • List the changes

Types of changes

What types of changes does your code introduce?

  • Bugfix (a non-breaking change that fixes an issue)
  • New feature (a non-breaking change that adds functionality)
  • Breaking change (a change that causes existing functionality not to work as expected)
  • Optimization
  • Refactoring
  • Documentation update
  • Build-related changes
  • Other: Description

Testing

Requires testing

  • Yes
  • No

If yes, did you write tests?

  • Yes
  • No

Notes on testing

Optional. Remove if not applicable.

Documentation

Requires documentation update

  • Yes
  • No

If yes, link the PR to the docs update or the issue with the details labeled docs. Remove if not applicable.

Requires explanation in Release Notes

  • Yes
  • No

If yes, fill in the details here. Remove if not applicable.

Remarks

Optional. Remove if not applicable.

@brbrr brbrr requested a review from Copilot April 9, 2025 16:26
@brbrr brbrr self-assigned this Apr 9, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

src/Nethermind/Nethermind.JsonRpc/Modules/BlockFinderExtensions.cs:48

  • The condition contains a duplicate check for blockParameter.BlockHash < blockFinder.EarliestHash. Consider removing the redundant check or revising the condition if a different condition was intended.
if (blockParameter is not null && (blockParameter.BlockHash < blockFinder.EarliestHash || blockParameter.BlockHash < blockFinder.EarliestHash))

src/Nethermind/Nethermind.JsonRpc/ErrorCodes.cs:121

  • The XML comment for 'PrunedHistoryUnavailable' is misleading since the constant is used for pruned history errors. Consider updating the comment to accurately describe the error.
/// Too many blocks for simulation

Comment on lines +168 to +175

EarliestHash = GenesisHash;
if (_syncConfig.AncientReceiptsBarrierCalc > 0 && _syncConfig.AncientBodiesBarrierCalc > 0)
{
var lowestBlock = _syncConfig.AncientReceiptsBarrierCalc < _syncConfig.AncientBodiesBarrierCalc ? _syncConfig.AncientReceiptsBarrierCalc : _syncConfig.AncientBodiesBarrierCalc;
EarliestHash = FindBlockHash(lowestBlock);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's probably very naive, and won't work. It should be called after we process/sync up to ancient barriers. Not sure when/where it happens tho.

@brbrr

brbrr commented Apr 9, 2025

Copy link
Copy Markdown
Contributor Author

I was considering passing ISyncConfig but it requires a lot of pass-throughs to get the ancient barrier values in the SearchForBlock call.

I've decided to go with the EearliestHash approach, as it seems the most straightforward, and easily accessible from within RPC context. But there is a potential issue with current implementation - it probably wont be initialized on the empty DB. As an alternative (hacky) solution we could store EarliestBlockNumber, which would not require any queries in the constructor.

@brbrr brbrr requested review from asdacap and flcl42 April 9, 2025 16:51

public static SearchResult<Block> SearchForBlock(this IBlockFinder blockFinder, BlockParameter? blockParameter, bool allowNulls = false)
{
if (blockParameter is not null && (blockParameter.BlockHash < blockFinder.EarliestHash || blockParameter.BlockHash < blockFinder.EarliestHash))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same condition twice?
How do you want to compare hashes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤦 forgot about the fact that there were hashes. Updated the code to fetch the block number instead

@brbrr

brbrr commented Apr 15, 2025

Copy link
Copy Markdown
Contributor Author

superseded by #8521

@brbrr brbrr closed this Apr 15, 2025
@brbrr brbrr deleted the add/eip-4444-rpc-error branch April 16, 2025 05:38
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.

Adjust RPC errors for 4444

3 participants