Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions pkg/rpc/server/da_visualization.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (s *DAVisualizationServer) handleDASubmissions(w http.ResponseWriter, r *ht

// If not an aggregator, return empty submissions with a message
if !s.isAggregator {
response := map[string]interface{}{
response := map[string]any{
"is_aggregator": false,
"submissions": []DASubmissionInfo{},
"total": 0,
Expand All @@ -139,7 +139,7 @@ func (s *DAVisualizationServer) handleDASubmissions(w http.ResponseWriter, r *ht
}

// Build response
response := map[string]interface{}{
response := map[string]any{
"submissions": reversed,
"total": len(reversed),
}
Expand Down Expand Up @@ -192,7 +192,7 @@ func (s *DAVisualizationServer) handleDABlobDetails(w http.ResponseWriter, r *ht
}

blob := blobs[0]
response := map[string]interface{}{
response := map[string]any{
"id": blobID,
"height": height,
"commitment": hex.EncodeToString(commitment),
Expand All @@ -215,7 +215,7 @@ func (s *DAVisualizationServer) handleDAStats(w http.ResponseWriter, r *http.Req

// If not an aggregator, return empty stats
if !s.isAggregator {
stats := map[string]interface{}{
stats := map[string]any{
"is_aggregator": false,
"total_submissions": 0,
"message": "This node is not an aggregator and does not submit to the DA layer",
Expand Down Expand Up @@ -264,15 +264,15 @@ func (s *DAVisualizationServer) handleDAStats(w http.ResponseWriter, r *http.Req
lastSubmission = &s.submissions[len(s.submissions)-1].Timestamp
}

stats := map[string]interface{}{
stats := map[string]any{
"total_submissions": totalSubmissions,
"success_count": successCount,
"error_count": errorCount,
"success_rate": fmt.Sprintf("%.2f%%", successRate),
"total_blob_size": totalBlobSize,
"avg_blob_size": avgBlobSize,
"avg_gas_price": avgGasPrice,
"time_range": map[string]interface{}{
"time_range": map[string]any{
"first": firstSubmission,
"last": lastSubmission,
},
Expand All @@ -292,7 +292,7 @@ func (s *DAVisualizationServer) handleDAHealth(w http.ResponseWriter, r *http.Re

// If not an aggregator, return simplified health status
if !s.isAggregator {
health := map[string]interface{}{
health := map[string]any{
"is_aggregator": false,
"status": "n/a",
"message": "This node is not an aggregator and does not submit to the DA layer",
Expand Down Expand Up @@ -409,12 +409,12 @@ func (s *DAVisualizationServer) handleDAHealth(w http.ResponseWriter, r *http.Re
}
}

health := map[string]interface{}{
health := map[string]any{
"status": healthStatus,
"is_healthy": isHealthy,
"connection_status": connectionStatus,
"connection_healthy": connectionHealthy,
"metrics": map[string]interface{}{
"metrics": map[string]any{
"recent_error_rate": fmt.Sprintf("%.1f%%", errorRate),
"recent_errors": recentErrors,
"recent_successes": recentSuccesses,
Expand Down Expand Up @@ -454,7 +454,7 @@ func (s *DAVisualizationServer) handleDAVisualizationHTML(w http.ResponseWriter,
}
return s[start:end]
},
"len": func(items interface{}) int {
"len": func(items any) int {
// Handle different types gracefully
switch v := items.(type) {
case []DASubmissionInfo:
Expand Down
8 changes: 4 additions & 4 deletions pkg/rpc/server/da_visualization_non_aggregator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ func TestNonAggregatorHandleDASubmissions(t *testing.T) {
assert.Equal(t, http.StatusOK, rr.Code)
assert.Equal(t, "application/json", rr.Header().Get("Content-Type"))

var response map[string]interface{}
var response map[string]any
err = json.Unmarshal(rr.Body.Bytes(), &response)
require.NoError(t, err)

assert.Equal(t, false, response["is_aggregator"])
assert.Equal(t, float64(0), response["total"])
assert.Contains(t, response["message"], "not an aggregator")

submissions, ok := response["submissions"].([]interface{})
submissions, ok := response["submissions"].([]any)
require.True(t, ok)
assert.Equal(t, 0, len(submissions))
}
Expand All @@ -73,7 +73,7 @@ func TestNonAggregatorHandleDAStats(t *testing.T) {
assert.Equal(t, http.StatusOK, rr.Code)
assert.Equal(t, "application/json", rr.Header().Get("Content-Type"))

var response map[string]interface{}
var response map[string]any
err = json.Unmarshal(rr.Body.Bytes(), &response)
require.NoError(t, err)

Expand All @@ -99,7 +99,7 @@ func TestNonAggregatorHandleDAHealth(t *testing.T) {
assert.Equal(t, http.StatusOK, rr.Code)
assert.Equal(t, "application/json", rr.Header().Get("Content-Type"))

var response map[string]interface{}
var response map[string]any
err = json.Unmarshal(rr.Body.Bytes(), &response)
require.NoError(t, err)

Expand Down
6 changes: 3 additions & 3 deletions pkg/rpc/server/da_visualization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,16 @@ func TestHandleDASubmissions(t *testing.T) {
assert.Equal(t, http.StatusOK, rr.Code)
assert.Equal(t, "application/json", rr.Header().Get("Content-Type"))

var response map[string]interface{}
var response map[string]any
err = json.Unmarshal(rr.Body.Bytes(), &response)
require.NoError(t, err)

assert.Equal(t, float64(1), response["total"])
submissions, ok := response["submissions"].([]interface{})
submissions, ok := response["submissions"].([]any)
require.True(t, ok)
assert.Equal(t, 1, len(submissions))

submission := submissions[0].(map[string]interface{})
submission := submissions[0].(map[string]any)
assert.Equal(t, float64(100), submission["height"])
assert.Equal(t, float64(1024), submission["blob_size"])
assert.Equal(t, 0.5, submission["gas_price"])
Expand Down
34 changes: 17 additions & 17 deletions tools/blob-decoder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ var templatesFS embed.FS

// DecodedBlob represents the result of decoding a blob
type DecodedBlob struct {
Type string `json:"type"`
Data interface{} `json:"data"`
RawHex string `json:"rawHex"`
Size int `json:"size"`
Timestamp time.Time `json:"timestamp"`
Error string `json:"error,omitempty"`
Type string `json:"type"`
Data any `json:"data"`
RawHex string `json:"rawHex"`
Size int `json:"size"`
Timestamp time.Time `json:"timestamp"`
Error string `json:"error,omitempty"`
}

func main() {
Expand Down Expand Up @@ -164,7 +164,7 @@ func decodeBlob(data []byte) DecodedBlob {
}

// Check if it's JSON
var jsonData interface{}
var jsonData any
if err := json.Unmarshal(data, &jsonData); err == nil {
return DecodedBlob{
Type: "JSON",
Expand All @@ -175,14 +175,14 @@ func decodeBlob(data []byte) DecodedBlob {
// Return as unknown binary
return DecodedBlob{
Type: "Unknown",
Data: map[string]interface{}{
Data: map[string]any{
"message": "Unable to decode blob format",
"preview": hex.EncodeToString(data[:min(100, len(data))]),
},
}
}

func tryDecodeHeader(data []byte) interface{} {
func tryDecodeHeader(data []byte) any {
var headerPb pb.SignedHeader
if err := proto.Unmarshal(data, &headerPb); err != nil {
return nil
Expand All @@ -199,14 +199,14 @@ func tryDecodeHeader(data []byte) interface{} {
}

// Return a map with the actual header fields
return map[string]interface{}{
return map[string]any{
// BaseHeader fields
"height": signedHeader.Height(),
"time": signedHeader.Time().Format(time.RFC3339Nano),
"chainId": signedHeader.ChainID(),

// Version
"version": map[string]interface{}{
"version": map[string]any{
"block": signedHeader.Version.Block,
"app": signedHeader.Version.App,
},
Expand All @@ -222,30 +222,30 @@ func tryDecodeHeader(data []byte) interface{} {

// Signature fields
"signature": bytesToHex(signedHeader.Signature),
"signer": map[string]interface{}{
"signer": map[string]any{
"address": bytesToHex(signedHeader.Signer.Address),
"pubKey": "",
},
}
}

func tryDecodeSignedData(data []byte) interface{} {
func tryDecodeSignedData(data []byte) any {
var signedData types.SignedData
if err := signedData.UnmarshalBinary(data); err != nil {
return nil
}

// Create transaction list
transactions := make([]map[string]interface{}, len(signedData.Txs))
transactions := make([]map[string]any, len(signedData.Txs))
for i, tx := range signedData.Txs {
transactions[i] = map[string]interface{}{
transactions[i] = map[string]any{
"index": i,
"size": len(tx),
"data": bytesToHex(tx),
}
}

result := map[string]interface{}{
result := map[string]any{
"transactions": transactions,
"transactionCount": len(signedData.Txs),
"signature": bytesToHex(signedData.Signature),
Expand Down Expand Up @@ -273,7 +273,7 @@ func bytesToHex(b []byte) string {
return hex.EncodeToString(b)
}

func sendJSONResponse(w http.ResponseWriter, data interface{}) {
func sendJSONResponse(w http.ResponseWriter, data any) {
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(data); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
Expand Down
Loading