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

program: add pause deposit state and guard in deposit & deposit_spl_token #14

Merged
merged 4 commits into from
Aug 15, 2024

Conversation

brewmaster012
Copy link
Contributor

@brewmaster012 brewmaster012 commented Aug 15, 2024

So that the program can be paused when zeta blockchain is undergoing upgrade or downtime, or TSS migration.

Only user deposits are paused to prevent users losing or experiencing delay in their assets during downtime;
Withdraws are not paused because:

  1. withdraws is initiated by blockchain and should be paused there
  2. if withdraw is paused in program in error, then withdraw will abort and user lost funds.

The new guards and instructions are part of the test suite; to run

anchor test

@codecov-commenter
Copy link

codecov-commenter commented Aug 15, 2024

Codecov Report

Attention: Patch coverage is 7.40741% with 25 lines in your changes missing coverage. Please review.

Project coverage is 9.17%. Comparing base (eb03529) to head (52a13a4).

Files Patch % Lines
programs/protocol-contracts-solana/src/lib.rs 7.40% 25 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##            main     #14      +/-   ##
========================================
- Coverage   9.42%   9.17%   -0.25%     
========================================
  Files          1       1              
  Lines        191     218      +27     
========================================
+ Hits          18      20       +2     
- Misses       173     198      +25     

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

README.md Outdated Show resolved Hide resolved
programs/protocol-contracts-solana/src/lib.rs Show resolved Hide resolved
pub fn deposit(ctx: Context<Deposit>, amount: u64, memo: Vec<u8>) -> Result<()> {
require!(memo.len() >= 20, Errors::MemoLengthTooShort);
require!(memo.len() <= 512, Errors::MemoLengthExceeded);

let pda = &mut ctx.accounts.pda;
Copy link
Collaborator

@ws4charlie ws4charlie Aug 15, 2024

Choose a reason for hiding this comment

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

not relating to this PR. Could we also print informative logs in withdraw, deposit_spl_token and withdraw_spl_token, similar to the log print in withdraw, which looks so useful (especial to non-technical user). The log seems free of charge in Solana?
image

Copy link
Collaborator

@ws4charlie ws4charlie left a comment

Choose a reason for hiding this comment

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

looks good. left minor comment

Co-authored-by: Lucas Bertrand <[email protected]>
@brewmaster012 brewmaster012 merged commit 18ed2fb into main Aug 15, 2024
13 checks passed
@brewmaster012 brewmaster012 deleted the pause-deposit branch August 15, 2024 17:34
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.

4 participants