Skip to content

Commit

Permalink
Added update_last_usage flag
Browse files Browse the repository at this point in the history
  • Loading branch information
AnastasiyaTarasova committed Oct 9, 2024
1 parent 3d6e853 commit 0419f12
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions evm_loader/program/src/account/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,16 @@ impl<'a> StateAccount<'a> {
program_id: &Pubkey,
info: &AccountInfo<'a>,
accounts: &AccountsDB,
update_last_usage: bool,
) -> Result<(Self, AccountsStatus)> {
let mut status = AccountsStatus::Ok;
let mut state = Self::from_account(program_id, info)?;

let timeout =
solana_program::clock::Clock::get().map(|clock| clock.slot.as_u256().as_u64())?;
state.data.timeout = timeout;
if update_last_usage {
let timeout =
solana_program::clock::Clock::get().map(|clock| clock.slot.as_u256().as_u64())?;
state.data.timeout = timeout;
}

let is_touched_account = |key: &Pubkey| -> bool {
state
Expand Down
2 changes: 1 addition & 1 deletion evm_loader/program/src/instruction/transaction_cancel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn process<'a>(
log_data(&[b"MINER", operator_balance.address().as_bytes()]);

let accounts_db = AccountsDB::new(&accounts[3..], operator, Some(operator_balance), None, None);
let (storage, _) = StateAccount::restore(program_id, &storage_info, &accounts_db)?;
let (storage, _) = StateAccount::restore(program_id, &storage_info, &accounts_db, false)?;

let current_timestamp =
solana_program::clock::Clock::get().map(|clock| clock.slot.as_u256().as_u64())?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub fn process_inner<'a>(
}
TAG_STATE => {
let (storage, accounts_status) =
StateAccount::restore(program_id, &holder_or_storage, &accounts_db)?;
StateAccount::restore(program_id, &holder_or_storage, &accounts_db, true)?;

operator_balance.validate_transaction(storage.trx())?;
let miner_address = operator_balance.miner(storage.trx_origin());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub fn process<'a>(
}
TAG_STATE => {
let (storage, accounts_status) =
StateAccount::restore(program_id, &storage_info, &accounts_db)?;
StateAccount::restore(program_id, &storage_info, &accounts_db, true)?;

operator_balance.validate_transaction(storage.trx())?;
let miner_address = operator_balance.miner(storage.trx_origin());
Expand Down

0 comments on commit 0419f12

Please sign in to comment.