Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable large_stack_frames lint #6343

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ lint:
cargo clippy --workspace --tests $(EXTRA_CLIPPY_OPTS) --features "$(TEST_FEATURES)" -- \
-D clippy::fn_to_numeric_cast_any \
-D clippy::manual_let_else \
-D clippy::large_stack_frames \
-D warnings \
-A clippy::derive_partial_eq_without_eq \
-A clippy::upper-case-acronyms \
Expand Down
12 changes: 8 additions & 4 deletions beacon_node/beacon_chain/src/kzg_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ fn ssz_blob_to_crypto_blob<E: EthSpec>(blob: &Blob<E>) -> Result<KzgBlob, KzgErr
KzgBlob::from_bytes(blob.as_ref()).map_err(Into::into)
}

fn ssz_blob_to_crypto_blob_boxed<E: EthSpec>(blob: &Blob<E>) -> Result<Box<KzgBlob>, KzgError> {
ssz_blob_to_crypto_blob::<E>(blob).map(Box::new)
}

/// Converts a cell ssz List object to an array to be used with the kzg
/// crypto library.
fn ssz_cell_to_crypto_cell<E: EthSpec>(cell: &Cell<E>) -> Result<KzgCellRef, KzgError> {
Expand All @@ -34,7 +38,7 @@ pub fn validate_blob<E: EthSpec>(
kzg_proof: KzgProof,
) -> Result<(), KzgError> {
let _timer = crate::metrics::start_timer(&crate::metrics::KZG_VERIFICATION_SINGLE_TIMES);
let kzg_blob = ssz_blob_to_crypto_blob::<E>(blob)?;
let kzg_blob = ssz_blob_to_crypto_blob_boxed::<E>(blob)?;
kzg.verify_blob_kzg_proof(&kzg_blob, kzg_commitment, kzg_proof)
}

Expand Down Expand Up @@ -104,7 +108,7 @@ pub fn compute_blob_kzg_proof<E: EthSpec>(
blob: &Blob<E>,
jimmygchen marked this conversation as resolved.
Show resolved Hide resolved
kzg_commitment: KzgCommitment,
) -> Result<KzgProof, KzgError> {
let kzg_blob = ssz_blob_to_crypto_blob::<E>(blob)?;
let kzg_blob = ssz_blob_to_crypto_blob_boxed::<E>(blob)?;
kzg.compute_blob_kzg_proof(&kzg_blob, kzg_commitment)
}

Expand All @@ -113,7 +117,7 @@ pub fn blob_to_kzg_commitment<E: EthSpec>(
kzg: &Kzg,
blob: &Blob<E>,
) -> Result<KzgCommitment, KzgError> {
let kzg_blob = ssz_blob_to_crypto_blob::<E>(blob)?;
let kzg_blob = ssz_blob_to_crypto_blob_boxed::<E>(blob)?;
kzg.blob_to_kzg_commitment(&kzg_blob)
}

Expand All @@ -124,7 +128,7 @@ pub fn compute_kzg_proof<E: EthSpec>(
z: Hash256,
) -> Result<(KzgProof, Hash256), KzgError> {
let z = z.0.into();
let kzg_blob = ssz_blob_to_crypto_blob::<E>(blob)?;
let kzg_blob = ssz_blob_to_crypto_blob_boxed::<E>(blob)?;
kzg.compute_kzg_proof(&kzg_blob, &z)
.map(|(proof, z)| (proof, Hash256::from_slice(&z.to_vec())))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,7 @@ mod test {
let kzg = load_kzg()?;
let (kzg_commitment, kzg_proof, blob) = load_test_blobs_bundle::<E>()?;
let kzg_blob = kzg::Blob::from_bytes(blob.as_ref())
.map(Box::new)
.map_err(|e| format!("Error converting blob to kzg blob: {e:?}"))?;
kzg.verify_blob_kzg_proof(&kzg_blob, kzg_commitment, kzg_proof)
.map_err(|e| format!("Invalid blobs bundle: {e:?}"))
Expand Down
1 change: 1 addition & 0 deletions beacon_node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use clap::{builder::ArgPredicate, crate_version, Arg, ArgAction, ArgGroup, Comma
use clap_utils::{get_color_style, FLAG_HEADER};
use strum::VariantNames;

#[allow(clippy::large_stack_frames)]
pub fn cli_app() -> Command {
Command::new("beacon_node")
.display_order(0)
Expand Down
1 change: 1 addition & 0 deletions testing/simulator/src/basic_sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const DENEB_FORK_EPOCH: u64 = 2;
const SUGGESTED_FEE_RECIPIENT: [u8; 20] =
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1];

#[allow(clippy::large_stack_frames)]
pub fn run_basic_sim(matches: &ArgMatches) -> Result<(), String> {
let node_count = matches
.get_one::<String>("nodes")
Expand Down
1 change: 1 addition & 0 deletions testing/state_transition_vectors/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/// - `mod tests`: runs all the test vectors locally.
macro_rules! vectors_and_tests {
($($name: ident, $test: expr),*) => {
#[allow(clippy::large_stack_frames)]
pub async fn vectors() -> Vec<TestVector> {
let mut vec = vec![];

Expand Down
2 changes: 2 additions & 0 deletions watch/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,7 @@ async fn chain_grows() {

#[cfg(unix)]
#[tokio::test]
#[allow(clippy::large_stack_frames)]
async fn chain_grows_with_metadata() {
let builder = TesterBuilder::new().await;

Expand Down Expand Up @@ -959,6 +960,7 @@ async fn chain_grows_with_metadata() {

#[cfg(unix)]
#[tokio::test]
#[allow(clippy::large_stack_frames)]
async fn chain_grows_with_metadata_and_multiple_skip_slots() {
let builder = TesterBuilder::new().await;

Expand Down
Loading