mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-30 12:47:05 +00:00
debugging
This commit is contained in:
@@ -6,7 +6,7 @@ mod votes;
|
||||
use crate::proto_array_fork_choice::{Block, ExecutionStatus, ProtoArrayForkChoice};
|
||||
use crate::{InvalidationOperation, JustifiedBalances};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::BTreeSet;
|
||||
use std::collections::{BTreeSet, HashMap};
|
||||
use types::{
|
||||
AttestationShufflingId, Checkpoint, Epoch, EthSpec, ExecutionBlockHash, FixedBytesExtended,
|
||||
Hash256, MainnetEthSpec, Slot,
|
||||
@@ -87,7 +87,7 @@ impl ForkChoiceTestDefinition {
|
||||
self.finalized_checkpoint,
|
||||
junk_shuffling_id.clone(),
|
||||
junk_shuffling_id,
|
||||
Hash256::ZERO,
|
||||
HashMap::new(),
|
||||
ExecutionStatus::Optimistic(ExecutionBlockHash::zero()),
|
||||
)
|
||||
.expect("should create fork choice struct");
|
||||
|
||||
@@ -134,7 +134,7 @@ pub struct ProtoArray {
|
||||
pub finalized_checkpoint: Checkpoint,
|
||||
pub nodes: Vec<ProtoNode>,
|
||||
pub indices: HashMap<Hash256, usize>,
|
||||
pub unsatisfied_inclusion_list_block: Hash256,
|
||||
pub unsatisfied_inclusion_list_blocks: HashMap<Slot, Hash256>,
|
||||
pub previous_proposer_boost: ProposerBoost,
|
||||
}
|
||||
|
||||
@@ -197,8 +197,14 @@ impl ProtoArray {
|
||||
let execution_status_is_invalid = node.execution_status.is_invalid();
|
||||
|
||||
// TODO(focil) seems sketchy...
|
||||
// modify is viable for head
|
||||
// debug/fork_choice
|
||||
let mut node_delta = if execution_status_is_invalid
|
||||
|| node.root == self.unsatisfied_inclusion_list_block
|
||||
|| node.root
|
||||
== *self
|
||||
.unsatisfied_inclusion_list_blocks
|
||||
.get(¤t_slot)
|
||||
.unwrap_or(&Hash256::ZERO)
|
||||
{
|
||||
// If the node has an invalid execution payload, or the payload doesn't satisfy
|
||||
// an inclusion list, reduce its weight to zero.
|
||||
@@ -892,7 +898,13 @@ impl ProtoArray {
|
||||
return false;
|
||||
}
|
||||
|
||||
if node.root == self.unsatisfied_inclusion_list_block {
|
||||
// TODO(focil) unwrap_or
|
||||
if node.root
|
||||
== *self
|
||||
.unsatisfied_inclusion_list_blocks
|
||||
.get(¤t_slot)
|
||||
.unwrap_or(&Hash256::ZERO)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -370,7 +370,7 @@ impl ProtoArrayForkChoice {
|
||||
finalized_checkpoint: Checkpoint,
|
||||
current_epoch_shuffling_id: AttestationShufflingId,
|
||||
next_epoch_shuffling_id: AttestationShufflingId,
|
||||
unsatisfied_inclusion_list_block: Hash256,
|
||||
unsatisfied_inclusion_list_blocks: HashMap<Slot, Hash256>,
|
||||
execution_status: ExecutionStatus,
|
||||
) -> Result<Self, String> {
|
||||
let mut proto_array = ProtoArray {
|
||||
@@ -379,7 +379,7 @@ impl ProtoArrayForkChoice {
|
||||
finalized_checkpoint,
|
||||
nodes: Vec::with_capacity(1),
|
||||
indices: HashMap::with_capacity(1),
|
||||
unsatisfied_inclusion_list_block,
|
||||
unsatisfied_inclusion_list_blocks,
|
||||
previous_proposer_boost: ProposerBoost::default(),
|
||||
};
|
||||
|
||||
@@ -1033,7 +1033,7 @@ mod test_compute_deltas {
|
||||
genesis_checkpoint,
|
||||
junk_shuffling_id.clone(),
|
||||
junk_shuffling_id.clone(),
|
||||
Hash256::ZERO,
|
||||
HashMap::new(),
|
||||
execution_status,
|
||||
)
|
||||
.unwrap();
|
||||
@@ -1160,7 +1160,7 @@ mod test_compute_deltas {
|
||||
genesis_checkpoint,
|
||||
junk_shuffling_id.clone(),
|
||||
junk_shuffling_id.clone(),
|
||||
Hash256::ZERO,
|
||||
HashMap::new(),
|
||||
execution_status,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@@ -8,7 +8,7 @@ use ssz::{four_byte_option_impl, Encode};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use std::collections::HashMap;
|
||||
use superstruct::superstruct;
|
||||
use types::{Checkpoint, Hash256};
|
||||
use types::{Checkpoint, Hash256, Slot};
|
||||
|
||||
// Define a "legacy" implementation of `Option<usize>` which uses four bytes for encoding the union
|
||||
// selector.
|
||||
@@ -27,7 +27,7 @@ pub struct SszContainer {
|
||||
pub nodes: Vec<ProtoNodeV17>,
|
||||
pub indices: Vec<(Hash256, usize)>,
|
||||
pub previous_proposer_boost: ProposerBoost,
|
||||
pub unsatisfied_inclusion_list_block: Hash256,
|
||||
pub unsatisfied_inclusion_list_blocks: Vec<(Slot, Hash256)>,
|
||||
}
|
||||
|
||||
impl From<&ProtoArrayForkChoice> for SszContainer {
|
||||
@@ -43,7 +43,11 @@ impl From<&ProtoArrayForkChoice> for SszContainer {
|
||||
nodes: proto_array.nodes.clone(),
|
||||
indices: proto_array.indices.iter().map(|(k, v)| (*k, *v)).collect(),
|
||||
previous_proposer_boost: proto_array.previous_proposer_boost,
|
||||
unsatisfied_inclusion_list_block: proto_array.unsatisfied_inclusion_list_block,
|
||||
unsatisfied_inclusion_list_blocks: proto_array
|
||||
.unsatisfied_inclusion_list_blocks
|
||||
.iter()
|
||||
.map(|(k, v)| (*k, *v))
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,8 +62,11 @@ impl TryFrom<SszContainer> for ProtoArrayForkChoice {
|
||||
finalized_checkpoint: from.finalized_checkpoint,
|
||||
nodes: from.nodes,
|
||||
indices: from.indices.into_iter().collect::<HashMap<_, _>>(),
|
||||
unsatisfied_inclusion_list_block: from.unsatisfied_inclusion_list_block,
|
||||
previous_proposer_boost: from.previous_proposer_boost,
|
||||
unsatisfied_inclusion_list_blocks: from
|
||||
.unsatisfied_inclusion_list_blocks
|
||||
.into_iter()
|
||||
.collect::<HashMap<_, _>>(),
|
||||
};
|
||||
|
||||
Ok(Self {
|
||||
|
||||
Reference in New Issue
Block a user