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

blockchain: fix inconsistent reorg behavior #391

Merged
merged 4 commits into from
Jan 17, 2024

Conversation

NganSM
Copy link
Contributor

@NganSM NganSM commented Jan 9, 2024

If the chain is reorganized because the newly submit block has higher justified block number, it can be reverted back to the old chain prior to reorg because the old blocks cause ErrKnownBlock during insertion via the insertChain method, which invokes writeKnownBlock to set the old chain as the canonical chain again.

@NganSM NganSM force-pushed the fix-inconsistent-reorg branch from 65df573 to c988786 Compare January 9, 2024 10:52
NganSM and others added 4 commits January 16, 2024 10:52
If the chain is reorganized because the newly submit block has higher
justified block number, it can be reverted back to the old chain prior
to reorg because the old blocks cause ErrKnownBlock during insertion
via the insertChain method, which invokes writeKnownBlock to set the
old chain as the canonical chain again.
…face

When testing, we may need to create the standalone consortium-v2 engine so we
need to make it fully implement FastFinalityPoSA interface.
When generating Consortium blocks, we need to modify the block after
FinalizeAndAssemble to change the block signature in header's extra data. New
function GenerateConsortiumChain adds a new parameter so the caller can pass a
function to modify block after FinalizeAndAssemble. Besides, the fake chain
reader also needs to return correct block header to be used by consensus engine
in FinalizeAndAssemble.
@minh-bq minh-bq force-pushed the fix-inconsistent-reorg branch from c988786 to cd2adc8 Compare January 17, 2024 06:06
@NganSM NganSM requested review from minh-bq and DNK90 January 17, 2024 07:07
@minh-bq minh-bq merged commit bf2f0d1 into axieinfinity:master Jan 17, 2024
1 check passed
minh-bq added a commit to minh-bq/ronin that referenced this pull request Feb 20, 2024
* blockchain: fix inconsistent reorg behavior

If the chain is reorganized because the newly submit block has higher
justified block number, it can be reverted back to the old chain prior
to reorg because the old blocks cause ErrKnownBlock during insertion
via the insertChain method, which invokes writeKnownBlock to set the
old chain as the canonical chain again.

* consortium-v2: make the engine fully implement FastFinalityPoSA interface

When testing, we may need to create the standalone consortium-v2 engine so we
need to make it fully implement FastFinalityPoSA interface.

* chain_makers: add GenerateConsortiumChain to genernate Consortium blocks

When generating Consortium blocks, we need to modify the block after
FinalizeAndAssemble to change the block signature in header's extra data. New
function GenerateConsortiumChain adds a new parameter so the caller can pass a
function to modify block after FinalizeAndAssemble. Besides, the fake chain
reader also needs to return correct block header to be used by consensus engine
in FinalizeAndAssemble.

* consortium-v2: add unit test for known block reorg case

---------

Co-authored-by: Bui Quang Minh <minh.bui@skymavis.com>
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