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
15 changes: 8 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,18 @@ rustdoc-args = ["--cfg", "docsrs"]

[dependencies]
alloy-primitives = { version = "0.8.5", features = ["map"] }
alloy-provider = { version = "0.5", default-features = false }
alloy-rpc-types = { version = "0.5", features = ["eth"] }
alloy-serde = { version = "0.5", default-features = false }
alloy-transport = { version = "0.5", default-features = false }
alloy-provider = { version = "0.6", default-features = false }
alloy-rpc-types = { version = "0.6", features = ["eth"] }
alloy-serde = { version = "0.6", default-features = false }
alloy-transport = { version = "0.6", default-features = false }
alloy-consensus = { version = "0.6", default-features = false }

eyre = "0.6"
futures = "0.3"

parking_lot = "0.12"

revm = { version = "17.0.0", default-features = false, features = [
revm = { version = "18.0.0", default-features = false, features = [
"std",
"serde",
] }
Expand All @@ -51,5 +52,5 @@ tracing = "0.1"
url = "2"

[dev-dependencies]
alloy-rpc-client = "0.5"
alloy-transport-http = "0.5"
alloy-rpc-client = "0.6"
alloy-transport-http = "0.6"
3 changes: 2 additions & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ allow = [
"Unicode-DFS-2016",
"Unlicense",
"Zlib",
"Unicode-3.0",
]

exceptions = [
Expand All @@ -48,4 +49,4 @@ license-files = [{ path = "LICENSE", hash = 0x001c7e6c }]

[sources]
unknown-registry = "deny"
unknown-git = "deny"
unknown-git = "deny"
45 changes: 19 additions & 26 deletions src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ use crate::{
error::{DatabaseError, DatabaseResult},
};
use alloy_primitives::{keccak256, Address, Bytes, B256, U256};
use alloy_provider::{network::AnyNetwork, Provider};
use alloy_rpc_types::{Block, BlockId, Transaction};
use alloy_provider::{
network::{AnyNetwork, AnyRpcBlock, AnyRpcTransaction, AnyTxEnvelope},
Provider,
};
use alloy_rpc_types::{BlockId, Transaction};
use alloy_serde::WithOtherFields;
use alloy_transport::Transport;
use eyre::WrapErr;
Expand Down Expand Up @@ -47,29 +50,16 @@ type AccountFuture<Err> =
type StorageFuture<Err> = Pin<Box<dyn Future<Output = (Result<U256, Err>, Address, U256)> + Send>>;
type BlockHashFuture<Err> = Pin<Box<dyn Future<Output = (Result<B256, Err>, u64)> + Send>>;
type FullBlockFuture<Err> = Pin<
Box<
dyn Future<
Output = (
FullBlockSender,
Result<Option<WithOtherFields<Block<WithOtherFields<Transaction>>>>, Err>,
BlockId,
),
> + Send,
>,
>;
type TransactionFuture<Err> = Pin<
Box<
dyn Future<Output = (TransactionSender, Result<WithOtherFields<Transaction>, Err>, B256)>
+ Send,
>,
Box<dyn Future<Output = (FullBlockSender, Result<Option<AnyRpcBlock>, Err>, BlockId)> + Send>,
>;
type TransactionFuture<Err> =
Pin<Box<dyn Future<Output = (TransactionSender, Result<AnyRpcTransaction, Err>, B256)> + Send>>;

type AccountInfoSender = OneshotSender<DatabaseResult<AccountInfo>>;
type StorageSender = OneshotSender<DatabaseResult<U256>>;
type BlockHashSender = OneshotSender<DatabaseResult<B256>>;
type FullBlockSender =
OneshotSender<DatabaseResult<WithOtherFields<Block<WithOtherFields<Transaction>>>>>;
type TransactionSender = OneshotSender<DatabaseResult<WithOtherFields<Transaction>>>;
type FullBlockSender = OneshotSender<DatabaseResult<AnyRpcBlock>>;
type TransactionSender = OneshotSender<DatabaseResult<AnyRpcTransaction>>;

type AddressData = AddressHashMap<AccountInfo>;
type StorageData = AddressHashMap<StorageInfo>;
Expand Down Expand Up @@ -318,7 +308,10 @@ where
let provider = self.provider.clone();
let fut = Box::pin(async move {
let block = provider
.get_block_by_number(number.into(), false)
.get_block_by_number(
number.into(),
alloy_rpc_types::BlockTransactionsKind::Hashes,
)
.await
.wrap_err("failed to get block");

Expand Down Expand Up @@ -679,10 +672,7 @@ impl SharedBackend {
}

/// Returns the full block for the given block identifier
pub fn get_full_block(
&self,
block: impl Into<BlockId>,
) -> DatabaseResult<WithOtherFields<Block<WithOtherFields<Transaction>>>> {
pub fn get_full_block(&self, block: impl Into<BlockId>) -> DatabaseResult<AnyRpcBlock> {
self.blocking_mode.run(|| {
let (sender, rx) = oneshot_channel();
let req = BackendRequest::FullBlock(block.into(), sender);
Expand All @@ -692,7 +682,10 @@ impl SharedBackend {
}

/// Returns the transaction for the hash
pub fn get_transaction(&self, tx: B256) -> DatabaseResult<WithOtherFields<Transaction>> {
pub fn get_transaction(
&self,
tx: B256,
) -> DatabaseResult<WithOtherFields<Transaction<AnyTxEnvelope>>> {
self.blocking_mode.run(|| {
let (sender, rx) = oneshot_channel();
let req = BackendRequest::Transaction(tx, sender);
Expand Down
5 changes: 3 additions & 2 deletions src/cache.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Cache related abstraction
use alloy_consensus::BlockHeader;
use alloy_primitives::{Address, B256, U256};
use alloy_provider::network::{HeaderResponse, TransactionResponse};
use alloy_provider::network::TransactionResponse;
use parking_lot::RwLock;
use revm::{
primitives::{
Expand Down Expand Up @@ -150,7 +151,7 @@ impl BlockchainDbMeta {
pub fn with_block<T: TransactionResponse>(mut self, block: &alloy_rpc_types::Block<T>) -> Self {
self.block_env = BlockEnv {
number: U256::from(block.header.number()),
coinbase: block.header.coinbase(),
coinbase: block.header.beneficiary(),
timestamp: U256::from(block.header.timestamp()),
difficulty: U256::from(block.header.difficulty()),
basefee: block.header.base_fee_per_gas().map(U256::from).unwrap_or_default(),
Expand Down
Loading