Skip to content
This repository has been archived by the owner on Dec 3, 2024. It is now read-only.

Testing Builder core logic #23

Testing Builder core logic

Testing Builder core logic #23

GitHub Actions / clippy failed Feb 15, 2024 in 1s

clippy

84 errors

Details

Results

Message level Amount
Internal compiler error 0
Error 84
Warning 0
Note 0
Help 0

Versions

  • rustc 1.76.0 (07dca489a 2024-02-04)
  • cargo 1.76.0 (c84b36747 2024-01-18)
  • clippy 0.1.76 (07dca48 2024-02-04)

Annotations

Check failure on line 439 in src/testing/basic_test.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

casting to the same type is unnecessary (`usize` -> `usize`)

error: casting to the same type is unnecessary (`usize` -> `usize`)
   --> src/testing/basic_test.rs:439:37
    |
439 |         assert_eq!(rres_msgs.len(), (num_test_messages - 1) as usize);
    |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `{ (num_test_messages - 1) }`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast

Check failure on line 386 in src/testing/basic_test.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

casting integer literal to `u64` is unnecessary

error: casting integer literal to `u64` is unnecessary
   --> src/testing/basic_test.rs:386:58
    |
386 |             BLSPubKey::generated_from_seed_indexed(seed, 2011 as u64);
    |                                                          ^^^^^^^^^^^ help: try: `2011_u64`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast

Check failure on line 384 in src/testing/basic_test.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

casting integer literal to `u8` is unnecessary

error: casting integer literal to `u8` is unnecessary
   --> src/testing/basic_test.rs:384:21
    |
384 |         let seed = [201 as u8; 32];
    |                     ^^^^^^^^^ help: try: `201_u8`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
    = note: `-D clippy::unnecessary-cast` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::unnecessary_cast)]`

Check failure on line 219 in src/testing/basic_test.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

using `clone` on type `ViewNumber` which implements the `Copy` trait

error: using `clone` on type `ViewNumber` which implements the `Copy` trait
   --> src/testing/basic_test.rs:219:38
    |
219 |                         view_number: sqc_msgs[(i - 1) as usize].proposal.data.view_number.clone(),
    |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try removing the `clone` call: `sqc_msgs[(i - 1) as usize].proposal.data.view_number`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy

Check failure on line 262 in src/testing/basic_test.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

returning the result of a `let` binding from a block

error: returning the result of a `let` binding from a block
   --> src/testing/basic_test.rs:262:21
    |
253 | /                     let justify_qc =
254 | |                         SimpleCertificate::<TestTypes, QuorumData<TestTypes>, SuccessThreshold> {
255 | |                             data: q_data.clone(),
256 | |                             vote_commitment: q_data.commit(),
...   |
260 | |                             _pd: PhantomData,
261 | |                         };
    | |__________________________- unnecessary `let` binding
262 |                       justify_qc
    |                       ^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_and_return
    = note: `-D clippy::let-and-return` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::let_and_return)]`
help: return the expression directly
    |
253 ~                     
254 ~                     SimpleCertificate::<TestTypes, QuorumData<TestTypes>, SuccessThreshold> {
255 +                             data: q_data.clone(),
256 +                             vote_commitment: q_data.commit(),
257 +                             view_number: view_number,
258 +                             signatures: previous_justify_qc.signatures.clone(),
259 +                             is_genesis: true, // todo setting true because we don't have signatures of QCType
260 +                             _pd: PhantomData,
261 +                         }
    |

Check failure on line 111 in src/service.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

using `clone` on type `HasherNode<CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, OidSha256>>>` which implements the `Copy` trait

error: using `clone` on type `HasherNode<CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, OidSha256>>>` which implements the `Copy` trait
   --> src/service.rs:111:39
    |
111 |             requested_vid_commitment: for_parent.clone(),
    |                                       ^^^^^^^^^^^^^^^^^^ help: try dereferencing it: `*for_parent`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy

Check failure on line 70 in src/service.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

very complex type used. Consider factoring parts into `type` definitions

error: very complex type used. Consider factoring parts into `type` definitions
  --> src/service.rs:61:30
   |
61 |       pub block_hash_to_block: HashMap<
   |  ______________________________^
