Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
IronGauntlets committed Jan 14, 2025
1 parent aeb9d65 commit 837d562
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Check warning on line 332 in sync/sync.go

View check run for this annotation

Codecov / codecov/patch

sync/sync.go#L331-L332

Added lines #L331 - L332 were not covered by tests
}
} else {
s.log.Warnw("Failed storing Block", "number", block.Number,
Expand All @@ -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)
}

Check warning on line 344 in sync/sync.go

View check run for this annotation

Codecov / codecov/patch

sync/sync.go#L343-L344

Added lines #L343 - L344 were not covered by tests

s.listener.OnSyncStepDone(OpStore, block.Number, time.Since(storeTimer))
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 837d562

Please sign in to comment.