Skip to content

Commit 4e0b107

Browse files
committed
chore: setup an in memory bundle store
1 parent 6450270 commit 4e0b107

File tree

23 files changed

+791
-707
lines changed

23 files changed

+791
-707
lines changed

Cargo.lock

Lines changed: 165 additions & 537 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ homepage = "https://github.com/base/tips"
77
repository = "https://github.com/base/tips"
88

99
[workspace]
10-
members = ["crates/audit", "crates/ingress-rpc", "crates/common"]
10+
members = ["crates/audit", "crates/ingress-rpc", "crates/bundle-pool", "crates/core"]
1111
resolver = "2"
1212

1313
[workspace.dependencies]
14-
tips-common = { path = "crates/common" }
1514
tips-audit = { path = "crates/audit" }
15+
tips-bundle-pool = { path = "crates/bundle-pool" }
16+
tips-core = { path = "crates/core" }
1617

1718
# Reth
18-
reth = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.1" }
19-
reth-rpc-eth-types = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.1" }
20-
reth-optimism-evm = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.1" }
21-
base-reth-flashblocks-rpc = { git = "https://github.com/base/node-reth", rev = "a1ae148a36354c88b356f80281fef12dad9f7737" }
19+
reth = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.2" }
20+
reth-rpc-eth-types = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.2" }
21+
reth-optimism-evm = { git = "https://github.com/paradigmxyz/reth", tag = "v1.8.2" }
2222

