Skip to content

Commit

Permalink
store generation on creation
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuajbouw committed May 18, 2021
1 parent d863d3d commit eb569aa
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ impl From<NewCallArgs> for EngineState {
pub struct Engine {
state: EngineState,
origin: Address,
generation: u32,
}

// TODO: upgrade to Berlin HF
Expand All @@ -139,7 +140,12 @@ impl Engine {
}

pub fn new_with_state(state: EngineState, origin: Address) -> Self {
Self { state, origin }
let generation = Self::get_generation(&origin);
Self {
state,
origin,
generation,
}
}

/// Saves state into the storage.
Expand Down Expand Up @@ -520,10 +526,9 @@ impl evm::backend::Backend for Engine {
Engine::get_code(&address)
}

/// Get storage value of address at index.
fn storage(&self, address: Address, index: H256) -> H256 {
let generation = Self::get_generation(&address);
Engine::get_storage(&address, &index, generation)
/// Get storage value of address at key.
fn storage(&self, address: Address, key: H256) -> H256 {
Engine::get_storage(&address, &key, self.generation)
}

/// Get original storage value of address at index, if available.
Expand Down

0 comments on commit eb569aa

Please sign in to comment.