Skip to content

Commit

Permalink
Merge branch 'arith-dev' into gauravahuja/skip_blockchain_tests_high_…
Browse files Browse the repository at this point in the history
…memory
  • Loading branch information
gauravahuja committed Oct 15, 2024
2 parents 12e9b83 + 3265a70 commit 723a3e1
Show file tree
Hide file tree
Showing 19 changed files with 495 additions and 407 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/reference-blockchain-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ jobs:
commit: ${{ inputs.commit || '' }}
if_no_artifact_found: ignore

- name: Rename filter input file
if: ${{ inputs.failed_module != '' }}
run: mv ${{ github.workspace }}/tmp/${{ steps.extract_branch.outputs.branch }}/failedBlockchainReferenceTests.json ${{ github.workspace }}/tmp/${{ steps.extract_branch.outputs.branch }}/failedBlockchainReferenceTests-input.json

- name: Run reference blockchain tests
run: ./gradlew referenceBlockchainTests -x spotlessCheck
timeout-minutes: 180
Expand All @@ -82,6 +86,7 @@ jobs:
FAILED_TEST_JSON_DIRECTORY: ${{ github.workspace }}/tmp/${{ steps.extract_branch.outputs.branch }}/
FAILED_MODULE: ${{ inputs.failed_module || '' }}
FAILED_CONSTRAINT: ${{ inputs.failed_constraint || '' }}
REFERENCE_TEST_FILTER_INPUT: failedBlockchainReferenceTests.json

- name: Upload artifact
uses: actions/upload-artifact@v4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,8 @@ public void resolveUponContextReEntry(Hub hub, CallFrame callFrame) {
contextReEntryDefers.remove(callFrame);
}
}

