From a38f21f8dbee75b69318f0431c65e8c5c8155f04 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Thu, 31 Oct 2024 11:11:41 +0400 Subject: [PATCH] only disallow -ive coinbase profit in mevshare fix ci fmt --- .github/workflows/checks.yaml | 2 +- crates/rbuilder/src/building/order_commit.rs | 28 +++++++------------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 3960f646..a492ebc4 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -55,7 +55,7 @@ jobs: version: nightly - name: Install native dependencies - run: sudo apt-get install -y libsqlite3-dev + run: sudo apt-get update && sudo apt-get upgrade && sudo apt-get install -y libsqlite3-dev - name: Lint run: make lint diff --git a/crates/rbuilder/src/building/order_commit.rs b/crates/rbuilder/src/building/order_commit.rs index 44d6d8d0..1f60627e 100644 --- a/crates/rbuilder/src/building/order_commit.rs +++ b/crates/rbuilder/src/building/order_commit.rs @@ -1011,16 +1011,11 @@ impl<'a, 'b, Tracer: SimulationTracer> PartialBlockFork<'a, 'b, Tracer> { )?; match res { Ok(ok) => { + // Builder does not sign txs in this code path, so allow negative coinbase + // profit. let coinbase_balance_after = self.state.balance(ctx.block_env.coinbase)?; - let coinbase_profit = match coinbase_profit( - coinbase_balance_before, - coinbase_balance_after, - ) { - Ok(profit) => profit, - Err(err) => { - return Ok(Err(err)); - } - }; + let coinbase_profit = + coinbase_balance_after.saturating_sub(coinbase_balance_before); Ok(Ok(OrderOk { coinbase_profit, gas_used: ok.gas_used, @@ -1049,16 +1044,11 @@ impl<'a, 'b, Tracer: SimulationTracer> PartialBlockFork<'a, 'b, Tracer> { )?; match res { Ok(ok) => { + // Builder does not sign txs in this code path, so allow negative coinbase + // profit. let coinbase_balance_after = self.state.balance(ctx.block_env.coinbase)?; - let coinbase_profit = match coinbase_profit( - coinbase_balance_before, - coinbase_balance_after, - ) { - Ok(profit) => profit, - Err(err) => { - return Ok(Err(err)); - } - }; + let coinbase_profit = + coinbase_balance_after.saturating_sub(coinbase_balance_before); Ok(Ok(OrderOk { coinbase_profit, gas_used: ok.gas_used, @@ -1088,6 +1078,8 @@ impl<'a, 'b, Tracer: SimulationTracer> PartialBlockFork<'a, 'b, Tracer> { match res { Ok(ok) => { let coinbase_balance_after = self.state.balance(ctx.block_env.coinbase)?; + // Builder does sign txs in this code path, so do not allow negative coinbase + // profit. let coinbase_profit = match coinbase_profit( coinbase_balance_before, coinbase_balance_after,