Skip to content

Commit dfa71ea

Browse files
committed
wip
1 parent f0a6f66 commit dfa71ea

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

crates/gateway/src/client.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,17 @@ impl Client {
202202
}
203203
}
204204

205+
// unknown format:
206+
// <html><head>
207+
// <meta http-equiv="content-type" content="text/html;charset=utf-8">
208+
// <title>502 Server Error</title>
209+
// </head>
210+
// <body text=#000000 bgcolor=#ffffff>
211+
// <h1>Error: Server Error</h1>
212+
// <h2>The server encountered a temporary error and could not complete your request.<p>Please try again in 30 seconds.</h2>
213+
// <h2></h2>
214+
// </body></html>
215+
205216
#[derive(Debug, thiserror::Error)]
206217
pub enum Error {
207218
#[error(transparent)]

crates/storage/provider/provider/src/providers/db/trie.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use katana_provider_api::ProviderError;
1313
use katana_trie::{
1414
compute_contract_state_hash, ClassesTrie, ContractLeaf, ContractsTrie, StoragesTrie,
1515
};
16+
use starknet::providers::Provider;
1617

1718
use crate::providers::db::DbProvider;
1819
use crate::ProviderResult;
@@ -85,8 +86,11 @@ impl<Db: Database> TrieWriter for DbProvider<Db> {
8586
let storage_root = storage_trie.root();
8687
leaf.storage_root = Some(storage_root);
8788

88-
let latest_state = self.latest()?;
89-
let leaf_hash = contract_state_leaf_hash(latest_state, &address, &leaf);
89+
let state = self
90+
.historical(block_number.into())?
91+
.expect("historical state should exist");
92+
let leaf_hash =
93+
contract_state_leaf_hash(state, &address, &leaf, block_number);
9094

9195
Ok((address, leaf_hash))
9296
})
@@ -108,6 +112,7 @@ fn contract_state_leaf_hash(
108112
provider: impl StateProvider,
109113
address: &ContractAddress,
110114
contract_leaf: &ContractLeaf,
115+
block_number: BlockNumber,
111116
) -> Felt {
112117
let nonce =
113118
contract_leaf.nonce.unwrap_or(provider.nonce(*address).unwrap().unwrap_or_default());
@@ -118,5 +123,18 @@ fn contract_state_leaf_hash(
118123

119124
let storage_root = contract_leaf.storage_root.expect("root need to set");
120125

121-
compute_contract_state_hash(&class_hash, &storage_root, &nonce)
126+
let root = compute_contract_state_hash(&class_hash, &storage_root, &nonce);
127+
128+
if block_number >= 6481 {
129+
println!("----------------------------------------");
130+
println!("block {block_number}");
131+
println!("address: {address}");
132+
println!("class hash : {class_hash:#x}");
133+
println!("nonce : {nonce:#x}");
134+
println!("storage root : {storage_root:#x}");
135+
println!("Contract state hash: {root}");
136+
println!("----------------------------------------");
137+
}
138+
139+
root
122140
}

0 commit comments

Comments
 (0)