Skip to content

Commit 104c01f

Browse files
committed
add last data for empty data
1 parent c918bde commit 104c01f

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

block/internal/syncing/da_retriever.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,10 @@ func (r *DARetriever) createEmptyDataForHeader(ctx context.Context, header *type
299299
return &types.Data{
300300
Txs: make(types.Txs, 0),
301301
Metadata: &types.Metadata{
302-
ChainID: header.ChainID(),
303-
Height: header.Height(),
304-
Time: header.BaseHeader.Time,
302+
ChainID: header.ChainID(),
303+
Height: header.Height(),
304+
Time: header.BaseHeader.Time,
305+
LastDataHash: nil, // LastDataHash must be filled in the syncer, as it is not available here, block n-1 has not been processed yet.
305306
},
306307
}
307308
}

block/internal/syncing/syncer.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,17 @@ func (s *Syncer) processHeightEvent(event *common.DAHeightEvent) {
382382
return
383383
}
384384

385+
// Last data must be got from store if the event comes from DA.
386+
// When if the event comes from P2P, the sequencer and then all the full nodes contains the data.
387+
if event.Source == common.SourceDA && bytes.Equal(event.Header.DataHash, common.DataHashForEmptyTxs) {
388+
_, lastData, err := s.store.GetBlockData(s.ctx, currentHeight)
389+
if err != nil {
390+
s.logger.Error().Err(err).Msg("failed to get last data")
391+
return
392+
}
393+
event.Data.LastDataHash = lastData.Hash()
394+
}
395+
385396
// Try to sync the next block
386397
if err := s.trySyncNextBlock(event); err != nil {
387398
s.logger.Error().Err(err).Msg("failed to sync next block")

0 commit comments

Comments
 (0)