Skip to content

Commit 581460a

Browse files
committed
feat: allow gas bumps to be config in the network config
1 parent 075a924 commit 581460a

File tree

45 files changed

+323
-90
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+323
-90
lines changed

TODO.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44

55
31st September plan:
66
- Last change for the gas bumping + price in bump_every config
7+
- Look into authentication to login and then use it outside rrelayer.yaml
78
- Reread documentation
9+
- TransactionSpeed code snippets tag default
810
- Get CI builds / releases working
911
- Testing
1012
- loading up ALL supported gas providers so it works
1113
- Testing handling custom gas with http call
12-
- Look into authentication to login and then use it outside rrelayer.yaml
1314
- Release—20:00 UK time
1415

1516
# AFTER

crates/cli/src/commands/network.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ async fn handle_add(project_path: &ProjectLocation) -> Result<(), NetworkError>
108108
permissions: None,
109109
api_keys: None,
110110
enable_sending_blobs: Some(true),
111+
gas_bump_blocks_every: Default::default(),
111112
});
112113

113114
project_path.overwrite_setup_config(setup_config)?;

crates/cli/src/commands/new.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ pub async fn handle_init(path: &Path) -> Result<(), InitError> {
7272
permissions: None,
7373
api_keys: None,
7474
enable_sending_blobs: Some(true),
75+
gas_bump_blocks_every: Default::default(),
7576
}],
7677
gas_providers: None,
7778
api_config: ApiConfig {

crates/core/src/relayer/api/clone_relayer.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ pub async fn clone_relayer(
5252
let id = relayer.id;
5353
let address = relayer.address;
5454

55+
let gas_bump_config = state
56+
.network_configs
57+
.iter()
58+
.find(|config| config.chain_id == relayer.chain_id)
59+
.map(|config| config.gas_bump_blocks_every.clone())
60+
.unwrap_or_default();
61+
5562
state
5663
.transactions_queues
5764
.lock()
@@ -65,6 +72,7 @@ pub async fn clone_relayer(
6572
Default::default(),
6673
Default::default(),
6774
state.safe_proxy_manager.clone(),
75+
gas_bump_config,
6876
),
6977
state.transactions_queues.clone(),
7078
)

crates/core/src/relayer/api/create_relayer.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ pub async fn create_relayer(
5656
let id = relayer.id;
5757
let address = relayer.address;
5858

59+
let gas_bump_config = state
60+
.network_configs
61+
.iter()
62+
.find(|config| config.chain_id == chain_id)
63+
.map(|config| config.gas_bump_blocks_every.clone())
64+
.unwrap_or_default();
65+
5966
state
6067
.transactions_queues
6168
.lock()
@@ -69,6 +76,7 @@ pub async fn create_relayer(
6976
Default::default(),
7077
Default::default(),
7178
state.safe_proxy_manager.clone(),
79+
gas_bump_config,
7280
),
7381
state.transactions_queues.clone(),
7482
)

crates/core/src/startup.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ pub async fn start(project_path: &Path) -> Result<(), StartError> {
346346
cache.clone(),
347347
webhook_manager.clone(),
348348
safe_proxy_manager.clone(),
349+
Arc::new(config.networks.clone()),
349350
)
350351
.await?;
351352

crates/core/src/transaction/queue_system/start.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ pub async fn startup_transactions_queues(
359359
cache: Arc<Cache>,
360360
webhook_manager: Option<Arc<Mutex<WebhookManager>>>,
361361
safe_proxy_manager: Arc<SafeProxyManager>,
362+
network_configs: Arc<Vec<crate::yaml::NetworkSetupConfig>>,
362363
) -> Result<Arc<Mutex<TransactionsQueues>>, StartTransactionsQueuesError> {
363364
let postgres = PostgresClient::new()
364365
.await
@@ -388,6 +389,12 @@ pub async fn startup_transactions_queues(
388389
repopulate_transaction_queue(&postgres, &relayer_id, &TransactionStatus::MINED)
389390
.await?;
390391

392+
let gas_bump_config = network_configs
393+
.iter()
394+
.find(|config| config.chain_id == relayer.chain_id)
395+
.map(|config| config.gas_bump_blocks_every.clone())
396+
.unwrap_or_default();
397+
391398
transaction_relayer_setups.push(TransactionRelayerSetup::new(
392399
relayer,
393400
evm_provider,
@@ -402,6 +409,7 @@ pub async fn startup_transactions_queues(
402409
.into_iter()
403410
.map(|transaction| (transaction.id, transaction))
404411
.collect(),
412+
gas_bump_config,
405413
));
406414
}
407415
}

crates/core/src/transaction/queue_system/transactions_queue.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use crate::{
2626
nonce_manager::NonceManager,
2727
types::{Transaction, TransactionHash, TransactionId, TransactionSpeed, TransactionStatus},
2828
},
29+
yaml::GasBumpBlockConfig,
2930
WalletError,
3031
};
3132
use alloy::network::{AnyTransactionReceipt, ReceiptResponse};
@@ -50,6 +51,7 @@ pub struct TransactionsQueue {
5051
blob_oracle_cache: Arc<Mutex<BlobGasOracleCache>>,
5152
confirmations: u64,
5253
safe_proxy_manager: Arc<SafeProxyManager>,
54+
gas_bump_config: GasBumpBlockConfig,
5355
}
5456

5557
impl TransactionsQueue {
@@ -74,16 +76,12 @@ impl TransactionsQueue {
7476
blob_oracle_cache,
7577
confirmations,
7678
safe_proxy_manager: setup.safe_proxy_manager,
79+
gas_bump_config: setup.gas_bump_config,
7780
}
7881
}
7982

8083
fn blocks_to_wait_before_bump(&self, speed: &TransactionSpeed) -> u64 {
81-
match speed {
82-
TransactionSpeed::SLOW => 10,
83-
TransactionSpeed::MEDIUM => 5,
84-
TransactionSpeed::FAST => 4,
85-
TransactionSpeed::SUPER => 2,
86-
}
84+
self.gas_bump_config.blocks_to_wait_before_bump(speed)
8785
}
8886

8987
pub fn should_bump_gas(&self, ms_between_times: u64, speed: &TransactionSpeed) -> bool {

crates/core/src/transaction/queue_system/transactions_queues.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ impl TransactionsQueues {
9494
setup.inmempool_transactions,
9595
setup.mined_transactions,
9696
safe_proxy_manager.clone(),
97+
setup.gas_bump_config,
9798
),
9899
gas_oracle_cache.clone(),
99100
blob_gas_oracle_cache.clone(),
@@ -182,6 +183,7 @@ impl TransactionsQueues {
182183
VecDeque::new(),
183184
HashMap::new(),
184185
self.safe_proxy_manager.clone(),
186+
setup.gas_bump_config,
185187
),
186188
self.gas_oracle_cache.clone(),
187189
self.blob_gas_oracle_cache.clone(),

crates/core/src/transaction/queue_system/types/transaction_relayer_setup.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::{
55
provider::EvmProvider,
66
relayer::Relayer,
77
transaction::types::{Transaction, TransactionId},
8+
yaml::GasBumpBlockConfig,
89
};
910

1011
pub struct TransactionRelayerSetup {
@@ -13,6 +14,7 @@ pub struct TransactionRelayerSetup {
1314
pub pending_transactions: VecDeque<Transaction>,
1415
pub inmempool_transactions: VecDeque<CompetitiveTransaction>,
1516
pub mined_transactions: HashMap<TransactionId, Transaction>,
17+
pub gas_bump_config: GasBumpBlockConfig,
1618
}
1719

1820
impl TransactionRelayerSetup {
@@ -22,13 +24,15 @@ impl TransactionRelayerSetup {
2224
pending_transactions: VecDeque<Transaction>,
2325
inmempool_transactions: VecDeque<CompetitiveTransaction>,
2426
mined_transactions: HashMap<TransactionId, Transaction>,
27+
gas_bump_config: GasBumpBlockConfig,
2528
) -> Self {
2629
TransactionRelayerSetup {
2730
relayer,
2831
evm_provider,
2932
pending_transactions,
3033
inmempool_transactions,
3134
mined_transactions,
35+
gas_bump_config,
3236
}
3337
}
3438
}

0 commit comments

Comments
 (0)