Skip to content

Commit 7aab20f

Browse files
authored
chore: emit audit logs from ingress-rpc (#48)
1 parent e59327b commit 7aab20f

File tree

19 files changed

+175
-181
lines changed

19 files changed

+175
-181
lines changed

.env.example

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ TIPS_INGRESS_ADDRESS=0.0.0.0
33
TIPS_INGRESS_PORT=8080
44
TIPS_INGRESS_RPC_MEMPOOL=http://localhost:2222
55
TIPS_INGRESS_DUAL_WRITE_MEMPOOL=false
6-
TIPS_INGRESS_KAFKA_INGRESS_PROPERTIES_FILE=/app/docker/ingress-kafka-properties
6+
TIPS_INGRESS_KAFKA_INGRESS_PROPERTIES_FILE=/app/docker/ingress-bundles-kafka-properties
77
TIPS_INGRESS_KAFKA_INGRESS_TOPIC=tips-ingress
8+
TIPS_INGRESS_KAFKA_AUDIT_PROPERTIES_FILE=/app/docker/ingress-audit-kafka-properties
9+
TIPS_INGRESS_KAFKA_AUDIT_TOPIC=tips-audit
810
TIPS_INGRESS_LOG_LEVEL=info
911
TIPS_INGRESS_SEND_TRANSACTION_DEFAULT_LIFETIME_SECONDS=10800
1012

Cargo.lock

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

Cargo.toml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,15 @@ alloy-primitives = { version = "1.3.1", default-features = false, features = [
2525
"map-foldhash",
2626
"serde",
2727
] }
28-
alloy-rpc-types = { version = "1.0.35", default-features = false }
29-
alloy-consensus = { version = "1.0.35" }
30-
alloy-provider = { version = "1.0.35" }
31-
alloy-rpc-types-mev = "1.0.35"
28+
alloy-consensus = { version = "1.0.37" }
29+
alloy-provider = { version = "1.0.37" }
3230
alloy-serde = "1.0.41"
3331

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

3938
tokio = { version = "1.47.1", features = ["full"] }
4039
tracing = "0.1.41"

crates/audit/src/storage.rs

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,7 @@ pub struct TransactionMetadata {
3636
#[derive(Debug, Clone, Serialize, Deserialize)]
3737
#[serde(tag = "event", content = "data")]
3838
pub enum BundleHistoryEvent {
39-
Created {
40-
key: String,
41-
timestamp: i64,
42-
bundle: Bundle,
43-
},
44-
Updated {
39+
Received {
4540
key: String,
4641
timestamp: i64,
4742
bundle: Bundle,
@@ -73,8 +68,7 @@ pub enum BundleHistoryEvent {
7368
impl BundleHistoryEvent {
7469
pub fn key(&self) -> &str {
7570
match self {
76-
BundleHistoryEvent::Created { key, .. } => key,
77-
BundleHistoryEvent::Updated { key, .. } => key,
71+
BundleHistoryEvent::Received { key, .. } => key,
7872
BundleHistoryEvent::Cancelled { key, .. } => key,
7973
BundleHistoryEvent::BuilderIncluded { key, .. } => key,
8074
BundleHistoryEvent::BlockIncluded { key, .. } => key,
@@ -106,12 +100,7 @@ fn update_bundle_history_transform(
106100
}
107101

108102
let history_event = match &event.event {
109-
BundleEvent::Created { bundle, .. } => BundleHistoryEvent::Created {
110-
key: event.key.clone(),
111-
timestamp: event.timestamp,
112-
bundle: bundle.clone(),
113-
},
114-
BundleEvent::Updated { bundle, .. } => BundleHistoryEvent::Updated {
103+
BundleEvent::Received { bundle, .. } => BundleHistoryEvent::Received {
115104
key: event.key.clone(),
116105
timestamp: event.timestamp,
117106
bundle: bundle.clone(),
@@ -396,7 +385,7 @@ mod tests {
396385
let bundle_history = BundleHistory { history: vec![] };
397386
let bundle = create_test_bundle();
398387
let bundle_id = Uuid::new_v4();
399-
let bundle_event = BundleEvent::Created {
388+
let bundle_event = BundleEvent::Received {
400389
bundle_id,
401390
bundle: bundle.clone(),
402391
};
@@ -409,7 +398,7 @@ mod tests {
409398
assert_eq!(bundle_history.history.len(), 1);
410399

411400
match &bundle_history.history[0] {
412-
BundleHistoryEvent::Created {
401+
BundleHistoryEvent::Received {
413402
key,
414403
timestamp: ts,
415404
bundle: b,
@@ -424,7 +413,7 @@ mod tests {
424413

425414
#[test]
426415
fn test_update_bundle_history_transform_skips_duplicate_key() {
427-
let existing_event = BundleHistoryEvent::Created {
416+
let existing_event = BundleHistoryEvent::Received {
428417
key: "duplicate-key".to_string(),
429418
timestamp: 1111111111,
430419
bundle: create_test_bundle(),
@@ -435,7 +424,7 @@ mod tests {
435424

436425
let bundle = create_test_bundle();
437426
let bundle_id = Uuid::new_v4();
438-
let bundle_event = BundleEvent::Updated { bundle_id, bundle };
427+
let bundle_event = BundleEvent::Received { bundle_id, bundle };
439428
let event = create_test_event("duplicate-key", 1234567890, bundle_event);
440429

441430
let result = update_bundle_history_transform(bundle_history, &event);
@@ -449,24 +438,16 @@ mod tests {
449438
let bundle_id = Uuid::new_v4();
450439

451440
let bundle = create_test_bundle();
452-
let bundle_event = BundleEvent::Created {
441+
let bundle_event = BundleEvent::Received {
453442
bundle_id,
454443
bundle: bundle.clone(),
455444
};
456445
let event = create_test_event("test-key", 1234567890, bundle_event);
457446
let result = update_bundle_history_transform(bundle_history.clone(), &event);
458447
assert!(result.is_some());
459448

460-
let bundle_event = BundleEvent::Updated {
461-
bundle_id,
462-
bundle: bundle.clone(),
463-
};
464-
let event = create_test_event("test-key-2", 1234567890, bundle_event);
465-
let result = update_bundle_history_transform(bundle_history.clone(), &event);
466-
assert!(result.is_some());
467-
468449
let bundle_event = BundleEvent::Cancelled { bundle_id };
469-
let event = create_test_event("test-key-3", 1234567890, bundle_event);
450+
let event = create_test_event("test-key-2", 1234567890, bundle_event);
470451
let result = update_bundle_history_transform(bundle_history.clone(), &event);
471452
assert!(result.is_some());
472453

@@ -476,7 +457,7 @@ mod tests {
476457
block_number: 12345,
477458
flashblock_index: 1,
478459
};
479-
let event = create_test_event("test-key-4", 1234567890, bundle_event);
460+
let event = create_test_event("test-key-3", 1234567890, bundle_event);
480461
let result = update_bundle_history_transform(bundle_history.clone(), &event);
481462
assert!(result.is_some());
482463

@@ -485,15 +466,15 @@ mod tests {
485466
block_number: 12345,
486467
block_hash: TxHash::from([1u8; 32]),
487468
};
488-
let event = create_test_event("test-key-5", 1234567890, bundle_event);
469+
let event = create_test_event("test-key-4", 1234567890, bundle_event);
489470
let result = update_bundle_history_transform(bundle_history.clone(), &event);
490471
assert!(result.is_some());
491472

492473
let bundle_event = BundleEvent::Dropped {
493474
bundle_id,
494475
reason: DropReason::TimedOut,
495476
};
496-
let event = create_test_event("test-key-6", 1234567890, bundle_event);
477+
let event = create_test_event("test-key-5", 1234567890, bundle_event);
497478
let result = update_bundle_history_transform(bundle_history, &event);
498479
assert!(result.is_some());
499480
}

0 commit comments

Comments
 (0)