mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2024-12-28 14:57:17 +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)?;
|
||||
|
||||
// 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.
|
||||
//
|
||||
|
@ -89,6 +89,7 @@ impl<T: BeaconChainTypes> ForkChoice<T> {
|
||||
&self,
|
||||
state: &BeaconState<T::EthSpec>,
|
||||
block: &BeaconBlock,
|
||||
block_root: Hash256,
|
||||
) -> Result<()> {
|
||||
// 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.backend.process_block(block_root, block.slot)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -138,7 +141,7 @@ impl<T: BeaconChainTypes> ForkChoice<T> {
|
||||
|
||||
for validator_index in validator_indices {
|
||||
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 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,
|
||||
validator_index: usize,
|
||||
block_hash: Hash256,
|
||||
block_slot: Slot,
|
||||
) -> 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>
|
||||
where
|
||||
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,
|
||||
validator_index: usize,
|
||||
block_hash: Hash256,
|
||||
@ -52,6 +52,11 @@ where
|
||||
.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>
|
||||
where
|
||||
F: Fn(usize) -> Option<u64> + Copy,
|
||||
|
Loading…
Reference in New Issue
Block a user