diff --git a/sync/sync.go b/sync/sync.go index f5a9ef2bbd..06eb24d695 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -323,11 +323,13 @@ func (s *Synchronizer) verifierTask(ctx context.Context, block *core.Block, stat // The previous head has been reverted, hence, get the current head and store empty pending block head, err := s.blockchain.HeadsHeader() if err != nil { - s.log.Warnw("Failed to retrieve the head header", "err", err) + s.log.Errorw("Failed to retrieve the head header", "err", err) } - if err := s.storeEmptyPending(head); err != nil { - s.log.Warnw("Failed to store empty pending block", "number", block.Number) + if head != nil { + if err := s.storeEmptyPending(head); err != nil { + s.log.Errorw("Failed to store empty pending block", "number", block.Number) + } } } else { s.log.Warnw("Failed storing Block", "number", block.Number, @@ -338,7 +340,7 @@ func (s *Synchronizer) verifierTask(ctx context.Context, block *core.Block, stat } if err := s.storeEmptyPending(block.Header); err != nil { - s.log.Warnw("Failed to store empty pending block", "number", block.Number) + s.log.Errorw("Failed to store empty pending block", "number", block.Number) } s.listener.OnSyncStepDone(OpStore, block.Number, time.Since(storeTimer)) @@ -673,15 +675,20 @@ func (s *Synchronizer) PendingState() (core.StateReader, func() error, error) { func (s *Synchronizer) storeEmptyPending(latestHeader *core.Header) error { receipts := make([]*core.TransactionReceipt, 0) pendingBlock := &core.Block{ - Header: latestHeader, + Header: &core.Header{ + ParentHash: latestHeader.Hash, + SequencerAddress: latestHeader.SequencerAddress, + Number: latestHeader.Number + 1, + Timestamp: uint64(time.Now().Unix()), + ProtocolVersion: latestHeader.ProtocolVersion, + EventsBloom: core.EventsBloom(receipts), + GasPrice: latestHeader.GasPrice, + GasPriceSTRK: latestHeader.GasPriceSTRK, + }, Transactions: make([]core.Transaction, 0), Receipts: receipts, } - pendingBlock.Number = latestHeader.Number + 1 - pendingBlock.Timestamp = uint64(time.Now().Unix()) - pendingBlock.EventsBloom = core.EventsBloom(receipts) - stateDiff, err := makeStateDiffForEmptyBlock(s.blockchain, latestHeader.Number+1) if err != nil { return err