Skip to content

Commit 649ed54

Browse files
committed
More bug fixes
1 parent 2037473 commit 649ed54

File tree

8 files changed

+136
-130
lines changed

8 files changed

+136
-130
lines changed

crates/ingress/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use alloy_provider::{ProviderBuilder, RootProvider};
22
use clap::Parser;
33
use jsonrpsee::server::Server;
4+
use op_alloy_network::Optimism;
45
use rdkafka::ClientConfig;
56
use rdkafka::producer::FutureProducer;
67
use std::net::IpAddr;
7-
use op_alloy_network::Optimism;
88
use tips_audit::KafkaMempoolEventPublisher;
99
use tracing::{info, warn};
1010
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};

crates/maintenance/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ use alloy_provider::network::primitives::BlockTransactions;
33
use alloy_provider::{Provider, ProviderBuilder, RootProvider};
44
use anyhow::Result;
55
use clap::Parser;
6+
use op_alloy_network::Optimism;
67
use rdkafka::ClientConfig;
78
use rdkafka::producer::FutureProducer;
89
use std::time::Duration;
9-
use op_alloy_network::Optimism;
1010
use tips_audit::{KafkaMempoolEventPublisher, MempoolEvent, MempoolEventPublisher};
1111
use tips_datastore::{BundleDatastore, PostgresDatastore};
1212
use tokio::time::sleep;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { NextResponse } from "next/server";
2+
import { listAllBundleKeys } from "@/lib/s3";
3+
4+
export async function GET() {
5+
try {
6+
const bundleKeys = await listAllBundleKeys();
7+
return NextResponse.json(bundleKeys);
8+
} catch (error) {
9+
console.error("Error fetching all bundle keys:", error);
10+
return NextResponse.json(
11+
{ error: "Internal server error" },
12+
{ status: 500 },
13+
);
14+
}
15+
}
Lines changed: 2 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"use client";
22

3-
import Link from "next/link";
43
import { useEffect, useState } from "react";
54
import type { BundleHistoryResponse } from "@/app/api/bundle/[uuid]/route";
65

@@ -126,14 +125,10 @@ export default function BundlePage({ params }: PageProps) {
126125

127126
return uniqueTransactions.length > 0 ? (
128127
<div className="border rounded-lg p-4 bg-white/5">
129-
<h2 className="text-xl font-semibold mb-3">
130-
Transactions
131-
</h2>
128+
<h2 className="text-xl font-semibold mb-3">Transactions</h2>
132129
<ul className="space-y-2">
133130
{uniqueTransactions.map((tx) => (
134-
<li key={tx}>
135-
{tx}
136-
</li>
131+
<li key={tx}>{tx}</li>
137132
))}
138133
</ul>
139134
</div>
@@ -169,72 +164,6 @@ export default function BundlePage({ params }: PageProps) {
169164
Event #{index + 1}
170165
</span>
171166
</div>
172-
173-
<div className="grid grid-cols-1 md:grid-cols-2 gap-2 text-sm">
174-
{event.builder && (
175-
<div>
176-
<span className="font-medium">Builder:</span>{" "}
177-
{event.builder}
178-
</div>
179-
)}
180-
{event.blockNumber && (
181-
<div>
182-
<span className="font-medium">Block Number:</span>{" "}
183-
{event.blockNumber}
184-
</div>
185-
)}
186-
{event.flashblockIndex && (
187-
<div>
188-
<span className="font-medium">
189-
Flashblock Index:
190-
</span>{" "}
191-
{event.flashblockIndex}
192-
</div>
193-
)}
194-
{event.blockHash && (
195-
<div>
196-
<span className="font-medium">Block Hash:</span>{" "}
197-
<span className="font-mono text-xs">
198-
{event.blockHash}
199-
</span>
200-
</div>
201-
)}
202-
{event.reason && (
203-
<div>
204-
<span className="font-medium">Reason:</span>{" "}
205-
{event.reason}
206-
</div>
207-
)}
208-
{event.bundle?.transactions && (
209-
<div className="md:col-span-2">
210-
<span className="font-medium">Transactions:</span>{" "}
211-
{event.bundle.transactions.length}
212-
<div className="mt-2 space-y-1">
213-
{event.bundle.transactions
214-
.slice(0, 3)
215-
.map((tx, _txIndex) => (
216-
<div
217-
key={tx.hash}
218-
className="flex items-center gap-2"
219-
>
220-
<Link
221-
href={`/txn/${tx.hash}`}
222-
className="font-mono text-xs text-blue-600 hover:text-blue-800 underline"
223-
>
224-
{tx.hash}
225-
</Link>
226-
</div>
227-
))}
228-
{event.bundle.transactions.length > 3 && (
229-
<div className="text-xs text-gray-500">
230-
... and {event.bundle.transactions.length - 3}{" "}
231-
more
232-
</div>
233-
)}
234-
</div>
235-
</div>
236-
)}
237-
</div>
238167
</div>
239168
);
240169
})}

