diff --git a/consensus/proto_array/src/error.rs b/consensus/proto_array/src/error.rs index bb5eea569d..bb47af97d9 100644 --- a/consensus/proto_array/src/error.rs +++ b/consensus/proto_array/src/error.rs @@ -61,6 +61,7 @@ pub enum Error { block_root: Hash256, }, NoViableChildren, + OnBlockRequiresProposerIndex, } impl From for Error { diff --git a/consensus/proto_array/src/fork_choice_test_definition.rs b/consensus/proto_array/src/fork_choice_test_definition.rs index 4507e013ba..b6ccc4d435 100644 --- a/consensus/proto_array/src/fork_choice_test_definition.rs +++ b/consensus/proto_array/src/fork_choice_test_definition.rs @@ -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::( diff --git a/consensus/proto_array/src/proto_array.rs b/consensus/proto_array/src/proto_array.rs index e3671eef7d..374190f9ed 100644 --- a/consensus/proto_array/src/proto_array.rs +++ b/consensus/proto_array/src/proto_array.rs @@ -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 diff --git a/consensus/proto_array/src/proto_array_fork_choice.rs b/consensus/proto_array/src/proto_array_fork_choice.rs index 94660f24ff..e8ad6c063a 100644 --- a/consensus/proto_array/src/proto_array_fork_choice.rs +++ b/consensus/proto_array/src/proto_array_fork_choice.rs @@ -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,