Skip to content

Commit 2e3472f

Browse files
committed
extract errors
1 parent cb3135d commit 2e3472f

5 files changed

Lines changed: 9 additions & 20 deletions

File tree

block/internal/common/errors.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,7 @@ var (
2020

2121
// ErrOversizedItem is an unrecoverable error indicating a single item exceeds DA blob size limit
2222
ErrOversizedItem = errors.New("single item exceeds DA blob size limit")
23+
24+
// ErrForceInclusionNotConfigured is returned when the forced inclusion namespace is not configured.
25+
ErrForceInclusionNotConfigured = errors.New("forced inclusion namespace not configured")
2326
)

block/internal/syncing/da_retriever.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,6 @@ func (r *daRetriever) RetrieveFromDA(ctx context.Context, daHeight uint64) ([]co
109109
return r.processBlobs(ctx, blobsResp.Data, daHeight), nil
110110
}
111111

112-
var (
113-
// ErrForceInclusionNotConfigured is returned when the forced inclusion namespace is not configured.
114-
ErrForceInclusionNotConfigured = errors.New("forced inclusion namespace not configured")
115-
116-
// ErrForcedInclusionDataTooLarge is returned when forced inclusion data exceeds the maximum blob size.
117-
ErrForcedInclusionDataTooLarge = errors.New("forced inclusion data exceeds maximum blob size limit")
118-
)
119-
120112
// RetrieveForcedIncludedTxsFromDA retrieves forced inclusion transactions from the DA layer.
121113
//
122114
// Behavior:
@@ -132,7 +124,7 @@ var (
132124
// - Error if forced inclusion is not configured or DA layer is unavailable
133125
func (r *daRetriever) RetrieveForcedIncludedTxsFromDA(ctx context.Context, daHeight uint64) (*common.ForcedIncludedEvent, error) {
134126
if !r.hasForcedInclusionNs {
135-
return nil, ErrForceInclusionNotConfigured
127+
return nil, common.ErrForceInclusionNotConfigured
136128
}
137129

138130
// Calculate deterministic epoch boundaries
@@ -306,7 +298,7 @@ func (r *daRetriever) processForcedInclusionBlobs(
306298
Int("blob_size", dataSize).
307299
Float64("max_size", common.DefaultMaxBlobSize).
308300
Msg("forced inclusion blob exceeds maximum size - skipping")
309-
return fmt.Errorf("%w: blob size %d exceeds maximum %f", ErrForcedInclusionDataTooLarge, dataSize, common.DefaultMaxBlobSize)
301+
return fmt.Errorf("blob size %d exceeds maximum %f", dataSize, common.DefaultMaxBlobSize)
310302
}
311303

312304
// Check if adding this blob would exceed the current epoch's max size

block/internal/syncing/syncer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ func (s *Syncer) verifyForcedInclusionTxs(currentState types.State, data *types.
689689
// Retrieve forced inclusion transactions from DA
690690
forcedIncludedTxsEvent, err := s.daRetriever.RetrieveForcedIncludedTxsFromDA(s.ctx, currentState.DAHeight)
691691
if err != nil {
692-
if errors.Is(err, ErrForceInclusionNotConfigured) {
692+
if errors.Is(err, common.ErrForceInclusionNotConfigured) {
693693
s.logger.Debug().Msg("forced inclusion namespace not configured, skipping verification")
694694
return nil
695695
}

sequencers/based/based.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,18 @@ package based
33
import (
44
"context"
55
"errors"
6-
"strings"
76
"sync"
87
"time"
98

109
"github.com/rs/zerolog"
1110

11+
"github.com/evstack/ev-node/block/internal/common"
1212
coreda "github.com/evstack/ev-node/core/da"
1313
coresequencer "github.com/evstack/ev-node/core/sequencer"
1414
"github.com/evstack/ev-node/pkg/config"
1515
"github.com/evstack/ev-node/pkg/genesis"
1616
)
1717

18-
// ErrForceInclusionNotConfigured is returned when forced inclusion is not configured
19-
var ErrForceInclusionNotConfigured = errors.New("forced inclusion namespace not configured")
20-
2118
// ForcedInclusionEvent represents forced inclusion transactions retrieved from DA
2219
type ForcedInclusionEvent = struct {
2320
Txs [][]byte
@@ -100,7 +97,7 @@ func (s *BasedSequencer) GetNextBatch(ctx context.Context, req coresequencer.Get
10097

10198
forcedTxsEvent, err := s.daRetriever.RetrieveForcedIncludedTxsFromDA(ctx, s.daHeight)
10299
if err != nil {
103-
if strings.Contains(err.Error(), ErrForceInclusionNotConfigured.Error()) {
100+
if errors.Is(err, common.ErrForceInclusionNotConfigured) {
104101
s.logger.Error().Msg("forced inclusion not configured, returning empty batch")
105102
return &coresequencer.GetNextBatchResponse{
106103
Batch: &coresequencer.Batch{Transactions: nil},

sequencers/single/sequencer.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"context"
66
"errors"
77
"fmt"
8-
"strings"
98
"sync"
109
"time"
1110

@@ -20,8 +19,6 @@ import (
2019
var (
2120
// ErrInvalidId is returned when the chain id is invalid
2221
ErrInvalidId = errors.New("invalid chain id")
23-
// ErrForceInclusionNotConfigured is returned when forced inclusion is not configured
24-
ErrForceInclusionNotConfigured = errors.New("forced inclusion namespace not configured")
2522
)
2623

2724
// ForcedInclusionEvent represents forced inclusion transactions retrieved from DA
@@ -141,7 +138,7 @@ func (c *Sequencer) GetNextBatch(ctx context.Context, req coresequencer.GetNextB
141138
forcedEvent, err := c.daRetriever.RetrieveForcedIncludedTxsFromDA(ctx, currentDAHeight)
142139
if err != nil {
143140
// If forced inclusion is not configured, continue without forced txs
144-
if !strings.Contains(err.Error(), ErrForceInclusionNotConfigured.Error()) {
141+
if !errors.Is(err, common.ErrForceInclusionNotConfigured) {
145142
// If we get a height from future error, keep the current DA height and return batch
146143
// We'll retry the same height on the next call until DA produces that block
147144
if errors.Is(err, coreda.ErrHeightFromFuture) {

0 commit comments

Comments
 (0)