Skip to content

Commit 48dcd3e

Browse files
authored
Proper non_mempool_coinbase_profit on DelayedRefunds (#801)
## 📝 Summary SimValue::non_mempool_coinbase_profit was not properly computed with Delayed refunds.
1 parent 4c5d8b0 commit 48dcd3e

File tree

1 file changed

+8
-7
lines changed
  • crates/rbuilder/src/building

1 file changed

+8
-7
lines changed

crates/rbuilder/src/building/mod.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,17 +1301,18 @@ pub fn create_sim_value(
13011301
// We don't filter for mempool txs.
13021302
order_ok.coinbase_profit
13031303
} else {
1304-
let non_mempool_coinbase_profit = order_ok
1304+
let mempool_coinbase_profit = order_ok
13051305
.tx_infos
13061306
.iter()
1307-
.filter(|tx_info| !mempool_detector.is_mempool(&tx_info.tx))
1307+
.filter(|tx_info| mempool_detector.is_mempool(&tx_info.tx))
13081308
.map(|tx_info| tx_info.coinbase_profit)
13091309
.sum::<I256>();
1310-
if non_mempool_coinbase_profit.is_zero() || non_mempool_coinbase_profit.is_positive() {
1311-
non_mempool_coinbase_profit.unsigned_abs()
1310+
if mempool_coinbase_profit.is_positive() {
1311+
order_ok
1312+
.coinbase_profit
1313+
.saturating_sub(mempool_coinbase_profit.unsigned_abs())
13121314
} else {
1313-
// This could be a bundle which was positive thanks to the inclusion of mempool txs.
1314-
U256::ZERO
1315+
order_ok.coinbase_profit
13151316
}
13161317
};
13171318

@@ -1345,7 +1346,7 @@ mod test {
13451346
let profit_1 = I256::unchecked_from(1000);
13461347
let profit_2 = I256::unchecked_from(10000);
13471348
let order_ok = OrderOk {
1348-
coinbase_profit: Default::default(),
1349+
coinbase_profit: (profit_1 + profit_2).unsigned_abs(),
13491350
space_used: Default::default(),
13501351
cumulative_space_used: Default::default(),
13511352
tx_infos: vec![

0 commit comments

Comments
 (0)