Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Return null number for pending block in eth_getBlockByNumber #8281

Merged

Conversation

sorpaas
Copy link
Collaborator

@sorpaas sorpaas commented Mar 31, 2018

Fixes #8028

Check whether it's fetching the pending block. If so, write the block number as null in JSONRPC.

@parity-cla-bot
Copy link

It looks like @sorpaas signed our Contributor License Agreement. 👍

Many thanks,

Parity Technologies CLA Bot

@@ -230,7 +230,10 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> EthClient<C, SN, S
state_root: view.state_root().into(),
transactions_root: view.transactions_root().into(),
receipts_root: view.receipts_root().into(),
number: Some(view.number().into()),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the same spec hash should be null as well.

@@ -180,9 +180,9 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> EthClient<C, SN, S
fn rich_block(&self, id: BlockNumberOrId, include_txs: bool) -> Result<Option<RichBlock>> {
let client = &self.client;

let client_query = |id| (client.block(id), client.block_total_difficulty(id), client.block_extra_info(id));
let client_query = |id, is_pending| (client.block(id), client.block_total_difficulty(id), client.block_extra_info(id), is_pending);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just inline false here, no point to pass is_pending

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooops right.

@sorpaas
Copy link
Collaborator Author

sorpaas commented Mar 31, 2018

According to the spec, hash, number, nonce and logsBloom should be null for pending block. If I get this right, pending blocks are not sealed so they don't have nonce or mixHash already. And hash, number and logsBloom are set to null in this PR.

@tomusdrw tomusdrw added A8-looksgood 🦄 Pull request is reviewed well. M4-core ⛓ Core client code / Rust. M6-rpcapi 📣 RPC API. and removed M4-core ⛓ Core client code / Rust. labels Mar 31, 2018
Copy link
Contributor

@andresilva andresilva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@andresilva andresilva merged commit f1b7d8a into openethereum:master Apr 2, 2018
@5chdn 5chdn added this to the 1.11 milestone Apr 3, 2018
KronicDeth added a commit to blockscout/blockscout that referenced this pull request Jul 31, 2018
Fixes #490

Compatibility with openethereum/parity-ethereum#8281, which fixed
openethereum/parity-ethereum#8028 and made pending return be compliant
with Ethereum docs.
feliperenan pushed a commit to blockscout/blockscout that referenced this pull request Aug 1, 2018
Fixes #490

Compatibility with openethereum/parity-ethereum#8281, which fixed
openethereum/parity-ethereum#8028 and made pending return be compliant
with Ethereum docs.
KronicDeth added a commit to blockscout/blockscout that referenced this pull request Aug 1, 2018
Fixes #490

Compatibility with openethereum/parity-ethereum#8281, which fixed
openethereum/parity-ethereum#8028 and made pending return be compliant
with Ethereum docs.
alexgaribay pushed a commit to blockscout/blockscout that referenced this pull request Aug 2, 2018
Fixes #490

Compatibility with openethereum/parity-ethereum#8281, which fixed
openethereum/parity-ethereum#8028 and made pending return be compliant
with Ethereum docs.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well. M6-rpcapi 📣 RPC API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants