How to implement EIP-2681?
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?
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.
Thank you for your explanation, looking forward to this feature release.
This should land within a month. But if you want to play with it already you can build evmone-statetest from the state. branch.