-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
Labels
A-rpcRelated to the RPC implementationRelated to the RPC implementationC-enhancementNew feature or requestNew feature or request
Description
Describe the feature
prep for alloy-rs/alloy#2974
we can already implement a function for this, similar to:
reth/crates/rpc/rpc/src/eth/pubsub.rs
Lines 87 to 90 in 5c19ce7
| /// Returns a stream that yields all new RPC blocks. | |
| pub fn new_headers_stream(&self) -> impl Stream<Item = Header<N::BlockHeader>> { | |
| self.inner.new_headers_stream() | |
| } |
we need to leverage the conversion trait for the tx to receipt conversion
reth/crates/rpc/rpc/src/eth/pubsub.rs
Lines 65 to 67 in 5c19ce7
| RpcConvert: RpcConvert< | |
| Primitives: NodePrimitives<SignedTx = PoolConsensusTx<Eth::Pool>>, | |
| >, |
reth/crates/rpc/rpc-convert/src/transaction.rs
Lines 179 to 187 in 5c19ce7
| /// Converts a set of primitive receipts to RPC representations. It is guaranteed that all | |
| /// receipts are from the same block. | |
| /// | |
| /// Also accepts the corresponding block in case the receipt requires additional metadata. | |
| fn convert_receipts_with_block( | |
| &self, | |
| receipts: Vec<ConvertReceiptInput<'_, Self::Primitives>>, | |
| block: &SealedBlock<BlockTy<Self::Primitives>>, | |
| ) -> Result<Vec<RpcReceipt<Self::Network>>, Self::Error>; |
basically just like
reth/crates/rpc/rpc-eth-api/src/helpers/block.rs
Lines 126 to 162 in 5c19ce7
| let inputs = block | |
| .transactions_recovered() | |
| .zip(Arc::unwrap_or_clone(receipts)) | |
| .enumerate() | |
| .map(|(idx, (tx, receipt))| { | |
| let meta = TransactionMeta { | |
| tx_hash: *tx.tx_hash(), | |
| index: idx as u64, | |
| block_hash, | |
| block_number, | |
| base_fee, | |
| excess_blob_gas, | |
| timestamp, | |
| }; | |
| let cumulative_gas_used = receipt.cumulative_gas_used(); | |
| let logs_len = receipt.logs().len(); | |
| let input = ConvertReceiptInput { | |
| tx, | |
| gas_used: cumulative_gas_used - gas_used, | |
| next_log_index, | |
| meta, | |
| receipt, | |
| }; | |
| gas_used = cumulative_gas_used; | |
| next_log_index += logs_len; | |
| input | |
| }) | |
| .collect::<Vec<_>>(); | |
| return self | |
| .tx_resp_builder() | |
| .convert_receipts_with_block(inputs, block.sealed_block()) | |
| .map(Some) |
which we could actually convert to a helper fn in rpconvert first maybe so that this can be reused
maybe @futreall
Additional context
No response
Metadata
Metadata
Assignees
Labels
A-rpcRelated to the RPC implementationRelated to the RPC implementationC-enhancementNew feature or requestNew feature or request
Type
Projects
Status
Backlog