Skip to content

MultiExceptionTests #1838

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

Open
3 tasks done
amkCha opened this issue Feb 20, 2025 · 1 comment · May be fixed by #1978
Open
3 tasks done

MultiExceptionTests #1838

amkCha opened this issue Feb 20, 2025 · 1 comment · May be fixed by #1978
Assignees
Labels

Comments

@amkCha
Copy link
Collaborator

amkCha commented Feb 20, 2025

Follow up on the OOGX task #1783

MultiExceptionsTest could have a simple test where one triggers simultaneously

staticException
outOfGasException

or

staticException
stackUnderflowException

One needs two smart contracts with byte code

BytecodeCompiler simpleLog0 = BytecodeCompiler.newProgram();
simpleLog0.push(0).push(0).op(LOG0);

BytecodeCompiler stackUnderflowLog0 = BytecodeCompiler.newProgram();
stackUnderflowLog0.push(0).op(LOG0);

Which are called upon through a STATICCALL with gas = 3 + 3 + 375 + cornerCase / gas = 3 + 375 + cornerCase.

test simultaneous exceptions, in this case:

jumpException
outOfGasException

And it would be trivial to implement, just switch the second push to

    final Bytes bytecode =
        BytecodeCompiler.newProgram()
            .push(1) // pc = 0, 1
            .push(6) // pc = 2, 3
            // ...

add a variant of the above where we do the following

program
        .push(0) // byte size of return data
        .push(0) // retOffset
        .push(0) // byte size calldata
        .push(0) // argsOffset
        .op("c0de") // address of 'return data provider' account
        .op(OpCode.GAS) // gas
        .op(OpCode.STATICCALL)
        // 3. Clean the stack
        .op(OpCode.POP)
        // 4. Doubly exceptional return data copy
        .op(OpCode.RETURNDATASIZE)
        .push(1)
        .op(OpCode.ADD); // size = RDS + 1, which will trigger the `returnDataCopyException`
        .push(0) // offset
        .push(65) // destoffset, trigger mem expansion
        .op(OpCode.RETURNDATACOPY);

We could name this test to doubleExceptionReturnDataCopyTestOogxAndRdcx. We have so far not written tests where we deliberately trigger several exceptions at once.

@OlivierBBB
Copy link
Collaborator

In terms of multi-exceptions testing we ideally produce a test for every

  • opcode that can produce 2 or more non stack exceptions
  • every subset of size 2, 3, ... of the possible (non stack) exceptions

@amkCha amkCha linked a pull request Apr 10, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants