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
12 changes: 12 additions & 0 deletions prdoc/pr_10186.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
title: Return the correct block difficulty from the eth-rpc
doc:
- audience: Runtime Dev
description: |-
# Description

This PR fixes an issue in the eth-rpc/pallet-revive that was causing it to return an incorrect value for the block's difficulty or prevrandao.

In the VM/interpreter implementation we use a constant for the block difficulty. However, the eth block construction side was unaware of this constant being used and therefore the RPC was always returning a block difficulty of zero.
crates:
- name: pallet-revive
bump: patch
5 changes: 5 additions & 0 deletions substrate/frame/revive/src/evm/block_hash/block_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ impl<T: crate::Config> EthereumBlockBuilder<T> {
let tx_hashes = core::mem::replace(&mut self.tx_hashes, Vec::new());
let gas_info = core::mem::replace(&mut self.gas_info, Vec::new());

let difficulty = U256::from(crate::vm::evm::DIFFICULTY);
let mix_hash = H256(difficulty.to_big_endian());

let mut block = Block {
number: block_number,
parent_hash,
Expand All @@ -186,6 +189,8 @@ impl<T: crate::Config> EthereumBlockBuilder<T> {
logs_bloom: self.logs_bloom.bloom.into(),
transactions: HashesOrTransactionInfos::Hashes(tx_hashes),

mix_hash,

..Default::default()
};

Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/revive/src/exec/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2842,7 +2842,7 @@ fn block_hash_returns_proper_values() {
assert_eq!(
ctx.ext.block_hash(U256::from(0)),
Some(H256::from(hex_literal::hex!(
"b9be84fb00044994dff6b62393b4c8aa8191717c5ea046f270bd2695524e9f85"
"c2fed5de763ecfa4cb65e8f57838c5517f69db4ede78a30093bf3fad66c5a8cd"
)))
);

Expand Down
Loading