Skip to content

EVM/Exec: Wrong stack depth in evm_execution

Arnaud Bihan requested to merge arnaud@functori@good_stack_depth into master

Context

I was debugging a test that ended with a CallTooDeep (this one LoopCallsDepthThenRevert3.json).

It test that at stack depth 1022 it can creates 2 contract before reverting and that their nonce are updated accordingly. But it seemed that the CallTooDeep error was triggered too soon.

So I checked for the stack depth function and find out that there is an error in the stack depth computation. Stack depth is used for the evm to know when to stop, so when entering the evm execution, stack depth should be set to 0. But because stack depth is relying on the number of layer and as said in the comment of the stack_depth function the last layer is not an execution layer for the evm.

So this layer (the default one) should not be taken in the stack depth computation.

Manually testing the MR

stCreate2_Create2OnDepth1023_data_index_0_gas_index_0_value_index_0: Failure -> Success
stEIP1559_gasPriceDiffPlaces_data_index_34_gas_index_0_value_index_0: Failure -> Success
stCallCreateCallCodeTest_CallRecursiveBombPreCall_data_index_0_gas_index_0_value_index_0: Failure -> Success
stCallCreateCallCodeTest_Call1024BalanceTooLow_data_index_0_gas_index_0_value_index_0: Failure -> Success
stEIP1559_baseFeeDiffPlaces_data_index_34_gas_index_0_value_index_0: Failure -> Success
stRevertTest_LoopCallsDepthThenRevert2_data_index_0_gas_index_0_value_index_0: Failure -> Success
stCallCreateCallCodeTest_Callcode1024BalanceTooLow_data_index_0_gas_index_0_value_index_0: Failure -> Success
stDelegatecallTestHomestead_CallRecursiveBombPreCall_data_index_0_gas_index_0_value_index_0: Failure -> Success
stCreate2_Create2OnDepth1024_data_index_0_gas_index_0_value_index_0: Failure -> Success
stSelfBalance_diffPlaces_data_index_34_gas_index_0_value_index_0: Failure -> Success
stStaticCall_static_Call1024PreCalls2_data_index_0_gas_index_0_value_index_0: Failure -> Success
stDelegatecallTestHomestead_Call1024BalanceTooLow_data_index_0_gas_index_0_value_index_0: Failure -> Success
stDelegatecallTestHomestead_Delegatecall1024_data_index_0_gas_index_0_value_index_0: Failure -> Success

Here is the diff, the test that are fixed are not the one that I was working on but they are related to multiple call to reach the end of the stack

Checklist

  • Document the interface of any function added or modified (see the coding guidelines)
  • Document any change to the user interface, including configuration parameters (see node configuration)
  • Provide automatic testing (see the testing guide).
  • For new features and bug fixes, add an item in the appropriate changelog (docs/protocols/alpha.rst for the protocol and the environment, CHANGES.rst at the root of the repository for everything else).
  • Select suitable reviewers using the Reviewers field below.
  • Select as Assignee the next person who should take action on that MR
Edited by Arnaud Bihan

Merge request reports