Skip to content

Commit

Permalink
fix retry (#1192)
Browse files Browse the repository at this point in the history
* fix retry

* update comments

* lint
  • Loading branch information
greged93 authored Jun 14, 2024
1 parent 3ec0300 commit e71a0b0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
3 changes: 2 additions & 1 deletion docker-compose.prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ services:
- starknet-explorer_prod:/var/lib/postgresql/data/

kakarot-rpc:
image: ghcr.io/kkrt-labs/kakarot-rpc/node:latest
image: ghcr.io/kkrt-labs/kakarot-rpc/node:v0.6.17
pull_policy: always
ports:
- 3030:3030
Expand Down Expand Up @@ -100,6 +100,7 @@ services:
- --rpc=http://starknet:6060
- --wait-for-rpc
- --data=/data
- --head-refresh-interval-ms=1000
ports:
- 7171:7171
volumes:
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ services:
- starknet_explorer_staging:/var/lib/postgresql/data/

kakarot-rpc:
image: ghcr.io/kkrt-labs/kakarot-rpc/node:latest
image: ghcr.io/kkrt-labs/kakarot-rpc/node:v0.6.19-alpha1
pull_policy: always
ports:
- 3030:3030
Expand Down Expand Up @@ -102,6 +102,7 @@ services:
- --rpc=http://starknet:6060
- --wait-for-rpc
- --data=/data
- --head-refresh-interval-ms=1000

### MongoDB with Mongo Express
mongo:
Expand Down
6 changes: 2 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@ services:
condition: service_completed_successfully

kakarot-rpc:
image: ghcr.io/kkrt-labs/kakarot-rpc/node:latest
# Always pull the latest image, until we use release tags
# TODO: use release tags
pull_policy: always
image: ghcr.io/kkrt-labs/kakarot-rpc/node:v0.6.18
ports:
- 3030:3030
environment:
Expand Down Expand Up @@ -99,6 +96,7 @@ services:
- --rpc=http://starknet:5050
- --wait-for-rpc
- --data=/data
- --head-refresh-interval-ms=500
ports:
- 7171:7171
volumes:
Expand Down
14 changes: 5 additions & 9 deletions src/eth_provider/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,22 +553,18 @@ where
let pending_transaction = self.database.get_one::<StoredPendingTransaction>(filter.clone(), None).await?;

// Number of retries for the transaction (0 if it's a new transaction)
let retries = pending_transaction.as_ref().map(|tx| tx.retries).unwrap_or_default();
let retries = pending_transaction.as_ref().map(|tx| tx.retries + 1).unwrap_or_default();

// Serialize transaction document
let transaction =
from_recovered(TransactionSignedEcRecovered::from_signed_transaction(transaction_signed.clone(), signer));

// Update or insert the pending transaction in the database
if let Some(pending_transaction) = pending_transaction {
tracing::info!(
"Updating transaction {}, retries: {}.",
transaction.hash.to_string(),
pending_transaction.retries + 1
);
if pending_transaction.is_some() {
tracing::info!("Updating transaction {}, retries: {}.", transaction.hash.to_string(), retries);
self.database
.update_one::<StoredPendingTransaction>(
StoredPendingTransaction::new(transaction, pending_transaction.retries + 1),
StoredPendingTransaction::new(transaction, retries),
filter,
true,
)
Expand All @@ -585,7 +581,7 @@ where

// Convert the transaction to a Starknet transaction
let starknet_transaction =
to_starknet_transaction(&transaction_signed, maybe_chain_id, signer, max_fee, retries + 1)?;
to_starknet_transaction(&transaction_signed, maybe_chain_id, signer, max_fee, retries)?;

// Deploy EVM transaction signer if Hive feature is enabled
#[cfg(feature = "hive")]
Expand Down

0 comments on commit e71a0b0

Please sign in to comment.