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
2 changes: 1 addition & 1 deletion benchmarks/aurora-rpc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ methodology:
- "Chain scope: every query on this page is pinned to `chain=\"aurora\"`. Provider coverage: 1 no-key endpoint (Aurora Official). Ankr and dRPC require an API key for Aurora and have been removed."

findings:
- "{{best_name}} currently leads free Aurora RPC at {{best_p50}} (`eth_getBlockByNumber` p50, 24h) 1 measured provider."
- "{{best_name}} currently leads free Aurora RPC at {{best_p50}} (`eth_getBlockByNumber` p50, 24h), 1 measured provider."

faq:
- q: "What is the fastest free Aurora RPC right now?"
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/kaia-rpc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ methodology:
- "Chain scope: every query on this page is pinned to `chain=\"kaia\"`. Provider coverage: 1 no-key endpoint (Kaia Foundation). dRPC removed (500 paid plan only)."

findings:
- "{{best_name}} currently leads free Kaia RPC at {{best_p50}} (`eth_getBlockByNumber(\"latest\", false)` p50, 24h) 1 measured provider."
- "{{best_name}} currently leads free Kaia RPC at {{best_p50}} (`eth_getBlockByNumber(\"latest\", false)` p50, 24h), 1 measured provider."

faq:
- q: "What is the fastest free Kaia RPC right now?"
Expand Down
210 changes: 105 additions & 105 deletions benchmarks/layerzero-message-latency.yml

Large diffs are not rendered by default.

35 changes: 34 additions & 1 deletion harnesses/aggregator-head-lag/cmd/script/defined_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,45 @@ func decodeJWTExpiration(token string) (time.Time, error) {
return time.Unix(claims.Exp, 0), nil
}

// tryTokenService calls the Paris-box sidecar (DEFINED_TOKEN_SERVICE_URL) for a fresh JWE.
func tryTokenService(baseURL string) (string, error) {
client := &http.Client{Timeout: 5 * time.Second}
for _, path := range []string{"/token", "/jwt", "/"} {
resp, err := client.Get(baseURL + path)
if err != nil {
continue
}
body, _ := io.ReadAll(resp.Body)
resp.Body.Close()
if resp.StatusCode != 200 {
continue
}
var parsed struct{ Token string `json:"token"` }
if err := json.Unmarshal(body, &parsed); err == nil && parsed.Token != "" {
return parsed.Token, nil
}
s := strings.TrimSpace(string(body))
if len(s) > 50 {
return s, nil
}
}
return "", fmt.Errorf("no working path on sidecar")
}

// GetDefinedJWTToken returns a cached JWT token or generates a new one if expired.
// If CODEX_JWT env var is set, it is returned directly (bypasses session-cookie flow).
// Priority: CODEX_JWT env var > DEFINED_TOKEN_SERVICE_URL sidecar > inline mint.
func GetDefinedJWTToken(sessionCookie string) (string, error) {
if jwt := os.Getenv("CODEX_JWT"); jwt != "" {
return jwt, nil
}
// Sidecar token service (Paris box chromedp scraper, auto-refreshes every 25 min)
if svcURL := os.Getenv("DEFINED_TOKEN_SERVICE_URL"); svcURL != "" {
if tok, err := tryTokenService(svcURL); err == nil && tok != "" {
fmt.Printf("[DEFINED-AUTH] Got token from sidecar (len=%d)\n", len(tok))
return tok, nil
}
}

globalTokenCache.mu.RLock()

// Check if we have a valid cached token
Expand Down
15 changes: 15 additions & 0 deletions harnesses/solana-exec/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM golang:1.24-alpine AS builder
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -o /app/collector ./cmd/collector
RUN CGO_ENABLED=0 go build -o /app/materializer ./cmd/materializer
RUN CGO_ENABLED=0 go build -o /app/api ./cmd/api

FROM alpine:3.20
RUN apk add --no-cache ca-certificates tzdata
COPY --from=builder /app/collector /app/collector
COPY --from=builder /app/materializer /app/materializer
COPY --from=builder /app/api /app/api
COPY migrations/ /app/migrations/
189 changes: 189 additions & 0 deletions harnesses/solana-exec/cmd/api/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
package main

import (
"context"
"encoding/json"
"log"
"net/http"
"os"
"sort"
"time"

"github.com/jackc/pgx/v5/pgxpool"
)

func main() {
ctx := context.Background()
pool, err := pgxpool.New(ctx, mustEnv("DATABASE_URL"))
if err != nil {
log.Fatalf("exec-api: connect: %v", err)
}
defer pool.Close()

mux := http.NewServeMux()
mux.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte(`{"status":"ok"}`))
})
mux.HandleFunc("/api/exec-leaderboard", corsJSON(handleExecLeaderboard(pool)))

