diff --git a/bolt-sidecar/src/primitives/commitment.rs b/bolt-sidecar/src/primitives/commitment.rs index ccfcb6ab..eba3461f 100644 --- a/bolt-sidecar/src/primitives/commitment.rs +++ b/bolt-sidecar/src/primitives/commitment.rs @@ -198,7 +198,10 @@ impl InclusionRequest { let tip = tx.effective_tip_per_gas(max_base_fee).unwrap_or_default(); if tip < min_priority_fee as u128 { - return Ok(false); + return Err(PricingError::TipTooLow { + tip, + min_priority_fee: min_priority_fee as u128, + }); } // Increment the preconfirmed gas for the next transaction in the bundle local_preconfirmed_gas = local_preconfirmed_gas.saturating_add(tx.gas_limit()); diff --git a/bolt-sidecar/src/state/execution.rs b/bolt-sidecar/src/state/execution.rs index 5a381492..8491243b 100644 --- a/bolt-sidecar/src/state/execution.rs +++ b/bolt-sidecar/src/state/execution.rs @@ -60,8 +60,8 @@ pub enum ValidationError { #[error("Max priority fee per gas is greater than max fee per gas")] MaxPriorityFeePerGasTooHigh, /// Max priority fee per gas is less than min priority fee. - #[error("Max priority fee per gas is less than min priority fee")] - MaxPriorityFeePerGasTooLow, + #[error("Max priority fee per gas {0} is less than min priority fee {1}")] + MaxPriorityFeePerGasTooLow(u128, u128), /// The sender does not have enough balance to pay for the transaction. #[error("Not enough balance to pay for value + maximum fee")] InsufficientBalance, @@ -113,7 +113,7 @@ impl ValidationError { Self::GasLimitTooHigh => "gas_limit_too_high", Self::TransactionSizeTooHigh => "transaction_size_too_high", Self::MaxPriorityFeePerGasTooHigh => "max_priority_fee_per_gas_too_high", - Self::MaxPriorityFeePerGasTooLow => "max_priority_fee_per_gas_too_low", + Self::MaxPriorityFeePerGasTooLow(_, _) => "max_priority_fee_per_gas_too_low", Self::InsufficientBalance => "insufficient_balance", Self::Pricing(_) => "pricing", Self::Eip4844Limit => "eip4844_limit", @@ -311,13 +311,18 @@ impl ExecutionState { // Ensure max_priority_fee_per_gas is greater than or equal to the calculated // min_priority_fee - if !req.validate_min_priority_fee( + if let Err(err) = req.validate_min_priority_fee( &self.pricing, template_committed_gas, self.limits.min_inclusion_profit, max_basefee, - )? { - return Err(ValidationError::MaxPriorityFeePerGasTooLow); + ) { + return Err(match err { + pricing::PricingError::TipTooLow { tip, min_priority_fee } => { + ValidationError::MaxPriorityFeePerGasTooLow(tip, min_priority_fee) + } + other => ValidationError::Pricing(other), + }); } if target_slot < self.slot { @@ -967,7 +972,7 @@ mod tests { assert!(matches!( state.validate_request(&mut request).await, - Err(ValidationError::MaxPriorityFeePerGasTooLow) + Err(ValidationError::MaxPriorityFeePerGasTooLow(_, _)) )); // Create a transaction with a max priority fee that is correct @@ -1010,7 +1015,7 @@ mod tests { assert!(matches!( state.validate_request(&mut request).await, - Err(ValidationError::MaxPriorityFeePerGasTooLow) + Err(ValidationError::MaxPriorityFeePerGasTooLow(_, _)) )); // Create a transaction with a gas price that is correct diff --git a/bolt-sidecar/src/state/pricing.rs b/bolt-sidecar/src/state/pricing.rs index e4703063..c470ebc5 100644 --- a/bolt-sidecar/src/state/pricing.rs +++ b/bolt-sidecar/src/state/pricing.rs @@ -35,6 +35,15 @@ pub enum PricingError { /// Gas required by the incoming transaction incoming_gas: u64, }, + + /// Tip is too low for the required minimum priority fee + #[error("Tip {tip} is too low. Minimum required priority fee is {min_priority_fee}")] + TipTooLow { + /// Tip provided by the transaction + tip: u128, + /// The minimum priority fee required + min_priority_fee: u128, + }, } impl Default for InclusionPricer {