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: own function access keys without write permission #11

Merged
merged 8 commits into from
Jul 30, 2024

Conversation

petersalomonsen
Copy link
Contributor

@petersalomonsen petersalomonsen commented Jul 29, 2024

As can be seen if running the tests without the fix, we get the error message ERROR: Social DB requires more storage deposit, but we cannot cover it when signing transaction with a Function Call only access key if using a function access key that does not have explicit write permission, but comes from the account that we want to write to. This should not fail, and this PR reproduces and fixes the issue.

Here is the output of running the unit tests without the fix:

test tests::test_get_deposit_other_account_no_explicit_write_permission ... ok
test tests::test_get_deposit_own_account_explicit_write_permission ... ok
test tests::test_get_deposit_own_account_no_explicit_write_permission ... FAILED
test tests::test_get_deposit_same_account_function_access_key_with_required_deposit ... ok
test tests::test_get_deposit_write_permission_function_access_key_with_required_deposit ... ok

failures:

---- tests::test_get_deposit_own_account_no_explicit_write_permission stdout ----
Error: ERROR: Social DB requires more storage deposit, but we cannot cover it when signing transaction with a Function Call only access key

Location:
    src/lib.rs:191:17
thread 'tests::test_get_deposit_own_account_no_explicit_write_permission' panicked at src/lib.rs:465:17:
get_deposit should not fail when using a public key belonging to the target account, even without explicit write permission. Error Message:
ERROR: Social DB requires more storage deposit, but we cannot cover it when signing transaction with a Function Call only access key
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    tests::test_get_deposit_own_account_no_explicit_write_permission

In addition this PR adds github codespaces setup, and a workflow for running the unit tests. The "code-style" CI workflow is also updated to use ubuntu-latest and rust-cache because it failed with the current setup.

fixes NEAR-DevHub/neardevhub-bos#897

@petersalomonsen petersalomonsen changed the title unit tests for storage estimation fix: should not fail if there is no required deposit and using a function access key belonging to the target account, even when not granted explicit write permission Jul 30, 2024
@petersalomonsen petersalomonsen changed the title fix: should not fail if there is no required deposit and using a function access key belonging to the target account, even when not granted explicit write permission fix: own function access keys without write permission Jul 30, 2024
@petersalomonsen
Copy link
Contributor Author

@race-of-sloths Please include this PR

@race-of-sloths
Copy link

race-of-sloths commented Jul 30, 2024

@petersalomonsen Thank you for your contribution! Your pull request is now a part of the Race of Sloths!
You are true leader! Other sloths hot on your heels, keep moving!

Shows profile picture for the author of the PR

Current status: executed
Reviewer Score
@frol 8

The average score is 8

@petersalomonsen check out your results on the Race of Sloths Leaderboard! and in the profile

What is the Race of Sloths

Race of Sloths is a friendly competition where you can participate in challenges and compete with other open-source contributors within your normal workflow

For contributors:

  • Tag @race-of-sloths inside your pull requests
  • Wait for the maintainer to review and score your pull request
  • Check out your position in the Leaderboard
  • Keep weekly and monthly streaks to reach higher positions
  • Boast your contributions with a dynamic picture of your Profile

For maintainers:

  • Score pull requests that participate in the Race of Sloths
  • Engage contributors with fair scoring and fast responses so they keep their streaks
  • Promote the Race to the point where the Race starts promoting you
  • Grow the community of your contributors

Feel free to check our website for additional details!

Bot commands
  • For contributors
    • Include a PR: @race-of-sloths include to enter the Race with your PR
  • For maintainers:
    • Assign points: @race-of-sloths score [1/2/3/5/8/13] to award points based on your assessment.
    • Reject this PR: @race-of-sloths exclude to send this PR back to the drawing board.
    • Exclude repo: @race-of-sloths pause to stop bot activity in this repo until @race-of-sloths unpause command is called

Copy link
Collaborator

@frol frol left a comment

Choose a reason for hiding this comment

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

@petersalomonsen Thank you for authoring the fix and introducing the tests!

@race-of-sloths score 8

@race-of-sloths
Copy link

🌟 Score recorded!

@frol, thank you for scoring this pull request in the Race of Sloths!

@petersalomonsen
Copy link
Contributor Author

@frol "code-style" and "unit-test" CI workflows are now updated to use ubuntu-latest and rust-cache because the existing setup failed to compile ( as you can see from previous runs ).

Al CI workflows pass in the PR to my own fork

@frol frol merged commit 60140eb into bos-cli-rs:main Jul 30, 2024
2 checks passed
@github-actions github-actions bot mentioned this pull request Jul 30, 2024
frol pushed a commit that referenced this pull request Jul 30, 2024
## 🤖 New release
* `near-socialdb-client`: 0.3.1 -> 0.3.2

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

##
[0.3.2](v0.3.1...v0.3.2)
- 2024-07-30

### Fixed
- Allow function access keys to be used without explicit write
permission (this reflects the SocialDB contract implementation)
([#11](#11))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/MarcoIeni/release-plz/).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@race-of-sloths
Copy link

✅ PR is finalized!

Your contribution is much appreciated with a final score of 8!
You have received 110 (80 base + 20 weekly bonus + 10 monthly bonus) Sloth points for this contribution

Congratulations @petersalomonsen! Your PR was highly scored and you completed another monthly streak! To keep your monthly streak make another pull request next month and get 8+ score for it

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.

Unable to deploy with near-bos-cli
3 participants