Skip to content

Commit 5a0732c

Browse files
authored
Redistribution fixes (#534)
## 📝 Summary Multiple fixes for redistribution. * Restore landing orders overhauled * allow beta-1 version for sbundle (real bundles with it still exist) * list_txs_revert is similar to list_txs but with enum instead of bool * add log when redistribution calculation is done for the block ## 💡 Motivation and Context <!--- (Optional) Why is this change required? What problem does it solve? Remove this section if not applicable. --> --- ## ✅ I have completed the following steps: * [ ] Run `make lint` * [ ] Run `make test` * [ ] Added tests (if applicable)
1 parent 4d87cf1 commit 5a0732c

File tree

4 files changed

+469
-298
lines changed

4 files changed

+469
-298
lines changed

crates/rbuilder/src/backtest/redistribute/mod.rs

+33
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use serde::{Deserialize, Serialize};
2828
use std::{
2929
cmp::{max, min},
3030
sync::Arc,
31+
time::Instant,
3132
};
3233
use tracing::{debug, error, info, info_span, trace, warn};
3334
use uuid::Uuid;
@@ -137,6 +138,7 @@ where
137138
warn!("Protect signers are not set");
138139
}
139140

141+
let start = Instant::now();
140142
let (onchain_block_profit, block_data, built_block_data) =
141143
prepare_block_data(config, block_data)?;
142144

@@ -157,13 +159,19 @@ where
157159
distribute_to_mempool_txs,
158160
);
159161

162+
let time_preparation_s = start.elapsed().as_millis() as f64 / 1000.0;
163+
let start = Instant::now();
164+
160165
let results_without_exclusion = calculate_backtest_without_exclusion(
161166
provider.clone(),
162167
config,
163168
block_data.clone(),
164169
blocklist.clone(),
165170
)?;
166171

172+
let time_no_exclusion_s = start.elapsed().as_millis() as f64 / 1000.0;
173+
let start = Instant::now();
174+
167175
let exclusion_results = calculate_backtest_identity_and_order_exclusion(
168176
provider.clone(),
169177
config,
@@ -173,6 +181,9 @@ where
173181
blocklist.clone(),
174182
)?;
175183

184+
let time_single_exclusion_s = start.elapsed().as_millis() as f64 / 1000.0;
185+
let start = Instant::now();
186+
176187
let exclusion_results = calc_joint_exclusion_results(
177188
provider.clone(),
178189
config,
@@ -184,6 +195,9 @@ where
184195
blocklist.clone(),
185196
)?;
186197

198+
let time_joint_exclusion_s = start.elapsed().as_millis() as f64 / 1000.0;
199+
let start = Instant::now();
200+
187201
let calculated_redistribution_result = apply_redistribution_formula(
188202
onchain_block_profit,
189203
&available_orders,
@@ -212,6 +226,25 @@ where
212226
.map(|o| o.redistribution_value_received)
213227
.sum::<U256>();
214228

229+
let time_result_s = start.elapsed().as_millis() as f64 / 1000.0;
230+
231+
let time_total_s = time_preparation_s
232+
+ time_no_exclusion_s
233+
+ time_single_exclusion_s
234+
+ time_joint_exclusion_s
235+
+ time_result_s;
236+
info!(
237+
block_profit = format_ether(onchain_block_profit),
238+
redistributed = format_ether(redistributed_identity_value),
239+
time_total_s,
240+
time_preparation_s,
241+
time_no_exclusion_s,
242+
time_single_exclusion_s,
243+
time_joint_exclusion_s,
244+
time_result_s,
245+
"Calculated redistribution"
246+
);
247+
215248
assert!(
216249
redistributed_identity_value <= onchain_block_profit,
217250
"Redistributed identity value is greater than onchain block profit"

0 commit comments

Comments
 (0)