public void unscheduleForContextReEntry(ContextReEntryDefer defer, CallFrame callFrame) {
contextReEntryDefers.get(callFrame).remove(defer);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public ModexpSubsection(final Hub hub, final CallSection callSection) {
.compareTo(BigInteger.valueOf(PROVER_MAX_INPUT_BYTE_SIZE))
>= 0) {
hub.modexpEffectiveCall().addPrecompileLimit(Integer.MAX_VALUE);
hub.defers().unscheduleForContextReEntry(this, hub.currentFrame());
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public String moduleKey() {
@Override
public void addPrecompileLimit(final int count) {
Preconditions.checkArgument(
count == 1, "can't add more than one effective precompile call at a time");
count == 1 || count == Integer.MAX_VALUE,
"Either use 1 for one effective precompile call at a time or use Integer.MAX_VALUE");
counts.add(count);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,23 @@ public void oneToOnePadded(
final short targetByteOffset,
final short size) {

checkArgument(0 <= sourceByteOffset && sourceByteOffset <= LLARGEMO);
checkArgument(0 < size && size <= LLARGE);
checkArgument(sourceByteOffset + size - 1 <= LLARGEMO);
checkArgument(0 <= targetByteOffset && targetByteOffset <= LLARGEMO);
checkArgument(targetByteOffset + size - 1 <= LLARGEMO);
checkArgument(
0 <= sourceByteOffset && sourceByteOffset <= LLARGEMO,
"sourceByteOffset has value {}.",
sourceByteOffset);
checkArgument(0 < size && size <= LLARGE, "size has value {}.", size);
checkArgument(
sourceByteOffset + size - 1 <= LLARGEMO,
"sourceByteOffset has value {}.",
sourceByteOffset);
checkArgument(
0 <= targetByteOffset && targetByteOffset <= LLARGEMO,
"targetByteOffset has value {}.",
targetByteOffset);
checkArgument(
targetByteOffset + size - 1 <= LLARGEMO,
"targetByteOffset has value {}.",
targetByteOffset);

for (short ct = 0; ct < LLARGE; ct++) {
bit1.add(ct, plateau(sourceByteOffset, ct));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,10 +542,10 @@ private BigInteger callToMOD(
private boolean callToLT(
int k, BigInteger arg1Hi, BigInteger arg1Lo, BigInteger arg2Hi, BigInteger arg2Lo) {
// 128 = 8 * 16
checkArgument(arg1Hi.bitLength() <= 128);
checkArgument(arg1Lo.bitLength() <= 128);
checkArgument(arg2Hi.bitLength() <= 128);
checkArgument(arg2Lo.bitLength() <= 128);
checkArgument(arg1Hi.bitLength() <= 128, "arg1Hi.bitLength() has length " + arg1Hi.bitLength());
checkArgument(arg1Lo.bitLength() <= 128, "arg1Lo.bitLength() has length " + arg1Lo.bitLength());
checkArgument(arg2Hi.bitLength() <= 128, "arg2Hi.bitLength() has length " + arg2Hi.bitLength());
checkArgument(arg2Lo.bitLength() <= 128, "arg2Lo.bitLength() has length " + arg2Lo.bitLength());
final EWord arg1 = EWord.of(arg1Hi, arg1Lo);
final EWord arg2 = EWord.of(arg2Hi, arg2Lo);
addFlag[k] = false;
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/groovy/RefTestGenerationTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ abstract class RefTestGenerationTask extends DefaultTask {
def parentPathFile = parentFile.getPath().substring(parentFile.getPath().indexOf(refTestJsonParamsDirectory))
if (!testJsonFile.getName().toString().startsWith(".") && !excludedPath.contains(parentPathFile)) {
def pathFile = testJsonFile.getPath()
paths << pathFile.substring(pathFile.indexOf(refTestJsonParamsDirectory))
paths << pathFile.substring(pathFile.indexOf(refTestJsonParamsDirectory)).replace('\\','/')
}
}

Expand Down
1 change: 1 addition & 0 deletions reference-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,5 @@ dependencies {
implementation project(":arithmetization")
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml'
testImplementation project(path: ':testing')
implementation 'org.junit.platform:junit-platform-launcher:1.11.2'
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
*/
package net.consensys.linea;

import java.io.FileWriter;
import static net.consensys.linea.ReferenceTestOutcomeRecorderTool.setFileDirectory;

import java.io.IOException;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
Expand All @@ -27,14 +28,14 @@

@Slf4j
public class BlockchainReferenceTestJson {
static String fileDirectory = setFileDirectory();

@Synchronized
public static CompletableFuture<String> readBlockchainReferenceTestsOutput(String fileName) {
String fileDirectory = setFileDirectory();
return CompletableFuture.supplyAsync(
() -> {
Path directoryPath = Paths.get(fileDirectory);
Path filePath = Paths.get(fileDirectory + fileName);
Path filePath = directoryPath.resolve(fileName);
String jsonString = "";

try {
Expand Down Expand Up @@ -62,24 +63,4 @@ public static CompletableFuture<String> readBlockchainReferenceTestsOutput(Strin
return jsonString;
});
}

@Synchronized
public static CompletableFuture<Void> writeToJsonFile(String jsonString, String fileName) {
return CompletableFuture.runAsync(
() -> {
try (FileWriter file = new FileWriter(fileDirectory + fileName)) {
file.write(jsonString);
} catch (Exception e) {
log.error("Error - Failed to write failed test output: %s".formatted(e.getMessage()));
}
});
}

private static String setFileDirectory() {
String jsonDirectory = System.getenv("FAILED_TEST_JSON_DIRECTORY");
if (jsonDirectory == null || jsonDirectory.isEmpty()) {
return "../tmp/local/";
}
return jsonDirectory;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,27 @@
*/
package net.consensys.linea;

import java.util.List;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentSkipListSet;

import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import lombok.AllArgsConstructor;
import lombok.Getter;

@JsonPropertyOrder({"failedCounter", "successCounter", "modules"})
public record BlockchainReferenceTestOutcome(
int failedCounter, int successCounter, List<ModuleToConstraints> modulesToConstraints) {}
@Getter
@AllArgsConstructor
@JsonPropertyOrder({
"failedCounter",
"successCounter",
"disabledCounter",
"abortedCounter",
"modules"
})
public class BlockchainReferenceTestOutcome {
private final int failedCounter;
private final int successCounter;
private final int disabledCounter;
private final int abortedCounter;
private final ConcurrentMap<String, ConcurrentMap<String, ConcurrentSkipListSet<String>>>
modulesToConstraintsToTests;
}

This file was deleted.

Loading

0 comments on commit 723a3e1

Please sign in to comment.