mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 01:05:47 +00:00
Make proposer_index mandatory in on_block
This commit is contained in:
@@ -61,6 +61,7 @@ pub enum Error {
|
|||||||
block_root: Hash256,
|
block_root: Hash256,
|
||||||
},
|
},
|
||||||
NoViableChildren,
|
NoViableChildren,
|
||||||
|
OnBlockRequiresProposerIndex,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ArithError> for Error {
|
impl From<ArithError> for Error {
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ impl ForkChoiceTestDefinition {
|
|||||||
unrealized_finalized_checkpoint: None,
|
unrealized_finalized_checkpoint: None,
|
||||||
execution_payload_parent_hash,
|
execution_payload_parent_hash,
|
||||||
execution_payload_block_hash,
|
execution_payload_block_hash,
|
||||||
proposer_index: None,
|
proposer_index: Some(0),
|
||||||
};
|
};
|
||||||
fork_choice
|
fork_choice
|
||||||
.process_block::<MainnetEthSpec>(
|
.process_block::<MainnetEthSpec>(
|
||||||
|
|||||||
@@ -551,6 +551,12 @@ impl ProtoArray {
|
|||||||
return Ok(());
|
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 node_index = self.nodes.len();
|
||||||
|
|
||||||
let parent_index = block
|
let parent_index = block
|
||||||
@@ -658,7 +664,7 @@ impl ProtoArray {
|
|||||||
BitVector::default()
|
BitVector::default()
|
||||||
},
|
},
|
||||||
payload_received: is_genesis,
|
payload_received: is_genesis,
|
||||||
proposer_index: block.proposer_index.unwrap_or(0),
|
proposer_index,
|
||||||
// Spec: `record_block_timeliness` + `get_forkchoice_store`.
|
// Spec: `record_block_timeliness` + `get_forkchoice_store`.
|
||||||
// Anchor gets [True, True]. Others computed from time_into_slot.
|
// Anchor gets [True, True]. Others computed from time_into_slot.
|
||||||
block_timeliness_attestation_threshold: is_genesis
|
block_timeliness_attestation_threshold: is_genesis
|
||||||
|
|||||||
@@ -492,7 +492,7 @@ impl ProtoArrayForkChoice {
|
|||||||
unrealized_finalized_checkpoint: Some(finalized_checkpoint),
|
unrealized_finalized_checkpoint: Some(finalized_checkpoint),
|
||||||
execution_payload_parent_hash,
|
execution_payload_parent_hash,
|
||||||
execution_payload_block_hash,
|
execution_payload_block_hash,
|
||||||
proposer_index: None,
|
proposer_index: Some(0),
|
||||||
};
|
};
|
||||||
|
|
||||||
proto_array
|
proto_array
|
||||||
@@ -1338,7 +1338,7 @@ mod test_compute_deltas {
|
|||||||
unrealized_finalized_checkpoint: Some(genesis_checkpoint),
|
unrealized_finalized_checkpoint: Some(genesis_checkpoint),
|
||||||
execution_payload_parent_hash: None,
|
execution_payload_parent_hash: None,
|
||||||
execution_payload_block_hash: None,
|
execution_payload_block_hash: None,
|
||||||
proposer_index: None,
|
proposer_index: Some(0),
|
||||||
},
|
},
|
||||||
genesis_slot + 1,
|
genesis_slot + 1,
|
||||||
genesis_checkpoint,
|
genesis_checkpoint,
|
||||||
@@ -1368,7 +1368,7 @@ mod test_compute_deltas {
|
|||||||
unrealized_finalized_checkpoint: None,
|
unrealized_finalized_checkpoint: None,
|
||||||
execution_payload_parent_hash: None,
|
execution_payload_parent_hash: None,
|
||||||
execution_payload_block_hash: None,
|
execution_payload_block_hash: None,
|
||||||
proposer_index: None,
|
proposer_index: Some(0),
|
||||||
},
|
},
|
||||||
genesis_slot + 1,
|
genesis_slot + 1,
|
||||||
genesis_checkpoint,
|
genesis_checkpoint,
|
||||||
@@ -1505,7 +1505,7 @@ mod test_compute_deltas {
|
|||||||
unrealized_finalized_checkpoint: Some(genesis_checkpoint),
|
unrealized_finalized_checkpoint: Some(genesis_checkpoint),
|
||||||
execution_payload_parent_hash: None,
|
execution_payload_parent_hash: None,
|
||||||
execution_payload_block_hash: None,
|
execution_payload_block_hash: None,
|
||||||
proposer_index: None,
|
proposer_index: Some(0),
|
||||||
},
|
},
|
||||||
Slot::from(block.slot),
|
Slot::from(block.slot),
|
||||||
genesis_checkpoint,
|
genesis_checkpoint,
|
||||||
|
|||||||
Reference in New Issue
Block a user