mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-10 12:11:59 +00:00
Update to consensus spec v1.4.0-beta.6 (#5094)
* get latest ef tests passing
* fix tests
* Fix invalid payload recovery tests
* Merge branch 'unstable' into update-to-spec-v1.4.0-beta.6
* Revert "fix tests"
This reverts commit 0c875b02e0.
* Fix fork choice def. tests
* Update beacon_node/beacon_chain/tests/payload_invalidation.rs
This commit is contained in:
@@ -59,7 +59,7 @@ pub fn get_ffg_case_01_test_definition() -> ForkChoiceTestDefinition {
|
||||
expected_head: get_root(3),
|
||||
});
|
||||
|
||||
// Ensure that with justified epoch 1 we find 2
|
||||
// Ensure that with justified epoch 1 we find 3
|
||||
//
|
||||
// 0
|
||||
// |
|
||||
@@ -68,11 +68,15 @@ pub fn get_ffg_case_01_test_definition() -> ForkChoiceTestDefinition {
|
||||
// 2 <- start
|
||||
// |
|
||||
// 3 <- head
|
||||
//
|
||||
// Since https://github.com/ethereum/consensus-specs/pull/3431 it is valid
|
||||
// to elect head blocks that have a higher justified checkpoint than the
|
||||
// store.
|
||||
ops.push(Operation::FindHead {
|
||||
justified_checkpoint: get_checkpoint(1),
|
||||
finalized_checkpoint: get_checkpoint(0),
|
||||
justified_state_balances: balances.clone(),
|
||||
expected_head: get_root(2),
|
||||
expected_head: get_root(3),
|
||||
});
|
||||
|
||||
// Ensure that with justified epoch 2 we find 3
|
||||
@@ -247,14 +251,19 @@ pub fn get_ffg_case_02_test_definition() -> ForkChoiceTestDefinition {
|
||||
justified_state_balances: balances.clone(),
|
||||
expected_head: get_root(10),
|
||||
});
|
||||
// Same as above, but with justified epoch 3 (should be invalid).
|
||||
ops.push(Operation::InvalidFindHead {
|
||||
// Same as above, but with justified epoch 3.
|
||||
//
|
||||
// Since https://github.com/ethereum/consensus-specs/pull/3431 it is valid
|
||||
// to elect head blocks that have a higher justified checkpoint than the
|
||||
// store.
|
||||
ops.push(Operation::FindHead {
|
||||
justified_checkpoint: Checkpoint {
|
||||
epoch: Epoch::new(3),
|
||||
root: get_root(6),
|
||||
},
|
||||
finalized_checkpoint: get_checkpoint(0),
|
||||
justified_state_balances: balances.clone(),
|
||||
expected_head: get_root(10),
|
||||
});
|
||||
|
||||
// Add a vote to 1.
|
||||
@@ -305,14 +314,19 @@ pub fn get_ffg_case_02_test_definition() -> ForkChoiceTestDefinition {
|
||||
justified_state_balances: balances.clone(),
|
||||
expected_head: get_root(9),
|
||||
});
|
||||
// Save as above but justified epoch 3 (should fail).
|
||||
ops.push(Operation::InvalidFindHead {
|
||||
// Save as above but justified epoch 3.
|
||||
//
|
||||
// Since https://github.com/ethereum/consensus-specs/pull/3431 it is valid
|
||||
// to elect head blocks that have a higher justified checkpoint than the
|
||||
// store.
|
||||
ops.push(Operation::FindHead {
|
||||
justified_checkpoint: Checkpoint {
|
||||
epoch: Epoch::new(3),
|
||||
root: get_root(5),
|
||||
},
|
||||
finalized_checkpoint: get_checkpoint(0),
|
||||
justified_state_balances: balances.clone(),
|
||||
expected_head: get_root(9),
|
||||
});
|
||||
|
||||
// Add a vote to 2.
|
||||
@@ -363,14 +377,19 @@ pub fn get_ffg_case_02_test_definition() -> ForkChoiceTestDefinition {
|
||||
justified_state_balances: balances.clone(),
|
||||
expected_head: get_root(10),
|
||||
});
|
||||
// Same as above but justified epoch 3 (should fail).
|
||||
ops.push(Operation::InvalidFindHead {
|
||||
// Same as above but justified epoch 3.
|
||||
//
|
||||
// Since https://github.com/ethereum/consensus-specs/pull/3431 it is valid
|
||||
// to elect head blocks that have a higher justified checkpoint than the
|
||||
// store.
|
||||
ops.push(Operation::FindHead {
|
||||
justified_checkpoint: Checkpoint {
|
||||
epoch: Epoch::new(3),
|
||||
root: get_root(6),
|
||||
},
|
||||
finalized_checkpoint: get_checkpoint(0),
|
||||
justified_state_balances: balances.clone(),
|
||||
expected_head: get_root(10),
|
||||
});
|
||||
|
||||
// Ensure that if we start at 1 we find 9 (just: 0, fin: 0).
|
||||
@@ -405,14 +424,19 @@ pub fn get_ffg_case_02_test_definition() -> ForkChoiceTestDefinition {
|
||||
justified_state_balances: balances.clone(),
|
||||
expected_head: get_root(9),
|
||||
});
|
||||
// Same as above but justified epoch 3 (should fail).
|
||||
ops.push(Operation::InvalidFindHead {
|
||||
// Same as above but justified epoch 3.
|
||||
//
|
||||
// Since https://github.com/ethereum/consensus-specs/pull/3431 it is valid
|
||||
// to elect head blocks that have a higher justified checkpoint than the
|
||||
// store.
|
||||
ops.push(Operation::FindHead {
|
||||
justified_checkpoint: Checkpoint {
|
||||
epoch: Epoch::new(3),
|
||||
root: get_root(5),
|
||||
},
|
||||
finalized_checkpoint: get_checkpoint(0),
|
||||
justified_state_balances: balances.clone(),
|
||||
expected_head: get_root(9),
|
||||
});
|
||||
|
||||
// Ensure that if we start at 2 we find 10 (just: 0, fin: 0).
|
||||
@@ -444,14 +468,19 @@ pub fn get_ffg_case_02_test_definition() -> ForkChoiceTestDefinition {
|
||||
justified_state_balances: balances.clone(),
|
||||
expected_head: get_root(10),
|
||||
});
|
||||
// Same as above but justified epoch 3 (should fail).
|
||||
ops.push(Operation::InvalidFindHead {
|
||||
// Same as above but justified epoch 3.
|
||||
//
|
||||
// Since https://github.com/ethereum/consensus-specs/pull/3431 it is valid
|
||||
// to elect head blocks that have a higher justified checkpoint than the
|
||||
// store.
|
||||
ops.push(Operation::FindHead {
|
||||
justified_checkpoint: Checkpoint {
|
||||
epoch: Epoch::new(3),
|
||||
root: get_root(6),
|
||||
},
|
||||
finalized_checkpoint: get_checkpoint(0),
|
||||
justified_state_balances: balances,
|
||||
expected_head: get_root(10),
|
||||
});
|
||||
|
||||
// END OF TESTS
|
||||
|
||||
@@ -184,7 +184,7 @@ pub fn get_no_votes_test_definition() -> ForkChoiceTestDefinition {
|
||||
root: Hash256::zero(),
|
||||
},
|
||||
},
|
||||
// Ensure the head is still 4 whilst the justified epoch is 0.
|
||||
// Ensure the head is now 5 whilst the justified epoch is 0.
|
||||
//
|
||||
// 0
|
||||
// / \
|
||||
@@ -203,9 +203,10 @@ pub fn get_no_votes_test_definition() -> ForkChoiceTestDefinition {
|
||||
root: Hash256::zero(),
|
||||
},
|
||||
justified_state_balances: balances.clone(),
|
||||
expected_head: get_root(4),
|
||||
expected_head: get_root(5),
|
||||
},
|
||||
// Ensure there is an error when starting from a block that has the wrong justified epoch.
|
||||
// Ensure there is no error when starting from a block that has the
|
||||
// wrong justified epoch.
|
||||
//
|
||||
// 0
|
||||
// / \
|
||||
@@ -214,7 +215,11 @@ pub fn get_no_votes_test_definition() -> ForkChoiceTestDefinition {
|
||||
// 4 3
|
||||
// |
|
||||
// 5 <- starting from 5 with justified epoch 0 should error.
|
||||
Operation::InvalidFindHead {
|
||||
//
|
||||
// Since https://github.com/ethereum/consensus-specs/pull/3431 it is valid
|
||||
// to elect head blocks that have a higher justified checkpoint than the
|
||||
// store.
|
||||
Operation::FindHead {
|
||||
justified_checkpoint: Checkpoint {
|
||||
epoch: Epoch::new(1),
|
||||
root: get_root(5),
|
||||
@@ -224,6 +229,7 @@ pub fn get_no_votes_test_definition() -> ForkChoiceTestDefinition {
|
||||
root: Hash256::zero(),
|
||||
},
|
||||
justified_state_balances: balances.clone(),
|
||||
expected_head: get_root(5),
|
||||
},
|
||||
// Set the justified epoch to 2 and the start block to 5 and ensure 5 is the head.
|
||||
//
|
||||
|
||||
@@ -961,16 +961,9 @@ impl ProtoArray {
|
||||
node_justified_checkpoint
|
||||
};
|
||||
|
||||
let mut correct_justified = self.justified_checkpoint.epoch == genesis_epoch
|
||||
|| voting_source.epoch == self.justified_checkpoint.epoch;
|
||||
|
||||
if let Some(node_unrealized_justified_checkpoint) = node.unrealized_justified_checkpoint {
|
||||
if !correct_justified && self.justified_checkpoint.epoch + 1 == current_epoch {
|
||||
correct_justified = node_unrealized_justified_checkpoint.epoch
|
||||
>= self.justified_checkpoint.epoch
|
||||
&& voting_source.epoch + 2 >= current_epoch;
|
||||
}
|
||||
}
|
||||
let correct_justified = self.justified_checkpoint.epoch == genesis_epoch
|
||||
|| voting_source.epoch == self.justified_checkpoint.epoch
|
||||
|| voting_source.epoch + 2 >= current_epoch;
|
||||
|
||||
let correct_finalized = self.finalized_checkpoint.epoch == genesis_epoch
|
||||
|| self.is_finalized_checkpoint_or_descendant::<E>(node.root);
|
||||
|
||||
Reference in New Issue
Block a user