Skip to content

Commit b61e95e

Browse files
Renames for consistency accross executors (#17)
* normalize stage names * rename hash to transaction_hash
1 parent 5feaa18 commit b61e95e

File tree

12 files changed

+52
-43
lines changed

12 files changed

+52
-43
lines changed

core/src/execution_options/mod.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub enum SpecificExecutionOptions {
3838
#[schema(title = "ERC-4337 Execution Options")]
3939
ERC4337(aa::Erc4337ExecutionOptions),
4040

41-
#[serde(rename = "eoa")]
41+
#[serde(rename = "EOA")]
4242
#[schema(title = "EOA Execution Options")]
4343
EOA(eoa::EoaExecutionOptions),
4444

@@ -188,7 +188,7 @@ impl ExecutionOptions {
188188
#[cfg(test)]
189189
mod tests {
190190
use super::*;
191-
191+
192192
#[test]
193193
fn test_webhook_options_user_metadata_validation() {
194194
// Test valid metadata
@@ -197,27 +197,33 @@ mod tests {
197197
"secret": "test_secret",
198198
"userMetadata": "test metadata"
199199
}"#;
200-
200+
201201
let webhook_options: Result<WebhookOptions, _> = serde_json::from_str(valid_json);
202202
assert!(webhook_options.is_ok());
203-
assert_eq!(webhook_options.unwrap().user_metadata, Some("test metadata".to_string()));
204-
203+
assert_eq!(
204+
webhook_options.unwrap().user_metadata,
205+
Some("test metadata".to_string())
206+
);
207+
205208
// Test metadata that's too large (over 4KB)
206209
let large_metadata = "x".repeat(5000); // 5KB string
207-
let invalid_json = format!(r#"{{
210+
let invalid_json = format!(
211+
r#"{{
208212
"url": "https://example.com/webhook",
209213
"secret": "test_secret",
210214
"userMetadata": "{}"
211-
}}"#, large_metadata);
212-
215+
}}"#,
216+
large_metadata
217+
);
218+
213219
let webhook_options: Result<WebhookOptions, _> = serde_json::from_str(&invalid_json);
214220
assert!(webhook_options.is_err());
215-
221+
216222
// Test missing metadata (should default to None)
217223
let minimal_json = r#"{
218224
"url": "https://example.com/webhook"
219225
}"#;
220-
226+
221227
let webhook_options: Result<WebhookOptions, _> = serde_json::from_str(minimal_json);
222228
assert!(webhook_options.is_ok());
223229
assert_eq!(webhook_options.unwrap().user_metadata, None);

core/src/signer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl Erc4337SigningOptions {
115115
#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)]
116116
#[serde(tag = "type", rename_all = "camelCase")]
117117
pub enum SigningOptions {
118-
#[serde(rename = "eoa")]
118+
#[serde(rename = "EOA")]
119119
#[schema(title = "EOA Signing Options")]
120120
Eoa(EoaSigningOptions),
121121

executors/src/eip7702_executor/send.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ where
160160
}
161161

162162
fn stage_name() -> &'static str {
163-
"prepare_and_send"
163+
"send"
164164
}
165165
}
166166