ui/src/app/bundles/page.tsx

Lines changed: 84 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,78 +5,125 @@ import { useEffect, useState } from "react";
55
import type { Bundle } from "@/app/api/bundles/route";
66

77
export default function BundlesPage() {
8-
const [bundles, setBundles] = useState<Bundle[]>([]);
8+
const [liveBundles, setLiveBundles] = useState<Bundle[]>([]);
9+
const [allBundles, setAllBundles] = useState<string[]>([]);
910
const [loading, setLoading] = useState(true);
1011
const [error, setError] = useState<string | null>(null);
1112

1213
useEffect(() => {
13-
const fetchBundles = async () => {
14+
const fetchLiveBundles = async () => {
1415
try {
1516
const response = await fetch("/api/bundles");
1617
if (!response.ok) {
17-
setError("Failed to fetch bundles");
18-
setBundles([]);
18+
setError("Failed to fetch live bundles");
19+
setLiveBundles([]);
1920
return;
2021
}
2122
const result = await response.json();
22-
setBundles(result);
23+
setLiveBundles(result);
2324
setError(null);
2425
} catch (_err) {
25-
setError("Failed to fetch bundles");
26-
setBundles([]);
27-
} finally {
28-
setLoading(false);
26+
setError("Failed to fetch live bundles");
27+
setLiveBundles([]);
2928
}
3029
};
3130

32-
fetchBundles();
31+
const fetchAllBundles = async () => {
32+
try {
33+
const response = await fetch("/api/bundles/all");
34+
if (!response.ok) {
35+
console.error("Failed to fetch all bundles from S3");
36+
setAllBundles([]);
37+
return;
38+
}
39+
const result = await response.json();
40+
setAllBundles(result);
41+
} catch (_err) {
42+
console.error("Failed to fetch all bundles from S3");
43+
setAllBundles([]);
44+
}
45+
};
46+
47+
const fetchData = async () => {
48+
await Promise.all([fetchLiveBundles(), fetchAllBundles()]);
49+
setLoading(false);
50+
};
3351

34-
const interval = setInterval(fetchBundles, 400);
52+
fetchData();
53+
54+
const interval = setInterval(fetchLiveBundles, 400);
3555

3656
return () => clearInterval(interval);
3757
}, []);
3858

3959
if (loading) {
4060
return (
4161
<div className="flex flex-col gap-4 p-8">
42-
<h1 className="text-2xl font-bold">Bundles</h1>
62+
<h1 className="text-2xl font-bold">BundleStore (fka Mempool)</h1>
4363
<div className="animate-pulse">Loading bundles...</div>
4464
</div>
4565
);
4666
}
4767

4868
return (
49-
<div className="flex flex-col gap-6 p-8">
69+
<div className="flex flex-col gap-8 p-8">
5070
<div className="flex flex-col gap-2">
51-
<h1 className="text-2xl font-bold">Bundles</h1>
71+
<h1 className="text-2xl font-bold">BundleStore (fka Mempool)</h1>
5272
{error && (
5373
<div className="text-sm text-red-600 dark:text-red-400">{error}</div>
5474
)}
5575
</div>
5676

57-
{bundles.length > 0 ? (
58-
<ul className="space-y-2">
59-
{bundles.map((bundle) => (
60-
<li key={bundle.id}>
61-
<Link
62-
href={`/bundle/${bundle.id}`}
63-
className="block p-3 border rounded-lg bg-white/5 hover:bg-white/10 transition-colors"
64-
>
65-
<span className="font-mono text-sm">
66-
{bundle.id}
67-
{" ("}
68-
{bundle.txnHashes?.join(", ") || "No transactions"}
69-
{")"}
70-
</span>
71-
</Link>
72-
</li>
73-
))}
74-
</ul>
75-
) : (
76-
<p className="text-gray-600 dark:text-gray-400">
77-
{loading ? "Loading bundles..." : "No bundles found."}
78-
</p>
79-
)}
77+
<div className="flex flex-col gap-6">
78+
<section>
79+
<h2 className="text-xl font-semibold mb-4">Live Bundles</h2>
80+
{liveBundles.length > 0 ? (
81+
<ul className="space-y-2">
82+
{liveBundles.map((bundle) => (
83+
<li key={bundle.id}>
84+
<Link
85+
href={`/bundles/${bundle.id}`}
86+
className="block p-3 border rounded-lg bg-white/5 hover:bg-white/10 transition-colors"
87+
>
88+
<span className="font-mono text-sm">
89+
{bundle.id}
90+
{" ("}
91+
{bundle.txnHashes?.join(", ") || "No transactions"}
92+
{")"}
93+
</span>
94+
</Link>
95+
</li>
96+
))}
97+
</ul>
98+
) : (
99+
<p className="text-gray-600 dark:text-gray-400">
100+
No live bundles found.
101+
</p>
102+
)}
103+
</section>
104+
105+
<section>
106+
<h2 className="text-xl font-semibold mb-4">All Bundles</h2>
107+
{allBundles.length > 0 ? (
108+
<ul className="space-y-2">
109+
{allBundles.map((bundleId) => (
110+
<li key={bundleId}>
111+
<Link
112+
href={`/bundles/${bundleId}`}
113+
className="block p-3 border rounded-lg bg-white/5 hover:bg-white/10 transition-colors"
114+
>
115+
<span className="font-mono text-sm">{bundleId}</span>
116+
</Link>
117+
</li>
118+
))}
119+
</ul>
120+
) : (
121+
<p className="text-gray-600 dark:text-gray-400">
122+
No bundles found in S3.
123+
</p>
124+
)}
125+
</section>
126+
</div>
80127
</div>
81128
);
82129
}

ui/src/app/page.tsx

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,5 @@
1-
"use client";
2-
3-
import { useRouter } from "next/navigation";
1+
import { redirect } from "next/navigation";
42

53
export default function Home() {
6-
const _router = useRouter();
7-
8-
return (
9-
<div>
10-
<main className="flex flex-col gap-[32px] row-start-2 items-center sm:items-start">
11-
<div className="w-full max-w-4xl">
12-
<h1 className="text-2xl font-bold mb-8">
13-
Tips - Transaction Inclusion Pipeline Services
14-
</h1>
15-
</div>
16-
</main>
17-
</div>
18-
);
4+
redirect("/bundles");
195
}

ui/src/app/txn/[hash]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export default function TransactionRedirectPage({ params }: PageProps) {
3939
const result: TransactionHistoryResponse = await response.json();
4040

4141
if (result.bundle_ids && result.bundle_ids.length > 0) {
42-
router.push(`/bundle/${result.bundle_ids[0]}`);
42+
router.push(`/bundles/${result.bundle_ids[0]}`);
4343
} else {
4444
setError("No bundle found for this transaction");
4545
}

ui/src/lib/s3.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
GetObjectCommand,
3+
ListObjectsV2Command,
34
S3Client,
45
type S3ClientConfig,
56
} from "@aws-sdk/client-s3";
@@ -96,7 +97,7 @@ export interface BundleEvent {
9697
};
9798
key: string;
9899
timestamp: number;
99-
}
100+
};
100101
}
101102

102103
export interface BundleHistory {
@@ -123,3 +124,31 @@ export async function getBundleHistory(
123124
return null;
124125
}
125126
}
127+
128+
export async function listAllBundleKeys(): Promise<string[]> {
129+
try {
130+
const command = new ListObjectsV2Command({
131+
Bucket: BUCKET_NAME,
132+
Prefix: "bundles/",
133+
});
134+
135+
const response = await s3Client.send(command);
136+
const bundleKeys: string[] = [];
137+
138+
if (response.Contents) {
139+
for (const object of response.Contents) {
140+
if (object.Key?.startsWith("bundles/")) {
141+
const bundleId = object.Key.replace("bundles/", "");
142+
if (bundleId) {
143+
bundleKeys.push(bundleId);
144+
}
145+
}
146+
}
147+
}
148+
149+
return bundleKeys;
150+
} catch (error) {
151+
console.error("Failed to list S3 bundle keys:", error);
152+
return [];
153+
}
154+
}

0 commit comments

Comments
 (0)