mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 11:41:51 +00:00
Implement Metadatav3 (#6303)
* Add a V3 variant for metadata * Add v3 for requests; persistence logic * Set custody_subnets on setting metadata * Fix tests * Address some comments * fmt * Address more comments * Fix tests * Update metadata rpc limits * Update method doc.
This commit is contained in:
@@ -165,7 +165,17 @@ impl<E: EthSpec> Network<E> {
|
||||
ctx.chain_spec,
|
||||
)?;
|
||||
// Construct the metadata
|
||||
let meta_data = utils::load_or_build_metadata(&config.network_dir, &log);
|
||||
let custody_subnet_count = if ctx.chain_spec.is_peer_das_scheduled() {
|
||||
if config.subscribe_all_data_column_subnets {
|
||||
Some(ctx.chain_spec.data_column_sidecar_subnet_count)
|
||||
} else {
|
||||
Some(ctx.chain_spec.custody_requirement)
|
||||
}
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let meta_data =
|
||||
utils::load_or_build_metadata(&config.network_dir, custody_subnet_count, &log);
|
||||
let globals = NetworkGlobals::new(
|
||||
enr,
|
||||
meta_data,
|
||||
@@ -1130,8 +1140,14 @@ impl<E: EthSpec> Network<E> {
|
||||
|
||||
/// Sends a METADATA request to a peer.
|
||||
fn send_meta_data_request(&mut self, peer_id: PeerId) {
|
||||
// We always prefer sending V2 requests
|
||||
let event = OutboundRequest::MetaData(MetadataRequest::new_v2());
|
||||
let event = if self.fork_context.spec.is_peer_das_scheduled() {
|
||||
// Nodes with higher custody will probably start advertising it
|
||||
// before peerdas is activated
|
||||
OutboundRequest::MetaData(MetadataRequest::new_v3())
|
||||
} else {
|
||||
// We always prefer sending V2 requests otherwise
|
||||
OutboundRequest::MetaData(MetadataRequest::new_v2())
|
||||
};
|
||||
self.eth2_rpc_mut()
|
||||
.send_request(peer_id, RequestId::Internal, event);
|
||||
}
|
||||
@@ -1139,15 +1155,12 @@ impl<E: EthSpec> Network<E> {
|
||||
/// Sends a METADATA response to a peer.
|
||||
fn send_meta_data_response(
|
||||
&mut self,
|
||||
req: MetadataRequest<E>,
|
||||
_req: MetadataRequest<E>,
|
||||
id: PeerRequestId,
|
||||
peer_id: PeerId,
|
||||
) {
|
||||
let metadata = self.network_globals.local_metadata.read().clone();
|
||||
let metadata = match req {
|
||||
MetadataRequest::V1(_) => metadata.metadata_v1(),
|
||||
MetadataRequest::V2(_) => metadata,
|
||||
};
|
||||
// The encoder is responsible for sending the negotiated version of the metadata
|
||||
let event = RPCCodedResponse::Success(RPCResponse::MetaData(metadata));
|
||||
self.eth2_rpc_mut().send_response(peer_id, id, event);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user