From f721c1c2c26bf695edbbba6ba612c5fb312aa57c Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Thu, 11 Jan 2024 10:45:41 +0100 Subject: [PATCH 01/14] Upgrade dependencies (#6377) * Bump com.github.oshi:oshi-core to 6.4.10 Signed-off-by: Fabio Di Fabio * Bump com.github.tomakehurst to org.wiremock 3.3.1 Signed-off-by: Fabio Di Fabio * Bump com.google.auto.service:auto-service to 1.1.1 Signed-off-by: Fabio Di Fabio * Bump com.google.dagger group to 2.50 Signed-off-by: Fabio Di Fabio * Bump com.graphql-java:graphql-java to 21.3 Signed-off-by: Fabio Di Fabio * Bump com.splunk.logging:splunk-library-javalogging to 1.11.8 Signed-off-by: Fabio Di Fabio * Bump com.squareup.okhttp3:okhttp to 4.12.0 Signed-off-by: Fabio Di Fabio * Bump commons-io:commons-io to 2.15.1 Signed-off-by: Fabio Di Fabio * Bump dnsjava:dnsjava to 3.5.3 Signed-off-by: Fabio Di Fabio * Bump info.picocli group to 4.7.5 Signed-off-by: Fabio Di Fabio * Bump io.grpc group to 1.60.1 Signed-off-by: Fabio Di Fabio * Bump io.kubernetes:client-java to 18.0.1 Signed-off-by: Fabio Di Fabio * Bump io.netty group to 4.1.104.Final Signed-off-by: Fabio Di Fabio * Bump net.java.dev.jna:jna to 5.14.0 Signed-off-by: Fabio Di Fabio * Bump org.apache.commons:commons-compress to 1.25.0 Signed-off-by: Fabio Di Fabio * Bump org.apache.commons:commons-lang3 to 3.14.0 Signed-off-by: Fabio Di Fabio * Bump org.apache.commons:commons-text to 1.11.0 Signed-off-by: Fabio Di Fabio * Bump org.apache.logging.log4j group to 2.22.1 Signed-off-by: Fabio Di Fabio * Redorder io.tmio group Signed-off-by: Fabio Di Fabio * Bump org.assertj:assertj-core to 3.25.1 Signed-off-by: Fabio Di Fabio * Bump org.bouncycastle group to 1.77 Signed-off-by: Fabio Di Fabio * Bump org.fusesource.jansi:jansi to 2.4.1 Signed-off-by: Fabio Di Fabio * Bump org.immutables group 2.10.0 Signed-off-by: Fabio Di Fabio * Bump org.java-websocket:Java-WebSocket to 1.5.5 Signed-off-by: Fabio Di Fabio * Bump org.jetbrains.kotlin:kotlin-stdlib to 1.9.22 Signed-off-by: Fabio Di Fabio * Bump org.junit.jupiter group to 5.10.1 Signed-off-by: Fabio Di Fabio * Bump org.jupnp group to 2.7.1 Signed-off-by: Fabio Di Fabio * Bump org.rocksdb:rocksdbjni to 8.9.1 Signed-off-by: Fabio Di Fabio * Bump org.slf4j group to 2.0.10 Signed-off-by: Fabio Di Fabio * Bump org.springframework.security:spring-security-crypto to 6.2.1 Signed-off-by: Fabio Di Fabio * Bump org.testcontainers:testcontainers to 1.19.3 Signed-off-by: Fabio Di Fabio * Bump org.web3j group to 4.10.3 Signed-off-by: Fabio Di Fabio * Bump org.xerial.snappy:snappy-java to 1.1.10.5 Signed-off-by: Fabio Di Fabio * Regenerate gradle verification metadata Signed-off-by: Fabio Di Fabio * Update commons-codec:commons-codec to 1.16.0 Signed-off-by: Fabio Di Fabio * Update org.junit.vintage:junit-vintage-engine to 5.10.1 Signed-off-by: Fabio Di Fabio * Update CHANGELOG Signed-off-by: Fabio Di Fabio --------- Signed-off-by: Fabio Di Fabio --- CHANGELOG.md | 1 + acceptance-tests/dsl/build.gradle | 2 +- acceptance-tests/tests/build.gradle | 2 +- gradle/allowed-licenses.json | 4 + gradle/license-normalizer-bundle.json | 2 +- gradle/verification-metadata.xml | 2892 +++++++++---------------- gradle/versions.gradle | 109 +- 7 files changed, 1090 insertions(+), 1922 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ce64c213aa..912122e786b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ ### Additions and Improvements - Optimize RocksDB WAL files, allows for faster restart and a more linear disk space utilization [#6328](https://github.com/hyperledger/besu/pull/6328) - Disable transaction handling when the node is not in sync, to avoid unnecessary transaction validation work [#6302](https://github.com/hyperledger/besu/pull/6302) +- Upgrade dependencies [#6377](https://github.com/hyperledger/besu/pull/6377) ### Bug fixes - INTERNAL_ERROR from `eth_estimateGas` JSON/RPC calls [#6344](https://github.com/hyperledger/besu/issues/6344) diff --git a/acceptance-tests/dsl/build.gradle b/acceptance-tests/dsl/build.gradle index 96a6a1c1bc0..6c9090fe9b9 100644 --- a/acceptance-tests/dsl/build.gradle +++ b/acceptance-tests/dsl/build.gradle @@ -26,7 +26,6 @@ dependencies { implementation project(':testutil') implementation project(':util') - implementation 'com.github.tomakehurst:wiremock-jre8' implementation 'com.google.guava:guava' implementation 'com.google.dagger:dagger' annotationProcessor 'com.google.dagger:dagger-compiler' @@ -45,6 +44,7 @@ dependencies { implementation 'org.web3j:abi' implementation 'org.web3j:besu' implementation 'org.web3j:crypto' + implementation 'org.wiremock:wiremock' implementation 'org.testcontainers:testcontainers' implementation 'org.junit.jupiter:junit-jupiter' diff --git a/acceptance-tests/tests/build.gradle b/acceptance-tests/tests/build.gradle index 464805779c8..b20b96b2735 100644 --- a/acceptance-tests/tests/build.gradle +++ b/acceptance-tests/tests/build.gradle @@ -55,7 +55,6 @@ dependencies { testImplementation project(':testutil') testImplementation project(':util') - testImplementation 'com.github.tomakehurst:wiremock-jre8-standalone' testImplementation 'commons-io:commons-io' testImplementation 'io.grpc:grpc-all' testImplementation 'io.grpc:grpc-core' @@ -84,6 +83,7 @@ dependencies { testImplementation 'org.web3j:abi' testImplementation 'org.web3j:besu' testImplementation 'org.web3j:core' + testImplementation 'org.wiremock:wiremock' testRuntimeOnly 'org.junit.vintage:junit-vintage-engine' } diff --git a/gradle/allowed-licenses.json b/gradle/allowed-licenses.json index a5d4048b224..25270190806 100644 --- a/gradle/allowed-licenses.json +++ b/gradle/allowed-licenses.json @@ -60,6 +60,10 @@ "moduleLicense": "Eclipse Public License - v 1.0", "moduleVersion": "4.13.2", "moduleName": "junit:junit" + }, + { + "moduleName": "org.jetbrains.kotlin:kotlin-stdlib-common", + "moduleVersion": "1.9.22" } ] } \ No newline at end of file diff --git a/gradle/license-normalizer-bundle.json b/gradle/license-normalizer-bundle.json index 341b7ab5f62..8c0af450fd3 100644 --- a/gradle/license-normalizer-bundle.json +++ b/gradle/license-normalizer-bundle.json @@ -50,9 +50,9 @@ { "bundleName" : "Apache-2.0", "licenseNamePattern" : ".*Apache License,?( Version)? 2.*" }, { "bundleName" : "Apache-2.0", "licenseUrlPattern" : ".*(www\\.)?opensource\\.org/licenses/Apache-2\\.0.*" }, { "bundleName" : "Apache-2.0", "licenseUrlPattern" : ".*www\\.apache\\.org/licenses/LICENSE-2\\.0.*" }, - { "bundleName" : "LGPL-2.1-only", "licenseUrlPattern" : ".*www\\.gnu\\.org/licenses/old-licenses/lgpl-2\\.1\\.html" }, { "bundleName" : "Apache-2.0", "licenseFileContentPattern" : ".*Apache License,?( Version)? 2.*" }, { "bundleName" : "Apache-1.1", "licenseFileContentPattern" : ".*Apache Software License, Version 1\\.1.*" }, + { "bundleName" : "LGPL-2.1-only", "licenseUrlPattern" : ".*www\\.gnu\\.org/licenses/old-licenses/lgpl-2\\.1\\.html" }, { "bundleName" : "CC0-1.0", "licenseNamePattern" : "CC0(( |-)1(\\.0)?)?" }, { "bundleName" : "CC0-1.0", "licenseUrlPattern" : ".*(www\\.)?creativecommons\\.org/publicdomain/zero/1\\.0/" }, { "bundleName" : "CDDL-1.0", "licenseFileContentPattern" : ".*CDDL.*1\\.0" }, diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index 8265a2810c4..d0cfe4bd752 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -78,9 +78,12 @@ - - - + + + + + + @@ -133,9 +136,9 @@ - - - + + + @@ -153,11 +156,6 @@ - - - - - @@ -183,11 +181,6 @@ - - - - - @@ -208,11 +201,6 @@ - - - - - @@ -229,11 +217,6 @@ - - - - - @@ -250,6 +233,14 @@ + + + + + + + + @@ -290,6 +281,14 @@ + + + + + + + + @@ -327,14 +326,6 @@ - - - - - - - - @@ -343,12 +334,15 @@ - - - + + + - - + + + + + @@ -356,9 +350,9 @@ - - - + + + @@ -372,12 +366,26 @@ - - - + + + + + + + + + + + + + + + + + - - + + @@ -385,9 +393,9 @@ - - - + + + @@ -414,33 +422,33 @@ - - - + + + - - + + - - - + + + - - - + + + - - + + - - - + + + - - + + @@ -523,11 +531,6 @@ - - - - - @@ -584,27 +587,17 @@ - - - - - - - - - - - + + + - - - - + + - - - + + + @@ -615,35 +608,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -689,14 +653,6 @@ - - - - - - - - @@ -705,15 +661,10 @@ - - - - - - - - + + + @@ -736,6 +687,14 @@ + + + + + + + + @@ -806,54 +765,36 @@ - - - - - - - - - - - - - - - - + + + - - + + - - - + + + - - - - - - - + + - - - + + + - - + + - - - + + + - - + + @@ -864,11 +805,6 @@ - - - - - @@ -909,11 +845,6 @@ - - - - - @@ -922,11 +853,6 @@ - - - - - @@ -947,11 +873,6 @@ - - - - - @@ -960,11 +881,6 @@ - - - - - @@ -1072,9 +988,6 @@ - - - @@ -1281,31 +1194,23 @@ - - - - - - - - - - - + + + - - + + - - - + + + - - + + - - + + @@ -1316,12 +1221,15 @@ - - - + + + - - + + + + + @@ -1329,49 +1237,18 @@ - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - + + + + + @@ -1446,17 +1323,6 @@ - - - - - - - - - - - @@ -1465,6 +1331,17 @@ + + + + + + + + + + + @@ -1473,19 +1350,6 @@ - - - - - - - - - - - - - @@ -1494,25 +1358,19 @@ - - - - - - - - + + + - - - - - + + + + @@ -1523,6 +1381,17 @@ + + + + + + + + + + + @@ -1539,12 +1408,12 @@ - - - + + + - - + + @@ -1556,6 +1425,9 @@ + + + @@ -1584,15 +1456,10 @@ - - - - - - - - + + + @@ -1610,35 +1477,36 @@ - - - - - - - - + + + - - - - - - - - + + + - - - + + + + + + + + + + + + + + @@ -1649,41 +1517,36 @@ - - - - - - + + + - - - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + @@ -1694,155 +1557,140 @@ - - - + + + - - + + - - - - - - + + + - - - - + + - - - + + + - - + + - - - + + + - - + + - - - - - - + + + - - - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - - - - + + + - - - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + @@ -1853,61 +1701,46 @@ - - - - - - + + + - - - - + + - - - - - - + + + - - - - + + - - - + + + - - - + + + - - + + - - - - - - + + + - - - - + + - - - + + + @@ -1920,12 +1753,12 @@ - - - + + + - - + + @@ -1933,12 +1766,12 @@ - - - + + + - - + + @@ -1949,12 +1782,12 @@ - - - + + + - - + + @@ -1965,20 +1798,20 @@ - - - + + + - - + + - - - + + + - - + + @@ -1990,13 +1823,18 @@ - - - + + + + + + + + @@ -2005,49 +1843,44 @@ - - - - - - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + @@ -2058,28 +1891,28 @@ - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + @@ -2087,12 +1920,12 @@ - - - + + + - - + + @@ -2104,13 +1937,18 @@ - - - + + + + + + + + @@ -2119,17 +1957,12 @@ - - - - - - - - + + + - - + + @@ -2137,9 +1970,9 @@ - - - + + + @@ -2147,22 +1980,12 @@ - - - - - - - - - - - - - + + + - - + + @@ -2170,12 +1993,12 @@ - - - + + + - - + + @@ -2186,23 +2009,23 @@ - - - + + + - - + + - - - + + + - - + + - - + + @@ -2226,12 +2049,12 @@ - - - + + + - - + + @@ -2239,95 +2062,83 @@ - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - + + - - + + - - - - + + - - - + + + - - + + - - + + - - + + - - - + + + - - - - - - - - - - - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + @@ -2365,14 +2176,6 @@ - - - - - - - - @@ -2428,14 +2231,6 @@ - - - - - - - - @@ -2458,14 +2253,6 @@ - - - - - - - - @@ -2477,14 +2264,6 @@ - - - - - - - - @@ -2507,14 +2286,6 @@ - - - - - - - - @@ -2548,14 +2319,6 @@ - - - - - - - - @@ -2567,14 +2330,6 @@ - - - - - - - - @@ -2586,14 +2341,6 @@ - - - - - - - - @@ -2618,14 +2365,6 @@ - - - - - - - - @@ -2634,14 +2373,6 @@ - - - - - - - - @@ -2750,11 +2481,6 @@ - - - - - @@ -2763,11 +2489,6 @@ - - - - - @@ -2784,11 +2505,6 @@ - - - - - @@ -2805,11 +2521,6 @@ - - - - - @@ -2836,9 +2547,7 @@ - - - + @@ -3003,16 +2712,6 @@ - - - - - - - - - - @@ -3029,11 +2728,6 @@ - - - - - @@ -3042,11 +2736,6 @@ - - - - - @@ -3057,11 +2746,6 @@ - - - - - @@ -3080,11 +2764,6 @@ - - - - - @@ -3119,11 +2798,6 @@ - - - - - @@ -3140,11 +2814,6 @@ - - - - - @@ -3153,11 +2822,6 @@ - - - - - @@ -3171,19 +2835,14 @@ - - - + + + - - - - - - - - + + + @@ -3210,14 +2869,6 @@ - - - - - - - - @@ -3268,12 +2919,12 @@ - - - + + + - - + + @@ -3289,9 +2940,9 @@ - - - + + + @@ -3304,38 +2955,33 @@ - - - - - - - - + + + - - - + + + - - + + - - - + + + - - + + - - - + + + @@ -3343,11 +2989,6 @@ - - - - - @@ -3364,36 +3005,20 @@ - - - - - - - - - - - - - - - - - - - + + + - - + + - - - + + + - - + + @@ -3446,11 +3071,6 @@ - - - - - @@ -3459,16 +3079,6 @@ - - - - - - - - - - @@ -3479,11 +3089,6 @@ - - - - - @@ -3532,14 +3137,6 @@ - - - - - - - - @@ -3549,6 +3146,9 @@ + + + @@ -3570,6 +3170,9 @@ + + + @@ -3600,11 +3203,6 @@ - - - - - @@ -3615,11 +3213,6 @@ - - - - - @@ -3660,38 +3253,17 @@ - - - + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - + + + @@ -3730,9 +3302,9 @@ - - - + + + @@ -3751,38 +3323,38 @@ - - - + + + - - + + - - - + + + - - - + + + - - + + - - - + + + - - + + - - - + + + @@ -3793,112 +3365,51 @@ - - - + + + - - - + + + - - - + + + - - - - + + - - - - - - - - - - - + + + - - - + + + - - - - + + - - - + + + - - + + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -3957,22 +3468,12 @@ - - - - - - - - + + + - - - - - - - + + @@ -3996,15 +3497,10 @@ - - - - - - - - + + + @@ -4025,25 +3521,20 @@ - - - - - - - - + + + - - - + + + - - + + @@ -4097,9 +3588,9 @@ - - - + + + @@ -4120,55 +3611,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -4198,9 +3640,9 @@ - - - + + + @@ -4259,205 +3701,186 @@ - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - - - - + + + - - - + + + - - + + - - - + + + - - - - - - + + + - - - + + + - - - - + + - - - + + + - - + + - - - + + + - - + + - - - - - - + + + - - - + + + - - + + - - - + + + - - - - - - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - - - - + + + - - - + + + - - + + - - - + + + - - - - + + - - + + + + @@ -5195,15 +4618,10 @@ - - - - - - - - + + + @@ -5237,14 +4655,6 @@ - - - - - - - - @@ -5266,11 +4676,6 @@ - - - - - @@ -5323,9 +4728,6 @@ - - - @@ -5334,9 +4736,6 @@ - - - @@ -5345,9 +4744,6 @@ - - - @@ -5356,9 +4752,6 @@ - - - @@ -5367,9 +4760,6 @@ - - - @@ -5378,54 +4768,36 @@ - - - - - - - - + + + - - - - - - - - + + + - - - - - - - - - - - + + + - - - + + + @@ -5473,17 +4845,12 @@ - - - + + + - - - - - - - + + @@ -5539,14 +4906,6 @@ - - - - - - - - @@ -5555,12 +4914,15 @@ - - - + + + + + + - - + + @@ -5581,14 +4943,6 @@ - - - - - - - - @@ -5597,6 +4951,16 @@ + + + + + + + + + + @@ -5605,36 +4969,28 @@ - - - - - - - - - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + @@ -5650,36 +5006,28 @@ - - - - - - - - - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + @@ -5714,14 +5062,6 @@ - - - - - - - - @@ -5851,6 +5191,9 @@ + + + @@ -5858,18 +5201,10 @@ - - - - - - - - - - - + + + @@ -5885,18 +5220,10 @@ - - - - - - - - - - - + + + @@ -5912,18 +5239,10 @@ - - - - - - - - - - - + + + @@ -5931,15 +5250,15 @@ - - - + + + - - + + - - + + @@ -5950,23 +5269,12 @@ - - - - - - - - - - - - - - + + + - - + + @@ -5974,12 +5282,15 @@ - - - + + + + + + - - + + @@ -5990,25 +5301,19 @@ - - - - - - - - - - - - - - + + + + + + + + @@ -6022,34 +5327,21 @@ - - - + + + - - - - - - - - - - - - - - - + + + + + - - - @@ -6067,47 +5359,27 @@ - - - - - - - - - - - - - + + + - - - - - - - - + + + - - - - - @@ -6126,11 +5398,6 @@ - - - - - @@ -6139,11 +5406,6 @@ - - - - - @@ -6181,11 +5443,6 @@ - - - - - @@ -6202,11 +5459,6 @@ - - - - - @@ -6246,6 +5498,17 @@ + + + + + + + + + + + @@ -6280,12 +5543,12 @@ - - - + + + - - + + @@ -6296,6 +5559,11 @@ + + + + + @@ -6365,17 +5633,12 @@ - - - - - - + + + - - - - + + @@ -6394,35 +5657,25 @@ - - - - - - + + + - - - - + + - - - + + + - - - + + + - - - - - - - + + @@ -6435,14 +5688,9 @@ - - - - - - - - + + + @@ -6476,11 +5724,6 @@ - - - - - @@ -6496,99 +5739,28 @@ - - - + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + - - - + + + @@ -6599,6 +5771,17 @@ + + + + + + + + + + + @@ -6607,30 +5790,15 @@ - - - - - - - - - - - + + + - - - - - - - + + - - - - + + @@ -6641,6 +5809,17 @@ + + + + + + + + + + + @@ -6657,17 +5836,15 @@ - - - + + + - - + + - - - - + + @@ -6678,30 +5855,15 @@ - - - - - - - - - - - + + + - - - - + + - - - - - - - + + @@ -6709,6 +5871,17 @@ + + + + + + + + + + + @@ -6717,12 +5890,15 @@ - - - + + + - - + + + + + @@ -6741,12 +5917,15 @@ - - - + + + + + + - - + + @@ -6757,14 +5936,6 @@ - - - - - - - - @@ -6786,11 +5957,6 @@ - - - - - @@ -6799,46 +5965,52 @@ - - - + + + + + + + + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - - + + + - - + + @@ -6860,14 +6032,6 @@ - - - - - - - - diff --git a/gradle/versions.gradle b/gradle/versions.gradle index f239370ab7a..45626801fc0 100644 --- a/gradle/versions.gradle +++ b/gradle/versions.gradle @@ -30,14 +30,11 @@ dependencyManagement { dependency 'com.github.ben-manes.caffeine:caffeine:3.1.8' - dependencySet(group: 'com.github.tomakehurst', version: '2.35.0') { - entry'wiremock-jre8-standalone' - entry'wiremock-jre8' - } + dependency 'com.github.oshi:oshi-core:6.4.10' - dependency 'com.google.auto.service:auto-service:1.0.1' + dependency 'com.google.auto.service:auto-service:1.1.1' - dependencySet(group: 'com.google.dagger', version: '2.45') { + dependencySet(group: 'com.google.dagger', version: '2.50') { entry'dagger-compiler' entry'dagger' } @@ -51,37 +48,37 @@ dependencyManagement { dependency 'com.google.guava:guava:31.1-jre' - dependency 'com.graphql-java:graphql-java:20.1' + dependency 'com.graphql-java:graphql-java:21.3' - dependency 'com.splunk.logging:splunk-library-javalogging:1.11.5' + dependency 'com.splunk.logging:splunk-library-javalogging:1.11.8' - dependency 'com.squareup.okhttp3:okhttp:4.10.0' + dependency 'com.squareup.okhttp3:okhttp:4.12.0' - dependency 'commons-codec:commons-codec:1.15' + dependency 'commons-codec:commons-codec:1.16.0' - dependency 'commons-io:commons-io:2.11.0' + dependency 'commons-io:commons-io:2.15.1' - dependency 'dnsjava:dnsjava:3.5.2' + dependency 'dnsjava:dnsjava:3.5.3' - dependencySet(group: 'info.picocli', version: '4.7.1') { + dependencySet(group: 'info.picocli', version: '4.7.5') { entry 'picocli' entry 'picocli-codegen' } - dependencySet(group: 'io.grpc', version: '1.59.0') { + dependencySet(group: 'io.grpc', version: '1.60.1') { entry 'grpc-all' entry 'grpc-core' entry 'grpc-netty' entry 'grpc-stub' } - dependency 'io.kubernetes:client-java:18.0.0' + dependency 'io.kubernetes:client-java:18.0.1' - dependency 'io.netty:netty-all:4.1.100.Final' + dependency 'io.netty:netty-all:4.1.104.Final' dependency 'io.netty:netty-tcnative-boringssl-static:2.0.62.Final' - dependency group: 'io.netty', name: 'netty-transport-native-epoll', version:'4.1.100.Final', classifier: 'linux-x86_64' - dependency group: 'io.netty', name: 'netty-transport-native-kqueue', version:'4.1.100.Final', classifier: 'osx-x86_64' - dependency 'io.netty:netty-transport-native-unix-common:4.1.100.Final' + dependency group: 'io.netty', name: 'netty-transport-native-epoll', version:'4.1.104.Final', classifier: 'linux-x86_64' + dependency group: 'io.netty', name: 'netty-transport-native-kqueue', version:'4.1.104.Final', classifier: 'osx-x86_64' + dependency 'io.netty:netty-transport-native-unix-common:4.1.104.Final' dependency 'io.opentelemetry:opentelemetry-api:1.24.0' dependency 'io.opentelemetry:opentelemetry-exporter-otlp:1.24.0' @@ -108,6 +105,20 @@ dependencyManagement { dependency 'io.reactivex.rxjava2:rxjava:2.2.21' + dependencySet(group: 'io.tmio', version: '2.4.2') { + entry 'tuweni-bytes' + entry 'tuweni-config' + entry 'tuweni-concurrent' + entry 'tuweni-crypto' + entry 'tuweni-devp2p' + entry 'tuweni-dns-discovery' + entry 'tuweni-io' + entry 'tuweni-net' + entry 'tuweni-rlp' + entry 'tuweni-toml' + entry 'tuweni-units' + } + dependencySet(group: 'io.vertx', version: '4.3.5') { entry 'vertx-auth-jwt' entry 'vertx-codegen' @@ -121,43 +132,29 @@ dependencyManagement { dependency 'junit:junit:4.13.2' - dependency 'net.java.dev.jna:jna:5.13.0' + dependency 'net.java.dev.jna:jna:5.14.0' - dependency 'org.apache.commons:commons-compress:1.23.0' - dependency 'org.apache.commons:commons-lang3:3.12.0' - dependency 'org.apache.commons:commons-text:1.10.0' + dependency 'org.apache.commons:commons-compress:1.25.0' + dependency 'org.apache.commons:commons-lang3:3.14.0' + dependency 'org.apache.commons:commons-text:1.11.0' - dependencySet(group: 'org.apache.logging.log4j', version: '2.20.0') { + dependencySet(group: 'org.apache.logging.log4j', version: '2.22.1') { entry 'log4j-api' entry 'log4j-core' entry 'log4j-jul' entry 'log4j-slf4j2-impl' } - dependencySet(group: 'io.tmio', version: '2.4.2') { - entry 'tuweni-bytes' - entry 'tuweni-config' - entry 'tuweni-concurrent' - entry 'tuweni-crypto' - entry 'tuweni-devp2p' - entry 'tuweni-dns-discovery' - entry 'tuweni-io' - entry 'tuweni-net' - entry 'tuweni-rlp' - entry 'tuweni-toml' - entry 'tuweni-units' - } - - dependency 'org.assertj:assertj-core:3.24.2' + dependency 'org.assertj:assertj-core:3.25.1' dependency 'org.awaitility:awaitility:4.2.0' - dependencySet(group: 'org.bouncycastle', version: '1.76') { + dependencySet(group: 'org.bouncycastle', version: '1.77') { entry'bcpkix-jdk18on' entry'bcprov-jdk18on' } - dependency 'org.fusesource.jansi:jansi:2.4.0' + dependency 'org.fusesource.jansi:jansi:2.4.1' dependency 'org.openjdk.jol:jol-core:0.17' dependency 'tech.pegasys:jc-kzg-4844:0.8.0' @@ -170,16 +167,16 @@ dependencyManagement { entry 'blake2bf' } - dependencySet(group: 'org.immutables', version: '2.9.3') { + dependencySet(group: 'org.immutables', version: '2.10.0') { entry 'value-annotations' entry 'value' } - dependency 'org.java-websocket:Java-WebSocket:1.5.3' + dependency 'org.java-websocket:Java-WebSocket:1.5.5' - dependency 'org.jetbrains.kotlin:kotlin-stdlib:1.8.10' + dependency 'org.jetbrains.kotlin:kotlin-stdlib:1.9.22' - dependencySet(group: 'org.junit.jupiter', version: '5.8.2') { + dependencySet(group: 'org.junit.jupiter', version: '5.10.1') { entry 'junit-jupiter' entry 'junit-jupiter-api' entry 'junit-jupiter-engine' @@ -188,9 +185,9 @@ dependencyManagement { dependency 'org.junit.platform:junit-platform-runner:1.9.2' - dependency 'org.junit.vintage:junit-vintage-engine:5.9.2' + dependency 'org.junit.vintage:junit-vintage-engine:5.10.1' - dependencySet(group: 'org.jupnp', version:'2.7.0') { + dependencySet(group: 'org.jupnp', version:'2.7.1') { entry 'org.jupnp.support' entry 'org.jupnp' } @@ -207,31 +204,33 @@ dependencyManagement { dependency 'org.owasp.encoder:encoder:1.2.3' - dependency 'org.rocksdb:rocksdbjni:8.3.2' + dependency 'org.rocksdb:rocksdbjni:8.9.1' - dependencySet(group: 'org.slf4j', version:'2.0.7') { + dependencySet(group: 'org.slf4j', version:'2.0.10') { entry 'slf4j-api' entry 'slf4j-nop' } - dependency 'org.springframework.security:spring-security-crypto:6.0.2' + dependency 'org.springframework.security:spring-security-crypto:6.2.1' - dependency 'org.testcontainers:testcontainers:1.17.6' + dependency 'org.testcontainers:testcontainers:1.19.3' dependency 'org.web3j:quorum:4.9.5' - dependencySet(group: 'org.web3j', version: '4.9.7') { + dependencySet(group: 'org.web3j', version: '4.10.3') { entry 'abi' entry 'besu' entry 'core' entry 'crypto' } - dependency 'org.xerial.snappy:snappy-java:1.1.9.1' + dependencySet(group: 'org.wiremock', version: '3.3.1') { + entry 'wiremock' + } + + dependency 'org.xerial.snappy:snappy-java:1.1.10.5' dependency 'org.yaml:snakeyaml:2.0' dependency 'tech.pegasys.discovery:discovery:22.2.0' - - dependency 'com.github.oshi:oshi-core:6.4.1' } } From 945a44c598a83003c0bc36d5ccce5c48cf5e3425 Mon Sep 17 00:00:00 2001 From: garyschulte Date: Thu, 11 Jan 2024 09:01:01 -0800 Subject: [PATCH 02/14] add a fallback for docker detection on Mac (#6356) Signed-off-by: garyschulte --- .../java/org/hyperledger/besu/nat/docker/DockerDetector.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nat/src/main/java/org/hyperledger/besu/nat/docker/DockerDetector.java b/nat/src/main/java/org/hyperledger/besu/nat/docker/DockerDetector.java index 5504def9c8d..e7f1cf2328b 100644 --- a/nat/src/main/java/org/hyperledger/besu/nat/docker/DockerDetector.java +++ b/nat/src/main/java/org/hyperledger/besu/nat/docker/DockerDetector.java @@ -33,6 +33,8 @@ public Optional detect() { return stream .filter(line -> line.contains("/docker")) .findFirst() + // fallback to looking for /.dockerenv in case we are running on Docker for Mac + .or(() -> Optional.ofNullable(Files.exists(Paths.get("/.dockerenv")) ? "docker" : null)) .map(__ -> NatMethod.DOCKER); } catch (IOException e) { return Optional.empty(); From c66054633d1a8cc38bbcb22e6f3e31e61464874a Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Fri, 12 Jan 2024 01:53:09 +0100 Subject: [PATCH 03/14] Fix test flackyness of acceptanceTestsPermissioning (#6384) Signed-off-by: Fabio Di Fabio Signed-off-by: Sally MacFarlane Co-authored-by: Sally MacFarlane --- .circleci/config.yml | 6 +-- .../dsl/condition/eth/EthConditions.java | 4 ++ .../condition/eth/SyncingStatusCondition.java | 40 +++++++++++++++++++ .../acceptance/dsl/node/cluster/Cluster.java | 7 +--- .../eth/EthSyncingTransaction.java | 40 +++++++++++++++++++ .../dsl/transaction/eth/EthTransactions.java | 4 ++ ...rtContractPermissioningAcceptanceTest.java | 5 +++ ...ContractPermissioningV2AcceptanceTest.java | 5 +++ .../simple_permissioning_genesis.json | 2 +- .../simple_permissioning_v2_genesis.json | 2 +- 10 files changed, 105 insertions(+), 10 deletions(-) create mode 100644 acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/eth/SyncingStatusCondition.java create mode 100644 acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/eth/EthSyncingTransaction.java diff --git a/.circleci/config.yml b/.circleci/config.yml index bcd81e45cbe..2f008df2578 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -269,7 +269,7 @@ jobs: - capture_test_logs acceptanceTestsPermissioning: - executor: besu_executor_xl + executor: besu_executor_med steps: - prepare - attach_workspace: @@ -278,7 +278,7 @@ jobs: name: AcceptanceTests (Non-Mainnet) no_output_timeout: 20m command: | - ./gradlew --no-daemon acceptanceTestPermissioning + ./gradlew --no-daemon --max-workers=1 acceptanceTestPermissioning - capture_test_results - capture_test_logs @@ -428,12 +428,12 @@ workflows: - acceptanceTestsPermissioning: requires: - assemble - - acceptanceTestsCliqueBft - buildDocker: requires: - assemble - buildArm64Docker: requires: + - buildDocker - assemble - publish: filters: diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/eth/EthConditions.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/eth/EthConditions.java index c4ee1347278..d3a86bafa86 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/eth/EthConditions.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/eth/EthConditions.java @@ -77,6 +77,10 @@ public Condition miningStatus(final boolean isMining) { return new MiningStatusCondition(transactions.mining(), isMining); } + public Condition syncingStatus(final boolean isSyncing) { + return new SyncingStatusCondition(transactions.syncing(), isSyncing); + } + public Condition expectNewPendingTransactions( final BigInteger filterId, final List transactionHashes) { return new NewPendingTransactionFilterChangesCondition( diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/eth/SyncingStatusCondition.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/eth/SyncingStatusCondition.java new file mode 100644 index 00000000000..5e01a0d4a90 --- /dev/null +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/eth/SyncingStatusCondition.java @@ -0,0 +1,40 @@ +/* + * Copyright Hyperledger Besu Contributors. + * + * 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 org.hyperledger.besu.tests.acceptance.dsl.condition.eth; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.hyperledger.besu.tests.acceptance.dsl.WaitUtils; +import org.hyperledger.besu.tests.acceptance.dsl.condition.Condition; +import org.hyperledger.besu.tests.acceptance.dsl.node.Node; +import org.hyperledger.besu.tests.acceptance.dsl.transaction.eth.EthSyncingTransaction; + +public class SyncingStatusCondition implements Condition { + + private final EthSyncingTransaction transaction; + private final boolean syncingMiningStatus; + + public SyncingStatusCondition( + final EthSyncingTransaction transaction, final boolean syncingStatus) { + this.transaction = transaction; + this.syncingMiningStatus = syncingStatus; + } + + @Override + public void verify(final Node node) { + WaitUtils.waitFor( + 10, () -> assertThat(node.execute(transaction)).isEqualTo(syncingMiningStatus)); + } +} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/cluster/Cluster.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/cluster/Cluster.java index 16a02874262..b454894e066 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/cluster/Cluster.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/cluster/Cluster.java @@ -86,11 +86,8 @@ public void start(final List nodes) { final Optional bootnode = selectAndStartBootnode(nodes); nodes.parallelStream() - .filter( - node -> { - LOG.info("starting non-bootnode {}", node.getName()); - return bootnode.map(boot -> boot != node).orElse(true); - }) + .filter(node -> bootnode.map(boot -> boot != node).orElse(true)) + .peek(node -> LOG.info("starting non-bootnode {}", node.getName())) .forEach(this::startNode); if (clusterConfiguration.isAwaitPeerDiscovery()) { diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/eth/EthSyncingTransaction.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/eth/EthSyncingTransaction.java new file mode 100644 index 00000000000..21b628abef2 --- /dev/null +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/eth/EthSyncingTransaction.java @@ -0,0 +1,40 @@ +/* + * Copyright Hyperledger Besu Contributors. + * + * 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 org.hyperledger.besu.tests.acceptance.dsl.transaction.eth; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; +import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; + +import java.io.IOException; + +import org.web3j.protocol.core.methods.response.EthSyncing; + +public class EthSyncingTransaction implements Transaction { + + EthSyncingTransaction() {} + + @Override + public Boolean execute(final NodeRequests node) { + try { + EthSyncing response = node.eth().ethSyncing().send(); + assertThat(response).isNotNull(); + return response.isSyncing(); + } catch (final IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/eth/EthTransactions.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/eth/EthTransactions.java index 84882b822d0..b8b72052d0b 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/eth/EthTransactions.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/eth/EthTransactions.java @@ -73,6 +73,10 @@ public EthMiningTransaction mining() { return new EthMiningTransaction(); } + public EthSyncingTransaction syncing() { + return new EthSyncingTransaction(); + } + public EthNewPendingTransactionFilterTransaction newPendingTransactionsFilter() { return new EthNewPendingTransactionFilterTransaction(); } diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTest.java index c5fbb693043..e9442bc0077 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTest.java @@ -49,6 +49,11 @@ public void setUp() { permissionedNode.verify(admin.addPeer(bootnode)); permissionedNode.verify(admin.addPeer(allowedNode)); + + allowedNode.verify(eth.syncingStatus(false)); + bootnode.verify(eth.syncingStatus(false)); + permissionedNode.verify(eth.syncingStatus(false)); + forbiddenNode.verify(eth.syncingStatus(false)); } @Test diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningV2AcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningV2AcceptanceTest.java index 72aab9cb7e4..b04bad5644d 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningV2AcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningV2AcceptanceTest.java @@ -46,6 +46,11 @@ public void setUp() { permissionedNode.execute(allowNode(permissionedNode)); permissionedNode.verify(connectionIsAllowed(permissionedNode)); + + allowedNode.verify(eth.syncingStatus(false)); + bootnode.verify(eth.syncingStatus(false)); + permissionedNode.verify(eth.syncingStatus(false)); + forbiddenNode.verify(eth.syncingStatus(false)); } @Test diff --git a/acceptance-tests/tests/src/test/resources/permissioning/simple_permissioning_genesis.json b/acceptance-tests/tests/src/test/resources/permissioning/simple_permissioning_genesis.json index 04ee1a4882e..5e8bc92a46a 100644 --- a/acceptance-tests/tests/src/test/resources/permissioning/simple_permissioning_genesis.json +++ b/acceptance-tests/tests/src/test/resources/permissioning/simple_permissioning_genesis.json @@ -4,7 +4,7 @@ "londonBlock": 0, "zeroBaseFee": true, "ethash": { - "fixeddifficulty": 100 + "fixeddifficulty": 500 } }, "nonce": "0x42", diff --git a/acceptance-tests/tests/src/test/resources/permissioning/simple_permissioning_v2_genesis.json b/acceptance-tests/tests/src/test/resources/permissioning/simple_permissioning_v2_genesis.json index b7ec620f310..aab9a35cdd3 100644 --- a/acceptance-tests/tests/src/test/resources/permissioning/simple_permissioning_v2_genesis.json +++ b/acceptance-tests/tests/src/test/resources/permissioning/simple_permissioning_v2_genesis.json @@ -4,7 +4,7 @@ "londonBlock": 0, "zeroBaseFee": true, "ethash": { - "fixeddifficulty": 100 + "fixeddifficulty": 500 } }, "nonce": "0x42", From d918baa4ae93be24a7a4988226d23f07cd190599 Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Fri, 12 Jan 2024 02:27:59 +0100 Subject: [PATCH 04/14] Upgrade `com.fasterxml.jackson` dependencies (#6378) Signed-off-by: Fabio Di Fabio --- CHANGELOG.md | 1 + gradle/verification-metadata.xml | 166 ++++++------------ gradle/versions.gradle | 2 +- .../besu/testutil/JsonTestParameters.java | 9 +- 4 files changed, 60 insertions(+), 118 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 912122e786b..64aeb93ab02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - Optimize RocksDB WAL files, allows for faster restart and a more linear disk space utilization [#6328](https://github.com/hyperledger/besu/pull/6328) - Disable transaction handling when the node is not in sync, to avoid unnecessary transaction validation work [#6302](https://github.com/hyperledger/besu/pull/6302) - Upgrade dependencies [#6377](https://github.com/hyperledger/besu/pull/6377) +- Upgrade `com.fasterxml.jackson` dependencies [#6378](https://github.com/hyperledger/besu/pull/6378) ### Bug fixes - INTERNAL_ERROR from `eth_estimateGas` JSON/RPC calls [#6344](https://github.com/hyperledger/besu/issues/6344) diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index d0cfe4bd752..30d55eb6840 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -131,14 +131,9 @@ - - - - - - - - + + + @@ -181,6 +176,11 @@ + + + + + @@ -225,20 +225,12 @@ - - - + + + - - - - - - - - - - + + @@ -273,20 +265,12 @@ - - - + + + - - - - - - - - - - + + @@ -318,84 +302,55 @@ - - - + + + - - + + - - - + + + - - - - - - - + + - - - - - - - - - - + + - - - + + + - - - + + + - - + + - - + + - - - + + + - - + + - - + + - - - - - - - - - - - - - - - - - - - + + + @@ -1392,14 +1347,6 @@ - - - - - - - - @@ -5301,11 +5248,6 @@ - - - - - @@ -5351,14 +5293,6 @@ - - - - - - - - diff --git a/gradle/versions.gradle b/gradle/versions.gradle index 45626801fc0..b497109d782 100644 --- a/gradle/versions.gradle +++ b/gradle/versions.gradle @@ -22,7 +22,7 @@ dependencyManagement { entry 'antlr4-runtime' } - dependencySet(group:'com.fasterxml.jackson.core', version:'2.14.2') { + dependencySet(group:'com.fasterxml.jackson.core', version:'2.16.1') { entry 'jackson-databind' entry 'jackson-datatype' entry 'jackson-datatype-jdk8' diff --git a/testutil/src/main/java/org/hyperledger/besu/testutil/JsonTestParameters.java b/testutil/src/main/java/org/hyperledger/besu/testutil/JsonTestParameters.java index f4fc7c49a36..69b21b37c8b 100644 --- a/testutil/src/main/java/org/hyperledger/besu/testutil/JsonTestParameters.java +++ b/testutil/src/main/java/org/hyperledger/besu/testutil/JsonTestParameters.java @@ -37,6 +37,8 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonFactoryBuilder; +import com.fasterxml.jackson.core.StreamReadConstraints; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; @@ -121,7 +123,12 @@ public interface Generator { } private static final ObjectMapper objectMapper = - new ObjectMapper().registerModule(new Jdk8Module()); + new ObjectMapper( + new JsonFactoryBuilder() + .streamReadConstraints( + StreamReadConstraints.builder().maxStringLength(Integer.MAX_VALUE).build()) + .build()) + .registerModule(new Jdk8Module()); // The type to which the json file is directly mapped private final Class jsonFileMappedType; From f146e7808317fded0b363b23379f60c51fe1e8c7 Mon Sep 17 00:00:00 2001 From: daniellehrner Date: Fri, 12 Jan 2024 03:02:33 +0100 Subject: [PATCH 05/14] Use mining beneficiary from protocol spec in TraceServiceImpl (#6390) * use mining beneficiary from protocol spec Signed-off-by: Daniel Lehrner --------- Signed-off-by: Daniel Lehrner Co-authored-by: Sally MacFarlane --- CHANGELOG.md | 1 + .../java/org/hyperledger/besu/services/TraceServiceImpl.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64aeb93ab02..f420def0cb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - INTERNAL_ERROR from `eth_estimateGas` JSON/RPC calls [#6344](https://github.com/hyperledger/besu/issues/6344) - Fix Besu Docker images with `openjdk-latest` tags since 23.10.3 using UID 1001 instead of 1000 for the `besu` user [#6360](https://github.com/hyperledger/besu/pull/6360) - Fluent EVM API definition for Tangerine Whistle had incorrect code size validation configured [#6382](https://github.com/hyperledger/besu/pull/6382) +- Correct mining beneficiary for Clique networks in TraceServiceImpl [#6390](https://github.com/hyperledger/besu/pull/6390) ### Download Links diff --git a/besu/src/main/java/org/hyperledger/besu/services/TraceServiceImpl.java b/besu/src/main/java/org/hyperledger/besu/services/TraceServiceImpl.java index 3ab2961734f..43af4e3866e 100644 --- a/besu/src/main/java/org/hyperledger/besu/services/TraceServiceImpl.java +++ b/besu/src/main/java/org/hyperledger/besu/services/TraceServiceImpl.java @@ -216,7 +216,7 @@ private List trace( worldUpdater, header, transaction, - header.getCoinbase(), + protocolSpec.getMiningBeneficiaryCalculator().calculateBeneficiary(header), tracer, new CachingBlockHashLookup(header, blockchain), false, From 33df79dd4ae5a25713659ad7f61cdda33bb64380 Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Fri, 12 Jan 2024 04:50:15 +0100 Subject: [PATCH 06/14] Make transaction pool configurable in acceptance tests (#6380) * Make transaction pool configurable in acceptance tests (#33) Signed-off-by: Fabio Di Fabio * Make BesuNode::getMiningParameters public Signed-off-by: Fabio Di Fabio --------- Signed-off-by: Fabio Di Fabio Co-authored-by: Sally MacFarlane --- .../besu/tests/acceptance/dsl/node/BesuNode.java | 15 ++++++++++++++- .../dsl/node/ProcessBesuNodeRunner.java | 14 +++++++++++--- .../acceptance/dsl/node/ThreadBesuNodeRunner.java | 1 + .../node/configuration/BesuNodeConfiguration.java | 8 ++++++++ .../BesuNodeConfigurationBuilder.java | 11 ++++++++++- .../dsl/node/configuration/BesuNodeFactory.java | 1 + .../tests/acceptance/dsl/privacy/PrivacyNode.java | 1 + 7 files changed, 46 insertions(+), 5 deletions(-) diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java index c8613e9a4ba..ba00ac8f22f 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java @@ -29,6 +29,7 @@ import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Util; +import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration; import org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration; import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration; @@ -100,6 +101,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable private final String name; private MiningParameters miningParameters; + private TransactionPoolConfiguration txPoolConfiguration; private final List runCommand; private PrivacyParameters privacyParameters = PrivacyParameters.DEFAULT; private final JsonRpcConfiguration jsonRpcConfiguration; @@ -135,6 +137,7 @@ public BesuNode( final String name, final Optional dataPath, final MiningParameters miningParameters, + final TransactionPoolConfiguration txPoolConfiguration, final JsonRpcConfiguration jsonRpcConfiguration, final Optional engineRpcConfiguration, final WebSocketConfiguration webSocketConfiguration, @@ -184,6 +187,7 @@ public BesuNode( () -> this.keyPair = KeyPairUtil.loadKeyPair(homeDirectory)); this.name = name; this.miningParameters = miningParameters; + this.txPoolConfiguration = txPoolConfiguration; this.jsonRpcConfiguration = jsonRpcConfiguration; this.engineRpcConfiguration = engineRpcConfiguration; this.webSocketConfiguration = webSocketConfiguration; @@ -661,7 +665,7 @@ public void setBootnodes(final List bootnodes) { this.bootnodes.addAll(bootnodes); } - MiningParameters getMiningParameters() { + public MiningParameters getMiningParameters() { return miningParameters; } @@ -669,6 +673,15 @@ public void setMiningParameters(final MiningParameters miningParameters) { this.miningParameters = miningParameters; } + public TransactionPoolConfiguration getTransactionPoolConfiguration() { + return txPoolConfiguration; + } + + public void setTransactionPoolConfiguration( + final TransactionPoolConfiguration txPoolConfiguration) { + this.txPoolConfiguration = txPoolConfiguration; + } + public PrivacyParameters getPrivacyParameters() { return privacyParameters; } diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java index f01c58549bc..538cb89e126 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ProcessBesuNodeRunner.java @@ -17,8 +17,10 @@ import static com.google.common.base.Preconditions.checkState; import static java.nio.charset.StandardCharsets.UTF_8; +import org.hyperledger.besu.cli.options.TransactionPoolOptions; import org.hyperledger.besu.cli.options.unstable.NetworkingOptions; import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration; +import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration; import org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration; import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration; import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; @@ -98,6 +100,15 @@ public void startNode(final BesuNode node) { params.add("--p2p-port"); params.add(node.getP2pPort()); + params.addAll( + TransactionPoolOptions.fromConfig( + ImmutableTransactionPoolConfiguration.builder() + .from(node.getTransactionPoolConfiguration()) + .strictTransactionReplayProtectionEnabled( + node.isStrictTxReplayProtectionEnabled()) + .build()) + .getCLIOptions()); + if (node.getMiningParameters().isMiningEnabled()) { params.add("--miner-enabled"); params.add("--miner-coinbase"); @@ -391,9 +402,6 @@ public void startNode(final BesuNode node) { params.add("--auto-log-bloom-caching-enabled"); params.add("false"); - params.add("--strict-tx-replay-protection-enabled"); - params.add(Boolean.toString(node.isStrictTxReplayProtectionEnabled())); - final String level = System.getProperty("root.log.level"); if (level != null) { params.add("--logging=" + level); diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java index 501674ea383..429c91d2b99 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java @@ -182,6 +182,7 @@ public void startNode(final BesuNode node) { final TransactionPoolConfiguration txPoolConfig = ImmutableTransactionPoolConfiguration.builder() + .from(node.getTransactionPoolConfiguration()) .strictTransactionReplayProtectionEnabled(node.isStrictTxReplayProtectionEnabled()) .build(); diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java index 3a61749881a..0c0d66be6a8 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java @@ -22,6 +22,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration; import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; +import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration; import org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration; import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration; @@ -39,6 +40,7 @@ public class BesuNodeConfiguration { private final String name; private final Optional dataPath; private final MiningParameters miningParameters; + private final TransactionPoolConfiguration transactionPoolConfiguration; private final JsonRpcConfiguration jsonRpcConfiguration; private final Optional engineRpcConfiguration; private final WebSocketConfiguration webSocketConfiguration; @@ -74,6 +76,7 @@ public class BesuNodeConfiguration { final String name, final Optional dataPath, final MiningParameters miningParameters, + final TransactionPoolConfiguration transactionPoolConfiguration, final JsonRpcConfiguration jsonRpcConfiguration, final Optional engineRpcConfiguration, final WebSocketConfiguration webSocketConfiguration, @@ -106,6 +109,7 @@ public class BesuNodeConfiguration { final Map environment) { this.name = name; this.miningParameters = miningParameters; + this.transactionPoolConfiguration = transactionPoolConfiguration; this.jsonRpcConfiguration = jsonRpcConfiguration; this.engineRpcConfiguration = engineRpcConfiguration; this.webSocketConfiguration = webSocketConfiguration; @@ -147,6 +151,10 @@ public MiningParameters getMiningParameters() { return miningParameters; } + public TransactionPoolConfiguration getTransactionPoolConfiguration() { + return transactionPoolConfiguration; + } + public JsonRpcConfiguration getJsonRpcConfiguration() { return jsonRpcConfiguration; } diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java index 2a7f16d24fd..c20e7ec6d11 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java @@ -35,6 +35,7 @@ import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; +import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration; import org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration; import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration; @@ -63,7 +64,8 @@ public class BesuNodeConfigurationBuilder { .mutableInitValues( MutableInitValues.builder().coinbase(AddressHelpers.ofValue(1)).build()) .build(); - + private TransactionPoolConfiguration transactionPoolConfiguration = + TransactionPoolConfiguration.DEFAULT; private JsonRpcConfiguration jsonRpcConfiguration = JsonRpcConfiguration.createDefault(); private JsonRpcConfiguration engineRpcConfiguration = JsonRpcConfiguration.createEngineDefault(); private WebSocketConfiguration webSocketConfiguration = WebSocketConfiguration.createDefault(); @@ -128,6 +130,12 @@ public BesuNodeConfigurationBuilder miningConfiguration(final MiningParameters m return this; } + public BesuNodeConfigurationBuilder transactionPoolConfiguration( + final TransactionPoolConfiguration transactionPoolConfiguration) { + this.transactionPoolConfiguration = transactionPoolConfiguration; + return this; + } + public BesuNodeConfigurationBuilder jsonRpcConfiguration( final JsonRpcConfiguration jsonRpcConfiguration) { this.jsonRpcConfiguration = jsonRpcConfiguration; @@ -503,6 +511,7 @@ public BesuNodeConfiguration build() { name, dataPath, miningParameters, + transactionPoolConfiguration, jsonRpcConfiguration, Optional.of(engineRpcConfiguration), webSocketConfiguration, diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java index 4b24071ab33..ed26587812c 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java @@ -64,6 +64,7 @@ public BesuNode create(final BesuNodeConfiguration config) throws IOException { config.getName(), config.getDataPath(), config.getMiningParameters(), + config.getTransactionPoolConfiguration(), config.getJsonRpcConfiguration(), config.getEngineRpcConfiguration(), config.getWebSocketConfiguration(), diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java index 3d397e24e27..4ec4396d6b5 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java @@ -100,6 +100,7 @@ public PrivacyNode( besuConfig.getName(), besuConfig.getDataPath(), besuConfig.getMiningParameters(), + besuConfig.getTransactionPoolConfiguration(), besuConfig.getJsonRpcConfiguration(), besuConfig.getEngineRpcConfiguration(), besuConfig.getWebSocketConfiguration(), From 540f5a4c768a4c810e2e16a4480dc9fa9d319935 Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Fri, 12 Jan 2024 10:21:49 +0100 Subject: [PATCH 07/14] Introduce TransactionEvaluationContext to pass data between selectors and plugin (#6381) Signed-off-by: Fabio Di Fabio --- CHANGELOG.md | 1 + .../txselection/BlockTransactionSelector.java | 91 +++++++++++-------- .../TransactionEvaluationContext.java | 66 ++++++++++++++ .../AbstractTransactionSelector.java | 10 +- .../AllAcceptingTransactionSelector.java | 9 +- .../BlobPriceTransactionSelector.java | 11 ++- .../BlockSizeTransactionSelector.java | 13 +-- ...nPriorityFeePerGasTransactionSelector.java | 11 ++- .../selectors/PriceTransactionSelector.java | 29 +++--- .../ProcessingResultTransactionSelector.java | 10 +- .../AbstractBlockTransactionSelectorTest.java | 39 +++++--- ...orityFeePerGasTransactionSelectorTest.java | 33 ++++--- plugin-api/build.gradle | 2 +- .../PluginTransactionSelector.java | 17 ++-- .../TransactionEvaluationContext.java | 57 ++++++++++++ 15 files changed, 277 insertions(+), 122 deletions(-) create mode 100644 ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/TransactionEvaluationContext.java create mode 100644 plugin-api/src/main/java/org/hyperledger/besu/plugin/services/txselection/TransactionEvaluationContext.java diff --git a/CHANGELOG.md b/CHANGELOG.md index f420def0cb8..abcc2ab3c85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ ### Additions and Improvements - Optimize RocksDB WAL files, allows for faster restart and a more linear disk space utilization [#6328](https://github.com/hyperledger/besu/pull/6328) - Disable transaction handling when the node is not in sync, to avoid unnecessary transaction validation work [#6302](https://github.com/hyperledger/besu/pull/6302) +- Introduce TransactionEvaluationContext to pass data between transaction selectors and plugin, during block creation [#6381](https://github.com/hyperledger/besu/pull/6381) - Upgrade dependencies [#6377](https://github.com/hyperledger/besu/pull/6377) - Upgrade `com.fasterxml.jackson` dependencies [#6378](https://github.com/hyperledger/besu/pull/6378) diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockTransactionSelector.java index 4a0707e76f7..944cf426d73 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockTransactionSelector.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockTransactionSelector.java @@ -228,26 +228,42 @@ private TransactionSelectionResult evaluateTransaction( final PendingTransaction pendingTransaction) { checkCancellation(); - final Stopwatch evaluationTimer = Stopwatch.createStarted(); + final TransactionEvaluationContext evaluationContext = + createTransactionEvaluationContext(pendingTransaction); - TransactionSelectionResult selectionResult = evaluatePreProcessing(pendingTransaction); + TransactionSelectionResult selectionResult = evaluatePreProcessing(evaluationContext); if (!selectionResult.selected()) { - return handleTransactionNotSelected(pendingTransaction, selectionResult, evaluationTimer); + return handleTransactionNotSelected(evaluationContext, selectionResult); } final WorldUpdater txWorldStateUpdater = blockWorldStateUpdater.updater(); final TransactionProcessingResult processingResult = processTransaction(pendingTransaction, txWorldStateUpdater); - var postProcessingSelectionResult = - evaluatePostProcessing(pendingTransaction, processingResult); + var postProcessingSelectionResult = evaluatePostProcessing(evaluationContext, processingResult); if (postProcessingSelectionResult.selected()) { - return handleTransactionSelected( - pendingTransaction, processingResult, txWorldStateUpdater, evaluationTimer); + return handleTransactionSelected(evaluationContext, processingResult, txWorldStateUpdater); } return handleTransactionNotSelected( - pendingTransaction, postProcessingSelectionResult, txWorldStateUpdater, evaluationTimer); + evaluationContext, postProcessingSelectionResult, txWorldStateUpdater); + } + + private TransactionEvaluationContext createTransactionEvaluationContext( + final PendingTransaction pendingTransaction) { + final Wei transactionGasPriceInBlock = + blockSelectionContext + .feeMarket() + .getTransactionPriceCalculator() + .price( + pendingTransaction.getTransaction(), + blockSelectionContext.processableBlockHeader().getBaseFee()); + + return new TransactionEvaluationContext( + pendingTransaction, + Stopwatch.createStarted(), + transactionGasPriceInBlock, + blockSelectionContext.miningParameters().getMinTransactionGasPrice()); } /** @@ -256,21 +272,20 @@ private TransactionSelectionResult evaluateTransaction( * it then processes it through external selectors. If the transaction is selected by all * selectors, it returns SELECTED. * - * @param pendingTransaction The transaction to be evaluated. + * @param evaluationContext The current selection session data. * @return The result of the transaction selection process. */ private TransactionSelectionResult evaluatePreProcessing( - final PendingTransaction pendingTransaction) { + final TransactionEvaluationContext evaluationContext) { for (var selector : transactionSelectors) { TransactionSelectionResult result = - selector.evaluateTransactionPreProcessing( - pendingTransaction, transactionSelectionResults); + selector.evaluateTransactionPreProcessing(evaluationContext, transactionSelectionResults); if (!result.equals(SELECTED)) { return result; } } - return pluginTransactionSelector.evaluateTransactionPreProcessing(pendingTransaction); + return pluginTransactionSelector.evaluateTransactionPreProcessing(evaluationContext); } /** @@ -279,24 +294,24 @@ private TransactionSelectionResult evaluatePreProcessing( * whether the transaction should be included in a block. If the transaction is selected by all * selectors, it returns SELECTED. * - * @param pendingTransaction The transaction to be evaluated. + * @param evaluationContext The current selection session data. * @param processingResult The result of the transaction processing. * @return The result of the transaction selection process. */ private TransactionSelectionResult evaluatePostProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionProcessingResult processingResult) { for (var selector : transactionSelectors) { TransactionSelectionResult result = selector.evaluateTransactionPostProcessing( - pendingTransaction, transactionSelectionResults, processingResult); + evaluationContext, transactionSelectionResults, processingResult); if (!result.equals(SELECTED)) { return result; } } return pluginTransactionSelector.evaluateTransactionPostProcessing( - pendingTransaction, processingResult); + evaluationContext, processingResult); } /** @@ -328,18 +343,16 @@ private TransactionProcessingResult processTransaction( * receipt, updating the TransactionSelectionResults with the selected transaction, and notifying * the external transaction selector. * - * @param pendingTransaction The pending transaction. + * @param evaluationContext The current selection session data. * @param processingResult The result of the transaction processing. * @param txWorldStateUpdater The world state updater. - * @param evaluationTimer tracks the evaluation elapsed time * @return The result of the transaction selection process. */ private TransactionSelectionResult handleTransactionSelected( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionProcessingResult processingResult, - final WorldUpdater txWorldStateUpdater, - final Stopwatch evaluationTimer) { - final Transaction transaction = pendingTransaction.getTransaction(); + final WorldUpdater txWorldStateUpdater) { + final Transaction transaction = evaluationContext.getTransaction(); final long gasUsedByTransaction = transaction.getGasLimit() - processingResult.getGasRemaining(); @@ -363,13 +376,14 @@ private TransactionSelectionResult handleTransactionSelected( transaction.getType(), processingResult, worldState, cumulativeGasUsed); transactionSelectionResults.updateSelected( - pendingTransaction.getTransaction(), receipt, gasUsedByTransaction, blobGasUsed); + transaction, receipt, gasUsedByTransaction, blobGasUsed); } } if (tooLate) { // even if this tx passed all the checks, it is too late to include it in this block, // so we need to treat it as not selected + final var evaluationTimer = evaluationContext.getEvaluationTimer(); // check if this tx took too much to evaluate, and in case remove it from the pool final TransactionSelectionResult timeoutSelectionResult; @@ -395,15 +409,15 @@ private TransactionSelectionResult handleTransactionSelected( // do not rely on the presence of this result, since by the time it is added, the code // reading it could have been already executed by another thread return handleTransactionNotSelected( - pendingTransaction, timeoutSelectionResult, txWorldStateUpdater, evaluationTimer); + evaluationContext, timeoutSelectionResult, txWorldStateUpdater); } - pluginTransactionSelector.onTransactionSelected(pendingTransaction, processingResult); + pluginTransactionSelector.onTransactionSelected(evaluationContext, processingResult); blockWorldStateUpdater = worldState.updater(); LOG.atTrace() .setMessage("Selected {} for block creation, evaluated in {}") .addArgument(transaction::toTraceLog) - .addArgument(evaluationTimer) + .addArgument(evaluationContext.getPendingTransaction()) .log(); return SELECTED; } @@ -413,36 +427,35 @@ private TransactionSelectionResult handleTransactionSelected( * TransactionSelectionResults with the unselected transaction, and notifies the external * transaction selector. * - * @param pendingTransaction The unselected pending transaction. + * @param evaluationContext The current selection session data. * @param selectionResult The result of the transaction selection process. - * @param evaluationTimer tracks the evaluation elapsed time * @return The result of the transaction selection process. */ private TransactionSelectionResult handleTransactionNotSelected( - final PendingTransaction pendingTransaction, - final TransactionSelectionResult selectionResult, - final Stopwatch evaluationTimer) { + final TransactionEvaluationContext evaluationContext, + final TransactionSelectionResult selectionResult) { + + final var pendingTransaction = evaluationContext.getPendingTransaction(); transactionSelectionResults.updateNotSelected( - pendingTransaction.getTransaction(), selectionResult); - pluginTransactionSelector.onTransactionNotSelected(pendingTransaction, selectionResult); + evaluationContext.getTransaction(), selectionResult); + pluginTransactionSelector.onTransactionNotSelected(evaluationContext, selectionResult); LOG.atTrace() .setMessage("Not selected {} for block creation with result {}, evaluated in {}") .addArgument(pendingTransaction::toTraceLog) .addArgument(selectionResult) - .addArgument(evaluationTimer) + .addArgument(evaluationContext.getEvaluationTimer()) .log(); return selectionResult; } private TransactionSelectionResult handleTransactionNotSelected( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionSelectionResult selectionResult, - final WorldUpdater txWorldStateUpdater, - final Stopwatch evaluationTimer) { + final WorldUpdater txWorldStateUpdater) { txWorldStateUpdater.revert(); - return handleTransactionNotSelected(pendingTransaction, selectionResult, evaluationTimer); + return handleTransactionNotSelected(evaluationContext, selectionResult); } private void checkCancellation() { diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/TransactionEvaluationContext.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/TransactionEvaluationContext.java new file mode 100644 index 00000000000..20609ebdc84 --- /dev/null +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/TransactionEvaluationContext.java @@ -0,0 +1,66 @@ +/* + * Copyright Hyperledger Besu Contributors. + * + * 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 org.hyperledger.besu.ethereum.blockcreation.txselection; + +import org.hyperledger.besu.datatypes.Wei; +import org.hyperledger.besu.ethereum.core.Transaction; +import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction; + +import com.google.common.base.Stopwatch; + +public class TransactionEvaluationContext + implements org.hyperledger.besu.plugin.services.txselection.TransactionEvaluationContext< + PendingTransaction> { + private final org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction + pendingTransaction; + private final Stopwatch evaluationTimer; + private final Wei transactionGasPrice; + private final Wei minGasPrice; + + public TransactionEvaluationContext( + final PendingTransaction pendingTransaction, + final Stopwatch evaluationTimer, + final Wei transactionGasPrice, + final Wei minGasPrice) { + this.pendingTransaction = pendingTransaction; + this.evaluationTimer = evaluationTimer; + this.transactionGasPrice = transactionGasPrice; + this.minGasPrice = minGasPrice; + } + + public Transaction getTransaction() { + return pendingTransaction.getTransaction(); + } + + @Override + public PendingTransaction getPendingTransaction() { + return pendingTransaction; + } + + @Override + public Stopwatch getEvaluationTimer() { + return evaluationTimer; + } + + @Override + public Wei getTransactionGasPrice() { + return transactionGasPrice; + } + + @Override + public Wei getMinGasPrice() { + return minGasPrice; + } +} diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/AbstractTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/AbstractTransactionSelector.java index 205e803e820..0e7f610a1f3 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/AbstractTransactionSelector.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/AbstractTransactionSelector.java @@ -15,8 +15,8 @@ package org.hyperledger.besu.ethereum.blockcreation.txselection.selectors; import org.hyperledger.besu.ethereum.blockcreation.txselection.BlockSelectionContext; +import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionEvaluationContext; import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionSelectionResults; -import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.plugin.data.TransactionSelectionResult; @@ -34,25 +34,25 @@ public AbstractTransactionSelector(final BlockSelectionContext context) { /** * Evaluates a transaction in the context of other transactions in the same block. * - * @param pendingTransaction The transaction to be evaluated within a block. + * @param evaluationContext The current selection session data. * @param blockTransactionResults The results of other transaction evaluations in the same block. * @return The result of the transaction evaluation */ public abstract TransactionSelectionResult evaluateTransactionPreProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionSelectionResults blockTransactionResults); /** * Evaluates a transaction considering other transactions in the same block and a transaction * processing result. * - * @param pendingTransaction The transaction to be evaluated. + * @param evaluationContext The current selection session data. * @param blockTransactionResults The results of other transaction evaluations in the same block. * @param processingResult The result of transaction processing. * @return The result of the transaction evaluation */ public abstract TransactionSelectionResult evaluateTransactionPostProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionSelectionResults blockTransactionResults, final TransactionProcessingResult processingResult); } diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/AllAcceptingTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/AllAcceptingTransactionSelector.java index 9032ddca575..a2b8d57ff29 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/AllAcceptingTransactionSelector.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/AllAcceptingTransactionSelector.java @@ -18,6 +18,7 @@ import org.hyperledger.besu.plugin.data.TransactionProcessingResult; import org.hyperledger.besu.plugin.data.TransactionSelectionResult; import org.hyperledger.besu.plugin.services.txselection.PluginTransactionSelector; +import org.hyperledger.besu.plugin.services.txselection.TransactionEvaluationContext; /** A TransactionSelector that unconditionally selects all transactions. */ public class AllAcceptingTransactionSelector implements PluginTransactionSelector { @@ -29,25 +30,25 @@ private AllAcceptingTransactionSelector() {} /** * Always selects the transaction in the pre-processing stage. * - * @param pendingTransaction The transaction to be evaluated. + * @param evaluationContext The current selection context. * @return Always SELECTED. */ @Override public TransactionSelectionResult evaluateTransactionPreProcessing( - final PendingTransaction pendingTransaction) { + final TransactionEvaluationContext evaluationContext) { return TransactionSelectionResult.SELECTED; } /** * Always selects the transaction in the post-processing stage. * - * @param pendingTransaction The transaction to be evaluated. + * @param evaluationContext The current selection context. * @param processingResult The result of the transaction processing. * @return Always SELECTED. */ @Override public TransactionSelectionResult evaluateTransactionPostProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionProcessingResult processingResult) { return TransactionSelectionResult.SELECTED; } diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/BlobPriceTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/BlobPriceTransactionSelector.java index 56a17c28434..96135bea214 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/BlobPriceTransactionSelector.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/BlobPriceTransactionSelector.java @@ -15,9 +15,9 @@ package org.hyperledger.besu.ethereum.blockcreation.txselection.selectors; import org.hyperledger.besu.ethereum.blockcreation.txselection.BlockSelectionContext; +import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionEvaluationContext; import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionSelectionResults; import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.plugin.data.TransactionSelectionResult; @@ -39,14 +39,15 @@ public BlobPriceTransactionSelector(final BlockSelectionContext context) { /** * Evaluates a transaction considering its blob price. * - * @param pendingTransaction The transaction to be evaluated. + * @param evaluationContext The current selection session data. * @param ignored The results of other transaction evaluations in the same block. * @return The result of the transaction selection. */ @Override public TransactionSelectionResult evaluateTransactionPreProcessing( - final PendingTransaction pendingTransaction, final TransactionSelectionResults ignored) { - if (transactionBlobPriceBelowMin(pendingTransaction.getTransaction())) { + final TransactionEvaluationContext evaluationContext, + final TransactionSelectionResults ignored) { + if (transactionBlobPriceBelowMin(evaluationContext.getTransaction())) { return TransactionSelectionResult.BLOB_PRICE_BELOW_CURRENT_MIN; } return TransactionSelectionResult.SELECTED; @@ -54,7 +55,7 @@ public TransactionSelectionResult evaluateTransactionPreProcessing( @Override public TransactionSelectionResult evaluateTransactionPostProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionSelectionResults blockTransactionResults, final TransactionProcessingResult processingResult) { // All necessary checks were done in the pre-processing method, so nothing to do here. diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/BlockSizeTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/BlockSizeTransactionSelector.java index 96f357546f3..168107f5950 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/BlockSizeTransactionSelector.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/BlockSizeTransactionSelector.java @@ -15,9 +15,9 @@ package org.hyperledger.besu.ethereum.blockcreation.txselection.selectors; import org.hyperledger.besu.ethereum.blockcreation.txselection.BlockSelectionContext; +import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionEvaluationContext; import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionSelectionResults; import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.plugin.data.TransactionSelectionResult; @@ -40,20 +40,21 @@ public BlockSizeTransactionSelector(final BlockSelectionContext context) { * Evaluates a transaction considering other transactions in the same block. If the transaction is * too large for the block returns a selection result based on block occupancy. * - * @param pendingTransaction The transaction to be evaluated. + * @param evaluationContext The current selection session data. * @param transactionSelectionResults The results of other transaction evaluations in the same * block. * @return The result of the transaction selection. */ @Override public TransactionSelectionResult evaluateTransactionPreProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionSelectionResults transactionSelectionResults) { + if (transactionTooLargeForBlock( - pendingTransaction.getTransaction(), transactionSelectionResults)) { + evaluationContext.getTransaction(), transactionSelectionResults)) { LOG.atTrace() .setMessage("Transaction {} too large to select for block creation") - .addArgument(pendingTransaction::toTraceLog) + .addArgument(evaluationContext.getPendingTransaction()::toTraceLog) .log(); if (blockOccupancyAboveThreshold(transactionSelectionResults)) { LOG.trace("Block occupancy above threshold, completing operation"); @@ -70,7 +71,7 @@ public TransactionSelectionResult evaluateTransactionPreProcessing( @Override public TransactionSelectionResult evaluateTransactionPostProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionSelectionResults blockTransactionResults, final TransactionProcessingResult processingResult) { // All necessary checks were done in the pre-processing method, so nothing to do here. diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/MinPriorityFeePerGasTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/MinPriorityFeePerGasTransactionSelector.java index 91085f4f020..1a46242ffe2 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/MinPriorityFeePerGasTransactionSelector.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/MinPriorityFeePerGasTransactionSelector.java @@ -16,6 +16,7 @@ import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.blockcreation.txselection.BlockSelectionContext; +import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionEvaluationContext; import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionSelectionResults; import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; @@ -36,7 +37,7 @@ public MinPriorityFeePerGasTransactionSelector(final BlockSelectionContext conte /** * Evaluates a transaction before processing. * - * @param pendingTransaction The transaction to be evaluated. + * @param evaluationContext The current selection session data. * @param transactionSelectionResults The results of other transaction evaluations in the same * block. * @return TransactionSelectionResult. If the priority fee is below the minimum, it returns an @@ -44,9 +45,9 @@ public MinPriorityFeePerGasTransactionSelector(final BlockSelectionContext conte */ @Override public TransactionSelectionResult evaluateTransactionPreProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionSelectionResults transactionSelectionResults) { - if (isPriorityFeePriceBelowMinimum(pendingTransaction)) { + if (isPriorityFeePriceBelowMinimum(evaluationContext.getPendingTransaction())) { return TransactionSelectionResult.PRIORITY_FEE_PER_GAS_BELOW_CURRENT_MIN; } return TransactionSelectionResult.SELECTED; @@ -74,13 +75,13 @@ private boolean isPriorityFeePriceBelowMinimum(final PendingTransaction pendingT /** * No evaluation is performed post-processing. * - * @param pendingTransaction The processed transaction. + * @param evaluationContext The current selection session data. * @param processingResult The result of the transaction processing. * @return Always returns SELECTED. */ @Override public TransactionSelectionResult evaluateTransactionPostProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionSelectionResults blockTransactionResults, final TransactionProcessingResult processingResult) { return TransactionSelectionResult.SELECTED; diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/PriceTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/PriceTransactionSelector.java index defd75cb77c..d677ea9358f 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/PriceTransactionSelector.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/PriceTransactionSelector.java @@ -14,10 +14,9 @@ */ package org.hyperledger.besu.ethereum.blockcreation.txselection.selectors; -import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.blockcreation.txselection.BlockSelectionContext; +import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionEvaluationContext; import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionSelectionResults; -import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.plugin.data.TransactionSelectionResult; @@ -41,14 +40,15 @@ public PriceTransactionSelector(final BlockSelectionContext context) { * Evaluates a transaction considering its price. If the transaction's current price is below the * minimum, it returns a selection result indicating the reason. * - * @param pendingTransaction The transaction to be evaluated. + * @param evaluationContext The current selection session data. * @param ignored The results of other transaction evaluations in the same block. * @return The result of the transaction selection. */ @Override public TransactionSelectionResult evaluateTransactionPreProcessing( - final PendingTransaction pendingTransaction, final TransactionSelectionResults ignored) { - if (transactionCurrentPriceBelowMin(pendingTransaction)) { + final TransactionEvaluationContext evaluationContext, + final TransactionSelectionResults ignored) { + if (transactionCurrentPriceBelowMin(evaluationContext)) { return TransactionSelectionResult.CURRENT_TX_PRICE_BELOW_MIN; } return TransactionSelectionResult.SELECTED; @@ -56,7 +56,7 @@ public TransactionSelectionResult evaluateTransactionPreProcessing( @Override public TransactionSelectionResult evaluateTransactionPostProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionSelectionResults blockTransactionResults, final TransactionProcessingResult processingResult) { // All necessary checks were done in the pre-processing method, so nothing to do here. @@ -66,30 +66,25 @@ public TransactionSelectionResult evaluateTransactionPostProcessing( /** * Checks if the transaction's current price is below the minimum. * - * @param pendingTransaction The transaction to be checked. + * @param evaluationContext The current selection session data. * @return True if the transaction's current price is below the minimum, false otherwise. */ - private boolean transactionCurrentPriceBelowMin(final PendingTransaction pendingTransaction) { - final Transaction transaction = pendingTransaction.getTransaction(); + private boolean transactionCurrentPriceBelowMin( + final TransactionEvaluationContext evaluationContext) { + final PendingTransaction pendingTransaction = evaluationContext.getPendingTransaction(); // Priority txs are exempt from this check if (!pendingTransaction.hasPriority()) { - // since the minGasPrice can change at runtime, we need to recheck it everytime - final Wei transactionGasPriceInBlock = - context - .feeMarket() - .getTransactionPriceCalculator() - .price(transaction, context.processableBlockHeader().getBaseFee()); if (context .miningParameters() .getMinTransactionGasPrice() - .compareTo(transactionGasPriceInBlock) + .compareTo(evaluationContext.getTransactionGasPrice()) > 0) { LOG.atTrace() .setMessage( "Current gas price of {} is {} and lower than the configured minimum {}, skipping") .addArgument(pendingTransaction::toTraceLog) - .addArgument(transactionGasPriceInBlock::toHumanReadableString) + .addArgument(evaluationContext.getTransactionGasPrice()::toHumanReadableString) .addArgument( context.miningParameters().getMinTransactionGasPrice()::toHumanReadableString) .log(); diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/ProcessingResultTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/ProcessingResultTransactionSelector.java index 8a2778eda03..bb89b965a39 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/ProcessingResultTransactionSelector.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/ProcessingResultTransactionSelector.java @@ -15,9 +15,9 @@ package org.hyperledger.besu.ethereum.blockcreation.txselection.selectors; import org.hyperledger.besu.ethereum.blockcreation.txselection.BlockSelectionContext; +import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionEvaluationContext; import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionSelectionResults; import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; @@ -41,7 +41,7 @@ public ProcessingResultTransactionSelector(final BlockSelectionContext context) @Override public TransactionSelectionResult evaluateTransactionPreProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionSelectionResults blockTransactionResults) { // All checks depend on processingResult and will be done in the post-processing method, so // nothing to do here. @@ -53,20 +53,20 @@ public TransactionSelectionResult evaluateTransactionPreProcessing( * result. If the processing result is invalid, it determines the selection result for the invalid * result. * - * @param pendingTransaction The transaction to be evaluated. + * @param evaluationContext The current selection session data. * @param blockTransactionResults The results of other transaction evaluations in the same block. * @param processingResult The processing result of the transaction. * @return The result of the transaction selection. */ @Override public TransactionSelectionResult evaluateTransactionPostProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionSelectionResults blockTransactionResults, final TransactionProcessingResult processingResult) { if (processingResult.isInvalid()) { return transactionSelectionResultForInvalidResult( - pendingTransaction.getTransaction(), processingResult.getValidationResult()); + evaluationContext.getTransaction(), processingResult.getValidationResult()); } return TransactionSelectionResult.SELECTED; } diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockTransactionSelectorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockTransactionSelectorTest.java index 4e7b3eae5eb..0b0b2cd7831 100644 --- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockTransactionSelectorTest.java +++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockTransactionSelectorTest.java @@ -83,6 +83,7 @@ import org.hyperledger.besu.plugin.services.MetricsSystem; import org.hyperledger.besu.plugin.services.txselection.PluginTransactionSelector; import org.hyperledger.besu.plugin.services.txselection.PluginTransactionSelectorFactory; +import org.hyperledger.besu.plugin.services.txselection.TransactionEvaluationContext; import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage; import org.hyperledger.besu.util.number.Percentage; @@ -581,17 +582,25 @@ public void transactionSelectionPluginShouldWork_PreProcessing() { new PluginTransactionSelector() { @Override public TransactionSelectionResult evaluateTransactionPreProcessing( - final PendingTransaction pendingTransaction) { - if (pendingTransaction.getTransaction().equals(notSelectedTransient)) + final TransactionEvaluationContext + evaluationContext) { + if (evaluationContext + .getPendingTransaction() + .getTransaction() + .equals(notSelectedTransient)) return PluginTransactionSelectionResult.GENERIC_PLUGIN_INVALID_TRANSIENT; - if (pendingTransaction.getTransaction().equals(notSelectedInvalid)) + if (evaluationContext + .getPendingTransaction() + .getTransaction() + .equals(notSelectedInvalid)) return PluginTransactionSelectionResult.GENERIC_PLUGIN_INVALID; return SELECTED; } @Override public TransactionSelectionResult evaluateTransactionPostProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext + evaluationContext, final org.hyperledger.besu.plugin.data.TransactionProcessingResult processingResult) { return SELECTED; @@ -645,13 +654,15 @@ public void transactionSelectionPluginShouldWork_PostProcessing() { new PluginTransactionSelector() { @Override public TransactionSelectionResult evaluateTransactionPreProcessing( - final PendingTransaction pendingTransaction) { + final TransactionEvaluationContext + evaluationContext) { return SELECTED; } @Override public TransactionSelectionResult evaluateTransactionPostProcessing( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext + evaluationContext, final org.hyperledger.besu.plugin.data.TransactionProcessingResult processingResult) { // the transaction with max gas +1 should fail @@ -711,13 +722,14 @@ public void transactionSelectionPluginShouldBeNotifiedWhenTransactionSelectionCo selector.buildTransactionListForBlock(); - ArgumentCaptor argumentCaptor = - ArgumentCaptor.forClass(PendingTransaction.class); + @SuppressWarnings("unchecked") + ArgumentCaptor> argumentCaptor = + ArgumentCaptor.forClass(TransactionEvaluationContext.class); // selected transaction must be notified to the selector verify(transactionSelector) .onTransactionSelected(argumentCaptor.capture(), any(TransactionProcessingResult.class)); - PendingTransaction selected = argumentCaptor.getValue(); + PendingTransaction selected = argumentCaptor.getValue().getPendingTransaction(); assertThat(selected.getTransaction()).isEqualTo(transaction); // unselected transaction must be notified to the selector with correct reason @@ -725,7 +737,7 @@ public void transactionSelectionPluginShouldBeNotifiedWhenTransactionSelectionCo .onTransactionNotSelected( argumentCaptor.capture(), eq(TransactionSelectionResult.invalid(invalidReason.toString()))); - PendingTransaction rejectedTransaction = argumentCaptor.getValue(); + PendingTransaction rejectedTransaction = argumentCaptor.getValue().getPendingTransaction(); assertThat(rejectedTransaction.getTransaction()).isEqualTo(invalidTransaction); } @@ -931,9 +943,10 @@ private void internalBlockSelectionTimeoutSimulation( final BiFunction> tooLate = (p, t) -> invocation -> { - final org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction ptx = - invocation.getArgument(0); - if (ptx.getTransaction().equals(p)) { + final org.hyperledger.besu.ethereum.blockcreation.txselection + .TransactionEvaluationContext + ctx = invocation.getArgument(0); + if (ctx.getTransaction().equals(p)) { Thread.sleep(t); } else { Thread.sleep(fastProcessingTxTime); diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/MinPriorityFeePerGasTransactionSelectorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/MinPriorityFeePerGasTransactionSelectorTest.java index a86dc73ee46..94d3abb105c 100644 --- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/MinPriorityFeePerGasTransactionSelectorTest.java +++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/MinPriorityFeePerGasTransactionSelectorTest.java @@ -21,6 +21,7 @@ import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.blockcreation.txselection.BlockSelectionContext; +import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionEvaluationContext; import org.hyperledger.besu.ethereum.blockcreation.txselection.selectors.AbstractTransactionSelector; import org.hyperledger.besu.ethereum.blockcreation.txselection.selectors.MinPriorityFeePerGasTransactionSelector; import org.hyperledger.besu.ethereum.core.MiningParameters; @@ -29,6 +30,7 @@ import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction; import org.hyperledger.besu.plugin.data.TransactionSelectionResult; +import com.google.common.base.Stopwatch; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -56,44 +58,47 @@ public void initialize() { @Test public void shouldNotSelectWhen_PriorityFeePerGas_IsLessThan_MinPriorityFeePerGas() { - var transaction = mockTransactionWithPriorityFee(minPriorityFeeParameter - 1); + var transaction = mockTransactionEvaluationContext(minPriorityFeeParameter - 1); assertSelectionResult( transaction, TransactionSelectionResult.PRIORITY_FEE_PER_GAS_BELOW_CURRENT_MIN); } @Test public void shouldSelectWhen_PriorityFeePerGas_IsEqual_MinPriorityFeePerGas() { - var transaction = mockTransactionWithPriorityFee(minPriorityFeeParameter); + var transaction = mockTransactionEvaluationContext(minPriorityFeeParameter); assertSelectionResult(transaction, TransactionSelectionResult.SELECTED); } @Test public void shouldSelectWhen_PriorityFeePerGas_IsGreaterThan_MinPriorityFeePerGas() { - var transaction = mockTransactionWithPriorityFee(minPriorityFeeParameter + 1); + var transaction = mockTransactionEvaluationContext(minPriorityFeeParameter + 1); assertSelectionResult(transaction, TransactionSelectionResult.SELECTED); } @Test public void shouldSelectWhenPrioritySender() { - var prioritySenderTransaction = mockTransactionWithPriorityFee(minPriorityFeeParameter - 1); + final var evaluationContext = mockTransactionEvaluationContext(minPriorityFeeParameter - 1); assertSelectionResult( - prioritySenderTransaction, - TransactionSelectionResult.PRIORITY_FEE_PER_GAS_BELOW_CURRENT_MIN); - when(prioritySenderTransaction.hasPriority()).thenReturn(true); - assertSelectionResult(prioritySenderTransaction, TransactionSelectionResult.SELECTED); + evaluationContext, TransactionSelectionResult.PRIORITY_FEE_PER_GAS_BELOW_CURRENT_MIN); + when(evaluationContext.getPendingTransaction().hasPriority()).thenReturn(true); + assertSelectionResult(evaluationContext, TransactionSelectionResult.SELECTED); } private void assertSelectionResult( - final PendingTransaction transaction, final TransactionSelectionResult expectedResult) { - var actualResult = transactionSelector.evaluateTransactionPreProcessing(transaction, null); + final TransactionEvaluationContext evaluationContext, + final TransactionSelectionResult expectedResult) { + var actualResult = + transactionSelector.evaluateTransactionPreProcessing(evaluationContext, null); assertThat(actualResult).isEqualTo(expectedResult); } - private PendingTransaction mockTransactionWithPriorityFee(final int priorityFeePerGas) { - PendingTransaction mockTransaction = mock(PendingTransaction.class); + private TransactionEvaluationContext mockTransactionEvaluationContext( + final int priorityFeePerGas) { + PendingTransaction pendingTransaction = mock(PendingTransaction.class); Transaction transaction = mock(Transaction.class); - when(mockTransaction.getTransaction()).thenReturn(transaction); + when(pendingTransaction.getTransaction()).thenReturn(transaction); when(transaction.getEffectivePriorityFeePerGas(any())).thenReturn(Wei.of(priorityFeePerGas)); - return mockTransaction; + return new TransactionEvaluationContext( + pendingTransaction, Stopwatch.createStarted(), Wei.ONE, Wei.ONE); } } diff --git a/plugin-api/build.gradle b/plugin-api/build.gradle index d271094604d..1dcfd00f7ee 100644 --- a/plugin-api/build.gradle +++ b/plugin-api/build.gradle @@ -69,7 +69,7 @@ Calculated : ${currentHash} tasks.register('checkAPIChanges', FileStateChecker) { description = "Checks that the API for the Plugin-API project does not change without deliberate thought" files = sourceSets.main.allJava.files - knownHash = 'N583pqJipDs4kJkgL0cPq9PBsYdsLzvUlu2I8Kk+w7g=' + knownHash = 'IGq+V3KaStHCRFkeK3KwPxJYKO4RX9YM1O4JYITk8S8=' } check.dependsOn('checkAPIChanges') diff --git a/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/txselection/PluginTransactionSelector.java b/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/txselection/PluginTransactionSelector.java index 716a05e7d8b..3d152c370ca 100644 --- a/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/txselection/PluginTransactionSelector.java +++ b/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/txselection/PluginTransactionSelector.java @@ -39,39 +39,40 @@ default BlockAwareOperationTracer getOperationTracer() { * Method called to decide whether a transaction is added to a block. The result can also indicate * that no further transactions can be added to the block. * - * @param pendingTransaction candidate transaction + * @param evaluationContext The current selection context * @return TransactionSelectionResult that indicates whether to include the transaction */ TransactionSelectionResult evaluateTransactionPreProcessing( - PendingTransaction pendingTransaction); + TransactionEvaluationContext evaluationContext); /** * Method called to decide whether a processed transaction is added to a block. The result can * also indicate that no further transactions can be added to the block. * - * @param pendingTransaction candidate transaction + * @param evaluationContext The current selection context * @param processingResult the transaction processing result * @return TransactionSelectionResult that indicates whether to include the transaction */ TransactionSelectionResult evaluateTransactionPostProcessing( - PendingTransaction pendingTransaction, TransactionProcessingResult processingResult); + TransactionEvaluationContext evaluationContext, + TransactionProcessingResult processingResult); /** * Method called when a transaction is selected to be added to a block. * - * @param pendingTransaction The transaction that has been selected. + * @param evaluationContext The current selection context * @param processingResult The result of processing the selected transaction. */ default void onTransactionSelected( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionProcessingResult processingResult) {} /** * Method called when a transaction is not selected to be added to a block. * - * @param pendingTransaction The transaction that has not been selected. + * @param evaluationContext The current selection context * @param transactionSelectionResult The transaction selection result */ default void onTransactionNotSelected( - final PendingTransaction pendingTransaction, + final TransactionEvaluationContext evaluationContext, final TransactionSelectionResult transactionSelectionResult) {} } diff --git a/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/txselection/TransactionEvaluationContext.java b/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/txselection/TransactionEvaluationContext.java new file mode 100644 index 00000000000..83aa7b91e7c --- /dev/null +++ b/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/txselection/TransactionEvaluationContext.java @@ -0,0 +1,57 @@ +/* + * Copyright Hyperledger Besu Contributors. + * + * 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 org.hyperledger.besu.plugin.services.txselection; + +import org.hyperledger.besu.datatypes.PendingTransaction; +import org.hyperledger.besu.datatypes.Wei; + +import com.google.common.base.Stopwatch; + +/** + * This interface defines the context for evaluating a transaction. It provides methods to get the + * pending transaction, the evaluation timer, and the transaction gas price. + * + * @param the type of the pending transaction + */ +public interface TransactionEvaluationContext { + + /** + * Gets the pending transaction. + * + * @return the pending transaction + */ + PT getPendingTransaction(); + + /** + * Gets the stopwatch used for timing the evaluation. + * + * @return the evaluation timer + */ + Stopwatch getEvaluationTimer(); + + /** + * Gets the gas price of the transaction. + * + * @return the transaction gas price + */ + Wei getTransactionGasPrice(); + + /** + * Gets the min gas price for block inclusion + * + * @return the min gas price + */ + Wei getMinGasPrice(); +} From 013d1c955365ca5aa826e0ccd1d01e83d59f509c Mon Sep 17 00:00:00 2001 From: Thabokani <149070269+Thabokani@users.noreply.github.com> Date: Sat, 13 Jan 2024 00:58:54 +0800 Subject: [PATCH 08/14] Fix typo in SUPPORT.md (#6395) Signed-off-by: Thabokani <149070269+Thabokani@users.noreply.github.com> Co-authored-by: Fabio Di Fabio --- SUPPORT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUPPORT.md b/SUPPORT.md index 16a9bccd6ae..a9eb54acb86 100644 --- a/SUPPORT.md +++ b/SUPPORT.md @@ -7,7 +7,7 @@ Welcome to the Besu repository! The following links are a set of guidelines for Having Github, Discord, and Linux Foundation accounts is necessary for obtaining support for Besu through the community channels, wiki and issue management. * If you want to raise an issue, you can do so [on the github issue tab](https://github.com/hyperledger/besu/issues). * Hyperledger Discord requires a [Discord account]. -* The Hyperlegder wiki also requires a [Linux Foundation (LF) account] in order to edit pages. +* The Hyperledger wiki also requires a [Linux Foundation (LF) account] in order to edit pages. ### Useful support links From b65c633860c8f7f0fa2dc34c0bae98e5ef00f1d1 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Sat, 13 Jan 2024 03:47:30 +1000 Subject: [PATCH 09/14] reduce machine size (#6392) Signed-off-by: Sally MacFarlane Co-authored-by: Fabio Di Fabio --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2f008df2578..6d08e515a18 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -233,7 +233,7 @@ jobs: - capture_test_logs acceptanceTestsCliqueBft: - executor: besu_executor_xl + executor: besu_executor_med steps: - prepare - attach_workspace: @@ -242,7 +242,7 @@ jobs: name: AcceptanceTests (Non-Mainnet) no_output_timeout: 20m command: | - ./gradlew --no-daemon acceptanceTestCliqueBft + ./gradlew --no-daemon --max-workers=1 acceptanceTestCliqueBft - capture_test_results - capture_test_logs From 9fbe4fbbb2e82671ddc8b7fe127b6d8706b2fc7c Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Sun, 14 Jan 2024 22:50:45 +0100 Subject: [PATCH 10/14] Upgrade Guava dependency (#6396) * Bump com.google.guava:guava to 33.0.0 Signed-off-by: Fabio Di Fabio * Update pending tx estimated memory size after Guava update Signed-off-by: Fabio Di Fabio * Rebuilt Gradle validation metadata Signed-off-by: Fabio Di Fabio * Update CHANGELOG Signed-off-by: Fabio Di Fabio --------- Signed-off-by: Fabio Di Fabio --- CHANGELOG.md | 1 + ...ingTransactionEstimatedMemorySizeTest.java | 2 +- gradle/verification-metadata.xml | 96 +++++++++---------- gradle/versions.gradle | 2 +- 4 files changed, 47 insertions(+), 54 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index abcc2ab3c85..bb8d3cb9bff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - Introduce TransactionEvaluationContext to pass data between transaction selectors and plugin, during block creation [#6381](https://github.com/hyperledger/besu/pull/6381) - Upgrade dependencies [#6377](https://github.com/hyperledger/besu/pull/6377) - Upgrade `com.fasterxml.jackson` dependencies [#6378](https://github.com/hyperledger/besu/pull/6378) +- Upgrade Guava dependency [#6396](https://github.com/hyperledger/besu/pull/6396) ### Bug fixes - INTERNAL_ERROR from `eth_estimateGas` JSON/RPC calls [#6344](https://github.com/hyperledger/besu/issues/6344) diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/PendingTransactionEstimatedMemorySizeTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/PendingTransactionEstimatedMemorySizeTest.java index c9c81543a63..20b94f5bf8c 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/PendingTransactionEstimatedMemorySizeTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/PendingTransactionEstimatedMemorySizeTest.java @@ -58,7 +58,7 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo private static final Set> SHARED_CLASSES = Set.of(SignatureAlgorithm.class, TransactionType.class); private static final Set COMMON_CONSTANT_FIELD_PATHS = - Set.of(".value.ctor", ".hashNoSignature"); + Set.of(".value.ctor", ".hashNoSignature", ".signature.encoded.delegate"); private static final Set EIP1559_EIP4844_CONSTANT_FIELD_PATHS = Sets.union(COMMON_CONSTANT_FIELD_PATHS, Set.of(".gasPrice")); private static final Set FRONTIER_ACCESS_LIST_CONSTANT_FIELD_PATHS = diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index 30d55eb6840..58a562fff88 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -760,14 +760,6 @@ - - - - - - - - @@ -777,9 +769,6 @@ - - - @@ -792,6 +781,14 @@ + + + + + + + + @@ -808,11 +805,6 @@ - - - - - @@ -828,6 +820,11 @@ + + + + + @@ -920,12 +917,12 @@ - - - + + + - - + + @@ -944,16 +941,22 @@ + + + + + + + + + + + - - - - - @@ -964,6 +967,11 @@ + + + + + @@ -998,14 +1006,6 @@ - - - - - - - - @@ -3492,22 +3492,6 @@ - - - - - - - - - - - - - - - - @@ -3523,8 +3507,16 @@ - - + + + + + + + + + + diff --git a/gradle/versions.gradle b/gradle/versions.gradle index b497109d782..c27af91f09b 100644 --- a/gradle/versions.gradle +++ b/gradle/versions.gradle @@ -46,7 +46,7 @@ dependencyManagement { entry 'error_prone_test_helpers' } - dependency 'com.google.guava:guava:31.1-jre' + dependency 'com.google.guava:guava:33.0.0-jre' dependency 'com.graphql-java:graphql-java:21.3' From 39d7042ca3f41091a7d24d12bfca6c85fe5b4dd8 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Mon, 15 Jan 2024 10:09:37 +1000 Subject: [PATCH 11/14] log a different warning if pruning is enabled with BONSAI (#6401) Signed-off-by: Sally MacFarlane --- CHANGELOG.md | 2 +- .../org/hyperledger/besu/cli/BesuCommand.java | 12 ++++++++++-- .../org/hyperledger/besu/cli/BesuCommandTest.java | 15 +++++++++++++-- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb8d3cb9bff..13f26a25781 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,7 +30,7 @@ ### Breaking Changes ### Deprecations -- Forest pruning (`pruning-enabled` options) is deprecated and will be removed soon. To save disk space consider switching to Bonsai data storage format [#6230](https://github.com/hyperledger/besu/pull/6230) +- Forest pruning (`pruning-enabled` option) is deprecated and will be removed soon. To save disk space consider switching to Bonsai data storage format [#6230](https://github.com/hyperledger/besu/pull/6230) ### Additions and Improvements - Add error messages on authentication failures with username and password [#6212](https://github.com/hyperledger/besu/pull/6212) diff --git a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java index 9842d52f875..d2fb5243313 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -148,6 +148,7 @@ import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProvider; import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProviderBuilder; import org.hyperledger.besu.ethereum.trie.forest.pruner.PrunerConfiguration; +import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat; import org.hyperledger.besu.evm.precompile.AbstractAltBnPrecompiledContract; import org.hyperledger.besu.evm.precompile.BigIntegerModularExponentiationPrecompiledContract; import org.hyperledger.besu.evm.precompile.KZGPointEvalPrecompiledContract; @@ -2063,8 +2064,15 @@ && isOptionSet(commandLine, "--sync-min-peers")) { } if (isPruningEnabled()) { - logger.warn( - "Forest pruning is deprecated and will be removed soon. To save disk space consider switching to Bonsai data storage format."); + if (dataStorageOptions + .toDomainObject() + .getDataStorageFormat() + .equals(DataStorageFormat.BONSAI)) { + logger.warn("Forest pruning is ignored with Bonsai data storage format."); + } else { + logger.warn( + "Forest pruning is deprecated and will be removed soon. To save disk space consider switching to Bonsai data storage format."); + } } } diff --git a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java index ba0e5b2754a..dc56c34845d 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java @@ -3840,8 +3840,8 @@ public void pruningParametersAreCaptured() throws Exception { } @Test - public void pruningLogsDeprecationWarning() { - parseCommand("--pruning-enabled"); + public void pruningLogsDeprecationWarningWithForest() { + parseCommand("--pruning-enabled", "--data-storage-format=FOREST"); verify(mockControllerBuilder).isPruningEnabled(true); @@ -3854,6 +3854,17 @@ public void pruningLogsDeprecationWarning() { + " To save disk space consider switching to Bonsai data storage format.")); } + @Test + public void pruningLogsIgnoredWarningWithBonsai() { + parseCommand("--pruning-enabled", "--data-storage-format=BONSAI"); + + verify(mockControllerBuilder).isPruningEnabled(true); + + assertThat(commandOutput.toString(UTF_8)).isEmpty(); + assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); + verify(mockLogger).warn(contains("Forest pruning is ignored with Bonsai data storage format.")); + } + @Test public void devModeOptionMustBeUsed() throws Exception { parseCommand("--network", "dev"); From 724e3d040e74204c9ace7844a0651cbdebd671f9 Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Tue, 16 Jan 2024 00:27:57 +0100 Subject: [PATCH 12/14] Upgrade Mockito (#6397) Signed-off-by: Fabio Di Fabio --- CHANGELOG.md | 1 + .../ethereum/api/handlers/HandlerFactory.java | 4 +- .../internal/methods/DebugTraceBlock.java | 23 ++-- .../JsonRpcHttpServiceHostAllowlistTest.java | 64 +++++---- .../jsonrpc/JsonRpcHttpServiceLoginTest.java | 62 ++++----- .../JsonRpcHttpServiceRpcApisTest.java | 129 +++++++++--------- .../api/jsonrpc/JsonRpcHttpServiceTest.java | 86 ++++++------ .../jsonrpc/JsonRpcHttpServiceTestBase.java | 88 +++++++----- .../JsonRpcHttpServiceTlsClientAuthTest.java | 64 +++++---- ...RpcHttpServiceTlsMisconfigurationTest.java | 64 +++++---- .../jsonrpc/JsonRpcHttpServiceTlsTest.java | 64 +++++---- .../DebugStandardTraceBlockToFileTest.java | 28 ++-- .../internal/methods/DebugTraceBlockTest.java | 45 +++--- .../backwardsync/BackwardSyncAlgSpec.java | 4 +- .../rlpx/connections/netty/DeFramerTest.java | 13 +- .../evm/operations/ChainIdOperationTest.java | 3 +- gradle/verification-metadata.xml | 46 +++---- gradle/versions.gradle | 2 +- 18 files changed, 396 insertions(+), 394 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13f26a25781..d520eba5425 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - Upgrade dependencies [#6377](https://github.com/hyperledger/besu/pull/6377) - Upgrade `com.fasterxml.jackson` dependencies [#6378](https://github.com/hyperledger/besu/pull/6378) - Upgrade Guava dependency [#6396](https://github.com/hyperledger/besu/pull/6396) +- Upgrade Mockito [#6397](https://github.com/hyperledger/besu/pull/6397) ### Bug fixes - INTERNAL_ERROR from `eth_estimateGas` JSON/RPC calls [#6344](https://github.com/hyperledger/besu/issues/6344) diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/HandlerFactory.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/HandlerFactory.java index 2d3639d52f6..03465f70f21 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/HandlerFactory.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/HandlerFactory.java @@ -22,6 +22,7 @@ import java.util.Collection; import java.util.Map; import java.util.Optional; +import java.util.function.Function; import java.util.stream.Collectors; import io.opentelemetry.api.trace.Tracer; @@ -35,7 +36,8 @@ public static Handler timeout( assert methods != null && globalOptions != null; return TimeoutHandler.handler( Optional.of(globalOptions), - methods.keySet().stream().collect(Collectors.toMap(String::new, ignored -> globalOptions))); + methods.keySet().stream() + .collect(Collectors.toMap(Function.identity(), ignored -> globalOptions))); } public static Handler authentication( diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlock.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlock.java index 270f176c7a8..6dab0436a84 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlock.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlock.java @@ -46,15 +46,15 @@ public class DebugTraceBlock implements JsonRpcMethod { private static final Logger LOG = LoggerFactory.getLogger(DebugTraceBlock.class); private final Supplier blockTracerSupplier; private final BlockHeaderFunctions blockHeaderFunctions; - private final BlockchainQueries blockchain; + private final BlockchainQueries blockchainQueries; public DebugTraceBlock( final Supplier blockTracerSupplier, final BlockHeaderFunctions blockHeaderFunctions, - final BlockchainQueries blockchain) { + final BlockchainQueries blockchainQueries) { this.blockTracerSupplier = blockTracerSupplier; this.blockHeaderFunctions = blockHeaderFunctions; - this.blockchain = blockchain; + this.blockchainQueries = blockchainQueries; } @Override @@ -79,18 +79,17 @@ public JsonRpcResponse response(final JsonRpcRequestContext requestContext) { .map(TransactionTraceParams::traceOptions) .orElse(TraceOptions.DEFAULT); - if (this.blockchain.blockByHash(block.getHeader().getParentHash()).isPresent()) { + if (this.blockchainQueries.blockByHash(block.getHeader().getParentHash()).isPresent()) { final Collection results = Tracer.processTracing( - blockchain, + blockchainQueries, Optional.of(block.getHeader()), - mutableWorldState -> { - return blockTracerSupplier - .get() - .trace(mutableWorldState, block, new DebugOperationTracer(traceOptions)) - .map(BlockTrace::getTransactionTraces) - .map(DebugTraceTransactionResult::of); - }) + mutableWorldState -> + blockTracerSupplier + .get() + .trace(mutableWorldState, block, new DebugOperationTracer(traceOptions)) + .map(BlockTrace::getTransactionTraces) + .map(DebugTraceTransactionResult::of)) .orElse(null); return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), results); } else { diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceHostAllowlistTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceHostAllowlistTest.java index da7319282fb..f433bcdc977 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceHostAllowlistTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceHostAllowlistTest.java @@ -17,7 +17,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.DEFAULT_RPC_APIS; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; import org.hyperledger.besu.config.StubGenesisConfigOptions; import org.hyperledger.besu.ethereum.ProtocolContext; @@ -98,38 +97,37 @@ public void initServerAndClient() throws Exception { supportedCapabilities.add(EthProtocol.ETH63); rpcMethods = - spy( - new JsonRpcMethodsFactory() - .methods( - CLIENT_VERSION, - CHAIN_ID, - new StubGenesisConfigOptions(), - peerDiscoveryMock, - blockchainQueries, - synchronizer, - MainnetProtocolSchedule.fromConfig( - new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID)), - mock(ProtocolContext.class), - mock(FilterManager.class), - mock(TransactionPool.class), - mock(MiningParameters.class), - mock(PoWMiningCoordinator.class), - new NoOpMetricsSystem(), - supportedCapabilities, - Optional.of(mock(AccountLocalConfigPermissioningController.class)), - Optional.of(mock(NodeLocalConfigPermissioningController.class)), - DEFAULT_RPC_APIS, - mock(PrivacyParameters.class), - mock(JsonRpcConfiguration.class), - mock(WebSocketConfiguration.class), - mock(MetricsConfiguration.class), - natService, - new HashMap<>(), - folder, - mock(EthPeers.class), - vertx, - mock(ApiConfiguration.class), - Optional.empty())); + new JsonRpcMethodsFactory() + .methods( + CLIENT_VERSION, + CHAIN_ID, + new StubGenesisConfigOptions(), + peerDiscoveryMock, + blockchainQueries, + synchronizer, + MainnetProtocolSchedule.fromConfig( + new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID)), + mock(ProtocolContext.class), + mock(FilterManager.class), + mock(TransactionPool.class), + mock(MiningParameters.class), + mock(PoWMiningCoordinator.class), + new NoOpMetricsSystem(), + supportedCapabilities, + Optional.of(mock(AccountLocalConfigPermissioningController.class)), + Optional.of(mock(NodeLocalConfigPermissioningController.class)), + DEFAULT_RPC_APIS, + mock(PrivacyParameters.class), + mock(JsonRpcConfiguration.class), + mock(WebSocketConfiguration.class), + mock(MetricsConfiguration.class), + natService, + new HashMap<>(), + folder, + mock(EthPeers.class), + vertx, + mock(ApiConfiguration.class), + Optional.empty()); service = createJsonRpcHttpService(); service.start().join(); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceLoginTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceLoginTest.java index 7b9eac24788..aa1b582174f 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceLoginTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceLoginTest.java @@ -19,7 +19,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.util.Lists.list; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; import org.hyperledger.besu.config.StubGenesisConfigOptions; import org.hyperledger.besu.ethereum.ProtocolContext; @@ -129,37 +128,36 @@ public static void initServerAndClient() throws Exception { new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID); rpcMethods = - spy( - new JsonRpcMethodsFactory() - .methods( - CLIENT_VERSION, - CHAIN_ID, - genesisConfigOptions, - peerDiscoveryMock, - blockchainQueries, - synchronizer, - MainnetProtocolSchedule.fromConfig(genesisConfigOptions), - mock(ProtocolContext.class), - mock(FilterManager.class), - mock(TransactionPool.class), - mock(MiningParameters.class), - mock(PoWMiningCoordinator.class), - new NoOpMetricsSystem(), - supportedCapabilities, - Optional.empty(), - Optional.empty(), - JSON_RPC_APIS, - mock(PrivacyParameters.class), - mock(JsonRpcConfiguration.class), - mock(WebSocketConfiguration.class), - mock(MetricsConfiguration.class), - natService, - new HashMap<>(), - folder, - mock(EthPeers.class), - vertx, - mock(ApiConfiguration.class), - Optional.empty())); + new JsonRpcMethodsFactory() + .methods( + CLIENT_VERSION, + CHAIN_ID, + genesisConfigOptions, + peerDiscoveryMock, + blockchainQueries, + synchronizer, + MainnetProtocolSchedule.fromConfig(genesisConfigOptions), + mock(ProtocolContext.class), + mock(FilterManager.class), + mock(TransactionPool.class), + mock(MiningParameters.class), + mock(PoWMiningCoordinator.class), + new NoOpMetricsSystem(), + supportedCapabilities, + Optional.empty(), + Optional.empty(), + JSON_RPC_APIS, + mock(PrivacyParameters.class), + mock(JsonRpcConfiguration.class), + mock(WebSocketConfiguration.class), + mock(MetricsConfiguration.class), + natService, + new HashMap<>(), + folder, + mock(EthPeers.class), + vertx, + mock(ApiConfiguration.class), + Optional.empty()); service = createJsonRpcHttpService(); jwtAuth = service.authenticationService.get().getJwtAuthProvider(); service.start().join(); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceRpcApisTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceRpcApisTest.java index 6870c4fed03..8323f61b2c5 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceRpcApisTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceRpcApisTest.java @@ -17,7 +17,6 @@ import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import org.hyperledger.besu.config.StubGenesisConfigOptions; @@ -201,37 +200,36 @@ private JsonRpcHttpService createJsonRpcHttpServiceWithRpcApis(final JsonRpcConf supportedCapabilities.add(EthProtocol.ETH63); final Map rpcMethods = - spy( - new JsonRpcMethodsFactory() - .methods( - CLIENT_VERSION, - NETWORK_ID, - new StubGenesisConfigOptions(), - mock(P2PNetwork.class), - blockchainQueries, - mock(Synchronizer.class), - ProtocolScheduleFixture.MAINNET, - mock(ProtocolContext.class), - mock(FilterManager.class), - mock(TransactionPool.class), - mock(MiningParameters.class), - mock(PoWMiningCoordinator.class), - new NoOpMetricsSystem(), - supportedCapabilities, - Optional.of(mock(AccountLocalConfigPermissioningController.class)), - Optional.of(mock(NodeLocalConfigPermissioningController.class)), - config.getRpcApis(), - mock(PrivacyParameters.class), - mock(JsonRpcConfiguration.class), - mock(WebSocketConfiguration.class), - mock(MetricsConfiguration.class), - natService, - new HashMap<>(), - folder, - mock(EthPeers.class), - vertx, - mock(ApiConfiguration.class), - Optional.empty())); + new JsonRpcMethodsFactory() + .methods( + CLIENT_VERSION, + NETWORK_ID, + new StubGenesisConfigOptions(), + mock(P2PNetwork.class), + blockchainQueries, + mock(Synchronizer.class), + ProtocolScheduleFixture.MAINNET, + mock(ProtocolContext.class), + mock(FilterManager.class), + mock(TransactionPool.class), + mock(MiningParameters.class), + mock(PoWMiningCoordinator.class), + new NoOpMetricsSystem(), + supportedCapabilities, + Optional.of(mock(AccountLocalConfigPermissioningController.class)), + Optional.of(mock(NodeLocalConfigPermissioningController.class)), + config.getRpcApis(), + mock(PrivacyParameters.class), + mock(JsonRpcConfiguration.class), + mock(WebSocketConfiguration.class), + mock(MetricsConfiguration.class), + natService, + new HashMap<>(), + folder, + mock(EthPeers.class), + vertx, + mock(ApiConfiguration.class), + Optional.empty()); final JsonRpcHttpService jsonRpcHttpService = new JsonRpcHttpService( vertx, @@ -302,8 +300,7 @@ private JsonRpcHttpService createJsonRpcHttpService( final WebSocketConfiguration webSocketConfiguration, final P2PNetwork p2pNetwork, final MetricsConfiguration metricsConfiguration, - final NatService natService) - throws Exception { + final NatService natService) { final Set supportedCapabilities = new HashSet<>(); supportedCapabilities.add(EthProtocol.ETH62); supportedCapabilities.add(EthProtocol.ETH63); @@ -311,37 +308,36 @@ private JsonRpcHttpService createJsonRpcHttpService( webSocketConfiguration.setPort(0); final Map rpcMethods = - spy( - new JsonRpcMethodsFactory() - .methods( - CLIENT_VERSION, - NETWORK_ID, - new StubGenesisConfigOptions(), - p2pNetwork, - blockchainQueries, - mock(Synchronizer.class), - ProtocolScheduleFixture.MAINNET, - mock(ProtocolContext.class), - mock(FilterManager.class), - mock(TransactionPool.class), - mock(MiningParameters.class), - mock(PoWMiningCoordinator.class), - new NoOpMetricsSystem(), - supportedCapabilities, - Optional.of(mock(AccountLocalConfigPermissioningController.class)), - Optional.of(mock(NodeLocalConfigPermissioningController.class)), - jsonRpcConfiguration.getRpcApis(), - mock(PrivacyParameters.class), - jsonRpcConfiguration, - webSocketConfiguration, - metricsConfiguration, - natService, - new HashMap<>(), - folder, - mock(EthPeers.class), - vertx, - mock(ApiConfiguration.class), - Optional.empty())); + new JsonRpcMethodsFactory() + .methods( + CLIENT_VERSION, + NETWORK_ID, + new StubGenesisConfigOptions(), + p2pNetwork, + blockchainQueries, + mock(Synchronizer.class), + ProtocolScheduleFixture.MAINNET, + mock(ProtocolContext.class), + mock(FilterManager.class), + mock(TransactionPool.class), + mock(MiningParameters.class), + mock(PoWMiningCoordinator.class), + new NoOpMetricsSystem(), + supportedCapabilities, + Optional.of(mock(AccountLocalConfigPermissioningController.class)), + Optional.of(mock(NodeLocalConfigPermissioningController.class)), + jsonRpcConfiguration.getRpcApis(), + mock(PrivacyParameters.class), + jsonRpcConfiguration, + webSocketConfiguration, + metricsConfiguration, + natService, + new HashMap<>(), + folder, + mock(EthPeers.class), + vertx, + mock(ApiConfiguration.class), + Optional.empty()); final JsonRpcHttpService jsonRpcHttpService = new JsonRpcHttpService( vertx, @@ -425,8 +421,7 @@ public RequestBody createNetServicesRequestBody() { "{\"jsonrpc\":\"2.0\",\"id\":" + Json.encode(id) + ",\"method\":\"net_services\"}", JSON); } - public JsonRpcHttpService getJsonRpcHttpService(final boolean[] enabledNetServices) - throws Exception { + public JsonRpcHttpService getJsonRpcHttpService(final boolean[] enabledNetServices) { JsonRpcConfiguration jsonRpcConfiguration = JsonRpcConfiguration.createDefault(); WebSocketConfiguration webSocketConfiguration = WebSocketConfiguration.createDefault(); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTest.java index f9c9b14ccd0..901f20ff754 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTest.java @@ -17,10 +17,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import org.hyperledger.besu.datatypes.Address; @@ -1389,65 +1386,68 @@ public void disabledMethod() throws Exception { + "\"}", JSON); - when(rpcMethods.get(any(String.class))).thenReturn(null); - when(rpcMethods.containsKey(any(String.class))).thenReturn(false); + try (var unused = disableRpcMethod(methodName)) { - try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { - assertThat(resp.code()).isEqualTo(200); - final JsonObject json = new JsonObject(resp.body().string()); - final RpcErrorType expectedError = RpcErrorType.METHOD_NOT_ENABLED; - testHelper.assertValidJsonRpcError( - json, id, expectedError.getCode(), expectedError.getMessage()); + try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { + assertThat(resp.code()).isEqualTo(200); + final JsonObject json = new JsonObject(resp.body().string()); + final RpcErrorType expectedError = RpcErrorType.METHOD_NOT_ENABLED; + testHelper.assertValidJsonRpcError( + json, id, expectedError.getCode(), expectedError.getMessage()); + } } - - verify(rpcMethods).containsKey(methodName); - verify(rpcMethods).get(methodName); - - reset(rpcMethods); } @Test public void exceptionallyHandleJsonSingleRequest() throws Exception { + final String methodName = "foo"; final JsonRpcMethod jsonRpcMethod = mock(JsonRpcMethod.class); - when(jsonRpcMethod.getName()).thenReturn("foo"); + when(jsonRpcMethod.getName()).thenReturn(methodName); when(jsonRpcMethod.response(any())).thenThrow(new RuntimeException("test exception")); - doReturn(jsonRpcMethod).when(rpcMethods).get("foo"); + try (var unused = addRpcMethod(methodName, jsonRpcMethod)) { - final RequestBody body = - RequestBody.create("{\"jsonrpc\":\"2.0\",\"id\":\"666\",\"method\":\"foo\"}", JSON); + final RequestBody body = + RequestBody.create( + "{\"jsonrpc\":\"2.0\",\"id\":\"666\",\"method\":\"" + methodName + "\"}", JSON); - try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { - assertThat(resp.code()).isEqualTo(200); - final JsonObject json = new JsonObject(resp.body().string()); - final RpcErrorType expectedError = RpcErrorType.INTERNAL_ERROR; - testHelper.assertValidJsonRpcError( - json, "666", expectedError.getCode(), expectedError.getMessage()); + try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { + assertThat(resp.code()).isEqualTo(200); + final JsonObject json = new JsonObject(resp.body().string()); + final RpcErrorType expectedError = RpcErrorType.INTERNAL_ERROR; + testHelper.assertValidJsonRpcError( + json, "666", expectedError.getCode(), expectedError.getMessage()); + } } } @Test public void exceptionallyHandleJsonBatchRequest() throws Exception { + final String methodName = "foo"; final JsonRpcMethod jsonRpcMethod = mock(JsonRpcMethod.class); - when(jsonRpcMethod.getName()).thenReturn("foo"); + when(jsonRpcMethod.getName()).thenReturn(methodName); when(jsonRpcMethod.response(any())).thenThrow(new RuntimeException("test exception")); - doReturn(jsonRpcMethod).when(rpcMethods).get("foo"); - final RequestBody body = - RequestBody.create( - "[{\"jsonrpc\":\"2.0\",\"id\":\"000\",\"method\":\"web3_clientVersion\"}," - + "{\"jsonrpc\":\"2.0\",\"id\":\"111\",\"method\":\"foo\"}," - + "{\"jsonrpc\":\"2.0\",\"id\":\"222\",\"method\":\"net_version\"}]", - JSON); - - try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { - assertThat(resp.code()).isEqualTo(200); - final JsonArray array = new JsonArray(resp.body().string()); - testHelper.assertValidJsonRpcResult(array.getJsonObject(0), "000"); - final RpcErrorType expectedError = RpcErrorType.INTERNAL_ERROR; - testHelper.assertValidJsonRpcError( - array.getJsonObject(1), "111", expectedError.getCode(), expectedError.getMessage()); - testHelper.assertValidJsonRpcResult(array.getJsonObject(2), "222"); + try (var unused = addRpcMethod(methodName, jsonRpcMethod)) { + + final RequestBody body = + RequestBody.create( + "[{\"jsonrpc\":\"2.0\",\"id\":\"000\",\"method\":\"web3_clientVersion\"}," + + "{\"jsonrpc\":\"2.0\",\"id\":\"111\",\"method\":\"" + + methodName + + "\"}," + + "{\"jsonrpc\":\"2.0\",\"id\":\"222\",\"method\":\"net_version\"}]", + JSON); + + try (final Response resp = client.newCall(buildPostRequest(body)).execute()) { + assertThat(resp.code()).isEqualTo(200); + final JsonArray array = new JsonArray(resp.body().string()); + testHelper.assertValidJsonRpcResult(array.getJsonObject(0), "000"); + final RpcErrorType expectedError = RpcErrorType.INTERNAL_ERROR; + testHelper.assertValidJsonRpcError( + array.getJsonObject(1), "111", expectedError.getCode(), expectedError.getMessage()); + testHelper.assertValidJsonRpcResult(array.getJsonObject(2), "222"); + } } } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTestBase.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTestBase.java index 580af7b7467..257dbf16679 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTestBase.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTestBase.java @@ -16,7 +16,6 @@ package org.hyperledger.besu.ethereum.api.jsonrpc; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; import org.hyperledger.besu.config.StubGenesisConfigOptions; import org.hyperledger.besu.ethereum.ProtocolContext; @@ -72,8 +71,9 @@ public class JsonRpcHttpServiceTestBase { protected final JsonRpcTestHelper testHelper = new JsonRpcTestHelper(); private static final Vertx vertx = Vertx.vertx(); - protected static Map rpcMethods; + private static Map disabledRpcMethods; + private static Set addedRpcMethods; protected static JsonRpcHttpService service; protected static OkHttpClient client; protected static String baseUrl; @@ -106,39 +106,41 @@ public static void initServerAndClient() throws Exception { supportedCapabilities.add(EthProtocol.ETH63); rpcMethods = - spy( - new JsonRpcMethodsFactory() - .methods( - CLIENT_VERSION, - CHAIN_ID, - new StubGenesisConfigOptions(), - peerDiscoveryMock, - blockchainQueries, - synchronizer, - MainnetProtocolSchedule.fromConfig( - new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID), - EvmConfiguration.DEFAULT), - mock(ProtocolContext.class), - mock(FilterManager.class), - mock(TransactionPool.class), - mock(MiningParameters.class), - mock(PoWMiningCoordinator.class), - new NoOpMetricsSystem(), - supportedCapabilities, - Optional.of(mock(AccountLocalConfigPermissioningController.class)), - Optional.of(mock(NodeLocalConfigPermissioningController.class)), - JSON_RPC_APIS, - mock(PrivacyParameters.class), - mock(JsonRpcConfiguration.class), - mock(WebSocketConfiguration.class), - mock(MetricsConfiguration.class), - natService, - new HashMap<>(), - folder, - ethPeersMock, - vertx, - mock(ApiConfiguration.class), - Optional.empty())); + new JsonRpcMethodsFactory() + .methods( + CLIENT_VERSION, + CHAIN_ID, + new StubGenesisConfigOptions(), + peerDiscoveryMock, + blockchainQueries, + synchronizer, + MainnetProtocolSchedule.fromConfig( + new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID), + EvmConfiguration.DEFAULT), + mock(ProtocolContext.class), + mock(FilterManager.class), + mock(TransactionPool.class), + mock(MiningParameters.class), + mock(PoWMiningCoordinator.class), + new NoOpMetricsSystem(), + supportedCapabilities, + Optional.of(mock(AccountLocalConfigPermissioningController.class)), + Optional.of(mock(NodeLocalConfigPermissioningController.class)), + JSON_RPC_APIS, + mock(PrivacyParameters.class), + mock(JsonRpcConfiguration.class), + mock(WebSocketConfiguration.class), + mock(MetricsConfiguration.class), + natService, + new HashMap<>(), + folder, + ethPeersMock, + vertx, + mock(ApiConfiguration.class), + Optional.empty()); + disabledRpcMethods = new HashMap<>(); + addedRpcMethods = new HashSet<>(); + service = createJsonRpcHttpService(createLimitedJsonRpcConfig()); service.start().join(); @@ -189,6 +191,22 @@ protected Request buildGetRequest(final String path) { return new Request.Builder().get().url(baseUrl + path).build(); } + protected AutoCloseable disableRpcMethod(final String methodName) { + disabledRpcMethods.put(methodName, rpcMethods.remove(methodName)); + return () -> resetRpcMethods(); + } + + protected AutoCloseable addRpcMethod(final String methodName, final JsonRpcMethod method) { + rpcMethods.put(methodName, method); + addedRpcMethods.add(methodName); + return () -> resetRpcMethods(); + } + + protected void resetRpcMethods() { + disabledRpcMethods.forEach(rpcMethods::put); + addedRpcMethods.forEach(rpcMethods::remove); + } + /** Tears down the HTTP server. */ @AfterAll public static void shutdownServer() { diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsClientAuthTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsClientAuthTest.java index 3a9a5577a1d..70cc3d58f84 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsClientAuthTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsClientAuthTest.java @@ -21,7 +21,6 @@ import static org.hyperledger.besu.ethereum.api.tls.TlsClientAuthConfiguration.Builder.aTlsClientAuthConfiguration; import static org.hyperledger.besu.ethereum.api.tls.TlsConfiguration.Builder.aTlsConfiguration; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; import org.hyperledger.besu.config.StubGenesisConfigOptions; import org.hyperledger.besu.ethereum.ProtocolContext; @@ -112,38 +111,37 @@ public void initServer() throws Exception { supportedCapabilities.add(EthProtocol.ETH63); rpcMethods = - spy( - new JsonRpcMethodsFactory() - .methods( - CLIENT_VERSION, - CHAIN_ID, - new StubGenesisConfigOptions(), - peerDiscoveryMock, - blockchainQueries, - synchronizer, - MainnetProtocolSchedule.fromConfig( - new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID)), - mock(ProtocolContext.class), - mock(FilterManager.class), - mock(TransactionPool.class), - mock(MiningParameters.class), - mock(PoWMiningCoordinator.class), - new NoOpMetricsSystem(), - supportedCapabilities, - Optional.of(mock(AccountLocalConfigPermissioningController.class)), - Optional.of(mock(NodeLocalConfigPermissioningController.class)), - DEFAULT_RPC_APIS, - mock(PrivacyParameters.class), - mock(JsonRpcConfiguration.class), - mock(WebSocketConfiguration.class), - mock(MetricsConfiguration.class), - natService, - Collections.emptyMap(), - folder, - mock(EthPeers.class), - vertx, - mock(ApiConfiguration.class), - Optional.empty())); + new JsonRpcMethodsFactory() + .methods( + CLIENT_VERSION, + CHAIN_ID, + new StubGenesisConfigOptions(), + peerDiscoveryMock, + blockchainQueries, + synchronizer, + MainnetProtocolSchedule.fromConfig( + new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID)), + mock(ProtocolContext.class), + mock(FilterManager.class), + mock(TransactionPool.class), + mock(MiningParameters.class), + mock(PoWMiningCoordinator.class), + new NoOpMetricsSystem(), + supportedCapabilities, + Optional.of(mock(AccountLocalConfigPermissioningController.class)), + Optional.of(mock(NodeLocalConfigPermissioningController.class)), + DEFAULT_RPC_APIS, + mock(PrivacyParameters.class), + mock(JsonRpcConfiguration.class), + mock(WebSocketConfiguration.class), + mock(MetricsConfiguration.class), + natService, + Collections.emptyMap(), + folder, + mock(EthPeers.class), + vertx, + mock(ApiConfiguration.class), + Optional.empty()); System.setProperty("javax.net.ssl.trustStore", CLIENT_AS_CA_CERT.getKeyStoreFile().toString()); System.setProperty( diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsMisconfigurationTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsMisconfigurationTest.java index 695dec93269..ee069f03232 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsMisconfigurationTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsMisconfigurationTest.java @@ -20,7 +20,6 @@ import static org.hyperledger.besu.ethereum.api.tls.TlsClientAuthConfiguration.Builder.aTlsClientAuthConfiguration; import static org.hyperledger.besu.ethereum.api.tls.TlsConfiguration.Builder.aTlsConfiguration; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; import org.hyperledger.besu.config.StubGenesisConfigOptions; import org.hyperledger.besu.ethereum.ProtocolContext; @@ -100,38 +99,37 @@ public void beforeEach() { supportedCapabilities.add(EthProtocol.ETH63); rpcMethods = - spy( - new JsonRpcMethodsFactory() - .methods( - CLIENT_VERSION, - CHAIN_ID, - new StubGenesisConfigOptions(), - peerDiscoveryMock, - blockchainQueries, - synchronizer, - MainnetProtocolSchedule.fromConfig( - new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID)), - mock(ProtocolContext.class), - mock(FilterManager.class), - mock(TransactionPool.class), - mock(MiningParameters.class), - mock(PoWMiningCoordinator.class), - new NoOpMetricsSystem(), - supportedCapabilities, - Optional.of(mock(AccountLocalConfigPermissioningController.class)), - Optional.of(mock(NodeLocalConfigPermissioningController.class)), - DEFAULT_RPC_APIS, - mock(PrivacyParameters.class), - mock(JsonRpcConfiguration.class), - mock(WebSocketConfiguration.class), - mock(MetricsConfiguration.class), - natService, - Collections.emptyMap(), - tempDir.getRoot(), - mock(EthPeers.class), - vertx, - mock(ApiConfiguration.class), - Optional.empty())); + new JsonRpcMethodsFactory() + .methods( + CLIENT_VERSION, + CHAIN_ID, + new StubGenesisConfigOptions(), + peerDiscoveryMock, + blockchainQueries, + synchronizer, + MainnetProtocolSchedule.fromConfig( + new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID)), + mock(ProtocolContext.class), + mock(FilterManager.class), + mock(TransactionPool.class), + mock(MiningParameters.class), + mock(PoWMiningCoordinator.class), + new NoOpMetricsSystem(), + supportedCapabilities, + Optional.of(mock(AccountLocalConfigPermissioningController.class)), + Optional.of(mock(NodeLocalConfigPermissioningController.class)), + DEFAULT_RPC_APIS, + mock(PrivacyParameters.class), + mock(JsonRpcConfiguration.class), + mock(WebSocketConfiguration.class), + mock(MetricsConfiguration.class), + natService, + Collections.emptyMap(), + tempDir.getRoot(), + mock(EthPeers.class), + vertx, + mock(ApiConfiguration.class), + Optional.empty()); } @AfterEach diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsTest.java index 587d142b7f8..295c7b91bd7 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsTest.java @@ -20,7 +20,6 @@ import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.DEFAULT_RPC_APIS; import static org.hyperledger.besu.ethereum.api.tls.TlsConfiguration.Builder.aTlsConfiguration; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; import org.hyperledger.besu.config.StubGenesisConfigOptions; import org.hyperledger.besu.ethereum.ProtocolContext; @@ -101,38 +100,37 @@ public void initServer() throws Exception { supportedCapabilities.add(EthProtocol.ETH63); rpcMethods = - spy( - new JsonRpcMethodsFactory() - .methods( - CLIENT_VERSION, - CHAIN_ID, - new StubGenesisConfigOptions(), - peerDiscoveryMock, - blockchainQueries, - synchronizer, - MainnetProtocolSchedule.fromConfig( - new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID)), - mock(ProtocolContext.class), - mock(FilterManager.class), - mock(TransactionPool.class), - mock(MiningParameters.class), - mock(PoWMiningCoordinator.class), - new NoOpMetricsSystem(), - supportedCapabilities, - Optional.of(mock(AccountLocalConfigPermissioningController.class)), - Optional.of(mock(NodeLocalConfigPermissioningController.class)), - DEFAULT_RPC_APIS, - mock(PrivacyParameters.class), - mock(JsonRpcConfiguration.class), - mock(WebSocketConfiguration.class), - mock(MetricsConfiguration.class), - natService, - Collections.emptyMap(), - folder, - mock(EthPeers.class), - vertx, - mock(ApiConfiguration.class), - Optional.empty())); + new JsonRpcMethodsFactory() + .methods( + CLIENT_VERSION, + CHAIN_ID, + new StubGenesisConfigOptions(), + peerDiscoveryMock, + blockchainQueries, + synchronizer, + MainnetProtocolSchedule.fromConfig( + new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID)), + mock(ProtocolContext.class), + mock(FilterManager.class), + mock(TransactionPool.class), + mock(MiningParameters.class), + mock(PoWMiningCoordinator.class), + new NoOpMetricsSystem(), + supportedCapabilities, + Optional.of(mock(AccountLocalConfigPermissioningController.class)), + Optional.of(mock(NodeLocalConfigPermissioningController.class)), + DEFAULT_RPC_APIS, + mock(PrivacyParameters.class), + mock(JsonRpcConfiguration.class), + mock(WebSocketConfiguration.class), + mock(MetricsConfiguration.class), + natService, + Collections.emptyMap(), + folder, + mock(EthPeers.class), + vertx, + mock(ApiConfiguration.class), + Optional.empty()); service = createJsonRpcHttpService(createJsonRpcConfig()); service.start().join(); baseUrl = service.url(); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugStandardTraceBlockToFileTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugStandardTraceBlockToFileTest.java index 42ec4c697f5..2cf7dcbfc27 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugStandardTraceBlockToFileTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugStandardTraceBlockToFileTest.java @@ -18,11 +18,12 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer; +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTracer; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; @@ -30,28 +31,23 @@ import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.MutableWorldState; -import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; import java.nio.file.Path; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Optional; +import java.util.function.Function; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -import org.mockito.Answers; public class DebugStandardTraceBlockToFileTest { // this tempDir is deliberately static @TempDir private static Path folder; - private final WorldStateArchive archive = - mock(WorldStateArchive.class, Answers.RETURNS_DEEP_STUBS); private final Blockchain blockchain = mock(Blockchain.class); - private final BlockchainQueries blockchainQueries = - spy(new BlockchainQueries(blockchain, archive)); + private final BlockchainQueries blockchainQueries = mock(BlockchainQueries.class); private final TransactionTracer transactionTracer = mock(TransactionTracer.class); private final DebugStandardTraceBlockToFile debugStandardTraceBlockToFile = new DebugStandardTraceBlockToFile(() -> transactionTracer, blockchainQueries, folder); @@ -76,20 +72,26 @@ public void shouldTraceTheTransactionUsingTheTransactionTracer() { new JsonRpcRequestContext( new JsonRpcRequest("2.0", "debug_standardTraceBlockToFile", params)); - final List paths = new ArrayList<>(); - paths.add("path-1"); - - when(blockchainQueries.getBlockchain()).thenReturn(blockchain); + final List paths = List.of("path-1"); when(blockchain.getBlockByHash(block.getHash())).thenReturn(Optional.of(block)); when(blockchain.getBlockHeader(genesis.getHash())).thenReturn(Optional.of(genesis.getHeader())); + when(blockchainQueries.getBlockchain()).thenReturn(blockchain); + + when(blockchainQueries.getAndMapWorldState(any(), any())) + .thenAnswer( + invocationOnMock -> { + Function> mapper = + invocationOnMock.getArgument(1); + return mapper.apply(mock(Tracer.TraceableState.class)); + }); when(transactionTracer.traceTransactionToFile( any(MutableWorldState.class), eq(block.getHash()), any(), any())) .thenReturn(paths); final JsonRpcSuccessResponse response = (JsonRpcSuccessResponse) debugStandardTraceBlockToFile.response(request); - final List result = (ArrayList) response.getResult(); + final List result = (List) response.getResult(); assertThat(result.size()).isEqualTo(1); } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockTest.java index 60841c24ef4..5da556182bc 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockTest.java @@ -18,9 +18,8 @@ import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doAnswer; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import org.hyperledger.besu.datatypes.Wei; @@ -35,32 +34,25 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; import org.hyperledger.besu.ethereum.api.query.BlockWithMetadata; import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; -import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.debug.TraceFrame; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; -import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; import java.util.Collection; import java.util.Collections; import java.util.Optional; import java.util.OptionalLong; +import java.util.function.Function; import org.apache.tuweni.bytes.Bytes; import org.junit.jupiter.api.Test; -import org.mockito.Answers; -import org.mockito.Mockito; public class DebugTraceBlockTest { private final BlockTracer blockTracer = mock(BlockTracer.class); - private final WorldStateArchive archive = - mock(WorldStateArchive.class, Answers.RETURNS_DEEP_STUBS); - private final Blockchain blockchain = mock(Blockchain.class); - private final BlockchainQueries blockchainQueries = - spy(new BlockchainQueries(blockchain, archive)); + private final BlockchainQueries blockchainQueries = mock(BlockchainQueries.class); private final DebugTraceBlock debugTraceBlock = new DebugTraceBlock(() -> blockTracer, new MainnetBlockHeaderFunctions(), blockchainQueries); @@ -127,22 +119,25 @@ public void shouldReturnCorrectResponse() { when(transaction2Trace.getResult()).thenReturn(transaction2Result); when(transaction1Result.getOutput()).thenReturn(Bytes.fromHexString("1234")); when(transaction2Result.getOutput()).thenReturn(Bytes.fromHexString("1234")); - when(blockTracer.trace(any(Tracer.TraceableState.class), Mockito.eq(block), any())) + when(blockTracer.trace(any(Tracer.TraceableState.class), eq(block), any())) .thenReturn(Optional.of(blockTrace)); - when(blockchain.getBlockHeader(parentBlock.getHash())) - .thenReturn(Optional.of(parentBlock.getHeader())); - doAnswer( - invocation -> - Optional.of( - new BlockWithMetadata<>( - parentBlock.getHeader(), - Collections.emptyList(), - Collections.emptyList(), - parentBlock.getHeader().getDifficulty(), - parentBlock.calculateSize()))) - .when(blockchainQueries) - .blockByHash(parentBlock.getHash()); + when(blockchainQueries.blockByHash(parentBlock.getHash())) + .thenReturn( + Optional.of( + new BlockWithMetadata<>( + parentBlock.getHeader(), + Collections.emptyList(), + Collections.emptyList(), + parentBlock.getHeader().getDifficulty(), + parentBlock.calculateSize()))); + when(blockchainQueries.getAndMapWorldState(eq(parentBlock.getHash()), any())) + .thenAnswer( + invocationOnMock -> { + Function> mapper = + invocationOnMock.getArgument(1); + return mapper.apply(mock(Tracer.TraceableState.class)); + }); final JsonRpcSuccessResponse response = (JsonRpcSuccessResponse) debugTraceBlock.response(request); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncAlgSpec.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncAlgSpec.java index 8a1a0a226e8..83355ecc291 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncAlgSpec.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncAlgSpec.java @@ -165,7 +165,7 @@ public void shouldAwokeWhenTTDReachedAndReady() throws Exception { ttdCaptor.getValue().onTTDReached(true); - voidCompletableFuture.get(100, TimeUnit.MILLISECONDS); + voidCompletableFuture.get(200, TimeUnit.MILLISECONDS); assertThat(voidCompletableFuture).isCompleted(); verify(context.getSyncState()).unsubscribeTTDReached(88L); @@ -192,7 +192,7 @@ public void shouldAwokeWhenConditionReachedAndReady() throws Exception { completionCaptor.getValue().onInitialSyncCompleted(); - voidCompletableFuture.get(100, TimeUnit.MILLISECONDS); + voidCompletableFuture.get(200, TimeUnit.MILLISECONDS); assertThat(voidCompletableFuture).isCompleted(); verify(context.getSyncState()).unsubscribeTTDReached(88L); diff --git a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/DeFramerTest.java b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/DeFramerTest.java index dfafb002f49..f5030fd9ad6 100644 --- a/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/DeFramerTest.java +++ b/ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/rlpx/connections/netty/DeFramerTest.java @@ -65,6 +65,7 @@ import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelId; import io.netty.channel.ChannelPipeline; @@ -196,7 +197,7 @@ public void decode_handlesHello() throws ExecutionException, InterruptedExceptio assertThat(out).isEmpty(); // Next phase of pipeline should be setup - verify(pipeline, times(1)).addLast(any()); + verify(pipeline, times(1)).addLast(any(ChannelHandler[].class)); // Next message should be pushed out final PingMessage nextMessage = PingMessage.get(); @@ -204,7 +205,7 @@ public void decode_handlesHello() throws ExecutionException, InterruptedExceptio when(framer.deframe(eq(nextData))) .thenReturn(new RawMessage(nextMessage.getCode(), nextMessage.getData())) .thenReturn(null); - verify(pipeline, times(1)).addLast(any()); + verify(pipeline, times(1)).addLast(any(ChannelHandler[].class)); deFramer.decode(ctx, nextData, out); assertThat(out.size()).isEqualTo(1); } @@ -246,7 +247,7 @@ public void decode_handlesHelloFromPeerWithAdvertisedPortOf0() assertThat(peerConnection.getPeer().getEnodeURL()).isEqualTo(expectedEnode); // Next phase of pipeline should be setup - verify(pipeline, times(1)).addLast(any()); + verify(pipeline, times(1)).addLast(any(ChannelHandler[].class)); // Next message should be pushed out final PingMessage nextMessage = PingMessage.get(); @@ -254,7 +255,7 @@ public void decode_handlesHelloFromPeerWithAdvertisedPortOf0() when(framer.deframe(eq(nextData))) .thenReturn(new RawMessage(nextMessage.getCode(), nextMessage.getData())) .thenReturn(null); - verify(pipeline, times(1)).addLast(any()); + verify(pipeline, times(1)).addLast(any(ChannelHandler[].class)); deFramer.decode(ctx, nextData, out); assertThat(out.size()).isEqualTo(1); } @@ -292,7 +293,7 @@ public void decode_handlesUnexpectedPeerId() { assertThat(out).isEmpty(); // Next phase of pipeline should be setup - verify(pipeline, times(1)).addLast(any()); + verify(pipeline, times(1)).addLast(any(ChannelHandler[].class)); } @Test @@ -321,7 +322,7 @@ public void decode_handlesNoSharedCaps() { assertThat(out).isEmpty(); // Next phase of pipeline should be setup - verify(pipeline, times(1)).addLast(any()); + verify(pipeline, times(1)).addLast(any(ChannelHandler[].class)); } @Test diff --git a/evm/src/test/java/org/hyperledger/besu/evm/operations/ChainIdOperationTest.java b/evm/src/test/java/org/hyperledger/besu/evm/operations/ChainIdOperationTest.java index 7202be03ce3..e8d2c3d02db 100644 --- a/evm/src/test/java/org/hyperledger/besu/evm/operations/ChainIdOperationTest.java +++ b/evm/src/test/java/org/hyperledger/besu/evm/operations/ChainIdOperationTest.java @@ -27,7 +27,6 @@ import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.units.bigints.UInt256; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @@ -51,7 +50,7 @@ static Iterable params() { void shouldReturnChainId(final String chainIdString, final int expectedGas) { Bytes32 chainId = Bytes32.fromHexString(chainIdString); ChainIdOperation operation = new ChainIdOperation(new ConstantinopleGasCalculator(), chainId); - final ArgumentCaptor arg = ArgumentCaptor.forClass(UInt256.class); + final ArgumentCaptor arg = ArgumentCaptor.forClass(Bytes.class); when(messageFrame.getRemainingGas()).thenReturn(100L); operation.execute(messageFrame, null); Mockito.verify(messageFrame).getRemainingGas(); diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index 58a562fff88..906d4a2ee27 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -2858,12 +2858,12 @@ - - - + + + - - + + @@ -2874,17 +2874,17 @@ - - - + + + - - + + - - - + + + @@ -5316,20 +5316,20 @@ - - - + + + - - + + - - - + + + - - + + diff --git a/gradle/versions.gradle b/gradle/versions.gradle index c27af91f09b..747a386cb38 100644 --- a/gradle/versions.gradle +++ b/gradle/versions.gradle @@ -192,7 +192,7 @@ dependencyManagement { entry 'org.jupnp' } - dependencySet(group: 'org.mockito', version:'4.11.0') { + dependencySet(group: 'org.mockito', version:'5.8.0') { entry 'mockito-core' entry 'mockito-junit-jupiter' } From 2c1d3d28410d6b0f3f55b67e0f2ad8cb7e111d5b Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Tue, 16 Jan 2024 10:53:41 +1000 Subject: [PATCH 13/14] cliqueBft AT task flakiness - extend no_output_timeout (#6406) * revert machine change and extend timeout instead Signed-off-by: Sally MacFarlane --------- Signed-off-by: Sally MacFarlane --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6d08e515a18..065a0280d04 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -240,7 +240,7 @@ jobs: at: ~/project - run: name: AcceptanceTests (Non-Mainnet) - no_output_timeout: 20m + no_output_timeout: 30m command: | ./gradlew --no-daemon --max-workers=1 acceptanceTestCliqueBft - capture_test_results From c316a6dfb5ea354bad50194840362c6622910b0e Mon Sep 17 00:00:00 2001 From: Gabriel-Trintinalia Date: Tue, 16 Jan 2024 13:53:55 +1100 Subject: [PATCH 14/14] Remove deprecated `--privacy-onchain-groups-enabled` option (#6411) Signed-off-by: Gabriel-Trintinalia --- CHANGELOG.md | 1 + .../org/hyperledger/besu/cli/BesuCommand.java | 21 +------- .../util/ConfigOptionSearchAndRunHandler.java | 11 ---- .../hyperledger/besu/cli/BesuCommandTest.java | 51 ------------------- .../src/test/resources/everything_config.toml | 1 - 5 files changed, 3 insertions(+), 82 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d520eba5425..504d120a9fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Breaking Changes - New `EXECUTION_HALTED` error returned if there is an error executing or simulating a transaction, with the reason for execution being halted. Replaces the generic `INTERNAL_ERROR` return code in certain cases which some applications may be checking for [#6343](https://github.com/hyperledger/besu/pull/6343) - The Besu Docker images with `openjdk-latest` tags since 23.10.3 were incorrectly using UID 1001 instead of 1000 for the container's `besu` user. The user now uses 1000 again. Containers created from or migrated to images using UID 1001 will need to chown their persistent database files to UID 1000 [#6360](https://github.com/hyperledger/besu/pull/6360) +- The deprecated `--privacy-onchain-groups-enabled` option has now been removed. Use the `--privacy-flexible-groups-enabled` option instead. [#6411](https://github.com/hyperledger/besu/pull/6411) ### Deprecations diff --git a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java index d2fb5243313..c51d03d4305 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -22,7 +22,6 @@ import static org.hyperledger.besu.cli.DefaultCommandValues.getDefaultBesuDataPath; import static org.hyperledger.besu.cli.config.NetworkName.MAINNET; import static org.hyperledger.besu.cli.util.CommandLineUtils.DEPENDENCY_WARNING_MSG; -import static org.hyperledger.besu.cli.util.CommandLineUtils.DEPRECATION_WARNING_MSG; import static org.hyperledger.besu.cli.util.CommandLineUtils.isOptionSet; import static org.hyperledger.besu.controller.BesuController.DATABASE_PATH; import static org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration.DEFAULT_GRAPHQL_HTTP_PORT; @@ -953,13 +952,6 @@ static class PrivacyOptionGroup { names = {"--privacy-flexible-groups-enabled"}, description = "Enable flexible privacy groups (default: ${DEFAULT-VALUE})") private final Boolean isFlexiblePrivacyGroupsEnabled = false; - - @Option( - hidden = true, - names = {"--privacy-onchain-groups-enabled"}, - description = - "!!DEPRECATED!! Use `--privacy-flexible-groups-enabled` instead. Enable flexible (onchain) privacy groups (default: ${DEFAULT-VALUE})") - private final Boolean isOnchainPrivacyGroupsEnabled = false; } // Metrics Option Group @@ -1716,8 +1708,7 @@ private void validatePluginOptions() { } if (unstablePrivacyPluginOptions.isPrivacyPluginEnabled() - && (privacyOptionGroup.isFlexiblePrivacyGroupsEnabled - || privacyOptionGroup.isOnchainPrivacyGroupsEnabled)) { + && privacyOptionGroup.isFlexiblePrivacyGroupsEnabled) { throw new ParameterException( commandLine, "Privacy Plugin can not be used with flexible privacy groups"); } @@ -2056,13 +2047,6 @@ && isOptionSet(commandLine, "--sync-min-peers")) { "--security-module=" + DEFAULT_SECURITY_MODULE); } - if (Boolean.TRUE.equals(privacyOptionGroup.isOnchainPrivacyGroupsEnabled)) { - logger.warn( - DEPRECATION_WARNING_MSG, - "--privacy-onchain-groups-enabled", - "--privacy-flexible-groups-enabled"); - } - if (isPruningEnabled()) { if (dataStorageOptions .toDomainObject() @@ -2750,8 +2734,7 @@ private PrivacyParameters privacyParameters() { privacyParametersBuilder.setMultiTenancyEnabled( privacyOptionGroup.isPrivacyMultiTenancyEnabled); privacyParametersBuilder.setFlexiblePrivacyGroupsEnabled( - privacyOptionGroup.isFlexiblePrivacyGroupsEnabled - || privacyOptionGroup.isOnchainPrivacyGroupsEnabled); + privacyOptionGroup.isFlexiblePrivacyGroupsEnabled); privacyParametersBuilder.setPrivacyPluginEnabled( unstablePrivacyPluginOptions.isPrivacyPluginEnabled()); diff --git a/besu/src/main/java/org/hyperledger/besu/cli/util/ConfigOptionSearchAndRunHandler.java b/besu/src/main/java/org/hyperledger/besu/cli/util/ConfigOptionSearchAndRunHandler.java index 17cf2e649c9..5866d43cde6 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/util/ConfigOptionSearchAndRunHandler.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/util/ConfigOptionSearchAndRunHandler.java @@ -55,7 +55,6 @@ public ConfigOptionSearchAndRunHandler( public List handle(final ParseResult parseResult) throws ParameterException { final CommandLine commandLine = parseResult.commandSpec().commandLine(); final Optional configFile = findConfigFile(parseResult, commandLine); - validatePrivacyOptions(parseResult, commandLine); commandLine.setDefaultValueProvider(createDefaultValueProvider(commandLine, configFile)); commandLine.setExecutionStrategy(resultHandler); commandLine.setParameterExceptionHandler(parameterExceptionHandler); @@ -64,16 +63,6 @@ public List handle(final ParseResult parseResult) throws ParameterExcept return new ArrayList<>(); } - private void validatePrivacyOptions( - final ParseResult parseResult, final CommandLine commandLine) { - if (parseResult.hasMatchedOption("--privacy-onchain-groups-enabled") - && parseResult.hasMatchedOption("--privacy-flexible-groups-enabled")) { - throw new ParameterException( - commandLine, - "The `--privacy-onchain-groups-enabled` option is deprecated and you should only use `--privacy-flexible-groups-enabled`"); - } - } - private Optional findConfigFile( final ParseResult parseResult, final CommandLine commandLine) { if (parseResult.hasMatchedOption("--config-file") diff --git a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java index dc56c34845d..26296556302 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java @@ -29,7 +29,6 @@ import static org.hyperledger.besu.cli.config.NetworkName.MORDOR; import static org.hyperledger.besu.cli.config.NetworkName.SEPOLIA; import static org.hyperledger.besu.cli.util.CommandLineUtils.DEPENDENCY_WARNING_MSG; -import static org.hyperledger.besu.cli.util.CommandLineUtils.DEPRECATION_WARNING_MSG; import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.ENGINE; import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.ETH; import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis.NET; @@ -1977,16 +1976,6 @@ public void ethStatsContactOptionCannotBeUsedWithoutEthStatsServerProvided() { "The `--ethstats-contact` requires ethstats server URL to be provided. Either remove --ethstats-contact or provide a URL (via --ethstats=nodename:secret@host:port)"); } - @Test - public void privacyOnchainGroupsEnabledCannotBeUsedWithPrivacyFlexibleGroupsEnabled() { - parseCommand("--privacy-onchain-groups-enabled", "--privacy-flexible-groups-enabled"); - Mockito.verifyNoInteractions(mockRunnerBuilder); - assertThat(commandOutput.toString(UTF_8)).isEmpty(); - assertThat(commandErrorOutput.toString(UTF_8)) - .contains( - "The `--privacy-onchain-groups-enabled` option is deprecated and you should only use `--privacy-flexible-groups-enabled`"); - } - @Test public void parsesValidBonsaiTrieLimitBackLayersOption() { parseCommand("--data-storage-format", "BONSAI", "--bonsai-historical-block-limit", "11"); @@ -4203,46 +4192,6 @@ public void flexiblePrivacyGroupEnabledFlagDefaultValueIsFalse() { assertThat(privacyParameters.isFlexiblePrivacyGroupsEnabled()).isEqualTo(false); } - @Test - public void onchainPrivacyGroupEnabledFlagValueIsSet() { - parseCommand( - "--privacy-enabled", - "--privacy-public-key-file", - ENCLAVE_PUBLIC_KEY_PATH, - "--privacy-onchain-groups-enabled", - "--min-gas-price", - "0"); - - final ArgumentCaptor privacyParametersArgumentCaptor = - ArgumentCaptor.forClass(PrivacyParameters.class); - - verify(mockControllerBuilder).privacyParameters(privacyParametersArgumentCaptor.capture()); - verify(mockControllerBuilder).build(); - - assertThat(commandOutput.toString(UTF_8)).isEmpty(); - assertThat(commandErrorOutput.toString(UTF_8)).isEmpty(); - - final PrivacyParameters privacyParameters = privacyParametersArgumentCaptor.getValue(); - assertThat(privacyParameters.isFlexiblePrivacyGroupsEnabled()).isEqualTo(true); - } - - @Test - public void onchainPrivacyGroupEnabledOptionIsDeprecated() { - parseCommand( - "--privacy-enabled", - "--privacy-public-key-file", - ENCLAVE_PUBLIC_KEY_PATH, - "--privacy-onchain-groups-enabled", - "--min-gas-price", - "0"); - - verify(mockLogger) - .warn( - DEPRECATION_WARNING_MSG, - "--privacy-onchain-groups-enabled", - "--privacy-flexible-groups-enabled"); - } - @Test public void flexiblePrivacyGroupEnabledFlagValueIsSet() { parseCommand( diff --git a/besu/src/test/resources/everything_config.toml b/besu/src/test/resources/everything_config.toml index e516060da86..c653f3f60fd 100644 --- a/besu/src/test/resources/everything_config.toml +++ b/besu/src/test/resources/everything_config.toml @@ -169,7 +169,6 @@ privacy-enabled=false privacy-multi-tenancy-enabled=true privacy-marker-transaction-signing-key-file="./signerKey" privacy-enable-database-migration=false -privacy-onchain-groups-enabled=false privacy-flexible-groups-enabled=false # Transaction Pool