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

test(CALL): zero size, huge return at offset, huge call data offset, huge return data offset #1448

Open
wants to merge 20 commits into
base: arith-dev
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d5a44f3
test(mxp): add testMxpRandomAdvancedWithFixedSeed
lorenzogentile404 Oct 22, 2024
6f4a136
fix(mxp): filter out RETURN and REVERT when testing against large off…
lorenzogentile404 Oct 22, 2024
0fd68d2
fix(mxp): revert wrong fix
lorenzogentile404 Oct 22, 2024
1f3d4ca
test(mxp): add print
lorenzogentile404 Oct 22, 2024
cab035d
test(mxp): add failing tests for debugging purposes
lorenzogentile404 Oct 22, 2024
8833f5a
fix: OperationAncillaries outputDataSpan
lorenzogentile404 Oct 23, 2024
bc80f91
test: add docs
lorenzogentile404 Oct 23, 2024
f3a9d26
fix: returnDataRequestedSegment
lorenzogentile404 Oct 23, 2024
65b48a8
fix(operationAncillaries): return at offset and return at capacity
lorenzogentile404 Oct 25, 2024
cb1ace9
Merge branch 'arith-dev' into 1444-failing-tests-for-testmxprandomadv…
OlivierBBB Oct 31, 2024
1bc1a35
typo
lorenzogentile404 Nov 4, 2024
f84f1fe
Merge branch 'arith-dev' into 1444-failing-tests-for-testmxprandomadv…
OlivierBBB Nov 4, 2024
ce175a0
Merge branch 'arith-dev' into 1444-failing-tests-for-testmxprandomadv…
lorenzogentile404 Nov 9, 2024
0e02378
Merge branch 'arith-dev' into 1444-failing-tests-for-testmxprandomadv…
letypequividelespoubelles Nov 15, 2024
1770b48
Merge branch 'arith-dev' into 1444-failing-tests-for-testmxprandomadv…
lorenzogentile404 Nov 15, 2024
c7f3bec
Merge branch 'arith-dev' into 1444-failing-tests-for-testmxprandomadv…
lorenzogentile404 Nov 28, 2024
3a67df5
docs: remove useless comment
lorenzogentile404 Nov 28, 2024
3089801
Merge branch 'arith-dev' into 1444-failing-tests-for-testmxprandomadv…
lorenzogentile404 Nov 29, 2024
d9f9e3b
Merge branch 'arith-dev' into 1444-failing-tests-for-testmxprandomadv…
lorenzogentile404 Dec 11, 2024
596b990
Merge branch 'arith-dev' into 1444-failing-tests-for-testmxprandomadv…
lorenzogentile404 Dec 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*
* Copyright ConsenSys Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/

package net.consensys.linea.zktracer.module.hub;

import java.util.List;

import net.consensys.linea.testing.BytecodeCompiler;
import net.consensys.linea.testing.BytecodeRunner;
import net.consensys.linea.testing.ToyAccount;
import net.consensys.linea.zktracer.opcode.OpCode;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.junit.jupiter.api.Test;

public class ZeroSizeCallDataOrReturnDataTest {

@Test
void zeroSizeHugeReturnAtOffsetTest() {
BytecodeCompiler program = BytecodeCompiler.newProgram();
program
.push(0) // return at capacity
.push("ff".repeat(32)) // return at offset
.push(0) // call data size
.push(0) // call data offset
.push("ca11ee") // address
.push(1000) // gas
.op(OpCode.STATICCALL);

BytecodeCompiler calleeProgram = BytecodeCompiler.newProgram();
calleeProgram.op(OpCode.CALLDATASIZE);

final ToyAccount calleeAccount =
ToyAccount.builder()
.balance(Wei.fromEth(1))
.nonce(10)
.address(Address.fromHexString("ca11ee"))
.code(calleeProgram.compile())
.build();

BytecodeRunner.of(program.compile()).run(Wei.fromEth(1), 30000L, List.of(calleeAccount));
}

@Test
void zeroSizeHugeCallDataOffsetTest() {
BytecodeCompiler program = BytecodeCompiler.newProgram();
program
.push(0) // return at capacity
.push(0) // return at offset
.push(0) // call data size
.push("ff".repeat(32)) // call data offset
.push("ca11ee") // address
.push(1000) // gas
.op(OpCode.STATICCALL);

BytecodeCompiler calleeProgram = BytecodeCompiler.newProgram();
calleeProgram.op(OpCode.CALLDATASIZE);

final ToyAccount calleeAccount =
ToyAccount.builder()
.balance(Wei.fromEth(1))
.nonce(10)
.address(Address.fromHexString("ca11ee"))
.code(calleeProgram.compile())
.build();

BytecodeRunner.of(program.compile()).run(Wei.fromEth(1), 30000L, List.of(calleeAccount));
}

@Test
void zeroSizeHugeReturnDataOffsetTest() {
BytecodeCompiler program = BytecodeCompiler.newProgram();
program
.push(0) // return at capacity
.push(0) // return at offset
.push(0) // call data size
.push(0) // call data offset
.push("ca11ee") // address
.push(1000) // gas
.op(OpCode.STATICCALL);

BytecodeCompiler calleeProgram = BytecodeCompiler.newProgram();
calleeProgram.push(0).push("ff".repeat(32)).op(OpCode.RETURN);

final ToyAccount calleeAccount =
ToyAccount.builder()
.balance(Wei.fromEth(1))
.nonce(10)
.address(Address.fromHexString("ca11ee"))
.code(calleeProgram.compile())
.build();

BytecodeRunner.of(program.compile()).run(Wei.fromEth(1), 30000L, List.of(calleeAccount));
}
}
Loading