mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-18 13:28:33 +00:00
Merge remote-tracking branch 'origin/unstable' into tree-states
This commit is contained in:
@@ -728,6 +728,15 @@ where
|
||||
state.get_block_root(slot).unwrap() == state.get_block_root(slot - 1).unwrap()
|
||||
}
|
||||
|
||||
pub async fn make_blinded_block(
|
||||
&self,
|
||||
state: BeaconState<E>,
|
||||
slot: Slot,
|
||||
) -> (SignedBlindedBeaconBlock<E>, BeaconState<E>) {
|
||||
let (unblinded, new_state) = self.make_block(state, slot).await;
|
||||
(unblinded.into(), new_state)
|
||||
}
|
||||
|
||||
/// Returns a newly created block, signed by the proposer for the given slot.
|
||||
pub async fn make_block(
|
||||
&self,
|
||||
@@ -740,9 +749,7 @@ where
|
||||
complete_state_advance(&mut state, None, slot, &self.spec)
|
||||
.expect("should be able to advance state to slot");
|
||||
|
||||
state
|
||||
.build_all_caches(&self.spec)
|
||||
.expect("should build caches");
|
||||
state.build_caches(&self.spec).expect("should build caches");
|
||||
|
||||
let proposer_index = state.get_beacon_proposer_index(slot, &self.spec).unwrap();
|
||||
|
||||
@@ -789,9 +796,7 @@ where
|
||||
complete_state_advance(&mut state, None, slot, &self.spec)
|
||||
.expect("should be able to advance state to slot");
|
||||
|
||||
state
|
||||
.build_all_caches(&self.spec)
|
||||
.expect("should build caches");
|
||||
state.build_caches(&self.spec).expect("should build caches");
|
||||
|
||||
let proposer_index = state.get_beacon_proposer_index(slot, &self.spec).unwrap();
|
||||
|
||||
@@ -1507,6 +1512,36 @@ where
|
||||
.sign(sk, &fork, genesis_validators_root, &self.chain.spec)
|
||||
}
|
||||
|
||||
pub fn add_proposer_slashing(&self, validator_index: u64) -> Result<(), String> {
|
||||
let propposer_slashing = self.make_proposer_slashing(validator_index);
|
||||
if let ObservationOutcome::New(verified_proposer_slashing) = self
|
||||
.chain
|
||||
.verify_proposer_slashing_for_gossip(propposer_slashing)
|
||||
.expect("should verify proposer slashing for gossip")
|
||||
{
|
||||
self.chain
|
||||
.import_proposer_slashing(verified_proposer_slashing);
|
||||
Ok(())
|
||||
} else {
|
||||
Err("should observe new proposer slashing".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_attester_slashing(&self, validator_indices: Vec<u64>) -> Result<(), String> {
|
||||
let attester_slashing = self.make_attester_slashing(validator_indices);
|
||||
if let ObservationOutcome::New(verified_attester_slashing) = self
|
||||
.chain
|
||||
.verify_attester_slashing_for_gossip(attester_slashing)
|
||||
.expect("should verify attester slashing for gossip")
|
||||
{
|
||||
self.chain
|
||||
.import_attester_slashing(verified_attester_slashing);
|
||||
Ok(())
|
||||
} else {
|
||||
Err("should observe new attester slashing".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_bls_to_execution_change(
|
||||
&self,
|
||||
validator_index: u64,
|
||||
@@ -1685,7 +1720,12 @@ where
|
||||
self.set_current_slot(slot);
|
||||
let block_hash: SignedBeaconBlockHash = self
|
||||
.chain
|
||||
.process_block(block_root, Arc::new(block), NotifyExecutionLayer::Yes)
|
||||
.process_block(
|
||||
block_root,
|
||||
Arc::new(block),
|
||||
NotifyExecutionLayer::Yes,
|
||||
|| Ok(()),
|
||||
)
|
||||
.await?
|
||||
.into();
|
||||
self.chain.recompute_head_at_current_slot().await;
|
||||
@@ -1702,6 +1742,7 @@ where
|
||||
block.canonical_root(),
|
||||
Arc::new(block),
|
||||
NotifyExecutionLayer::Yes,
|
||||
|| Ok(()),
|
||||
)
|
||||
.await?
|
||||
.into();
|
||||
|
||||
Reference in New Issue
Block a user