Skip to content

Commit

Permalink
fix(katana-rpc): return the correct block hash from getStorageProof (
Browse files Browse the repository at this point in the history
  • Loading branch information
kariy committed Dec 23, 2024
1 parent 8b03336 commit 30efc06
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions crates/katana/rpc/rpc/src/starknet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use katana_primitives::env::BlockEnv;
use katana_primitives::event::MaybeForkedContinuationToken;
use katana_primitives::transaction::{ExecutableTxWithHash, TxHash, TxWithHash};
use katana_primitives::Felt;
use katana_provider::error::ProviderError;
use katana_provider::traits::block::{BlockHashProvider, BlockIdReader, BlockNumberProvider};
use katana_provider::traits::contract::ContractClassProvider;
use katana_provider::traits::env::BlockEnvProvider;
Expand Down Expand Up @@ -1139,6 +1140,10 @@ where
self.on_io_blocking_task(move |this| {
let provider = this.inner.backend.blockchain.provider();

let Some(block_num) = provider.convert_block_id(block_id)? else {
return Err(StarknetApiError::BlockNotFound);
};

// Check if the total number of keys requested exceeds the RPC limit.
if let Some(limit) = this.inner.config.max_proof_keys {
let total_keys = class_hashes.as_ref().map(|v| v.len()).unwrap_or(0)
Expand All @@ -1151,8 +1156,11 @@ where
}
}

let state = this.state(&block_id)?;
let block_hash = provider.latest_hash()?;
// TODO: the way we handle the block id is very clanky. change it!
let state = this.state(&BlockIdOrTag::Number(block_num))?;
let block_hash = provider
.block_hash_by_num(block_num)?
.ok_or(ProviderError::MissingBlockHeader(block_num))?;

// --- Get classes proof (if any)

Expand Down

0 comments on commit 30efc06

Please sign in to comment.