mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-29 10:54:24 +00:00
Merge remote-tracking branch 'origin/master' into spec-v0.12
This commit is contained in:
@@ -190,7 +190,7 @@ fn dequeue_attestations(
|
||||
queued_attestations
|
||||
.iter()
|
||||
.position(|a| a.slot >= current_slot)
|
||||
.unwrap_or(queued_attestations.len()),
|
||||
.unwrap_or_else(|| queued_attestations.len()),
|
||||
);
|
||||
|
||||
std::mem::replace(queued_attestations, remaining)
|
||||
@@ -286,6 +286,7 @@ where
|
||||
/// Equivalent to:
|
||||
///
|
||||
/// https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/fork-choice.md#get_ancestor
|
||||
#[allow(clippy::if_same_then_else)]
|
||||
fn get_ancestor(
|
||||
&self,
|
||||
block_root: Hash256,
|
||||
|
||||
@@ -80,10 +80,9 @@ impl ForkChoiceTestDefinition {
|
||||
finalized_epoch,
|
||||
&justified_state_balances,
|
||||
)
|
||||
.expect(&format!(
|
||||
"find_head op at index {} returned error",
|
||||
op_index
|
||||
));
|
||||
.unwrap_or_else(|_| {
|
||||
panic!("find_head op at index {} returned error", op_index)
|
||||
});
|
||||
|
||||
assert_eq!(
|
||||
head, expected_head,
|
||||
@@ -129,10 +128,12 @@ impl ForkChoiceTestDefinition {
|
||||
justified_epoch,
|
||||
finalized_epoch,
|
||||
};
|
||||
fork_choice.process_block(block).expect(&format!(
|
||||
"process_block op at index {} returned error",
|
||||
op_index
|
||||
));
|
||||
fork_choice.process_block(block).unwrap_or_else(|e| {
|
||||
panic!(
|
||||
"process_block op at index {} returned error: {:?}",
|
||||
op_index, e
|
||||
)
|
||||
});
|
||||
check_bytes_round_trip(&fork_choice);
|
||||
}
|
||||
Operation::ProcessAttestation {
|
||||
@@ -142,10 +143,12 @@ impl ForkChoiceTestDefinition {
|
||||
} => {
|
||||
fork_choice
|
||||
.process_attestation(validator_index, block_root, target_epoch)
|
||||
.expect(&format!(
|
||||
"process_attestation op at index {} returned error",
|
||||
op_index
|
||||
));
|
||||
.unwrap_or_else(|_| {
|
||||
panic!(
|
||||
"process_attestation op at index {} returned error",
|
||||
op_index
|
||||
)
|
||||
});
|
||||
check_bytes_round_trip(&fork_choice);
|
||||
}
|
||||
Operation::Prune {
|
||||
|
||||
@@ -91,7 +91,7 @@ pub fn get_ffg_case_01_test_definition() -> ForkChoiceTestDefinition {
|
||||
justified_epoch: Epoch::new(2),
|
||||
justified_root: get_hash(3),
|
||||
finalized_epoch: Epoch::new(1),
|
||||
justified_state_balances: balances.clone(),
|
||||
justified_state_balances: balances,
|
||||
expected_head: get_hash(3),
|
||||
});
|
||||
|
||||
@@ -421,7 +421,7 @@ pub fn get_ffg_case_02_test_definition() -> ForkChoiceTestDefinition {
|
||||
justified_epoch: Epoch::new(3),
|
||||
justified_root: get_hash(2),
|
||||
finalized_epoch: Epoch::new(0),
|
||||
justified_state_balances: balances.clone(),
|
||||
justified_state_balances: balances,
|
||||
});
|
||||
|
||||
// END OF TESTS
|
||||
|
||||
@@ -212,7 +212,7 @@ pub fn get_no_votes_test_definition() -> ForkChoiceTestDefinition {
|
||||
justified_epoch: Epoch::new(2),
|
||||
justified_root: get_hash(5),
|
||||
finalized_epoch: Epoch::new(1),
|
||||
justified_state_balances: balances.clone(),
|
||||
justified_state_balances: balances,
|
||||
expected_head: get_hash(6),
|
||||
},
|
||||
];
|
||||
|
||||
@@ -673,7 +673,7 @@ pub fn get_votes_test_definition() -> ForkChoiceTestDefinition {
|
||||
justified_epoch: Epoch::new(2),
|
||||
justified_root: get_hash(5),
|
||||
finalized_epoch: Epoch::new(2),
|
||||
justified_state_balances: balances.clone(),
|
||||
justified_state_balances: balances,
|
||||
expected_head: get_hash(11),
|
||||
});
|
||||
|
||||
|
||||
@@ -10,20 +10,8 @@ use tree_hash_derive::TreeHash;
|
||||
///
|
||||
/// Spec v0.12.1
|
||||
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
|
||||
#[derive(
|
||||
Derivative,
|
||||
Debug,
|
||||
PartialEq,
|
||||
Eq,
|
||||
Clone,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
Encode,
|
||||
Decode,
|
||||
TreeHash,
|
||||
TestRandom,
|
||||
)]
|
||||
#[derivative(Hash(bound = "T: EthSpec"))]
|
||||
#[derive(Derivative, Debug, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom)]
|
||||
#[derivative(PartialEq, Eq, Hash(bound = "T: EthSpec"))]
|
||||
#[serde(bound = "T: EthSpec")]
|
||||
pub struct AttesterSlashing<T: EthSpec> {
|
||||
pub attestation_1: IndexedAttestation<T>,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use crate::{test_utils::TestRandom, AggregateSignature, AttestationData, EthSpec, VariableList};
|
||||
use derivative::Derivative;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use ssz::Encode;
|
||||
use ssz_derive::{Decode, Encode};
|
||||
@@ -12,9 +13,8 @@ use tree_hash_derive::TreeHash;
|
||||
///
|
||||
/// Spec v0.12.1
|
||||
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
|
||||
#[derive(
|
||||
Debug, PartialEq, Eq, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom,
|
||||
)]
|
||||
#[derive(Derivative, Debug, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom)]
|
||||
#[derivative(PartialEq, Eq)] // to satisfy Clippy's lint about `Hash`
|
||||
#[serde(bound = "T: EthSpec")]
|
||||
pub struct IndexedAttestation<T: EthSpec> {
|
||||
/// Lists validator registry indices, not committee indices.
|
||||
|
||||
@@ -47,11 +47,11 @@ impl TestingAttesterSlashingBuilder {
|
||||
};
|
||||
|
||||
let data_2 = if test_task == AttesterSlashingTestTask::NotSlashable {
|
||||
AttestationData { ..data_1.clone() }
|
||||
data_1.clone()
|
||||
} else {
|
||||
AttestationData {
|
||||
target: checkpoint_2,
|
||||
..data_1.clone()
|
||||
..data_1
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user