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(core-blockchain): remove too early check for a chained block #2905

Closed
wants to merge 2 commits into from

Conversation

vasild
Copy link
Contributor

@vasild vasild commented Sep 3, 2019

In processBlocks() we would check whether the first downloaded block is
chained and if not then we would return from processBlocks(). However,
if that happens it leads to an "infinite" loop of downloading blocks,
not applying any of them until the nodejs process runs out of memory to
store all the blocks it has downloaded. A block that would cause this is
(on devnet): height=1199883, id=5174570296595098048.

Remove this early check. Later all blocks (not only the first one) are
verified whether chained or not.

A summary of what changes this PR introduces and why they were made.

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Refactor
  • Performance
  • Tests
  • Build
  • Documentation
  • Code style update
  • Continuous Integration
  • Other, please describe:

Does this PR introduce a breaking change?

  • Yes
  • No

Does this PR release a new version?

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

  • It's submitted to the develop branch, not the master branch
  • All tests are passing
  • New/updated tests are included

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

In processBlocks() we would check whether the first downloaded block is
chained and if not then we would return from processBlocks(). However,
if that happens it leads to an "infinite" loop of downloading blocks,
not applying any of them until the nodejs process runs out of memory to
store all the blocks it has downloaded. A block that would cause this is
(on devnet): height=1199883, id=5174570296595098048.

Remove this early check. Later all blocks (not only the first one) are
verified whether chained or not.
@vasild
Copy link
Contributor Author

vasild commented Sep 3, 2019

This PR supersedes #2903. If we merge this one, then 2903 can be discarded.

Copy link
Contributor

@spkjp spkjp left a comment

Choose a reason for hiding this comment

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

I'm not convinced about this one. Each batch contains up to 10k blocks and without this we end up processing them all just to discard them anyway if the first block is unchained which occasionally happens because of how the parallel block download works. An alternative approach would be to just add && !Utils.isException(blocks[0].data) to the condition.

@vasild
Copy link
Contributor Author

vasild commented Sep 4, 2019

Adding "isException()" check would only solve the problem for block "height=1199883, id=5174570296595098048" in particular because we already have it listed as an exception.

However there is a bigger problem - due to this check the nodejs process crashes whenever we receive an unchained block for which we don't have an exception.

Checking the first of 10k blocks would indeed save us processing time if the first block turns out to be unchained. However that would only work in 1 of 10k cases - if the second or 10th or 100th block is unchained we will still process the remaining ones.

So, the pro of this check is that we save processing time in 1 of 10k cases. The con is that it could cause the nodejs process to crash. IMO it hurts more than it helps.

…ly-chained-check

* ArkEcosystem/core/develop:
  test: mock missing wsServer
  release: 2.5.24 (#2908)
  fix(core-p2p): terminate blocked client connections
  fix(core-p2p): drop connections with malformed messages
  fix(core-api): return block timestamp for v2 transactions (#2906)
  fix(core-blockchain): only shift milestoneHeights[] if at that height (#2904)
  fix(crypto): use `anyOf` for transactions schema (#2894)
  fix(core-webhooks): cast params in condition checks (#2887)
  feat(core-p2p): use compression on the p2p level (#2886)
@spkjp
Copy link
Contributor

spkjp commented Sep 6, 2019

Superseded by #2903

@spkjp spkjp closed this Sep 6, 2019
@spkjp spkjp deleted the fix-early-chained-check branch September 6, 2019 23:51
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