62 | |         BuilderCommitment,
63 | |         (
64 | |             Types::BlockPayload,
...  |
69 | |         ),
70 | |     >,
   | |_____^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity
   = note: `-D clippy::type-complexity` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(clippy::type_complexity)]`

Check failure on line 768 in src/builder_state.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this function has too many arguments (10/7)

error: this function has too many arguments (10/7)
   --> src/builder_state.rs:754:5
    |
754 | /     pub fn new(
755 | |         builder_keys: (
756 | |             TYPES::SignatureKey,
757 | |             <<TYPES as BuilderType>::SignatureKey as SignatureKey>::PrivateKey,
...   |
767 | |         quorum_membership: Arc<TYPES::Membership>,
768 | |     ) -> Self {
    | |_____________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
    = note: `-D clippy::too-many-arguments` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::too_many_arguments)]`

Check failure on line 111 in src/service.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

using `clone` on type `HasherNode<CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, OidSha256>>>` which implements the `Copy` trait

error: using `clone` on type `HasherNode<CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, OidSha256>>>` which implements the `Copy` trait
   --> src/service.rs:111:39
    |
111 |             requested_vid_commitment: for_parent.clone(),
    |                                       ^^^^^^^^^^^^^^^^^^ help: try dereferencing it: `*for_parent`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy

Check failure on line 70 in src/service.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

very complex type used. Consider factoring parts into `type` definitions

error: very complex type used. Consider factoring parts into `type` definitions
  --> src/service.rs:61:30
   |
61 |       pub block_hash_to_block: HashMap<
   |  ______________________________^
62 | |         BuilderCommitment,
63 | |         (
64 | |             Types::BlockPayload,
...  |
69 | |         ),
70 | |     >,
   | |_____^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity
   = note: `-D clippy::type-complexity` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(clippy::type_complexity)]`

Check failure on line 768 in src/builder_state.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this function has too many arguments (10/7)

error: this function has too many arguments (10/7)
   --> src/builder_state.rs:754:5
    |
754 | /     pub fn new(
755 | |         builder_keys: (
756 | |             TYPES::SignatureKey,
757 | |             <<TYPES as BuilderType>::SignatureKey as SignatureKey>::PrivateKey,
...   |
767 | |         quorum_membership: Arc<TYPES::Membership>,
768 | |     ) -> Self {
    | |_____________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
    = note: `-D clippy::too-many-arguments` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::too_many_arguments)]`

Check failure on line 538 in src/builder_state.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

useless conversion to the same type: `<<TYPES as hotshot_types::traits::node_implementation::NodeType>::BlockPayload as hotshot_types::traits::BlockPayload>::Encode<'_>`

error: useless conversion to the same type: `<<TYPES as hotshot_types::traits::node_implementation::NodeType>::BlockPayload as hotshot_types::traits::BlockPayload>::Encode<'_>`
   --> src/builder_state.rs:538:41
    |
538 |             let encoded_txns: Vec<u8> = payload.encode().unwrap().into_iter().collect();
    |                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `payload.encode().unwrap()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
    = note: `-D clippy::useless-conversion` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::useless_conversion)]`

Check failure on line 460 in src/builder_state.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

error: this expression creates a reference which is immediately dereferenced by the compiler
   --> src/builder_state.rs:460:67
    |
460 | ...                   self.tx_hash_to_available_txns.remove(&tx_hash);
    |                                                             ^^^^^^^^ help: change this to: `tx_hash`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Check failure on line 455 in src/builder_state.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

error: this expression creates a reference which is immediately dereferenced by the compiler
   --> src/builder_state.rs:455:64
    |
455 | ...                   self.tx_hash_to_available_txns.get(&tx_hash)
    |                                                          ^^^^^^^^ help: change this to: `tx_hash`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Check failure on line 449 in src/builder_state.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

error: this expression creates a reference which is immediately dereferenced by the compiler
   --> src/builder_state.rs:449:90
    |
449 |                     let transactions_commitments = block_payload.transaction_commitments(&metadata);
    |                                                                                          ^^^^^^^^^ help: change this to: `metadata`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
    = note: `-D clippy::needless-borrow` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::needless_borrow)]`

Check failure on line 538 in src/builder_state.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

useless conversion to the same type: `<<TYPES as hotshot_types::traits::node_implementation::NodeType>::BlockPayload as hotshot_types::traits::BlockPayload>::Encode<'_>`

