From dfee65665dcd021b81aa02a3557692df2949d99a Mon Sep 17 00:00:00 2001 From: garyschulte Date: Fri, 12 Jul 2024 10:53:16 -0700 Subject: [PATCH] test template refactor, bump besu-native to 0.9.2 (#7315) Signed-off-by: garyschulte --- ethereum/evmtool/build.gradle | 2 +- ethereum/referencetests/build.gradle | 32 ++- .../BlockchainReferenceTest.java.template | 2 +- .../ExecutionSpecStateTest.java.template | 37 --- .../templates/ExecutionSpecTest.java.template | 36 --- .../GeneralStateReferenceTest.java.template | 2 +- evm/build.gradle | 1 + gradle/verification-metadata.xml | 248 +++++++----------- gradle/versions.gradle | 3 +- 9 files changed, 122 insertions(+), 241 deletions(-) delete mode 100644 ethereum/referencetests/src/reference-test/templates/ExecutionSpecStateTest.java.template delete mode 100644 ethereum/referencetests/src/reference-test/templates/ExecutionSpecTest.java.template diff --git a/ethereum/evmtool/build.gradle b/ethereum/evmtool/build.gradle index aaddc354d5f..5712e7174a3 100644 --- a/ethereum/evmtool/build.gradle +++ b/ethereum/evmtool/build.gradle @@ -15,7 +15,7 @@ */ plugins { - id 'org.graalvm.buildtools.native' version '0.9.17' + id 'org.graalvm.buildtools.native' version '0.10.2' } apply plugin: 'java-library' diff --git a/ethereum/referencetests/build.gradle b/ethereum/referencetests/build.gradle index c023dcd699e..11db6b8eeee 100644 --- a/ethereum/referencetests/build.gradle +++ b/ethereum/referencetests/build.gradle @@ -34,6 +34,7 @@ def blockchainReferenceTests = tasks.register("blockchainReferenceTests") { "BlockchainTests", "$generatedTestsPath/org/hyperledger/besu/ethereum/vm/blockchain", "BlockchainReferenceTest", + "org.hyperledger.besu.ethereum.vm.blockchain", ("BlockchainTests/InvalidBlocks/bcExpectSection") // exclude test for test filling tool ) } @@ -50,6 +51,7 @@ def eipBlockchainReferenceTests = tasks.register("eipBlockchainReferenceTests") "EIPTests${File.separatorChar}BlockchainTests", "$generatedTestsPath/org/hyperledger/besu/ethereum/vm/eip", "EIPBlockchainReferenceTest", + "org.hyperledger.besu.ethereum.vm.eip", ) } @@ -65,6 +67,7 @@ def eipStateReferenceTests = tasks.register("eipStateReferenceTests") { "EIPTests${File.separatorChar}StateTests", "$generatedTestsPath/org/hyperledger/besu/ethereum/vm/eip", "EIPStateReferenceTest", + "org.hyperledger.besu.ethereum.vm.eip", ) } @@ -83,19 +86,21 @@ def executionSpecTests = tasks.register("executionSpecTests") { // generate blockchain_tests: generateTestFiles( fileTree(referenceTestsPath + "/fixtures/blockchain_tests"), - file("src/reference-test/templates/ExecutionSpecTest.java.template"), + file("src/reference-test/templates/BlockchainReferenceTest.java.template"), "fixtures", "$generatedTestsPath/org/hyperledger/besu/ethereum/vm/executionspec", - "ExecutionSpecBlockchainTest" + "ExecutionSpecBlockchainTest", + "org.hyperledger.besu.ethereum.vm.executionspec", ) // generate state_tests: generateTestFiles( fileTree(referenceTestsPath + "/fixtures/state_tests"), - file("src/reference-test/templates/ExecutionSpecStateTest.java.template"), + file("src/reference-test/templates/GeneralStateReferenceTest.java.template"), "fixtures", "$generatedTestsPath/org/hyperledger/besu/ethereum/vm/executionspec", - "ExecutionSpecStateTest" + "ExecutionSpecStateTest", + "org.hyperledger.besu.ethereum.vm.executionspec", ) } @@ -110,7 +115,8 @@ def generalstateReferenceTests = tasks.register("generalstateReferenceTests") { file("src/reference-test/templates/GeneralStateReferenceTest.java.template"), "GeneralStateTests", "$generatedTestsPath/org/hyperledger/besu/ethereum/vm/generalstate", - "GeneralStateReferenceTest" + "GeneralStateReferenceTest", + "org.hyperledger.besu.ethereum.vm.generalstate", ) } @@ -125,7 +131,8 @@ def generalstateRegressionReferenceTests = tasks.register("generalstateRegressio file("src/reference-test/templates/GeneralStateReferenceTest.java.template"), "regressions", "$generatedTestsPath/org/hyperledger/besu/ethereum/vm/generalstate", - "GeneralStateRegressionReferenceTest" + "GeneralStateRegressionReferenceTest", + "org.hyperledger.besu.ethereum.vm.generalstate" ) } @@ -140,7 +147,8 @@ def eofReferenceTests = tasks.register("eofReferenceTests") { file("src/reference-test/templates/EOFReferenceTest.java.template"), "EOFTests", "$generatedTestsPath/org/hyperledger/besu/ethereum/vm/eof", - "EOFReferenceTest" + "EOFReferenceTest", + "org.hyperledger.besu.ethereum.vm.eof" ) } @@ -259,7 +267,14 @@ following commands: } processResources.dependsOn('validateReferenceTestSubmodule') -def generateTestFiles(FileTree jsonPath, File templateFile, String pathstrip, String destination, String namePrefix, String ... excludedPath) { +def generateTestFiles( + FileTree jsonPath, + File templateFile, + String pathstrip, + String destination, + String namePrefix, + String packageString, + String ... excludedPath) { mkdir(destination) def referenceTestTemplate = templateFile.text @@ -281,6 +296,7 @@ def generateTestFiles(FileTree jsonPath, File templateFile, String pathstrip, St def testFileContents = referenceTestTemplate .replaceAll("%%TESTS_FILE%%", allPaths) .replaceAll("%%TESTS_NAME%%", namePrefix + "_" + idx) + .replaceAll("%%PACKAGE_NAME%%", packageString) testFile.newWriter().withWriter { w -> w << testFileContents } } } diff --git a/ethereum/referencetests/src/reference-test/templates/BlockchainReferenceTest.java.template b/ethereum/referencetests/src/reference-test/templates/BlockchainReferenceTest.java.template index 387fb0cc189..e7789905b35 100644 --- a/ethereum/referencetests/src/reference-test/templates/BlockchainReferenceTest.java.template +++ b/ethereum/referencetests/src/reference-test/templates/BlockchainReferenceTest.java.template @@ -1,4 +1,4 @@ -package org.hyperledger.besu.ethereum.vm.blockchain; +package %%PACKAGE_NAME%%; import static org.hyperledger.besu.ethereum.vm.BlockchainReferenceTestTools.executeTest; import static org.hyperledger.besu.ethereum.vm.BlockchainReferenceTestTools.generateTestParametersForConfig; diff --git a/ethereum/referencetests/src/reference-test/templates/ExecutionSpecStateTest.java.template b/ethereum/referencetests/src/reference-test/templates/ExecutionSpecStateTest.java.template deleted file mode 100644 index 76da5d64f9c..00000000000 --- a/ethereum/referencetests/src/reference-test/templates/ExecutionSpecStateTest.java.template +++ /dev/null @@ -1,37 +0,0 @@ -package org.hyperledger.besu.ethereum.vm.executionspec; - -import static org.hyperledger.besu.ethereum.vm.GeneralStateReferenceTestTools.executeTest; -import static org.hyperledger.besu.ethereum.vm.GeneralStateReferenceTestTools.generateTestParametersForConfig; -import static org.junit.jupiter.api.Assumptions.assumeTrue; - -import org.hyperledger.besu.ethereum.referencetests.GeneralStateTestCaseEipSpec; - -import java.util.stream.Stream; - -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; - -import static org.junit.jupiter.api.Assumptions.assumeTrue; - -/** The general state test operation testing framework entry point. */ -public class %%TESTS_NAME%% { - - private static final String[] TEST_CONFIG_FILE_DIR_PATH = new String[] {%%TESTS_FILE%%}; - - public static Stream getTestParametersForConfig() { - return generateTestParametersForConfig(TEST_CONFIG_FILE_DIR_PATH).stream().map(params -> - Arguments.of(params[0], params[1], params[2]) - ); - } - - @ParameterizedTest(name = "Name: {0}") - @MethodSource("getTestParametersForConfig") - public void execution( - final String name, - final GeneralStateTestCaseEipSpec spec, - final boolean runTest) { - assumeTrue(runTest, "Test " + name + " was ignored"); - executeTest(spec); - } -} diff --git a/ethereum/referencetests/src/reference-test/templates/ExecutionSpecTest.java.template b/ethereum/referencetests/src/reference-test/templates/ExecutionSpecTest.java.template deleted file mode 100644 index d56115f123c..00000000000 --- a/ethereum/referencetests/src/reference-test/templates/ExecutionSpecTest.java.template +++ /dev/null @@ -1,36 +0,0 @@ -package org.hyperledger.besu.ethereum.vm.executionspec; - -import static org.hyperledger.besu.ethereum.vm.BlockchainReferenceTestTools.executeTest; -import static org.hyperledger.besu.ethereum.vm.BlockchainReferenceTestTools.generateTestParametersForConfig; - -import org.hyperledger.besu.ethereum.referencetests.BlockchainReferenceTestCaseSpec; - -import java.util.stream.Stream; - -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; - -import static org.junit.jupiter.api.Assumptions.assumeTrue; - -/** The blockchain test operation testing framework entry point. */ -public class %%TESTS_NAME%% { - - private static final String[] TEST_CONFIG_FILE_DIR_PATH = new String[] {%%TESTS_FILE%%}; - - public static Stream getTestParametersForConfig() { - return generateTestParametersForConfig(TEST_CONFIG_FILE_DIR_PATH).stream().map(params -> - Arguments.of(params[0], params[1], params[2]) - ); - } - - @ParameterizedTest(name = "Name: {0}") - @MethodSource("getTestParametersForConfig") - public void execution( - final String name, - final BlockchainReferenceTestCaseSpec spec, - final boolean runTest) { - assumeTrue(runTest, "Test " + name + " was ignored"); - executeTest(spec); - } -} diff --git a/ethereum/referencetests/src/reference-test/templates/GeneralStateReferenceTest.java.template b/ethereum/referencetests/src/reference-test/templates/GeneralStateReferenceTest.java.template index 3d5976aff2b..139766a4b83 100644 --- a/ethereum/referencetests/src/reference-test/templates/GeneralStateReferenceTest.java.template +++ b/ethereum/referencetests/src/reference-test/templates/GeneralStateReferenceTest.java.template @@ -1,4 +1,4 @@ -package org.hyperledger.besu.ethereum.vm.generalstate; +package %%PACKAGE_NAME%%; import static org.hyperledger.besu.ethereum.vm.GeneralStateReferenceTestTools.executeTest; import static org.hyperledger.besu.ethereum.vm.GeneralStateReferenceTestTools.generateTestParametersForConfig; diff --git a/evm/build.gradle b/evm/build.gradle index efcab24b717..b6f8ea36185 100644 --- a/evm/build.gradle +++ b/evm/build.gradle @@ -44,6 +44,7 @@ dependencies { implementation 'io.tmio:tuweni-units' implementation 'org.hyperledger.besu:arithmetic' implementation 'org.hyperledger.besu:bls12-381' + implementation'org.hyperledger.besu:gnark' implementation 'tech.pegasys:jc-kzg-4844' compileOnly 'com.fasterxml.jackson.core:jackson-databind' diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index 86f65970e61..bd437c3a4e7 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -114,9 +114,9 @@ - - - + + + @@ -134,9 +134,9 @@ - - - + + + @@ -189,12 +189,12 @@ - - - + + + - - + + @@ -221,12 +221,12 @@ - - - + + + - - + + @@ -253,12 +253,12 @@ - - - + + + - - + + @@ -1361,14 +1361,6 @@ - - - - - - - - @@ -2507,14 +2499,6 @@ - - - - - - - - @@ -2531,22 +2515,6 @@ - - - - - - - - - - - - - - - - @@ -2765,14 +2733,6 @@ - - - - - - - - @@ -3139,11 +3099,6 @@ - - - - - @@ -4603,41 +4558,41 @@ - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + @@ -4677,12 +4632,12 @@ - - - + + + - - + + @@ -4693,44 +4648,52 @@ - - - + + + + + + + + + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + @@ -5060,17 +5023,6 @@ - - - - - - - - - - - @@ -5177,14 +5129,6 @@ - - - - - - - - @@ -5193,14 +5137,6 @@ - - - - - - - - @@ -5304,6 +5240,11 @@ + + + + + @@ -5312,11 +5253,6 @@ - - - - - @@ -5336,6 +5272,11 @@ + + + + + @@ -5352,11 +5293,6 @@ - - - - - diff --git a/gradle/versions.gradle b/gradle/versions.gradle index db29cfd589b..0c2289233d6 100644 --- a/gradle/versions.gradle +++ b/gradle/versions.gradle @@ -156,13 +156,14 @@ dependencyManagement { dependency 'org.openjdk.jol:jol-core:0.17' dependency 'tech.pegasys:jc-kzg-4844:1.0.0' - dependencySet(group: 'org.hyperledger.besu', version: '0.8.5') { + dependencySet(group: 'org.hyperledger.besu', version: '0.9.2') { entry 'arithmetic' entry 'ipa-multipoint' entry 'bls12-381' entry 'secp256k1' entry 'secp256r1' entry 'blake2bf' + entry 'gnark' } dependencySet(group: 'org.immutables', version: '2.10.0') {