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

MultiExceptionTests #1838

Open
3 tasks
amkCha opened this issue Feb 20, 2025 · 0 comments
Open
3 tasks

MultiExceptionTests #1838

amkCha opened this issue Feb 20, 2025 · 0 comments
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant