diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f70cadc95e1..8e4dee9142c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,6 +30,8 @@ jobs: - "--no-default-features" # Default features - "" + # All features + - "--all-features" exclude: # All features on MSRV - rust: "1.76" # MSRV diff --git a/crates/provider/src/ext/debug.rs b/crates/provider/src/ext/debug.rs index f8933bff221..d3252972299 100644 --- a/crates/provider/src/ext/debug.rs +++ b/crates/provider/src/ext/debug.rs @@ -2,7 +2,7 @@ use crate::Provider; use alloy_network::Network; use alloy_primitives::{hex, Bytes, TxHash, B256}; -use alloy_rpc_types_eth::{Block, BlockNumberOrTag, TransactionRequest}; +use alloy_rpc_types_eth::{Block, BlockId, BlockNumberOrTag, TransactionRequest}; use alloy_rpc_types_trace::geth::{ BlockTraceResult, GethDebugTracingCallOptions, GethDebugTracingOptions, GethTrace, TraceResult, }; @@ -13,16 +13,16 @@ use alloy_transport::{Transport, TransportResult}; #[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)] pub trait DebugApi: Send + Sync { /// Returns an RLP-encoded header. - async fn debug_get_raw_header(&self, block: BlockNumberOrTag) -> TransportResult; + async fn debug_get_raw_header(&self, block: BlockId) -> TransportResult; /// Retrieves and returns the RLP encoded block by number, hash or tag. - async fn debug_get_raw_block(&self, block: BlockNumberOrTag) -> TransportResult; + async fn debug_get_raw_block(&self, block: BlockId) -> TransportResult; /// Returns an EIP-2718 binary-encoded transaction. async fn debug_get_raw_transaction(&self, hash: TxHash) -> TransportResult; /// Returns an array of EIP-2718 binary-encoded receipts. - async fn debug_get_raw_receipts(&self, block: BlockNumberOrTag) -> TransportResult>; + async fn debug_get_raw_receipts(&self, block: BlockId) -> TransportResult>; /// Returns an array of recent bad blocks that the client has seen on the network. async fn debug_get_bad_blocks(&self) -> TransportResult>; @@ -109,7 +109,7 @@ pub trait DebugApi: Send + Sync { async fn debug_trace_call( &self, tx: TransactionRequest, - block: BlockNumberOrTag, + block: BlockId, trace_options: GethDebugTracingCallOptions, ) -> TransportResult; @@ -123,7 +123,7 @@ pub trait DebugApi: Send + Sync { async fn debug_trace_call_many( &self, txs: Vec, - block: BlockNumberOrTag, + block: BlockId, trace_options: GethDebugTracingCallOptions, ) -> TransportResult>; } @@ -136,11 +136,11 @@ where T: Transport + Clone, P: Provider, { - async fn debug_get_raw_header(&self, block: BlockNumberOrTag) -> TransportResult { + async fn debug_get_raw_header(&self, block: BlockId) -> TransportResult { self.client().request("debug_getRawHeader", (block,)).await } - async fn debug_get_raw_block(&self, block: BlockNumberOrTag) -> TransportResult { + async fn debug_get_raw_block(&self, block: BlockId) -> TransportResult { self.client().request("debug_getRawBlock", (block,)).await } @@ -148,7 +148,7 @@ where self.client().request("debug_getRawTransaction", (hash,)).await } - async fn debug_get_raw_receipts(&self, block: BlockNumberOrTag) -> TransportResult> { + async fn debug_get_raw_receipts(&self, block: BlockId) -> TransportResult> { self.client().request("debug_getRawReceipts", (block,)).await } @@ -200,7 +200,7 @@ where async fn debug_trace_call( &self, tx: TransactionRequest, - block: BlockNumberOrTag, + block: BlockId, trace_options: GethDebugTracingCallOptions, ) -> TransportResult { self.client().request("debug_traceCall", (tx, block, trace_options)).await @@ -209,7 +209,7 @@ where async fn debug_trace_call_many( &self, txs: Vec, - block: BlockNumberOrTag, + block: BlockId, trace_options: GethDebugTracingCallOptions, ) -> TransportResult> { self.client().request("debug_traceCallMany", (txs, block, trace_options)).await @@ -268,7 +268,11 @@ mod test { .max_priority_fee_per_gas(gas_price + 1); let trace = provider - .debug_trace_call(tx, BlockNumberOrTag::Latest, GethDebugTracingCallOptions::default()) + .debug_trace_call( + tx, + BlockNumberOrTag::Latest.into(), + GethDebugTracingCallOptions::default(), + ) .await .unwrap(); @@ -284,7 +288,7 @@ mod test { let provider = ProviderBuilder::new().on_http(geth.endpoint_url()); let rlp_header = provider - .debug_get_raw_header(BlockNumberOrTag::default()) + .debug_get_raw_header(BlockId::Number(BlockNumberOrTag::Latest)) .await .expect("debug_getRawHeader call should succeed"); @@ -298,7 +302,7 @@ mod test { let provider = ProviderBuilder::new().on_http(geth.endpoint_url()); let rlp_block = provider - .debug_get_raw_block(BlockNumberOrTag::default()) + .debug_get_raw_block(BlockId::Number(BlockNumberOrTag::Latest)) .await .expect("debug_getRawBlock call should succeed"); @@ -311,7 +315,8 @@ mod test { let geth = Geth::new().disable_discovery().data_dir(temp_dir.path()).spawn(); let provider = ProviderBuilder::new().on_http(geth.endpoint_url()); - let result = provider.debug_get_raw_receipts(BlockNumberOrTag::default()).await; + let result = + provider.debug_get_raw_receipts(BlockId::Number(BlockNumberOrTag::Latest)).await; assert!(result.is_ok()); } diff --git a/crates/provider/src/ext/trace.rs b/crates/provider/src/ext/trace.rs index 334ef2a883a..b6a81dc2077 100644 --- a/crates/provider/src/ext/trace.rs +++ b/crates/provider/src/ext/trace.rs @@ -1,6 +1,6 @@ //! This module extends the Ethereum JSON-RPC provider with the Trace namespace's RPC methods. use crate::{Provider, RpcWithBlock}; -use alloy_eips::BlockNumberOrTag; +use alloy_eips::BlockId; use alloy_network::Network; use alloy_primitives::TxHash; use alloy_rpc_types_eth::Index; @@ -81,23 +81,20 @@ where /// # Note /// /// Not all nodes support this call. - async fn trace_block( - &self, - block: BlockNumberOrTag, - ) -> TransportResult>; + async fn trace_block(&self, block: BlockId) -> TransportResult>; /// Replays a transaction. async fn trace_replay_transaction( &self, hash: TxHash, - trace_type: &[TraceType], + trace_types: &[TraceType], ) -> TransportResult; /// Replays all transactions in the given block. async fn trace_replay_block_transactions( &self, - block: BlockNumberOrTag, - trace_type: &[TraceType], + block: BlockId, + trace_types: &[TraceType], ) -> TransportResult>; } @@ -112,10 +109,10 @@ where fn trace_call<'a, 'b>( &self, request: &'a ::TransactionRequest, - trace_type: &'b [TraceType], + trace_types: &'b [TraceType], ) -> RpcWithBlock::TransactionRequest, &'b [TraceType]), TraceResults> { - RpcWithBlock::new(self.weak_client(), "trace_call", (request, trace_type)) + RpcWithBlock::new(self.weak_client(), "trace_call", (request, trace_types)) } fn trace_call_many<'a>( @@ -144,9 +141,9 @@ where async fn trace_raw_transaction( &self, data: &[u8], - trace_type: &[TraceType], + trace_types: &[TraceType], ) -> TransportResult { - self.client().request("trace_rawTransaction", (data, trace_type)).await + self.client().request("trace_rawTransaction", (data, trace_types)).await } async fn trace_filter( @@ -156,33 +153,31 @@ where self.client().request("trace_filter", (tracer,)).await } - async fn trace_block( - &self, - block: BlockNumberOrTag, - ) -> TransportResult> { + async fn trace_block(&self, block: BlockId) -> TransportResult> { self.client().request("trace_block", (block,)).await } async fn trace_replay_transaction( &self, hash: TxHash, - trace_type: &[TraceType], + trace_types: &[TraceType], ) -> TransportResult { - self.client().request("trace_replayTransaction", (hash, trace_type)).await + self.client().request("trace_replayTransaction", (hash, trace_types)).await } async fn trace_replay_block_transactions( &self, - block: BlockNumberOrTag, - trace_type: &[TraceType], + block: BlockId, + trace_types: &[TraceType], ) -> TransportResult> { - self.client().request("trace_replayBlockTransactions", (block, trace_type)).await + self.client().request("trace_replayBlockTransactions", (block, trace_types)).await } } #[cfg(test)] mod test { use crate::ProviderBuilder; + use alloy_eips::BlockNumberOrTag; use super::*; @@ -194,7 +189,7 @@ mod test { async fn test_trace_block() { init_tracing(); let provider = ProviderBuilder::new().on_anvil(); - let traces = provider.trace_block(BlockNumberOrTag::Latest).await.unwrap(); + let traces = provider.trace_block(BlockId::Number(BlockNumberOrTag::Latest)).await.unwrap(); assert_eq!(traces.len(), 0); } } diff --git a/crates/provider/src/provider/trait.rs b/crates/provider/src/provider/trait.rs index 4d2664718af..ec75c68b66b 100644 --- a/crates/provider/src/provider/trait.rs +++ b/crates/provider/src/provider/trait.rs @@ -259,10 +259,10 @@ pub trait Provider: /// Gets a block by either its hash, tag, or number, with full transactions or only hashes. async fn get_block( &self, - id: BlockId, + block: BlockId, kind: BlockTransactionsKind, ) -> TransportResult> { - match id { + match block { BlockId::Hash(hash) => self.get_block_by_hash(hash.into(), kind).await, BlockId::Number(number) => { let full = matches!(kind, BlockTransactionsKind::Full); @@ -320,10 +320,10 @@ pub trait Provider: Ok(block) } - /// Gets the selected block [BlockNumberOrTag] receipts. + /// Gets the selected block [BlockId] receipts. async fn get_block_receipts( &self, - block: BlockNumberOrTag, + block: BlockId, ) -> TransportResult>> { self.client().request("eth_getBlockReceipts", (block,)).await } @@ -1086,7 +1086,7 @@ mod tests { } } - #[cfg(feature = "ws")] + #[cfg(all(feature = "ws", not(windows)))] #[tokio::test] async fn subscribe_blocks_ws() { use futures::stream::StreamExt; @@ -1107,7 +1107,7 @@ mod tests { } } - #[cfg(feature = "ws")] + #[cfg(all(feature = "ws", not(windows)))] #[tokio::test] async fn subscribe_blocks_ws_boxed() { use futures::stream::StreamExt; @@ -1433,7 +1433,8 @@ mod tests { async fn gets_block_receipts() { init_tracing(); let provider = ProviderBuilder::new().on_anvil(); - let receipts = provider.get_block_receipts(BlockNumberOrTag::Latest).await.unwrap(); + let receipts = + provider.get_block_receipts(BlockId::Number(BlockNumberOrTag::Latest)).await.unwrap(); assert!(receipts.is_some()); } diff --git a/crates/provider/src/provider/with_block.rs b/crates/provider/src/provider/with_block.rs index 808b72a15f6..471e310c156 100644 --- a/crates/provider/src/provider/with_block.rs +++ b/crates/provider/src/provider/with_block.rs @@ -11,7 +11,7 @@ use std::{ task::Poll, }; -/// States of the +/// States of the [`RpcWithBlock`] future. #[derive(Clone)] enum States Output> where diff --git a/crates/rpc-client/src/builtin.rs b/crates/rpc-client/src/builtin.rs index ee0670ff849..6b95963a090 100644 --- a/crates/rpc-client/src/builtin.rs +++ b/crates/rpc-client/src/builtin.rs @@ -250,7 +250,7 @@ mod test { } #[test] - #[cfg(feature = "ipc")] + #[cfg(all(feature = "ipc", not(windows)))] fn test_parsing_ipc() { use alloy_node_bindings::Anvil;