-
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 all 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 |
---|---|---|
|
@@ -7,8 +7,8 @@ use access_controller::AccessController; | |
use bytemuck::Zeroable; | ||
|
||
use crate::constants::{ | ||
EMPTY_PREDECESSOR, TIMELOCK_CONFIG_SEED, TIMELOCK_ID_PADDED, TIMELOCK_OPERATION_SEED, | ||
TIMELOCK_SIGNER_SEED, | ||
EMPTY_PREDECESSOR, TIMELOCK_BYPASSER_OPERATION_SEED, TIMELOCK_CONFIG_SEED, TIMELOCK_ID_PADDED, | ||
TIMELOCK_OPERATION_SEED, TIMELOCK_SIGNER_SEED, | ||
}; | ||
use crate::error::TimelockError; | ||
use crate::event::*; | ||
|
@@ -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,22 @@ 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()], | ||
seeds = [TIMELOCK_BYPASSER_OPERATION_SEED, timelock_id.as_ref(), id.as_ref()], | ||
bump, | ||
constraint = operation.is_finalized @ TimelockError::OperationNotFinalized, | ||
close = authority, // close the bypasser operation after execution | ||
)] | ||
pub operation: Account<'info, Operation>, | ||
|
||
|
@@ -194,7 +196,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)] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
pub mod cancel; | ||
pub mod execute; | ||
pub mod initialize; | ||
pub mod operation; | ||
pub mod schedule; | ||
|
||
pub use cancel::*; | ||
pub use execute::*; | ||
pub use initialize::*; | ||
pub use operation::*; | ||
pub use schedule::*; |
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