Skip to content
This repository was archived by the owner on Jun 24, 2024. It is now read-only.

imp: use workspace lints #114

Merged
merged 1 commit into from
Mar 29, 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
20 changes: 19 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ publish = false
authors = ["Informal Systems <[email protected]>"]
repository = "https://github.com/informalsystems/sovereign-ibc"

[workspace.lints.rust]
unsafe_code = "forbid"
dead_code = "deny"
rust_2018_idioms = "deny"
trivial_casts = "deny"
unused_import_braces = "deny"
unused_variables = "allow"

[workspace.lints.clippy]
debug_assert_with_mut_call = "deny"
doc_link_with_quotes = "deny"
inefficient_to_string = "deny"
map_flatten = "deny"
manual_ok_or = "deny"
match_same_arms = "deny"
semicolon_if_nothing_returned = "deny"
uninlined_format_args = "deny"

[workspace.dependencies]
# external dependencies
anyhow = "1.0.68"
Expand All @@ -44,7 +62,7 @@ serde_json = "1.0"
schemars = { version = "0.8.12", features = ["derive"] }
tempfile = "3.5"
thiserror = "1.0.38"
tracing = { version = "0.1.40", default-features = false }
tracing = { version = "0.1.40", default-features = false }

# ibc depedenencies
ibc-core = { version = "0.51.0", default-features = false, features = ["borsh","schema"] }
Expand Down
3 changes: 3 additions & 0 deletions clients/sov-celestia-cw/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ description = """
Contains the CosmWasm contract implementation of the `sov-celesita` light client.
"""

[lints]
workspace = true

[lib]
crate-type = ["cdylib", "rlib"]

Expand Down
3 changes: 3 additions & 0 deletions clients/sov-celestia/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ description = """
essential data structures and domain types from `ibc-core-client-types` crate.
"""

[lints]
workspace = true

[dependencies]
# external dependencies
borsh = { workspace = true }
Expand Down
11 changes: 0 additions & 11 deletions clients/sov-celestia/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
#![cfg_attr(not(test), deny(clippy::unwrap_used))]
#![deny(
warnings,
trivial_casts,
trivial_numeric_casts,
unused_import_braces,
unused_qualifications,
rust_2018_idioms
)]
#![forbid(unsafe_code)]

extern crate alloc;

pub mod client_state;
Expand Down
3 changes: 3 additions & 0 deletions clients/sov-celestia/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ description = """
applicability to facilitate development and integration across diverse IBC-enabled projects.
"""

[lints]
workspace = true

