Skip to content
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
6291128
EIP-3651-warm-coinbase
letypequividelespoubelles Apr 2, 2025
64c2de3
rebase
letypequividelespoubelles Apr 3, 2025
87bd587
wip
letypequividelespoubelles Apr 3, 2025
44ca96d
fix: ras
letypequividelespoubelles Apr 4, 2025
a320ba9
shanghai hard fork
letypequividelespoubelles Apr 4, 2025
fec753c
fix constraints
letypequividelespoubelles Apr 4, 2025
53123ca
ras
letypequividelespoubelles Apr 4, 2025
e20dd0e
Merge branch 'shanghai-hard-fork' into eip-3651-warm-coinbase
letypequividelespoubelles Apr 4, 2025
2940d24
spotless
letypequividelespoubelles Apr 4, 2025
0e946ca
Merge branch 'shanghai-hard-fork' into eip-3651-warm-coinbase
letypequividelespoubelles Apr 4, 2025
4e8ae71
add possibility to specify fork
letypequividelespoubelles Apr 7, 2025
9d31649
constraint
letypequividelespoubelles Apr 7, 2025
50c62c4
Merge branch 'shanghai-hard-fork' into eip-3651-warm-coinbase
letypequividelespoubelles Apr 7, 2025
4d9badc
feat: make the ZkTracer fork dependant
letypequividelespoubelles Apr 8, 2025
a576e20
feat: fork dependant txMetadata
letypequividelespoubelles Apr 8, 2025
ec85496
Merge branch 'shanghai-hard-fork' into eip-3651-warm-coinbase
letypequividelespoubelles Apr 8, 2025
80951d7
chore: put fork in the chain config
letypequividelespoubelles Apr 8, 2025
afa9a0f
fix: specify fork for RPC calls
letypequividelespoubelles Apr 8, 2025
f58f0da
spotless
letypequividelespoubelles Apr 8, 2025
f2c06ba
delete debug stuff
letypequividelespoubelles Apr 8, 2025
744aa55
fix: pointer to module after instantiation
letypequividelespoubelles Apr 9, 2025
79ded4f
ras
letypequividelespoubelles Apr 9, 2025
a1276fc
Merge branch 'shanghai-hard-fork' into eip-3651-warm-coinbase
letypequividelespoubelles Apr 9, 2025
5738fe1
Init section is fork dependant
letypequividelespoubelles Apr 10, 2025
942dc35
coinbase warmth at tx end
letypequividelespoubelles Apr 10, 2025
f36fb72
rollback txFinalization
letypequividelespoubelles Apr 10, 2025
3bcf05f
fix dom/sub offset are fork dependant
letypequividelespoubelles Apr 10, 2025
be3efbe
fix sender coinbase collision, warmth is fork dependant
letypequividelespoubelles Apr 10, 2025
9e6ae9e
make the constructor uses final
letypequividelespoubelles Apr 10, 2025
03c0170
Merge branch 'shanghai-hard-fork' into eip-3651-warm-coinbase
letypequividelespoubelles Apr 10, 2025
524dd21
spotless
letypequividelespoubelles Apr 10, 2025
422d8dd
ras
letypequividelespoubelles Apr 10, 2025
875f9aa
ras
letypequividelespoubelles Apr 10, 2025
4388d03
Merge branch 'arith-dev' into shanghai-hard-fork
letypequividelespoubelles Apr 11, 2025
b28fff1
Merge branch 'shanghai-hard-fork' into eip-3651-warm-coinbase
letypequividelespoubelles Apr 11, 2025
9b0e56a
set finalization section only onbce
letypequividelespoubelles Apr 11, 2025
7d6ae3d
fix account warmth for initialization section
letypequividelespoubelles Apr 11, 2025
c9da824
rebase
letypequividelespoubelles Apr 14, 2025
890ea34
Merge branch 'shanghai-hard-fork' into eip-3651-warm-coinbase
letypequividelespoubelles Apr 14, 2025
768fb8c
rebase
letypequividelespoubelles Apr 14, 2025
a274bc0
renaming following OB's review
letypequividelespoubelles Apr 14, 2025
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
Expand Up @@ -15,7 +15,7 @@

package net.consensys.linea.corset;

import static net.consensys.linea.zktracer.ChainConfig.MAINNET_TESTCONFIG;
import static net.consensys.linea.zktracer.ChainConfig.MAINNET_LONDON_TESTCONFIG;

