mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 19:51:47 +00:00
Implement status v2 version (#7590)
N/A Implements status v2 as defined in https://github.com/ethereum/consensus-specs/pull/4374/
This commit is contained in:
@@ -1243,6 +1243,7 @@ mod tests {
|
||||
head_root: Hash256::random(),
|
||||
finalized_epoch,
|
||||
finalized_root: Hash256::random(),
|
||||
earliest_available_slot: None,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
@@ -398,10 +398,11 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
// ensure the beacon chain still exists
|
||||
let status = self.chain.status_message();
|
||||
let local = SyncInfo {
|
||||
head_slot: status.head_slot,
|
||||
head_root: status.head_root,
|
||||
finalized_epoch: status.finalized_epoch,
|
||||
finalized_root: status.finalized_root,
|
||||
head_slot: *status.head_slot(),
|
||||
head_root: *status.head_root(),
|
||||
finalized_epoch: *status.finalized_epoch(),
|
||||
finalized_root: *status.finalized_root(),
|
||||
earliest_available_slot: status.earliest_available_slot().ok().cloned(),
|
||||
};
|
||||
|
||||
let sync_type = remote_sync_type(&local, &remote, &self.chain);
|
||||
@@ -450,10 +451,11 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
) {
|
||||
let status = self.chain.status_message();
|
||||
let local = SyncInfo {
|
||||
head_slot: status.head_slot,
|
||||
head_root: status.head_root,
|
||||
finalized_epoch: status.finalized_epoch,
|
||||
finalized_root: status.finalized_root,
|
||||
head_slot: *status.head_slot(),
|
||||
head_root: *status.head_root(),
|
||||
finalized_epoch: *status.finalized_epoch(),
|
||||
finalized_root: *status.finalized_root(),
|
||||
earliest_available_slot: status.earliest_available_slot().ok().cloned(),
|
||||
};
|
||||
|
||||
let head_slot = head_slot.unwrap_or_else(|| {
|
||||
@@ -471,6 +473,7 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
// Set finalized to same as local to trigger Head sync
|
||||
finalized_epoch: local.finalized_epoch,
|
||||
finalized_root: local.finalized_root,
|
||||
earliest_available_slot: local.earliest_available_slot,
|
||||
};
|
||||
|
||||
for peer_id in peers {
|
||||
|
||||
@@ -384,11 +384,12 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
|
||||
for peer_id in peers {
|
||||
debug!(
|
||||
peer = %peer_id,
|
||||
fork_digest = ?status_message.fork_digest,
|
||||
finalized_root = ?status_message.finalized_root,
|
||||
finalized_epoch = ?status_message.finalized_epoch,
|
||||
head_root = %status_message.head_root,
|
||||
head_slot = %status_message.head_slot,
|
||||
fork_digest = ?status_message.fork_digest(),
|
||||
finalized_root = ?status_message.finalized_root(),
|
||||
finalized_epoch = ?status_message.finalized_epoch(),
|
||||
head_root = %status_message.head_root(),
|
||||
head_slot = %status_message.head_slot(),
|
||||
earliest_available_slot = ?status_message.earliest_available_slot(),
|
||||
"Sending Status Request"
|
||||
);
|
||||
|
||||
|
||||
@@ -411,10 +411,11 @@ where
|
||||
|
||||
let status = self.beacon_chain.status_message();
|
||||
let local = SyncInfo {
|
||||
head_slot: status.head_slot,
|
||||
head_root: status.head_root,
|
||||
finalized_epoch: status.finalized_epoch,
|
||||
finalized_root: status.finalized_root,
|
||||
head_slot: *status.head_slot(),
|
||||
head_root: *status.head_root(),
|
||||
finalized_epoch: *status.finalized_epoch(),
|
||||
finalized_root: *status.finalized_root(),
|
||||
earliest_available_slot: status.earliest_available_slot().ok().cloned(),
|
||||
};
|
||||
|
||||
// update the state of the collection
|
||||
|
||||
@@ -11,9 +11,9 @@ use beacon_chain::{block_verification_types::RpcBlock, EngineState, NotifyExecut
|
||||
use beacon_processor::WorkType;
|
||||
use lighthouse_network::rpc::methods::{
|
||||
BlobsByRangeRequest, DataColumnsByRangeRequest, OldBlocksByRangeRequest,
|
||||
OldBlocksByRangeRequestV2,
|
||||
OldBlocksByRangeRequestV2, StatusMessageV2,
|
||||
};
|
||||
use lighthouse_network::rpc::{RequestType, StatusMessage};
|
||||
use lighthouse_network::rpc::RequestType;
|
||||
use lighthouse_network::service::api_types::{
|
||||
AppRequestId, BlobsByRangeRequestId, BlocksByRangeRequestId, DataColumnsByRangeRequestId,
|
||||
SyncRequestId,
|
||||
@@ -98,6 +98,7 @@ impl TestRig {
|
||||
finalized_root,
|
||||
head_slot: finalized_epoch.start_slot(E::slots_per_epoch()),
|
||||
head_root: Hash256::random(),
|
||||
earliest_available_slot: None,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -109,22 +110,25 @@ impl TestRig {
|
||||
finalized_root: Hash256::random(),
|
||||
head_slot: finalized_epoch.start_slot(E::slots_per_epoch()),
|
||||
head_root: Hash256::random(),
|
||||
earliest_available_slot: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn local_info(&self) -> SyncInfo {
|
||||
let StatusMessage {
|
||||
let StatusMessageV2 {
|
||||
fork_digest: _,
|
||||
finalized_root,
|
||||
finalized_epoch,
|
||||
head_root,
|
||||
head_slot,
|
||||
} = self.harness.chain.status_message();
|
||||
earliest_available_slot,
|
||||
} = self.harness.chain.status_message().status_v2();
|
||||
SyncInfo {
|
||||
head_slot,
|
||||
head_root,
|
||||
finalized_epoch,
|
||||
finalized_root,
|
||||
earliest_available_slot: Some(earliest_available_slot),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user