Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GeneralStateTestCaseEipSpec for use in linea-arithmetization #7377

Merged
merged 3 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -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
Loading