Skip to content

Commit

Permalink
Update GeneralStateTestCaseEipSpec for use in linea-arithmetization (#…
Browse files Browse the repository at this point in the history
…7377)

* Update GeneralStateTestCaseEipSpec for use in linea-arithmetization

Signed-off-by: Gaurav Ahuja <[email protected]>

* formatting

Signed-off-by: Sally MacFarlane <[email protected]>

---------

Signed-off-by: Gaurav Ahuja <[email protected]>
Signed-off-by: Sally MacFarlane <[email protected]>
Co-authored-by: Sally MacFarlane <[email protected]>
  • Loading branch information
gauravahuja and macfarla authored Jul 25, 2024
1 parent 30dfa66 commit cf358c0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ private void traceTestSpecs(final String test, final List<GeneralStateTestCaseEi
}

final BlockHeader blockHeader = spec.getBlockHeader();
final Transaction transaction = spec.getTransaction();
final Transaction transaction = spec.getTransaction(0);
final ObjectNode summaryLine = objectMapper.createObjectNode();
if (transaction == null) {
if (parentCommand.showJsonAlloc || parentCommand.showJsonResults) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Transaction;

import java.util.List;
import java.util.function.Supplier;

public class GeneralStateTestCaseEipSpec {
Expand All @@ -33,7 +34,7 @@ public class GeneralStateTestCaseEipSpec {
// anything
// is run, which isn't friendly and 2) this makes it harder to parallelize this step. Anyway, this
// is why this is a supplier: calling get() actually does the signing.
private final Supplier<Transaction> transactionSupplier;
private final List<Supplier<Transaction>> transactionSuppliers;

private final ReferenceTestWorldState initialWorldState;

Expand All @@ -51,7 +52,7 @@ public class GeneralStateTestCaseEipSpec {

GeneralStateTestCaseEipSpec(
final String fork,
final Supplier<Transaction> transactionSupplier,
final List<Supplier<Transaction>> transactionSuppliers,
final ReferenceTestWorldState initialWorldState,
final Hash expectedRootHash,
final Hash expectedLogsHash,
Expand All @@ -61,7 +62,7 @@ public class GeneralStateTestCaseEipSpec {
final int valueIndex,
final String expectException) {
this.fork = fork;
this.transactionSupplier = transactionSupplier;
this.transactionSuppliers = transactionSuppliers;
this.initialWorldState = initialWorldState;
this.expectedRootHash = expectedRootHash;
this.expectedLogsHash = expectedLogsHash;
Expand All @@ -88,9 +89,13 @@ public Hash getExpectedLogsHash() {
return expectedLogsHash;
}

public Transaction getTransaction() {
public int getTransactionsCount() {
return transactionSuppliers.size();
}

public Transaction getTransaction(final int txIndex) {
try {
return transactionSupplier.get();
return transactionSuppliers.get(txIndex).get();
} catch (RuntimeException re) {
// some tests specify invalid transactions. We throw exceptions in
// GeneralStateTests but they are encoded in BlockchainTests, so we
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@ private Map<String, List<GeneralStateTestCaseEipSpec>> generate(
.stateRoot(p.rootHash)
.blockHeaderFunctions(MAINNET_FUNCTIONS)
.buildBlockHeader();
final Supplier<Transaction> txSupplier = () -> versionedTransaction.get(p.indexes);
final List<Supplier<Transaction>> txSupplierList =
List.of(() -> versionedTransaction.get(p.indexes));
specs.add(
new GeneralStateTestCaseEipSpec(
eip,
txSupplier,
txSupplierList,
initialWorldState,
p.rootHash,
p.logsHash,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public static Collection<Object[]> generateTestParametersForConfig(final String[
public static void executeTest(final GeneralStateTestCaseEipSpec spec) {
final BlockHeader blockHeader = spec.getBlockHeader();
final ReferenceTestWorldState initialWorldState = spec.getInitialWorldState();
final Transaction transaction = spec.getTransaction();
final Transaction transaction = spec.getTransaction(0);
ProtocolSpec protocolSpec = protocolSpec(spec.getFork());

BlockchainReferenceTestTools.verifyJournaledEVMAccountCompatability(initialWorldState, protocolSpec);
Expand Down

0 comments on commit cf358c0

Please sign in to comment.