mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 00:42:42 +00:00
Add extra data in /eth/v1/debug/fork_choice (#7845)
* #7829 Co-Authored-By: Tan Chee Keong <tanck@sigmaprime.io> Co-Authored-By: chonghe <44791194+chong-he@users.noreply.github.com>
This commit is contained in:
@@ -48,9 +48,9 @@ use bytes::Bytes;
|
|||||||
use directory::DEFAULT_ROOT_DIR;
|
use directory::DEFAULT_ROOT_DIR;
|
||||||
use eth2::types::{
|
use eth2::types::{
|
||||||
self as api_types, BroadcastValidation, ContextDeserialize, EndpointVersion, ForkChoice,
|
self as api_types, BroadcastValidation, ContextDeserialize, EndpointVersion, ForkChoice,
|
||||||
ForkChoiceNode, LightClientUpdatesQuery, PublishBlockRequest, StateId as CoreStateId,
|
ForkChoiceExtraData, ForkChoiceNode, LightClientUpdatesQuery, PublishBlockRequest,
|
||||||
ValidatorBalancesRequestBody, ValidatorId, ValidatorIdentitiesRequestBody, ValidatorStatus,
|
StateId as CoreStateId, ValidatorBalancesRequestBody, ValidatorId,
|
||||||
ValidatorsRequestBody,
|
ValidatorIdentitiesRequestBody, ValidatorStatus, ValidatorsRequestBody,
|
||||||
};
|
};
|
||||||
use eth2::{CONSENSUS_VERSION_HEADER, CONTENT_TYPE_HEADER, SSZ_CONTENT_TYPE_HEADER};
|
use eth2::{CONSENSUS_VERSION_HEADER, CONTENT_TYPE_HEADER, SSZ_CONTENT_TYPE_HEADER};
|
||||||
use health_metrics::observe::Observe;
|
use health_metrics::observe::Observe;
|
||||||
@@ -3033,6 +3033,32 @@ pub fn serve<T: BeaconChainTypes>(
|
|||||||
.execution_status
|
.execution_status
|
||||||
.block_hash()
|
.block_hash()
|
||||||
.map(|block_hash| block_hash.into_root()),
|
.map(|block_hash| block_hash.into_root()),
|
||||||
|
extra_data: ForkChoiceExtraData {
|
||||||
|
target_root: node.target_root,
|
||||||
|
justified_root: node.justified_checkpoint.root,
|
||||||
|
finalized_root: node.finalized_checkpoint.root,
|
||||||
|
unrealized_justified_root: node
|
||||||
|
.unrealized_justified_checkpoint
|
||||||
|
.map(|checkpoint| checkpoint.root),
|
||||||
|
unrealized_finalized_root: node
|
||||||
|
.unrealized_finalized_checkpoint
|
||||||
|
.map(|checkpoint| checkpoint.root),
|
||||||
|
unrealized_justified_epoch: node
|
||||||
|
.unrealized_justified_checkpoint
|
||||||
|
.map(|checkpoint| checkpoint.epoch),
|
||||||
|
unrealized_finalized_epoch: node
|
||||||
|
.unrealized_finalized_checkpoint
|
||||||
|
.map(|checkpoint| checkpoint.epoch),
|
||||||
|
execution_status: node.execution_status.to_string(),
|
||||||
|
best_child: node
|
||||||
|
.best_child
|
||||||
|
.and_then(|index| proto_array.nodes.get(index))
|
||||||
|
.map(|child| child.root),
|
||||||
|
best_descendant: node
|
||||||
|
.best_descendant
|
||||||
|
.and_then(|index| proto_array.nodes.get(index))
|
||||||
|
.map(|descendant| descendant.root),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|||||||
@@ -3088,6 +3088,32 @@ impl ApiTester {
|
|||||||
.execution_status
|
.execution_status
|
||||||
.block_hash()
|
.block_hash()
|
||||||
.map(|block_hash| block_hash.into_root()),
|
.map(|block_hash| block_hash.into_root()),
|
||||||
|
extra_data: ForkChoiceExtraData {
|
||||||
|
target_root: node.target_root,
|
||||||
|
justified_root: node.justified_checkpoint.root,
|
||||||
|
finalized_root: node.finalized_checkpoint.root,
|
||||||
|
unrealized_justified_root: node
|
||||||
|
.unrealized_justified_checkpoint
|
||||||
|
.map(|checkpoint| checkpoint.root),
|
||||||
|
unrealized_finalized_root: node
|
||||||
|
.unrealized_finalized_checkpoint
|
||||||
|
.map(|checkpoint| checkpoint.root),
|
||||||
|
unrealized_justified_epoch: node
|
||||||
|
.unrealized_justified_checkpoint
|
||||||
|
.map(|checkpoint| checkpoint.epoch),
|
||||||
|
unrealized_finalized_epoch: node
|
||||||
|
.unrealized_finalized_checkpoint
|
||||||
|
.map(|checkpoint| checkpoint.epoch),
|
||||||
|
execution_status: node.execution_status.to_string(),
|
||||||
|
best_child: node
|
||||||
|
.best_child
|
||||||
|
.and_then(|index| expected_proto_array.nodes.get(index))
|
||||||
|
.map(|child| child.root),
|
||||||
|
best_descendant: node
|
||||||
|
.best_descendant
|
||||||
|
.and_then(|index| expected_proto_array.nodes.get(index))
|
||||||
|
.map(|descendant| descendant.root),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|||||||
@@ -1520,6 +1520,21 @@ pub struct ForkChoiceNode {
|
|||||||
pub weight: u64,
|
pub weight: u64,
|
||||||
pub validity: Option<String>,
|
pub validity: Option<String>,
|
||||||
pub execution_block_hash: Option<Hash256>,
|
pub execution_block_hash: Option<Hash256>,
|
||||||
|
pub extra_data: ForkChoiceExtraData,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||||
|
pub struct ForkChoiceExtraData {
|
||||||
|
pub target_root: Hash256,
|
||||||
|
pub justified_root: Hash256,
|
||||||
|
pub finalized_root: Hash256,
|
||||||
|
pub unrealized_justified_root: Option<Hash256>,
|
||||||
|
pub unrealized_finalized_root: Option<Hash256>,
|
||||||
|
pub unrealized_justified_epoch: Option<Epoch>,
|
||||||
|
pub unrealized_finalized_epoch: Option<Epoch>,
|
||||||
|
pub execution_status: String,
|
||||||
|
pub best_child: Option<Hash256>,
|
||||||
|
pub best_descendant: Option<Hash256>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq)]
|
||||||
|
|||||||
Reference in New Issue
Block a user