[dependencies]
# external dependencies
base64 = { workspace = true, features = ["alloc"] }
Expand Down
4 changes: 2 additions & 2 deletions clients/sov-celestia/types/src/client_message/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ impl TryFrom<RawSovTmHeader> for SovTmHeader {
type Error = ClientError;

fn try_from(value: RawSovTmHeader) -> Result<Self, Self::Error> {
let da_header = value
let raw_da_header = value
.tendermint_header
.ok_or(Error::missing("missing core header"))?;

let da_header = TmHeader::try_from(da_header).map_err(Error::source)?;
let da_header = TmHeader::try_from(raw_da_header).map_err(Error::source)?;

let aggregated_proof_data = value
.aggregated_proof_data
Expand Down
4 changes: 2 additions & 2 deletions clients/sov-celestia/types/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ impl core::fmt::Display for Error {
write!(f, "Code: {} Origin: {}", self.code, self.origin)?;

if let Some(given) = &self.given {
write!(f, ", Given: {}", given)?;
write!(f, ", Given: {given}")?;
}

if let Some(expected) = &self.expected {
write!(f, ", Expected: {}", expected)?;
write!(f, ", Expected: {expected}")?;
}

Ok(())
Expand Down
11 changes: 0 additions & 11 deletions clients/sov-celestia/types/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
#![cfg_attr(not(test), deny(clippy::unwrap_used))]
#![deny(
warnings,
trivial_casts,
trivial_numeric_casts,
unused_import_braces,
unused_qualifications,
rust_2018_idioms
)]
#![forbid(unsafe_code)]

extern crate alloc;

pub mod client_message;
Expand Down
3 changes: 3 additions & 0 deletions mocks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ version = { workspace = true }
readme = "README.md"
publish = false

[lints]
workspace = true

[dependencies]
# external dependencies
anyhow = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions mocks/src/cosmos/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ impl<S: ProvableStore + Default + Debug> MockCosmosChain<S> {
ibc(self.app.clone()).ctx()
}

pub fn get_balance_of(&self, denom: &str, account: String) -> Option<u64> {
pub fn get_balance_of(&self, denom_str: &str, account: String) -> Option<u64> {
let account_id: AccountId = account.parse().unwrap();

let denom = Denom(denom.to_string());
let denom = Denom(denom_str.to_string());

if let Some(coin) = bank(self.app.clone())
.balance_reader()
Expand Down
8 changes: 4 additions & 4 deletions mocks/src/cosmos/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl<S: ProvableStore + Default + Debug> MockCosmosChain<S> {
}

/// Begins a new block on the chain.
async fn begin_block(&self) {
fn begin_block(&self) {
self.core.grow_blocks(self.app.store.root_hash());

let last_block = self.core.blocks().last().unwrap().clone();
Expand All @@ -54,7 +54,7 @@ impl<S: ProvableStore + Default + Debug> MockCosmosChain<S> {
}

/// Commits the chain state to the store.
async fn commit(&self) {
fn commit(&self) {
let mut modules = self.app.modules.write_access();

let mut state = self.app.store.write_access();
Expand All @@ -81,11 +81,11 @@ impl<S: ProvableStore + Default + Debug> MockCosmosChain<S> {
chain.init().await;

loop {
chain.begin_block().await;
chain.begin_block();

tokio::time::sleep(Duration::from_millis(200)).await;

chain.commit().await;
chain.commit();
}
});

Expand Down
10 changes: 4 additions & 6 deletions mocks/src/relayer/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,10 @@ where
self.setup_cfg.da_service.clone(),
);

rollup
.init(
&self.setup_cfg.kernel_genesis_config(),
&self.setup_cfg.runtime_genesis_config(),
)
.await;
rollup.init(
&self.setup_cfg.kernel_genesis_config(),
&self.setup_cfg.runtime_genesis_config(),
);

let sov_client_counter = match rollup.query(QueryReq::ClientCounter).await {
QueryResp::ClientCounter(counter) => counter,
Expand Down
2 changes: 1 addition & 1 deletion mocks/src/relayer/msgs/cosmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ where
}

/// Builds a Cosmos chain token transfer message; serialized to Any
pub async fn build_msg_transfer_for_cos(&self, config: &TransferTestConfig) -> MsgTransfer {
pub fn build_msg_transfer_for_cos(&self, config: &TransferTestConfig) -> MsgTransfer {
let memo = match config.sov_token_address {
Some(token_address) => {
let mut token_address_buf = String::new();
Expand Down
2 changes: 1 addition & 1 deletion mocks/src/relayer/msgs/rollup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ where

/// Builds a sdk token transfer message wrapped in a `CallMessage` with the given amount
/// Note: keep the amount value lower than the initial balance of the sender address
pub async fn build_msg_transfer_for_sov(&self, config: &TransferTestConfig) -> MsgTransfer {
pub fn build_msg_transfer_for_sov(&self, config: &TransferTestConfig) -> MsgTransfer {
let mut token_address_buf = String::new();

general_purpose::STANDARD_NO_PAD
Expand Down
13 changes: 7 additions & 6 deletions mocks/src/sovereign/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use std::time::Duration;
use sov_consensus_state_tracker::HasConsensusState;
use sov_modules_api::runtime::capabilities::{Kernel, KernelSlotHooks};
use sov_modules_api::{
DispatchCall, Gas, Genesis, KernelWorkingSet, ModuleInfo, SlotData, Spec, StateCheckpoint,
DispatchCall, Gas, GasMeter, Genesis, KernelWorkingSet, ModuleInfo, SlotData, Spec,
StateCheckpoint,
};
use sov_modules_stf_blueprint::kernels::basic::BasicKernelGenesisConfig;
use sov_rollup_interface::da::BlockHeaderTrait;
Expand All @@ -26,7 +27,7 @@ where
<P as MerkleProofSpec>::Hasher: Send,
{
/// Initializes the chain with the genesis configuration
pub async fn init(
pub fn init(
&mut self,
kernel_genesis_config: &BasicKernelGenesisConfig<S, Da::Spec>,
runtime_genesis_config: &GenesisConfig<S>,
Expand Down Expand Up @@ -88,23 +89,23 @@ where

/// Apply a slot by executing the messages in the mempool and committing the state update
pub async fn apply_slot(&mut self, checkpoint: StateCheckpoint<S>) {
let mut checkpoint = self.execute_msg(checkpoint).await;
let mut checkpoint = self.execute_msg(checkpoint);

self.kernel().end_slot_hook(&Gas::zero(), &mut checkpoint);

self.commit(checkpoint);
}

pub async fn execute_msg(&mut self, mut checkpoint: StateCheckpoint<S>) -> StateCheckpoint<S> {
pub fn execute_msg(&mut self, mut checkpoint: StateCheckpoint<S>) -> StateCheckpoint<S> {
let kernel_working_set = KernelWorkingSet::from_kernel(self.kernel(), &mut checkpoint);

let visible_slot = kernel_working_set.virtual_slot();

let mut working_set = checkpoint.to_revertable(Default::default());
let mut working_set = checkpoint.to_revertable(GasMeter::default());

let rollup_ctx = self.rollup_ctx();

for m in self.mempool().into_iter() {
for m in self.mempool() {
// Sets the sender address to the address of the 'sov-ibc'
// module, ensuring that the module's address is used for the
// token creation.
Expand Down
2 changes: 1 addition & 1 deletion mocks/src/sovereign/runtime/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub fn create_chain_state_config<S: Spec>() -> ChainStateConfig<S> {
pub fn create_bank_config<S: Spec>(addresses_count: u64, initial_balance: u64) -> BankConfig<S> {
let address_and_balances: Vec<_> = (0..addresses_count)
.map(|i| {
let key = format!("key_{}", i);
let key = format!("key_{i}");
let addr = gen_address_generic::<S>(&key);
(addr, initial_balance)
})
Expand Down
8 changes: 4 additions & 4 deletions mocks/src/tests/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async fn test_escrow_unescrow_on_sov() {
// -----------------------------------------------------------------------
// Send a `MsgTransfer` to the rollup
// -----------------------------------------------------------------------
let msg_transfer_on_sov = rly.build_msg_transfer_for_sov(&cfg).await;
let msg_transfer_on_sov = rly.build_msg_transfer_for_sov(&cfg);

rly.src_chain_ctx()
.submit_msgs(vec![
Expand Down Expand Up @@ -97,7 +97,7 @@ async fn test_escrow_unescrow_on_sov() {
.service()
.get_balance_of(cfg.sov_address, fake_token_address);

let msg_transfer_on_sov = rly.build_msg_transfer_for_sov(&cfg).await;
let msg_transfer_on_sov = rly.build_msg_transfer_for_sov(&cfg);

rly.src_chain_ctx()
.submit_msgs(vec![
Expand Down Expand Up @@ -170,7 +170,7 @@ async fn test_mint_burn_on_sov() {
// -----------------------------------------------------------------------
// Send a `MsgTransfer` to the Cosmos chain
// -----------------------------------------------------------------------
let msg_transfer_on_cos = rly.build_msg_transfer_for_cos(&cfg).await;
let msg_transfer_on_cos = rly.build_msg_transfer_for_cos(&cfg);

rly.dst_chain_ctx()
.submit_msgs(vec![msg_transfer_on_cos.clone().to_any()])
Expand Down Expand Up @@ -276,7 +276,7 @@ async fn test_mint_burn_on_sov() {
cfg.sov_denom = "transfer/channel-0/basecoin".to_string();
cfg.sov_token_address = Some(token_address_on_sov);

let msg_transfer_on_sov = rly.build_msg_transfer_for_sov(&cfg).await;
let msg_transfer_on_sov = rly.build_msg_transfer_for_sov(&cfg);

rly.src_chain_ctx()
.submit_msgs(vec![
Expand Down
4 changes: 2 additions & 2 deletions mocks/src/utils/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use std::sync::{Arc, Mutex, MutexGuard};

/// helper trait to simplify the error handling when locking a Mutex.
pub trait MutexUtil<T> {
fn acquire_mutex(&self) -> MutexGuard<T>;
fn acquire_mutex(&self) -> MutexGuard<'_, T>;
}

impl<T> MutexUtil<T> for Arc<Mutex<T>> {
fn acquire_mutex(&self) -> MutexGuard<T> {
fn acquire_mutex(&self) -> MutexGuard<'_, T> {
match self.lock() {
Ok(locked_mutex) => locked_mutex,
Err(e) => {
Expand Down
3 changes: 3 additions & 0 deletions modules/sov-consensus-state-tracker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ repository = { workspace = true }
publish = false
readme = "README.md"

[lints]
workspace = true

[dependencies]
# external dependencies
anyhow = { workspace = true }
Expand Down
11 changes: 1 addition & 10 deletions modules/sov-consensus-state-tracker/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
#![forbid(unsafe_code)]
#![deny(
warnings,
unused_import_braces,
unused_qualifications,
rust_2018_idioms,
clippy::unwrap_used
)]

#[cfg(feature = "celestia-da")]
mod celestia_da;
#[cfg(feature = "mock-da")]
Expand Down Expand Up @@ -164,6 +155,6 @@ where
}

fn end_slot_hook(&self, gas_used: &S::Gas, working_set: &mut StateCheckpoint<Self::Spec>) {
self.inner.end_slot_hook(gas_used, working_set)
self.inner.end_slot_hook(gas_used, working_set);
}
}
3 changes: 3 additions & 0 deletions modules/sov-ibc-transfer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ repository = { workspace = true }
publish = false
readme = "README.md"

[lints]
workspace = true

[dependencies]
# external dependencies
anyhow = { workspace = true }
Expand Down
Loading
Loading