mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-23 23:04:53 +00:00
Refactor block_processing
- Add the rayon library for parallelization - Move from std::sync::Rwlock to rayon::RwLock - Add `state` field to BeaconChain - Fix major bug in attestation validator where justified slot was incorrectly looked up.
This commit is contained in:
@@ -113,6 +113,7 @@ impl BeaconChainHarness {
|
||||
debug!("Incrementing BeaconChain slot to {}.", slot);
|
||||
|
||||
self.beacon_chain.slot_clock.set_slot(slot);
|
||||
self.beacon_chain.advance_state(slot).unwrap();
|
||||
slot
|
||||
}
|
||||
|
||||
@@ -125,8 +126,8 @@ impl BeaconChainHarness {
|
||||
|
||||
let attesting_validators = self
|
||||
.beacon_chain
|
||||
.state(present_slot)
|
||||
.unwrap()
|
||||
.state
|
||||
.read()
|
||||
.get_crosslink_committees_at_slot(present_slot, &self.spec)
|
||||
.unwrap()
|
||||
.iter()
|
||||
@@ -195,13 +196,27 @@ impl BeaconChainHarness {
|
||||
self.beacon_chain.process_block(block).unwrap();
|
||||
debug!("...block processed by BeaconChain.");
|
||||
|
||||
debug!("Producing free attestations...");
|
||||
|
||||
// Produce new attestations.
|
||||
let free_attestations = self.gather_free_attesations();
|
||||
|
||||
debug!("Processing free attestations...");
|
||||
|
||||
free_attestations.par_iter().for_each(|free_attestation| {
|
||||
self.beacon_chain
|
||||
.process_free_attestation(free_attestation.clone())
|
||||
.unwrap();
|
||||
});
|
||||
|
||||
debug!("Free attestations processed.");
|
||||
/*
|
||||
for free_attestation in free_attestations {
|
||||
self.beacon_chain
|
||||
.process_free_attestation(free_attestation)
|
||||
.unwrap();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
pub fn chain_dump(&self) -> Result<Vec<SlotDump>, DumpError> {
|
||||
|
||||
@@ -13,10 +13,10 @@ where
|
||||
{
|
||||
fn produce_attestation_data(
|
||||
&self,
|
||||
slot: u64,
|
||||
_slot: u64,
|
||||
shard: u64,
|
||||
) -> Result<Option<AttestationData>, NodeError> {
|
||||
match self.beacon_chain.produce_attestation_data(slot, shard) {
|
||||
match self.beacon_chain.produce_attestation_data(shard) {
|
||||
Ok(attestation_data) => Ok(Some(attestation_data)),
|
||||
Err(e) => Err(NodeError::RemoteFailure(format!("{:?}", e))),
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ use attester::{Attester, Error as AttestationPollError};
|
||||
use beacon_chain::BeaconChain;
|
||||
use block_producer::{BlockProducer, Error as BlockPollError};
|
||||
use db::MemoryDB;
|
||||
use log::trace;
|
||||
use signer::TestSigner;
|
||||
use slot_clock::TestingSlotClock;
|
||||
use std::sync::Arc;
|
||||
|
||||
Reference in New Issue
Block a user