Skip to content

Commit a9cb329

Browse files
committed
Use empty_uninitialized and fix warnings
1 parent 4dc6e65 commit a9cb329

File tree

11 files changed

+24
-29
lines changed

11 files changed

+24
-29
lines changed

beacon_node/beacon_chain/src/blob_verification.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use crate::{metrics, BeaconChainError};
1212
use kzg::{Error as KzgError, Kzg, KzgCommitment};
1313
use slog::debug;
1414
use ssz_derive::{Decode, Encode};
15-
use ssz_types::VariableList;
1615
use std::time::Duration;
1716
use tree_hash::TreeHash;
1817
use types::blob_sidecar::BlobIdentifier;

beacon_node/beacon_chain/src/block_verification.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ use slog::{debug, error, warn, Logger};
8181
use slot_clock::SlotClock;
8282
use ssz::Encode;
8383
use ssz_derive::{Decode, Encode};
84-
use ssz_types::VariableList;
8584
use state_processing::per_block_processing::{errors::IntoWithIndex, is_merge_transition_block};
8685
use state_processing::{
8786
block_signature_verifier::{BlockSignatureVerifier, Error as BlockSignatureVerifierError},

beacon_node/beacon_chain/src/block_verification_types.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ use crate::data_column_verification::{
88
use crate::eth1_finalization_cache::Eth1FinalizationData;
99
use crate::{get_block_root, GossipVerifiedBlock, PayloadVerificationOutcome};
1010
use derivative::Derivative;
11-
use ssz_types::VariableList;
1211
use state_processing::ConsensusContext;
1312
use std::fmt::{Debug, Formatter};
1413
use std::sync::Arc;
15-
use types::blob_sidecar::{self, BlobIdentifier, FixedBlobSidecarList};
14+
use types::blob_sidecar::{self, BlobIdentifier};
1615
use types::data_column_sidecar::{self};
1716
use types::{
1817
BeaconBlockRef, BeaconState, BlindedPayload, BlobSidecarList, ChainSpec, Epoch, EthSpec,

beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use crate::BeaconChainTypes;
1111
use kzg::Kzg;
1212
use lru::LruCache;
1313
use parking_lot::RwLock;
14-
use ssz_types::{FixedVector, VariableList};
1514
use std::collections::HashSet;
1615
use std::num::NonZeroUsize;
1716
use std::sync::Arc;

beacon_node/client/src/builder.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ use network::{NetworkConfig, NetworkSenders, NetworkService};
3737
use slasher::Slasher;
3838
use slasher_service::SlasherService;
3939
use slog::{debug, info, warn, Logger};
40-
use ssz::Decode;
4140
use std::net::TcpListener;
4241
use std::path::{Path, PathBuf};
4342
use std::sync::Arc;

beacon_node/http_api/src/block_id.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,15 +279,21 @@ impl BlockId {
279279
.get_blobs(&root)
280280
.map_err(warp_utils::reject::beacon_chain_error)?;
281281

282-
let max_len = blob_sidecar_list.max_len();
283282
let blob_sidecar_list_filtered = match indices.indices {
284283
Some(vec) => {
285-
let list = blob_sidecar_list
284+
let list: Vec<_> = blob_sidecar_list
286285
.into_iter()
287286
.filter(|blob_sidecar| vec.contains(&blob_sidecar.index))
288287
.collect();
289-
BlobSidecarList::new(list, max_len)
290-
.map_err(|e| warp_utils::reject::custom_server_error(format!("{:?}", e)))?
288+
if let Some(max_len) = list
289+
.first()
290+
.map(|sidecar| chain.spec.max_blobs_per_block(sidecar.epoch()))
291+
{
292+
BlobSidecarList::new(list, max_len as usize)
293+
.map_err(|e| warp_utils::reject::custom_server_error(format!("{:?}", e)))?
294+
} else {
295+
BlobSidecarList::empty_uninitialized()
296+
}
291297
}
292298
None => blob_sidecar_list,
293299
};

beacon_node/http_api/src/publish_blocks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use types::{
2323
AbstractExecPayload, BeaconBlockRef, BlobSidecarList, BlockImportSource, DataColumnSidecarList,
2424
DataColumnSubnetId, EthSpec, ExecPayload, ExecutionBlockHash, ForkName, FullPayload,
2525
FullPayloadBellatrix, Hash256, RuntimeVariableList, SignedBeaconBlock,
26-
SignedBlindedBeaconBlock, VariableList,
26+
SignedBlindedBeaconBlock,
2727
};
2828
use warp::http::StatusCode;
2929
use warp::{reply::Response, Rejection, Reply};

beacon_node/network/src/sync/block_sidecar_coupling.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use beacon_chain::{
22
block_verification_types::RpcBlock, data_column_verification::CustodyDataColumn, get_block_root,
33
};
44
use lighthouse_network::PeerId;
5-
use ssz_types::VariableList;
65
use std::{
76
collections::{HashMap, VecDeque},
87
sync::Arc,

beacon_node/network/src/sync/network_context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ use std::time::Duration;
3636
use tokio::sync::mpsc;
3737
use types::blob_sidecar::FixedBlobSidecarList;
3838
use types::{
39-
chain_spec, BlobSidecar, ChainSpec, ColumnIndex, DataColumnSidecar, DataColumnSidecarList,
40-
EthSpec, Hash256, SignedBeaconBlock, Slot,
39+
BlobSidecar, ColumnIndex, DataColumnSidecar, DataColumnSidecarList, EthSpec,
40+
Hash256, SignedBeaconBlock, Slot,
4141
};
4242

4343
pub mod custody;

beacon_node/store/src/hot_cold_store.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,19 +1673,16 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
16731673
// a plain vec since we don't know the length limit of the list without
16741674
// knowing the slot.
16751675
// The encoding of a VariableList is same as a regular vec.
1676-
let blobs = BlobSidecarVec::from_ssz_bytes(blobs_bytes)?;
1677-
let max_blobs_per_block = blobs
1676+
let blobs: Vec<Arc<BlobSidecar<E>>> = Vec::<_>::from_ssz_bytes(blobs_bytes)?;
1677+
let blobs = if let Some(max_blobs_per_block) = blobs
16781678
.first()
1679-
.map(|blob| {
1680-
self.spec
1681-
.max_blobs_per_block(blob.slot().epoch(E::slots_per_epoch()))
1682-
})
1683-
// This is the case where we have no blobs for the slot, doesn't matter what value we keep for max here
1684-
// TODO(pawan): double check that this is the case
1685-
// we could also potentially deal with just vecs in the db since we only add length validated sidecar
1686-
// lists to the db
1687-
.unwrap_or(6);
1688-
let blobs = BlobSidecarList::from_vec(blobs, max_blobs_per_block as usize);
1679+
.map(|blob| self.spec.max_blobs_per_block(blob.epoch()))
1680+
{
1681+
BlobSidecarList::from_vec(blobs, max_blobs_per_block as usize)
1682+
} else {
1683+
// This always implies that there were no blobs for this block_root
1684+
BlobSidecarList::empty_uninitialized()
1685+
};
16891686
self.block_cache
16901687
.lock()
16911688
.put_blobs(*block_root, blobs.clone());

consensus/types/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,7 @@ pub use crate::beacon_block_body::{
138138
pub use crate::beacon_block_header::BeaconBlockHeader;
139139
pub use crate::beacon_committee::{BeaconCommittee, OwnedBeaconCommittee};
140140
pub use crate::beacon_state::{Error as BeaconStateError, *};
141-
pub use crate::blob_sidecar::{
142-
BlobIdentifier, BlobSidecar, BlobSidecarList, BlobSidecarVec, BlobsList,
143-
};
141+
pub use crate::blob_sidecar::{BlobIdentifier, BlobSidecar, BlobSidecarList, BlobsList};
144142
pub use crate::bls_to_execution_change::BlsToExecutionChange;
145143
pub use crate::chain_spec::{ChainSpec, Config, Domain};
146144
pub use crate::checkpoint::Checkpoint;

0 commit comments

Comments
 (0)