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

feat(katana): limit number of proof keys #2814

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
add new starknet api error type
  • Loading branch information
kariy committed Dec 16, 2024
commit e25c4b014338af7a5ff63486efd0e4ca34bf5511
1 change: 0 additions & 1 deletion crates/katana/core/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ impl<'a, P: TrieWriter> UncommittedBlock<'a, P> {

// state_commitment = hPos("STARKNET_STATE_V0", contract_trie_root, class_trie_root)
fn compute_new_state_root(&self) -> Felt {
println!("ohayo im committing now");
let class_trie_root = self
.provider
.trie_insert_declared_classes(self.header.number, &self.state_updates.declared_classes)
Expand Down
22 changes: 22 additions & 0 deletions crates/katana/rpc/rpc-types/src/error/starknet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use jsonrpsee::types::error::CallError;
use jsonrpsee::types::ErrorObject;
use katana_pool::validation::error::InvalidTransactionError;
use katana_pool::PoolError;
use katana_primitives::block::BlockNumber;
use katana_primitives::event::ContinuationTokenError;
use katana_provider::error::ProviderError;
use serde::Serialize;
Expand Down Expand Up @@ -83,6 +84,13 @@ pub enum StarknetApiError {
TooManyKeysInFilter,
#[error("Failed to fetch pending transactions")]
FailedToFetchPendingTransactions,
#[error("The node doesn't support storage proofs for blocks that are too far in the past")]
StorageProofNotSupported {
/// The oldest block whose storage proof can be obtained.
oldest_block: BlockNumber,
/// The block of the storage proof that is being requested.
requested_block: BlockNumber,
},
}

impl StarknetApiError {
Expand All @@ -103,6 +111,7 @@ impl StarknetApiError {
StarknetApiError::FailedToFetchPendingTransactions => 38,
StarknetApiError::ContractError { .. } => 40,
StarknetApiError::TransactionExecutionError { .. } => 41,
StarknetApiError::StorageProofNotSupported { .. } => 42,
StarknetApiError::InvalidContractClass => 50,
StarknetApiError::ClassAlreadyDeclared => 51,
StarknetApiError::InvalidTransactionNonce { .. } => 52,
Expand Down Expand Up @@ -130,6 +139,7 @@ impl StarknetApiError {
StarknetApiError::ContractError { .. }
| StarknetApiError::UnexpectedError { .. }
| StarknetApiError::PageSizeTooBig { .. }
| StarknetApiError::StorageProofNotSupported { .. }
| StarknetApiError::TransactionExecutionError { .. } => Some(serde_json::json!(self)),

StarknetApiError::InvalidTransactionNonce { reason }
Expand Down Expand Up @@ -372,6 +382,18 @@ mod tests {
"max_allowed": 500
}),
)]
#[case(
StarknetApiError::StorageProofNotSupported {
oldest_block: 10,
requested_block: 9
},
42,
"The node doesn't support storage proofs for blocks that are too far in the past",
json!({
"oldest_block": 10,
"requested_block": 9
}),
)]
fn test_starknet_api_error_to_error_conversion_data_some(
#[case] starknet_error: StarknetApiError,
#[case] expected_code: i32,
Expand Down