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

chore(bolt-sidecar): add params in err message #660

Merged
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion bolt-sidecar/src/primitives/commitment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
21 changes: 13 additions & 8 deletions bolt-sidecar/src/state/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -311,13 +311,18 @@ impl<C: StateFetcher> ExecutionState<C> {

// 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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions bolt-sidecar/src/state/pricing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down