Set safe block hash to justified (#3347)

## Issue Addressed

Closes https://github.com/sigp/lighthouse/issues/3189.

## Proposed Changes

- Always supply the justified block hash as the `safe_block_hash` when calling `forkchoiceUpdated` on the execution engine.
- Refactor the `get_payload` routine to use the new `ForkchoiceUpdateParameters` struct rather than just the `finalized_block_hash`. I think this is a nice simplification and that the old way of computing the `finalized_block_hash` was unnecessary, but if anyone sees reason to keep that approach LMK.
This commit is contained in:
Michael Sproul
2022-07-21 05:45:37 +00:00
parent 6a0e9d4353
commit e32868458f
12 changed files with 156 additions and 96 deletions

View File

@@ -335,7 +335,9 @@ impl<T: EthSpec> ExecutionBlockGenerator<T> {
}
let unknown_head_block_hash = !self.blocks.contains_key(&forkchoice_state.head_block_hash);
let unknown_safe_block_hash = !self.blocks.contains_key(&forkchoice_state.safe_block_hash);
let unknown_safe_block_hash = forkchoice_state.safe_block_hash
!= ExecutionBlockHash::zero()
&& !self.blocks.contains_key(&forkchoice_state.safe_block_hash);
let unknown_finalized_block_hash = forkchoice_state.finalized_block_hash
!= ExecutionBlockHash::zero()
&& !self

View File

@@ -88,11 +88,16 @@ impl<T: EthSpec> MockExecutionLayer<T> {
let block_number = latest_execution_block.block_number() + 1;
let timestamp = block_number;
let prev_randao = Hash256::from_low_u64_be(block_number);
let finalized_block_hash = parent_hash;
let head_block_root = Hash256::repeat_byte(42);
let forkchoice_update_params = ForkchoiceUpdateParameters {
head_root: head_block_root,
head_hash: Some(parent_hash),
justified_hash: None,
finalized_hash: None,
};
// Insert a proposer to ensure the fork choice updated command works.
let slot = Slot::new(0);
let head_block_root = Hash256::repeat_byte(42);
let validator_index = 0;
self.el
.insert_proposer(
@@ -111,6 +116,7 @@ impl<T: EthSpec> MockExecutionLayer<T> {
.notify_forkchoice_updated(
parent_hash,
ExecutionBlockHash::zero(),
ExecutionBlockHash::zero(),
slot,
head_block_root,
)
@@ -124,10 +130,10 @@ impl<T: EthSpec> MockExecutionLayer<T> {
parent_hash,
timestamp,
prev_randao,
finalized_block_hash,
validator_index,
None,
slot,
forkchoice_update_params,
)
.await
.unwrap()
@@ -148,6 +154,7 @@ impl<T: EthSpec> MockExecutionLayer<T> {
.notify_forkchoice_updated(
block_hash,
ExecutionBlockHash::zero(),
ExecutionBlockHash::zero(),
slot,
head_block_root,
)