Skip to content

Commit 2037473

Browse files
committed
Working end to end demo
1 parent 92cc8be commit 2037473

File tree

26 files changed

+571
-732
lines changed

26 files changed

+571
-732
lines changed

.env.example

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ TIPS_INGRESS_LOG_LEVEL=info
1010

1111
# Maintenance
1212
TIPS_MAINTENANCE_DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres
13-
TIPS_MAINTENANCE_RPC_NODE=http://localhost:8545
13+
TIPS_MAINTENANCE_RPC_NODE=http://localhost:2222
1414
TIPS_MAINTENANCE_KAFKA_BROKERS=localhost:9092
1515
TIPS_MAINTENANCE_KAFKA_TOPIC=tips-audit
1616
TIPS_MAINTENANCE_POLL_INTERVAL_MS=250
@@ -20,5 +20,25 @@ TIPS_MAINTENANCE_LOG_LEVEL=info
2020
TIPS_AUDIT_KAFKA_BROKERS=localhost:9092
2121
TIPS_AUDIT_KAFKA_TOPIC=tips-audit
2222
TIPS_AUDIT_KAFKA_GROUP_ID=local-audit
23-
TIPS_AUDIT_S3_BUCKET=tips
2423
TIPS_AUDIT_LOG_LEVEL=info
24+
TIPS_AUDIT_S3_BUCKET=tips
25+
TIPS_AUDIT_S3_CONFIG_TYPE=manual
26+
TIPS_AUDIT_S3_ENDPOINT=http://localhost:7000
27+
TIPS_AUDIT_S3_REGION=us-east-1
28+
TIPS_AUDIT_S3_ACCESS_KEY_ID=minioadmin
29+
TIPS_AUDIT_S3_SECRET_ACCESS_KEY=minioadmin
30+
31+
# For production AWS (uncomment and remove manual config above)
32+
# TIPS_AUDIT_S3_CONFIG_TYPE=aws
33+
34+
# TIPS UI
35+
TIPS_DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres
36+
TIPS_UI_AWS_REGION=us-east-1
37+
TIPS_UI_S3_BUCKET_NAME=tips
38+
TIPS_UI_S3_CONFIG_TYPE=manual
39+
TIPS_UI_S3_ENDPOINT=http://localhost:7000
40+
TIPS_UI_S3_ACCESS_KEY_ID=minioadmin
41+
TIPS_UI_S3_SECRET_ACCESS_KEY=minioadmin
42+
43+
# For production AWS (uncomment and remove manual config above)
44+
# TIPS_UI_S3_CONFIG_TYPE=aws

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ ui/.env*.local
3131
ui/.vercel
3232
ui/*.tsbuildinfo
3333
ui/next-env.d.ts
34+
35+
# Local data directories
36+
data/

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ alloy-rlp = "0.3.12"
2626
# op-alloy
2727
op-alloy-rpc-types = { version = "0.20.0" }
2828
op-alloy-consensus = { version = "0.20.0", features = ["k256"] }
29+
op-alloy-network = {version = "0.20.0"}
2930

3031
tokio = { version = "1.47.1", features = ["full"] }
3132
tracing = "0.1.41"
@@ -55,6 +56,7 @@ futures-util = "0.3.32"
5556
rdkafka = { version = "0.37.0", features = ["libz-static"] }
5657
aws-config = "1.1.7"
5758
aws-sdk-s3 = "1.106.0"
59+
aws-credential-types = "1.1.7"
5860
bytes = { version = "1.8.0", features = ["serde"] }
5961
md5 = "0.7.0"
6062
base64 = "0.22.1"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# tips
2-
A prototype of a Transaction Inclusion Pipeline Service for private sequencers that does not use the P2P mempool. The project
2+
A prototype of a Transaction Inclusion & Prioritization Stack for private sequencers that does not use the P2P mempool. The project
33
aims to increase throughput, improve transaction tracking, reduce latency and add support for bundles.
44

55
This project is currently at:
@@ -64,7 +64,7 @@ just ui
6464
## Dev Notes
6565

6666
### Services Access
67-
- **MinIO UI**: http://localhost:9001 (minioadmin/minioadmin)
67+
- **MinIO UI**: http://localhost:7001 (minioadmin/minioadmin)
6868
- **PostgreSQL**: localhost:5432 (postgres/postgres)
6969
- **Kafka**: localhost:9092
7070

crates/audit/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ dotenvy = { workspace = true }
2929
rdkafka = { workspace = true }
3030
aws-config = { workspace = true }
3131
aws-sdk-s3 = { workspace = true }
32+
aws-credential-types = { workspace = true }
3233
bytes = { workspace = true }
3334
md5 = { workspace = true }
3435
futures = "0.3.31"

crates/audit/src/bin/main.rs

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
use anyhow::Result;
2-
use aws_sdk_s3::Client as S3Client;
3-
use clap::Parser;
2+
use aws_config::{BehaviorVersion, Region};
3+
use aws_credential_types::Credentials;
4+
use aws_sdk_s3::{config::Builder as S3ConfigBuilder, Client as S3Client};
5+
use clap::{Parser, ValueEnum};
46
use rdkafka::consumer::Consumer;
57
use tips_audit::{
68
create_kafka_consumer, KafkaMempoolArchiver, KafkaMempoolReader, S3MempoolEventReaderWriter,
79
};
810
use tracing::{info, warn};
911
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
1012

13+
#[derive(Debug, Clone, ValueEnum)]
14+
enum S3ConfigType {
15+
Aws,
16+
Manual,
17+
}
18+
1119
#[derive(Parser, Debug)]
1220
#[command(author, version, about, long_about = None)]
1321
struct Args {
@@ -25,6 +33,21 @@ struct Args {
2533

2634
#[arg(long, env = "TIPS_AUDIT_LOG_LEVEL", default_value = "info")]
2735
log_level: String,
36+
37+
#[arg(long, env = "TIPS_AUDIT_S3_CONFIG_TYPE", default_value = "aws")]
38+
s3_config_type: S3ConfigType,
39+
40+
#[arg(long, env = "TIPS_AUDIT_S3_ENDPOINT")]
41+
s3_endpoint: Option<String>,
42+
43+
#[arg(long, env = "TIPS_AUDIT_S3_REGION", default_value = "us-east-1")]
44+
s3_region: String,
45+
46+
#[arg(long, env = "TIPS_AUDIT_S3_ACCESS_KEY_ID")]
47+
s3_access_key_id: Option<String>,
48+
49+
#[arg(long, env = "TIPS_AUDIT_S3_SECRET_ACCESS_KEY")]
50+
s3_secret_access_key: Option<String>,
2851
}
2952

3053
#[tokio::main]
@@ -67,15 +90,47 @@ async fn main() -> Result<()> {
6790
let consumer = create_kafka_consumer(&args.kafka_brokers, &args.kafka_group_id)?;
6891
consumer.subscribe(&[&args.kafka_topic])?;
6992

70-
let reader = KafkaMempoolReader::new(consumer, args.kafka_topic)?;
93+
let reader = KafkaMempoolReader::new(consumer, args.kafka_topic.clone())?;
7194

72-
let config = aws_config::load_defaults(aws_config::BehaviorVersion::latest()).await;
73-
let s3_client = S3Client::new(&config);
74-
let writer = S3MempoolEventReaderWriter::new(s3_client, args.s3_bucket);
95+
let s3_client = create_s3_client(&args).await?;
96+
let s3_bucket = args.s3_bucket.clone();
97+
let writer = S3MempoolEventReaderWriter::new(s3_client, s3_bucket);
7598

7699
let mut archiver = KafkaMempoolArchiver::new(reader, writer);
77100

78101
info!("Audit archiver initialized, starting main loop");
79102

80103
archiver.run().await
81104
}
105+
106+
async fn create_s3_client(args: &Args) -> Result<S3Client> {
107+
match args.s3_config_type {
108+
S3ConfigType::Manual => {
109+
let region = args.s3_region.clone();
110+
let mut config_builder =
111+
aws_config::defaults(BehaviorVersion::latest()).region(Region::new(region));
112+
113+
if let Some(endpoint) = &args.s3_endpoint {
114+
config_builder = config_builder.endpoint_url(endpoint);
115+
}
116+
117+
if let (Some(access_key), Some(secret_key)) =
118+
(&args.s3_access_key_id, &args.s3_secret_access_key)
119+
{
120+
let credentials = Credentials::new(access_key, secret_key, None, None, "manual");
121+
config_builder = config_builder.credentials_provider(credentials);
122+
}
123+
124+
let config = config_builder.load().await;
125+
let s3_config_builder = S3ConfigBuilder::from(&config).force_path_style(true);
126+
127+
info!(message = "manually configuring s3 client");
128+
Ok(S3Client::from_conf(s3_config_builder.build()))
129+
}
130+
S3ConfigType::Aws => {
131+
info!(message = "using aws s3 client");
132+
let config = aws_config::load_defaults(BehaviorVersion::latest()).await;
133+
Ok(S3Client::new(&config))
134+
}
135+
}
136+
}

crates/audit/tests/common/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ use uuid::Uuid;
77
pub struct TestHarness {
88
pub s3_client: aws_sdk_s3::Client,
99
pub bucket_name: String,
10+
#[allow(dead_code)] // TODO is read
1011
pub kafka_producer: FutureProducer,
12+
#[allow(dead_code)] // TODO is read
1113
pub kafka_consumer: StreamConsumer,
1214
_minio_container: testcontainers::ContainerAsync<MinIO>,
1315
_kafka_container: testcontainers::ContainerAsync<Kafka>,

crates/ingress/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ tips-audit.workspace = true
1313
jsonrpsee.workspace = true
1414
alloy-rpc-types-mev.workspace = true
1515
alloy-primitives.workspace = true
16+
op-alloy-network.workspace = true
1617
alloy-provider.workspace = true
1718
tokio.workspace = true
1819
tracing.workspace = true

crates/ingress/src/main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use jsonrpsee::server::Server;
44
use rdkafka::ClientConfig;
55
use rdkafka::producer::FutureProducer;
66
use std::net::IpAddr;
7+
use op_alloy_network::Optimism;
78
use tips_audit::KafkaMempoolEventPublisher;
89
use tracing::{info, warn};
910
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
@@ -87,8 +88,9 @@ async fn main() -> anyhow::Result<()> {
8788
mempool_url = %config.mempool_url
8889
);
8990

90-
let provider: RootProvider = ProviderBuilder::new()
91+
let provider: RootProvider<Optimism> = ProviderBuilder::new()
9192
.disable_recommended_fillers()
93+
.network::<Optimism>()
9294
.connect_http(config.mempool_url);
9395

9496
let bundle_store = PostgresDatastore::connect(config.database_url).await?;

crates/ingress/src/service.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use jsonrpsee::{
88
proc_macros::rpc,
99
};
1010
use op_alloy_consensus::OpTxEnvelope;
11+
use op_alloy_network::Optimism;
1112
use tips_audit::{MempoolEvent, MempoolEventPublisher};
1213
use tips_datastore::BundleDatastore;
1314
use tracing::{info, warn};
@@ -28,15 +29,15 @@ pub trait IngressApi {
2829
}
2930

3031
pub struct IngressService<Store, Publisher> {
31-
provider: RootProvider,
32+
provider: RootProvider<Optimism>,
3233
datastore: Store,
3334
dual_write_mempool: bool,
3435
publisher: Publisher,
3536
}
3637

3738
impl<Store, Publisher> IngressService<Store, Publisher> {
3839
pub fn new(
39-
provider: RootProvider,
40+
provider: RootProvider<Optimism>,
4041
datastore: Store,
4142
dual_write_mempool: bool,
4243
publisher: Publisher,

0 commit comments

Comments
 (0)