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

bug: OOG failure for MLOAD not replicated #31

Closed
Tracked by #28
greged93 opened this issue Aug 29, 2023 · 0 comments
Closed
Tracked by #28

bug: OOG failure for MLOAD not replicated #31

greged93 opened this issue Aug 29, 2023 · 0 comments
Labels
evm bug Something related to normal EVM execution isn't working

Comments

@greged93
Copy link
Contributor

greged93 commented Aug 29, 2023

Bug Report

Kakarot version: ee6458a

Current behavior:
Test mload_d1g0v0_Shanghai fails with the following error message:

[!] Case ~/code/rust/ef-tests/crates/ef-testing/ethereum-tests/BlockchainTests/GeneralStateTests/VMTests/vmIOandFlowOperations/mload.json failed (description: mload): Test failed: failed test mload_d1g0v0_Shanghai: expected storage value 0x0000000000000000000000000000000000000000000000000000000000000bad, got 0x0000000000000000000000000000000000000000000000000000000000000000

Expected behavior:
Test should pass or be skipped. The error is due to the fact that the transaction is expected to revert in the EVM with OOG (out of gas), while the transaction passes in Kakarot.

Steps to reproduce:

make tarket=mload_d1g0v0_Shanghai ef-test

Related code:
The MLOAD gas cost depends on the current size of the memory and the expansion produced by the offset.

No where in the current Kakarot implementation do we revert the execution if the gas cost if above the current gas limit. To decide if this is needed or not.

https://github.com/kkrt-labs/kakarot/blob/0c6e7a62a38e973ad6ceebfbf648841749ffe0ee/src/kakarot/instructions.cairo#L601-L644

// @notice Iteratively decode and execute the bytecode of an ExecutionContext
    // @param ctx The pointer to the execution context.
    // @return ExecutionContext The pointer to the updated execution context.
    func run{
        syscall_ptr: felt*,
        pedersen_ptr: HashBuiltin*,
        range_check_ptr,
        bitwise_ptr: BitwiseBuiltin*,
    }(ctx: model.ExecutionContext*) -> model.ExecutionContext* {
        alloc_locals;
        // Decode and execute
        let ctx: model.ExecutionContext* = decode_and_execute(ctx=ctx);

        // Check if execution should be stopped
        let stopped: felt = ExecutionContext.is_stopped(self=ctx);
        let is_root: felt = ExecutionContext.is_root(self=ctx);

        // Terminate execution
        if (stopped != FALSE) {
            let ctx = ExecutionContext.finalize_state(ctx);
            if (is_root != FALSE) {
                if (ctx.destroy_contracts_len != 0) {
                    let ctx = SelfDestructHelper.finalize(ctx);
                    return ctx;
                }
                return ctx;
            } else {
                let is_precompile = Precompiles.is_precompile(address=ctx.evm_contract_address);
                if (is_precompile != FALSE) {
                    let ctx = CallHelper.finalize_calling_context(ctx);
                    return run(ctx=ctx);
                }
                let (bytecode_len) = IAccount.bytecode_len(
                    contract_address=ctx.starknet_contract_address
                );
                let is_eao = ExecutionContext.is_caller_eoa(self=ctx);
                // If the starknet contract of the execution context has no bytecode and is not an EOA,
                // then it means we are at the end of a CREATE/CREATE2 opcode.
                if (bytecode_len + is_eao == 0) {
                    let ctx = CreateHelper.finalize_calling_context(ctx);
                    return run(ctx=ctx);
                } else {
                    let ctx = CallHelper.finalize_calling_context(ctx);
                    return run(ctx=ctx);
                }
            }
        }

        // Continue execution
        return run(ctx=ctx);
    }
@github-project-automation github-project-automation bot moved this to 🆕 Backlog in Kakarot on Starknet Aug 29, 2023
@Eikix Eikix added this to the Official Ethereum Conformance milestone Aug 29, 2023
@greged93 greged93 added the evm bug Something related to normal EVM execution isn't working label Sep 2, 2023
@github-project-automation github-project-automation bot moved this from 🆕 Backlog to ✅ Done in Kakarot on Starknet Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
evm bug Something related to normal EVM execution isn't working
Projects
No open projects
Archived in project
Development

No branches or pull requests

3 participants