Skip to content

Commit 4360e64

Browse files
committed
improve logs
1 parent d8df97d commit 4360e64

File tree

2 files changed

+4
-32
lines changed

2 files changed

+4
-32
lines changed

block/retriever_da.go

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,16 @@ func (m *Manager) processBlobs(ctx context.Context, blobs [][]byte, daHeight uin
132132
if data == nil {
133133
if bytes.Equal(header.DataHash, dataHashForEmptyTxs) || len(header.DataHash) == 0 {
134134
// Header expects empty data, create it
135-
data = m.createEmptyData(header)
135+
data = m.createEmptyDataForHeader(ctx, header)
136136
} else {
137137
// Check if header's DataHash matches the hash of empty data
138-
emptyData := m.createEmptyData(header)
138+
emptyData := m.createEmptyDataForHeader(ctx, header)
139139
emptyDataHash := emptyData.Hash()
140140
if bytes.Equal(header.DataHash, emptyDataHash) {
141141
data = emptyData
142142
} else {
143143
// Header expects data but no data found - skip for now
144-
m.logger.Debug().Uint64("height", height).Uint64("daHeight", daHeight).Msg("header found but no matching data")
144+
m.logger.Debug().Uint64("height", height).Uint64("daHeight", daHeight).Msg("header found but no matching data yet")
145145
continue
146146
}
147147
}
@@ -221,34 +221,6 @@ func (m *Manager) tryDecodeData(bz []byte, daHeight uint64) *types.Data {
221221
return &signedData.Data
222222
}
223223

224-
// createEmptyData creates empty data for headers with empty data hash
225-
func (m *Manager) createEmptyData(header *types.SignedHeader) *types.Data {
226-
headerHeight := header.Height()
227-
var lastDataHash types.Hash
228-
229-
if headerHeight > 1 {
230-
ctx := context.Background()
231-
_, lastData, err := m.store.GetBlockData(ctx, headerHeight-1)
232-
if err != nil {
233-
// This is expected in tests and when syncing - just use empty hash
234-
m.logger.Debug().Uint64("current_height", headerHeight).Uint64("previous_height", headerHeight-1).Err(err).Msg("previous block not available, using empty last data hash")
235-
} else if lastData != nil {
236-
lastDataHash = lastData.Hash()
237-
}
238-
}
239-
240-
metadata := &types.Metadata{
241-
ChainID: header.ChainID(),
242-
Height: headerHeight,
243-
Time: header.BaseHeader.Time,
244-
LastDataHash: lastDataHash,
245-
}
246-
247-
return &types.Data{
248-
Metadata: metadata,
249-
}
250-
}
251-
252224
func (m *Manager) waitForHeight(ctx context.Context, height uint64) error {
253225
for {
254226
currentHeight, err := m.GetStoreHeight(ctx)

block/retriever_store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func (m *Manager) createEmptyDataForHeader(ctx context.Context, header *types.Si
190190
if headerHeight > 1 {
191191
_, lastData, err := m.store.GetBlockData(ctx, headerHeight-1)
192192
if err != nil {
193-
m.logger.Debug().Uint64("current_height", headerHeight).Uint64("previous_height", headerHeight-1).Err(err).Msg("previous block not applied yet")
193+
m.logger.Debug().Uint64("current_height", headerHeight).Uint64("previous_height", headerHeight-1).Msg(fmt.Sprintf("previous block not available, using empty last data hash: %s", err.Error()))
194194
}
195195
if lastData != nil {
196196
lastDataHash = lastData.Hash()

0 commit comments

Comments
 (0)