Skip to content

Commit

Permalink
fix:meerevm continue snap-sync when reboot
Browse files Browse the repository at this point in the history
  • Loading branch information
lochjin committed Dec 23, 2024
1 parent 9e6065a commit 8294c10
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
14 changes: 8 additions & 6 deletions core/blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,15 @@ func (b *BlockChain) Start() error {
b.wg.Add(1)
go b.handler()

// prepare evm env
mainTip := b.bd.GetMainChainTip()
evmHead, err := b.meerChain.PrepareEnvironment(mainTip.GetState())
if err != nil {
return err
if !b.IsSnapSyncing() {
// prepare evm env
mainTip := b.bd.GetMainChainTip()
evmHead, err := b.meerChain.PrepareEnvironment(mainTip.GetState())
if err != nil {
return err
}
log.Info("prepare evm environment", "mainTipOrder", mainTip.GetOrder(), "mainTipHash", mainTip.GetHash().String(), "hash", evmHead.Hash().String(), "number", evmHead.Number.Uint64(), "root", evmHead.Root.String())
}
log.Info("prepare evm environment", "mainTipOrder", mainTip.GetOrder(), "mainTipHash", mainTip.GetHash().String(), "hash", evmHead.Hash().String(), "number", evmHead.Number.Uint64(), "root", evmHead.Root.String())

return b.DB().Snapshot()
}
Expand Down
2 changes: 2 additions & 0 deletions p2p/synch/peersync.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func (ps *PeerSync) Stop() error {
ps.wg.Wait()

log.Info("P2P PeerSync Stoped")
ps.saveSnapSync()
return nil
}

Expand Down Expand Up @@ -765,5 +766,6 @@ func NewPeerSync(sy *Sync) *PeerSync {
interrupt: make(chan struct{}),
lastBlockID: meerdag.MaxId,
}
peerSync.loadSnapSync()
return peerSync
}
2 changes: 1 addition & 1 deletion p2p/synch/snapstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func (ss *SnapStatus) Decode(data []byte) error {
if err != nil {
return err
}
ss.peid, err = peer.Decode(string(peid))
ss.peid, err = peer.IDFromBytes(peid)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion p2p/synch/snapsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func (ps *PeerSync) loadSnapSync() {
}
snapStatus.syncPoint = ps.Chain().BlockDAG().GetBlockById(uint(snapStatus.PointID))
if snapStatus.syncPoint == nil {
log.Error("Can't find snap status point", "id", snapStatus.PointID)
return
}
ps.snapStatus = snapStatus
Expand All @@ -51,7 +52,6 @@ func (ps *PeerSync) loadSnapSync() {
log.Info("End snap-sync", "err", err.Error())
return
}

}

func (ps *PeerSync) saveSnapSync() {
Expand Down

0 comments on commit 8294c10

Please sign in to comment.