Skip to content

Commit a256a1c

Browse files
authored
Merge branch 'main' into marko/exchange
2 parents 52762d4 + 2b5a1df commit a256a1c

15 files changed

Lines changed: 65 additions & 23 deletions

File tree

apps/evm/cmd/rollback.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func NewRollbackCmd() *cobra.Command {
3838
}
3939

4040
// evolve db
41-
rawEvolveDB, err := store.NewDefaultKVStore(nodeConfig.RootDir, nodeConfig.DBPath, "evm")
41+
rawEvolveDB, err := store.NewDefaultKVStore(nodeConfig.RootDir, nodeConfig.DBPath, evmDbName)
4242
if err != nil {
4343
return err
4444
}

apps/evm/cmd/run.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import (
2828
"github.com/evstack/ev-node/sequencers/single"
2929
)
3030

31+
const evmDbName = "evm-single"
32+
3133
var RunCmd = &cobra.Command{
3234
Use: "start",
3335
Aliases: []string{"node", "run"},
@@ -60,7 +62,7 @@ var RunCmd = &cobra.Command{
6062
return err
6163
}
6264

63-
datastore, err := store.NewDefaultKVStore(nodeConfig.RootDir, nodeConfig.DBPath, "evm")
65+
datastore, err := store.NewDefaultKVStore(nodeConfig.RootDir, nodeConfig.DBPath, evmDbName)
6466
if err != nil {
6567
return err
6668
}

apps/grpc/cmd/run.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
)
2727