import java.io.IOException;
import java.nio.file.Files;
Expand Down Expand Up @@ -154,7 +154,7 @@ private List<String> buildCommandLine(Path traceFile, String zkEvmBin) {
* @param options
*/
private void setChainConstants(List<String> options) {
if (chain != MAINNET_TESTCONFIG) {
if (chain != MAINNET_LONDON_TESTCONFIG) {
options.add("-Sblockdata.GAS_LIMIT_MINIMUM=" + chain.gasLimitMinimum.toString());
options.add("-Sblockdata.GAS_LIMIT_MAXIMUM=" + chain.gasLimitMaximum.toString());
if (chain.fixedGasLimitEnabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@

package net.consensys.linea.plugins;

import static net.consensys.linea.zktracer.Fork.LONDON;

import java.util.Map;

import lombok.extern.slf4j.Slf4j;
import net.consensys.linea.plugins.config.LineaL1L2BridgeSharedCliOptions;
import net.consensys.linea.plugins.config.LineaL1L2BridgeSharedConfiguration;
import net.consensys.linea.zktracer.Fork;

/** In this class we put CLI options that are shared with other plugins not defined here */
@Slf4j
Expand All @@ -45,6 +48,10 @@ public LineaL1L2BridgeSharedConfiguration l1L2BridgeSharedConfiguration() {
return l2L1;
}

public Fork fork() {
return LONDON; // TODO: IMPORTANT
}

@Override
public void start() {
super.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import net.consensys.linea.plugins.rpc.RequestLimiter;
import net.consensys.linea.plugins.rpc.Validator;
import net.consensys.linea.plugins.rpc.tracegeneration.TraceRequestParams;
import net.consensys.linea.zktracer.Fork;
import net.consensys.linea.zktracer.ZkTracer;
import net.consensys.linea.zktracer.json.JsonConverter;
import org.hyperledger.besu.plugin.ServiceManager;
Expand All @@ -48,6 +49,7 @@ public class ConflatedCountTracesV2 {
private final ServiceManager besuContext;
private final LineaL1L2BridgeSharedConfiguration l1L2BridgeSharedConfiguration;
private TraceService traceService;
private Fork fork;

public String getNamespace() {
return "linea";
Expand Down Expand Up @@ -86,6 +88,7 @@ private ConflatedLineCounts countConflation(PluginRpcRequest request) {
final long toBlock = params.endBlockNumber();
final ZkTracer tracer =
new ZkTracer(
fork,
l1L2BridgeSharedConfiguration,
BesuServiceProvider.getBesuService(besuContext, BlockchainService.class)
.getChainId()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import net.consensys.linea.plugins.config.LineaL1L2BridgeSharedConfiguration;
import net.consensys.linea.plugins.rpc.RequestLimiter;
import net.consensys.linea.plugins.rpc.Validator;
import net.consensys.linea.zktracer.Fork;
import net.consensys.linea.zktracer.ZkTracer;
import net.consensys.linea.zktracer.json.JsonConverter;
import org.hyperledger.besu.plugin.ServiceManager;
Expand All @@ -43,8 +44,8 @@ public class GenerateLineCountsV2 {
private static final Cache<Long, Map<String, Integer>> CACHE =
CacheBuilder.newBuilder().maximumSize(CACHE_SIZE).build();

private final Fork fork;
private final RequestLimiter requestLimiter;

private final ServiceManager besuContext;
private TraceService traceService;
private final LineaL1L2BridgeSharedConfiguration l1L2BridgeSharedConfiguration;
Expand Down Expand Up @@ -99,6 +100,7 @@ private LineCounts getLineCounts(PluginRpcRequest request) {
blockNumber -> {
final ZkTracer tracer =
new ZkTracer(
fork,
l1L2BridgeSharedConfiguration,
BesuServiceProvider.getBesuService(
besuContext, BlockchainService.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import net.consensys.linea.plugins.rpc.RequestLimiter;
import net.consensys.linea.plugins.rpc.Validator;
import net.consensys.linea.tracewriter.TraceWriter;
import net.consensys.linea.zktracer.Fork;
import net.consensys.linea.zktracer.ZkTracer;
import net.consensys.linea.zktracer.json.JsonConverter;
import org.hyperledger.besu.plugin.ServiceManager;
Expand All @@ -49,16 +50,19 @@ public class GenerateConflatedTracesV2 {
private final ServiceManager besuContext;
private TraceService traceService;
private final LineaL1L2BridgeSharedConfiguration l1L2BridgeSharedConfiguration;
private final Fork fork;

public GenerateConflatedTracesV2(
final ServiceManager besuContext,
final RequestLimiter requestLimiter,
final TracesEndpointConfiguration endpointConfiguration,
LineaL1L2BridgeSharedConfiguration lineaL1L2BridgeSharedConfiguration) {
final LineaL1L2BridgeSharedConfiguration lineaL1L2BridgeSharedConfiguration,
final Fork fork) {
this.besuContext = besuContext;
this.requestLimiter = requestLimiter;
this.tracesOutputPath = Paths.get(endpointConfiguration.tracesOutputPath());
this.l1L2BridgeSharedConfiguration = lineaL1L2BridgeSharedConfiguration;
this.fork = fork;
}

public String getNamespace() {
Expand Down Expand Up @@ -98,6 +102,7 @@ private TraceFile generateTraceFile(PluginRpcRequest request) {
final long toBlock = params.endBlockNumber();
final ZkTracer tracer =
new ZkTracer(
fork,
l1L2BridgeSharedConfiguration,
BesuServiceProvider.getBesuService(besuContext, BlockchainService.class)
.getChainId()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
package net.consensys.linea.zktracer;

import static net.consensys.linea.zktracer.Fork.LONDON;
import static net.consensys.linea.zktracer.Trace.ETHEREUM_GAS_LIMIT_MAXIMUM;
import static net.consensys.linea.zktracer.Trace.ETHEREUM_GAS_LIMIT_MINIMUM;
import static net.consensys.linea.zktracer.Trace.LINEA_CHAIN_ID;
Expand All @@ -34,17 +35,19 @@ public class ChainConfig {
* Represents Linea mainnet as it stands today which enforces the block gas limit (currently two
* billion). As the name suggest, this is only intended for testing purposes.
*/
public static final ChainConfig MAINNET_TESTCONFIG =
public static final ChainConfig MAINNET_LONDON_TESTCONFIG =
new ChainConfig(
LONDON,
LINEA_CHAIN_ID,
true,
BigInteger.valueOf(LINEA_GAS_LIMIT_MINIMUM),
BigInteger.valueOf(LINEA_GAS_LIMIT_MAXIMUM),
LineaL1L2BridgeSharedConfiguration.TEST_DEFAULT);

/** Represents Ethereum mainnet for the purposes of running reference tests. */
public static final ChainConfig ETHEREUM =
public static final ChainConfig ETHEREUM_LONDON =
new ChainConfig(
LONDON,
1,
false,
BigInteger.valueOf(ETHEREUM_GAS_LIMIT_MINIMUM),
Expand All @@ -57,6 +60,7 @@ public class ChainConfig {
*/
public static final ChainConfig OLD_MAINNET_TESTCONFIG =
new ChainConfig(
LONDON,
LINEA_CHAIN_ID,
false,
BigInteger.valueOf(LINEA_GAS_LIMIT_MINIMUM),
Expand All @@ -69,12 +73,15 @@ public class ChainConfig {
*/
public static final ChainConfig OLD_SEPOLIA_TESTCONFIG =
new ChainConfig(
LONDON,
LINEA_SEPOLIA_CHAIN_ID,
false,
BigInteger.valueOf(LINEA_GAS_LIMIT_MINIMUM),
BigInteger.valueOf(LINEA_GAS_LIMIT_MAXIMUM),
LineaL1L2BridgeSharedConfiguration.TEST_DEFAULT);

public final Fork fork;

/** ChainID for this chain */
public final BigInteger id;

Expand All @@ -91,12 +98,14 @@ public class ChainConfig {
public final LineaL1L2BridgeSharedConfiguration bridgeConfiguration;

private ChainConfig(
Fork fork,
int chainId,
boolean gasLimitEnabled,
BigInteger gasLimitMinimum,
BigInteger gasLimitMaximum,
LineaL1L2BridgeSharedConfiguration bridgeConfig) {
this(
fork,
BigInteger.valueOf(chainId),
gasLimitEnabled,
gasLimitMinimum,
Expand All @@ -105,16 +114,18 @@ private ChainConfig(
}

private ChainConfig(
Fork fork,
BigInteger chainId,
boolean fixedGasLimitEnabled,
BigInteger gasLimitMinimum,
BigInteger gasLimitMaximum,
LineaL1L2BridgeSharedConfiguration bridgeConfig) {
// Sanity cehck chainId is non-negative.
// Sanity check chainId is non-negative.
if (chainId.compareTo(BigInteger.ZERO) < 0) {
throw new IllegalArgumentException("invalid chain id (" + chainId + ")");
}
//
this.fork = fork;
this.id = chainId;
this.fixedGasLimitEnabled = fixedGasLimitEnabled;
this.gasLimitMinimum = gasLimitMinimum;
Expand All @@ -130,9 +141,21 @@ private ChainConfig(
* @param chainId
* @return
*/
public static ChainConfig LINEA_CHAIN(
public static ChainConfig LONDON_LINEA_CHAIN(
LineaL1L2BridgeSharedConfiguration bridgeConfig, BigInteger chainId) {
return new ChainConfig(
LONDON,
chainId,
true,
BigInteger.valueOf(LINEA_GAS_LIMIT_MINIMUM),
BigInteger.valueOf(LINEA_GAS_LIMIT_MAXIMUM),
bridgeConfig);
}

public static ChainConfig FORK_LINEA_CHAIN(
Fork fork, LineaL1L2BridgeSharedConfiguration bridgeConfig, BigInteger chainId) {
return new ChainConfig(
fork,
chainId,
true,
BigInteger.valueOf(LINEA_GAS_LIMIT_MINIMUM),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* 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;

public enum Fork {
LONDON,
SHANGHAI,
CANCUN,
PRAGUE;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
package net.consensys.linea.zktracer;

import static net.consensys.linea.zktracer.ChainConfig.LINEA_CHAIN;
import static net.consensys.linea.zktracer.ChainConfig.FORK_LINEA_CHAIN;

import java.io.IOException;
import java.io.RandomAccessFile;
Expand All @@ -34,7 +34,7 @@
import net.consensys.linea.zktracer.container.module.Module;
import net.consensys.linea.zktracer.exceptions.TracingExceptions;
import net.consensys.linea.zktracer.module.DebugMode;
import net.consensys.linea.zktracer.module.hub.Hub;
import net.consensys.linea.zktracer.module.hub.*;
import net.consensys.linea.zktracer.runtime.callstack.CallFrame;
import net.consensys.linea.zktracer.types.FiniteList;
import org.apache.tuweni.bytes.Bytes;
Expand Down Expand Up @@ -73,8 +73,10 @@ public class ZkTracer implements ConflationAwareOperationTracer {
* @param chainId Identifies the chain being traced.
*/
public ZkTracer(
final LineaL1L2BridgeSharedConfiguration bridgeConfiguration, BigInteger chainId) {
this(LINEA_CHAIN(bridgeConfiguration, chainId));
final Fork fork,
final LineaL1L2BridgeSharedConfiguration bridgeConfiguration,
BigInteger chainId) {
this(FORK_LINEA_CHAIN(fork, bridgeConfiguration, chainId));
}

/**
Expand All @@ -85,7 +87,13 @@ public ZkTracer(
*/
public ZkTracer(ChainConfig chain) {
this.chain = chain;
this.hub = new Hub(chain);
this.hub =
switch (chain.fork) {
case LONDON -> new LondonHub(chain);
case SHANGHAI -> new ShanghaiHub(chain);
case CANCUN -> new CancunHub(chain);
case PRAGUE -> new PragueHub(chain);
};
final DebugMode.PinLevel debugLevel = new DebugMode.PinLevel();
this.debugMode =
debugLevel.none() ? Optional.empty() : Optional.of(new DebugMode(debugLevel, this.hub));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
import net.consensys.linea.zktracer.Trace;
import net.consensys.linea.zktracer.container.module.Module;
import net.consensys.linea.zktracer.module.euc.Euc;
import net.consensys.linea.zktracer.module.txndata.TxnData;
import net.consensys.linea.zktracer.module.hub.Hub;
import net.consensys.linea.zktracer.module.txndata.module.TxnData;
import net.consensys.linea.zktracer.module.wcp.Wcp;
import net.consensys.linea.zktracer.opcode.OpCode;
import org.hyperledger.besu.evm.worldstate.WorldView;
Expand All @@ -36,9 +37,9 @@

@RequiredArgsConstructor
public class Blockdata implements Module {
private final Hub hub;
private final Wcp wcp;
private final Euc euc;
private final TxnData txnData;
private final ChainConfig chain;
@Getter private final List<BlockdataOperation> operations = new ArrayList<>();
@Getter private long firstBlockNumber;
Expand Down Expand Up @@ -94,10 +95,10 @@ public void traceEndBlock(final BlockHeader blockHeader, final BlockBody blockBo
for (OpCode opCode : opCodes) {
final BlockdataOperation operation =
new BlockdataOperation(
txnData.hub(),
hub,
blockHeader,
previousBlockHeader,
txnData.currentBlock().getNbOfTxsInBlock(),
txnData().currentBlock().getNbOfTxsInBlock(),
wcp,
euc,
chain,
Expand Down Expand Up @@ -135,4 +136,8 @@ public void commit(Trace trace) {
blockData.trace(trace.blockdata);
}
}

private TxnData txnData() {
return hub.txnData();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ public static AccountSnapshot canonical(Hub hub, Address address) {
isAddressWarm(hub.messageFrame(), address));
}

public static AccountSnapshot canonical(Hub hub, Address address, boolean warmth) {
return canonical(hub, address).setWarmthTo(warmth);
}

public static AccountSnapshot canonical(Hub hub, WorldView world, Address address) {
return fromArguments(
world,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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 net.consensys.linea.zktracer.ChainConfig;

public class CancunHub extends ShanghaiHub {
public CancunHub(ChainConfig chain) {
super(chain);
}
}
Loading
Loading