Skip to content

Commit

Permalink
Upgrade to Java 21
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio Di Fabio <[email protected]>
  • Loading branch information
fab-10 committed Jun 11, 2024
1 parent 412af1d commit db1a18a
Show file tree
Hide file tree
Showing 51 changed files with 637 additions and 521 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
java-version: 21
distribution: temurin

- name: Build without tests
run: ./gradlew build -x test -x spotlessCheck
Expand All @@ -51,11 +51,11 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
java-version: 21
distribution: temurin

- name: Run acceptance tests
run: ./gradlew :acceptance-tests:acceptanceTests
Expand All @@ -81,11 +81,11 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
java-version: 21
distribution: temurin

- name: Run libcompress JNI tests
run: ./gradlew :native:compress:test
Expand All @@ -105,11 +105,11 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
java-version: 21
distribution: temurin

- name: Run unit tests
run: ./gradlew :arithmetization:test
Expand All @@ -130,7 +130,7 @@ jobs:
- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: adopt
java-version: 17
distribution: temurin
java-version: 21
- name: spotless
run: ./gradlew --no-daemon --parallel clean spotlessCheck
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
java-version: 21
distribution: temurin
cache: 'gradle'

- name: Grant execute permission for gradlew
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class BlockCapturer implements ConflationAwareOperationTracer {
* The {@link Reaper} will collect all the data that will need to be mimicked to replay the block.
*/
private final Reaper reaper = new Reaper();

/**
* This keeps a pointer to the initial state (i.e. ) to be used at the end of tracing to store the
* minimal required information to replay the conflation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@
public class Reaper {
/** Collect the reads from the state */
private final StorageReaper storage = new StorageReaper();

/** Collect the addresses read from the state */
private final AddressReaper addresses = new AddressReaper();

/** Collect the blocks within a conflation */
private final List<BlockSnapshot> blocks = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
public class LineaProfitabilityConfiguration {
/** It is safe to keep this as long, since it will store value <= max_int * 1000 */
private long fixedCostWei;

/** It is safe to keep this as long, since it will store value <= max_int * 1000 */
private long variableCostWei;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
public class CountersEndpointServicePlugin extends AbstractLineaSharedOptionsPlugin {
private BesuContext besuContext;
private RpcEndpointService rpcEndpointService;

/**
* Register the RPC service.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
public class TracesEndpointServicePlugin extends AbstractLineaSharedOptionsPlugin {
private BesuContext besuContext;
private RpcEndpointService rpcEndpointService;

/**
* Register the RPC service.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
public class BaseBytes implements HighLowBytes {
/** The size in bytes of the high and low sections of the 256-bit block. */
private static final int LOW_HIGH_SIZE = 16;

/**
* The mutable `Bytes32` object that stores the 256-bit block of data. Equals and hashCode must
* only be computed on the numeric value wrapped by this class, so that sets of operations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
public class StackedList<E extends ModuleOperation> implements List<E>, StackedContainer {

private final LinkedList<CountedList<E>> lists = new LinkedList<>();

/** The cached number of elements in this container */
private int totalSize;

Expand Down Expand Up @@ -239,8 +240,10 @@ public List<E> subList(int fromIndex, int toIndex) {
private static class StackedListIterator<F extends ModuleOperation>
implements Iterator<F>, ListIterator<F> {
private final StackedList<F> sl;

/** Position of the iterator in the list of lists */
private int head = 0;

/** Position of the iterator within the current list, i.e. this.sl.lists[head] */
private int offset = -1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class EcDataOperation extends ModuleOperation {

private final int ecType;
private final int nRows;

/** -1 if no switch off (i.e. preliminary checks passed) */
private int hurdleSwitchOffRow;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,9 @@ public static AbstractExtCalculator create(OpCode opCode) {
return switch (opCode) {
case MULMOD -> new MulModCalculator();
case ADDMOD -> new AddModCalculator();
default -> throw new RuntimeException(
"Incompatible instruction for extended modular arithmetic module");
default ->
throw new RuntimeException(
"Incompatible instruction for extended modular arithmetic module");
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public final class Bytecode {

/** The bytecode. */
private final Bytes bytecode;

/** The bytecode hash; is null by default and computed & memoized on the fly when required. */
private Hash hash;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public void reset() {
public boolean stackException() {
return this.stackUnderflow() || this.stackOverflow();
}

/**
* @return true if no stack exception has been raised
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -957,26 +957,29 @@ void traceOperation(MessageFrame frame) {

switch (this.opCodeData().instructionFamily()) {
case ADD,
MOD,
MUL,
SHF,
BIN,
WCP,
EXT,
BATCH,
MACHINE_STATE,
PUSH_POP,
DUP,
SWAP,
HALT,
INVALID -> this.addTraceSection(new StackOnlySection(this));
MOD,
MUL,
SHF,
BIN,
WCP,
EXT,
BATCH,
MACHINE_STATE,
PUSH_POP,
DUP,
SWAP,
HALT,
INVALID ->
this.addTraceSection(new StackOnlySection(this));
case KEC -> {
this.addTraceSection(
new KeccakSection(this, this.currentFrame(), new MiscFragment(this, frame)));
}
case CONTEXT, LOG -> this.addTraceSection(
new ContextLogSection(
this, new ContextFragment(this.callStack, this.currentFrame(), updateReturnData)));
case CONTEXT, LOG ->
this.addTraceSection(
new ContextLogSection(
this,
new ContextFragment(this.callStack, this.currentFrame(), updateReturnData)));
case ACCOUNT -> {
TraceSection accountSection = new AccountSection(this);
if (this.opCodeData().stackSettings().flag1()) {
Expand Down Expand Up @@ -1034,17 +1037,18 @@ void traceOperation(MessageFrame frame) {
}
this.addTraceSection(copySection);
}
case TRANSACTION -> this.addTraceSection(
new TransactionSection(
this,
TransactionFragment.prepare(
this.conflation.number(),
frame.getMiningBeneficiary(),
this.tx.transaction(),
true,
frame.getGasPrice(),
frame.getBlockValues().getBaseFee().orElse(Wei.ZERO),
this.tx.initialGas())));
case TRANSACTION ->
this.addTraceSection(
new TransactionSection(
this,
TransactionFragment.prepare(
this.conflation.number(),
frame.getMiningBeneficiary(),
this.tx.transaction(),
true,
frame.getGasPrice(),
frame.getBlockValues().getBaseFee().orElse(Wei.ZERO),
this.tx.initialGas())));
case STACK_RAM -> {
switch (this.currentFrame().opCode()) {
case CALLDATALOAD -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@
@Accessors(fluent = true)
public class PlatformController {
private final Hub hub;

/** What other modules should be triggered for the current operation */
@Getter private final Signals signals;

/** The exceptions raised during the execution of the current operation */
@Getter private final Exceptions exceptions;

/** The aborting conditions raised during the execution of the current operation */
@Getter private final AbortingConditions aborts;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
public class TxTrace {
/** The {@link TraceSection} of which this transaction trace is made of */
@Getter private final List<TraceSection> trace = new ArrayList<>();

/** A cache for the line count of this transaction */
private int cachedLineCount = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
public class DeferRegistry {
/** A list of actions deferred until the end of the current transaction */
private final List<PostTransactionDefer> txDefers = new ArrayList<>();

/** A list of actions deferred until the end of the current opcode execution */
private final List<PostExecDefer> postExecDefers = new ArrayList<>();

/** A list of actions deferred until the end of the current opcode execution */
private final List<Pair<Integer, NextContextDefer>> contextReentry = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ private StackFragment(
switch (this.opCode) {
case SHA3 -> exceptions.none() && gp.messageSize() > 0;
case RETURN -> exceptions.none() && gp.messageSize() > 0 && isDeploying;
case CREATE2 -> exceptions.none()
&& contextExceptions.none()
&& aborts.none()
&& gp.messageSize() > 0;
case CREATE2 ->
exceptions.none()
&& contextExceptions.none()
&& aborts.none()
&& gp.messageSize() > 0;
default -> false;
};
this.hashInfoSize = this.hashInfoFlag ? gp.messageSize() : 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public Trace trace(Trace trace) {

/** Count the stack lines */
@Getter private int stackRowsCounter;

/** Count the non-stack lines */
private int nonStackRowsCounter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class L2Block implements Module {

/** The byte size of the RLP-encoded transaction of the conflation */
@Getter private final Deque<Integer> sizesRlpEncodedTxs = new ArrayDeque<>();

/** The byte size of the L2->L1 logs messages of the conflation */
@Getter private final Deque<List<Integer>> l2l1LogSizes = new ArrayDeque<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public void tracePreOpcode(MessageFrame frame) {
long dataByteLength = 0;
switch (opCode) {
case CALL, CALLCODE -> dataByteLength = Words.clampedToLong(frame.getStackItem(4));
case DELEGATECALL, STATICCALL -> dataByteLength =
Words.clampedToLong(frame.getStackItem(3));
case DELEGATECALL, STATICCALL ->
dataByteLength = Words.clampedToLong(frame.getStackItem(3));
}

if (dataByteLength == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public void tracePreOpcode(MessageFrame frame) {
long dataByteLength = 0;
switch (opCode) {
case CALL, CALLCODE -> dataByteLength = Words.clampedToLong(frame.getStackItem(4));
case DELEGATECALL, STATICCALL -> dataByteLength =
Words.clampedToLong(frame.getStackItem(3));
case DELEGATECALL, STATICCALL ->
dataByteLength = Words.clampedToLong(frame.getStackItem(3));
}
if (dataByteLength == 0) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ public void traceLog(
.dataLo(topic4.slice(16, 16).toUnsignedBigInteger())
.validateRow();
}
default -> throw new IllegalArgumentException(
"ct = " + ct + " greater than ctMax =" + ctMax);
default ->
throw new IllegalArgumentException("ct = " + ct + " greater than ctMax =" + ctMax);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ public MicroData dispatch(
microData.microOp(MmuTrace.FullStackToRam);
}
}
default -> throw new IllegalArgumentException(
"Opcode %s is not supported for type 1 pre-computation".formatted(opCode));
default ->
throw new IllegalArgumentException(
"Opcode %s is not supported for type 1 pre-computation".formatted(opCode));
}

return microData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,10 @@ public MicroData preProcess(final MicroData microData, final CallStack callStack
microData.exoIsRom(true);
microData.exoIsHash(true);
}
default -> throw new UnsupportedOperationException(
"OpCode.%s is not supported for MMU type 3 pre-processing."
.formatted(microData.opCode()));
default ->
throw new UnsupportedOperationException(
"OpCode.%s is not supported for MMU type 3 pre-processing."
.formatted(microData.opCode()));
}

return microData;
Expand Down
Loading

0 comments on commit db1a18a

Please sign in to comment.