Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eth::block() not working for BlockNumber::Pending #342

Closed
fleupold opened this issue May 11, 2020 · 1 comment · Fixed by #343
Closed

Eth::block() not working for BlockNumber::Pending #342

fleupold opened this issue May 11, 2020 · 1 comment · Fixed by #343

Comments

@fleupold
Copy link
Contributor

The following example code:

use web3::futures::Future;
use web3::types::BlockNumber;
fn main() {
    let (_eloop, transport) =
        web3::transports::Http::new("https://node.mainnet.gnosisdev.com").unwrap();

    let web3 = web3::Web3::new(transport);
    let block = web3
        .eth()
        .block(BlockNumber::Pending.into())
        .wait()
        .unwrap();

    println!("Block: {:?}", block);
}

Fails with the following error:

thread 'main' panicked at 'called Result::unwrap() on an Err value: Decoder("Error("invalid type: null, expected a 0x-prefixed hex string with length of 512", line: 0, column: 0)")', src/main.rs:8:17

The problem seems to be that the RPC response for a pending block (parity client) contains null for logs_bloom (512 hex characters = 2048 bit) and this field is not optional on the Block struct.

Is there a reason for this? Do consumers expect logs_bloom to be always set? Would it be a valid change to make this field optional or could we alternatively tighten the interface to not allow querying block() for Pending?

@tomusdrw
Copy link
Owner

The Block struct in rust-web3 was based on the one returned by Parity Ethereum, but it was a long while ago. Seems that this change: https://github.com/openethereum/openethereum/pull/8281 was not reflected in web3 copy of the Block struct.

I think we should just change the logs_bloom to be an Option, PR welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants