Skip to content

Commit

Permalink
Merge branch 'arith-dev' into feat/issue-1395/modules-to-count
Browse files Browse the repository at this point in the history
  • Loading branch information
powerslider committed Oct 9, 2024
2 parents 16248a8 + 349d5be commit ed776d7
Show file tree
Hide file tree
Showing 20 changed files with 201 additions and 189 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/gradle-ethereum-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:

jobs:
ethereum-tests:
runs-on: ubuntu-latest-128
runs-on: [self-hosted, Linux, X64, xxlarge]
steps:
- uses: webfactory/[email protected]
with:
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:


ethereum-tests-go-corset:
runs-on: ubuntu-latest-128
runs-on: [self-hosted, Linux, X64, xxlarge]
steps:
- uses: webfactory/[email protected]
with:
Expand Down Expand Up @@ -88,6 +88,8 @@ jobs:

- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.23.1

- name: Install Go Corset
run: go install github.com/consensys/go-corset/cmd/go-corset@latest
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/gradle-nightly-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:

jobs:
nightly-tests:
runs-on: ubuntu-latest-128
runs-on: [self-hosted, Linux, X64, xxlarge]
steps:
- uses: webfactory/[email protected]
with:
Expand All @@ -35,6 +35,8 @@ jobs:

- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.23.1

- name: Install Go Corset
run:
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/gradle-weekly-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:

jobs:
tests:
runs-on: ubuntu-latest
runs-on: [self-hosted, Linux, X64, medium]
steps:
- uses: webfactory/[email protected]
with:
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
path: build/reports/tests/**/*

go-corset-tests:
runs-on: ubuntu-latest
runs-on: [self-hosted, Linux, X64, medium]
continue-on-error: true
steps:
- uses: webfactory/[email protected]
Expand All @@ -75,6 +75,8 @@ jobs:

- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.23.1

- name: Install Go Corset
run:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gradle-wrapper-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push, pull_request]
jobs:
validation:
name: "Validation"
runs-on: ubuntu-latest
runs-on: [self-hosted, Linux, X64, small]
steps:
- uses: actions/checkout@v3
- uses: gradle/wrapper-validation-action@v1
10 changes: 7 additions & 3 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ env:

jobs:
build:
runs-on: ubuntu-latest
runs-on: [self-hosted, Linux, X64, large]
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.23.1

- name: Set up GCC
uses: egor-tensin/setup-gcc@v1
Expand Down Expand Up @@ -52,7 +54,7 @@ jobs:

tests:
needs: [ build ]
runs-on: ubuntu-latest-32
runs-on: [self-hosted, Linux, X64, large]
steps:
- name: Setup upterm session
if: ${{ inputs.tests-with-ssh }}
Expand Down Expand Up @@ -105,7 +107,7 @@ jobs:

go-corset-tests:
needs: [ build ]
runs-on: ubuntu-latest-32
runs-on: [self-hosted, Linux, X64, large]
continue-on-error: true
steps:
- name: Setup upterm session
Expand Down Expand Up @@ -138,6 +140,8 @@ jobs:

- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.23.1

- name: Install Go Corset
run:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/reference-blockchain-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:

jobs:
blockchain-reference-tests:
runs-on: [ubuntu-latest-128]
runs-on: [self-hosted, Linux, X64, xxlarge]
steps:
- uses: webfactory/[email protected]
with:
Expand Down Expand Up @@ -50,6 +50,8 @@ jobs:

- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.23.1

- name: Install Go Corset
run: go install github.com/consensys/go-corset/cmd/go-corset@latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: [self-hosted, Linux, X64, medium]

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -56,7 +56,7 @@ jobs:
publish:
needs: build
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
runs-on: [self-hosted, Linux, X64, medium]
env:
architecture: "amd64"
GRADLE_OPTS: "-Xmx6g -Dorg.gradle.parallel=true -Dorg.gradle.workers.max=4"
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# Changelog

