Skip to content

Commit

Permalink
chore: improve relayers (#1448)
Browse files Browse the repository at this point in the history
improve relayers
  • Loading branch information
greged93 authored Oct 11, 2024
1 parent fa0adcd commit 1aa3ac8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/pool/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use starknet::{
};
use std::{collections::HashMap, sync::Arc, time::Duration};
use tokio::sync::Mutex;
use tracing::instrument;

/// A type alias for the Kakarot Transaction Validator.
/// Uses the Reth implementation [`TransactionValidationTaskExecutor`].
Expand Down Expand Up @@ -67,6 +68,7 @@ impl<SP: starknet::providers::Provider + Send + Sync + Clone + 'static> AccountM
}

/// Starts the account manager task that periodically checks account balances and processes transactions.
#[instrument(skip_all, name = "mempool")]
pub fn start(self) {
let this = Arc::new(self);

Expand Down
8 changes: 4 additions & 4 deletions src/providers/eth_provider/starknet/relayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
use reth_primitives::TransactionSigned;
use starknet::{
accounts::{Account, ExecutionEncoding, ExecutionV1, SingleOwnerAccount},
core::types::Felt,
core::types::{Felt, NonZeroFelt},
providers::Provider,
signers::{LocalWallet, SigningKey},
};
Expand Down Expand Up @@ -64,9 +64,9 @@ where
let mut execution = ExecutionV1::new(vec![call], &self.account);
execution = execution.nonce(*self.nonce);

// We set the max fee to the balance of the account - 1. This might cause some issues in the future
// and should be replaced by a simulation of the transaction (?)
execution = execution.max_fee(self.balance - 1);
// We set the max fee to the balance of the account / 5. This means that the account could
// send up to 5 transactions before hitting a feeder gateway error.
execution = execution.max_fee(self.balance.floor_div(&NonZeroFelt::from_felt_unchecked(5.into())));

let prepared = execution.prepared().map_err(|_| SignatureError::SigningFailure)?;
let res = prepared.send().await.map_err(|err| TransactionError::Broadcast(err.into()))?;
Expand Down

0 comments on commit 1aa3ac8

Please sign in to comment.