executors/src/eoa/events.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl Display for EoaExecutorStage {
4949
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5050
match self {
5151
EoaExecutorStage::Send => write!(f, "send"),
52-
EoaExecutorStage::Confirmation => write!(f, "confirmation"),
52+
EoaExecutorStage::Confirmation => write!(f, "confirm"),
5353
}
5454
}
5555
}
@@ -110,7 +110,7 @@ impl EoaExecutorEvent {
110110
payload: SerializableNackData {
111111
error: EoaConfirmationError::TransactionReplaced {
112112
nonce: replaced_transaction.nonce,
113-
hash: replaced_transaction.hash,
113+
hash: replaced_transaction.transaction_hash,
114114
},
115115
delay_ms: None,
116116
position: RequeuePosition::Last,

executors/src/eoa/store/borrowed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ impl SafeRedisTransaction for ProcessBorrowedTransactions<'_> {
129129
// Update hash-to-ID mapping
130130
let hash_to_id_key = self
131131
.keys
132-
.transaction_hash_to_id_key_name(&result.transaction.hash);
132+
.transaction_hash_to_id_key_name(&result.transaction.transaction_hash);
133133

134134
pipeline.set(&hash_to_id_key, transaction_id);
135135

executors/src/eoa/store/hydrate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl Dehydrated<SubmittedTransactionHydrator> for SubmittedTransactionDehydrated
3535
SubmittedTransactionHydrator::Noop => {
3636
SubmittedTransactionHydrated::Noop(SubmittedNoopTransaction {
3737
nonce: self.nonce,
38-
hash: self.hash,
38+
transaction_hash: self.transaction_hash,
3939
})
4040
}
4141
SubmittedTransactionHydrator::Real(request) => {

executors/src/eoa/store/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ pub const NO_OP_TRANSACTION_ID: &str = "noop";
3030

3131
#[derive(Debug, Clone)]
3232
pub struct ReplacedTransaction {
33-
pub hash: String,
33+
pub transaction_hash: String,
3434
pub transaction_id: String,
3535
}
3636

3737
#[derive(Debug, Clone)]
3838
pub struct ConfirmedTransaction {
39-
pub hash: String,
39+
pub transaction_hash: String,
4040
pub transaction_id: String,
4141
pub receipt: alloy::rpc::types::TransactionReceipt,
4242
pub receipt_serialized: String,
@@ -338,7 +338,7 @@ impl From<BorrowedTransactionData> for SubmittedTransactionDehydrated {
338338
fn from(data: BorrowedTransactionData) -> Self {
339339
SubmittedTransactionDehydrated {
340340
nonce: data.signed_transaction.nonce(),
341-
hash: data.signed_transaction.hash().to_string(),
341+
transaction_hash: data.signed_transaction.hash().to_string(),
342342
transaction_id: data.transaction_id.clone(),
343343
queued_at: data.queued_at,
344344
}

executors/src/eoa/store/submitted.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ impl Deref for SubmittedTransaction {
3535
#[derive(Debug, Clone)]
3636
pub struct SubmittedNoopTransaction {
3737
pub nonce: u64,
38-
pub hash: String,
38+
pub transaction_hash: String,
3939
}
4040

4141
pub type SubmittedTransactionStringWithNonce = (String, u64);
4242

4343
impl SubmittedNoopTransaction {
4444
pub fn to_redis_string_with_nonce(&self) -> SubmittedTransactionStringWithNonce {
4545
(
46-
format!("{}:{}:0", self.hash, NO_OP_TRANSACTION_ID),
46+
format!("{}:{}:0", self.transaction_hash, NO_OP_TRANSACTION_ID),
4747
self.nonce,
4848
)
4949
}
@@ -58,8 +58,8 @@ pub enum SubmittedTransactionHydrated {
5858
impl SubmittedTransactionHydrated {
5959
pub fn hash(&self) -> &str {
6060
match self {
61-
SubmittedTransactionHydrated::Noop(tx) => &tx.hash,
62-
SubmittedTransactionHydrated::Real(tx) => &tx.hash,
61+
SubmittedTransactionHydrated::Noop(tx) => &tx.transaction_hash,
62+
SubmittedTransactionHydrated::Real(tx) => &tx.transaction_hash,
6363
}
6464
}
6565

@@ -89,7 +89,7 @@ impl SubmittedTransactionHydrated {
8989
#[serde(rename_all = "camelCase")]
9090
pub struct SubmittedTransactionDehydrated {
9191
pub nonce: u64,
92-
pub hash: String,
92+
pub transaction_hash: String,
9393
pub transaction_id: String,
9494
pub queued_at: u64,
9595
}
@@ -103,7 +103,7 @@ impl SubmittedTransactionDehydrated {
103103
if parts.len() == 3 {
104104
if let Ok(queued_at) = parts[2].parse::<u64>() {
105105
Some(SubmittedTransactionDehydrated {
106-
hash: parts[0].to_string(),
106+
transaction_hash: parts[0].to_string(),
107107
transaction_id: parts[1].to_string(),
108108
nonce: tx.1,
109109
queued_at,
@@ -136,7 +136,10 @@ impl SubmittedTransactionDehydrated {
136136
/// The nonce is the value of the transaction in the submitted state, and is used as the score of the submitted zset
137137
pub fn to_redis_string_with_nonce(&self) -> SubmittedTransactionStringWithNonce {
138138
(
139-
format!("{}:{}:{}", self.hash, self.transaction_id, self.queued_at),
139+
format!(
140+
"{}:{}:{}",
141+
self.transaction_hash, self.transaction_id, self.queued_at
142+
),
140143
self.nonce,
141144
)
142145
}
@@ -226,7 +229,7 @@ impl SafeRedisTransaction for CleanSubmittedTransactions<'_> {
226229
let confirmed_hashes: HashSet<&str> = self
227230
.confirmed_transactions
228231
.iter()
229-
.map(|tx| tx.hash.as_str())
232+
.map(|tx| tx.transaction_hash.as_str())
230233
.collect();
231234

232235
let confirmed_ids: BTreeMap<&str, ConfirmedTransaction> = self
@@ -396,8 +399,8 @@ fn detect_violations<'a>(
396399
for (nonce, txs) in &txs_by_nonce {
397400
let confirmed_hashes_for_nonce: Vec<String> = txs
398401
.iter()
399-
.filter(|tx| confirmed_hashes.contains(tx.hash.as_str()))
400-
.map(|tx| tx.hash.clone())
402+
.filter(|tx| confirmed_hashes.contains(tx.transaction_hash.as_str()))
403+
.map(|tx| tx.transaction_hash.clone())
401404
.collect();
402405

403406
if confirmed_hashes_for_nonce.len() > 1 {
@@ -411,9 +414,9 @@ fn detect_violations<'a>(
411414
for (nonce, txs) in &txs_by_nonce {
412415
let has_confirmed = txs
413416
.iter()
414-
.any(|tx| confirmed_hashes.contains(tx.hash.as_str()));
417+
.any(|tx| confirmed_hashes.contains(tx.transaction_hash.as_str()));
415418
if !has_confirmed {
416-
let hashes: Vec<String> = txs.iter().map(|tx| tx.hash.clone()).collect();
419+
let hashes: Vec<String> = txs.iter().map(|tx| tx.transaction_hash.clone()).collect();
417420
report.nonces_without_receipts.push((*nonce, hashes));
418421
}
419422
}

executors/src/eoa/worker/confirm.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const NONCE_STALL_TIMEOUT: u64 = 300_000; // 5 minutes in milliseconds - after t
1919
#[serde(rename_all = "camelCase")]
2020
pub struct ConfirmedTransactionWithRichReceipt {
2121
pub nonce: u64,
22-
pub hash: String,
22+
pub transaction_hash: String,
2323
pub transaction_id: String,
2424
pub receipt: alloy::rpc::types::TransactionReceipt,
2525
}
@@ -122,7 +122,7 @@ impl<C: Chain> EoaExecutorWorker<C> {
122122
Err(e) => {
123123
tracing::warn!(
124124
transaction_id = %tx.transaction_id,
125-
hash = %tx.hash,
125+
hash = %tx.transaction_hash,
126126
error = %e,
127127
"Failed to serialize receipt as JSON, using debug format"
128128
);
@@ -133,12 +133,12 @@ impl<C: Chain> EoaExecutorWorker<C> {
133133
tracing::info!(
134134
transaction_id = %tx.transaction_id,
135135
nonce = tx.nonce,
136-
hash = %tx.hash,
136+
hash = %tx.transaction_hash,
137137
"Transaction confirmed"
138138
);
139139

140140
ConfirmedTransaction {
141-
hash: tx.hash,
141+
transaction_hash: tx.transaction_hash,
142142
transaction_id: tx.transaction_id,
143143
receipt: tx.receipt.into(),
144144
receipt_serialized: receipt_data,
@@ -169,7 +169,7 @@ impl<C: Chain> EoaExecutorWorker<C> {
169169
// Fetch all receipts in parallel
170170
let receipt_futures: Vec<_> = submitted_txs
171171
.iter()
172-
.filter_map(|tx| match tx.hash.parse::<B256>() {
172+
.filter_map(|tx| match tx.transaction_hash.parse::<B256>() {
173173
Ok(hash_bytes) => Some(async move {
174174
let receipt = self
175175
.chain
@@ -179,7 +179,7 @@ impl<C: Chain> EoaExecutorWorker<C> {
179179
(tx, receipt)
180180
}),
181181
Err(_) => {
182-
tracing::warn!("Invalid hash format: {}, skipping", tx.hash);
182+
tracing::warn!("Invalid hash format: {}, skipping", tx.transaction_hash);
183183
None
184184
}
185185
})
@@ -196,14 +196,14 @@ impl<C: Chain> EoaExecutorWorker<C> {
196196
Ok(Some(receipt)) => {
197197
confirmed_txs.push(ConfirmedTransactionWithRichReceipt {
198198
nonce: tx.nonce,
199-
hash: tx.hash.clone(),
199+
transaction_hash: tx.transaction_hash.clone(),
200200
transaction_id: tx.transaction_id.clone(),
201201
receipt,
202202
});
203203
}
204204
Ok(None) | Err(_) => {
205205
failed_txs.push(ReplacedTransaction {
206-
hash: tx.hash.clone(),
206+
transaction_hash: tx.transaction_hash.clone(),
207207
transaction_id: tx.transaction_id.clone(),
208208
});
209209
}
@@ -323,7 +323,7 @@ impl<C: Chain> EoaExecutorWorker<C> {
323323
.add_gas_bump_attempt(
324324
&SubmittedTransactionDehydrated {
325325
nonce: expected_nonce,
326-
hash: bumped_tx.hash().to_string(),
326+
transaction_hash: bumped_tx.hash().to_string(),
327327
transaction_id: transaction_id.to_string(),
328328
queued_at: tx_data.created_at,
329329
},

executors/src/eoa/worker/transaction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ impl<C: Chain> EoaExecutorWorker<C> {
156156
})
157157
.map(|pending| SubmittedNoopTransaction {
158158
nonce,
159-
hash: pending.tx_hash().to_string(),
159+
transaction_hash: pending.tx_hash().to_string(),
160160
})
161161
}
162162

0 commit comments

Comments
 (0)