Skip to content

Commit ace381a

Browse files
authored
Fix parsing storage from cache (#1072)
<!-- Reference any GitHub issues resolved by this PR --> Follow up task: #1073 ## Introduced changes <!-- A brief description of the changes --> - Fix the issue where decimal values would be parsed as hex, resulting in felt overflows ## Checklist <!-- Make sure all of these are complete --> - [ ] Linked relevant issue - [ ] Updated relevant documentation - [ ] Added relevant tests - [ ] Performed self-review of the code - [ ] Added changes to `CHANGELOG.md`
1 parent b32ef68 commit ace381a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

crates/cheatnet/src/forking/cache.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use fs2::FileExt;
66
use num_bigint::BigUint;
77
use regex::Regex;
88
use serde::{Deserialize, Serialize};
9-
use starknet::core::types::{BlockId, BlockTag, ContractClass, FieldElement};
9+
use starknet::core::types::{BlockId, BlockTag, ContractClass};
1010
use starknet_api::core::{ClassHash, ContractAddress, Nonce};
1111
use starknet_api::hash::StarkFelt;
1212
use starknet_api::state::StorageKey;
@@ -182,9 +182,11 @@ impl ForkCache {
182182
.get(&storage_key_str)?;
183183

184184
Some(
185-
FieldElement::from_hex_be(cache_hit)
186-
.unwrap_or_else(|_| panic!("Could not parse {cache_hit}"))
187-
.to_stark_felt(),
185+
Felt252::from(
186+
BigUint::parse_bytes(cache_hit.as_bytes(), 10)
187+
.expect("Parsing class_hash_at entry failed"),
188+
)
189+
.to_stark_felt(),
188190
)
189191
}
190192

0 commit comments

Comments
 (0)