-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Describe the feature
currently all rpc calls follow this pattern:
reth/crates/rpc/rpc-eth-api/src/helpers/call.rs
Lines 207 to 220 in 8f5b4ae
| /// Executes the call request (`eth_call`) and returns the output | |
| fn call( | |
| &self, | |
| request: RpcTxReq<<Self::RpcConvert as RpcConvert>::Network>, | |
| block_number: Option<BlockId>, | |
| overrides: EvmOverrides, | |
| ) -> impl Future<Output = Result<Bytes, Self::Error>> + Send { | |
| async move { | |
| let res = | |
| self.transact_call_at(request, block_number.unwrap_or_default(), overrides).await?; | |
| Self::Error::ensure_success(res.result) | |
| } | |
| } |
reth/crates/rpc/rpc-eth-api/src/helpers/call.rs
Lines 538 to 541 in 8f5b4ae
| let this = self.clone(); | |
| self.spawn_with_call_at(request, at, overrides, move |db, evm_env, tx_env| { | |
| this.transact(db, evm_env, tx_env) | |
| }) |
this gets called from the rpc request's context but the spawned task that performs the execution is fully detached and usually fully sync (evm execution)
we can use a tokio_util::sync::CancellationToken; and check during sync execution if this was cancelled and on the callsite use the drop_guard()
TODO
- introduce a
struct CallCtx {token: Cancellationtoken}that for now just wraps the token (we use a struct in case we need more things later) - Integrate in spawn fns: like
reth/crates/rpc/rpc-eth-api/src/helpers/call.rs
Lines 579 to 585 in 8f5b4ae
fn spawn_with_call_at<F, R>( &self, request: RpcTxReq<<Self::RpcConvert as RpcConvert>::Network>, at: BlockId, overrides: EvmOverrides, f: F, ) -> impl Future<Output = Result<R, Self::Error>> + Send - Instantiate it and the drop guard on the callsite
reth/crates/rpc/rpc-eth-api/src/helpers/call.rs
Lines 539 to 541 in 8f5b4ae
self.spawn_with_call_at(request, at, overrides, move |db, evm_env, tx_env| { this.transact(db, evm_env, tx_env) })
we can start with eth_call and then also integrate this in heaver tracing calls
Additional context
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status