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

core: repro #18977 #18988

Merged
merged 2 commits into from
Feb 8, 2019
Merged

core: repro #18977 #18988

merged 2 commits into from
Feb 8, 2019

Conversation

holiman
Copy link
Contributor

@holiman holiman commented Feb 4, 2019

This PR adds a testcase to reproduce the crash in #18977. What happens is

  1. A chain A has N blocks at td Ta.
  2. A sidechain B has M blocks at td Tb. Tb > Ta.
  3. However, the B chain consists of a lot more blocks, so that at the point where Tb surpasses Ta, the block number is more than 128 blocks ahead of the head of A.

Todo: @karalabe take it from here and make the test pass.


@karalabe: Done.

The issue was that when we import very long sidechains, we only reorg the canonical numbers after we exceed the local chain's TD. The pruner however used canonical numbers to figure out which trie to commit when. Since canonical numbers are unavailable until sidechain import is actually done, the pruner accessed non-indexed headers and crashed.

The fix is first of all to not access the canonical number unless actually needed (only when we want to commit, not during normal imports); and second to handle the case when the header numbering is missing by postponing commit to the next block.

@karalabe
Copy link
Member

karalabe commented Feb 8, 2019

@holiman PTAL

@holiman
Copy link
Contributor Author

holiman commented Feb 8, 2019

I'm unable to github-approve, since it's my PR. But you have my approval!

Note:
As you fixed it, it will work. Howver, whenever it's doing a sidechain import, which does not fulfill this low-td-but-long behaviour (that is, a normal sidechain), it will behave somewhat oddly.

  • Import sideblock B' number N.
  • Perform gc on canonblock B number N. Which it has already done, while importng B.

So this fix addresses the panic, but I think it's still not quite Correct (tm)

@karalabe
Copy link
Member

karalabe commented Feb 8, 2019

If it does not exceed the TD, it won't process the sidechain, only inject the raw block into the database.

@karalabe
Copy link
Member

karalabe commented Feb 8, 2019

Btw, I added a tiny extension to the test case so that it also verifies that the canonical numbers are updated after the whole fiasco (just to make sure it's not a deeper bug, just a temporary thing).

@karalabe karalabe force-pushed the repro18977 branch 2 times, most recently from bcdbeb1 to e09d928 Compare February 8, 2019 09:54
@karalabe
Copy link
Member

karalabe commented Feb 8, 2019

Also I deleted the helpers, modifying the difficulty is already supported (alas a bit convoluted) through b.OffsetTime(-9).

@karalabe karalabe added this to the 1.9.0 milestone Feb 8, 2019
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.

2 participants