Skip to content

jsonrpc: Implement debug_getBadBlocks#11888

Merged
somnergy merged 20 commits intomainfrom
eth_badblocks
Dec 4, 2024
Merged

jsonrpc: Implement debug_getBadBlocks#11888
somnergy merged 20 commits intomainfrom
eth_badblocks

Conversation

@sudeepdino008
Copy link
Copy Markdown
Member

@sudeepdino008 sudeepdino008 commented Sep 5, 2024

#8171

  • reference of rpc api query params/return value is taken from geth here
  • difference is that geth returns ALL bad blocks, this PR returns 100.

@erigontech erigontech deleted a comment from daniel-tomberg Nov 26, 2024
@sudeepdino008 sudeepdino008 marked this pull request as ready for review November 26, 2024 11:20
@somnergy
Copy link
Copy Markdown
Member

getbadBlocks does get hit quite often by some CLs, about once every block or so, i think.
It does make sense to limit output to 100 blocks in the LRU, but reading the whole table on every call doesn't make sense. There should be an in-memory cache. Assuming there are about 1000 bad blocks, it's a 1000 sequential mdbx reads - that is not bad as such, but only if it's called every block
In accessors_chain tho, i don't see a natural point to include this LRU cache
It may help to add another table with blockNum + hash -> {}

@sudeepdino008
Copy link
Copy Markdown
Member Author

getbadBlocks does get hit quite often by some CLs, about once every block or so, i think. It does make sense to limit output to 100 blocks in the LRU, but reading the whole table on every call doesn't make sense. There should be an in-memory cache. Assuming there are about 1000 bad blocks, it's a 1000 sequential mdbx reads - that is not bad as such, but only if it's called every block In accessors_chain tho, i don't see a natural point to include this LRU cache It may help to add another table with blockNum + hash -> {}

that's interesting. I thought it was just one-off queries by the user. Is there a reference which I can see about CL calling getBadBlocks?
If last 100 blocks is good enough, I think LRU cache is enough optimization. Adding new table is useful only if there are large number of bad blocks, and the assumption is that there aren't.

@somnergy somnergy changed the title eth_getBadBlocks jsonrpc: Implement debug_getBadBlocks Nov 27, 2024
@somnergy
Copy link
Copy Markdown
Member

getbadBlocks does get hit quite often by some CLs, about once every block or so, i think. It does make sense to limit output to 100 blocks in the LRU, but reading the whole table on every call doesn't make sense. There should be an in-memory cache. Assuming there are about 1000 bad blocks, it's a 1000 sequential mdbx reads - that is not bad as such, but only if it's called every block In accessors_chain tho, i don't see a natural point to include this LRU cache It may help to add another table with blockNum + hash -> {}

that's interesting. I thought it was just one-off queries by the user. Is there a reference which I can see about CL calling getBadBlocks? If last 100 blocks is good enough, I think LRU cache is enough optimization. Adding new table is useful only if there are large number of bad blocks, and the assumption is that there aren't.

I think you will see those hits by running against a CL like lighthouse, nimbus, or teku against any network. You can also run a kurtosis env. Some of the CLs might also be optimizing on their side how often they call for this json resp, but in the worst case it could be bad.

@sudeepdino008
Copy link
Copy Markdown
Member Author

@somnathb1 added cache to store the heap; it'll return the sorted values when queried.

Copy link
Copy Markdown
Member

@somnergy somnergy left a comment

Choose a reason for hiding this comment

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

Please fix lint. Rest looks good.

@somnergy somnergy merged commit 53b973d into main Dec 4, 2024
@somnergy somnergy deleted the eth_badblocks branch December 4, 2024 10:39
sudeepdino008 added a commit that referenced this pull request Dec 4, 2024
#8171

- reference of rpc api query params/return value is taken from geth
[here](https://github.com/ethereum/go-ethereum/blob/b4d99e39176f89bb0ffbb32635e9cf17b5fd7367/eth/api_debug.go#L107)
- difference is that geth returns ALL bad blocks, this PR returns 100.
somnergy added a commit that referenced this pull request Jan 24, 2025
See #8171
and Previous PR which put this into `eth_` api -
#11888
somnergy added a commit that referenced this pull request Jan 28, 2025
See #8171
and Previous PR which put this into `eth_` api -
#11888
somnergy added a commit that referenced this pull request Jan 28, 2025
See #8171
and Previous PR which put this into `eth_` api -
#11888
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.

4 participants