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(EOF): add evmone test suite #1689

Merged
merged 4 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 4 additions & 2 deletions .github/workflows/ethereum-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ jobs:
ethtests/EIPTests/StateTests/stEIP1153-transientStorage/ \
ethtests/EIPTests/StateTests/stEIP4844-blobtransactions/ \
ethtests/EIPTests/StateTests/stEIP2537/ \
tests/eof_suite/state_tests \
tests/eof_suite/eest/state_tests \
tests/eof_suite/evmone/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
tests/eof_suite/eest/eof_tests/prague \
tests/eof_suite/evmone/eof_tests

13 changes: 8 additions & 5 deletions bins/revme/src/cmd/eofvalidation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,20 @@ use structopt::StructOpt;
pub struct Cmd {
/// Input path to eof validation test
#[structopt(required = true)]
path: PathBuf,
path: Vec<PathBuf>,
}

impl Cmd {
/// Run statetest command.
pub fn run(&self) -> Result<(), Error> {
// check if path exists.
if !self.path.exists() {
return Err(Error::Custom("The specified path does not exist"));
for path in &self.path {
if !path.exists() {
return Err(Error::Custom("The specified path does not exist"));
}
run_test(path)?
}
run_test(&self.path)
Ok(())
}
}

Expand All @@ -47,7 +50,7 @@ pub fn run_test(path: &Path) -> Result<(), Error> {
let kind = if test_vector.container_kind.is_some() {
Some(CodeType::ReturnContract)
} else {
None
Some(CodeType::ReturnOrStop)
};
let res = validate_raw_eof_inner(test_vector.code.clone(), kind);
if res.is_ok() != test_vector.results.prague.result {
Expand Down
1 change: 1 addition & 0 deletions bins/revme/src/cmd/eofvalidation/test_suite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub struct TestSuite(pub BTreeMap<String, TestUnit>);
pub struct TestUnit {
#[serde(default, rename = "_info")]
pub info: Option<serde_json::Value>,
#[serde(default)]
pub vectors: BTreeMap<String, TestVector>,
}

Expand Down
3 changes: 2 additions & 1 deletion bins/revme/src/cmd/statetest/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ pub struct AccountInfo {
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct Env {
pub current_coinbase: Address,
#[serde(default)]
pub current_difficulty: U256,
pub current_gas_limit: U256,
pub current_number: U256,
Expand Down Expand Up @@ -118,7 +119,7 @@ pub struct TransactionParts {
/// if sender is not present we need to derive it from secret key.
#[serde(default)]
pub sender: Option<Address>,
#[serde(deserialize_with = "deserialize_maybe_empty")]
#[serde(default, deserialize_with = "deserialize_maybe_empty")]
pub to: Option<Address>,
pub value: Vec<U256>,
pub max_fee_per_gas: Option<U256>,
Expand Down
2 changes: 2 additions & 0 deletions bins/revme/src/cmd/statetest/models/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub enum SpecName {
Cancun,
Prague,
PragueEOF,
Osaka, // SKIPPED
#[serde(other)]
Unknown,
}
Expand All @@ -52,6 +53,7 @@ impl SpecName {
Self::ByzantiumToConstantinopleAt5 | Self::Constantinople => {
panic!("Overridden with PETERSBURG")
}
Self::Osaka => panic!("Osaka is not implemented"),
Self::Unknown => panic!("Unknown spec"),
}
}
Expand Down
16 changes: 15 additions & 1 deletion bins/revme/src/cmd/statetest/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ fn skip_test(path: &Path) -> bool {
| "static_Call50000_sha256.json"
| "loopMul.json"
| "CALLBlake2f_MaxRounds.json"

// evmone statetest
| "initcode_transaction_before_prague.json"
| "invalid_tx_non_existing_sender.json"
| "tx_non_existing_sender.json"
| "block_apply_withdrawal.json"
| "block_apply_ommers_reward.json"
| "known_block_hash.json"
| "eip7516_blob_base_fee.json"
) || path_str.contains("stEOF")
}

Expand Down Expand Up @@ -322,12 +331,17 @@ pub fn execute_test_suite(
// Constantinople was immediately extended by Petersburg.
// There isn't any production Constantinople transaction
// so we don't support it and skip right to Petersburg.
if spec_name == SpecName::Constantinople {
if spec_name == SpecName::Constantinople || spec_name == SpecName::Osaka {
continue;
}

let spec_id = spec_name.to_spec_id();

if spec_id.is_enabled_in(SpecId::MERGE) && env.block.prevrandao.is_none() {
// if spec is merge and prevrandao is not set, set it to default
env.block.prevrandao = Some(B256::default());
}

for (index, test) in tests.into_iter().enumerate() {
env.tx.gas_limit = unit.transaction.gas_limit[test.indexes.gas].saturating_to();

Expand Down
7 changes: 2 additions & 5 deletions crates/interpreter/src/instruction_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ impl From<HaltReason> for InstructionResult {
HaltReason::EofAuxDataOverflow => Self::EofAuxDataOverflow,
HaltReason::EofAuxDataTooSmall => Self::EofAuxDataTooSmall,
HaltReason::EOFFunctionStackOverflow => Self::EOFFunctionStackOverflow,
HaltReason::InvalidEXTCALLTarget => Self::InvalidEXTCALLTarget,
#[cfg(feature = "optimism")]
HaltReason::FailedDeposit => Self::FatalExternalError,
}
Expand Down Expand Up @@ -226,8 +227,6 @@ pub enum InternalResult {
InternalCallOrCreate,
/// Internal CREATE/CREATE starts with 0xEF00
CreateInitCodeStartingEF00,
/// Check for target address validity is only done inside subcall.
InvalidEXTCALLTarget,
/// Internal to ExtDelegateCall
InvalidExtDelegateCallTarget,
}
Expand Down Expand Up @@ -338,9 +337,7 @@ impl From<InstructionResult> for SuccessOrHalt {
InstructionResult::ReturnContract => Self::Success(SuccessReason::EofReturnContract),
InstructionResult::EofAuxDataOverflow => Self::Halt(HaltReason::EofAuxDataOverflow),
InstructionResult::EofAuxDataTooSmall => Self::Halt(HaltReason::EofAuxDataTooSmall),
InstructionResult::InvalidEXTCALLTarget => {
Self::Internal(InternalResult::InvalidEXTCALLTarget)
}
InstructionResult::InvalidEXTCALLTarget => Self::Halt(HaltReason::InvalidEXTCALLTarget),
InstructionResult::InvalidExtDelegateCallTarget => {
Self::Internal(InternalResult::InvalidExtDelegateCallTarget)
}
Expand Down
2 changes: 2 additions & 0 deletions crates/primitives/src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,8 @@ pub enum HaltReason {
EofAuxDataTooSmall,
/// EOF Subroutine stack overflow
EOFFunctionStackOverflow,
/// Check for target address validity is only done inside subcall.
InvalidEXTCALLTarget,

/* Optimism errors */
#[cfg(feature = "optimism")]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"EOF1_callf_truncated": {
"vectors": {
"EOF1_callf_truncated_0": {
"code": "0xef000101000402000100010400000000800000e3",
"results": {
"Prague": {
"exception": "EOF_TruncatedImmediate",
"result": false
}
}
},
"EOF1_callf_truncated_1": {
"code": "0xef000101000402000100020400000000800000e300",
"results": {
"Prague": {
"exception": "EOF_TruncatedImmediate",
"result": false
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"EOF1_code_section_0_size": {
"vectors": {
"EOF1_code_section_0_size_0": {
"code": "0xef000101000402000000",
"results": {
"Prague": {
"exception": "EOF_ZeroSectionSize",
"result": false
}
}
},
"EOF1_code_section_0_size_1": {
"code": "0xef000101000402000004000100da",
"results": {
"Prague": {
"exception": "EOF_ZeroSectionSize",
"result": false
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"EOF1_code_section_missing": {
"vectors": {
"EOF1_code_section_missing_0": {
"code": "0xef000101000400",
"results": {
"Prague": {
"exception": "EOF_CodeSectionMissing",
"result": false
}
}
},
"EOF1_code_section_missing_1": {
"code": "0xef00010100040400010000800000da",
"results": {
"Prague": {
"exception": "EOF_CodeSectionMissing",
"result": false
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"EOF1_code_section_offset": {
"vectors": {
"EOF1_code_section_offset_0": {
"code": "0xef000101000802000200030001040004000080000000800000e50001fe00000000",
"results": {
"Prague": {
"result": true
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"EOF1_data_section_0_size": {
"vectors": {
"EOF1_data_section_0_size_0": {
"code": "0xef000101000402000100010400000000800000fe",
"results": {
"Prague": {
"result": true
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"EOF1_data_section_before_code_section": {
"vectors": {
"EOF1_data_section_before_code_section_0": {
"code": "0xef000101000403000102000100010000800000aafe",
"results": {
"Prague": {
"exception": "EOF_CodeSectionMissing",
"result": false
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"EOF1_data_section_before_types_section": {
"vectors": {
"EOF1_data_section_before_types_section_0": {
"code": "0xef0001040001010004020001000100aa00800000fe",
"results": {
"Prague": {
"exception": "EOF_TypeSectionMissing",
"result": false
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"EOF1_dataloadn_truncated": {
"vectors": {
"EOF1_dataloadn_truncated_0": {
"code": "0xef000101000402000100010400000000800000d1",
"results": {
"Prague": {
"exception": "EOF_TruncatedImmediate",
"result": false
}
}
},
"EOF1_dataloadn_truncated_1": {
"code": "0xef000101000402000100020400000000800000d100",
"results": {
"Prague": {
"exception": "EOF_TruncatedImmediate",
"result": false
}
}
}
}
}
}

Large diffs are not rendered by default.

Loading
Loading