Skip to content

Commit d4d6fc3

Browse files
committed
updates
1 parent 5e77da5 commit d4d6fc3

File tree

4 files changed

+13
-26
lines changed

4 files changed

+13
-26
lines changed

block/errors.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package block
22

33
import (
44
"errors"
5-
"fmt"
65
)
76

87
// These errors are used by Manager.
@@ -19,16 +18,3 @@ var (
1918
// ErrHeightFromFutureStr is the error message for height from future returned by da
2019
ErrHeightFromFutureStr = errors.New("given height is from the future")
2120
)
22-
23-
// SaveBlockError is returned on failure to save block data
24-
type SaveBlockError struct {
25-
Err error
26-
}
27-
28-
func (e SaveBlockError) Error() string {
29-
return fmt.Sprintf("failed to save block: %v", e.Err)
30-
}
31-
32-
func (e SaveBlockError) Unwrap() error {
33-
return e.Err
34-
}

block/lazy_aggregation_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func TestLazyAggregationLoop_BlockTimerTrigger(t *testing.T) {
9999
defer wg.Done()
100100
blockTimer := time.NewTimer(0) // Fire immediately first time
101101
defer blockTimer.Stop()
102-
m.lazyAggregationLoop(ctx, blockTimer)
102+
require.NoError(m.lazyAggregationLoop(ctx, blockTimer))
103103
}()
104104

105105
// Wait for at least one block to be published
@@ -137,7 +137,7 @@ func TestLazyAggregationLoop_LazyTimerTrigger(t *testing.T) {
137137
// Use real timers for this test
138138
blockTimer := time.NewTimer(0) // Fire immediately first time
139139
defer blockTimer.Stop()
140-
m.lazyAggregationLoop(ctx, blockTimer)
140+
require.NoError(m.lazyAggregationLoop(ctx, blockTimer))
141141
}()
142142

143143
// Wait for the first publish call triggered by the initial immediate lazyTimer fire
@@ -186,7 +186,7 @@ func TestLazyAggregationLoop_PublishError(t *testing.T) {
186186
// Use real timers
187187
blockTimer := time.NewTimer(0)
188188
defer blockTimer.Stop()
189-
m.lazyAggregationLoop(ctx, blockTimer)
189+
require.Error(m.lazyAggregationLoop(ctx, blockTimer))
190190
}()
191191

192192
// Wait for the first publish attempt (which will fail)
@@ -267,7 +267,7 @@ func TestLazyAggregationLoop_TxNotification(t *testing.T) {
267267
// Start with a timer that won't fire immediately
268268
blockTimer := time.NewTimer(blockTime)
269269
defer blockTimer.Stop()
270-
m.lazyAggregationLoop(ctx, blockTimer)
270+
require.NoError(m.lazyAggregationLoop(ctx, blockTimer))
271271
}()
272272

273273
// Wait for the initial lazy timer to fire and publish a block
@@ -342,7 +342,7 @@ func TestEmptyBlockCreation(t *testing.T) {
342342
defer blockTimer.Stop()
343343

344344
// Call produceBlock directly to test empty block creation
345-
m.produceBlock(ctx, "test_trigger", lazyTimer, blockTimer)
345+
require.NoError(m.produceBlock(ctx, "test_trigger", lazyTimer, blockTimer))
346346

347347
// Verify that the context was passed correctly
348348
require.NotNil(capturedCtx, "Context should have been captured by mock publish function")
@@ -370,7 +370,7 @@ func TestNormalAggregationLoop_TxNotification(t *testing.T) {
370370
defer wg.Done()
371371
blockTimer := time.NewTimer(blockTime)
372372
defer blockTimer.Stop()
373-
m.normalAggregationLoop(ctx, blockTimer)
373+
require.NoError(m.normalAggregationLoop(ctx, blockTimer))
374374
}()
375375

376376
// Wait for the first block to be published by the timer

block/manager.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,8 @@ func (m *Manager) publishBlockInternal(ctx context.Context) error {
507507
}
508508

509509
if m.config.Node.MaxPendingHeaders != 0 && m.pendingHeaders.numPendingHeaders() >= m.config.Node.MaxPendingHeaders {
510-
return fmt.Errorf("refusing to create block: pending blocks [%d] reached limit [%d]",
511-
m.pendingHeaders.numPendingHeaders(), m.config.Node.MaxPendingHeaders)
510+
m.logger.Warn("refusing to create block: pending blocks [%d] reached limit [%d]", m.pendingHeaders.numPendingHeaders(), m.config.Node.MaxPendingHeaders)
511+
return nil
512512
}
513513

514514
var (
@@ -566,7 +566,8 @@ func (m *Manager) publishBlockInternal(ctx context.Context) error {
566566
}
567567
m.logger.Info("Creating empty block", "height", newHeight)
568568
} else {
569-
return fmt.Errorf("failed to get transactions from batch: %w", err)
569+
m.logger.Warn("failed to get transactions from batch", "error", err)
570+
return nil
570571
}
571572
} else {
572573
if batchData.Before(lastHeaderTime) {
@@ -582,7 +583,7 @@ func (m *Manager) publishBlockInternal(ctx context.Context) error {
582583
}
583584

584585
if err = m.store.SaveBlockData(ctx, header, data, &signature); err != nil {
585-
return SaveBlockError{err}
586+
return fmt.Errorf("failed to save block: %w", err)
586587
}
587588
}
588589

@@ -624,7 +625,7 @@ func (m *Manager) publishBlockInternal(ctx context.Context) error {
624625
// SaveBlock commits the DB tx
625626
err = m.store.SaveBlockData(ctx, header, data, &signature)
626627
if err != nil {
627-
return SaveBlockError{err}
628+
return fmt.Errorf("failed to save block: %w", err)
628629
}
629630

630631
// Update the store height before submitting to the DA layer but after committing to the DB

block/sync.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func (m *Manager) trySyncNextBlock(ctx context.Context, daHeight uint64) error {
163163
}
164164

165165
if err = m.store.SaveBlockData(ctx, h, d, &h.Signature); err != nil {
166-
return SaveBlockError{err}
166+
return fmt.Errorf("failed to save block: %w", err)
167167
}
168168

169169
// Height gets updated

0 commit comments

Comments
 (0)