Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(levm): running all ef tests with revm and fixing problems #1275

Merged
merged 48 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
4de7a5e
Do not skip `VMTests`
ilitteri Nov 19, 2024
33b948f
Refactor runner
ilitteri Nov 21, 2024
950f2aa
Isolate EF test parsing
ilitteri Nov 21, 2024
9eaab48
Fix initial state loading
ilitteri Nov 21, 2024
cdc76d4
Fix types
ilitteri Nov 21, 2024
e389c73
Fix deserialization
ilitteri Nov 21, 2024
a28aa00
Refactor report module
ilitteri Nov 21, 2024
f72bd3f
Rename test file and modules
ilitteri Nov 21, 2024
798ca19
Ignore report file
ilitteri Nov 21, 2024
0df3e41
Chore
ilitteri Nov 21, 2024
1391e03
Merge main
ilitteri Nov 21, 2024
3e7ece3
Revert "Merge main"
ilitteri Nov 21, 2024
50cf7af
Merge branch 'main' of github.com:lambdaclass/lambda_ethereum_rust in…
ilitteri Nov 21, 2024
221990c
Update cmd/ef_tests/levm/runner/levm_runner.rs
ilitteri Nov 22, 2024
a437508
Fix
ilitteri Nov 22, 2024
12333c1
Fix parsing
ilitteri Nov 22, 2024
0e51cf8
Fix parsing
ilitteri Nov 22, 2024
b2160a0
change HashSet import
JereSalo Nov 22, 2024
522ec08
Fix
ilitteri Nov 22, 2024
15592c3
Improvements
ilitteri Nov 25, 2024
0a904aa
Fix lint
ilitteri Nov 25, 2024
6da1e57
start implementing runner revm (doesnt work well)
JereSalo Nov 25, 2024
62d6cfb
finish implementing running with revm and add some debugs
JereSalo Nov 25, 2024
d6c3f37
add deserialization for other stuff in transaction
JereSalo Nov 25, 2024
f4779da
fix deserialize and add some things for debugging
JereSalo Nov 25, 2024
fc71b1d
change blob excess gas and price in revm
JereSalo Nov 26, 2024
c168c15
add quick simple fix for storing revmerrors, then change
JereSalo Nov 26, 2024
a18335d
add comments and temporary error typein VMError for debugging
JereSalo Nov 26, 2024
9c316b6
set gas priority fee and max fee per blob gas, remove serde in EFTest…
JereSalo Nov 26, 2024
9759734
comment stTimeConsuming and add things for debugging
JereSalo Nov 26, 2024
9381ed6
add blob hashes
JereSalo Nov 26, 2024
c535e93
calculate effective gas price for revm setup
JereSalo Nov 26, 2024
26e96c4
start with deserialization of access lists (doesn't work yet)
JereSalo Nov 26, 2024
0899b57
partially fix access list deserializing
JereSalo Nov 26, 2024
fc73748
fix deserialize access lists
JereSalo Nov 26, 2024
2c89323
finally implement and fix access lists (i think so)
JereSalo Nov 26, 2024
84671af
leave some todos for tackling afterwards
JereSalo Nov 26, 2024
cd7502e
Merge branch 'main' into levm/running-ef-tests-revm
JereSalo Nov 27, 2024
04d95ab
comment prints and run with levm
JereSalo Nov 27, 2024
047a16c
simplify access lists deserializer
JereSalo Nov 27, 2024
d4ba11a
adapt PR for merging
JereSalo Nov 27, 2024
dfdef69
change some stuff in revm errors...
JereSalo Nov 27, 2024
d87f6ad
remove testing error in levm
JereSalo Nov 27, 2024
eb2df57
Merge branch 'main' into levm/running-ef-tests-revm
JereSalo Nov 27, 2024
72892c1
comment revm execution
JereSalo Nov 27, 2024
be3d894
Merge branch 'levm/running-ef-tests-revm' of github.com:lambdaclass/l…
JereSalo Nov 27, 2024
f4891c0
remove comment and add description to run_with_revm
JereSalo Nov 27, 2024
51ebf37
merge main
JereSalo Nov 27, 2024
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
62 changes: 60 additions & 2 deletions cmd/ef_tests/levm/deserialize.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::types::{EFTest, EFTests};
use crate::types::{EFTest, EFTestAccessListItem, EFTests};
use bytes::Bytes;
use ethrex_core::U256;
use ethrex_core::{H256, U256};
use serde::Deserialize;
use std::{collections::HashMap, str::FromStr};

Expand Down Expand Up @@ -65,6 +65,50 @@ where
)
}

