namada icon indicating copy to clipboard operation
namada copied to clipboard

core: checked arithmetics

Open tzemanovic opened this issue 1 year ago • 4 comments

Describe your changes

first part of #2555 addressing core crate

Indicate on which release or other PRs this topic is based on

v0.34.0

Checklist before merging to draft

  • [x] I have added a changelog
  • [x] Git history is in acceptable state

tzemanovic avatar Apr 12 '24 12:04 tzemanovic

Codecov Report

Attention: Patch coverage is 79.78385% with 318 lines in your changes are missing coverage. Please review.

Project coverage is 59.53%. Comparing base (9d4de02) to head (a78ec98). Report is 12 commits behind head on main.

Files Patch % Lines
crates/sdk/src/queries/vp/pos.rs 0.00% 35 Missing :warning:
crates/proof_of_stake/src/lib.rs 87.90% 26 Missing :warning:
crates/core/src/uint.rs 87.62% 25 Missing :warning:
crates/sdk/src/tx.rs 0.00% 23 Missing :warning:
crates/sdk/src/masp.rs 0.00% 19 Missing :warning:
crates/core/src/dec.rs 89.24% 17 Missing :warning:
...ledger/native_vp/ethereum_bridge/bridge_pool_vp.rs 0.00% 16 Missing :warning:
crates/core/src/storage.rs 77.27% 15 Missing :warning:
crates/core/src/voting_power.rs 71.42% 12 Missing :warning:
crates/governance/src/utils.rs 86.81% 12 Missing :warning:
... and 30 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3074      +/-   ##
==========================================
+ Coverage   59.40%   59.53%   +0.12%     
==========================================
  Files         298      298              
  Lines       92326    92613     +287     
==========================================
+ Hits        54849    55138     +289     
+ Misses      37477    37475       -2     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar May 03 '24 14:05 codecov[bot]

@tzemanovic Is the title of this PR still accurate? Looks like a bunch of crates beyond core are changed. Does this cover everything, everywhere or are there other sections still remaining to transition to checked arithemetic?

cwgoes avatar May 06 '24 15:05 cwgoes

@tzemanovic Is the title of this PR still accurate? Looks like a bunch of crates beyond core are changed. Does this cover everything, everywhere or are there other sections still remaining to transition to checked arithemetic?

@cwgoes It is accurate - the lints to warn about unchecked arithmetics and conversions are only applied in the core crate, i.e.:

#![warn(
    clippy::cast_sign_loss,
    clippy::cast_possible_truncation,
    clippy::cast_possible_wrap,
    clippy::cast_lossless,
    clippy::arithmetic_side_effects
)]

The changes outside of core are only due to removal of unchecked API in core types (except for a few reasonable exceptions), which are extensive but not exhaustive. We should also add these lints to other relevant crates which can still do unchecked arithmetics and conversions with other non-core types.

tzemanovic avatar May 07 '24 08:05 tzemanovic

Understood @tzemanovic - thanks!

cwgoes avatar May 08 '24 07:05 cwgoes