Skip to content

Commit

Permalink
feat(EOF): EOF Validation add code type and sub container tracker (#1648
Browse files Browse the repository at this point in the history
)

* feat(EOF): EOF Validation add code type and sub container tracker

* fix

* omit tests

* fix some things, bump test suite

* fix(EOF): Overflow on num_sections

* cleanup fmt

* clippy

* fix tests

* Run EOF validation tests
  • Loading branch information
rakita authored Jul 24, 2024
1 parent d71acb5 commit e123600
Show file tree
Hide file tree
Showing 278 changed files with 64,764 additions and 11,760 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ethereum-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@ jobs:
ethtests/EIPTests/StateTests/stEIP2537/ \
tests/eof_suite/state_tests \
tests/prague_suite/state_tests
- name: Run EOF validation tests
run: |
cross run --target ${{matrix.target}} --profile ${{ matrix.profile }} -p revme -- eof-validation \
tests/eof_suite/eof_tests/prague
15 changes: 8 additions & 7 deletions bins/revme/src/cmd/eofvalidation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ mod test_suite;
pub use test_suite::{PragueTestResult, TestResult, TestSuite, TestUnit, TestVector};

use crate::{cmd::Error, dir_utils::find_all_json_tests};
use revm::{
interpreter::analysis::{validate_raw_eof, EofError},
primitives::Eof,
};
use revm::interpreter::analysis::{validate_raw_eof_inner, CodeType, EofError};
use std::collections::BTreeMap;
use std::path::{Path, PathBuf};
use structopt::StructOpt;
Expand Down Expand Up @@ -48,11 +45,15 @@ pub fn run_test(path: &Path) {
for (name, test_unit) in suite.0 {
for (vector_name, test_vector) in test_unit.vectors {
test_sum += 1;
let res = validate_raw_eof(test_vector.code.clone());
let kind = if test_vector.container_kind.is_some() {
Some(CodeType::ReturnContract)
} else {
None
};
let res = validate_raw_eof_inner(test_vector.code.clone(), kind);
if res.is_ok() != test_vector.results.prague.result {
let eof = Eof::decode(test_vector.code.clone());
println!(
"\nTest failed: {} - {}\nresult:{:?}\nrevm err_result:{:#?}\nbytes:{:?}\n,eof:{eof:#?}",
"\nTest failed: {} - {}\nresult:{:?}\nrevm err_result:{:#?}\nbytes:{:?}\n",
name,
vector_name,
test_vector.results.prague,
Expand Down
3 changes: 2 additions & 1 deletion bins/revme/src/cmd/eofvalidation/test_suite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ pub struct TestUnit {
}

#[derive(Debug, PartialEq, Eq, Deserialize)]
#[serde(deny_unknown_fields)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct TestVector {
pub code: Bytes,
pub container_kind: Option<String>,
pub results: PragueTestResult,
}

Expand Down
Loading

0 comments on commit e123600

Please sign in to comment.