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