Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions client/rpc/src/eth/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use sp_runtime::traits::{BlakeTwo256, Block as BlockT};
use fc_rpc_core::types::*;

use crate::{
eth::{rich_block_build, Eth},
eth::{empty_block_from, rich_block_build, Eth},
frontier_backend_client, internal_err,
};

Expand Down Expand Up @@ -132,7 +132,22 @@ where
base_fee,
)))
}
_ => Ok(None),
_ => {
if let BlockNumber::Num(block_number) = number {
let eth_block = empty_block_from(block_number.into());
let eth_hash =
H256::from_slice(keccak_256(&rlp::encode(&eth_block.header)).as_slice());
Ok(Some(rich_block_build(
eth_block,
Default::default(),
Some(eth_hash),
full,
None,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should we put base_fee here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is just empty block for no-evm period of Shiden, not sure it matters.

)))
} else {
Ok(None)
}
}
}
}

Expand Down
23 changes: 23 additions & 0 deletions client/rpc/src/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,29 @@ fn rich_block_build(
}
}

fn empty_block_from(number: U256) -> ethereum::BlockV2 {
let ommers = Vec::<ethereum::Header>::new();
let receipts = Vec::<ethereum::ReceiptV2>::new();
let receipts_root = ethereum::util::ordered_trie_root(receipts.iter().map(|r| rlp::encode(r)));
let logs_bloom = ethereum_types::Bloom::default();
let partial_header = ethereum::PartialHeader {
parent_hash: H256::default(),
beneficiary: Default::default(),
state_root: Default::default(),
receipts_root,
logs_bloom,
difficulty: U256::zero(),
number,
gas_limit: U256::from(4_000_000),
gas_used: U256::zero(),
timestamp: Default::default(),
extra_data: Vec::new(),
mix_hash: H256::default(),
nonce: H64::default(),
};
ethereum::Block::new(partial_header, Default::default(), ommers)
}

fn transaction_build(
ethereum_transaction: EthereumTransaction,
block: Option<EthereumBlock>,
Expand Down
5 changes: 4 additions & 1 deletion primitives/consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,8 @@ pub fn find_log(digest: &Digest) -> Result<Log, FindLogError> {
}

pub fn ensure_log(digest: &Digest) -> Result<(), FindLogError> {
find_log(digest).map(|_log| ())
match find_log(digest) {
Err(FindLogError::MultipleLogs) => Err(FindLogError::MultipleLogs),
_ => Ok(()),
}
}