2828
const (
29+
grpcDbName = "grpc-single"
2930
// FlagGrpcExecutorURL is the flag for the gRPC executor endpoint
3031
FlagGrpcExecutorURL = "grpc-executor-url"
3132
)
@@ -63,7 +64,7 @@ The execution client must implement the Evolve execution gRPC interface.`,
6364
}
6465

6566
// Create datastore
66-
datastore, err := store.NewDefaultKVStore(nodeConfig.RootDir, nodeConfig.DBPath, "evgrpc")
67+
datastore, err := store.NewDefaultKVStore(nodeConfig.RootDir, nodeConfig.DBPath, grpcDbName)
6768
if err != nil {
6869
return err
6970
}

apps/testapp/cmd/rollback.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func NewRollbackCmd() *cobra.Command {
3939
}
4040

4141
// evolve db
42-
rawEvolveDB, err := store.NewDefaultKVStore(nodeConfig.RootDir, nodeConfig.DBPath, "testapp")
42+
rawEvolveDB, err := store.NewDefaultKVStore(nodeConfig.RootDir, nodeConfig.DBPath, testDbName)
4343
if err != nil {
4444
return err
4545
}

apps/testapp/cmd/run.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import (
1919
"github.com/evstack/ev-node/sequencers/single"
2020
)
2121

22+
const testDbName = "testapp"
23+
2224
var RunCmd = &cobra.Command{
2325
Use: "start",
2426
Aliases: []string{"node", "run"},
@@ -61,7 +63,7 @@ var RunCmd = &cobra.Command{
6163
return err
6264
}
6365

64-
datastore, err := store.NewDefaultKVStore(nodeConfig.RootDir, nodeConfig.DBPath, "testapp")
66+
datastore, err := store.NewDefaultKVStore(nodeConfig.RootDir, nodeConfig.DBPath, testDbName)
6567
if err != nil {
6668
return err
6769
}

block/internal/submitting/da_submitter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ func submitToDA[T any](
411411

412412
// Record submission result for observability
413413
if daVisualizationServer := server.GetDAVisualizationServer(); daVisualizationServer != nil {
414-
daVisualizationServer.RecordSubmission(&res, 0, uint64(len(items)))
414+
daVisualizationServer.RecordSubmission(&res, 0, uint64(len(items)), namespace)
415415
}
416416

417417
switch res.Code {

execution/evm/test/execution_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build evm
2-
// +build evm
32

43
package test
54

execution/evm/test/test_helpers.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build evm
2-
// +build evm
32

43
package test
54

pkg/rpc/server/da_visualization.go

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type DASubmissionInfo struct {
2929
Message string `json:"message,omitempty"`
3030
NumBlobs uint64 `json:"num_blobs"`
3131
BlobIDs []string `json:"blob_ids,omitempty"`
32+
Namespace string `json:"namespace,omitempty"`
3233
}
3334

3435
// DAVisualizationServer provides DA layer visualization endpoints
@@ -52,7 +53,7 @@ func NewDAVisualizationServer(da coreda.DA, logger zerolog.Logger, isAggregator
5253

5354
// RecordSubmission records a DA submission for visualization
5455
// Only keeps the last 100 submissions in memory for the dashboard display
55-
func (s *DAVisualizationServer) RecordSubmission(result *coreda.ResultSubmit, gasPrice float64, numBlobs uint64) {
56+
func (s *DAVisualizationServer) RecordSubmission(result *coreda.ResultSubmit, gasPrice float64, numBlobs uint64, namespace []byte) {
5657
s.mutex.Lock()
5758
defer s.mutex.Unlock()
5859

@@ -72,6 +73,7 @@ func (s *DAVisualizationServer) RecordSubmission(result *coreda.ResultSubmit, ga
7273
Message: result.Message,
7374
NumBlobs: numBlobs,
7475
BlobIDs: blobIDs,
76+
Namespace: hex.EncodeToString(namespace),
7577
}
7678

7779
// Keep only the last 100 submissions in memory to avoid memory growth
@@ -171,8 +173,49 @@ func (s *DAVisualizationServer) handleDABlobDetails(w http.ResponseWriter, r *ht
171173
ctx, cancel := context.WithTimeout(r.Context(), 10*time.Second)
172174
defer cancel()
173175

174-
// Extract namespace - using empty namespace for now, could be parameterized
175-
namespace := []byte{}
176+
var namespace []byte
177+
found := false
178+
179+
// 1. Check query parameter first
180+
nsParam := r.URL.Query().Get("namespace")
181+
if nsParam != "" {
182+
if ns, err := coreda.ParseHexNamespace(nsParam); err == nil {
183+
namespace = ns.Bytes()
184+
found = true
185+
} else {
186+
ns := coreda.NamespaceFromString(nsParam)
187+
namespace = ns.Bytes()
188+
found = true
189+
}
190+
}
191+
192+
// 2. If not provided in query, try to find in recent submissions
193+
if !found {
194+
s.mutex.RLock()
195+
for _, submission := range s.submissions {
196+
for _, subBlobID := range submission.BlobIDs {
197+
if subBlobID == blobID {
198+
if submission.Namespace != "" {
199+
if ns, err := hex.DecodeString(submission.Namespace); err == nil {
200+
namespace = ns
201+
found = true
202+
}
203+
}
204+
break
205+
}
206+
}
207+
if found {
208+
break
209+
}
210+
}
211+
s.mutex.RUnlock()
212+
}
213+
214+
if !found || len(namespace) == 0 {
215+
http.Error(w, "Namespace required to retrieve blob (not found in recent submissions and not provided in query)", http.StatusBadRequest)
216+
return
217+
}
218+
176219
blobs, err := s.da.Get(ctx, []coreda.ID{id}, namespace)
177220
if err != nil {
178221
s.logger.Error().Err(err).Str("blob_id", blobID).Msg("Failed to retrieve blob from DA")

pkg/rpc/server/da_visualization_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func TestRecordSubmission(t *testing.T) {
4646
},
4747
}
4848

49-
server.RecordSubmission(result, -1, 2)
49+
server.RecordSubmission(result, -1, 2, []byte("test-ns"))
5050

5151
assert.Equal(t, 1, len(server.submissions))
5252
submission := server.submissions[0]
@@ -58,6 +58,7 @@ func TestRecordSubmission(t *testing.T) {
5858
assert.Equal(t, 2, len(submission.BlobIDs))
5959
assert.Equal(t, hex.EncodeToString([]byte("test-id-1")), submission.BlobIDs[0])
6060
assert.Equal(t, hex.EncodeToString([]byte("test-id-2")), submission.BlobIDs[1])
61+
assert.Equal(t, hex.EncodeToString([]byte("test-ns")), submission.Namespace)
6162
}
6263

6364
func TestRecordSubmissionMemoryLimit(t *testing.T) {
@@ -75,7 +76,7 @@ func TestRecordSubmissionMemoryLimit(t *testing.T) {
7576
Timestamp: time.Now(),
7677
},
7778
}
78-
server.RecordSubmission(result, float64(i)*0.1, 1)
79+
server.RecordSubmission(result, float64(i)*0.1, 1, []byte{})
7980
}
8081

8182
// Should only keep the last 100 submissions
@@ -124,9 +125,7 @@ func TestHandleDASubmissions(t *testing.T) {
124125
IDs: [][]byte{[]byte("test-id")},
125126
},
126127
}
127-
server.RecordSubmission(result, 0.5, 1)
128-
129-
// Create test request
128+
server.RecordSubmission(result, 0.5, 1, []byte{})
130129
req, err := http.NewRequest("GET", "/da/submissions", nil)
131130
require.NoError(t, err)
132131

@@ -197,7 +196,7 @@ func TestHandleDAVisualizationHTML(t *testing.T) {
197196
Message: "Test submission",
198197
},
199198
}
200-
server.RecordSubmission(result, 0.5, 1)
199+
server.RecordSubmission(result, 0.5, 1, []byte{})
201200

202201
req, err := http.NewRequest("GET", "/da", nil)
203202
require.NoError(t, err)
@@ -247,7 +246,7 @@ func TestRegisterCustomHTTPEndpointsDAVisualization(t *testing.T) {
247246
Timestamp: time.Now(),
248247
},
249248
}
250-
server.RecordSubmission(result, 0.5, 1)
249+
server.RecordSubmission(result, 0.5, 1, []byte{})
251250

252251
// Set global server
253252
SetDAVisualizationServer(server)

0 commit comments

Comments
 (0)