File tree Expand file tree Collapse file tree 3 files changed +19
-10
lines changed Expand file tree Collapse file tree 3 files changed +19
-10
lines changed Original file line number Diff line number Diff line change 11use std:: collections:: HashMap ;
2- use std:: time:: UNIX_EPOCH ;
32
43use serde:: de:: DeserializeOwned ;
54
@@ -10,6 +9,8 @@ use solana_sdk::pubkey::Pubkey;
109use solana_sdk:: sysvar:: Sysvar ;
1110use solana_sdk:: sysvar:: SysvarId ;
1211
12+ use crate :: utils:: get_current_timestamp;
13+
1314#[ derive( Default ) ]
1415pub struct AccountsDB {
1516 accounts : HashMap < Pubkey , AccountSharedData > ,
@@ -83,10 +84,7 @@ impl AccountsDB {
8384 let mut clock: Clock =
8485 bincode:: deserialize ( self . sysvars . get ( & Clock :: id ( ) ) . unwrap ( ) . data ( ) ) . unwrap ( ) ;
8586
86- let current_timestamp = std:: time:: SystemTime :: now ( )
87- . duration_since ( UNIX_EPOCH )
88- . expect ( "Time went backwards!" )
89- . as_secs ( ) ;
87+ let current_timestamp = get_current_timestamp ( ) ;
9088
9189 // current time is always greater than last clock update
9290 let time_since_last_update =
@@ -126,10 +124,7 @@ pub struct SysvarTracker {
126124
127125impl SysvarTracker {
128126 pub fn refresh_last_clock_update ( & mut self ) {
129- self . last_clock_update = std:: time:: SystemTime :: now ( )
130- . duration_since ( UNIX_EPOCH )
131- . expect ( "Time went backwards!" )
132- . as_secs ( ) ;
127+ self . last_clock_update = get_current_timestamp ( ) ;
133128 }
134129}
135130
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ use crate::log::turn_off_solana_logging;
4949use crate :: native:: BUILTINS ;
5050use crate :: trident_fork_graphs:: TridentForkGraph ;
5151use crate :: trident_svm:: TridentSVM ;
52+ use crate :: utils:: get_current_timestamp;
5253use crate :: utils:: ProgramEntrypoint ;
5354use crate :: utils:: SBFTarget ;
5455use crate :: utils:: TridentAccountSharedData ;
@@ -97,7 +98,11 @@ impl TridentSVM {
9798 self
9899 }
99100 fn with_sysvars ( mut self ) -> Self {
100- self . set_sysvar ( & Clock :: default ( ) ) ;
101+ let clock = Clock {
102+ unix_timestamp : get_current_timestamp ( ) as i64 ,
103+ ..Default :: default ( )
104+ } ;
105+ self . set_sysvar ( & clock) ;
101106 self . set_sysvar ( & EpochRewards :: default ( ) ) ;
102107 self . set_sysvar ( & EpochSchedule :: default ( ) ) ;
103108 #[ allow( deprecated) ]
Original file line number Diff line number Diff line change 1+ use std:: time:: UNIX_EPOCH ;
2+
13use solana_program_runtime:: invoke_context:: BuiltinFunctionWithContext ;
24
35use solana_sdk:: account:: AccountSharedData ;
@@ -46,3 +48,10 @@ impl TridentAccountSharedData {
4648 Self { address, account }
4749 }
4850}
51+
52+ pub ( crate ) fn get_current_timestamp ( ) -> u64 {
53+ std:: time:: SystemTime :: now ( )
54+ . duration_since ( UNIX_EPOCH )
55+ . expect ( "Time went backwards!" )
56+ . as_secs ( )
57+ }
You can’t perform that action at this time.
0 commit comments