error: useless conversion to the same type: `<<TYPES as hotshot_types::traits::node_implementation::NodeType>::BlockPayload as hotshot_types::traits::BlockPayload>::Encode<'_>`
   --> src/builder_state.rs:538:41
    |
538 |             let encoded_txns: Vec<u8> = payload.encode().unwrap().into_iter().collect();
    |                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `payload.encode().unwrap()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
    = note: `-D clippy::useless-conversion` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::useless_conversion)]`

Check failure on line 380 in src/builder_state.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

using `clone` on type `HasherNode<CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, OidSha256>>>` which implements the `Copy` trait

error: using `clone` on type `HasherNode<CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, OidSha256>>>` which implements the `Copy` trait
   --> src/builder_state.rs:380:24
    |
380 |                 .entry(payload_vid_commitment.clone())
    |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try removing the `clone` call: `payload_vid_commitment`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy

Check failure on line 398 in src/builder_state.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

usage of `contains_key` followed by `insert` on a `HashMap`

error: usage of `contains_key` followed by `insert` on a `HashMap`
   --> src/builder_state.rs:373:9
    |
373 | /         if !self
374 | |             .quorum_proposal_payload_commit_to_quorum_proposal
375 | |             .contains_key(&payload_vid_commitment)
376 | |         {
...   |
397 | |             }
398 | |         }
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_entry
help: try
    |
373 ~         if let std::collections::hash_map::Entry::Vacant(e) = self
374 +             .quorum_proposal_payload_commit_to_quorum_proposal.entry(payload_vid_commitment) {
375 +             // if we have matching da and quorum proposals, we can skip storing the one, and remove the other from storage, and call build_block with both, to save a little space.
376 +             if let Entry::Occupied(da_proposal_data) = self
377 +                 .da_proposal_payload_commit_to_da_proposal
378 +                 .entry(payload_vid_commitment.clone())
379 +             {
380 +                 let da_proposal_data = da_proposal_data.remove();
381 + 
382 +                 // make sure we don't clone for the bootstrapping da and qc proposals
383 +                 if da_proposal_data.view_number.get_u64() != 0 {
384 +                     tracing::info!("Spawning a clone");
385 +                     self.clone()
386 +                         .spawn_clone(da_proposal_data, qc_proposal_data, sender);
387 +                     // registed the clone to the global state
388 +                     //self.global_state.get_mut().vid_to_potential_builder_state.insert(payload_vid_commitment, self_clone);
389 +                 } else {
390 +                     tracing::info!("Not spawning a clone despite matching DA and QC proposals, as they corresponds to bootstrapping phase");
391 +                 }
392 +             } else {
393 +                 e.insert(qc_proposal_data.clone());
394 +             }
395 +         }
    |

Check failure on line 460 in src/builder_state.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

error: this expression creates a reference which is immediately dereferenced by the compiler
   --> src/builder_state.rs:460:67
    |
460 | ...                   self.tx_hash_to_available_txns.remove(&tx_hash);
    |                                                             ^^^^^^^^ help: change this to: `tx_hash`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Check failure on line 455 in src/builder_state.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

error: this expression creates a reference which is immediately dereferenced by the compiler
   --> src/builder_state.rs:455:64
    |
455 | ...                   self.tx_hash_to_available_txns.get(&tx_hash)
    |                                                          ^^^^^^^^ help: change this to: `tx_hash`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Check failure on line 449 in src/builder_state.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

error: this expression creates a reference which is immediately dereferenced by the compiler
   --> src/builder_state.rs:449:90
    |
