Add {fork_name}_enabled functions (#5951)

* add fork_name_enabled fn to Forkname impl

* refactor codebase to use new fork_enabled fn

* fmt

* Merge branch 'unstable' of https://github.com/sigp/lighthouse into fork-ord-impl

* small code cleanup

* resolve merge conflicts

* fix beacon chain test

* merge conflicts

* fix ef test issue

* resolve merge conflicts
This commit is contained in:
Eitan Seri-Levi
2024-10-02 19:00:52 -07:00
committed by GitHub
parent dd08ebb2b0
commit 82faf975b3
22 changed files with 223 additions and 251 deletions

View File

@@ -16,7 +16,7 @@ use std::collections::{hash_map::Entry, HashMap};
use std::sync::Arc;
use tokio_stream::StreamExt;
use types::blob_sidecar::BlobIdentifier;
use types::{Epoch, EthSpec, FixedBytesExtended, ForkName, Hash256, Slot};
use types::{Epoch, EthSpec, FixedBytesExtended, Hash256, Slot};
impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
/* Auxiliary functions */
@@ -564,14 +564,10 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
self.chain
.epoch()
.map_or(self.chain.spec.max_request_blocks, |epoch| {
match self.chain.spec.fork_name_at_epoch(epoch) {
ForkName::Deneb | ForkName::Electra => {
self.chain.spec.max_request_blocks_deneb
}
ForkName::Base
| ForkName::Altair
| ForkName::Bellatrix
| ForkName::Capella => self.chain.spec.max_request_blocks,
if self.chain.spec.fork_name_at_epoch(epoch).deneb_enabled() {
self.chain.spec.max_request_blocks_deneb
} else {
self.chain.spec.max_request_blocks
}
});
if *req.count() > max_request_size {

View File

@@ -537,21 +537,20 @@ mod tests {
} else {
panic!("Should have sent a batch request to the peer")
};
let blob_req_id = match fork_name {
ForkName::Deneb | ForkName::Electra => {
if let Ok(NetworkMessage::SendRequest {
peer_id,
request: _,
request_id,
}) = self.network_rx.try_recv()
{
assert_eq!(&peer_id, expected_peer);
Some(request_id)
} else {
panic!("Should have sent a batch request to the peer")
}
let blob_req_id = if fork_name.deneb_enabled() {
if let Ok(NetworkMessage::SendRequest {
peer_id,
request: _,
request_id,
}) = self.network_rx.try_recv()
{
assert_eq!(&peer_id, expected_peer);
Some(request_id)
} else {
panic!("Should have sent a batch request to the peer")
}
_ => None,
} else {
None
};
(block_req_id, blob_req_id)
}