adding tests and payload changes

This commit is contained in:
hopinheimer
2026-02-26 03:14:57 -05:00
parent d5c5077a31
commit e04a8c31ea
13 changed files with 627 additions and 73 deletions

View File

@@ -106,7 +106,6 @@ pub fn get_execution_status_test_definition_01() -> ForkChoiceTestDefinition {
validator_index: 0,
block_root: get_root(1),
attestation_slot: Slot::new(2),
payload_present: false,
});
// Ensure that the head is now 1, because 1 has a vote.
@@ -149,7 +148,6 @@ pub fn get_execution_status_test_definition_01() -> ForkChoiceTestDefinition {
validator_index: 1,
block_root: get_root(2),
attestation_slot: Slot::new(2),
payload_present: false,
});
// Ensure that the head is 2 since 1 and 2 both have a vote
@@ -254,7 +252,6 @@ pub fn get_execution_status_test_definition_01() -> ForkChoiceTestDefinition {
validator_index: 0,
block_root: get_root(3),
attestation_slot: Slot::new(3),
payload_present: false,
});
// Ensure that the head is still 2
@@ -357,7 +354,6 @@ pub fn get_execution_status_test_definition_01() -> ForkChoiceTestDefinition {
validator_index: 1,
block_root: get_root(1),
attestation_slot: Slot::new(3),
payload_present: false,
});
// Ensure that the head has switched back to 1
@@ -521,7 +517,6 @@ pub fn get_execution_status_test_definition_02() -> ForkChoiceTestDefinition {
validator_index: 0,
block_root: get_root(1),
attestation_slot: Slot::new(2),
payload_present: false,
});
// Ensure that the head is now 1, because 1 has a vote.
@@ -564,7 +559,6 @@ pub fn get_execution_status_test_definition_02() -> ForkChoiceTestDefinition {
validator_index: 1,
block_root: get_root(2),
attestation_slot: Slot::new(2),
payload_present: false,
});
// Ensure that the head is 2 since 1 and 2 both have a vote
@@ -669,7 +663,6 @@ pub fn get_execution_status_test_definition_02() -> ForkChoiceTestDefinition {
validator_index: 0,
block_root: get_root(3),
attestation_slot: Slot::new(3),
payload_present: false,
});
// Move validator #1 vote from 2 to 3
@@ -683,7 +676,6 @@ pub fn get_execution_status_test_definition_02() -> ForkChoiceTestDefinition {
validator_index: 1,
block_root: get_root(3),
attestation_slot: Slot::new(3),
payload_present: false,
});
// Ensure that the head is now 3.
@@ -898,7 +890,6 @@ pub fn get_execution_status_test_definition_03() -> ForkChoiceTestDefinition {
validator_index: 0,
block_root: get_root(1),
attestation_slot: Slot::new(2),
payload_present: false,
});
// Ensure that the head is now 1, because 1 has a vote.
@@ -941,7 +932,6 @@ pub fn get_execution_status_test_definition_03() -> ForkChoiceTestDefinition {
validator_index: 1,
block_root: get_root(1),
attestation_slot: Slot::new(2),
payload_present: false,
});
// Ensure that the head is 1.

View File

@@ -312,7 +312,6 @@ pub fn get_ffg_case_02_test_definition() -> ForkChoiceTestDefinition {
validator_index: 0,
block_root: get_root(1),
attestation_slot: Slot::new(0),
payload_present: false,
});
// Ensure that if we start at 0 we find 9 (just: 0, fin: 0).
@@ -376,7 +375,6 @@ pub fn get_ffg_case_02_test_definition() -> ForkChoiceTestDefinition {
validator_index: 1,
block_root: get_root(2),
attestation_slot: Slot::new(0),
payload_present: false,
});
// Ensure that if we start at 0 we find 10 (just: 0, fin: 0).

View File

