mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2025-01-01 00:41:20 +00:00
Add stubbed-out block processing to fork choice
This commit is contained in:
parent
f6c86d0f7f
commit
9c2bbb6c05
@ -624,7 +624,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
self.store.put(&state_root, &state)?;
|
self.store.put(&state_root, &state)?;
|
||||||
|
|
||||||
// Register the new block with the fork choice service.
|
// Register the new block with the fork choice service.
|
||||||
self.fork_choice.process_block(&state, &block)?;
|
self.fork_choice.process_block(&state, &block, block_root)?;
|
||||||
|
|
||||||
// Execute the fork choice algorithm, enthroning a new head if discovered.
|
// Execute the fork choice algorithm, enthroning a new head if discovered.
|
||||||
//
|
//
|
||||||
|
@ -89,6 +89,7 @@ impl<T: BeaconChainTypes> ForkChoice<T> {
|
|||||||
&self,
|
&self,
|
||||||
state: &BeaconState<T::EthSpec>,
|
state: &BeaconState<T::EthSpec>,
|
||||||
block: &BeaconBlock,
|
block: &BeaconBlock,
|
||||||
|
block_root: Hash256,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
// Note: we never count the block as a latest message, only attestations.
|
// Note: we never count the block as a latest message, only attestations.
|
||||||
//
|
//
|
||||||
@ -100,6 +101,8 @@ impl<T: BeaconChainTypes> ForkChoice<T> {
|
|||||||
self.process_attestation_from_block(state, attestation)?;
|
self.process_attestation_from_block(state, attestation)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.backend.process_block(block_root, block.slot)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +141,7 @@ impl<T: BeaconChainTypes> ForkChoice<T> {
|
|||||||
|
|
||||||
for validator_index in validator_indices {
|
for validator_index in validator_indices {
|
||||||
self.backend
|
self.backend
|
||||||
.process_message(validator_index, block_hash, block_slot)?;
|
.process_attestation(validator_index, block_hash, block_slot)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,18 +9,27 @@ pub use reduced_tree::ThreadSafeReducedTree;
|
|||||||
pub type Result<T> = std::result::Result<T, String>;
|
pub type Result<T> = std::result::Result<T, String>;
|
||||||
|
|
||||||
pub trait LmdGhost<S: Store, E: EthSpec>: Send + Sync {
|
pub trait LmdGhost<S: Store, E: EthSpec>: Send + Sync {
|
||||||
fn new(store: Arc<S>, genesis_root: Hash256) -> Self;
|
/// Create a new instance, with the given `store` and `finalized_root`.
|
||||||
|
fn new(store: Arc<S>, finalized_root: Hash256) -> Self;
|
||||||
|
|
||||||
fn process_message(
|
/// Process an attestation message from some validator that attests to some `block_hash`
|
||||||
|
/// representing a block at some `block_slot`.
|
||||||
|
fn process_attestation(
|
||||||
&self,
|
&self,
|
||||||
validator_index: usize,
|
validator_index: usize,
|
||||||
block_hash: Hash256,
|
block_hash: Hash256,
|
||||||
block_slot: Slot,
|
block_slot: Slot,
|
||||||
) -> Result<()>;
|
) -> Result<()>;
|
||||||
|
|
||||||
|
/// Process a block that was seen on the network.
|
||||||
|
fn process_block(&self, block_hash: Hash256, block_slot: Slot) -> Result<()>;
|
||||||
|
|
||||||
|
/// Returns the head of the chain, starting the search at `start_block_root` and moving upwards
|
||||||
|
/// (in block height).
|
||||||
fn find_head<F>(&self, start_block_root: Hash256, weight: F) -> Result<Hash256>
|
fn find_head<F>(&self, start_block_root: Hash256, weight: F) -> Result<Hash256>
|
||||||
where
|
where
|
||||||
F: Fn(usize) -> Option<u64> + Copy;
|
F: Fn(usize) -> Option<u64> + Copy;
|
||||||
|
|
||||||
fn update_finalized_root(&self, new_root: Hash256) -> Result<()>;
|
/// Provide an indication that the blockchain has been finalized at the given `finalized_root`.
|
||||||
|
fn update_finalized_root(&self, finalized_root: Hash256) -> Result<()>;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process_message(
|
fn process_attestation(
|
||||||
&self,
|
&self,
|
||||||
validator_index: usize,
|
validator_index: usize,
|
||||||
block_hash: Hash256,
|
block_hash: Hash256,
|
||||||
@ -52,6 +52,11 @@ where
|
|||||||
.map_err(Into::into)
|
.map_err(Into::into)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Process a block that was seen on the network.
|
||||||
|
fn process_block(&self, block_hash: Hash256, block_slot: Slot) -> SuperResult<()> {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
|
||||||
fn find_head<F>(&self, start_block_root: Hash256, weight_fn: F) -> SuperResult<Hash256>
|
fn find_head<F>(&self, start_block_root: Hash256, weight_fn: F) -> SuperResult<Hash256>
|
||||||
where
|
where
|
||||||
F: Fn(usize) -> Option<u64> + Copy,
|
F: Fn(usize) -> Option<u64> + Copy,
|
||||||
|
Loading…
Reference in New Issue
Block a user