Skip to content

Commit

Permalink
Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
grarco committed Jan 12, 2023
1 parent f4325fb commit b2a4067
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 36 deletions.
6 changes: 3 additions & 3 deletions apps/src/lib/node/ledger/shell/finalize_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ mod test_finalize_block {
let tx_code = std::fs::read(wasm_path)
.expect("Expected a file at given code path");
let raw_tx = Tx::new(
tx_code.clone(),
tx_code,
Some("Encrypted transaction data".as_bytes().to_owned()),
);
let wrapper_tx = WrapperTx::new(
Expand All @@ -847,7 +847,7 @@ mod test_finalize_block {

let processed_tx = ProcessedTx {
tx: Tx::from(TxType::Decrypted(DecryptedTx::Decrypted {
tx: raw_tx.clone(),
tx: raw_tx,
#[cfg(not(feature = "mainnet"))]
has_valid_pow: false,
}))
Expand All @@ -866,7 +866,7 @@ mod test_finalize_block {
})
.expect("Test failed")[0];

// FIXME: @grarco, uncomment when proper gas metering is in place
// FIXME: uncomment when proper gas metering is in place
// // Check inner tx hash has been removed from storage
// assert_eq!(event.event_type.to_string(), String::from("applied"));
// let code = event.attributes.get("code").expect("Test
Expand Down
62 changes: 31 additions & 31 deletions apps/src/lib/node/ledger/shell/process_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ where
let tx_results = self.process_txs(&req.txs);

ProcessProposal {
status: if tx_results.iter().any(|res| match res.code {
1 | 2 | 4 | 5 | 7 => true,
_ => false,
}) {
status: if tx_results
.iter()
.any(|res| matches!(res.code, 1 | 2 | 4 | 5 | 7))
{
ProposalStatus::Reject as i32
} else {
ProposalStatus::Accept as i32
Expand Down Expand Up @@ -88,7 +88,7 @@ where
/// INVARIANT: Any changes applied in this method must be reverted if the
/// proposal is rejected (unless we can simply overwrite them in the
/// next block).
pub(crate) fn process_single_tx<'a>(
pub(crate) fn process_single_tx(
&mut self,
tx_bytes: &[u8],
tx_queue_index: &mut usize,
Expand Down Expand Up @@ -214,20 +214,20 @@ where
),
};
}
if let (Some(m), _) =
self.write_log.read(&inner_hash_key)
// Check in WAL for replay attack in the same block
if let (
Some(StorageModification::Write { value: _ }),
_,
) = self.write_log.read(&inner_hash_key)
{
// Check in WAL for replay attack in the same block
if let StorageModification::Write { value: _ } = m {
return TxResult {
code: ErrorCodes::ReplayTx.into(),
info: format!(
"Inner transaction hash {} already in \
storage, replay attempt",
&tx.tx_hash
),
};
}
return TxResult {
code: ErrorCodes::ReplayTx.into(),
info: format!(
"Inner transaction hash {} already in \
storage, replay attempt",
&tx.tx_hash
),
};
}

// Write inner hash to WAL
Expand Down Expand Up @@ -258,20 +258,20 @@ where
),
};
}
if let (Some(m), _) =
self.write_log.read(&wrapper_hash_key)
// Check in WAL for replay attack in the same block
if let (
Some(StorageModification::Write { value: _ }),
_,
) = self.write_log.read(&wrapper_hash_key)
{
// Check in WAL for replay attack in the same block
if let StorageModification::Write { value: _ } = m {
return TxResult {
code: ErrorCodes::ReplayTx.into(),
info: format!(
"Wrapper transaction hash {} already \
in storage, replay attempt",
wrapper_hash
),
};
}
return TxResult {
code: ErrorCodes::ReplayTx.into(),
info: format!(
"Wrapper transaction hash {} already in \
storage, replay attempt",
wrapper_hash
),
};
}

// Write wrapper hash to WAL
Expand Down
3 changes: 1 addition & 2 deletions shared/src/ledger/native_vp/replay_protection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,10 @@ where
}
}

#[allow(clippy::upper_case_acronyms)]
enum KeyType {
#[allow(clippy::upper_case_acronyms)]
#[allow(non_camel_case_types)]
TX_HASH,
#[allow(clippy::upper_case_acronyms)]
UNKNOWN,
}

Expand Down

0 comments on commit b2a4067

Please sign in to comment.