Skip to content

Commit

Permalink
Support using system storage directly for EVM balance and nonce (#6659)
Browse files Browse the repository at this point in the history
  • Loading branch information
goldoneen committed Jul 23, 2020
1 parent f43cfc8 commit b07e24b
Show file tree
Hide file tree
Showing 3 changed files with 193 additions and 118 deletions.
10 changes: 5 additions & 5 deletions src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use frame_support::traits::Get;
use frame_support::storage::{StorageMap, StorageDoubleMap};
use sha3::{Keccak256, Digest};
use evm::backend::{Backend as BackendT, ApplyBackend, Apply};
use crate::{Trait, Accounts, AccountStorages, AccountCodes, Module, Event};
use crate::{Trait, AccountStorages, AccountCodes, Module, Event};

#[derive(Clone, Eq, PartialEq, Encode, Decode, Default)]
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
Expand Down Expand Up @@ -100,7 +100,7 @@ impl<'vicinity, T: Trait> BackendT for Backend<'vicinity, T> {
}

fn basic(&self, address: H160) -> evm::backend::Basic {
let account = Accounts::get(&address);
let account = Module::<T>::account_basic(&address);

evm::backend::Basic {
balance: account.balance,
Expand Down Expand Up @@ -141,9 +141,9 @@ impl<'vicinity, T: Trait> ApplyBackend for Backend<'vicinity, T> {
Apply::Modify {
address, basic, code, storage, reset_storage,
} => {
Accounts::mutate(&address, |account| {
account.balance = basic.balance;
account.nonce = basic.nonce;
Module::<T>::mutate_account_basic(&address, Account {
nonce: basic.nonce,
balance: basic.balance,
});

if let Some(code) = code {
Expand Down
Loading

0 comments on commit b07e24b

Please sign in to comment.