Harden get_validator_by_slot_band
#176
Annotations
21 warnings and 1 notice
|
called `unwrap` on `args.password` after checking its variant with `is_some`:
pow-migration/src/main.rs#L118
warning: called `unwrap` on `args.password` after checking its variant with `is_some`
--> pow-migration/src/main.rs:118:67
|
117 | let pow_client = if args.username.is_some() && args.password.is_some() {
| ----------------------- the check is happening here
118 | Client::new_with_credentials(url, args.username.unwrap(), args.password.unwrap())
| ^^^^^^^^^^^^^^^^^^^^^^
|
= help: try using `if let` or `match`
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.95.0/index.html#unnecessary_unwrap
|
|
called `unwrap` on `args.username` after checking its variant with `is_some`:
pow-migration/src/main.rs#L118
warning: called `unwrap` on `args.username` after checking its variant with `is_some`
--> pow-migration/src/main.rs:118:43
|
117 | let pow_client = if args.username.is_some() && args.password.is_some() {
| ----------------------- the check is happening here
118 | Client::new_with_credentials(url, args.username.unwrap(), args.password.unwrap())
| ^^^^^^^^^^^^^^^^^^^^^^
|
= help: try using `if let` or `match`
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.95.0/index.html#unnecessary_unwrap
= note: `#[warn(clippy::unnecessary_unwrap)]` on by default
|
|
consider using `sort_by_key`:
pow-migration/src/lib.rs#L133
warning: consider using `sort_by_key`
--> pow-migration/src/lib.rs:133:5
|
133 | txns.sort_by(|a, b| a.block_number.cmp(&b.block_number));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.95.0/index.html#unnecessary_sort_by
= note: `#[warn(clippy::unnecessary_sort_by)]` on by default
help: try
|
133 - txns.sort_by(|a, b| a.block_number.cmp(&b.block_number));
133 + txns.sort_by_key(|a| a.block_number);
|
|
|
this `if` can be collapsed into the outer `match`:
mempool/mempool-task/src/lib.rs#L160
warning: this `if` can be collapsed into the outer `match`
--> mempool/mempool-task/src/lib.rs:160:17
|
160 | / if self.consensus.is_ready_for_validation() {
161 | | self.mempool.update(new_chain, old_chain);
162 | | }
| |_________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.95.0/index.html#collapsible_match
help: collapse nested if block
|
158 ~ BlockchainEvent::Rebranched(old_chain, new_chain)
159 | // Mempool updates are only done once we are synced.
160 ~ if self.consensus.is_ready_for_validation() => {
161 | self.mempool.update(new_chain, old_chain);
162 ~ }
|
|
|
this `if` can be collapsed into the outer `match`:
mempool/mempool-task/src/lib.rs#L147
warning: this `if` can be collapsed into the outer `match`
--> mempool/mempool-task/src/lib.rs:147:17
|
147 | / if self.consensus.is_ready_for_validation() {
148 | | let block = self
149 | | .consensus
150 | | .blockchain
... |
155 | | self.mempool.update(&[(hash.clone(), block)], [].as_ref());
156 | | }
| |_________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.95.0/index.html#collapsible_match
help: collapse nested if block
|
145 ~ BlockchainEvent::Extended(hash)
146 | // Mempool updates are only done once we are synced.
147 ~ if self.consensus.is_ready_for_validation() => {
148 | let block = self
...
155 | self.mempool.update(&[(hash.clone(), block)], [].as_ref());
156 ~ }
|
|
|
this `if` can be collapsed into the outer `match`:
mempool/mempool-task/src/lib.rs#L140
warning: this `if` can be collapsed into the outer `match`
--> mempool/mempool-task/src/lib.rs:140:17
|
140 | / if self.consensus.is_ready_for_validation() {
141 | | self.mempool.cleanup();
142 | | debug!("Performed a mempool clean up because new history was adopted");
143 | | }
| |_________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.95.0/index.html#collapsible_match
= note: `#[warn(clippy::collapsible_match)]` on by default
help: collapse nested if block
|
138 ~ BlockchainEvent::HistoryAdopted(_)
139 | // Mempool updates are only done once we are synced.
140 ~ if self.consensus.is_ready_for_validation() => {
141 | self.mempool.cleanup();
142 | debug!("Performed a mempool clean up because new history was adopted");
143 ~ }
|
|
|
called `unwrap` on `self.validity_requests` after checking its variant with `is_some`:
consensus/src/sync/light/validity_window.rs#L158
warning: called `unwrap` on `self.validity_requests` after checking its variant with `is_some`
--> consensus/src/sync/light/validity_window.rs:158:33
|
156 | if self.validity_requests.is_some() {
| ----------------------------------- help: try: `if let Some(<item>) = &self.validity_requests`
157 | // We already have a synchoronization in progress, so we just add the peer
158 | let current_chunk = self.validity_requests.as_ref().unwrap().chunk_index;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.95.0/index.html#unnecessary_unwrap
= note: `#[warn(clippy::unnecessary_unwrap)]` on by default
|
|
this `if` can be collapsed into the outer `match`:
consensus/src/consensus/mod.rs#L529
warning: this `if` can be collapsed into the outer `match`
--> consensus/src/consensus/mod.rs:529:17
|
529 | / if self.zkp_proxy.get_zkp_state().latest_block.block_number()
530 | | < Policy::election_block_before(
531 | | self.blockchain.read().election_head().block_number(),
... |
535 | | .request_zkp_from_peers(self.sync.peers(), false);
536 | | }
| |_________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.95.0/index.html#collapsible_match
= note: `#[warn(clippy::collapsible_match)]` on by default
help: collapse nested if block
|
526 ~ SyncerProxy::History(_)
527 | // Only request a proof when we are too far from the last election head.
...
532 | )
533 ~ => {
534 | self.zkp_proxy
535 | .request_zkp_from_peers(self.sync.peers(), false);
536 ~ }
|
|
|
called `unwrap` on `self.pre_genesis` after checking its variant with `is_some`:
blockchain/src/history/merged_history_store.rs#L392
warning: called `unwrap` on `self.pre_genesis` after checking its variant with `is_some`
--> blockchain/src/history/merged_history_store.rs:392:13
|
389 | if epoch_number == 0 && self.pre_genesis.is_some() {
| -------------------------- the check is happening here
...
392 | / self.pre_genesis
393 | | .as_ref()
394 | | .unwrap()
| |_________________________^
|
= help: try using `if let` or `match`
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.95.0/index.html#unnecessary_unwrap
|
|
called `unwrap` on `self.pre_genesis` after checking its variant with `is_some`:
blockchain/src/history/merged_history_store.rs#L369
warning: called `unwrap` on `self.pre_genesis` after checking its variant with `is_some`
--> blockchain/src/history/merged_history_store.rs:369:17
|
363 | if tx_hashes.len() < max as usize && self.pre_genesis.is_some() {
| -------------------------- the check is happening here
...
369 | self.pre_genesis.as_ref().unwrap().get_tx_hashes_by_address(
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: try using `if let` or `match`
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.95.0/index.html#unnecessary_unwrap
|
|
called `unwrap` on `self.pre_genesis` after checking its variant with `is_some`:
blockchain/src/history/merged_history_store.rs#L80
warning: called `unwrap` on `self.pre_genesis` after checking its variant with `is_some`
--> blockchain/src/history/merged_history_store.rs:80:13
|
77 | if Policy::epoch_at(block_number) == 0 && self.pre_genesis.is_some() {
| -------------------------- the check is happening here
...
80 | / self.pre_genesis
81 | | .as_ref()
82 | | .unwrap()
| |_________________________^
|
= help: try using `if let` or `match`
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.95.0/index.html#unnecessary_unwrap
= note: `#[warn(clippy::unnecessary_unwrap)]` on by default
|
|
the variable `idx` is used as a loop counter:
zkp-circuits/src/gadgets/compressed_vk.rs#L156
warning: the variable `idx` is used as a loop counter
--> zkp-circuits/src/gadgets/compressed_vk.rs:156:13
|
156 | for elem in gamma_abc_g1.iter() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `for (idx, elem) in (4..).zip(gamma_abc_g1.iter())`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.95.0/index.html#explicit_counter_loop
|
|
the variable `idx` is used as a loop counter:
zkp-circuits/src/gadgets/compressed_vk.rs#L82
warning: the variable `idx` is used as a loop counter
--> zkp-circuits/src/gadgets/compressed_vk.rs:82:13
|
82 | for elem in gamma_abc_g1.iter() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `for (idx, elem) in (4..).zip(gamma_abc_g1.iter())`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.95.0/index.html#explicit_counter_loop
= note: `#[warn(clippy::explicit_counter_loop)]` on by default
|
|
iterating on a map's keys:
primitives/account/src/account/staking_contract/mod.rs#L255
warning: iterating on a map's keys
--> primitives/account/src/account/staking_contract/mod.rs:255:47
|
255 | let unsupporting_validators: Vec<_> = self
| _______________________________________________^
256 | | .active_validators
257 | | .iter()
258 | | .filter_map(|(validator_address, _stake)| {
... |
267 | | })
| |______________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.95.0/index.html#iter_kv_map
= note: `#[warn(clippy::iter_kv_map)]` on by default
help: try
|
255 ~ let unsupporting_validators: Vec<_> = self
256 + .active_validators.keys().filter_map(|validator_address| {
257 + let validator = store
258 + .get_validator(validator_address)
259 + .expect("Active Validators must be present in the Staking Contract.");
260 + if !support_check(validator.signal_data) {
261 + Some((validator.address, Address::from(&validator.signing_key)))
262 + } else {
263 + None
264 + }
265 + })
|
|
|
iterating on a map's keys:
primitives/account/src/account/staking_contract/mod.rs#L255
warning: iterating on a map's keys
--> primitives/account/src/account/staking_contract/mod.rs:255:47
|
255 | let unsupporting_validators: Vec<_> = self
| _______________________________________________^
256 | | .active_validators
257 | | .iter()
258 | | .filter_map(|(validator_address, _stake)| {
... |
267 | | })
| |______________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.95.0/index.html#iter_kv_map
= note: `#[warn(clippy::iter_kv_map)]` on by default
help: try
|
255 ~ let unsupporting_validators: Vec<_> = self
256 + .active_validators.keys().filter_map(|validator_address| {
257 + let validator = store
258 + .get_validator(validator_address)
259 + .expect("Active Validators must be present in the Staking Contract.");
260 + if !support_check(validator.signal_data) {
261 + Some((validator.address, Address::from(&validator.signing_key)))
262 + } else {
263 + None
264 + }
265 + })
|
|
|
iterating on a map's values:
network-libp2p/src/discovery/peer_contacts.rs#L530
warning: iterating on a map's values
--> network-libp2p/src/discovery/peer_contacts.rs:530:9
|
530 | / self.peer_contacts.iter().filter_map(move |(_, contact)| {
531 | | if contact.matches(services) {
532 | | Some(Arc::clone(contact))
533 | | } else {
... |
536 | | })
| |__________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.95.0/index.html#iter_kv_map
= note: `#[warn(clippy::iter_kv_map)]` on by default
help: try
|
530 ~ self.peer_contacts.values().filter_map(|contact| {
531 + if contact.matches(services) {
532 + Some(Arc::clone(contact))
533 + } else {
534 + None
535 + }
536 + })
|
|
|
this `if` can be collapsed into the outer `match`:
network-libp2p/src/discovery/behaviour.rs#L257
warning: this `if` can be collapsed into the outer `match`
--> network-libp2p/src/discovery/behaviour.rs:257:17
|
257 | / if other_established == 0 {
258 | | // This is the first connection to this peer
259 | | self.connected_peers.insert(peer_id);
260 | | }
| |_________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.95.0/index.html#collapsible_match
help: collapse nested if block
|
256 ~ })
257 ~ if other_established == 0 => {
258 | // This is the first connection to this peer
259 | self.connected_peers.insert(peer_id);
260 ~ }
|
|
|
this `if` can be collapsed into the outer `match`:
network-libp2p/src/discovery/behaviour.rs#L247
warning: this `if` can be collapsed into the outer `match`
--> network-libp2p/src/discovery/behaviour.rs:247:17
|
247 | / if remaining_established == 0 {
248 | | // There are no more remaining connections to this peer
249 | | self.connected_peers.remove(&peer_id);
250 | | }
| |_________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.95.0/index.html#collapsible_match
= note: `#[warn(clippy::collapsible_match)]` on by default
help: collapse nested if block
|
246 ~ })
247 ~ if remaining_established == 0 => {
248 | // There are no more remaining connections to this peer
249 | self.connected_peers.remove(&peer_id);
250 ~ }
|
|
|
called `unwrap` on `signature_proof.webauthn_fields` after checking its variant with `is_some`:
primitives/transaction/src/lib.rs#L733
warning: called `unwrap` on `signature_proof.webauthn_fields` after checking its variant with `is_some`
--> primitives/transaction/src/lib.rs:733:29
|
730 | if signature_proof.webauthn_fields.is_some() {
| -------------------------------------------- help: try: `if let Some(<item>) = &signature_proof.webauthn_fields`
...
733 | signature_proof.webauthn_fields.as_ref().unwrap(),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.95.0/index.html#unnecessary_unwrap
|
|
called `unwrap` on `self.webauthn_fields` after checking its variant with `is_some`:
primitives/transaction/src/signature_proof.rs#L452
warning: called `unwrap` on `self.webauthn_fields` after checking its variant with `is_some`
--> primitives/transaction/src/signature_proof.rs:452:50
|
451 | if self.webauthn_fields.is_some() {
| --------------------------------- help: try: `if let Some(<item>) = &self.webauthn_fields`
452 | state.serialize_field(FIELDS[4], self.webauthn_fields.as_ref().unwrap())?;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.95.0/index.html#unnecessary_unwrap
= note: `#[warn(clippy::unnecessary_unwrap)]` on by default
|
|
called `unwrap` on `self.webauthn_fields` after checking its variant with `is_some`:
primitives/transaction/src/signature_proof.rs#L452
warning: called `unwrap` on `self.webauthn_fields` after checking its variant with `is_some`
--> primitives/transaction/src/signature_proof.rs:452:50
|
451 | if self.webauthn_fields.is_some() {
| --------------------------------- help: try: `if let Some(<item>) = &self.webauthn_fields`
452 | state.serialize_field(FIELDS[4], self.webauthn_fields.as_ref().unwrap())?;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.95.0/index.html#unnecessary_unwrap
= note: `#[warn(clippy::unnecessary_unwrap)]` on by default
|
|
preview
{
"workflowData": {
"owner": "nimiq",
"repo": "core-rs-albatross",
"sha": "fc367b027226ab0ea92dee0d6014c4b80af400c7",
"ref": "3720"
},
"key": "BnGo8TPQ4b",
"runId": 24775563350,
"webhookDebug": {
"action": "requested",
"head_branch": "nibhar/harden_validator_by_slot_band",
"head_repository_full_name": "nimiq/core-rs-albatross",
"full_name": "nimiq/core-rs-albatross",
"isPullRequest": true,
"prNumber": 3720,
"prNumberType": "number",
"isNewPullRequest": true,
"isOldPullRequest": false,
"prKey": "nimiq/core-rs-albatross:nibhar/harden_validator_by_slot_band",
"oldPrDataHash": "EsYQ7EJQ3p",
"lookupKey": "nimiq/core-rs-albatross:nibhar/harden_validator_by_slot_band",
"data": {
"owner": "nimiq",
"repo": "core-rs-albatross",
"sha": "fc367b027226ab0ea92dee0d6014c4b80af400c7",
"ref": "3720"
}
}
}
|