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

refactor(core-blockchain): block processing #1953

Merged
merged 17 commits into from Jan 10, 2019

Conversation

Projects
None yet
4 participants
@supaiku0
Copy link
Contributor

supaiku0 commented Jan 8, 2019

Proposed changes

This PR refactors the current block processing logic to streamline the handling of bad blocks
and make it overall more robust and easier to follow.

Short summary:

  • Added new BlockProcessor class
  • Divided existing logic into BlockHandlers, used by BlockProcessor
  • Handlers do something i.e. reverting the last downloaded block, starting a fork or chaining a block
  • Custom behavior is implemented in subclasses of BlockHandler by overwriting execute
  • I twisted the logic a bit and now it is assumed that we get a bad block by default

Forging still works on my delegate and tests are all green . Though I had to disable two tests for now - acceptChainedBlock and manageUnchainedBlock. The functionality is implicitely tested by other tests and the tests don't make sense in their current form anymore. Remove them?

Any feedback is welcome.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (improve a current implementation without adding a new feature or fixing a bug)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Build (changes that affect the build system)
  • Docs (documentation only changes)
  • Test (adding missing tests or fixing existing tests)
  • Other... Please describe:

Checklist

  • I have read the CONTRIBUTING documentation
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

@supaiku0 supaiku0 requested review from vasild , kristjank and faustbrian Jan 8, 2019

@codecov-io

This comment has been minimized.

Copy link

codecov-io commented Jan 8, 2019

Codecov Report

Merging #1953 into develop will increase coverage by 0.64%.
The diff coverage is 71.73%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1953      +/-   ##
===========================================
+ Coverage     38.6%   39.24%   +0.64%     
===========================================
  Files          354      363       +9     
  Lines         7764     7840      +76     
  Branches      1172     1168       -4     
===========================================
+ Hits          2997     3077      +80     
+ Misses        4752     4748       -4     
  Partials        15       15
Impacted Files Coverage Δ
...2p/src/server/versions/internal/handlers/blocks.ts 0% <0%> (ø) ⬆️
...ackages/core-p2p/src/server/versions/1/handlers.ts 0% <0%> (ø) ⬆️
packages/core-database/src/interface.ts 32.77% <0%> (+4.09%) ⬆️
...blockchain/src/processor/handlers/block-handler.ts 100% <100%> (ø)
...rc/processor/handlers/invalid-generator-handler.ts 100% <100%> (ø)
...ages/core-blockchain/src/utils/is-block-chained.ts 100% <100%> (ø)
.../processor/handlers/verification-failed-handler.ts 50% <50%> (ø)
...n/src/processor/handlers/already-forged-handler.ts 60% <60%> (ø)
...kchain/src/processor/handlers/unchained-handler.ts 61.9% <61.9%> (ø)
...s/core-blockchain/src/processor/block-processor.ts 65.85% <65.85%> (ø)
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7dcb256...f1f67c4. Read the comment docs.

kristjank and others added some commits Jan 8, 2019

@faustbrian

This comment has been minimized.

Copy link
Collaborator

faustbrian commented Jan 10, 2019

I would leave the skipped tests in for now, in case we want to enable them again, otherwise we can remove them soon.

@faustbrian faustbrian merged commit 39b6aa8 into ArkEcosystem:develop Jan 10, 2019

6 checks passed

ci/circleci: test-node10-0 Your tests passed on CircleCI!
Details
ci/circleci: test-node10-1 Your tests passed on CircleCI!
Details
ci/circleci: test-node10-2 Your tests passed on CircleCI!
Details
ci/circleci: test-node11-0 Your tests passed on CircleCI!
Details
ci/circleci: test-node11-1 Your tests passed on CircleCI!
Details
ci/circleci: test-node11-2 Your tests passed on CircleCI!
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment