Skip to content

Commit

Permalink
feat(levm): error handling ef_tests (Part 1) (#1319)
Browse files Browse the repository at this point in the history
**Motivation**

<!-- Why does this pull request exist? What are its goals? -->

**Description**

<!-- A clear and concise general description of the changes this PR
introduces -->
- Add some other fields to levm's environment: Max priority fee per gas,
max fee per gas, block gas limit, max fee per blob gas.
- Refactors `tx_blob_hashes` and `op_blobhash`. I realized this opcode
wasn't pushing 0 to the stack if no blobhash was found.
- Make `execute()` propagate interal errors
- Partially implements validation errors. Partially because for them to
be fully implemented I have to make changes like gas consumption logic
and that would be too much for this PR.


- The amount of tests that passed is pretty similar to the ones that are
passing in `main`, only a few more are passing. This PR only doesn't fix
all execution errors, for this to be fixed I have to make a lot more
changes and it would transform itself into a very big PR.

<!-- Link to issues: Resolves #111, Resolves #222 -->

Closes #issue_number
  • Loading branch information
JereSalo authored Nov 28, 2024
1 parent 9a2f8e0 commit f461511
Show file tree
Hide file tree
Showing 13 changed files with 5,272 additions and 328 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_levm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ concurrency:

env:
CARGO_TERM_COLOR: always
RUST_VERSION: 1.79.0
RUST_VERSION: 1.81.0

jobs:
ef-test:
Expand Down
31 changes: 19 additions & 12 deletions cmd/ef_tests/levm/runner/levm_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,31 +73,38 @@ pub fn prepare_vm_for_tx(vector: &TestVector, test: &EFTest) -> Result<VM, EFTes
store: initial_state.database().unwrap().clone(),
block_hash,
});

let tx = test
.transactions
.get(vector)
.ok_or(EFTestRunnerError::Internal(
InternalError::FirstRunInternal("Failed to get transaction".to_owned()),
))?;

VM::new(
test.transactions.get(vector).unwrap().to.clone(),
tx.to.clone(),
Environment {
origin: test.transactions.get(vector).unwrap().sender,
origin: tx.sender,
consumed_gas: U256::default(),
refunded_gas: U256::default(),
gas_limit: test.env.current_gas_limit, //this should be tx gas limit
gas_limit: tx.gas_limit,
block_number: test.env.current_number,
coinbase: test.env.current_coinbase,
timestamp: test.env.current_timestamp,
prev_randao: test.env.current_random,
chain_id: U256::from(1729),
base_fee_per_gas: test.env.current_base_fee.unwrap_or_default(),
gas_price: test
.transactions
.get(vector)
.unwrap()
.gas_price
.unwrap_or_default(), // or max_fee_per_gas?
gas_price: tx.gas_price.unwrap_or_default(),
block_excess_blob_gas: test.env.current_excess_blob_gas,
block_blob_gas_used: None,
tx_blob_hashes: None,
tx_blob_hashes: tx.blob_versioned_hashes.clone(),
tx_max_priority_fee_per_gas: tx.max_priority_fee_per_gas,
tx_max_fee_per_gas: tx.max_fee_per_gas,
tx_max_fee_per_blob_gas: tx.max_fee_per_blob_gas,
block_gas_limit: test.env.current_gas_limit,
},
test.transactions.get(vector).unwrap().value,
test.transactions.get(vector).unwrap().data.clone(),
tx.value,
tx.data.clone(),
db,
CacheDB::default(),
)
Expand Down
Loading

0 comments on commit f461511

Please sign in to comment.