Skip to content

Commit

Permalink
undone fake blooms,
Browse files Browse the repository at this point in the history
including real logs and blooms for system transactions now.
  • Loading branch information
SurfingNerd committed Nov 7, 2024
1 parent b028571 commit 8e832a4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 29 deletions.
8 changes: 3 additions & 5 deletions crates/db/blooms-db/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,12 @@ impl DatabaseFiles {
}

pub fn accrue_bloom(&mut self, pos: Positions, bloom: ethbloom::BloomRef) -> io::Result<()> {
let fake_bloom = ethbloom::Bloom::repeat_byte(255);
let fake_bloom_ref = ethbloom::BloomRef::from(&fake_bloom);
self.top
.accrue_bloom::<ethbloom::BloomRef>(pos.top, fake_bloom_ref)?;
.accrue_bloom::<ethbloom::BloomRef>(pos.top, bloom)?;
self.mid
.accrue_bloom::<ethbloom::BloomRef>(pos.mid, fake_bloom_ref)?;
.accrue_bloom::<ethbloom::BloomRef>(pos.mid, bloom)?;
self.bot
.replace_bloom::<ethbloom::BloomRef>(pos.bot, fake_bloom_ref)?;
.replace_bloom::<ethbloom::BloomRef>(pos.bot, bloom)?;
Ok(())
}

Expand Down
13 changes: 1 addition & 12 deletions crates/ethcore/blockchain/src/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1459,20 +1459,9 @@ impl BlockChain {
}

if let Some((block, blooms)) = update.blocks_blooms {
// we fake the blooms and write ff for all bloom fields.

let mut fake_blooms = Vec::new();

for _ in blooms.iter() {
let fake_bloom = Bloom::repeat_byte(255);
fake_blooms.push(fake_bloom);
}

warn!(target: "engine", "Block {} writing fake blooms {}?", block, fake_blooms.len());

self.db
.blooms()
.insert_blooms(block, fake_blooms.iter())
.insert_blooms(block, blooms.iter())
.expect("Low level database error when updating blooms. Some issue with disk?");
}

Expand Down
9 changes: 0 additions & 9 deletions crates/ethcore/src/engines/hbbft/hbbft_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1673,15 +1673,6 @@ impl Engine<EthereumMachine> for HoneyBadgerBFT {
}

fn on_close_block(&self, block: &mut ExecutedBlock) -> Result<(), Error> {

let bloom = Bloom::repeat_byte(255);
warn!(
"faking bloom filter on_close_block for block {} {}",
block.header.number(),
bloom
);
block.header.set_log_bloom(bloom);

if let Some(address) = self.params.block_reward_contract_address {
// only if no block reward skips are defined for this block.
let header_number = block.header.number();
Expand Down
17 changes: 16 additions & 1 deletion crates/ethcore/src/machine/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ use std::{
sync::Arc,
};

use ethereum_types::{Address, H256, U256};
use ethereum_types::{Address, Bloom, H256, U256};
use types::{
header::Header,
receipt::TransactionOutcome,
transaction::{
self, SignedTransaction, TypedTransaction, UnverifiedTransaction, SYSTEM_ADDRESS,
UNSIGNED_SENDER,
Expand Down Expand Up @@ -210,6 +211,20 @@ impl EthereumMachine {
.map_err(|e| ::engines::EngineError::FailedSystemCall(format!("{}", e)))?;
let output = res.return_data.to_vec();

let logs = substate.logs.clone();
let gas_used = gas;
let mut log_bloom = Bloom::zero();
//log_bloom.accrue(logs);

for log in substate.logs {
let bloom = log.bloom();
log_bloom.accrue_bloom(&bloom);
}

block.receipts.push(types::receipt::TypedReceipt::Legacy(
types::receipt::LegacyReceipt::new(TransactionOutcome::StatusCode(1), gas_used, logs),
));

Ok(output)
}

Expand Down
3 changes: 1 addition & 2 deletions crates/ethcore/types/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,7 @@ impl Header {

/// Set the log bloom field of the header.
pub fn set_log_bloom(&mut self, a: Bloom) {
let fake_bloom = Bloom::repeat_byte(255);
change_field(&mut self.hash, &mut self.log_bloom, fake_bloom);
change_field(&mut self.hash, &mut self.log_bloom, a);
}

/// Set the timestamp field of the header.
Expand Down

0 comments on commit 8e832a4

Please sign in to comment.