addr := ":2116"
log.Printf("exec-api listening on %s", addr)
if err := http.ListenAndServe(addr, mux); err != nil {
log.Fatalf("exec-api: serve: %v", err)
}
}

// WindowStats holds aggregated execution metrics for one time window.
type WindowStats struct {
TxCount int64 `json:"txCount"`
AvgPriorityFeeLamports float64 `json:"avgPriorityFeeLamports"`
P50CUPriceMicro float64 `json:"p50CUPriceMicro"`
P95CUPriceMicro float64 `json:"p95CUPriceMicro"`
AvgPlatformFeeLamports float64 `json:"avgPlatformFeeLamports"`
JitoRate float64 `json:"jitoRate"`
AvgCUConsumed float64 `json:"avgCUConsumed"`
}

type PlatformRow struct {
Platform string `json:"platform"`
LatestBkt string `json:"latestBucket"`
Windows map[string]WindowStats `json:"windows"`
}

type ExecLeaderboardResponse struct {
UpdatedAt string `json:"updatedAt"`
Platforms []PlatformRow `json:"platforms"`
}

func handleExecLeaderboard(pool *pgxpool.Pool) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
ctx, cancel := context.WithTimeout(r.Context(), 10*time.Second)
defer cancel()

rows, err := pool.Query(ctx, `
SELECT
platform,
AVG(avg_priority_fee_lamports) FILTER (WHERE bucket_start >= now() - INTERVAL '24 hours') AS h24_prio,
AVG(p50_cu_price_micro) FILTER (WHERE bucket_start >= now() - INTERVAL '24 hours') AS h24_p50,
AVG(p95_cu_price_micro) FILTER (WHERE bucket_start >= now() - INTERVAL '24 hours') AS h24_p95,
AVG(avg_platform_fee_lamports) FILTER (WHERE bucket_start >= now() - INTERVAL '24 hours') AS h24_pfee,
AVG(jito_rate) FILTER (WHERE bucket_start >= now() - INTERVAL '24 hours') AS h24_jito,
AVG(avg_cu_consumed) FILTER (WHERE bucket_start >= now() - INTERVAL '24 hours') AS h24_cu,
SUM(tx_count) FILTER (WHERE bucket_start >= now() - INTERVAL '24 hours') AS h24_count,

AVG(avg_priority_fee_lamports) FILTER (WHERE bucket_start >= now() - INTERVAL '7 days') AS d7_prio,
AVG(p50_cu_price_micro) FILTER (WHERE bucket_start >= now() - INTERVAL '7 days') AS d7_p50,
AVG(p95_cu_price_micro) FILTER (WHERE bucket_start >= now() - INTERVAL '7 days') AS d7_p95,
AVG(avg_platform_fee_lamports) FILTER (WHERE bucket_start >= now() - INTERVAL '7 days') AS d7_pfee,
AVG(jito_rate) FILTER (WHERE bucket_start >= now() - INTERVAL '7 days') AS d7_jito,
AVG(avg_cu_consumed) FILTER (WHERE bucket_start >= now() - INTERVAL '7 days') AS d7_cu,
SUM(tx_count) FILTER (WHERE bucket_start >= now() - INTERVAL '7 days') AS d7_count,

AVG(avg_priority_fee_lamports) FILTER (WHERE bucket_start >= now() - INTERVAL '30 days') AS d30_prio,
AVG(p50_cu_price_micro) FILTER (WHERE bucket_start >= now() - INTERVAL '30 days') AS d30_p50,
AVG(p95_cu_price_micro) FILTER (WHERE bucket_start >= now() - INTERVAL '30 days') AS d30_p95,
AVG(avg_platform_fee_lamports) FILTER (WHERE bucket_start >= now() - INTERVAL '30 days') AS d30_pfee,
AVG(jito_rate) FILTER (WHERE bucket_start >= now() - INTERVAL '30 days') AS d30_jito,
AVG(avg_cu_consumed) FILTER (WHERE bucket_start >= now() - INTERVAL '30 days') AS d30_cu,
SUM(tx_count) FILTER (WHERE bucket_start >= now() - INTERVAL '30 days') AS d30_count,

MAX(bucket_start)::text AS latest_bucket
FROM solana_exec_facts
GROUP BY platform`,
)
if err != nil {
log.Printf("exec-api: query: %v", err)
http.Error(w, "internal", http.StatusInternalServerError)
return
}
defer rows.Close()

