Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions core/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ impl<N: NetworkSpec, C: Consensus<N::BlockResponse>> Client<N, C> {
pub async fn get_storage_at(
&self,
address: Address,
slot: B256,
slot: U256,
block: BlockTag,
) -> Result<U256> {
) -> Result<B256> {
self.node.get_storage_at(address, slot, block).await
}

Expand Down
17 changes: 4 additions & 13 deletions core/src/client/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,12 @@ impl<N: NetworkSpec, C: Consensus<N::BlockResponse>> Node<N, C> {
pub async fn get_storage_at(
&self,
address: Address,
slot: B256,
slot: U256,
tag: BlockTag,
) -> Result<U256> {
self.check_head_age().await?;

let account = self
.execution
.get_account(address, Some(&[slot]), tag)
.await?;
) -> Result<B256> {
self.check_blocktag_age(&tag).await?;

let value = account.slots.get(&slot);
match value {
Some(value) => Ok(*value),
None => Err(eyre!("slot not found")),
}
self.execution.get_storage_at(address, slot, tag).await
}

pub async fn send_raw_transaction(&self, bytes: &[u8]) -> Result<B256> {
Expand Down
8 changes: 4 additions & 4 deletions core/src/client/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ trait EthRpc<
async fn get_storage_at(
&self,
address: Address,
slot: B256,
slot: U256,
block: BlockTag,
) -> Result<U256, ErrorObjectOwned>;
) -> Result<B256, ErrorObjectOwned>;
#[method(name = "coinbase")]
async fn coinbase(&self) -> Result<Address, ErrorObjectOwned>;
#[method(name = "syncing")]
Expand Down Expand Up @@ -370,9 +370,9 @@ impl<N: NetworkSpec, C: Consensus<N::BlockResponse>>
async fn get_storage_at(
&self,
address: Address,
slot: B256,
slot: U256,
block: BlockTag,
) -> Result<U256, ErrorObjectOwned> {
) -> Result<B256, ErrorObjectOwned> {
convert_err(self.node.get_storage_at(address, slot, block).await)
}
}
Expand Down
19 changes: 19 additions & 0 deletions core/src/execution/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,25 @@
})
}

pub async fn get_storage_at(
&self,
address: Address,
slot: U256,
block: BlockTag,
) -> Result<B256> {
let storage_key = slot.into();

let account = self
.get_account(address, Some(&[storage_key]), block)
.await?;

let value = account.slots.get(&storage_key);
match value {
Some(value) => Ok((*value).into()),
None => Err(ExecutionError::InvalidStorageProof(address, storage_key).into()),
}
}

pub async fn send_raw_transaction(&self, bytes: &[u8]) -> Result<B256> {
self.rpc.send_raw_transaction(bytes).await
}
Expand Down Expand Up @@ -354,7 +373,7 @@
}
_ => {
// only concerned with filters created via helios
return Err(ExecutionError::FilterNotFound(filter_id).into());

Check failure on line 376 in core/src/execution/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement
}
}
}
Expand Down Expand Up @@ -516,7 +535,7 @@
/// Compute a trie root of a collection of encoded items.
/// Ref: https://github.com/alloy-rs/trie/blob/main/src/root.rs.
fn ordered_trie_root(items: &[Vec<u8>]) -> B256 {
fn noop_encoder(item: &Vec<u8>, buffer: &mut Vec<u8>) {

Check failure on line 538 in core/src/execution/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

writing `&Vec` instead of `&[_]` involves a new object where a slice will do
buffer.extend_from_slice(item);
}

Expand Down
Loading