-
Notifications
You must be signed in to change notification settings - Fork 6
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
solana: timelock preloading ops authority #474
Changes from 22 commits
576b2f1
39b5025
e2f8c40
b48b290
a71263d
1b5da06
14f8e08
babff69
3c62d54
24fad7a
64f0fde
624af26
3566aa0
0d437cb
ba2078c
00d5ab4
279665f
adbc31f
46d203e
813ee27
d025072
d921aa7
0c9bc62
8b5919c
411ae32
191b969
55eab56
3ab0e03
7da5bf8
ebb168b
90317ed
735340a
e1907bf
ca4be96
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ use crate::state::{Config, InstructionData, Operation}; | |
pub fn execute_batch<'info>( | ||
ctx: Context<'_, '_, '_, 'info, ExecuteBatch<'info>>, | ||
timelock_id: [u8; TIMELOCK_ID_PADDED], | ||
_id: [u8; 32], | ||
_id: [u8; HASH_BYTES], | ||
) -> Result<()> { | ||
let op = &mut ctx.accounts.operation; | ||
|
||
|
@@ -38,8 +38,9 @@ pub fn execute_batch<'info>( | |
ctx.program_id, | ||
); | ||
|
||
require!( | ||
ctx.accounts.predecessor_operation.key() == expected_address, | ||
require_keys_eq!( | ||
ctx.accounts.predecessor_operation.key(), | ||
expected_address, | ||
TimelockError::InvalidInput | ||
); | ||
|
||
|
@@ -49,8 +50,9 @@ pub fn execute_batch<'info>( | |
|
||
require!(predecessor_acc.is_done(), TimelockError::MissingDependency); | ||
} else { | ||
require!( | ||
ctx.accounts.predecessor_operation.key() == Pubkey::zeroed(), | ||
require_keys_eq!( | ||
ctx.accounts.predecessor_operation.key(), | ||
Pubkey::zeroed(), | ||
TimelockError::InvalidInput | ||
); | ||
} | ||
|
@@ -78,8 +80,6 @@ pub fn execute_batch<'info>( | |
}); | ||
} | ||
|
||
require!(op.is_ready(current_time), TimelockError::OperationNotReady); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: In the EVM-based version, we do a second |
||
|
||
// all executed, update the timestamp | ||
op.mark_done(); | ||
|
||
|
@@ -88,10 +88,11 @@ pub fn execute_batch<'info>( | |
|
||
/// execute operation(instructions) w/o checking predecessors and readiness | ||
/// bypasser_execute also need the operation to be uploaded formerly | ||
/// NOTE: operation should be closed after execution | ||
pub fn bypasser_execute_batch<'info>( | ||
ctx: Context<'_, '_, '_, 'info, BypasserExecuteBatch<'info>>, | ||
timelock_id: [u8; TIMELOCK_ID_PADDED], | ||
_id: [u8; 32], | ||
_id: [u8; HASH_BYTES], | ||
) -> Result<()> { | ||
let op = &mut ctx.accounts.operation; | ||
|
||
|
@@ -166,21 +167,23 @@ pub struct ExecuteBatch<'info> { | |
)] | ||
pub timelock_signer: UncheckedAccount<'info>, | ||
|
||
// NOTE: access controller check happens in only_role_or_admin_role macro | ||
// NOTE: access controller check happens in require_role_or_admin macro | ||
pub role_access_controller: AccountLoader<'info, AccessController>, | ||
|
||
#[account(mut)] | ||
pub authority: Signer<'info>, | ||
} | ||
|
||
#[derive(Accounts)] | ||
#[instruction(timelock_id: [u8; 32], id: [u8; 32])] | ||
#[instruction(timelock_id: [u8; TIMELOCK_ID_PADDED], id: [u8; HASH_BYTES])] | ||
pub struct BypasserExecuteBatch<'info> { | ||
#[account( | ||
mut, | ||
seeds = [TIMELOCK_OPERATION_SEED, timelock_id.as_ref(), id.as_ref()], | ||
bump, | ||
constraint = operation.is_finalized @ TimelockError::OperationNotFinalized, | ||
constraint = !operation.is_done() @ TimelockError::OperationAlreadyExecuted, | ||
close = authority, // close the operation after execution | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: bypasser_execution operation management, the operation is needed to be pre-uploaded, but it shouldn't affect normal schedule/execute workflow so we're closing the account |
||
)] | ||
pub operation: Account<'info, Operation>, | ||
|
||
|
@@ -194,7 +197,7 @@ pub struct BypasserExecuteBatch<'info> { | |
)] | ||
pub timelock_signer: UncheckedAccount<'info>, | ||
|
||
// NOTE: access controller check happens in only_role_or_admin_role macro | ||
// NOTE: access controller check happens in require_role_or_admin macro | ||
pub role_access_controller: AccountLoader<'info, AccessController>, | ||
|
||
#[account(mut)] | ||
|
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.
note: clean up error messages but subject to change on the off-chain requirement