Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
db01eb5
Add all forks to revm
rakita Aug 16, 2022
38bfb6d
Add all hardforks
rakita Aug 17, 2022
f2ff107
Merge remote-tracking branch 'origin/main' into main
rakita Aug 17, 2022
84739f1
EXTCODESIZE and EXTCODEHASH old hardfork gas fix
rakita Aug 17, 2022
fc1a81e
EXTCODECOPY fix gas hardfork
rakita Aug 17, 2022
daadfa2
fmt
rakita Aug 17, 2022
25f06a0
cleanups
rakita Aug 17, 2022
d10dfdf
EIP-161 is in SPURIOUS_DRAGON hardfork
rakita Aug 18, 2022
6e97f92
EIP-161 create nonce increment for SPURIOUS_DRAGON
rakita Aug 18, 2022
175aee5
Enable SPURIOUS_DRAGON tests
rakita Aug 18, 2022
c25fc75
Change database traits to return Result<Option<>>
rakita Aug 18, 2022
b1de572
80perc done transition
rakita Aug 20, 2022
0d68e72
db result compiled and new forks passing
rakita Aug 21, 2022
588d99d
not_existing, precompile perf is_cold
rakita Aug 22, 2022
4222270
fix for not_existing
rakita Aug 22, 2022
1d532dc
passing most of legact tests
rakita Aug 22, 2022
94bc2be
Remove spurious precompile hotfix for old forks
rakita Aug 22, 2022
61eebc8
EIP-2 OOG if crate bytecode can't be paid
rakita Aug 23, 2022
4859b12
Merge remote-tracking branch 'origin/main' into forks
rakita Aug 26, 2022
c8171a7
Add legacy tests to github ci, fmt,clippy
rakita Aug 26, 2022
2d1edcf
Merge remote-tracking branch 'origin/main' into forks
rakita Aug 26, 2022
b5c65f9
fmt
rakita Aug 26, 2022
4317474
Propagate FatalExternalError
rakita Aug 26, 2022
431fe68
Add Error associated type to Database.
rakita Aug 27, 2022
44f6ec1
Small cleanup
rakita Aug 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
not_existing, precompile perf is_cold
  • Loading branch information
rakita committed Aug 22, 2022
commit 588d99dc1ffb1ca746616f10ca1c0b0d15dd8c25
10 changes: 5 additions & 5 deletions crates/revm/src/db/in_memory_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ pub struct EmptyDB();
impl DatabaseRef for EmptyDB {
/// Get basic account information.
fn basic(&self, _address: H160) -> Result<Option<AccountInfo>, &'static str> {
Ok(None) //AccountInfo::default()
Ok(None)
}
/// Get account code by its hash
fn code_by_hash(&self, _code_hash: H256) -> Result<Bytecode, &'static str> {
Expand Down Expand Up @@ -363,7 +363,7 @@ impl Database for BenchmarkDB {
code_hash: self.1,
}));
}
Ok(None) //AccountInfo::default()
Ok(None)
}

/// Get account code by its hash
Expand Down Expand Up @@ -405,7 +405,7 @@ mod tests {

let (key, value) = (123u64.into(), 456u64.into());
let mut new_state = CacheDB::new(init_state);
new_state.insert_account_storage(account, key, value);
let _ = new_state.insert_account_storage(account, key, value);

assert_eq!(new_state.basic(account).unwrap().unwrap().nonce, nonce);
assert_eq!(new_state.storage(account, key), Ok(value));
Expand All @@ -426,10 +426,10 @@ mod tests {

let (key0, value0) = (123u64.into(), 456u64.into());
let (key1, value1) = (789u64.into(), 999u64.into());
init_state.insert_account_storage(account, key0, value0);
let _ = init_state.insert_account_storage(account, key0, value0);

let mut new_state = CacheDB::new(init_state);
new_state.replace_account_storage(account, [(key1, value1)].into());
let _ = new_state.replace_account_storage(account, [(key1, value1)].into());

assert_eq!(new_state.basic(account).unwrap().unwrap().nonce, nonce);
assert_eq!(new_state.storage(account, key0), Ok(0.into()));
Expand Down
62 changes: 33 additions & 29 deletions crates/revm/src/evm_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
models::SelfDestructResult,
return_ok, CallContext, CallInputs, CallScheme, CreateInputs, CreateScheme, Env,
ExecutionResult, Gas, Inspector, Log, Return, Spec,
SpecId::*,
SpecId::{*, self},
TransactOut, TransactTo, Transfer, KECCAK_EMPTY,
};
use alloc::vec::Vec;
Expand Down Expand Up @@ -78,7 +78,14 @@ impl<'a, GSPEC: Spec, DB: Database, const INSPECT: bool> Transact
}

