Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fast sync #839

Merged
merged 1 commit into from
Oct 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/state/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (m *SnapshotManager) createShapshotForVersion(height uint64, version Snapsh

func (m *SnapshotManager) createSnapshot(height uint64) (root common.Hash) {

cidV2, _, filePath := m.createShapshotForVersion(height, SnapshotVersionV2)
cidV2, root, filePath := m.createShapshotForVersion(height, SnapshotVersionV2)
if cidV2 != nil {
m.clearFs([]string{filePath})
m.writeLastManifest(cidV2, root, height, filePath)
Expand Down
2 changes: 1 addition & 1 deletion protocol/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func (d *Downloader) getBestManifest() *snapshot.Manifest {

var best *snapshot.Manifest
for _, m := range manifests {
if (best == nil || best.Height < m.Height) && !d.sm.IsInvalidManifest(m.Cid) {
if (best == nil || best.Height < m.Height) && !d.sm.IsInvalidManifest(m.CidV2) {
best = m
}
}
Expand Down
12 changes: 6 additions & 6 deletions protocol/fast.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,14 +330,14 @@ func (fs *fastSync) postConsuming() error {
return errors.New("preliminary head is lower than manifest's head")
}

if fs.chain.PreliminaryHead.Root() != fs.manifest.Root {
fs.sm.AddInvalidManifest(fs.manifest.Cid)
/* if fs.chain.PreliminaryHead.Root() != fs.manifest.Root {
fs.sm.AddInvalidManifest(fs.manifest.CidV2)
return errors.New("preliminary head's root doesn't equal manifest's root")
}
}*/
fs.log.Info("Start loading of snapshot", "height", fs.manifest.Height)
filePath, version, err := fs.sm.DownloadSnapshot(fs.manifest)
if err != nil {
fs.sm.AddTimeoutManifest(fs.manifest.Cid)
fs.sm.AddTimeoutManifest(fs.manifest.CidV2)
return errors.WithMessage(err, "snapshot's downloading has been failed")
}
fs.log.Info("Snapshot has been loaded", "height", fs.manifest.Height)
Expand All @@ -348,12 +348,12 @@ func (fs *fastSync) postConsuming() error {
}
switch version {
case state.SnapshotVersionV2:
err = fs.appState.State.RecoverSnapshot2(fs.manifest.Height, fs.manifest.Root, file)
err = fs.appState.State.RecoverSnapshot2(fs.manifest.Height, fs.chain.PreliminaryHead.Root(), file)
}

file.Close()
if err != nil {
fs.sm.AddInvalidManifest(fs.manifest.Cid)
fs.sm.AddInvalidManifest(fs.manifest.CidV2)
//TODO : add snapshot to ban list
return err
}
Expand Down