449 |                     let transactions_commitments = block_payload.transaction_commitments(&metadata);
    |                                                                                          ^^^^^^^^^ help: change this to: `metadata`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
    = note: `-D clippy::needless-borrow` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::needless_borrow)]`

Check failure on line 380 in src/builder_state.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

using `clone` on type `HasherNode<CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, OidSha256>>>` which implements the `Copy` trait

error: using `clone` on type `HasherNode<CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, OidSha256>>>` which implements the `Copy` trait
   --> src/builder_state.rs:380:24
    |
380 |                 .entry(payload_vid_commitment.clone())
    |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try removing the `clone` call: `payload_vid_commitment`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy

Check failure on line 318 in src/builder_state.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

using `clone` on type `HasherNode<CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, OidSha256>>>` which implements the `Copy` trait

error: using `clone` on type `HasherNode<CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, OidSha256>>>` which implements the `Copy` trait
   --> src/builder_state.rs:318:24
    |
318 |                 .entry(payload_vid_commitment.clone())
    |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try removing the `clone` call: `payload_vid_commitment`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy

Check failure on line 398 in src/builder_state.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

usage of `contains_key` followed by `insert` on a `HashMap`

error: usage of `contains_key` followed by `insert` on a `HashMap`
   --> src/builder_state.rs:373:9
    |
373 | /         if !self
374 | |             .quorum_proposal_payload_commit_to_quorum_proposal
375 | |             .contains_key(&payload_vid_commitment)
376 | |         {
...   |
397 | |             }
398 | |         }
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_entry
help: try
    |
373 ~         if let std::collections::hash_map::Entry::Vacant(e) = self
374 +             .quorum_proposal_payload_commit_to_quorum_proposal.entry(payload_vid_commitment) {
375 +             // if we have matching da and quorum proposals, we can skip storing the one, and remove the other from storage, and call build_block with both, to save a little space.
376 +             if let Entry::Occupied(da_proposal_data) = self
377 +                 .da_proposal_payload_commit_to_da_proposal
378 +                 .entry(payload_vid_commitment.clone())
379 +             {
380 +                 let da_proposal_data = da_proposal_data.remove();
381 + 
382 +                 // make sure we don't clone for the bootstrapping da and qc proposals
383 +                 if da_proposal_data.view_number.get_u64() != 0 {
384 +                     tracing::info!("Spawning a clone");
385 +                     self.clone()
386 +                         .spawn_clone(da_proposal_data, qc_proposal_data, sender);
387 +                     // registed the clone to the global state
388 +                     //self.global_state.get_mut().vid_to_potential_builder_state.insert(payload_vid_commitment, self_clone);
389 +                 } else {
390 +                     tracing::info!("Not spawning a clone despite matching DA and QC proposals, as they corresponds to bootstrapping phase");
391 +                 }
392 +             } else {
393 +                 e.insert(qc_proposal_data.clone());
394 +             }
395 +         }
    |

Check failure on line 336 in src/builder_state.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

usage of `contains_key` followed by `insert` on a `HashMap`

error: usage of `contains_key` followed by `insert` on a `HashMap`
   --> src/builder_state.rs:305:9
    |
305 | /         if !self
306 | |             .da_proposal_payload_commit_to_da_proposal
307 | |             .contains_key(&payload_vid_commitment)
308 | |         {
...   |
335 | |             }
336 | |         }
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_entry
    = note: `-D clippy::map-entry` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::map_entry)]`
help: try
    |
305 ~         if let std::collections::hash_map::Entry::Vacant(e) = self
306 +             .da_proposal_payload_commit_to_da_proposal.entry(payload_vid_commitment) {
307 +             let da_proposal_data = DAProposal {
308 +                 encoded_transactions: encoded_txns.clone(),
309 +                 metadata: metadata.clone(),
310 +                 view_number: view_number,
311 +             };
312 + 
313 +             // if we have matching da and quorum proposals, we can skip storing the one, and remove the other from storage, and call build_block with both, to save a little space.
314 +             if let Entry::Occupied(qc_proposal_data) = self
315 +                 .quorum_proposal_payload_commit_to_quorum_proposal
316 +                 .entry(payload_vid_commitment.clone())
317 +             {
318 +                 let qc_proposal_data = qc_proposal_data.remove();
319 + 
320 +                 // make sure we don't clone for the bootstrapping da and qc proposals
321 +                 if qc_proposal_data.view_number.get_u64() != 0 {
322 +                     tracing::info!("Spawning a clone");
323 +                     self.clone()
324 +                         .spawn_clone(da_proposal_data, qc_proposal_data, sender);
325 +                     // register the clone to the global state
326 +                     //self.global_state.get_mut().vid_to_potential_builder_state.insert(payload_vid_commitment, self_clone);
327 +                 } else {
328 +                     tracing::info!("Not spawning a clone despite matching DA and QC proposals, as they corresponds to bootstrapping phase");
329 +                 }
330 +             } else {
331 +                 e.insert(da_proposal_data);
332 +             }
333 +         }
    |