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: add block validation on Fast Sync #517

Merged
merged 2 commits into from
Dec 2, 2022
Merged

Conversation

ulbqb
Copy link
Member

@ulbqb ulbqb commented Dec 1, 2022

Description

This PR enable to make block synchronization safer by performing block verification before persisting blocks during Fast Sync. This PR is same as tendermint/tendermint#8493.

Problem

In consensus, we always validate a block before voting and thereby before we persist it, however in blocksync it's possible to persist an invalid block as we only validate it afterwards (in ApplyBlock). This potentially puts the node in a bad state where it can't simply rollback the previous execution.

tendermint/tendermint#8493 (comment)

Fix

I added block validation before before persisting blocks.

@Mdaiki0730 Mdaiki0730 self-requested a review December 1, 2022 07:31
@codecov
Copy link

codecov bot commented Dec 1, 2022

Codecov Report

Merging #517 (e31f06a) into main (07a894b) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

❗ Current head e31f06a differs from pull request most recent head 3570b83. Consider uploading reports for the commit 3570b83 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #517      +/-   ##
==========================================
- Coverage   65.62%   65.60%   -0.02%     
==========================================
  Files         279      279              
  Lines       38032    38033       +1     
==========================================
- Hits        24957    24951       -6     
- Misses      11276    11283       +7     
  Partials     1799     1799              
Impacted Files Coverage Δ
blockchain/v0/reactor.go 70.46% <100.00%> (+0.97%) ⬆️
libs/events/events.go 93.23% <0.00%> (-5.27%) ⬇️
types/tx.go 90.24% <0.00%> (-3.66%) ⬇️
p2p/switch.go 65.90% <0.00%> (-0.62%) ⬇️
blockchain/v0/pool.go 79.06% <0.00%> (-0.52%) ⬇️
p2p/pex/addrbook.go 71.57% <0.00%> (-0.51%) ⬇️
consensus/reactor.go 74.13% <0.00%> (-0.45%) ⬇️
consensus/state.go 73.47% <0.00%> (-0.15%) ⬇️
proxy/multi_app_conn.go 47.66% <0.00%> (ø)
types/voter_set.go 85.20% <0.00%> (+0.42%) ⬆️
... and 6 more

@ulbqb ulbqb changed the title fix: add block validation fix: add block validation on Fast Sync Dec 1, 2022
@ulbqb ulbqb marked this pull request as ready for review December 1, 2022 09:32
@Kynea0b Kynea0b added the C: enhancement Classification: New feature or its request, or improvement in maintainability of code label Dec 2, 2022
Copy link
Contributor

@Kynea0b Kynea0b left a comment

Choose a reason for hiding this comment

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

LGTM

@ulbqb ulbqb merged commit f016cae into Finschia:main Dec 2, 2022
@ulbqb ulbqb deleted the fix/fast_sync branch December 2, 2022 02:31
@ulbqb ulbqb restored the fix/fast_sync branch December 2, 2022 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: enhancement Classification: New feature or its request, or improvement in maintainability of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants