alloy-rs / alloy-rs/alloy

[Bug] Unable to Fetch Transaction Receipt Sometimes

Đang mở
#2,956 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
Rust
Star
1.3k
Fork
668
Merge trung bình
2 ngày 2 giờ
Pull request đã merge (30 ngày)
29

Mô tả

### Component

contract

### What version of Alloy are you on?

1.0.32

### Operating System

None

### Describe the bug

We are encountering an issue where a transaction is successfully sent, but the receipt is never generated.

**Error observed:**

```
Error writing to contract: transaction was not confirmed within the timeout
```

This behavior is typically observed during short bursts of transactions created by users interacting with the contract. Currently, I am **unable to reproduce this issue in the Anvil environment**.

**Example Transaction:**
[`0x26f55dc89cf0faa1f56dec4a9946c0f23f779fabe0f73cdcad8eb6c3912dcdb0`](https://explorer.gobob.xyz/tx/0x26f55dc89cf0faa1f56dec4a9946c0f23f779fabe0f73cdcad8eb6c3912dcdb0)

The transaction is confirmed in 4 seconds yet, I receive this error after approx 10 seconds.

**Error log snippet:**

```json
{
"timestamp": "2025-09-26T11:31:34.732041Z",
"level": "ERROR",
"fields": {
"message": "Failed to accept or transfer BTC for order: \n Order ID: 168 \n Amount Sent: 0.00080038 BTC \n Destination Address: bc1qrzhh583e0wczr8qhek8k8q4qwpr8auf24gsyrg,\n Reason: FailToAccept(\n \"Error writing to contract: transaction was not confirmed within the timeout\"\n )"
},
"target": "offramp_solver::scan_and_process_orders"
}
```

**Reference Code (Rust):**

```rust
pub async fn send_accept_order_tx(
offramp_registry: &GatewayOfframpRegistryV1Instance,
order_id: U256,
bob_transaction_timeout_in_secs: u64, // 10 sec in production
bob_transaction_block_confirmation_required: u64, // 2 blocks
) -> Result {
tracing::info!(order_id = %order_id, "Accepting order");

// Create and send transaction
let pending_tx = offramp_registry.acceptOrder(order_id).send().await?;

let tx_hash = pending_tx.tx_hash();
tracing::info!(%tx_hash, %order_id, "Accept order transaction sent");

// Wait for receipt
let tx_receipt = pending_tx
.with_required_confirmations(bob_transaction_block_confirmation_required)
.with_timeout(Some(Duration::from_secs(bob_transaction_timeout_in_secs)))
.get_receipt()
.await?;

if !tx_receipt.status() {
tracing::error!(
"Accept order tx reverted receipt: {:#?}, order id {}",
tx_receipt,
order_id
);
return Err(Error::AcceptOrderTxReverted(
order_id.to_string(),
tx_receipt.transaction_hash.to_string(),
));
}

Ok(tx_receipt.transaction_hash)
}
```

**Observations / Notes:**

* The issue occurs intermittently during high transaction bursts.
* Receipt never arrives despite transaction being sent.
* Timeout handling in `get_receipt()` is triggered.
* Not reproducible in local Anvil environment.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.