Skip to content

Commit

Permalink
Merge branch 'fix/sidecar/same-nonce' of github.com:chainbound/bolt-v…
Browse files Browse the repository at this point in the history
…0 into fix/sidecar/same-nonce
  • Loading branch information
merklefruit committed Jul 17, 2024
2 parents 0e00315 + e24eebd commit d99a29e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
10 changes: 8 additions & 2 deletions bolt-sidecar/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,17 @@ pub fn validate_transaction(
) -> Result<(), ValidationError> {
// Check if the nonce is correct (should be the same as the transaction count)
if transaction.nonce() < account_state.transaction_count {
return Err(ValidationError::NonceTooLow);
return Err(ValidationError::NonceTooLow(
account_state.transaction_count,
transaction.nonce(),
));
}

if transaction.nonce() > account_state.transaction_count {
return Err(ValidationError::NonceTooHigh);
return Err(ValidationError::NonceTooHigh(
account_state.transaction_count,
transaction.nonce(),
));
}

// Check if the balance is enough
Expand Down
6 changes: 3 additions & 3 deletions bolt-sidecar/src/state/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ pub enum ValidationError {
#[error("Invalid max basefee calculation: overflow")]
MaxBaseFeeCalcOverflow,
/// The transaction nonce is too low.
#[error("Transaction nonce too low")]
NonceTooLow,
#[error("Transaction nonce too low. Expected {0}, got {1}")]
NonceTooLow(u64, u64),
/// The transaction nonce is too high.
#[error("Transaction nonce too high")]
NonceTooHigh,
NonceTooHigh(u64, u64),
/// The sender account is a smart contract and has code.
#[error("Account has code")]
AccountHasCode,
Expand Down
2 changes: 1 addition & 1 deletion bolt-sidecar/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ mod tests {

assert!(matches!(
state.validate_commitment_request(&request).await,
Err(ValidationError::NonceTooHigh)
Err(ValidationError::NonceTooHigh(_, _))
));

Ok(())
Expand Down

0 comments on commit d99a29e

Please sign in to comment.