mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +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)
|
h.snapSync.Store(true)
|
||||||
log.Warn("Switch sync mode from full sync to snap sync", "reason", "snap sync incomplete")
|
log.Warn("Switch sync mode from full sync to snap sync", "reason", "snap sync incomplete")
|
||||||
} else if !h.chain.HasState(fullBlock.Root) {
|
} 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")
|
log.Warn("Switch sync mode from full sync to snap sync", "reason", "head state missing")
|
||||||
}
|
}
|
||||||
} else {
|
} 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) {
|
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 we're in snap sync mode, return that directly
|
||||||
if cs.handler.snapSync.Load() {
|
if cs.handler.snapSync.Load() {
|
||||||
block := cs.handler.chain.CurrentSnapBlock()
|
block := cs.handler.chain.CurrentSnapBlock()
|
||||||
td := cs.handler.chain.GetTd(block.Hash(), block.Number.Uint64())
|
td := cs.handler.chain.GetTd(block.Hash(), block.Number.Uint64())
|
||||||
return downloader.SnapSync, td
|
return downloader.SnapSync, td
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// We are probably in full sync, but we might have rewound to before the
|
// 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.
|
// snap sync pivot, check if we should re-enable snap sync.
|
||||||
head := cs.handler.chain.CurrentBlock()
|
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 pivot := rawdb.ReadLastPivotNumber(cs.handler.database); pivot != nil {
|
||||||
if head.Number.Uint64() < *pivot {
|
if head.Number.Uint64() < *pivot {
|
||||||
block := cs.handler.chain.CurrentSnapBlock()
|
block := cs.handler.chain.CurrentSnapBlock()
|
||||||
|
|
@ -216,6 +222,11 @@ func (cs *chainSyncer) modeAndLocalHead() (downloader.SyncMode, *big.Int) {
|
||||||
return downloader.SnapSync, td
|
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
|
// 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
|
// the head state, forcefully rerun the snap sync. Note it doesn't mean the
|
||||||
// persistent state is corrupted, just mismatch with the head block.
|
// 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")
|
log.Info("Reenabled snap sync as chain is stateless")
|
||||||
return downloader.SnapSync, td
|
return downloader.SnapSync, td
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// Nope, we're really full syncing
|
// Nope, we're really full syncing
|
||||||
td := cs.handler.chain.GetTd(head.Hash(), head.Number.Uint64())
|
td := cs.handler.chain.GetTd(head.Hash(), head.Number.Uint64())
|
||||||
|
|
||||||
return downloader.FullSync, td
|
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.
|
// startSync launches doSync in a new goroutine.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue