Closed yangby-cryptape closed 8 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
e0a060a
) 71.14% compared to head (78e099a
) 71.41%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Description
This PR will fix #145.
If the first new "last state" after light client restarted is a fork state, the light client will do reorg to change its state to the new chain.
Let's denote
LAST_N_BLOCKS
as $N$.The blocks before $n{old}$ (included) are called as "reorg blocks", "reorg blocks" must be continuous. The last n continuous blocks before $n{new}$ (included) are called as "last n blocks"; non-continuous blocks are "sampled blocks".
If the restart is too soon, $n{new} - n{old} < N$, the "last n blocks" will not enough, then light client will throw the error
InvalidReorgHeaders
and ban the peer who sent the proof.How to fix?
If light client received all blocks between the fork block to the new "last state", then light client could use the reorg blocks to fill the "last n blocks".
Commits