Add workspace lints

This commit is contained in:
Luke Parker
2023-12-16 20:54:24 -05:00
parent c40ce00955
commit ea3af28139
122 changed files with 329 additions and 128 deletions

View File

@@ -7,6 +7,13 @@ repository = "https://github.com/serai-dex/serai/tree/develop/coordinator/tribut
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
edition = "2021"
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
[lints]
workspace = true
[dependencies]
async-trait = { version = "0.1", default-features = false }
thiserror = { version = "1", default-features = false }

View File

@@ -207,7 +207,7 @@ impl<T: TransactionTrait> Block<T> {
let mut last_tx_order = Order::Provided;
let mut included_in_block = HashSet::new();
let mut txs = Vec::with_capacity(self.transactions.len());
for tx in self.transactions.iter() {
for tx in &self.transactions {
let tx_hash = tx.hash();
txs.push(tx_hash);

View File

@@ -73,7 +73,7 @@ impl<D: Db, T: TransactionTrait> Blockchain<D, T> {
let mut res = Self {
db: Some(db.clone()),
genesis,
participants: participants.iter().cloned().collect(),
participants: participants.iter().copied().collect(),
block_number: 0,
tip: genesis,

View File

@@ -38,7 +38,6 @@ impl<D: Db, T: TransactionTrait> Mempool<D, T> {
let tx_hash = tx.hash();
let transaction_key = self.transaction_key(&tx_hash);
let current_mempool_key = self.current_mempool_key();
#[allow(clippy::unwrap_or_default)]
let mut current_mempool = self.db.get(&current_mempool_key).unwrap_or(vec![]);
let mut txn = self.db.txn();
@@ -182,14 +181,14 @@ impl<D: Db, T: TransactionTrait> Mempool<D, T> {
signer: &<Ristretto as Ciphersuite>::G,
order: Vec<u8>,
) -> Option<u32> {
self.last_nonce_in_mempool.get(&(*signer, order)).cloned().map(|nonce| nonce + 1)
self.last_nonce_in_mempool.get(&(*signer, order)).copied().map(|nonce| nonce + 1)
}
/// Get transactions to include in a block.
pub(crate) fn block(&mut self) -> Vec<Transaction<T>> {
let mut unsigned = vec![];
let mut signed = vec![];
for hash in self.txs.keys().cloned().collect::<Vec<_>>() {
for hash in self.txs.keys().copied().collect::<Vec<_>>() {
let tx = &self.txs[&hash];
match tx.kind() {
@@ -222,7 +221,6 @@ impl<D: Db, T: TransactionTrait> Mempool<D, T> {
pub(crate) fn remove(&mut self, tx: &[u8; 32]) {
let transaction_key = self.transaction_key(tx);
let current_mempool_key = self.current_mempool_key();
#[allow(clippy::unwrap_or_default)]
let current_mempool = self.db.get(&current_mempool_key).unwrap_or(vec![]);
let mut i = 0;

View File

@@ -136,7 +136,6 @@ impl<D: Db, T: Transaction> ProvidedTransactions<D, T> {
}
txn.commit();
} else {
#[allow(clippy::unwrap_or_default)]
let mut currently_provided = txn.get(&current_provided_key).unwrap_or(vec![]);
currently_provided.extend(tx_hash);
txn.put(current_provided_key, currently_provided);

View File

@@ -7,6 +7,13 @@ repository = "https://github.com/serai-dex/serai/tree/develop/coordinator/tender
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
edition = "2021"
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
[lints]
workspace = true
[dependencies]
async-trait = { version = "0.1", default-features = false }
thiserror = { version = "1", default-features = false }

View File

@@ -30,7 +30,7 @@ pub mod ext;
use ext::*;
pub fn commit_msg(end_time: u64, id: &[u8]) -> Vec<u8> {
[&end_time.to_le_bytes(), id].concat().to_vec()
[&end_time.to_le_bytes(), id].concat()
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Encode, Decode)]
@@ -398,7 +398,7 @@ impl<N: Network + 'static> TendermintMachine<N> {
},
// Handle our messages
_ = queue_future => {
() = queue_future => {
Some((true, self.queue.pop_front().unwrap(), None))
},
@@ -752,7 +752,7 @@ impl<N: Network + 'static> TendermintMachine<N> {
if self.block.round().step == Step::Propose {
// Delay error handling (triggering a slash) until after we vote.
let (valid, err) = match self.network.validate(block).await {
Ok(_) => (true, Ok(None)),
Ok(()) => (true, Ok(None)),
Err(BlockError::Temporal) => (false, Ok(None)),
Err(BlockError::Fatal) => (false, {
log::warn!(target: "tendermint", "Validator proposed a fatally invalid block");
@@ -812,7 +812,7 @@ impl<N: Network + 'static> TendermintMachine<N> {
if self.block.log.has_consensus(self.block.round().number, Data::Prevote(Some(block.id()))) {
match self.network.validate(block).await {
Ok(_) => (),
Ok(()) => (),
// BlockError::Temporal is due to a temporal error we have, yet a supermajority of the
// network does not, Because we do not believe this block to be fatally invalid, and
// because a supermajority deems it valid, accept it.

View File

@@ -21,9 +21,7 @@ impl<N: Network> MessageLog<N> {
pub(crate) fn log(&mut self, signed: SignedMessageFor<N>) -> Result<bool, TendermintError<N>> {
let msg = &signed.msg;
// Clarity, and safety around default != new edge cases
#[allow(clippy::unwrap_or_default)]
let round = self.log.entry(msg.round).or_insert_with(HashMap::new);
#[allow(clippy::unwrap_or_default)]
let msgs = round.entry(msg.sender).or_insert_with(HashMap::new);
// Handle message replays without issue. It's only multiple messages which is malicious