sync: Mark chains with bad blocks as bad too
This commit is contained in:
parent
7514d3e1bd
commit
a6135b62ce
@ -122,7 +122,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sync
|
// Sync
|
||||||
const BadBlockCacheSize = 8192
|
const BadBlockCacheSize = 1 << 15
|
||||||
|
|
||||||
// assuming 4000 blocks per round, this lets us not lose any messages across a
|
// assuming 4000 blocks per round, this lets us not lose any messages across a
|
||||||
// 10 block reorg.
|
// 10 block reorg.
|
||||||
|
@ -755,10 +755,16 @@ func (syncer *Syncer) collectHeaders(ctx context.Context, from *types.TipSet, to
|
|||||||
|
|
||||||
syncer.syncState.SetHeight(blockSet[len(blockSet)-1].Height())
|
syncer.syncState.SetHeight(blockSet[len(blockSet)-1].Height())
|
||||||
|
|
||||||
|
var acceptedBlocks []cid.Cid
|
||||||
|
|
||||||
loop:
|
loop:
|
||||||
for blockSet[len(blockSet)-1].Height() > untilHeight {
|
for blockSet[len(blockSet)-1].Height() > untilHeight {
|
||||||
for _, bc := range at {
|
for _, bc := range at {
|
||||||
if syncer.bad.Has(bc) {
|
if syncer.bad.Has(bc) {
|
||||||
|
for _, b := range acceptedBlocks {
|
||||||
|
syncer.bad.Add(b)
|
||||||
|
}
|
||||||
|
|
||||||
return nil, xerrors.Errorf("chain contained block marked previously as bad (%s, %s)", from.Cids(), bc)
|
return nil, xerrors.Errorf("chain contained block marked previously as bad (%s, %s)", from.Cids(), bc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -766,6 +772,8 @@ loop:
|
|||||||
// If, for some reason, we have a suffix of the chain locally, handle that here
|
// If, for some reason, we have a suffix of the chain locally, handle that here
|
||||||
ts, err := syncer.store.LoadTipSet(at)
|
ts, err := syncer.store.LoadTipSet(at)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
acceptedBlocks = append(acceptedBlocks, at...)
|
||||||
|
|
||||||
blockSet = append(blockSet, ts)
|
blockSet = append(blockSet, ts)
|
||||||
at = ts.Parents()
|
at = ts.Parents()
|
||||||
continue
|
continue
|
||||||
@ -801,12 +809,18 @@ loop:
|
|||||||
}
|
}
|
||||||
for _, bc := range b.Cids() {
|
for _, bc := range b.Cids() {
|
||||||
if syncer.bad.Has(bc) {
|
if syncer.bad.Has(bc) {
|
||||||
|
for _, b := range acceptedBlocks {
|
||||||
|
syncer.bad.Add(b)
|
||||||
|
}
|
||||||
|
|
||||||
return nil, xerrors.Errorf("chain contained block marked previously as bad (%s, %s)", from.Cids(), bc)
|
return nil, xerrors.Errorf("chain contained block marked previously as bad (%s, %s)", from.Cids(), bc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
blockSet = append(blockSet, b)
|
blockSet = append(blockSet, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
acceptedBlocks = append(acceptedBlocks, at...)
|
||||||
|
|
||||||
syncer.syncState.SetHeight(blks[len(blks)-1].Height())
|
syncer.syncState.SetHeight(blks[len(blks)-1].Height())
|
||||||
at = blks[len(blks)-1].Parents()
|
at = blks[len(blks)-1].Parents()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user