Skip to content
Open
Changes from all commits
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
51 changes: 15 additions & 36 deletions crates/storage/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2275,18 +2275,13 @@ impl Store {
let Some(state_trie) = self.state_trie(block_hash)? else {
return Ok(None);
};
let hashed_address = hash_address_fixed(&address);

let Some(encoded_state) = state_trie.get(hashed_address.as_bytes())? else {
return Ok(None);
};

let account_state = AccountState::decode(&encoded_state)?;
Ok(Some(AccountInfo {
code_hash: account_state.code_hash,
balance: account_state.balance,
nonce: account_state.nonce,
}))
Ok(self
.get_account_state_from_trie(&state_trie, address)?
.map(|account_state| AccountInfo {
code_hash: account_state.code_hash,
balance: account_state.balance,
nonce: account_state.nonce,
}))
}

pub fn get_account_state_by_acc_hash(
Expand Down Expand Up @@ -2324,37 +2319,21 @@ impl Store {
block_number: BlockNumber,
address: Address,
) -> Result<Option<Code>, StoreError> {
let Some(block_hash) = self.get_canonical_block_hash(block_number).await? else {
return Ok(None);
};
let Some(state_trie) = self.state_trie(block_hash)? else {
return Ok(None);
};
let hashed_address = hash_address_fixed(&address);
let Some(encoded_state) = state_trie.get(hashed_address.as_bytes())? else {
return Ok(None);
};
let account_state = AccountState::decode(&encoded_state)?;
self.get_account_code(account_state.code_hash)
match self.get_account_state(block_number, address).await? {
Some(account_state) => self.get_account_code(account_state.code_hash),
None => Ok(None),
}
}

pub async fn get_nonce_by_account_address(
&self,
block_number: BlockNumber,
address: Address,
) -> Result<Option<u64>, StoreError> {
let Some(block_hash) = self.get_canonical_block_hash(block_number).await? else {
return Ok(None);
};
let Some(state_trie) = self.state_trie(block_hash)? else {
return Ok(None);
};
let hashed_address = hash_address_fixed(&address);
let Some(encoded_state) = state_trie.get(hashed_address.as_bytes())? else {
return Ok(None);
};
let account_state = AccountState::decode(&encoded_state)?;
Ok(Some(account_state.nonce))
Ok(self
.get_account_state(block_number, address)
.await?
.map(|account_state| account_state.nonce))
}

/// Applies account updates based on the block's latest storage state
Expand Down
Loading