gakonst / ethers-rs

Complete Ethereum & Celo library and wallet implementation in Rust. https://docs.rs/ethers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

subscribe_blocks() missing transaction hashes

nick-staked opened this issue · comments

Version

[package]
name = "hack"
version = "0.1.0"
edition = "2021"

[dependencies]
ethers = { version = "2.0.9", features = ["ws"] }
eyre = "0.6.8"
tokio = { version = "1.32.0", features = ["full"] }

Platform
Linux c74e346b57d7 6.2.0-26-generic

Description

Using: https://github.com/gakonst/ethers-rs/blob/master/examples/subscriptions/examples/subscribe_blocks.rs

use ethers::providers::{Middleware, Provider, StreamExt, Ws};
use eyre::Result;

#[tokio::main]
async fn main() -> Result<()> {
    let provider =
        Provider::<Ws>::connect("<full-node-path>")
            .await?;
    let mut stream = provider.subscribe_blocks().await?.take(1);
    while let Some(block) = stream.next().await {
        println!(
            "Ts: {:?}, block number: {} -> {:?}",
            block.timestamp,
            block.number.unwrap(),
            block.hash.unwrap()
        );
        // Additional Lines 
        println!("{:?}", block.transactions);  // Empty Vec..
        println!("{:?}", block); // Everything else in the block header is populated correctly
    }

    Ok(())
}

Example output from mainnet:

Ts: 1694041271, block number: 18080543 -> 0x2b3adf0c0e27b9109e194d822cb4f36c3922e1e352d337e9882d1362b44349bc
[]
Block { hash: Some(0x2b3adf0c0e27b9109e194d822cb4f36c3922e1e352d337e9882d1362b44349bc), parent_hash: 0x1d5f437aa7a1512f0c897c62e9de8e7986881560c0ab67deb2c07ebe66b992d5, uncles_hash: 0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347, author: Some(0x4838b106fce9647bdf1e7877bf73ce8b0bad5f97), state_root: 0x3c177a9a6794fce43a1e6a3fdc880a684925cf7cc13513ec1cb9afb99064a35c, transactions_root: 0xfc3f0a7046e6239b71e93a64137993af051415a37d256c18607cf423dbb9a489, receipts_root: 0xfc9d30f1167c540196bdcb8b2960034296dd3b3f50270b3df3b8e2a98148207f, number: Some(18080543), gas_used: 12215723, gas_limit: 30000000, extra_data: Bytes(0x546974616e2028746974616e6275696c6465722e78797a29), logs_bloom: Some(0xd7f29046482356684a1b8bb691209133de8f8043b08128881129b424c400c3e6243a98abef4045db575b2aa0481507b46620120ddf87f0406428b80b05e33c2a4a04a40c532d7d6a7a27c55f51ed073f8c1a0078115e58c2018a4083e8b6098150cad8d3726a532214020d9cdf020f5dca5930da90488c5620d0365f185f8b5887e50a4620420ce2c9e8c0016913c94e2ab014a52f5a820e107118ee24b8007afaf9974cbed06100091c4bc978154dba6200479a0b01417616c0960a160368d455040c77b4424dd0792230860b6685eb1de4320440291032e7164957e031a84c303020382112002020c5a80138101f28947095231a4841d9027348807ec275e7), timestamp: 1694041271, difficulty: 0, total_difficulty: None, seal_fields: [], uncles: [], transactions: [], size: None, mix_hash: Some(0xdd94229ae029ab3988610712ca2832ff9be074ade1f4b333c15e595df433ad12), nonce: Some(0x0000000000000000), base_fee_per_gas: Some(14345552918), withdrawals_root: Some(0xf16121462dee35a6cf479ee1c10ee239b460df7873f3424b4413b249d7b5b239), withdrawals: None, other: OtherFields { inner: {} } }

Was this actually completed? Am running into the same issues

The spec for newHeads doesn't include the transactions. https://geth.ethereum.org/docs/interacting-with-geth/rpc/pubsub#newheads