Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Prevent crashing the application when a block is received and node is syncing or forging - Closes #3896 #3946

Merged

Conversation

2snEM6
Copy link
Contributor

@2snEM6 2snEM6 commented Jul 11, 2019

What was the problem?

When receiving a block from the network in receiveBlockFromNetwork function, the application was crashing with a fatal error if the node was syncing or forging at that moment (aka blocks.js#_isActive was set to true)

How did I fix it?

By adding back forger.#forge call to the Sequence. Somehow it was removed from it in 2.2
Added a unit test case to cover this particular scenario.

How to test it?

Run these tests npm run mocha:unit framework/test/mocha/unit/modules/chain/chain.js

Review checklist

Copy link
Collaborator

@shuse2 shuse2 left a comment

Choose a reason for hiding this comment

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

https://github.com/LiskHQ/lisk-sdk/blob/release/2.0.0/framework/src/modules/chain/submodules/blocks/process.js#L560-L565

I think we shouldn't change the receiveBlockFromNetwork in block, but it should be rejected in transport layer as it was before

@pablitovicente
Copy link
Contributor

https://github.com/LiskHQ/lisk-sdk/blob/release/2.0.0/framework/src/modules/chain/submodules/blocks/process.js#L560-L565

I think we shouldn't change the receiveBlockFromNetwork in block, but it should be rejected in transport layer as it was before

I like this idea if the changes are not massive - due to the possible accessibility issues of the active variable - it would be nice for this to happen in network. Maybe through ApplicationState? But I think that if the changes for this are too big it could be ok if we create an issue to solve it in a minor version.

@2snEM6
Copy link
Contributor Author

2snEM6 commented Jul 12, 2019

/2.0.0/framework/src/modules/chain/submodules/blocks/process.js@release#L560-L565

I think we shouldn't change the receiveBlockFromNetwork in block, but it should be rejected in transport layer as it was before

@shuse2 you mean transport.js? That file points to process.js

@2snEM6
Copy link
Contributor Author

2snEM6 commented Jul 12, 2019

Also @shuse2 @pablitovicente shouldn't we add the task to the Sequence queue no matter what, and then the task itself could check if active = true. This way we don't miss received blocks. Doing it the way you propose I think could change the behavior.

@shuse2
Copy link
Collaborator

shuse2 commented Jul 12, 2019

If the current status is syncing it shouldn't add to the sequence. If we do, the process queue will be something like

height: 10 (sync)
height: 10 (sync)
height: 200000 (received)
height: 10 (sync)
height: 10 (sync)
height: 10 (sync)

but this received is unnecessary, and only useful in case where it's pushed exactly when the sync is finishing

…omNetwork is triggered"

This reverts commit 89f918a

Reason: this is not the problem. The problem is forging task is not being
added to Sequence. Therefore this causes Forging to overlap with Syncing
or Receiving blocks.
@2snEM6 2snEM6 force-pushed the 3896-Block_process_cannot_be_executed_in_parallel branch from 7f5c438 to 510dc3d Compare July 12, 2019 13:59
@2snEM6 2snEM6 requested a review from shuse2 July 12, 2019 15:36
@2snEM6 2snEM6 force-pushed the 3896-Block_process_cannot_be_executed_in_parallel branch from 78951c4 to e683795 Compare July 15, 2019 08:19
@shuse2 shuse2 requested review from SargeKhan and yatki and removed request for pablitovicente July 15, 2019 09:52
@2snEM6 2snEM6 requested a review from shuse2 July 15, 2019 10:00
@shuse2 shuse2 requested a review from ishantiw July 15, 2019 10:02
@2snEM6 2snEM6 requested review from yatki and shuse2 July 15, 2019 12:19
@shuse2 shuse2 merged commit 40e24bb into release/2.2.0 Jul 15, 2019
@shuse2 shuse2 deleted the 3896-Block_process_cannot_be_executed_in_parallel branch July 15, 2019 15:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants