Skip to content

Commit e7ae5e6

Browse files
committed
simplify clients
1 parent 5c48ddb commit e7ae5e6

File tree

12 files changed

+119
-178
lines changed

12 files changed

+119
-178
lines changed

.mockery.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@ packages:
7676
dir: ./test/mocks
7777
pkgname: mocks
7878
filename: da.go
79-
Verifier:
80-
config:
81-
dir: ./test/mocks
82-
pkgname: mocks
83-
filename: da.go
8479
github.com/evstack/ev-node/pkg/da/node:
8580
interfaces:
8681
BlobModule:

apps/evm/cmd/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func createSequencer(
148148
datastore datastore.Batching,
149149
nodeConfig config.Config,
150150
genesis genesis.Genesis,
151-
daClient block.FullDAClient,
151+
daClient block.DAClient,
152152
executor execution.Executor,
153153
) (coresequencer.Sequencer, error) {
154154
if nodeConfig.Node.BasedSequencer {

block/internal/da/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ type client struct {
2929
hasForcedNamespace bool
3030
}
3131

32-
// Ensure client implements the FullClient interface.
33-
var _ FullClient = (*client)(nil)
32+
// Ensure client implements the Client interface.
33+
var _ Client = (*client)(nil)
3434

3535
// NewClient creates a new unified DA client wrapper.
36-
func NewClient(cfg Config) FullClient {
36+
func NewClient(cfg Config) Client {
3737
if cfg.Client == nil {
3838
return nil
3939
}

block/internal/da/interface.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import (
66
datypes "github.com/evstack/ev-node/pkg/da/types"
77
)
88

9-
// Client represents the DA client contract.
9+
// Client defines the complete interface for DA layer operations.
10+
// This is the interface implemented by the concrete DA client.
1011
type Client interface {
1112
// Submit submits blobs to the DA layer.
1213
Submit(ctx context.Context, data [][]byte, gasPrice float64, namespace []byte, options []byte) datypes.ResultSubmit
@@ -25,21 +26,10 @@ type Client interface {
2526
GetDataNamespace() []byte
2627
GetForcedInclusionNamespace() []byte
2728
HasForcedInclusionNamespace() bool
28-
}
2929

30-
// Verifier defines the interface for DA proof verification operations.
31-
// This is a subset of the DA interface used by sequencers to verify batch inclusion.
32-
type Verifier interface {
3330
// GetProofs returns inclusion Proofs for Blobs specified by their IDs.
3431
GetProofs(ctx context.Context, ids []datypes.ID, namespace []byte) ([]datypes.Proof, error)
3532

3633
// Validate validates Commitments against the corresponding Proofs.
3734
Validate(ctx context.Context, ids []datypes.ID, proofs []datypes.Proof, namespace []byte) ([]bool, error)
3835
}
39-
40-
// FullClient combines Client and Verifier interfaces.
41-
// This is the complete interface implemented by the concrete DA client.
42-
type FullClient interface {
43-
Client
44-
Verifier
45-
}

block/internal/da/tracing.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ import (
1212
datypes "github.com/evstack/ev-node/pkg/da/types"
1313
)
1414

15-
// tracedClient decorates a FullClient with OpenTelemetry spans.
15+
// tracedClient decorates a Client with OpenTelemetry spans.
1616
type tracedClient struct {
17-
inner FullClient
17+
inner Client
1818
tracer trace.Tracer
1919
}
2020

2121
// WithTracingClient decorates the provided client with tracing spans.
22-
func WithTracingClient(inner FullClient) FullClient {
22+
func WithTracingClient(inner Client) Client {
2323
return &tracedClient{inner: inner, tracer: otel.Tracer("ev-node/da")}
2424
}
2525

block/internal/da/tracing_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (m *mockFullClient) GetForcedInclusionNamespace() []byte { return []byte{0x
6363
func (m *mockFullClient) HasForcedInclusionNamespace() bool { return true }
6464

6565
// setup a tracer provider + span recorder
66-
func setupDATrace(t *testing.T, inner FullClient) (FullClient, *tracetest.SpanRecorder) {
66+
func setupDATrace(t *testing.T, inner Client) (Client, *tracetest.SpanRecorder) {
6767
t.Helper()
6868
sr := tracetest.NewSpanRecorder()
6969
tp := sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(sr))

block/public.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,12 @@ func NopMetrics() *Metrics {
3535
// DAClient is the interface representing the DA client for public use.
3636
type DAClient = da.Client
3737

38-
// DAVerifier is the interface for DA proof verification operations.
39-
type DAVerifier = da.Verifier
40-
41-
// FullDAClient combines DAClient and DAVerifier interfaces.
42-
// This is the complete interface implemented by the concrete DA client.
43-
type FullDAClient = da.FullClient
44-
4538
// NewDAClient creates a new DA client backed by the provided BlobClient implementation.
46-
// The returned client implements both DAClient and DAVerifier interfaces.
4739
func NewDAClient(
4840
client datypes.BlobClient,
4941
config config.Config,
5042
logger zerolog.Logger,
51-
) FullDAClient {
43+
) DAClient {
5244
base := da.NewClient(da.Config{
5345
Client: client,
5446
Logger: logger,

pkg/sequencers/based/sequencer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ type BasedSequencer struct {
4141

4242
// NewBasedSequencer creates a new based sequencer instance
4343
func NewBasedSequencer(
44-
daClient block.FullDAClient,
44+
daClient block.DAClient,
4545
cfg config.Config,
4646
db ds.Batching,
4747
genesis genesis.Genesis,

pkg/sequencers/based/sequencer_test.go

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ import (
2222
"github.com/evstack/ev-node/test/mocks"
2323
)
2424

25-
// MockFullDAClient combines MockClient and MockVerifier to implement FullDAClient
26-
type MockFullDAClient struct {
25+
// MockDAClient wraps MockClient for the consolidated Client interface
26+
type MockDAClient struct {
2727
*mocks.MockClient
28-
*mocks.MockVerifier
2928
}
3029

3130
// createDefaultMockExecutor creates a MockExecutor with default passthrough behavior for FilterTxs and GetExecutionInfo
@@ -64,9 +63,8 @@ func createTestSequencer(t *testing.T, mockRetriever *common.MockForcedInclusion
6463
db := syncds.MutexWrap(ds.NewMapDatastore())
6564

6665
// Create mock DA client
67-
mockDAClient := &MockFullDAClient{
66+
mockDAClient := &MockDAClient{
6867
MockClient: mocks.NewMockClient(t),
69-
MockVerifier: mocks.NewMockVerifier(t),
7068
}
7169
// Mock the forced inclusion namespace call
7270
mockDAClient.MockClient.On("GetForcedInclusionNamespace").Return([]byte("test-forced-inclusion-ns")).Maybe()
@@ -462,9 +460,8 @@ func TestBasedSequencer_CheckpointPersistence(t *testing.T) {
462460
db := syncds.MutexWrap(ds.NewMapDatastore())
463461

464462
// Create mock DA client
465-
mockDAClient := &MockFullDAClient{
463+
mockDAClient := &MockDAClient{
466464
MockClient: mocks.NewMockClient(t),
467-
MockVerifier: mocks.NewMockVerifier(t),
468465
}
469466
mockDAClient.MockClient.On("GetForcedInclusionNamespace").Return([]byte("test-forced-inclusion-ns")).Maybe()
470467
mockDAClient.MockClient.On("HasForcedInclusionNamespace").Return(true).Maybe()
@@ -489,9 +486,8 @@ func TestBasedSequencer_CheckpointPersistence(t *testing.T) {
489486
assert.Equal(t, 2, len(resp.Batch.Transactions))
490487

491488
// Create a new sequencer with the same datastore (simulating restart)
492-
mockDAClient2 := &MockFullDAClient{
489+
mockDAClient2 := &MockDAClient{
493490
MockClient: mocks.NewMockClient(t),
494-
MockVerifier: mocks.NewMockVerifier(t),
495491
}
496492
mockDAClient2.MockClient.On("GetForcedInclusionNamespace").Return([]byte("test-forced-inclusion-ns")).Maybe()
497493
mockDAClient2.MockClient.On("HasForcedInclusionNamespace").Return(true).Maybe()
@@ -534,9 +530,8 @@ func TestBasedSequencer_CrashRecoveryMidEpoch(t *testing.T) {
534530
db := syncds.MutexWrap(ds.NewMapDatastore())
535531

536532
// Create mock DA client
537-
mockDAClient := &MockFullDAClient{
533+
mockDAClient := &MockDAClient{
538534
MockClient: mocks.NewMockClient(t),
539-
MockVerifier: mocks.NewMockVerifier(t),
540535
} // On restart, the epoch is re-fetched but we must NOT reset TxIndex
541536

542537
mockDAClient.MockClient.On("GetForcedInclusionNamespace").Return([]byte("test-forced-inclusion-ns")).Maybe()
@@ -595,9 +590,8 @@ func TestBasedSequencer_CrashRecoveryMidEpoch(t *testing.T) {
595590
// === SIMULATE CRASH: Create new sequencer with same DB ===
596591
// The in-memory cache is lost, but checkpoint is persisted
597592

598-
mockDAClient2 := &MockFullDAClient{
593+
mockDAClient2 := &MockDAClient{
599594
MockClient: mocks.NewMockClient(t),
600-
MockVerifier: mocks.NewMockVerifier(t),
601595
}
602596
mockDAClient2.MockClient.On("GetForcedInclusionNamespace").Return([]byte("test-forced-inclusion-ns")).Maybe()
603597
mockDAClient2.MockClient.On("HasForcedInclusionNamespace").Return(true).Maybe()
@@ -917,9 +911,8 @@ func TestBasedSequencer_GetNextBatch_GasFilteringPreservesUnprocessedTxs(t *test
917911

918912
// Create sequencer with custom executor
919913
db := syncds.MutexWrap(ds.NewMapDatastore())
920-
mockDAClient := &MockFullDAClient{
914+
mockDAClient := &MockDAClient{
921915
MockClient: mocks.NewMockClient(t),
922-
MockVerifier: mocks.NewMockVerifier(t),
923916
}
924917
mockDAClient.MockClient.On("GetForcedInclusionNamespace").Return([]byte("test-forced-inclusion-ns")).Maybe()
925918
mockDAClient.MockClient.On("HasForcedInclusionNamespace").Return(true).Maybe()

pkg/sequencers/single/sequencer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ type Sequencer struct {
3636
cfg config.Config
3737

3838
Id []byte
39-
daClient block.FullDAClient
39+
daClient block.DAClient
4040

4141
batchTime time.Duration
4242
queue *BatchQueue // single queue for immediate availability
@@ -57,7 +57,7 @@ type Sequencer struct {
5757
func NewSequencer(
5858
logger zerolog.Logger,
5959
db ds.Batching,
60-
daClient block.FullDAClient,
60+
daClient block.DAClient,
6161
cfg config.Config,
6262
id []byte,
6363
maxQueueSize int,

0 commit comments

Comments
 (0)