From 0d114537a2cbce4f7f6e74d695155778d2d9854d Mon Sep 17 00:00:00 2001 From: enitrat Date: Thu, 23 Nov 2023 09:00:49 +0100 Subject: [PATCH] fix: dont commit storage of SD accounts --- crates/evm/src/model/account.cairo | 11 +++++++++++ crates/evm/src/state.cairo | 16 +--------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/crates/evm/src/model/account.cairo b/crates/evm/src/model/account.cairo index 0b1ef9d8c..7c6137ccb 100644 --- a/crates/evm/src/model/account.cairo +++ b/crates/evm/src/model/account.cairo @@ -227,6 +227,17 @@ impl AccountImpl of AccountTrait { return Result::Ok(()); } + fn commit_storage(self: @Account, key: u256, value: u256) { + if self.is_selfdestruct() { + return; + } + match self.account_type { + AccountType::EOA => { panic_with_felt252('EOA account commitment') }, + AccountType::ContractAccount => { self.store_storage(key, value); }, + AccountType::Unknown(_) => { panic_with_felt252('Unknown account commitment') } + } + } + #[inline(always)] fn address(self: @Account) -> Address { *self.address diff --git a/crates/evm/src/state.cairo b/crates/evm/src/state.cairo index 295b0e56a..92df49ff2 100644 --- a/crates/evm/src/state.cairo +++ b/crates/evm/src/state.cairo @@ -342,21 +342,7 @@ impl StateInternalImpl of StateInternalTrait { .deref(); let res_account = self.get_account(evm_address); match res_account { - Result::Ok(account) => { - let account_type = account.account_type; - match account_type { - //this shouldn't ever happen - AccountType::EOA => { - panic_with_felt252('EOA account commitment') - }, - AccountType::ContractAccount => { - account.store_storage(key, value); - }, - AccountType::Unknown(_) => { - panic_with_felt252('Unknown account commitment') - } - } - }, + Result::Ok(account) => { account.commit_storage(key, value); }, Result::Err(err) => { break Result::Err(err); } } },