Skip to content

Commit

Permalink
fix: dont commit storage of SD accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
enitrat committed Nov 23, 2023
1 parent 6028b14 commit 0d11453
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
11 changes: 11 additions & 0 deletions crates/evm/src/model/account.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 1 addition & 15 deletions crates/evm/src/state.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
}
},
Expand Down

0 comments on commit 0d11453

Please sign in to comment.