From fd629956d5fd34e889ae0e734737ec605bf5a9f9 Mon Sep 17 00:00:00 2001 From: James Prestwich Date: Fri, 25 Oct 2024 14:41:39 -0400 Subject: [PATCH 1/2] feat: make eth_call and eth_estimateGas default to using Pending block (#1568) * feat: make eth_call and eth_estimateGas default to using Pending block * chore: docs --- crates/provider/src/provider/trait.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/crates/provider/src/provider/trait.rs b/crates/provider/src/provider/trait.rs index 03ca092de4b..5f0c8b6133a 100644 --- a/crates/provider/src/provider/trait.rs +++ b/crates/provider/src/provider/trait.rs @@ -128,7 +128,7 @@ pub trait Provider: /// /// This function returns [`EthCall`] which can be used to execute the /// call, or to add [`StateOverride`] or a [`BlockId`]. If no overrides - /// or block ID is provided, the call will be executed on the latest block + /// or block ID is provided, the call will be executed on the pending block /// with the current state. /// /// [`StateOverride`]: alloy_rpc_types_eth::state::StateOverride @@ -153,7 +153,7 @@ pub trait Provider: #[doc(alias = "eth_call")] #[doc(alias = "call_with_overrides")] fn call<'req>(&self, tx: &'req N::TransactionRequest) -> EthCall<'req, T, N, Bytes> { - EthCall::new(self.weak_client(), tx) + EthCall::new(self.weak_client(), tx).block(BlockNumberOrTag::Pending.into()) } /// Executes an arbitrary number of transactions on top of the requested state. @@ -185,10 +185,13 @@ pub trait Provider: self.client().request("eth_createAccessList", request).into() } - /// This function returns an [`EthCall`] which can be used to get a gas estimate, - /// or to add [`StateOverride`] or a [`BlockId`]. If no overrides - /// or block ID is provided, the gas estimate will be computed for the latest block - /// with the current state. + /// Create an [`EthCall`] future to estimate the gas required for a + /// transaction. + /// + /// The future can be used to specify a [`StateOverride`] or [`BlockId`] + /// before dispatching the call. If no overrides or block ID is provided, + /// the gas estimate will be computed for the pending block with the + /// current state. /// /// [`StateOverride`]: alloy_rpc_types_eth::state::StateOverride /// @@ -196,7 +199,9 @@ pub trait Provider: /// /// Not all client implementations support state overrides for eth_estimateGas. fn estimate_gas<'req>(&self, tx: &'req N::TransactionRequest) -> EthCall<'req, T, N, U64, u64> { - EthCall::gas_estimate(self.weak_client(), tx).map_resp(utils::convert_u64) + EthCall::gas_estimate(self.weak_client(), tx) + .block(BlockNumberOrTag::Pending.into()) + .map_resp(utils::convert_u64) } /// Estimates the EIP1559 `maxFeePerGas` and `maxPriorityFeePerGas` fields. From ea5eb7d504a1f4eb6c9937af7913577f78fee121 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 26 Oct 2024 09:03:39 +0200 Subject: [PATCH 2/2] fix: enable std with jwt (#1569) --- crates/rpc-types-engine/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/rpc-types-engine/Cargo.toml b/crates/rpc-types-engine/Cargo.toml index f33d895cd30..2c289617e3d 100644 --- a/crates/rpc-types-engine/Cargo.toml +++ b/crates/rpc-types-engine/Cargo.toml @@ -48,7 +48,7 @@ jsonwebtoken = { workspace = true, optional = true } default = ["jwt", "std", "serde"] std = ["alloy-consensus/std", "derive_more/std", "strum/std"] serde = ["dep:serde", "dep:alloy-serde"] -jwt = ["dep:jsonwebtoken", "dep:rand"] +jwt = ["std", "dep:jsonwebtoken", "dep:rand"] jsonrpsee-types = ["dep:jsonrpsee-types"] ssz = ["std", "dep:ethereum_ssz", "dep:ethereum_ssz_derive", "alloy-eips/ssz"] kzg = ["alloy-consensus/kzg"]