-
Notifications
You must be signed in to change notification settings - Fork 40
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
Extensive OOGX
tests involving memory expansion + gas estimation tool BytecodeRunner.runOnlyForGasCost
+ MSIZE
(#1783)
#1783
Conversation
4fe31f2
to
f449242
Compare
7e06004
to
af937c1
Compare
...hmetization/src/test/java/net/consensys/linea/zktracer/exceptions/OutOfGasExceptionTest.java
Show resolved
Hide resolved
...hmetization/src/test/java/net/consensys/linea/zktracer/exceptions/OutOfGasExceptionTest.java
Outdated
Show resolved
Hide resolved
...hmetization/src/test/java/net/consensys/linea/zktracer/exceptions/OutOfGasExceptionTest.java
Outdated
Show resolved
Hide resolved
...hmetization/src/test/java/net/consensys/linea/zktracer/exceptions/OutOfGasExceptionTest.java
Show resolved
Hide resolved
...hmetization/src/test/java/net/consensys/linea/zktracer/exceptions/OutOfGasExceptionTest.java
Show resolved
Hide resolved
.op(OpCode.MSIZE) | ||
.push(0xFF) | ||
.push(1) // expand memory | ||
.op(OpCode.MSTORE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Obvious remark: both MSTORE
's expand memory, the first to size 0x20
, the second to size 0x40
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, it felt better to go from a non-zero value to a non-zero value, but it's strictly the same behavior. Let me simplify it 👍
...ation/src/test/java/net/consensys/linea/zktracer/exceptions/OutOfGasMemExpExceptionTest.java
Outdated
Show resolved
Hide resolved
bytecodeRunner.run(Wei.fromEth(1), gasCost + cornerCase, List.of(), calldata); | ||
if (cornerCase == -1) { | ||
assertEquals( | ||
OUT_OF_GAS_EXCEPTION, | ||
bytecodeRunner.getHub().previousTraceSection().commonValues.tracedException()); | ||
} else { | ||
assertNotEquals( | ||
OUT_OF_GAS_EXCEPTION, | ||
bytecodeRunner.getHub().previousTraceSection().commonValues.tracedException()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This paragraph could be extracted into a method I imagine ? It's duplicated quite a number of times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, I created a Utils method 👌
...ation/src/test/java/net/consensys/linea/zktracer/exceptions/OutOfGasMemExpExceptionTest.java
Show resolved
Hide resolved
...ation/src/test/java/net/consensys/linea/zktracer/exceptions/OutOfGasMemExpExceptionTest.java
Outdated
Show resolved
Hide resolved
...ation/src/test/java/net/consensys/linea/zktracer/exceptions/OutOfGasMemExpExceptionTest.java
Show resolved
Hide resolved
...ation/src/test/java/net/consensys/linea/zktracer/exceptions/OutOfGasMemExpExceptionTest.java
Show resolved
Hide resolved
...ation/src/test/java/net/consensys/linea/zktracer/exceptions/OutOfGasMemExpExceptionTest.java
Show resolved
Hide resolved
...ation/src/test/java/net/consensys/linea/zktracer/exceptions/OutOfGasMemExpExceptionTest.java
Show resolved
Hide resolved
|
||
@ParameterizedTest | ||
@ValueSource(ints = {-1, 0, 1}) | ||
void outOfGasExceptionJumpi(int cornerCase) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, too, we have the opportunity to 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
// ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would make sense to create a new class for these MultiExceptionTests
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which would include the RETURNDATACOPY
double exception test mentioned earlier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue created for MultiExceptionTests
#1838
...ation/src/test/java/net/consensys/linea/zktracer/exceptions/OutOfGasMemExpExceptionTest.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left several comments
bb84d5e
to
ca1f209
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
OOGX
tests involving memory expansion + gas estimation tool BytecodeRunner.runOnlyForGasCost
+ MSIZE
(#1783)
Closes #1685
BytecodeRunner.runOnlyForGasCost
Method to calculate cost dynamically - based on LondonGasCalculator (Besu)opCodeToOpCodeDataMap.values()
without opcodes with mem expansion costLocal benchmark done on 366 tests with
BytecodeRunner.run
twice 2min50sTest coverage improvement
+7 lines covered
+4 conditions covered
Results
+0.3% condition coverage on Unit tests
+0.1% overall coverage score (with blockchain ref tests)