evmone icon indicating copy to clipboard operation
evmone copied to clipboard

How to implement EIP-2681?

Open samlior opened this issue 3 years ago • 3 comments

I'm trying to get evmone to pass all the tests in ethereum/tests, but currently I find that evmone can't pass this test. After debugging, I found out that this is because EIP-2681 is not implemented. However EIP-2681 doesn't seem to be possible implemented via evmc_host_inferface.

So I made some changes to evmc_host_inferface, added a function to check if the nonce is too high, and made the following changes in create_impl:

template <evmc_opcode Op>
evmc_status_code create_impl(StackTop stack, ExecutionState& state) noexcept
{
    //...

    stack.push(0);
    state.return_data.clear();

    if (!state.host.eip2681_check_nonce(state.msg->recipient)) // EIP-2681
        return EVMC_SUCCESS;

    if (state.msg->depth >= 1024)
        return EVMC_SUCCESS;

    //...
}

The test passed, and it worked fine.

What do you think about this problem, is there a better solution?

samlior avatar Sep 29 '22 06:09 samlior

Currently evmone does not have access to account nonce so it cannot perform this check. However, the Host implementation can check it in the call() method.

Here is the WIP state test execution tool which does this: https://github.com/ethereum/evmone/blob/state/test/state/host.cpp#L154-L160.

chfast avatar Oct 20 '22 17:10 chfast

Thank you for your explanation, looking forward to this feature release.

samlior avatar Oct 21 '22 03:10 samlior

This should land within a month. But if you want to play with it already you can build evmone-statetest from the state. branch.

chfast avatar Oct 21 '22 07:10 chfast