## 0.8.0-rc3
## 0.8.0-rc4
* Introduction of an EMPTY_STACK_ITEM singleton and associated factory ([#1383](https://github.com/Consensys/linea-tracer/pull/1383))
* Improve StackOperation memory footprint ([#1376](https://github.com/Consensys/linea-tracer/pull/1376))
* Reference Test Watcher - Extend to parse failing constraint ([#1375](https://github.com/Consensys/linea-tracer/pull/1375))

## 0.8.0-rc3
* fix: temporarily disable max block behind check on tracer readiness endpoint due to infrequent sync status updates
([#1378](https://github.com/Consensys/linea-tracer/pull/1378))
* feat: EXTCODEHASH / EXTCODESIZE tests in relation to account existence ([#1372](https://github.com/Consensys/linea-tracer/pull/1372))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import net.consensys.linea.zktracer.types.FiniteList;
import net.consensys.linea.zktracer.types.Utils;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.toml.Toml;
import org.apache.tuweni.toml.TomlTable;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.PendingTransaction;
Expand All @@ -60,7 +62,7 @@ public class ZkTracer implements ConflationAwareOperationTracer {

private static final Map<String, Integer> spillings;

private static List<Module> modulesToCount;
private static Set<String> configuredModulesToCount;

static {
try {
Expand All @@ -81,7 +83,12 @@ public class ZkTracer implements ConflationAwareOperationTracer {
/** Accumulate all the exceptions that happened at tracing time. */
@Getter private final List<Exception> tracingExceptions = new FiniteList<>(50);

public ZkTracer(final Path modulesToCountConfigFilePath) {}
public ZkTracer(final Path modulesToCountConfigFilePath) {
this(
LineaL1L2BridgeSharedConfiguration.EMPTY,
Bytes.fromHexString("c0ffee").toBigInteger().abs(),
modulesToCountConfigFilePath);
}

public ZkTracer() {
this(
Expand All @@ -90,8 +97,8 @@ public ZkTracer() {
null);
}

public ZkTracer(BigInteger nonnegativeChainId) {
this(LineaL1L2BridgeSharedConfiguration.EMPTY, nonnegativeChainId, null);
public ZkTracer(BigInteger nonNegativeChainId) {
this(LineaL1L2BridgeSharedConfiguration.EMPTY, nonNegativeChainId, null);
}

public ZkTracer(
Expand All @@ -100,18 +107,15 @@ public ZkTracer(
Path modulesToCountConfig) {
final BigInteger nonNegativeChainId = chainId.abs();

final Optional<Path> modulesToCountConfigFilePath = Optional.ofNullable(modulesToCountConfig);
if (modulesToCountConfigFilePath.isPresent() && modulesToCount == null) {
// Process TOML file

}
Set<String> configuredLineCountModuleKeys =
getConfiguredLineCountModuleKeys(modulesToCountConfig);

this.hub =
new Hub(
bridgeConfiguration.contract(),
bridgeConfiguration.topic(),
nonNegativeChainId,
modulesToCount);
configuredModulesToCount);
for (Module m : this.hub.modulesToCount()) {
if (!spillings.containsKey(m.moduleKey())) {
throw new IllegalStateException(
Expand All @@ -129,6 +133,26 @@ public ZkTracer(
debugLevel.none() ? Optional.empty() : Optional.of(new DebugMode(debugLevel, this.hub));
}

private Set<String> getConfiguredLineCountModuleKeys(final Path modulesToCountConfig) {
if (configuredModulesToCount != null) {
return configuredModulesToCount;
}

if (modulesToCountConfig != null) {
// Process TOML file
final Optional<TomlTable> table;
try {
table = Optional.ofNullable(Toml.parse(modulesToCountConfig).getTable("traces-limits"));
} catch (IOException e) {
throw new RuntimeException(e);
}

return table.map(TomlTable::keySet).orElse(null);
}

return null;
}

public void writeToFile(final Path filename) {
maybeThrowTracingExceptions();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,10 @@ public List<Module> getDefaultModulesToCount() {
public Hub(
final Address l2l1ContractAddress,
final Bytes l2l1Topic,
final BigInteger nonnegativeChainId,
final List<Module> configuredModulesToCount) {
Preconditions.checkState(nonnegativeChainId.signum() >= 0);
chainId = nonnegativeChainId;
final BigInteger nonNegativeChainId,
final Set<String> configuredModuleKeysToCount) {
Preconditions.checkState(nonNegativeChainId.signum() >= 0);
chainId = nonNegativeChainId;
l2Block = new L2Block(l2l1ContractAddress, LogTopic.of(l2l1Topic));
l2L1Logs = new L2L1Logs(l2Block);
keccak = new Keccak(ecRecoverEffectiveCall, l2Block);
Expand Down Expand Up @@ -462,7 +462,9 @@ public Hub(
.toList();

modulesToCount =
configuredModulesToCount != null ? configuredModulesToCount : getDefaultModulesToCount();
configuredModuleKeysToCount != null
? configuredModuleKeysToCount.stream().map(lineCountModuleMap::get).toList()
: getDefaultModulesToCount();
}

private Map<String, Module> initLineCountModuleMap() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@
import net.consensys.linea.zktracer.opcode.OpCode;
import net.consensys.linea.zktracer.opcode.gas.MxpType;
import net.consensys.linea.zktracer.opcode.gas.projector.GasProjection;
import net.consensys.linea.zktracer.runtime.stack.Action;
import net.consensys.linea.zktracer.runtime.stack.Stack;
import net.consensys.linea.zktracer.runtime.stack.StackOperation;
import net.consensys.linea.zktracer.runtime.stack.StackItem;
import net.consensys.linea.zktracer.types.EWord;
import net.consensys.linea.zktracer.types.UnsignedByte;
import org.apache.tuweni.bytes.Bytes;
Expand All @@ -50,7 +49,7 @@
@Accessors(fluent = true)
public final class StackFragment implements TraceFragment {
private final Stack stack;
@Getter private final List<StackOperation> stackOps;
@Getter private final List<StackItem> stackOps;
private final short exceptions;
private final long staticGas;
@Setter public boolean hashInfoFlag;
Expand All @@ -66,7 +65,7 @@ public final class StackFragment implements TraceFragment {
private StackFragment(
final Hub hub,
Stack stack,
List<StackOperation> stackOps,
List<StackItem> stackOps,
short exceptions,
AbortingConditions aborts,
GasProjection gp,
Expand Down Expand Up @@ -135,7 +134,7 @@ private StackFragment(
public static StackFragment prepare(
final Hub hub,
final Stack stack,
final List<StackOperation> stackOperations,
final List<StackItem> stackItems,
final short exceptions,
final AbortingConditions aborts,
final GasProjection gp,
Expand All @@ -145,7 +144,7 @@ public static StackFragment prepare(
return new StackFragment(
hub,
stack,
stackOperations,
stackItems,
exceptions,
aborts,
gp,
Expand Down Expand Up @@ -213,7 +212,7 @@ public Trace trace(Trace trace) {
heightTracers.get(i).apply(Bytes.ofUnsignedShort(op.height()));
valLoTracers.get(i).apply(eValue.lo());
valHiTracers.get(i).apply(eValue.hi());
popTracers.get(i).apply(op.action() == Action.POP);
popTracers.get(i).apply(op.action() == Stack.POP);
stampTracers.get(i).apply(Bytes.ofUnsignedLong(op.stackStamp()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private List<TraceFragment> makeStackFragments(final Hub hub, CallFrame f) {
StackFragment.prepare(
hub,
f.stack().snapshot(),
new StackLine().asStackOperations(),
new StackLine().asStackItems(),
hub.pch().exceptions(),
hub.pch().abortingConditions().snapshot(),
Hub.GAS_PROJECTOR.of(f.frame(), f.opCode()),
Expand All @@ -178,7 +178,7 @@ private List<TraceFragment> makeStackFragments(final Hub hub, CallFrame f) {
StackFragment.prepare(
hub,
f.stack().snapshot(),
line.asStackOperations(),
line.asStackItems(),
hub.pch().exceptions(),
hub.pch().abortingConditions().snapshot(),
Hub.GAS_PROJECTOR.of(f.frame(), f.opCode()),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
* sparse.
*
* @param i the index of the stack item within a stack line -- within [[1, 4]
* @param it the details of the {@link StackOperation} to apply to a column of a stack line
* @param it the details of the {@link StackItem} to apply to a column of a stack line
*/
record IndexedStackOperation(int i, StackOperation it) {
record IndexedStackOperation(int i, StackItem it) {
/**
* For the sake of homogeneity with the zkEVM spec, {@param i} is set with 1-based indices.
* However, these indices are used to index 0-based array; hence this sneaky conversion.
Expand Down
Loading

0 comments on commit ed776d7

Please sign in to comment.