2323
# alloy
2424
alloy-primitives = { version = "1.3.1", default-features = false, features = [
@@ -28,29 +28,20 @@ alloy-primitives = { version = "1.3.1", default-features = false, features = [
2828
alloy-rpc-types = { version = "1.0.35", default-features = false }
2929
alloy-consensus = { version = "1.0.35" }
3030
alloy-provider = { version = "1.0.35" }
31-
alloy-rpc-types-mev = "1.0.35"
3231

3332
# op-alloy
34-
op-alloy-rpc-types = { version = "0.20.0", default-features = false }
35-
op-alloy-network = { version = "0.20.0", default-features = false }
36-
op-alloy-consensus = { version = "0.20.0", features = ["k256"] }
33+
op-alloy-network = { version = "0.21.0", default-features = false }
34+
op-alloy-consensus = { version = "0.21.0", features = ["k256"] }
35+
op-alloy-rpc-types = { version = "0.21.0", default-features = true}
3736

3837
tokio = { version = "1.47.1", features = ["full"] }
3938
tracing = "0.1.41"
4039
tracing-subscriber = { version = "0.3.20", features = ["env-filter"] }
4140
anyhow = "1.0.99"
4241
clap = { version = "4.5.47", features = ["derive", "env"] }
4342
url = "2.5.7"
44-
sqlx = { version = "0.8.6", features = [
45-
"runtime-tokio-native-tls",
46-
"postgres",
47-
"uuid",
48-
"chrono",
49-
"json",
50-
]}
5143
uuid = { version = "1.18.1", features = ["v4", "serde"] }
5244
serde = { version = "1.0.219", features = ["derive"] }
53-
eyre = "0.6.12"
5445
async-trait = "0.1.89"
5546
serde_json = "1.0.143"
5647
dotenvy = "0.15.7"

crates/audit/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ name = "tips-audit"
1212
path = "src/bin/main.rs"
1313

1414
[dependencies]
15+
tips-core = { workspace = true }
1516
tokio = { workspace = true }
1617
tracing = { workspace = true }
1718
tracing-subscriber = { workspace = true }
@@ -23,7 +24,6 @@ async-trait = { workspace = true }
2324
alloy-primitives = { workspace = true }
2425
alloy-consensus = { workspace = true }
2526
alloy-provider = { workspace = true }
26-
alloy-rpc-types-mev = { workspace = true }
2727
op-alloy-consensus = { workspace = true }
2828
clap = { workspace = true }
2929
dotenvy = { workspace = true }

crates/audit/src/publisher.rs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use anyhow::Result;
33
use async_trait::async_trait;
44
use rdkafka::producer::{FutureProducer, FutureRecord};
55
use serde_json;
6-
use tracing::{debug, error};
6+
use tracing::{debug, error, info};
77

88
#[async_trait]
99
pub trait BundleEventPublisher: Send + Sync {
@@ -70,3 +70,37 @@ impl BundleEventPublisher for KafkaBundleEventPublisher {
7070
Ok(())
7171
}
7272
}
73+
74+
#[derive(Clone)]
75+
pub struct LoggingBundleEventPublisher;
76+
77+
impl LoggingBundleEventPublisher {
78+
pub fn new() -> Self {
79+
Self
80+
}
81+
}
82+
83+
impl Default for LoggingBundleEventPublisher {
84+
fn default() -> Self {
85+
Self::new()
86+
}
87+
}
88+
89+
#[async_trait]
90+
impl BundleEventPublisher for LoggingBundleEventPublisher {
91+
async fn publish(&self, event: BundleEvent) -> Result<()> {
92+
info!(
93+
bundle_id = %event.bundle_id(),
94+
event = ?event,
95+
"Received bundle event"
96+
);
97+
Ok(())
98+
}
99+
100+
async fn publish_all(&self, events: Vec<BundleEvent>) -> Result<()> {
101+
for event in events {
102+
self.publish(event).await?;
103+
}
104+
Ok(())
105+
}
106+
}

crates/audit/src/storage.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::reader::Event;
22
use crate::types::{BundleEvent, BundleId, DropReason, TransactionId};
33
use alloy_primitives::TxHash;
4-
use alloy_rpc_types_mev::EthSendBundle;
54
use anyhow::Result;
65
use async_trait::async_trait;
76
use aws_sdk_s3::Client as S3Client;
@@ -11,6 +10,7 @@ use aws_sdk_s3::primitives::ByteStream;
1110
use serde::{Deserialize, Serialize};
1211
use std::fmt;
1312
use std::fmt::Debug;
13+
use tips_core::Bundle;
1414
use tracing::info;
1515

1616
#[derive(Debug)]
@@ -39,12 +39,12 @@ pub enum BundleHistoryEvent {
3939
Created {
4040
key: String,
4141
timestamp: i64,
42-
bundle: EthSendBundle,
42+
bundle: Bundle,
4343
},
4444
Updated {
4545
key: String,
4646
timestamp: i64,
47-
bundle: EthSendBundle,
47+
bundle: Bundle,
4848
},
4949
Cancelled {
5050
key: String,
@@ -376,11 +376,11 @@ mod tests {
376376
use crate::reader::Event;
377377
use crate::types::{BundleEvent, DropReason};
378378
use alloy_primitives::TxHash;
379-
use alloy_rpc_types_mev::EthSendBundle;
379+
use tips_core::Bundle;
380380
use uuid::Uuid;
381381

382-
fn create_test_bundle() -> EthSendBundle {
383-
EthSendBundle::default()
382+
fn create_test_bundle() -> Bundle {
383+
Bundle::default()
384384
}
385385

386386
fn create_test_event(key: &str, timestamp: i64, bundle_event: BundleEvent) -> Event {
@@ -485,15 +485,15 @@ mod tests {
485485
block_number: 12345,
486486
block_hash: TxHash::from([1u8; 32]),
487487
};
488-
let event = create_test_event("test-key-6", 1234567890, bundle_event);
488+
let event = create_test_event("test-key-5", 1234567890, bundle_event);
489489
let result = update_bundle_history_transform(bundle_history.clone(), &event);
490490
assert!(result.is_some());
491491

492492
let bundle_event = BundleEvent::Dropped {
493493
bundle_id,
494494
reason: DropReason::TimedOut,
495495
};
496-
let event = create_test_event("test-key-7", 1234567890, bundle_event);
496+
let event = create_test_event("test-key-6", 1234567890, bundle_event);
497497
let result = update_bundle_history_transform(bundle_history, &event);
498498
assert!(result.is_some());
499499
}

crates/audit/src/types.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use alloy_consensus::transaction::{SignerRecoverable, Transaction as ConsensusTransaction};
22
use alloy_primitives::{Address, TxHash, U256};
33
use alloy_provider::network::eip2718::Decodable2718;
4-
use alloy_rpc_types_mev::EthSendBundle;
54
use bytes::Bytes;
65
use op_alloy_consensus::OpTxEnvelope;
76
use serde::{Deserialize, Serialize};
7+
use tips_core::Bundle;
88
use uuid::Uuid;
99

1010
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
@@ -19,13 +19,7 @@ pub type BundleId = Uuid;
1919
#[derive(Debug, Clone, Serialize, Deserialize)]
2020
pub enum DropReason {
2121
TimedOut,
22-
}
23-
24-
#[derive(Debug, Clone, Serialize, Deserialize)]
25-
pub struct Bundle {
26-
pub id: BundleId,
27-
pub transactions: Vec<Transaction>,
28-
pub metadata: serde_json::Value,
22+
Reverted,
2923
}
3024

3125
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -39,11 +33,11 @@ pub struct Transaction {
3933
pub enum BundleEvent {
4034
Created {
4135
bundle_id: BundleId,
42-
bundle: EthSendBundle,
36+
bundle: Bundle,
4337
},
4438
Updated {
4539
bundle_id: BundleId,
46-
bundle: EthSendBundle,
40+
bundle: Bundle,
4741
},
4842
Cancelled {
4943
bundle_id: BundleId,

crates/audit/tests/integration_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
use alloy_rpc_types_mev::EthSendBundle;
21
use std::time::Duration;
32
use tips_audit::{
43
KafkaMempoolArchiver, KafkaMempoolReader,
54
publisher::{BundleEventPublisher, KafkaBundleEventPublisher},
65
storage::{BundleEventS3Reader, S3EventReaderWriter},
76
types::{BundleEvent, DropReason},
87
};
8+
use tips_core::Bundle;
99
use uuid::Uuid;
1010
mod common;
1111
use common::TestHarness;
@@ -23,7 +23,7 @@ async fn test_kafka_publisher_s3_archiver_integration()
2323
let test_events = vec![
2424
BundleEvent::Created {
2525
bundle_id: test_bundle_id,
26-
bundle: EthSendBundle::default(),
26+
bundle: Bundle::default(),
2727
},
2828
BundleEvent::Dropped {
2929
bundle_id: test_bundle_id,

crates/audit/tests/s3_test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use alloy_primitives::{Bytes, TxHash, b256, bytes};
2-
use alloy_rpc_types_mev::EthSendBundle;
32
use std::sync::Arc;
43
use tips_audit::{
54
reader::Event,
65
storage::{BundleEventS3Reader, EventWriter, S3EventReaderWriter},
76
types::BundleEvent,
87
};
8+
use tips_core::Bundle;
99
use tokio::task::JoinSet;
1010
use uuid::Uuid;
1111

@@ -19,8 +19,8 @@ const TXN_DATA: Bytes = bytes!(
1919
const TXN_HASH: TxHash =
2020
b256!("0x4f7ddfc911f5cf85dd15a413f4cbb2a0abe4f1ff275ed13581958c0bcf043c5e");
2121

22-
fn create_test_bundle() -> EthSendBundle {
23-
EthSendBundle {
22+
fn create_test_bundle() -> Bundle {
23+
Bundle {
2424
txs: vec![TXN_DATA.clone()],
2525
..Default::default()
2626
}

crates/bundle-pool/Cargo.toml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[package]
2+
name = "tips-bundle-pool"
3+
version.workspace = true
4+
rust-version.workspace = true
5+
license.workspace = true
6+
homepage.workspace = true
7+
repository.workspace = true
8+
edition.workspace = true
9+
10+
[dependencies]
11+
tips-core = { workspace = true }
12+
tips-audit.workspace = true
13+
uuid.workspace = true
14+
alloy-primitives.workspace = true
15+
16+
tracing.workspace = true
17+
tokio.workspace = true
18+
anyhow.workspace = true
19+
async-trait.workspace = true
20+
21+
[dev-dependencies]
22+
tips-core = { workspace = true, features = ["test-utils"] }
23+
alloy-consensus.workspace = true
24+
alloy-provider.workspace = true
25+
alloy-signer = "1.0.41"
26+
alloy-signer-local = "1.0.41"
27+
op-alloy-consensus.workspace = true
28+
op-alloy-rpc-types.workspace = true

crates/bundle-pool/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pub mod pool;
2+
3+
pub use pool::{BundleStore, InMemoryBundlePool};
4+
pub use tips_core::{Bundle, BundleHash, BundleWithMetadata, CancelBundle};

0 commit comments

Comments
 (0)