// load acc
self.data.journaled_state.load_account(caller, self.data.db);
if self
.data
.journaled_state
.load_account(caller, self.data.db)
.is_err()
{
return exit(Return::FatalNotSupported);
}

// EIP-3607: Reject transactions from senders with deployed code
// This EIP is introduced after london but there was no colision in past
Expand Down Expand Up @@ -185,22 +192,11 @@ impl<'a, GSPEC: Spec, DB: Database, const INSPECT: bool> EVMImpl<'a, GSPEC, DB,
inspector: &'a mut dyn Inspector<DB>,
precompiles: Precompiles,
) -> Self {
let mut journaled_state = JournaledState::default();
if env.cfg.perf_all_precompiles_have_balance {
// load precompiles without asking db.
let mut precompile_acc = Vec::new();
for (add, _) in precompiles.as_slice() {
precompile_acc.push(*add);
}
journaled_state.load_precompiles_default(&precompile_acc);
let journaled_state = if GSPEC::enabled(SpecId::SPURIOUS_DRAGON) {
JournaledState::new(precompiles.len())
} else {
let mut precompile_acc = Map::new();
// TODO
for (add, _) in precompiles.as_slice() {
precompile_acc.insert(*add, db.basic(*add).ok().flatten().unwrap_or_default());
}
journaled_state.load_precompiles(precompile_acc);
}
JournaledState::new_legacy(precompiles.len())
};
Self {
data: EVMData {
env,
Expand Down Expand Up @@ -241,7 +237,9 @@ impl<'a, GSPEC: Spec, DB: Database, const INSPECT: bool> EVMImpl<'a, GSPEC, DB,
effective_gas_price
};

self.data
// TODO
let _ = self
.data
.journaled_state
.load_account(coinbase, self.data.db);
self.data.journaled_state.touch(&coinbase);
Expand All @@ -255,7 +253,9 @@ impl<'a, GSPEC: Spec, DB: Database, const INSPECT: bool> EVMImpl<'a, GSPEC, DB,
(gas.spend() - gas_refunded, gas_refunded)
} else {
// touch coinbase
self.data
// TODO return
let _ = self
.data
.journaled_state
.load_account(coinbase, self.data.db);
self.data.journaled_state.touch(&coinbase);
Expand Down Expand Up @@ -296,12 +296,16 @@ impl<'a, GSPEC: Spec, DB: Database, const INSPECT: bool> EVMImpl<'a, GSPEC, DB,
let mut accessed_slots = 0_u64;

for (address, slots) in self.data.env.tx.access_list.iter() {
self.data
// TODO return
let _ = self
.data
.journaled_state
.load_account(*address, self.data.db);
accessed_slots += slots.len() as u64;
// TODO return
for slot in slots {
self.data
let _ = self
.data
.journaled_state
.sload(*address, *slot, self.data.db);
}
Expand Down Expand Up @@ -682,14 +686,14 @@ impl<'a, GSPEC: Spec, DB: Database + 'a, const INSPECT: bool> Host
}

fn balance(&mut self, address: H160) -> Option<(U256, bool)> {
let is_cold = self
.data
.journaled_state
.load_account(address, self.data.db)
.map_err(|e| self.data.error = Some(e))
.ok()?;
let balance = self.data.journaled_state.account(address).info.balance;
Some((balance, is_cold))
let db = &mut self.data.db;
let journal = &mut self.data.journaled_state;
let error = &mut self.data.error;
journal
.load_account(address, db)
.map_err(|e| *error = Some(e))
.ok()
.map(|(acc, is_cold)| (acc.info.balance, is_cold))
}

fn code(&mut self, address: H160) -> Option<(Bytecode, bool)> {
Expand Down
Loading