-
Notifications
You must be signed in to change notification settings - Fork 1
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
Authority timelock #3
Conversation
// Check that the timelock is no longer than 1 year | ||
if Clock::get()?.unix_timestamp.saturating_add(ONE_YEAR) < timestamp { | ||
return Err(ErrorCode::TimestampTooLate.into()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
smart
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice
/// CHECK: Unchecked new authority, can be a native wallet or a PDA of another program | ||
pub new_authority: AccountInfo<'info>, | ||
#[account(seeds = [new_authority.key().as_ref(), timestamp.to_be_bytes().as_ref()], bump)] | ||
pub escrow_authority: SystemAccount<'info>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me make sure i follow this correctly: escrow_authority holds one or more authorities on behalf of new_authority.key(), but all of those authorities can only be claimed after timestamp
.
i.e., this logic works even if multiple programs are transferred to the same new_authority at the same timestamp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes exactly, you send any number of authorities to the PDA seeded by new_authority
and timestamp
.
This PDA will only ever sign to send the authorities to new_authority
after timestamp
.
pub struct Commit<'info> { | ||
pub current_authority: Signer<'info>, | ||
/// CHECK: Unchecked new authority, can be a native wallet or a PDA of another program | ||
pub new_authority: AccountInfo<'info>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have to be super careful about setting this key correctly right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(i'm not sure if there's anything better we can do here, since it's not like we can sign as the governance authority anyway)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I have a strategy
30a06fa
to
d461e45
Compare
This program implements a timelock for upgrade authorities.
The
current_authority
transfers the authority to a PDA of thenew_authority
and thetimestamp
at which the transfer can happen. The PDA will only sign authority transfer tonew_authority
after thetimestamp
.