@@ -184,28 +184,16 @@ func (c *client) Submit(ctx context.Context, data [][]byte, _ float64, namespace
184184
185185// getBlockTimestamp fetches the block timestamp from the DA layer header.
186186// If the header fetch fails, it falls back to time.Now() and logs a warning.
187- func (c * client ) getBlockTimestamp (ctx context.Context , height uint64 ) time.Time {
188- if c .headerAPI == nil {
189- c .logger .Warn ().Uint64 ("height" , height ).Msg ("header API not available, using current time" )
190- return time .Now ()
191- }
192-
187+ func (c * client ) getBlockTimestamp (ctx context.Context , height uint64 ) (time.Time , error ) {
193188 headerCtx , cancel := context .WithTimeout (ctx , c .defaultTimeout )
194189 defer cancel ()
195190
196191 header , err := c .headerAPI .GetByHeight (headerCtx , height )
197192 if err != nil {
198- c .logger .Warn ().Uint64 ("height" , height ).Err (err ).Msg ("failed to get header timestamp, using current time" )
199- return time .Now ()
200- }
201-
202- blockTime := header .Time ()
203- if blockTime .IsZero () {
204- c .logger .Warn ().Uint64 ("height" , height ).Msg ("header timestamp is zero, using current time" )
205- return time .Now ()
193+ return time.Time {}, fmt .Errorf ("failed to get header timestamp for block %d: %w" , height , err )
206194 }
207195
208- return blockTime
196+ return header . Time (), nil
209197}
210198
211199// Retrieve retrieves blobs from the DA layer at the specified height and namespace.
@@ -234,7 +222,12 @@ func (c *client) Retrieve(ctx context.Context, height uint64, namespace []byte)
234222 case strings .Contains (err .Error (), datypes .ErrBlobNotFound .Error ()):
235223 c .logger .Debug ().Uint64 ("height" , height ).Msg ("No blobs found at height" )
236224 // Fetch block timestamp for deterministic responses using parent context
237- blockTime := c .getBlockTimestamp (ctx , height )
225+ blockTime , err := c .getBlockTimestamp (ctx , height )
226+ if err != nil {
227+ c .logger .Error ().Uint64 ("height" , height ).Err (err ).Msg ("failed to get block timestamp" )
228+ // TODO: we should retry fetching the timestamp.
229+ }
230+
238231 return datypes.ResultRetrieve {
239232 BaseResult : datypes.BaseResult {
240233 Code : datypes .StatusNotFound ,
@@ -266,7 +259,11 @@ func (c *client) Retrieve(ctx context.Context, height uint64, namespace []byte)
266259 }
267260
268261 // Fetch block timestamp for deterministic responses using parent context
269- blockTime := c .getBlockTimestamp (ctx , height )
262+ blockTime , err := c .getBlockTimestamp (ctx , height )
263+ if err != nil {
264+ c .logger .Error ().Uint64 ("height" , height ).Err (err ).Msg ("failed to get block timestamp" )
265+ // TODO: we should retry fetching the timestamp.
266+ }
270267
271268 if len (blobs ) == 0 {
272269 c .logger .Debug ().Uint64 ("height" , height ).Msg ("No blobs found at height" )
0 commit comments