mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
eth: explicitly commented the code were bor could get into snap-sync mode (#1243)
* eth: explicitly commented the code were bor could get into snap-sync mode * addressed comment
This commit is contained in:
parent
8fc2a955a2
commit
902c1ce97e
2 changed files with 36 additions and 46 deletions
|
|
@ -178,7 +178,9 @@ func newHandler(config *handlerConfig) (*handler, error) {
|
|||
h.snapSync.Store(true)
|
||||
log.Warn("Switch sync mode from full sync to snap sync", "reason", "snap sync incomplete")
|
||||
} else if !h.chain.HasState(fullBlock.Root) {
|
||||
h.snapSync.Store(true)
|
||||
// TODO - uncomment when we (Polygon-PoS, bor) have snap sync/pbss
|
||||
// For more info - https://github.com/ethereum/go-ethereum/pull/28171
|
||||
// h.snapSync.Store(true)
|
||||
log.Warn("Switch sync mode from full sync to snap sync", "reason", "head state missing")
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
36
eth/sync.go
36
eth/sync.go
|
|
@ -200,15 +200,21 @@ func peerToSyncOp(mode downloader.SyncMode, p *eth.Peer) *chainSyncOp {
|
|||
}
|
||||
|
||||
func (cs *chainSyncer) modeAndLocalHead() (downloader.SyncMode, *big.Int) {
|
||||
// TODO - uncomment when we (Polygon-PoS, bor) have snap sync/pbss
|
||||
/*
|
||||
// If we're in snap sync mode, return that directly
|
||||
if cs.handler.snapSync.Load() {
|
||||
block := cs.handler.chain.CurrentSnapBlock()
|
||||
td := cs.handler.chain.GetTd(block.Hash(), block.Number.Uint64())
|
||||
return downloader.SnapSync, td
|
||||
}
|
||||
*/
|
||||
|
||||
// We are probably in full sync, but we might have rewound to before the
|
||||
// snap sync pivot, check if we should re-enable snap sync.
|
||||
head := cs.handler.chain.CurrentBlock()
|
||||
// TODO - uncomment when we (Polygon-PoS, bor) have snap sync/pbss
|
||||
/*
|
||||
if pivot := rawdb.ReadLastPivotNumber(cs.handler.database); pivot != nil {
|
||||
if head.Number.Uint64() < *pivot {
|
||||
block := cs.handler.chain.CurrentSnapBlock()
|
||||
|
|
@ -216,6 +222,11 @@ func (cs *chainSyncer) modeAndLocalHead() (downloader.SyncMode, *big.Int) {
|
|||
return downloader.SnapSync, td
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// TODO - uncomment when we (Polygon-PoS, bor) have snap sync/pbss
|
||||
// For more info - https://github.com/ethereum/go-ethereum/pull/28171
|
||||
/*
|
||||
// We are in a full sync, but the associated head state is missing. To complete
|
||||
// the head state, forcefully rerun the snap sync. Note it doesn't mean the
|
||||
// persistent state is corrupted, just mismatch with the head block.
|
||||
|
|
@ -225,34 +236,11 @@ func (cs *chainSyncer) modeAndLocalHead() (downloader.SyncMode, *big.Int) {
|
|||
log.Info("Reenabled snap sync as chain is stateless")
|
||||
return downloader.SnapSync, td
|
||||
}
|
||||
*/
|
||||
// Nope, we're really full syncing
|
||||
td := cs.handler.chain.GetTd(head.Hash(), head.Number.Uint64())
|
||||
|
||||
return downloader.FullSync, td
|
||||
// TODO(snap): Uncomment when we have snap sync working
|
||||
// If we're in snap sync mode, return that directly
|
||||
//
|
||||
// if atomic.LoadUint32(&cs.handler.snapSync) == 1 {
|
||||
// block := cs.handler.chain.CurrentFastBlock()
|
||||
// td := cs.handler.chain.GetTd(block.Hash(), block.NumberU64())
|
||||
// return downloader.SnapSync, td
|
||||
// }
|
||||
//
|
||||
// // We are probably in full sync, but we might have rewound to before the
|
||||
// // snap sync pivot, check if we should reenable
|
||||
//
|
||||
// if pivot := rawdb.ReadLastPivotNumber(cs.handler.database); pivot != nil {
|
||||
// if head := cs.handler.chain.CurrentBlock(); head.NumberU64() < *pivot {
|
||||
// block := cs.handler.chain.CurrentFastBlock()
|
||||
// td := cs.handler.chain.GetTd(block.Hash(), block.NumberU64())
|
||||
// return downloader.SnapSync, td
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Nope, we're really full syncing
|
||||
// head := cs.handler.chain.CurrentBlock()
|
||||
// td := cs.handler.chain.GetTd(head.Hash(), head.NumberU64())
|
||||
// return downloader.FullSync, td
|
||||
}
|
||||
|
||||
// startSync launches doSync in a new goroutine.
|
||||
|
|
|
|||
Loading…
Reference in a new issue