Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more checked arith and other lints #3214

Merged
merged 45 commits into from
May 21, 2024
Merged

more checked arith and other lints #3214

merged 45 commits into from
May 21, 2024

Conversation

tzemanovic
Copy link
Member

@tzemanovic tzemanovic commented May 9, 2024

Describe your changes

closes #2555

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

0.35.1

Checklist before merging to draft

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

Copy link

codecov bot commented May 9, 2024

Codecov Report

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

Project coverage is 60.26%. Comparing base (4ed6229) to head (860132b).

Files Patch % Lines
crates/namada/src/vm/host_env.rs 82.01% 25 Missing ⚠️
...s/apps/src/lib/node/ledger/shell/finalize_block.rs 60.52% 15 Missing ⚠️
crates/namada/src/ledger/vp_host_fns.rs 63.33% 11 Missing ⚠️
crates/tx/src/types.rs 68.57% 11 Missing ⚠️
crates/apps/src/lib/node/ledger/shell/mod.rs 70.96% 9 Missing ⚠️
crates/governance/src/cli/validation.rs 0.00% 9 Missing ⚠️
crates/apps/src/lib/config/genesis/chain.rs 33.33% 8 Missing ⚠️
crates/apps/src/lib/node/ledger/mod.rs 0.00% 8 Missing ⚠️
crates/namada/src/ledger/mod.rs 38.46% 8 Missing ⚠️
crates/proof_of_stake/src/epoched.rs 50.00% 8 Missing ⚠️
... and 22 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3214      +/-   ##
==========================================
+ Coverage   60.24%   60.26%   +0.01%     
==========================================
  Files         303      303              
  Lines       93191    93455     +264     
==========================================
+ Hits        56145    56322     +177     
- Misses      37046    37133      +87     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

tzemanovic added a commit that referenced this pull request May 13, 2024
@tzemanovic tzemanovic marked this pull request as ready for review May 13, 2024 16:37
/// Passed proposal
Passed {
/// Does the proposal contain code
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a ? at the end

@@ -80,25 +81,27 @@ where
fn read_bytes(&self, key: &Key) -> Result<Option<Vec<u8>>> {
match self.store.get(key) {
Some(StorageModification::Write { ref value }) => {
let gas = key.len() + value.len();
let gas = checked!(key.len() + value.len())? as u64;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fine not to use a u64::try_from as in other places? Same for below

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's ok to assume 64bit arch - we'll have a warning if not (#3215)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also it won't fail on 32bit

let mut transparent_tx_pool = shielded_tx.sapling_value_balance();
// The Sapling value balance adds to the transparent tx pool
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put the comment above the code? Or remove?

tzemanovic added a commit that referenced this pull request May 14, 2024
@tzemanovic
Copy link
Member Author

Looks good to me in general, just left a couple questions.

thx! I fixed all the issues in https://github.com/anoma/namada/compare/ec36ae148190e183c70cc0c56171aa3bb8b1d359..31e54b9fcccb58d5628cc0362597d5848b576796

tzemanovic added a commit that referenced this pull request May 14, 2024
* tomas/more-checked-arith:
  changelog: add #3214
  doc/sdk: fix bare urls
  doc/gas: fix broken link
  apps: fix lint warnings
  apps: add lints
  namada: fix lint warnings
  namada: add lints
  vp_env: fix lint warnings
  vp_env: add lints
  tx_env: add lints
  ethereum_bridge: fix lint warnings
  ethereum_bridge: add lints
  ibc: fix lint warnings
  ibc: add lints
  vm_env: fix lint warnings
  vm_env: add lints
  state: fix lint warnings
  state: add lints
  token: fix lint warnings
  token: add lints
  proof_of_stake: fix lint warnings
  proof_of_stake: add lints
  governance: fix lint warnings
  governance: add lints
  account: fix lint warnings
  account: add lints
  shielded_token: fix lint warnings
  shielded_token: add lints
  trans_token: add lints
  parameters: add lints
  controller: fix lint warnings
  controller: add lints
  storage: fix lint warnings
  storage: add lints
  vote_ext: add lints
  tx: fix lints warnings
  tx: add lints
  gas: fix lints warning
  gas: add lints
  merkle_tree: fix lints warning
  merkle_tree: add lints
  crates: update for checked events gas
  events: use checked arith
  events: add lints
  replay_protection: add lints
@tzemanovic tzemanovic mentioned this pull request May 16, 2024
2 tasks
brentstone added a commit that referenced this pull request May 21, 2024
* origin/tomas/more-checked-arith:
  changelog: add #3214
  doc/sdk: fix bare urls
  doc/gas: fix broken link
  apps: fix lint warnings
  apps: add lints
  namada: fix lint warnings
  namada: add lints
  vp_env: fix lint warnings
  vp_env: add lints
  tx_env: add lints
  ethereum_bridge: fix lint warnings
  ethereum_bridge: add lints
  ibc: fix lint warnings
  ibc: add lints
  vm_env: fix lint warnings
  vm_env: add lints
  state: fix lint warnings
  state: add lints
  token: fix lint warnings
  token: add lints
  proof_of_stake: fix lint warnings
  proof_of_stake: add lints
  governance: fix lint warnings
  governance: add lints
  account: fix lint warnings
  account: add lints
  shielded_token: fix lint warnings
  shielded_token: add lints
  trans_token: add lints
  parameters: add lints
  controller: fix lint warnings
  controller: add lints
  storage: fix lint warnings
  storage: add lints
  vote_ext: add lints
  tx: fix lints warnings
  tx: add lints
  gas: fix lints warning
  gas: add lints
  merkle_tree: fix lints warning
  merkle_tree: add lints
  crates: update for checked events gas
  events: use checked arith
  events: add lints
  replay_protection: add lints
tzemanovic added a commit that referenced this pull request May 21, 2024
* tomas/split-up-apps:
  changelog: add #3259
  test/apps_lib: fix the top-level dir check
  fix paths for split up namada_apps_lib
  git: ignore the new generated version.rs path
  symlink proto from `apps_lib`
  `mv crates/apps/build.rs crates/apps_lib/`
  `mv crates/apps_lib/src/lib/mod.rs crates/apps_lib/src/lib.rs`
  `mv crates/apps/src/lib crates/apps_lib/src`
  apps_lib: add a new crate for apps lib crate
  fixup! Merge branch 'grarco/masp-fees' (#3217)
  fixup! Merge branch 'grarco/tx-batch' (#3103)
  fixup! Merge branch 'grarco/tx-batch' (#3103)
  fixup! Merge branch 'bat/fix/issue-1796' (#3226)
  fixup! Merge branch 'tiago/max-proposal-bytes-validation' (#3220)
  fixup! Merge branch 'tomas/more-checked-arith' (#3214)
  empty commit
  changelog: add #3216
  deliberatly empty
  Changelog #2817
  added clone to transaction structs
@tzemanovic tzemanovic merged commit b4c95c3 into main May 21, 2024
15 of 19 checks passed
@tzemanovic tzemanovic deleted the tomas/more-checked-arith branch May 21, 2024 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Audit for all usage of unchecked arithmetic and update nomenclature
2 participants