var platforms []PlatformRow
for rows.Next() {
var plt, latestBkt string
var h24Prio, h24P50, h24P95, h24Pfee, h24Jito, h24Cu *float64
var h24Count *int64
var d7Prio, d7P50, d7P95, d7Pfee, d7Jito, d7Cu *float64
var d7Count *int64
var d30Prio, d30P50, d30P95, d30Pfee, d30Jito, d30Cu *float64
var d30Count *int64

if err := rows.Scan(
&plt,
&h24Prio, &h24P50, &h24P95, &h24Pfee, &h24Jito, &h24Cu, &h24Count,
&d7Prio, &d7P50, &d7P95, &d7Pfee, &d7Jito, &d7Cu, &d7Count,
&d30Prio, &d30P50, &d30P95, &d30Pfee, &d30Jito, &d30Cu, &d30Count,
&latestBkt,
); err != nil {
log.Printf("exec-api: scan: %v", err)
continue
}

p := PlatformRow{
Platform: plt,
LatestBkt: latestBkt,
Windows: map[string]WindowStats{
"24h": buildWindow(h24Prio, h24P50, h24P95, h24Pfee, h24Jito, h24Cu, h24Count),
"7d": buildWindow(d7Prio, d7P50, d7P95, d7Pfee, d7Jito, d7Cu, d7Count),
"30d": buildWindow(d30Prio, d30P50, d30P95, d30Pfee, d30Jito, d30Cu, d30Count),
},
}
platforms = append(platforms, p)
}

// Sort by 30d tx count descending.
sort.Slice(platforms, func(i, j int) bool {
return platforms[i].Windows["30d"].TxCount > platforms[j].Windows["30d"].TxCount
})

resp := ExecLeaderboardResponse{
UpdatedAt: time.Now().UTC().Format(time.RFC3339),
Platforms: platforms,
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(resp)
}
}

func buildWindow(prio, p50, p95, pfee, jito, cu *float64, count *int64) WindowStats {
ws := WindowStats{}
if count != nil {
ws.TxCount = *count
}
if prio != nil {
ws.AvgPriorityFeeLamports = *prio
}
if p50 != nil {
ws.P50CUPriceMicro = *p50
}
if p95 != nil {
ws.P95CUPriceMicro = *p95
}
if pfee != nil {
ws.AvgPlatformFeeLamports = *pfee
}
if jito != nil {
ws.JitoRate = *jito
}
if cu != nil {
ws.AvgCUConsumed = *cu
}
return ws
}

func corsJSON(h http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Cache-Control", "public, max-age=60, stale-while-revalidate=300")
h(w, r)
}
}

func mustEnv(key string) string {
v := os.Getenv(key)
if v == "" {
log.Fatalf("missing env: %s", key)
}
return v
}
Loading
Loading