Skip to content

Commit a792088

Browse files
authored
fix: account for BEACON_ROOTS_ADDRESS access (#2382)
* fix: account for BEACON_ROOTS_ADDRESS access It seems that, post CANCUN, both SSTORE and SLOAD invoke the system transaction and that this results in the BEACON_ROOTS_ADDRESS being accessed. The existing tests did not account for this. * support Prague for addresses seen by system tx This adds support for the number of addresses seen in Prague by the system transaction.
1 parent a587b33 commit a792088

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

arithmetization/src/main/java/net/consensys/linea/zktracer/Fork.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,22 @@ public static GasCalculator getGasCalculatorFromFork(Fork fork) {
187187
};
188188
}
189189

190+
/**
191+
* Return the number of contract addresses seen by the system transaction during execution. This
192+
* is primary to testing purposes to ensure the right number were seen.
193+
*
194+
* @param fork
195+
* @return
196+
*/
197+
public static int numberOfAddressesSeenBySystemTransaction(Fork fork) {
198+
return switch (fork) {
199+
case LONDON, PARIS, SHANGHAI -> 0;
200+
case CANCUN -> 1;
201+
case PRAGUE -> 2;
202+
default -> throw new IllegalArgumentException("Unknown fork: " + fork);
203+
};
204+
}
205+
190206
// Used for blockchain ref tests with the Paris exception of "Merge"
191207
public static String toPascalCase(Fork fork) {
192208
return switch (fork) {

arithmetization/src/test/java/net/consensys/linea/zktracer/statemanager/HubShomeiTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import net.consensys.linea.testing.ToyExecutionEnvironmentV2;
2929
import net.consensys.linea.testing.ToyTransaction;
3030
import net.consensys.linea.zktracer.ChainConfig;
31+
import net.consensys.linea.zktracer.Fork;
3132
import net.consensys.linea.zktracer.ZkTracer;
3233
import net.consensys.linea.zktracer.opcode.OpCode;
3334
import org.apache.tuweni.bytes.Bytes;
@@ -127,7 +128,7 @@ void sandwichPrewarming(OpCode opcode, TestInfo testInfo) {
127128
final Set<Address> addressSeen = tracer.getAddressesSeenByHubForRelativeBlock(1);
128129
final Map<Address, Set<Bytes32>> storageSeen = tracer.getStoragesSeenByHubForRelativeBlock(1);
129130

130-
assert (addressSeen.size() == 4);
131+
assert (addressSeen.size() == 4 + Fork.numberOfAddressesSeenBySystemTransaction(fork));
131132
assert (addressSeen.contains(senderAddress));
132133
assert (addressSeen.contains(recipientAccount.getAddress()));
133134
assert (addressSeen.contains(DEFAULT_COINBASE_ADDRESS));
@@ -182,7 +183,7 @@ void uselessPrewarming(OpCode opcode, TestInfo testInfo) {
182183
final Set<Address> addressSeen = tracer.getAddressesSeenByHubForRelativeBlock(1);
183184
final Map<Address, Set<Bytes32>> storageSeen = tracer.getStoragesSeenByHubForRelativeBlock(1);
184185

185-
assert (addressSeen.size() == 3);
186+
assert (addressSeen.size() == 3 + Fork.numberOfAddressesSeenBySystemTransaction(fork));
186187
assert (addressSeen.contains(senderAddress));
187188
assert (addressSeen.contains(recipientAccount.getAddress()));
188189
assert (addressSeen.contains(DEFAULT_COINBASE_ADDRESS));

0 commit comments

Comments
 (0)