Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow negative coinbase profit in Order::Tx and Order::Bundle #233

Merged
merged 2 commits into from
Nov 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 10 additions & 18 deletions crates/rbuilder/src/building/order_commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
liamaharon marked this conversation as resolved.
Show resolved Hide resolved
coinbase_balance_after.saturating_sub(coinbase_balance_before);
Ok(Ok(OrderOk {
coinbase_profit,
gas_used: ok.gas_used,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Loading