pub fn deserialize_h256_vec_optional_safe<'de, D>(
deserializer: D,
) -> Result<Option<Vec<H256>>, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = Option::<Vec<String>>::deserialize(deserializer)?;
match s {
Some(s) => {
let mut ret = Vec::new();
for s in s {
ret.push(H256::from_str(s.trim_start_matches("0x")).map_err(|err| {
serde::de::Error::custom(format!(
"error parsing H256 when deserializing H256 vec optional: {err}"
))
})?);
}
Ok(Some(ret))
}
None => Ok(None),
}
}

pub fn deserialize_access_lists<'de, D>(
deserializer: D,
) -> Result<Option<Vec<Vec<EFTestAccessListItem>>>, D::Error>
where
D: serde::Deserializer<'de>,
{
let access_lists: Option<Vec<Option<Vec<EFTestAccessListItem>>>> =
Option::<Vec<Option<Vec<EFTestAccessListItem>>>>::deserialize(deserializer)?;

let mut final_access_lists: Vec<Vec<EFTestAccessListItem>> = Vec::new();

if let Some(access_lists) = access_lists {
for access_list in access_lists {
// Treat `null` as an empty vector
final_access_lists.push(access_list.unwrap_or_default());
}
}

Ok(Some(final_access_lists))
}

pub fn deserialize_u256_optional_safe<'de, D>(deserializer: D) -> Result<Option<U256>, D::Error>
where
D: serde::Deserializer<'de>,
Expand Down Expand Up @@ -164,6 +208,20 @@ impl<'de> Deserialize<'de> for EFTests {
sender: raw_tx.sender,
to: raw_tx.to.clone(),
value: *value,
blob_versioned_hashes: raw_tx
.blob_versioned_hashes
.clone()
.unwrap_or_default(),
max_fee_per_blob_gas: raw_tx.max_fee_per_blob_gas,
max_priority_fee_per_gas: raw_tx.max_priority_fee_per_gas,
max_fee_per_gas: raw_tx.max_fee_per_gas,
access_list: raw_tx
.access_lists
.clone()
.unwrap_or_default()
.get(data_id)
.cloned()
.unwrap_or_default(),
};
transactions.insert((data_id, gas_limit_id, value_id), tx);
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/ef_tests/levm/runner/levm_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub fn prepare_vm_for_tx(vector: &TestVector, test: &EFTest) -> Result<VM, EFTes
origin: test.transactions.get(vector).unwrap().sender,
consumed_gas: U256::default(),
refunded_gas: U256::default(),
gas_limit: test.env.current_gas_limit,
gas_limit: test.env.current_gas_limit, //this should be tx gas limit
block_number: test.env.current_number,
coinbase: test.env.current_coinbase,
timestamp: test.env.current_timestamp,
Expand Down
38 changes: 38 additions & 0 deletions cmd/ef_tests/levm/runner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub fn run_ef_tests(
run_with_levm(&mut reports, &ef_tests)?;
}
re_run_with_revm(&mut reports, &ef_tests)?;
// _run_with_revm(&mut reports, &ef_tests)?;
Copy link
Contributor

@ilitteri ilitteri Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is going to be merged to main we should remove this commented line and add documentation on the commented function explaining when to use it.

Suggested change
// _run_with_revm(&mut reports, &ef_tests)?;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in f4891c0

write_report(&reports)
}

Expand Down Expand Up @@ -88,6 +89,43 @@ fn run_with_levm(
Ok(())
}

fn _run_with_revm(
reports: &mut Vec<EFTestReport>,
ef_tests: &[EFTest],
) -> Result<(), EFTestRunnerError> {
let revm_run_time = std::time::Instant::now();
let mut revm_run_spinner = Spinner::new(
Dots,
"Running all tests with REVM...".to_owned(),
Color::Cyan,
);
for (idx, test) in ef_tests.iter().enumerate() {
let total_tests = ef_tests.len();
revm_run_spinner.update_text(format!(
"{} {}/{total_tests} - {}",
"Running all tests with REVM".bold(),
idx + 1,
format_duration_as_mm_ss(revm_run_time.elapsed())
));
let ef_test_report = match revm_runner::_run_ef_test_revm(test) {
Ok(ef_test_report) => ef_test_report,
Err(EFTestRunnerError::Internal(err)) => return Err(EFTestRunnerError::Internal(err)),
non_internal_errors => {
return Err(EFTestRunnerError::Internal(InternalError::FirstRunInternal(format!(
"Non-internal error raised when executing revm. This should not happen: {non_internal_errors:?}",
))))
}
};
reports.push(ef_test_report);
revm_run_spinner.update_text(report::progress(reports, revm_run_time.elapsed()));
}
revm_run_spinner.success(&format!(
"Ran all tests with REVM in {}",
format_duration_as_mm_ss(revm_run_time.elapsed())
));
Ok(())
}

fn re_run_with_revm(
reports: &mut [EFTestReport],
ef_tests: &[EFTest],
Expand Down
Loading
Loading