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
Small cleanup
  • Loading branch information
rakita committed Aug 29, 2022
commit 44f6ec1dc33c2bcc30e35602ff325cc44a077f8b
1 change: 1 addition & 0 deletions .github/workflows/ethereum-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
with:
repository: ethereum/tests
path: ethtests
submodules: recursive,

- name: Install toolchain
uses: actions-rs/toolchain@v1
Expand Down
20 changes: 0 additions & 20 deletions bins/revme/src/statetest/models/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,3 @@ impl SpecName {
}
}
}

/*
spec!(FRONTIER);
// FRONTIER_THAWING no EVM spec change
spec!(HOMESTEAD);
// DAO_FORK no EVM spec change
spec!(TANGERINE);
spec!(SPURIOUS_DRAGON);
spec!(BYZANTIUM);
// CONSTANTINOPLE was overriden with PETERSBURG
spec!(PETERSBURG);
spec!(ISTANBUL);
// MUIR_GLACIER no EVM spec change
spec!(BERLIN);
spec!(LONDON);
// ARROW_GLACIER no EVM spec change
// GRAT_GLACIER no EVM spec change
spec!(MERGE);
spec!(LATEST);
*/
2 changes: 1 addition & 1 deletion bins/revme/src/statetest/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ pub fn run(test_files: Vec<PathBuf>) -> Result<(), TestError> {
let mut joins: Vec<std::thread::JoinHandle<Result<(), TestError>>> = Vec::new();
let queue = Arc::new(Mutex::new((0, test_files)));
let elapsed = Arc::new(Mutex::new(std::time::Duration::ZERO));
for _ in 0..1 {
for _ in 0..10 {
let queue = queue.clone();
let endjob = endjob.clone();
let console_bar = console_bar.clone();
Expand Down
4 changes: 2 additions & 2 deletions bins/revme/src/statetest/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ impl<DB: Database> Inspector<DB> for CustomPrintTracer {
is_static: bool,
) -> (Return, Gas, Bytes) {
println!(
"SM CALL: {:?},context:{:?}, is_static:{:?}, transfer:{:?}, input:", //{:?}",
"SM CALL: {:?},context:{:?}, is_static:{:?}, transfer:{:?}, input_size:{:?}",
inputs.contract,
inputs.context,
is_static,
inputs.transfer,
//hex::encode(&inputs.input),
inputs.input.len(),
);
(Return::Continue, Gas::new(0), Bytes::new())
}
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/db/in_memory_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl InMemoryDB {
/// Memory backend, storing all state values in a `Map` in memory.
#[derive(Debug, Clone)]
pub struct CacheDB<ExtDB: DatabaseRef> {
/// Account info where None means it is not existing. None existing state is needed for Pre TANGERINE forks.
/// Account info where None means it is not existing. Not existing state is needed for Pre TANGERINE forks.
/// `code` is always `None`, and bytecode can be found in `contracts`.
pub accounts: Map<H160, DbAccount>,
pub contracts: Map<H256, Bytecode>,
Expand Down
64 changes: 58 additions & 6 deletions crates/revm/src/journaled_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{interpreter::bytecode::Bytecode, models::SelfDestructResult, Return,
use alloc::{vec, vec::Vec};
use core::mem::{self};
use hashbrown::{hash_map::Entry, HashMap as Map};
use primitive_types::{H160, H256, U256};
use primitive_types::{H160, U256};

use crate::{db::Database, AccountInfo, Log};

Expand Down Expand Up @@ -604,10 +604,62 @@ impl JournaledState {
}

fn is_precompile(address: H160, num_of_precompiles: usize) -> bool {
let u256: H256 = address.into();
let u256: U256 = U256::from_big_endian(u256.as_bytes());

let first = u256.0[0].wrapping_sub(1);
if !address[..18].iter().all(|i| *i == 0) {
return false;
}
let num = u16::from_be_bytes([address[18], address[19]]);
num.wrapping_sub(1) < num_of_precompiles as u16
}

u256.0[3] == 0 && u256.0[2] == 0 && u256.0[1] == 0 && first < num_of_precompiles as u64
#[cfg(test)]
mod test {
use super::*;

#[test]
fn test_is_precompile() {
assert_eq!(
is_precompile(
H160([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),
3
),
false,
"Zero is not precompile"
);

assert_eq!(
is_precompile(
H160([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9]),
3
),
false,
"0x100..0 is not precompile"
);

assert_eq!(
is_precompile(
H160([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4]),
3
),
false,
"0x000..4 is not precompile"
);

assert_eq!(
is_precompile(
H160([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]),
3
),
true,
"0x00..01 is precompile"
);

assert_eq!(
is_precompile(
H160([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3]),
3
),
true,
"0x000..3 is precompile"
);
}
}
34 changes: 17 additions & 17 deletions crates/revm/src/specification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@ use num_enum::TryFromPrimitive;
use revm_precompiles::SpecId as PrecompileId;

/// SpecId and their activation block
/// Information was got from: https://github.com/ethereum/execution-specs
/// Information was obtained from: https://github.com/ethereum/execution-specs
#[repr(u8)]
#[derive(Debug, Copy, Clone, TryFromPrimitive, Eq, PartialEq, Hash, Ord, PartialOrd)]
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(non_camel_case_types)]
pub enum SpecId {
FRONTIER = 0, // Frontier 1
FRONTIER_THAWING = 1, // Frontier Thawing 200000
HOMESTEAD = 2, // Homestead 1150000
DAO_FORK = 3, // DAO Fork 1920000
TANGERINE = 4, // Tangerine Whistle 2463000
SPURIOUS_DRAGON = 5, //Spurious Dragon 2675000
BYZANTIUM = 6, // Byzantium 4370000
CONSTANTINOPLE = 7, // Constantinople 7280000 is overwriten with PETERSBURG
PETERSBURG = 8, // Petersburg 7280000
ISTANBUL = 9, // Istanbul 9069000
MUIR_GLACIER = 10, // Muir Glacier 9200000
BERLIN = 11, // Berlin 12244000
LONDON = 12, // London 12965000
ARROW_GLACIER = 13, //Arrow Glacier 13773000
GRAY_GLACIER = 14, // Gray Glacier 15050000
MERGE = 15, // Paris TBD (Depends on difficulty)
FRONTIER = 0, // Frontier 0
FRONTIER_THAWING = 1, // Frontier Thawing 200000
HOMESTEAD = 2, // Homestead 1150000
DAO_FORK = 3, // DAO Fork 1920000
TANGERINE = 4, // Tangerine Whistle 2463000
SPURIOUS_DRAGON = 5, // Spurious Dragon 2675000
BYZANTIUM = 6, // Byzantium 4370000
CONSTANTINOPLE = 7, // Constantinople 7280000 is overwriten with PETERSBURG
PETERSBURG = 8, // Petersburg 7280000
ISTANBUL = 9, // Istanbul 9069000
MUIR_GLACIER = 10, // Muir Glacier 9200000
BERLIN = 11, // Berlin 12244000
LONDON = 12, // London 12965000
ARROW_GLACIER = 13, // Arrow Glacier 13773000
GRAY_GLACIER = 14, // Gray Glacier 15050000
MERGE = 15, // Paris/Merge TBD (Depends on difficulty)
LATEST = 16,
}

Expand Down