Skip to content

Commit b5b14a5

Browse files
authored
log clientid, txnid, queueid, chainid (#98)
* log clientid, txnid, queueid, chainid
1 parent 6bf1f2f commit b5b14a5

File tree

9 files changed

+245
-22
lines changed

9 files changed

+245
-22
lines changed

core/src/chain.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ impl RpcCredentials {
2525

2626
Ok(header_map)
2727
}
28+
29+
pub fn client_id_for_logs(&self) -> Option<&str> {
30+
match self {
31+
RpcCredentials::Thirdweb(ThirdwebAuth::ClientIdServiceKey(creds)) => {
32+
Some(&creds.client_id)
33+
}
34+
RpcCredentials::Thirdweb(ThirdwebAuth::SecretKey(_)) => None,
35+
}
36+
}
2837
}
2938

3039
pub trait Chain: Send + Sync {

executors/src/eip7702_executor/confirm.rs

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ use crate::{
2929
},
3030
};
3131

32+
const EIP7702_CONFIRM_QUEUE_ID: &str = "eip7702_confirm";
33+
3234
// --- Job Payload ---
3335
#[derive(Serialize, Deserialize, Debug, Clone)]
3436
#[serde(rename_all = "camelCase")]
@@ -168,7 +170,7 @@ where
168170
type ErrorData = Eip7702ConfirmationError;
169171
type JobData = Eip7702ConfirmationJobData;
170172