@@ -109,18 +109,21 @@ pub fn get_gloas_payload_probe_test_definition() -> ForkChoiceTestDefinition {
execution_payload_block_hash: Some(get_hash(1)),
});
// One Full and one Empty vote for the same head block: tie should probe as Full.
ops.push(Operation::ProcessAttestation {
// One Full and one Empty vote for the same head block: tie probes via runtime tiebreak,
// which defaults to Empty unless timely+data-available evidence is set.
ops.push(Operation::ProcessPayloadAttestation {
validator_index: 0,
block_root: get_root(1),
attestation_slot: Slot::new(2),
payload_present: true,
blob_data_available: false,
});
ops.push(Operation::ProcessAttestation {
ops.push(Operation::ProcessPayloadAttestation {
validator_index: 1,
block_root: get_root(1),
attestation_slot: Slot::new(2),
payload_present: false,
blob_data_available: false,
});
ops.push(Operation::FindHead {
justified_checkpoint: get_checkpoint(0),
@@ -135,15 +138,16 @@ pub fn get_gloas_payload_probe_test_definition() -> ForkChoiceTestDefinition {
});
ops.push(Operation::AssertHeadPayloadStatus {
head_root: get_root(1),
expected_status: PayloadStatus::Full,
expected_status: PayloadStatus::Empty,
});
// Flip validator 0 to Empty; probe should now report Empty.
ops.push(Operation::ProcessAttestation {
ops.push(Operation::ProcessPayloadAttestation {
validator_index: 0,
block_root: get_root(1),
attestation_slot: Slot::new(3),
payload_present: false,
blob_data_available: false,
});
ops.push(Operation::FindHead {
justified_checkpoint: get_checkpoint(0),
@@ -171,11 +175,12 @@ pub fn get_gloas_payload_probe_test_definition() -> ForkChoiceTestDefinition {
execution_payload_parent_hash: Some(get_hash(1)),
execution_payload_block_hash: Some(get_hash(5)),
});
ops.push(Operation::ProcessAttestation {
ops.push(Operation::ProcessPayloadAttestation {
validator_index: 2,
block_root: get_root(5),
attestation_slot: Slot::new(3),
payload_present: true,
blob_data_available: false,
});
ops.push(Operation::FindHead {
justified_checkpoint: get_checkpoint(0),
@@ -190,7 +195,250 @@ pub fn get_gloas_payload_probe_test_definition() -> ForkChoiceTestDefinition {
});
ops.push(Operation::AssertHeadPayloadStatus {
head_root: get_root(5),
expected_status: PayloadStatus::Full,
expected_status: PayloadStatus::Empty,
});
ForkChoiceTestDefinition {
finalized_block_slot: Slot::new(0),
justified_checkpoint: get_checkpoint(0),
finalized_checkpoint: get_checkpoint(0),
operations: ops,
execution_payload_parent_hash: Some(get_hash(42)),
execution_payload_block_hash: Some(get_hash(0)),
spec: Some(gloas_spec()),
}
}
pub fn get_gloas_find_head_vote_transition_test_definition() -> ForkChoiceTestDefinition {
let mut ops = vec![];
// Competing branches with distinct payload ancestry (Full vs Empty from genesis).
ops.push(Operation::ProcessBlock {
slot: Slot::new(1),
root: get_root(1),
parent_root: get_root(0),
justified_checkpoint: get_checkpoint(0),
finalized_checkpoint: get_checkpoint(0),
execution_payload_parent_hash: Some(get_hash(0)),
execution_payload_block_hash: Some(get_hash(1)),
});
ops.push(Operation::ProcessBlock {
slot: Slot::new(1),
root: get_root(2),
parent_root: get_root(0),
justified_checkpoint: get_checkpoint(0),
finalized_checkpoint: get_checkpoint(0),
execution_payload_parent_hash: Some(get_hash(99)),
execution_payload_block_hash: Some(get_hash(2)),
});
ops.push(Operation::ProcessBlock {
slot: Slot::new(2),
root: get_root(3),
parent_root: get_root(1),
justified_checkpoint: get_checkpoint(0),
finalized_checkpoint: get_checkpoint(0),
execution_payload_parent_hash: Some(get_hash(1)),
execution_payload_block_hash: Some(get_hash(3)),
});
ops.push(Operation::ProcessBlock {
slot: Slot::new(2),
root: get_root(4),
parent_root: get_root(2),
justified_checkpoint: get_checkpoint(0),
finalized_checkpoint: get_checkpoint(0),
execution_payload_parent_hash: Some(get_hash(100)),
execution_payload_block_hash: Some(get_hash(4)),
});
// Equal branch weights: tiebreak FULL picks branch rooted at 3.
ops.push(Operation::SetPayloadTiebreak {
block_root: get_root(0),
is_timely: true,
is_data_available: true,
});
ops.push(Operation::FindHead {
justified_checkpoint: get_checkpoint(0),
finalized_checkpoint: get_checkpoint(0),
justified_state_balances: vec![1],
expected_head: get_root(3),
});
// Validator 0 votes Empty branch -> head flips to 4.
ops.push(Operation::ProcessPayloadAttestation {
validator_index: 0,
block_root: get_root(4),
attestation_slot: Slot::new(3),
payload_present: false,
blob_data_available: false,
});
ops.push(Operation::FindHead {
justified_checkpoint: get_checkpoint(0),
finalized_checkpoint: get_checkpoint(0),
justified_state_balances: vec![1],
expected_head: get_root(4),
});
// Latest-message update back to Full branch -> head returns to 3.
ops.push(Operation::ProcessPayloadAttestation {
validator_index: 0,
block_root: get_root(3),
attestation_slot: Slot::new(4),
payload_present: true,
blob_data_available: false,
});
ops.push(Operation::FindHead {
justified_checkpoint: get_checkpoint(0),
finalized_checkpoint: get_checkpoint(0),
justified_state_balances: vec![1],
expected_head: get_root(3),
});
ops.push(Operation::AssertPayloadWeights {
block_root: get_root(3),
expected_full_weight: 1,
expected_empty_weight: 0,
});
ForkChoiceTestDefinition {
finalized_block_slot: Slot::new(0),
justified_checkpoint: get_checkpoint(0),
finalized_checkpoint: get_checkpoint(0),
operations: ops,
execution_payload_parent_hash: Some(get_hash(42)),
execution_payload_block_hash: Some(get_hash(0)),
spec: Some(gloas_spec()),
}
}
pub fn get_gloas_weight_priority_over_payload_preference_test_definition()
-> ForkChoiceTestDefinition {
let mut ops = vec![];
// Build two branches where one child extends payload (Full) and the other doesn't (Empty).
ops.push(Operation::ProcessBlock {
slot: Slot::new(1),
root: get_root(1),
parent_root: get_root(0),
justified_checkpoint: get_checkpoint(0),
finalized_checkpoint: get_checkpoint(0),
execution_payload_parent_hash: Some(get_hash(0)),
execution_payload_block_hash: Some(get_hash(1)),
});
ops.push(Operation::ProcessBlock {
slot: Slot::new(1),
root: get_root(2),
parent_root: get_root(0),
justified_checkpoint: get_checkpoint(0),
finalized_checkpoint: get_checkpoint(0),
execution_payload_parent_hash: Some(get_hash(99)),
execution_payload_block_hash: Some(get_hash(2)),
});
ops.push(Operation::ProcessBlock {
slot: Slot::new(2),
root: get_root(3),
parent_root: get_root(1),
justified_checkpoint: get_checkpoint(0),
finalized_checkpoint: get_checkpoint(0),
execution_payload_parent_hash: Some(get_hash(1)),
execution_payload_block_hash: Some(get_hash(3)),
});
ops.push(Operation::ProcessBlock {
slot: Slot::new(2),
root: get_root(4),
parent_root: get_root(2),
justified_checkpoint: get_checkpoint(0),
finalized_checkpoint: get_checkpoint(0),
execution_payload_parent_hash: Some(get_hash(100)),
execution_payload_block_hash: Some(get_hash(4)),
});
// Parent prefers Full on equal branch weights.
ops.push(Operation::SetPayloadTiebreak {
block_root: get_root(0),
is_timely: true,
is_data_available: true,
});
ops.push(Operation::FindHead {
justified_checkpoint: get_checkpoint(0),
finalized_checkpoint: get_checkpoint(0),
justified_state_balances: vec![1],
expected_head: get_root(3),
});
// Add two Empty votes to make the Empty branch strictly heavier.
ops.push(Operation::ProcessPayloadAttestation {
validator_index: 0,
block_root: get_root(4),
attestation_slot: Slot::new(3),
payload_present: false,
blob_data_available: false,
});
ops.push(Operation::ProcessPayloadAttestation {
validator_index: 1,
block_root: get_root(4),
attestation_slot: Slot::new(3),
payload_present: false,
blob_data_available: false,
});
ops.push(Operation::FindHead {
justified_checkpoint: get_checkpoint(0),
finalized_checkpoint: get_checkpoint(0),
justified_state_balances: vec![1, 1],
expected_head: get_root(4),
});
ForkChoiceTestDefinition {
finalized_block_slot: Slot::new(0),
justified_checkpoint: get_checkpoint(0),
finalized_checkpoint: get_checkpoint(0),
operations: ops,
execution_payload_parent_hash: Some(get_hash(42)),
execution_payload_block_hash: Some(get_hash(0)),
spec: Some(gloas_spec()),
}
}
pub fn get_gloas_parent_empty_when_child_points_to_grandparent_test_definition()
-> ForkChoiceTestDefinition {
let mut ops = vec![];
// Build a three-block chain A -> B -> C (CL parent links).
// A: EL parent = genesis hash(0), EL hash = hash(1).
ops.push(Operation::ProcessBlock {
slot: Slot::new(1),
root: get_root(1),
parent_root: get_root(0),
justified_checkpoint: get_checkpoint(0),
finalized_checkpoint: get_checkpoint(0),
execution_payload_parent_hash: Some(get_hash(0)),
execution_payload_block_hash: Some(get_hash(1)),
});
// B: EL parent = hash(1), EL hash = hash(2).
ops.push(Operation::ProcessBlock {
slot: Slot::new(2),
root: get_root(2),
parent_root: get_root(1),
justified_checkpoint: get_checkpoint(0),
finalized_checkpoint: get_checkpoint(0),
execution_payload_parent_hash: Some(get_hash(1)),
execution_payload_block_hash: Some(get_hash(2)),
});
// C: CL parent is B, but EL parent points to A (hash 1), not B (hash 2).
// This models B's payload not arriving in time, so C records parent status as Empty.
ops.push(Operation::ProcessBlock {
slot: Slot::new(3),
root: get_root(3),
parent_root: get_root(2),
justified_checkpoint: get_checkpoint(0),
finalized_checkpoint: get_checkpoint(0),
execution_payload_parent_hash: Some(get_hash(1)),
execution_payload_block_hash: Some(get_hash(3)),
});
ops.push(Operation::AssertParentPayloadStatus {
block_root: get_root(3),
expected_status: PayloadStatus::Empty,
});
ForkChoiceTestDefinition {
@@ -219,4 +467,22 @@ mod tests {
let test = get_gloas_payload_probe_test_definition();
test.run();
}
#[test]
fn find_head_vote_transition() {
let test = get_gloas_find_head_vote_transition_test_definition();
test.run();
}
#[test]
fn weight_priority_over_payload_preference() {
let test = get_gloas_weight_priority_over_payload_preference_test_definition();
test.run();
}
#[test]
fn parent_empty_when_child_points_to_grandparent() {
let test = get_gloas_parent_empty_when_child_points_to_grandparent_test_definition();
test.run();
}
}

View File

@@ -106,7 +106,6 @@ pub fn get_votes_test_definition() -> ForkChoiceTestDefinition {
validator_index: 0,
block_root: get_root(1),
attestation_slot: Slot::new(2),
payload_present: false,
});
// Ensure that the head is now 1, because 1 has a vote.
@@ -136,7 +135,6 @@ pub fn get_votes_test_definition() -> ForkChoiceTestDefinition {
validator_index: 1,
block_root: get_root(2),
attestation_slot: Slot::new(2),
payload_present: false,
});
// Ensure that the head is 2 since 1 and 2 both have a vote
@@ -211,7 +209,6 @@ pub fn get_votes_test_definition() -> ForkChoiceTestDefinition {
validator_index: 0,
block_root: get_root(3),
attestation_slot: Slot::new(3),
payload_present: false,
});
// Ensure that the head is still 2
@@ -246,7 +243,6 @@ pub fn get_votes_test_definition() -> ForkChoiceTestDefinition {
validator_index: 1,
block_root: get_root(1),
attestation_slot: Slot::new(3),
payload_present: false,
});
// Ensure that the head is now 3
@@ -409,13 +405,11 @@ pub fn get_votes_test_definition() -> ForkChoiceTestDefinition {
validator_index: 0,
block_root: get_root(5),
attestation_slot: Slot::new(4),
payload_present: false,
});
ops.push(Operation::ProcessAttestation {
validator_index: 1,
block_root: get_root(5),
attestation_slot: Slot::new(4),
payload_present: false,
});
// Add blocks 7, 8 and 9. Adding these blocks helps test the `best_descendant`
@@ -570,13 +564,11 @@ pub fn get_votes_test_definition() -> ForkChoiceTestDefinition {
validator_index: 0,
block_root: get_root(9),
attestation_slot: Slot::new(5),
payload_present: false,
});
ops.push(Operation::ProcessAttestation {
validator_index: 1,
block_root: get_root(9),
attestation_slot: Slot::new(5),
payload_present: false,
});
// Add block 10
@@ -650,13 +642,11 @@ pub fn get_votes_test_definition() -> ForkChoiceTestDefinition {
validator_index: 2,
block_root: get_root(10),
attestation_slot: Slot::new(5),
payload_present: false,
});
ops.push(Operation::ProcessAttestation {
validator_index: 3,
block_root: get_root(10),
attestation_slot: Slot::new(5),
payload_present: false,
});
// Check the head is now 10.