Skip to content

refactor(core-blockchain): block processing#1953

Merged
faustbrian merged 17 commits intoArkEcosystem:developfrom
spkjp:refactor-block-processing
Jan 10, 2019
Merged

refactor(core-blockchain): block processing#1953
faustbrian merged 17 commits intoArkEcosystem:developfrom
spkjp:refactor-block-processing

Conversation

@spkjp
Copy link
Copy Markdown
Contributor

@spkjp spkjp 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)

@codecov-io
Copy link
Copy Markdown

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.

@faustbrian
Copy link
Copy Markdown
Contributor

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
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.

3 participants