171-
#[tracing::instrument(skip(self, job), fields(transaction_id = job.job.id, stage = Self::stage_name(), executor = Self::executor_name()))]
173+
#[tracing::instrument(skip(self, job), fields(transaction_id = job.job.id, chain_id = job.job.data.chain_id, client_id = ?job.job.data.rpc_credentials.client_id_for_logs(), queue_id = EIP7702_CONFIRM_QUEUE_ID, stage = Self::stage_name(), executor = Self::executor_name()))]
172174
async fn process(
173175
&self,
174176
job: &BorrowedJob<Self::JobData>,
@@ -202,7 +204,14 @@ where
202204
.await
203205
.map_err(|e| {
204206
tracing::error!(
205-
bundler_transaction_id = job_data.bundler_transaction_id,
207+
transaction_id = %job_data.transaction_id,
208+
chain_id = job_data.chain_id,
209+
client_id = job_data
210+
.rpc_credentials
211+
.client_id_for_logs()
212+
.unwrap_or("unknown"),
213+
queue_id = EIP7702_CONFIRM_QUEUE_ID,
214+
bundler_transaction_id = %job_data.bundler_transaction_id,
206215
sender_details = ?job_data.sender_details,
207216
error = ?e,
208217
"Failed to get transaction hash from bundler"
@@ -321,7 +330,15 @@ where
321330
// Send webhook
322331
if let Err(e) = self.queue_success_webhook(job, success_data, tx) {
323332
tracing::error!(
324-
transaction_id = job.job.data.transaction_id,
333+
transaction_id = %job.job.data.transaction_id,
334+
chain_id = job.job.data.chain_id,
335+
client_id = job
336+
.job
337+
.data
338+
.rpc_credentials
339+
.client_id_for_logs()
340+
.unwrap_or("unknown"),
341+
queue_id = EIP7702_CONFIRM_QUEUE_ID,
325342
error = ?e,
326343
"Failed to queue success webhook"
327344
);
@@ -346,7 +363,15 @@ where
346363
if should_queue_webhook {
347364
if let Err(e) = self.queue_nack_webhook(job, nack_data, tx) {
348365
tracing::error!(
349-
transaction_id = job.job.data.transaction_id,
366+
transaction_id = %job.job.data.transaction_id,
367+
chain_id = job.job.data.chain_id,
368+
client_id = job
369+
.job
370+
.data
371+
.rpc_credentials
372+
.client_id_for_logs()
373+
.unwrap_or("unknown"),
374+
queue_id = EIP7702_CONFIRM_QUEUE_ID,
350375
error = ?e,
351376
"Failed to queue nack webhook"
352377
);
@@ -370,14 +395,30 @@ where
370395
.add_remove_command(tx.pipeline(), &job.job.data.transaction_id);
371396

372397
tracing::error!(
373-
transaction_id = job.job.data.transaction_id,
398+
transaction_id = %job.job.data.transaction_id,
399+
chain_id = job.job.data.chain_id,
400+
client_id = job
401+
.job
402+
.data
403+
.rpc_credentials
404+
.client_id_for_logs()
405+
.unwrap_or("unknown"),
406+
queue_id = EIP7702_CONFIRM_QUEUE_ID,
374407
error = ?fail_data.error,
375408
"EIP-7702 confirmation job failed"
376409
);
377410

378411
if let Err(e) = self.queue_fail_webhook(job, fail_data, tx) {
379412
tracing::error!(
380-
transaction_id = job.job.data.transaction_id,
413+
transaction_id = %job.job.data.transaction_id,
414+
chain_id = job.job.data.chain_id,
415+
client_id = job
416+
.job
417+
.data
418+
.rpc_credentials
419+
.client_id_for_logs()
420+
.unwrap_or("unknown"),
421+
queue_id = EIP7702_CONFIRM_QUEUE_ID,
381422
error = ?e,
382423
"Failed to queue fail webhook"
383424
);

executors/src/eip7702_executor/send.rs

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ use crate::{
3636

3737
use super::confirm::{Eip7702ConfirmationHandler, Eip7702ConfirmationJobData};
3838

39+
const EIP7702_SEND_QUEUE_ID: &str = "eip7702_send";
40+
const EIP7702_CONFIRM_QUEUE_ID: &str = "eip7702_confirm";
41+
3942
// --- Job Payload ---
4043
#[derive(Serialize, Deserialize, Debug, Clone)]
4144
#[serde(rename_all = "camelCase")]
@@ -175,7 +178,7 @@ where
175178
type ErrorData = Eip7702SendError;
176179
type JobData = Eip7702SendJobData;
177180

178-
#[tracing::instrument(skip(self, job), fields(transaction_id = job.job.id, stage = Self::stage_name(), executor = Self::executor_name()))]
181+
#[tracing::instrument(skip(self, job), fields(transaction_id = job.job.id, chain_id = job.job.data.chain_id, client_id = ?job.job.data.rpc_credentials.client_id_for_logs(), queue_id = EIP7702_SEND_QUEUE_ID, stage = Self::stage_name(), executor = Self::executor_name()))]
179182
async fn process(
180183
&self,
181184
job: &BorrowedJob<Self::JobData>,
@@ -386,7 +389,15 @@ where
386389

387390
if let Err(e) = tx.queue_job(confirmation_job) {
388391
tracing::error!(
389-
transaction_id = job.job.data.transaction_id,
392+
transaction_id = %job.job.data.transaction_id,
393+
chain_id = job.job.data.chain_id,
394+
client_id = job
395+
.job
396+
.data
397+
.rpc_credentials
398+
.client_id_for_logs()
399+
.unwrap_or("unknown"),
400+
queue_id = EIP7702_CONFIRM_QUEUE_ID,
390401
error = ?e,
391402
"Failed to enqueue confirmation job"
392403
);
@@ -395,7 +406,15 @@ where
395406
// Send webhook
396407
if let Err(e) = self.queue_success_webhook(job, success_data, tx) {
397408
tracing::error!(
398-
transaction_id = job.job.data.transaction_id,
409+
transaction_id = %job.job.data.transaction_id,
410+
chain_id = job.job.data.chain_id,
411+
client_id = job
412+
.job
413+
.data
414+
.rpc_credentials
415+
.client_id_for_logs()
416+
.unwrap_or("unknown"),
417+
queue_id = EIP7702_SEND_QUEUE_ID,
399418
error = ?e,
400419
"Failed to queue success webhook"
401420
);
@@ -411,7 +430,15 @@ where
411430
// Don't modify transaction registry on NACK - job will be retried
412431
if let Err(e) = self.queue_nack_webhook(job, nack_data, tx) {
413432
tracing::error!(
414-
transaction_id = job.job.data.transaction_id,
433+
transaction_id = %job.job.data.transaction_id,
434+
chain_id = job.job.data.chain_id,
435+
client_id = job
436+
.job
437+
.data
438+
.rpc_credentials
439+
.client_id_for_logs()
440+
.unwrap_or("unknown"),
441+
queue_id = EIP7702_SEND_QUEUE_ID,
415442
error = ?e,
416443
"Failed to queue nack webhook"
417444
);
@@ -429,14 +456,30 @@ where
429456
.add_remove_command(tx.pipeline(), &job.job.data.transaction_id);
430457

431458
tracing::error!(
432-
transaction_id = job.job.data.transaction_id,
459+
transaction_id = %job.job.data.transaction_id,
460+
chain_id = job.job.data.chain_id,
461+
client_id = job
462+
.job
463+
.data
464+
.rpc_credentials
465+
.client_id_for_logs()
466+
.unwrap_or("unknown"),
467+
queue_id = EIP7702_SEND_QUEUE_ID,
433468
error = ?fail_data.error,
434469
"EIP-7702 send job failed"
435470
);
436471

437472
if let Err(e) = self.queue_fail_webhook(job, fail_data, tx) {
438473
tracing::error!(
439-
transaction_id = job.job.data.transaction_id,
474+
transaction_id = %job.job.data.transaction_id,
475+
chain_id = job.job.data.chain_id,
476+
client_id = job
477+
.job
478+
.data
479+
.rpc_credentials
480+
.client_id_for_logs()
481+
.unwrap_or("unknown"),
482+
queue_id = EIP7702_SEND_QUEUE_ID,
440483
error = ?e,
441484
"Failed to queue fail webhook"
442485
);

executors/src/eoa/store/atomic.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use crate::{
3131

3232
const MAX_RETRIES: u32 = 10;
3333
const RETRY_BASE_DELAY_MS: u64 = 10;
34+
const EOA_QUEUE_ID: &str = "eoa_executor";
3435

3536
pub trait SafeRedisTransaction: Send + Sync {
3637
type ValidationData;
@@ -613,7 +614,18 @@ impl AtomicEoaExecutorStore {
613614
&mut tx_context,
614615
webhook_queue.clone(),
615616
) {
616-
tracing::error!("Failed to queue webhook for fail: {}", e);
617+
tracing::error!(
618+
transaction_id = %pending_transaction.transaction_id,
619+
chain_id = pending_transaction.user_request.chain_id,
620+
client_id = pending_transaction
621+
.user_request
622+
.rpc_credentials
623+
.client_id_for_logs()
624+
.unwrap_or("unknown"),
625+
queue_id = EOA_QUEUE_ID,
626+
"Failed to queue webhook for fail: {}",
627+
e
628+
);
617629
}
618630
}
619631

@@ -695,6 +707,13 @@ impl AtomicEoaExecutorStore {
695707
) {
696708
tracing::error!(
697709
transaction_id = %pending_transaction.transaction_id,
710+
chain_id = pending_transaction.user_request.chain_id,
711+
client_id = pending_transaction
712+
.user_request
713+
.rpc_credentials
714+
.client_id_for_logs()
715+
.unwrap_or("unknown"),
716+
queue_id = EOA_QUEUE_ID,
698717
error = ?e,
699718
"Failed to queue webhook for batch fail"
700719
);

executors/src/eoa/store/borrowed.rs

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ use crate::eoa::{
1616
use crate::metrics::{EoaMetrics, calculate_duration_seconds, current_timestamp_ms};
1717
use crate::webhook::{WebhookJobHandler, queue_webhook_envelopes};
1818

19+
const EOA_QUEUE_ID: &str = "eoa_executor";
20+
1921
#[derive(Debug, Clone)]
2022
pub enum SubmissionResultType {
2123
Success,
@@ -173,7 +175,19 @@ impl SafeRedisTransaction for ProcessBorrowedTransactions<'_> {
173175
&mut tx_context,
174176
self.webhook_queue.clone(),
175177
) {
176-
tracing::error!("Failed to queue webhook for success: {}", e);
178+
tracing::error!(
179+
transaction_id = transaction_id,
180+
chain_id = result.transaction.user_request.chain_id,
181+
client_id = result
182+
.transaction
183+
.user_request
184+
.rpc_credentials
185+
.client_id_for_logs()
186+
.unwrap_or("unknown"),
187+
queue_id = EOA_QUEUE_ID,
188+
"Failed to queue webhook for success: {}",
189+
e
190+
);
177191
} else {
178192
report.webhook_events_queued += 1;
179193
}
@@ -213,7 +227,19 @@ impl SafeRedisTransaction for ProcessBorrowedTransactions<'_> {
213227
&mut tx_context,
214228
self.webhook_queue.clone(),
215229
) {
216-
tracing::error!("Failed to queue webhook for nack: {}", e);
230+
tracing::error!(
231+
transaction_id = transaction_id,
232+
chain_id = result.transaction.user_request.chain_id,
233+
client_id = result
234+
.transaction
235+
.user_request
236+
.rpc_credentials
237+
.client_id_for_logs()
238+
.unwrap_or("unknown"),
239+
queue_id = EOA_QUEUE_ID,
240+
"Failed to queue webhook for nack: {}",
241+
e
242+
);
217243
} else {
218244
report.webhook_events_queued += 1;
219245
}
@@ -255,7 +281,19 @@ impl SafeRedisTransaction for ProcessBorrowedTransactions<'_> {
255281
&mut tx_context,
256282
self.webhook_queue.clone(),
257283
) {
258-
tracing::error!("Failed to queue webhook for fail: {}", e);
284+
tracing::error!(
285+
transaction_id = transaction_id,
286+
chain_id = result.transaction.user_request.chain_id,
287+
client_id = result
288+
.transaction
289+
.user_request
290+
.rpc_credentials
291+
.client_id_for_logs()
292+
.unwrap_or("unknown"),
293+
queue_id = EOA_QUEUE_ID,
294+
"Failed to queue webhook for fail: {}",
295+
e
296+
);
259297
} else {
260298
report.webhook_events_queued += 1;
261299
}

executors/src/eoa/store/submitted.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ use crate::{
2222
webhook::{WebhookJobHandler, queue_webhook_envelopes},
2323
};
2424

25+
const EOA_QUEUE_ID: &str = "eoa_executor";
26+
2527
#[derive(Debug, Clone)]
2628
pub struct SubmittedTransaction {
2729
pub data: SubmittedTransactionDehydrated,
@@ -397,6 +399,14 @@ impl SafeRedisTransaction for CleanSubmittedTransactions<'_> {
397399
self.webhook_queue.clone(),
398400
) {
399401
tracing::error!(
402+
transaction_id = %tx.transaction_id,
403+
chain_id = tx.user_request.chain_id,
404+
client_id = tx
405+
.user_request
406+
.rpc_credentials
407+
.client_id_for_logs()
408+
.unwrap_or("unknown"),
409+
queue_id = EOA_QUEUE_ID,
400410
"Failed to queue webhook for confirmed transaction: {}",
401411
e
402412
);
@@ -436,6 +446,14 @@ impl SafeRedisTransaction for CleanSubmittedTransactions<'_> {
436446
self.webhook_queue.clone(),
437447
) {
438448
tracing::error!(
449+
transaction_id = %tx.transaction_id,
450+
chain_id = tx.user_request.chain_id,
451+
client_id = tx
452+
.user_request
453+
.rpc_credentials
454+
.client_id_for_logs()
455+
.unwrap_or("unknown"),
456+
queue_id = EOA_QUEUE_ID,
439457
"Failed to queue webhook for replaced transaction: {}",
440458
e
441459
);

0 commit comments

Comments
 (0)