mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-20 22:38:34 +00:00
Make proposer_index mandatory in on_block
This commit is contained in:
@@ -61,6 +61,7 @@ pub enum Error {
|
||||
block_root: Hash256,
|
||||
},
|
||||
NoViableChildren,
|
||||
OnBlockRequiresProposerIndex,
|
||||
}
|
||||
|
||||
impl From<ArithError> for Error {
|
||||
|
||||
@@ -280,7 +280,7 @@ impl ForkChoiceTestDefinition {
|
||||
unrealized_finalized_checkpoint: None,
|
||||
execution_payload_parent_hash,
|
||||
execution_payload_block_hash,
|
||||
proposer_index: None,
|
||||
proposer_index: Some(0),
|
||||
};
|
||||
fork_choice
|
||||
.process_block::<MainnetEthSpec>(
|
||||
|
||||
@@ -551,6 +551,12 @@ impl ProtoArray {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// We do not allow `proposer_index=None` for calls to `on_block`, it is only non-optional
|
||||
// for backwards-compatibility with pre-Gloas V17 proto nodes.
|
||||
let Some(proposer_index) = block.proposer_index else {
|
||||
return Err(Error::OnBlockRequiresProposerIndex);
|
||||
};
|
||||
|
||||
let node_index = self.nodes.len();
|
||||
|
||||
let parent_index = block
|
||||
@@ -658,7 +664,7 @@ impl ProtoArray {
|
||||
BitVector::default()
|
||||
},
|
||||
payload_received: is_genesis,
|
||||
proposer_index: block.proposer_index.unwrap_or(0),
|
||||
proposer_index,
|
||||
// Spec: `record_block_timeliness` + `get_forkchoice_store`.
|
||||
// Anchor gets [True, True]. Others computed from time_into_slot.
|
||||
block_timeliness_attestation_threshold: is_genesis
|
||||
|
||||
@@ -492,7 +492,7 @@ impl ProtoArrayForkChoice {
|
||||
unrealized_finalized_checkpoint: Some(finalized_checkpoint),
|
||||
execution_payload_parent_hash,
|
||||
execution_payload_block_hash,
|
||||
proposer_index: None,
|
||||
proposer_index: Some(0),
|
||||
};
|
||||
|
||||
proto_array
|
||||
@@ -1338,7 +1338,7 @@ mod test_compute_deltas {
|
||||
unrealized_finalized_checkpoint: Some(genesis_checkpoint),
|
||||
execution_payload_parent_hash: None,
|
||||
execution_payload_block_hash: None,
|
||||
proposer_index: None,
|
||||
proposer_index: Some(0),
|
||||
},
|
||||
genesis_slot + 1,
|
||||
genesis_checkpoint,
|
||||
@@ -1368,7 +1368,7 @@ mod test_compute_deltas {
|
||||
unrealized_finalized_checkpoint: None,
|
||||
execution_payload_parent_hash: None,
|
||||
execution_payload_block_hash: None,
|
||||
proposer_index: None,
|
||||
proposer_index: Some(0),
|
||||
},
|
||||
genesis_slot + 1,
|
||||
genesis_checkpoint,
|
||||
@@ -1505,7 +1505,7 @@ mod test_compute_deltas {
|
||||
unrealized_finalized_checkpoint: Some(genesis_checkpoint),
|
||||
execution_payload_parent_hash: None,
|
||||
execution_payload_block_hash: None,
|
||||
proposer_index: None,
|
||||
proposer_index: Some(0),
|
||||
},
|
||||
Slot::from(block.slot),
|
||||
genesis_checkpoint,
|
||||
|
||||
Reference in New Issue
Block a user