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

Use eth_getUncleByBlockHashAndIndex for uncle block fetching #1799

Merged
merged 1 commit into from
Apr 22, 2019

Conversation

goodsoft
Copy link
Contributor

@goodsoft goodsoft commented Apr 21, 2019

Fixes #1798

Motivation

Parity returns null for many uncle blocks, if they are fetched using eth_getBlockByHash. This is most probably caused by the fact that Parity only keeps full block data for recent non-consensus blocks.

This causes uncle_block fetcher to loop endlessly trying to fetch "missing" blocks, hogging both app server and Parity resources.

Changes

Instead, we use eth_getUncleByBlockHashAndIndex method, which works for all uncle blocks.

As we didn't previously store index of an uncle block within a nephew block, a new field and a temporary fixup fetcher is added to get the index from nephew blocks.

Checklist for your PR

  • I added an entry to CHANGELOG.md with this PR
  • If I added new functionality, I added tests covering it.
  • If I fixed a bug, I added a regression test to prevent the bug from silently reappearing again.
  • I checked whether I should update the docs and did so if necessary

@ghost ghost assigned goodsoft Apr 21, 2019
@ghost ghost added the in progress label Apr 21, 2019
@goodsoft goodsoft force-pushed the gs-uncle-blocks-api branch 2 times, most recently from fe26a62 to ed268c6 Compare April 21, 2019 16:36
@coveralls
Copy link

coveralls commented Apr 21, 2019

Pull Request Test Coverage Report for Build 7d057ddf-d894-418b-84c7-d833c6d03185

  • 12 of 48 (25.0%) changed or added relevant lines in 8 files are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage remained the same at 82.303%

Changes Missing Coverage Covered Lines Changed/Added Lines %
apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex 0 1 0.0%
apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/block/by_nephew.ex 0 1 0.0%
apps/explorer/lib/explorer/chain/import/runner/block/second_degree_relations.ex 0 1 0.0%
apps/indexer/lib/indexer/temporary/uncles_without_index.ex 0 33 0.0%
Files with Coverage Reduction New Missed Lines %
apps/indexer/lib/indexer/block/catchup/fetcher.ex 4 69.23%
Totals Coverage Status
Change from base Build b657bc58-2dbd-4a39-8c61-121c04526287: 0.0%
Covered Lines: 4432
Relevant Lines: 5385

💛 - Coveralls

@goodsoft goodsoft force-pushed the gs-uncle-blocks-api branch 5 times, most recently from 93b09b2 to 44ca4ff Compare April 21, 2019 18:13
@goodsoft goodsoft added ready for review This PR is ready for reviews. and removed in progress labels Apr 21, 2019
@ghost ghost assigned vbaranov Apr 22, 2019
@ghost ghost added the in progress label Apr 22, 2019
Copy link
Contributor

@ayrat555 ayrat555 left a comment

Choose a reason for hiding this comment

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

looks good

Parity returns `null` for many uncle blocks, if they are fetched using
`eth_getBlockByHash`. This is most probably caused by the fact that Parity
only keeps full block data for recent non-consensus blocks.

This causes uncle_block fetcher to loop endlessly trying to fetch "missing"
blocks, hogging both app server and Parity resources.

Instead, we use `eth_getUncleByBlockHashAndIndex` method, which works for
all uncle blocks.

As we didn't previously store index of an uncle block within a nephew block,
a new field and a temporary fixup fetcher is added to get the index from
nephew blocks.
@vbaranov vbaranov merged commit ba9583c into master Apr 22, 2019
@vbaranov vbaranov deleted the gs-uncle-blocks-api branch April 22, 2019 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review This PR is ready for reviews.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Uncle blocks can't be indexed using eth_getBlockByHash
5 participants