-
Notifications
You must be signed in to change notification settings - Fork 185
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(katana-pool): rename error for clarity #2528
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
use katana_primitives::class::ClassHash; | ||
use katana_primitives::contract::{ContractAddress, Nonce}; | ||
use katana_primitives::Felt; | ||
|
||
// TODO: figure out how to combine this with ExecutionError | ||
#[derive(Debug, thiserror::Error)] | ||
pub enum InvalidTransactionError { | ||
/// Error when the account's balance is insufficient to cover the specified transaction fee. | ||
#[error("Max fee ({max_fee}) exceeds balance ({balance}).")] | ||
InsufficientFunds { | ||
/// The specified transaction fee. | ||
max_fee: u128, | ||
/// The account's balance of the fee token. | ||
balance: Felt, | ||
}, | ||
|
||
/// Error when the specified transaction fee is insufficient to cover the minimum fee required | ||
/// to start the invocation (including the account's validation logic). | ||
/// | ||
/// It is a static check that is performed before the transaction is invoked to ensure the | ||
/// transaction can cover the intrinsics cost ie data availability, etc. | ||
/// | ||
/// This is different from an error due to transaction runs out of gas during execution ie. | ||
/// the specified max fee is lower than the amount needed to finish the transaction execution | ||
/// (either validation or execution). | ||
#[error("Intrinsic transaction fee is too low")] | ||
IntrinsicFeeTooLow { | ||
/// The minimum required for the transaction to be executed. | ||
min: u128, | ||
/// The specified transaction fee. | ||
max_fee: u128, | ||
}, | ||
|
||
/// Error when the account's validation logic fails (ie __validate__ function). | ||
#[error("{error}")] | ||
ValidationFailure { | ||
/// The address of the contract that failed validation. | ||
address: ContractAddress, | ||
/// The class hash of the account contract. | ||
class_hash: ClassHash, | ||
/// The error message returned by Blockifier. | ||
// TODO: this should be a more specific error type. | ||
error: String, | ||
}, | ||
|
||
/// Error when the transaction's sender is not an account contract. | ||
#[error("Sender is not an account")] | ||
NonAccount { | ||
/// The address of the contract that is not an account. | ||
address: ContractAddress, | ||
}, | ||
|
||
/// Error when the transaction is using a nonexpected nonce. | ||
#[error( | ||
"Invalid transaction nonce of contract at address {address}. Account nonce: \ | ||
{current_nonce:#x}; got: {tx_nonce:#x}." | ||
)] | ||
InvalidNonce { | ||
/// The address of the contract that has the invalid nonce. | ||
address: ContractAddress, | ||
/// The current nonce of the sender's account. | ||
current_nonce: Nonce, | ||
/// The nonce that the tx is using. | ||
tx_nonce: Nonce, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider enhancing the error message for clarity.
Including the
min
andmax_fee
values in theIntrinsicFeeTooLow
error message can provide better context and align with the error message format used inInsufficientFunds
. This will help users understand exactly why their transaction fee is considered too low.You might update the error annotation as follows:
📝 Committable suggestion