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

fix: client side check to prevent threshold=0 on init/update #2747

Conversation

phy-chain
Copy link

@phy-chain phy-chain commented Feb 27, 2024

Adding Client side check to ensure threshold > 0 in init-account and update-account (also init-validator)

Describe your changes

Accounts (and validator accounts) should not be created/updated with less than 1 as threshold, otherwise this would allow transaction requiring to signature.

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

I initially first reported this in #2671.

Checklist before merging to draft

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

@phy-chain phy-chain force-pushed the fix-threshold-always-positive_client-check branch from e58987d to d002fee Compare February 27, 2024 21:38
@Fraccaman
Copy link
Member

Thanks for the PR! I think the logic is almost correct, but I would say it better to check if the threshold is <= than the number of public-keys associated with the new account. Would you be able to make the change?

@phy-chain
Copy link
Author

phy-chain commented Feb 27, 2024

@Fraccaman I think it's 2 differents issues. Checking if the threshold <= public-keys would not prevent it from begin 0, right ?
But I can add that logic too in the same PR if you want

@phy-chain
Copy link
Author

Also, I can see that some of the CI check are not passing. Is it expected, or should I fix them ? (I've fixed the namada-release already, Im not used to Rust - make build works fine locally though)

@Fraccaman
Copy link
Member

Fraccaman commented Feb 27, 2024

to get CI to work, just rebase this branch on base. For the logic I think we can do something like:

  • at least 1 public key is definied
  • threshold is <= number of public keys

This should solve both the issues, wdyt?

@Fraccaman
Copy link
Member

for update-account the logic is more complex because you could modify only the threshold but we should check on the client that the new threshold won't "burn" the account. As an example, lets say that the current threshold for account X is 1, and the number of associated public keys is 1. If a user tries to modify the threshold of account X to 2, it should fail (without --force).

@spidey-169
Copy link

spidey-169 commented Feb 28, 2024

for update-account the logic is more complex because you could modify only the threshold but we should check on the client that the new threshold won't "burn" the account. As an example, lets say that the current threshold for account X is 1, and the number of associated public keys is 1. If a user tries to modify the threshold of account X to 2, it should fail (without --force).

Hi, looks like this is actually what I am trying to implement in my PR #2677. Sorry, am new to rust and hence taking a little longer. Will try to see I can get this implemented for update-account and currently planning to throw and exception and exit if threshold > num-public-keys is ever detected

crates/apps/src/lib/cli.rs Outdated Show resolved Hide resolved
crates/apps/src/lib/cli.rs Outdated Show resolved Hide resolved
crates/apps/src/lib/cli.rs Outdated Show resolved Hide resolved
crates/apps/src/lib/cli.rs Outdated Show resolved Hide resolved
@sug0
Copy link
Collaborator

sug0 commented Feb 28, 2024

also, please rebase on the latest base branch from upstream

$ git remote add upstream https://github.com/anoma/namada
$ git fetch -p upstream
$ git rebase upstream/base

@phy-chain
Copy link
Author

git remote add upstream https://github.com/anoma/namada

Am i not supposed to continue working on my fork ? Im not used to open source contributions, so I'd rather not mess up my branche :D

Copy link

codecov bot commented Feb 28, 2024

Codecov Report

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

Project coverage is 53.94%. Comparing base (2535c9c) to head (35d90f5).

Files Patch % Lines
crates/apps/src/lib/cli.rs 0.00% 30 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2747      +/-   ##
==========================================
- Coverage   53.95%   53.94%   -0.02%     
==========================================
  Files         308      308              
  Lines      100018   100042      +24     
==========================================
- Hits        53967    53966       -1     
- Misses      46051    46076      +25     

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

@phy-chain phy-chain force-pushed the fix-threshold-always-positive_client-check branch from f0e67c4 to b09e238 Compare February 28, 2024 13:32
@sug0
Copy link
Collaborator

sug0 commented Feb 28, 2024

git remote add upstream https://github.com/anoma/namada

Am i not supposed to continue working on my fork ? Im not used to open source contributions, so I'd rather not mess up my branche :D

you won't mess it up xd

your changes are pretty trivial, you shouldn't run into any conflicts by rebasing. the git remote-add command adds a new location to fetch git commits/references from, since your forked repository won't have our latest releases.

@phy-chain
Copy link
Author

git remote add upstream https://github.com/anoma/namada

Am i not supposed to continue working on my fork ? Im not used to open source contributions, so I'd rather not mess up my branche :D

you won't mess it up xd

your changes are pretty trivial, you shouldn't run into any conflicts by rebasing. the git remote-add command adds a new location to fetch git commits/references from, since your forked repository won't have our latest releases.

Yeah rebase is already done. Im trying to figure out the NoneZeroU8 change now. But Im not so much of a Rust coder. More into typescript/frontend/react native :D But I'll keep hacking into it (unless you want to handle that your own way 😅 )

@phy-chain phy-chain force-pushed the fix-threshold-always-positive_client-check branch from 320f222 to 35d90f5 Compare March 1, 2024 07:14
@Fraccaman Fraccaman mentioned this pull request Apr 30, 2024
2 tasks
@brentstone
Copy link
Collaborator

Closing this in favor of #3154.

@brentstone brentstone closed this May 1, 2024
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.

5 participants