From 9a7744763a13cd6bf047a396f7db5194ba0068f1 Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Fri, 18 Oct 2024 12:50:55 +0200 Subject: [PATCH 01/14] Create and publish Besu BOM (Bill of Materials) (#7615) Signed-off-by: Fabio Di Fabio --- CHANGELOG.md | 1 + acceptance-tests/tests/build.gradle | 15 +- build.gradle | 34 +- ethereum/referencetests/build.gradle | 1 + gradle/verification-metadata.xml | 532 ++++++++++++++++++--------- gradle/versions.gradle | 249 ------------- platform/build.gradle | 218 +++++++++++ settings.gradle | 1 + 8 files changed, 614 insertions(+), 437 deletions(-) delete mode 100644 gradle/versions.gradle create mode 100644 platform/build.gradle diff --git a/CHANGELOG.md b/CHANGELOG.md index c581fbd034..2234201da3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ### Additions and Improvements - Fine tune already seen txs tracker when a tx is removed from the pool [#7755](https://github.com/hyperledger/besu/pull/7755) +- Create and publish Besu BOM (Bill of Materials) [#7615](https://github.com/hyperledger/besu/pull/7615) ### Bug fixes diff --git a/acceptance-tests/tests/build.gradle b/acceptance-tests/tests/build.gradle index 8bb8fb2f2f..809d82957b 100644 --- a/acceptance-tests/tests/build.gradle +++ b/acceptance-tests/tests/build.gradle @@ -106,7 +106,8 @@ task acceptanceTest(type: Test) { setSystemProperties(test.getSystemProperties()) systemProperty 'acctests.runBesuAsProcess', 'true' systemProperty 'java.security.properties', "${buildDir}/resources/test/acceptanceTesting.security" - mustRunAfter rootProject.subprojects*.test + def javaProjects = rootProject.subprojects - project(':platform') + mustRunAfter javaProjects.test description = 'Runs ALL Besu acceptance tests (mainnet and non-mainnet).' group = 'verification' @@ -135,7 +136,8 @@ task acceptanceTestNotPrivacy(type: Test) { setSystemProperties(test.getSystemProperties()) systemProperty 'acctests.runBesuAsProcess', 'true' systemProperty 'java.security.properties', "${buildDir}/resources/test/acceptanceTesting.security" - mustRunAfter rootProject.subprojects*.test + def javaProjects = rootProject.subprojects - project(':platform') + mustRunAfter javaProjects.test description = 'Runs MAINNET Besu acceptance tests (excluding specific non-mainnet suites).' group = 'verification' @@ -163,7 +165,8 @@ task acceptanceTestCliqueBft(type: Test) { setSystemProperties(test.getSystemProperties()) systemProperty 'acctests.runBesuAsProcess', 'true' systemProperty 'java.security.properties', "${buildDir}/resources/test/acceptanceTesting.security" - mustRunAfter rootProject.subprojects*.test + def javaProjects = rootProject.subprojects - project(':platform') + mustRunAfter javaProjects.test description = 'Runs Clique and BFT Besu acceptance tests.' group = 'verification' @@ -192,7 +195,8 @@ task acceptanceTestBftSoak(type: Test) { // Set to any time > 60 minutes to run the soak test for longer // systemProperty 'acctests.soakTimeMins', '120' systemProperty 'java.security.properties', "${buildDir}/resources/test/acceptanceTesting.security" - mustRunAfter rootProject.subprojects*.test + def javaProjects = rootProject.subprojects - project(':platform') + mustRunAfter javaProjects.test description = 'Runs BFT soak test.' group = 'verification' @@ -219,7 +223,8 @@ task acceptanceTestPermissioning(type: Test) { setSystemProperties(test.getSystemProperties()) systemProperty 'acctests.runBesuAsProcess', 'true' systemProperty 'java.security.properties', "${buildDir}/resources/test/acceptanceTesting.security" - mustRunAfter rootProject.subprojects*.test + def javaProjects = rootProject.subprojects - project(':platform') + mustRunAfter javaProjects.test description = 'Runs Permissioning Besu acceptance tests.' group = 'verification' diff --git a/build.gradle b/build.gradle index 901f08f4f0..de8f3e23d1 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,6 @@ plugins { id 'com.github.ben-manes.versions' version '0.51.0' id 'com.github.jk1.dependency-license-report' version '2.9' id 'com.jfrog.artifactory' version '5.2.5' - id 'io.spring.dependency-management' version '1.1.6' id 'me.champeau.jmh' version '0.7.2' apply false id 'net.ltgt.errorprone' version '4.0.1' id 'maven-publish' @@ -120,12 +119,10 @@ licenseReport { ] } -allprojects { +configure(allprojects - project(':platform')) { apply plugin: 'java-library' - apply plugin: 'io.spring.dependency-management' apply plugin: 'jacoco' apply plugin: 'net.ltgt.errorprone' - apply from: "${rootDir}/gradle/versions.gradle" version = calculateVersion() @@ -185,6 +182,12 @@ allprojects { } dependencies { + api platform(project(':platform')) + + annotationProcessor(platform(project(':platform'))) + + testAnnotationProcessor(platform(project(':platform'))) + components.all(BouncyCastleCapability) errorprone 'com.google.errorprone:error_prone_core' // https://github.com/hyperledger/besu-errorprone-checks/ @@ -442,14 +445,16 @@ task checkMavenCoordinateCollisions { doLast { def coordinates = [:] getAllprojects().forEach { - if (it.properties.containsKey('publishing') && it.jar?.enabled) { - def coordinate = it.publishing?.publications[0].coordinates - if (coordinate.toString().startsWith("org") && coordinates.containsKey(coordinate)) { - throw new GradleException("Duplicate maven coordinates detected, ${coordinate} is used by " + - "both ${coordinates[coordinate]} and ${it.path}.\n" + - "Please add a `publishing` script block to one or both subprojects.") + if (it.properties.containsKey('publishing')) { + if(!it.properties.containsKey('jar') || it.jar.enabled) { + def coordinate = it.publishing?.publications[0].coordinates + if (coordinate.toString().startsWith("org") && coordinates.containsKey(coordinate)) { + throw new GradleException("Duplicate maven coordinates detected, ${coordinate} is used by " + + "both ${coordinates[coordinate]} and ${it.path}.\n" + + "Please add a `publishing` script block to one or both subprojects.") + } + coordinates[coordinate] = it.path } - coordinates[coordinate] = it.path } } } @@ -597,7 +602,9 @@ subprojects { configurations { + testSupportAnnotationProcessor.extendsFrom annotationProcessor testSupportImplementation.extendsFrom implementation + integrationTestAnnotationProcessor.extendsFrom annotationProcessor integrationTestImplementation.extendsFrom implementation testSupportArtifacts } @@ -622,7 +629,10 @@ subprojects { duplicateClassesStrategy = DuplicatesStrategy.WARN } - dependencies { jmh 'org.slf4j:slf4j-api' } + dependencies { + jmhAnnotationProcessor(platform(project(':platform'))) + jmh 'org.slf4j:slf4j-api' + } } // making sure assemble task invokes integration test compile diff --git a/ethereum/referencetests/build.gradle b/ethereum/referencetests/build.gradle index 22f22c70a5..48f556a5b9 100644 --- a/ethereum/referencetests/build.gradle +++ b/ethereum/referencetests/build.gradle @@ -14,6 +14,7 @@ */ configurations { + referenceTestAnnotationProcessor.extendsFrom testAnnotationProcessor // we need this because referenceTestImplementation defaults to 'canBeResolved=false'. tarConfig.extendsFrom referenceTestImplementation tarConfig { diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index 67e88aa204..507b031b58 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -134,6 +134,11 @@ + + + + + @@ -144,11 +149,6 @@ - - - - - @@ -164,6 +164,11 @@ + + + + + @@ -213,6 +218,11 @@ + + + + + @@ -246,9 +256,6 @@ - - - @@ -285,6 +292,16 @@ + + + + + + + + + + @@ -293,6 +310,11 @@ + + + + + @@ -304,6 +326,11 @@ + + + + + @@ -320,6 +347,11 @@ + + + + + @@ -331,6 +363,11 @@ + + + + + @@ -496,6 +533,11 @@ + + + + + @@ -818,6 +860,9 @@ + + + @@ -929,6 +974,14 @@ + + + + + + + + @@ -937,6 +990,29 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -953,6 +1029,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -1177,14 +1273,6 @@ - - - - - - - - @@ -1307,9 +1395,6 @@ - - - @@ -1363,6 +1448,11 @@ + + + + + @@ -1382,10 +1472,15 @@ - - - + + + + + + + + @@ -1398,6 +1493,14 @@ + + + + + + + + @@ -1467,6 +1570,11 @@ + + + + + @@ -1532,9 +1640,6 @@ - - - @@ -1600,6 +1705,11 @@ + + + + + @@ -1789,6 +1899,11 @@ + + + + + @@ -1807,9 +1922,9 @@ - - - + + + @@ -1825,14 +1940,6 @@ - - - - - - - - @@ -1841,14 +1948,6 @@ - - - - - - - - @@ -1866,9 +1965,6 @@ - - - @@ -1881,15 +1977,7 @@ - - - - - - - - @@ -1934,14 +2022,6 @@ - - - - - - - - @@ -1980,9 +2060,6 @@ - - - @@ -1995,15 +2072,7 @@ - - - - - - - - @@ -2024,11 +2093,6 @@ - - - - - @@ -2053,9 +2117,6 @@ - - - @@ -2087,25 +2148,25 @@ - - - + + + - - + + - - - + + + - - + + - - - + + + @@ -2137,6 +2198,11 @@ + + + + + @@ -2154,6 +2220,11 @@ + + + + + @@ -2168,6 +2239,11 @@ + + + + + @@ -2238,6 +2314,11 @@ + + + + + @@ -2525,11 +2606,6 @@ - - - - - @@ -2543,6 +2619,11 @@ + + + + + @@ -2567,12 +2648,12 @@ - - - + + + - - + + @@ -2628,19 +2709,6 @@ - - - - - - - - - - - - - @@ -2795,11 +2863,6 @@ - - - - - @@ -2823,25 +2886,25 @@ - - - + + + - - + + - - - + + + - - + + - - - + + + @@ -2849,6 +2912,16 @@ + + + + + + + + + + @@ -3211,6 +3284,11 @@ + + + + + @@ -3248,6 +3326,11 @@ + + + + + @@ -3312,6 +3395,11 @@ + + + + + @@ -3322,6 +3410,11 @@ + + + + + @@ -3342,6 +3435,11 @@ + + + + + @@ -3456,11 +3554,26 @@ + + + + + + + + + + + + + + + @@ -3474,6 +3587,11 @@ + + + + + @@ -3572,6 +3690,11 @@ + + + + + @@ -3617,6 +3740,11 @@ + + + + + @@ -3666,6 +3794,9 @@ + + + @@ -4888,6 +5019,11 @@ + + + + + @@ -4953,6 +5089,14 @@ + + + + + + + + @@ -4977,12 +5121,12 @@ - - - + + + - - + + @@ -5088,15 +5232,12 @@ - - - + + + - - - - - + + @@ -5130,14 +5271,6 @@ - - - - - - - - @@ -5366,6 +5499,14 @@ + + + + + + + + @@ -5374,6 +5515,14 @@ + + + + + + + + @@ -5474,11 +5623,6 @@ - - - - - @@ -5528,13 +5672,18 @@ - - - + + + + + + + + @@ -5574,6 +5723,11 @@ + + + + + @@ -5796,6 +5950,14 @@ + + + + + + + + @@ -5830,6 +5992,14 @@ + + + + + + + + @@ -5846,6 +6016,14 @@ + + + + + + + + @@ -5947,6 +6125,11 @@ + + + + + @@ -5980,6 +6163,11 @@ + + + + + @@ -6111,9 +6299,6 @@ - - - @@ -6187,9 +6372,6 @@ - - - @@ -6306,6 +6488,14 @@ + + + + + + + + diff --git a/gradle/versions.gradle b/gradle/versions.gradle deleted file mode 100644 index 4796aa5282..0000000000 --- a/gradle/versions.gradle +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * 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 - */ - -dependencyManagement { - dependencies { - applyMavenExclusions = false - - dependencySet(group:'com.fasterxml.jackson.core', version:'2.17.2') { - entry 'jackson-databind' - entry 'jackson-datatype' - entry 'jackson-datatype-jdk8' - } - - dependency 'com.github.ben-manes.caffeine:caffeine:3.1.8' - - dependency 'com.google.protobuf:protobuf-java:3.25.5' - - dependency 'org.bitbucket.b_c:jose4j:0.9.4' - - dependency 'com.github.oshi:oshi-core:6.6.3' - - dependency 'com.google.auto.service:auto-service:1.1.1' - - dependencySet(group: 'com.google.dagger', version: '2.52') { - entry'dagger-compiler' - entry'dagger' - } - - dependency 'org.hyperledger.besu:besu-errorprone-checks:1.0.0' - - dependency 'com.google.guava:guava:33.3.0-jre' - - dependency 'com.graphql-java:graphql-java:22.2' - - dependency 'com.splunk.logging:splunk-library-javalogging:1.11.8' - - dependency 'com.squareup.okhttp3:okhttp:4.12.0' - - dependency 'commons-codec:commons-codec:1.16.0' - - dependency 'commons-io:commons-io:2.16.1' - - dependency 'commons-net:commons-net:3.11.1' - - dependency 'dnsjava:dnsjava:3.6.1' - - dependencySet(group: 'info.picocli', version: '4.7.6') { - entry 'picocli' - entry 'picocli-codegen' - } - - dependencySet(group: 'io.grpc', version: '1.66.0') { - entry 'grpc-all' - entry 'grpc-core' - entry 'grpc-netty' - entry 'grpc-stub' - } - - dependency 'io.kubernetes:client-java:18.0.1' - - dependency 'io.netty:netty-all:4.1.112.Final' - dependency 'io.netty:netty-tcnative-boringssl-static:2.0.66.Final' - dependency group: 'io.netty', name: 'netty-transport-native-epoll', version:'4.1.112.Final', classifier: 'linux-x86_64' - dependency group: 'io.netty', name: 'netty-transport-native-kqueue', version:'4.1.112.Final', classifier: 'osx-x86_64' - dependency 'io.netty:netty-transport-native-unix-common:4.1.112.Final' - - dependency 'io.opentelemetry:opentelemetry-api:1.41.0' - dependency 'io.opentelemetry:opentelemetry-exporter-otlp:1.41.0' - dependency 'io.opentelemetry:opentelemetry-extension-trace-propagators:1.41.0' - dependency 'io.opentelemetry:opentelemetry-sdk-metrics:1.41.0' - dependency 'io.opentelemetry:opentelemetry-sdk-trace:1.41.0' - dependency 'io.opentelemetry:opentelemetry-sdk:1.41.0' - dependency 'io.opentelemetry:opentelemetry-sdk-extension-autoconfigure:1.41.0' - dependency 'io.opentelemetry.instrumentation:opentelemetry-okhttp-3.0:2.7.0-alpha' - dependency 'io.opentelemetry.proto:opentelemetry-proto:1.3.2-alpha' - dependency 'io.opentelemetry.semconv:opentelemetry-semconv:1.27.0-alpha' - - dependency 'io.opentracing.contrib:opentracing-okhttp3:3.0.0' - dependency 'io.opentracing:opentracing-api:0.33.0' - dependency 'io.opentracing:opentracing-util:0.33.0' - - dependency 'io.pkts:pkts-core:3.0.10' - - dependencySet(group: 'io.prometheus', version: '0.16.0') { - entry 'simpleclient' - entry 'simpleclient_common' - entry 'simpleclient_hotspot' - entry 'simpleclient_pushgateway' - entry 'simpleclient_guava' - } - - 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-io' - entry 'tuweni-net' - entry 'tuweni-rlp' - entry 'tuweni-toml' - entry 'tuweni-units' - } - - dependencySet(group: 'io.vertx', version: '4.5.9') { - entry 'vertx-auth-jwt' - entry 'vertx-codegen' - entry 'vertx-core' - entry 'vertx-junit5' - entry 'vertx-unit' - entry 'vertx-web' - entry 'vertx-web-client' - entry 'vertx-auth-jwt' - } - - dependency 'junit:junit:4.13.2' - - dependency 'net.java.dev.jna:jna:5.14.0' - - dependencySet(group: 'org.antlr', version: '4.11.1') { - entry 'antlr4' - entry 'antlr4-runtime' - } - - dependency 'org.apache.commons:commons-collections4:4.4' - dependency 'org.apache.commons:commons-compress:1.27.1' - dependency 'org.apache.commons:commons-lang3:3.17.0' - dependency 'org.apache.commons:commons-text:1.12.0' - - dependencySet(group: 'org.apache.logging.log4j', version: '2.23.1') { - entry 'log4j-api' - entry 'log4j-core' - entry 'log4j-jul' - entry 'log4j-slf4j2-impl' - } - - dependency 'org.assertj:assertj-core:3.26.3' - - dependency 'org.awaitility:awaitility:4.2.2' - - dependencySet(group: 'org.bouncycastle', version: '1.78.1') { - entry'bcpkix-jdk18on' - entry'bcprov-jdk18on' - } - - dependency 'org.fusesource.jansi:jansi:2.4.1' - - dependencySet(group: 'org.hyperledger.besu', version: '0.9.7') { - entry 'arithmetic' - entry 'ipa-multipoint' - entry 'bls12-381' - entry 'secp256k1' - entry 'secp256r1' - entry 'blake2bf' - entry 'gnark' - } - - dependencySet(group: 'org.immutables', version: '2.10.1') { - entry 'value-annotations' - entry 'value' - } - - dependency 'org.java-websocket:Java-WebSocket:1.5.7' - - dependencySet(group: 'org.jacoco', version: '0.8.12') { - entry 'org.jacoco.agent' - entry 'org.jacoco.core' - } - - dependency 'org.jetbrains.kotlin:kotlin-stdlib:2.0.20' - - dependencySet(group: 'org.junit.jupiter', version: '5.11.0') { - entry 'junit-jupiter' - entry 'junit-jupiter-api' - entry 'junit-jupiter-engine' - entry 'junit-jupiter-params' - } - - dependency 'org.openjdk.jol:jol-core:0.17' - - dependency 'org.junit.platform:junit-platform-runner:1.9.2' - - dependency 'org.junit.vintage:junit-vintage-engine:5.10.1' - - dependencySet(group: 'org.jupnp', version:'3.0.2') { - entry 'org.jupnp.support' - entry 'org.jupnp' - } - - dependencySet(group: 'org.mockito', version:'5.13.0') { - entry 'mockito-core' - entry 'mockito-junit-jupiter' - } - - dependencySet(group: 'org.openjdk.jmh', version:'1.37') { - entry 'jmh-core' - entry 'jmh-generator-annprocess' - } - - dependency 'org.owasp.encoder:encoder:1.3.1' - - dependency 'org.rocksdb:rocksdbjni:8.3.2' // 8.9.1 causes a bug with a FOREST canary - - dependencySet(group: 'org.slf4j', version:'2.0.16') { - entry 'slf4j-api' - entry 'slf4j-nop' - } - - dependency 'org.springframework.security:spring-security-crypto:6.3.3' - - dependency 'org.testcontainers:testcontainers:1.20.1' - - dependency 'org.web3j:quorum:4.10.0' - dependencySet(group: 'org.web3j', version: '4.12.1') { - entry 'abi' - entry 'besu' - entry 'core' - entry 'crypto' - } - - dependencySet(group: 'org.wiremock', version: '3.9.1') { - entry 'wiremock' - } - - dependency 'org.xerial.snappy:snappy-java:1.1.10.6' - - dependency 'org.yaml:snakeyaml:2.0' - - dependency 'org.apache.maven:maven-artifact:3.9.6' - - dependency 'tech.pegasys:jc-kzg-4844:1.0.0' - - dependency 'tech.pegasys.discovery:discovery:24.6.0' - } -} diff --git a/platform/build.gradle b/platform/build.gradle new file mode 100644 index 0000000000..7234a1006d --- /dev/null +++ b/platform/build.gradle @@ -0,0 +1,218 @@ +/* + * Copyright contributors to Hyperledger Besu. + * + * 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 + */ +plugins { + id 'java-platform' + id 'com.diffplug.spotless' + id 'maven-publish' +} + +repositories { + mavenCentral() +} + +javaPlatform { + allowDependencies() +} + +dependencies { + api platform('com.fasterxml.jackson:jackson-bom:2.17.2') + api platform('io.grpc:grpc-bom:1.66.0') + api platform('io.netty:netty-bom:4.1.112.Final') + api platform('io.opentelemetry:opentelemetry-bom:1.41.0') + api platform('io.prometheus:simpleclient_bom:0.16.0') + api platform('io.vertx:vertx-stack-depchain:4.5.9') + api platform('org.apache.logging.log4j:log4j-bom:2.23.1') + api platform('org.assertj:assertj-bom:3.26.3') + api platform('org.immutables:bom:2.10.1') + api platform('org.junit:junit-bom:5.11.0') + api platform('org.mockito:mockito-bom:5.13.0') + api platform('org.slf4j:slf4j-bom:2.0.16') + + constraints { + api project(':acceptance-tests:dsl') + api project(':besu') + api project(':config') + api project(':crypto:algorithms') + api project(':crypto:services') + api project(':ethereum:api') + api project(':ethereum:blockcreation') + api project(':ethereum:core') + api project(':ethereum:eth') + api project(':ethereum:p2p') + api project(':ethereum:permissioning') + api project(':ethereum:referencetests') + api project(':ethereum:rlp') + api project(':evm') + api project(':datatypes') + api project(':plugin-api') + + api 'com.github.ben-manes.caffeine:caffeine:3.1.8' + + api 'org.bitbucket.b_c:jose4j:0.9.4' + + api 'com.github.oshi:oshi-core:6.6.3' + + api 'com.google.auto.service:auto-service:1.1.1' + + api 'com.google.dagger:dagger-compiler:2.52' + api 'com.google.dagger:dagger:2.52' + + api 'com.google.guava:guava:33.3.0-jre' + + api 'com.google.protobuf:protobuf-java:3.25.5' + + api 'com.graphql-java:graphql-java:22.2' + + api 'com.splunk.logging:splunk-library-javalogging:1.11.8' + + api 'com.squareup.okhttp3:okhttp:4.12.0' + + api 'commons-io:commons-io:2.16.1' + + api 'commons-net:commons-net:3.11.1' + + api 'dnsjava:dnsjava:3.6.1' + + api 'info.picocli:picocli:4.7.6' + api 'info.picocli:picocli-codegen:4.7.6' + + api 'io.kubernetes:client-java:18.0.1' + + api 'io.opentelemetry.instrumentation:opentelemetry-okhttp-3.0:2.7.0-alpha' + api 'io.opentelemetry.proto:opentelemetry-proto:1.3.2-alpha' + api 'io.opentelemetry.semconv:opentelemetry-semconv:1.27.0-alpha' + + api 'io.opentracing:opentracing-api:0.33.0' + api 'io.opentracing:opentracing-util:0.33.0' + api 'io.opentracing.contrib:opentracing-okhttp3:3.0.0' + + api 'io.pkts:pkts-core:3.0.10' + + api 'io.tmio:tuweni-bytes:2.4.2' + api 'io.tmio:tuweni-config:2.4.2' + api 'io.tmio:tuweni-concurrent:2.4.2' + api 'io.tmio:tuweni-crypto:2.4.2' + api 'io.tmio:tuweni-devp2p:2.4.2' + api 'io.tmio:tuweni-io:2.4.2' + api 'io.tmio:tuweni-net:2.4.2' + api 'io.tmio:tuweni-rlp:2.4.2' + api 'io.tmio:tuweni-toml:2.4.2' + api 'io.tmio:tuweni-units:2.4.2' + + api 'junit:junit:4.13.2' + + api 'net.java.dev.jna:jna:5.14.0' + + api 'org.antlr:antlr4:4.11.1' + api 'org.antlr:antlr4-runtime:4.11.1' + + api 'org.apache.commons:commons-collections4:4.4' + api 'org.apache.commons:commons-compress:1.27.1' + api 'org.apache.commons:commons-lang3:3.17.0' + api 'org.apache.commons:commons-text:1.12.0' + + api 'org.apache.maven:maven-artifact:3.9.6' + + api 'org.awaitility:awaitility:4.2.2' + + api 'org.bouncycastle:bcpkix-jdk18on:1.78.1' + api 'org.bouncycastle:bcprov-jdk18on:1.78.1' + + api 'org.fusesource.jansi:jansi:2.4.1' + + api 'org.hyperledger.besu:arithmetic:0.9.7' + api 'org.hyperledger.besu:blake2bf:0.9.7' + api 'org.hyperledger.besu:bls12-381:0.9.7' + api 'org.hyperledger.besu:gnark:0.9.7' + api 'org.hyperledger.besu:ipa-multipoint:0.9.7' + api 'org.hyperledger.besu:secp256k1:0.9.7' + api 'org.hyperledger.besu:secp256r1:0.9.7' + + api 'org.hyperledger.besu:besu-errorprone-checks:1.0.0' + + api 'org.jacoco:org.jacoco.agent:0.8.12' + api 'org.jacoco:org.jacoco.core:0.8.12' + + api 'org.junit.platform:junit-platform-runner:1.9.2' + api 'org.junit.vintage:junit-vintage-engine:5.10.1' + + api 'org.jupnp:org.jupnp:3.0.2' + api 'org.jupnp:org.jupnp.support:3.0.2' + + api 'org.openjdk.jmh:jmh-core:1.37' + api 'org.openjdk.jmh:jmh-generator-annprocess:1.37' + + api 'org.openjdk.jol:jol-core:0.17' + + api 'org.owasp.encoder:encoder:1.3.1' + + api 'org.rocksdb:rocksdbjni:8.3.2' + + api 'org.springframework.security:spring-security-crypto:6.3.3' + + api 'org.testcontainers:testcontainers:1.20.1' + + api 'org.wiremock:wiremock:3.9.1' + + api 'org.web3j:abi:4.12.1' + api 'org.web3j:besu:4.12.1' + api 'org.web3j:core:4.12.1' + api 'org.web3j:crypto:4.12.1' + api 'org.web3j:quorum:4.10.0' + + api 'org.xerial.snappy:snappy-java:1.1.10.6' + + api 'tech.pegasys:jc-kzg-4844:1.0.0' + + api 'tech.pegasys.discovery:discovery:24.6.0' + } +} + + +spotless { + // spotless check applied to build.gradle (groovy) files + groovyGradle { + target '*.gradle' + greclipse('4.31').configFile(rootProject.file('gradle/spotless/greclipse.properties')) + endWithNewline() + } +} + +publishing { + publications { + mavenPlatform(MavenPublication) { + from components.javaPlatform + groupId "org.hyperledger.besu" + artifactId 'bom' + version calculateVersion() + + pom { + name = "Besu BOM" + url = 'http://github.com/hyperledger/besu' + licenses { + license { + name = 'The Apache License, Version 2.0' + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + scm { + connection = 'scm:git:git://github.com/hyperledger/besu.git' + developerConnection = 'scm:git:ssh://github.com/hyperledger/besu.git' + url = 'https://github.com/hyperledger/besu' + } + } + } + } +} diff --git a/settings.gradle b/settings.gradle index 322383b32c..2860c666d9 100644 --- a/settings.gradle +++ b/settings.gradle @@ -62,6 +62,7 @@ include 'metrics:core' include 'metrics:rocksdb' include 'nat' include 'pki' +include 'platform' include 'plugin-api' include 'plugins:rocksdb' include 'privacy-contracts' From 7e61f74ff79ae845a262dc2f6f09a6cce9761780 Mon Sep 17 00:00:00 2001 From: Stefan Pingel <16143240+pinges@users.noreply.github.com> Date: Mon, 21 Oct 2024 10:03:56 +1000 Subject: [PATCH 02/14] Add requests root to empty block check (#7785) * add requests root to empty block check and move it to BlockHeader Signed-off-by: stefan.pingel@consensys.net --- .../hyperledger/besu/ethereum/core/BlockHeader.java | 13 +++++++++++++ .../ethereum/eth/sync/tasks/CompleteBlocksTask.java | 12 +----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeader.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeader.java index 42f99fafb6..7ff841280d 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeader.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeader.java @@ -92,6 +92,19 @@ public class BlockHeader extends SealableBlockHeader this.parsedExtraData = Suppliers.memoize(() -> blockHeaderFunctions.parseExtraData(this)); } + public static boolean hasEmptyBlock(final BlockHeader blockHeader) { + return blockHeader.getOmmersHash().equals(Hash.EMPTY_LIST_HASH) + && blockHeader.getTransactionsRoot().equals(Hash.EMPTY_TRIE_HASH) + && blockHeader + .getWithdrawalsRoot() + .map(wsRoot -> wsRoot.equals(Hash.EMPTY_TRIE_HASH)) + .orElse(true) + && blockHeader + .getRequestsRoot() + .map(reqRoot -> reqRoot.equals(Hash.EMPTY_TRIE_HASH)) + .orElse(true); + } + /** * Returns the block mixed hash. * diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTask.java index 524851af5f..ec679e53a1 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTask.java @@ -19,7 +19,6 @@ import static java.util.Collections.emptyList; import static java.util.concurrent.CompletableFuture.completedFuture; import static java.util.stream.Collectors.toMap; -import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; @@ -75,7 +74,7 @@ public class CompleteBlocksTask extends AbstractRetryingPeerTask> { this.headers = headers; this.blocks = headers.stream() - .filter(this::hasEmptyBody) + .filter(BlockHeader::hasEmptyBlock) .collect( toMap( BlockHeader::getNumber, @@ -102,15 +101,6 @@ public class CompleteBlocksTask extends AbstractRetryingPeerTask> { return protocolSchedule.getByBlockHeader(header).getWithdrawalsProcessor().isPresent(); } - private boolean hasEmptyBody(final BlockHeader header) { - return header.getOmmersHash().equals(Hash.EMPTY_LIST_HASH) - && header.getTransactionsRoot().equals(Hash.EMPTY_TRIE_HASH) - && header - .getWithdrawalsRoot() - .map(wsRoot -> wsRoot.equals(Hash.EMPTY_TRIE_HASH)) - .orElse(true); - } - public static CompleteBlocksTask forHeaders( final ProtocolSchedule protocolSchedule, final EthContext ethContext, From 937c25acdd1389f892fc1884db170d050f5dfb1e Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Mon, 21 Oct 2024 11:49:06 +0200 Subject: [PATCH 03/14] Update Java dependencies (#7786) Signed-off-by: Fabio Di Fabio --- CHANGELOG.md | 1 + build.gradle | 1 - gradle/verification-metadata.xml | 2142 +++++++++-------- .../nat/kubernetes/KubernetesNatManager.java | 2 +- platform/build.gradle | 53 +- 5 files changed, 1127 insertions(+), 1072 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2234201da3..f862ed866f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ### Additions and Improvements - Fine tune already seen txs tracker when a tx is removed from the pool [#7755](https://github.com/hyperledger/besu/pull/7755) - Create and publish Besu BOM (Bill of Materials) [#7615](https://github.com/hyperledger/besu/pull/7615) +- Update Java dependencies [#7786](https://github.com/hyperledger/besu/pull/7786) ### Bug fixes diff --git a/build.gradle b/build.gradle index de8f3e23d1..b3a29ac656 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,6 @@ import java.util.regex.Pattern plugins { id 'com.diffplug.spotless' version '6.25.0' - id 'com.github.ben-manes.versions' version '0.51.0' id 'com.github.jk1.dependency-license-report' version '2.9' id 'com.jfrog.artifactory' version '5.2.5' id 'me.champeau.jmh' version '0.7.2' apply false diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index 507b031b58..0c72f91416 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -17,6 +17,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -114,6 +143,11 @@ + + + + + @@ -139,9 +173,9 @@ - - - + + + @@ -174,6 +208,11 @@ + + + + + @@ -194,6 +233,11 @@ + + + + + @@ -223,12 +267,12 @@ - - - + + + - - + + @@ -260,12 +304,12 @@ - - - + + + - - + + @@ -302,12 +346,25 @@ - - - + + + - - + + + + + + + + + + + + + + + @@ -315,15 +372,25 @@ - - - + + + + + + - - + + - - + + + + + + + + + @@ -331,20 +398,20 @@ - - - + + + - - - + + + - - + + - - + + @@ -352,15 +419,15 @@ - - - + + + - - + + - - + + @@ -368,17 +435,9 @@ - - - - - - - - - - - + + + @@ -392,11 +451,6 @@ - - - - - @@ -618,17 +672,17 @@ - - - + + + - - + + - - - + + + @@ -639,6 +693,14 @@ + + + + + + + + @@ -736,6 +798,14 @@ + + + + + + + + @@ -752,6 +822,11 @@ + + + + + @@ -783,14 +858,6 @@ - - - - - - - - @@ -804,11 +871,6 @@ - - - - - @@ -1013,15 +1075,15 @@ - - - + + + - - + + - - + + @@ -1049,9 +1111,9 @@ - - - + + + @@ -1109,26 +1171,6 @@ - - - - - - - - - - - - - - - - - - - - @@ -1139,43 +1181,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1192,26 +1197,6 @@ - - - - - - - - - - - - - - - - - - - - @@ -1246,12 +1231,12 @@ - - - + + + - - + + @@ -1302,6 +1287,14 @@ + + + + + + + + @@ -1310,6 +1303,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1350,33 +1375,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1420,11 +1418,6 @@ - - - - - @@ -1433,11 +1426,6 @@ - - - - - @@ -1538,6 +1526,14 @@ + + + + + + + + @@ -1546,6 +1542,11 @@ + + + + + @@ -1591,12 +1592,12 @@ - - - + + + - - + + @@ -1628,9 +1629,15 @@ - - - + + + + + + + + + @@ -1673,230 +1680,230 @@ - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - - + + + - - + + @@ -1904,17 +1911,12 @@ - - - - - - + + + - - - - + + @@ -1922,9 +1924,9 @@ - - - + + + @@ -1932,36 +1934,36 @@ - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + @@ -1969,12 +1971,12 @@ - - - + + + - - + + @@ -1982,68 +1984,68 @@ - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + @@ -2051,12 +2053,12 @@ - - - + + + - - + + @@ -2064,12 +2066,12 @@ - - - + + + - - + + @@ -2077,20 +2079,20 @@ - - - + + + - - + + - - - + + + - - + + @@ -2098,9 +2100,9 @@ - - - + + + @@ -2108,12 +2110,12 @@ - - - + + + - - + + @@ -2121,52 +2123,57 @@ - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - + + - - - - - - + + + - - + + - - - + + + + + + + + + + + @@ -2174,28 +2181,28 @@ - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + @@ -2203,21 +2210,21 @@ - - - + + + - - + + - - + + - - + + - - + + @@ -2225,18 +2232,18 @@ - - - + + + - - + + - - + + - - + + @@ -2244,36 +2251,36 @@ - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + @@ -2292,174 +2299,174 @@ - - - + + + - - + + - - + + - - - + + + - - + + - - + + - - - + + + - - - + + + - - + + - - + + - - - + + + - - + + - - + + - - - + + + - - + + - - + + - - - + + + - - + + - - + + - - - + + + - - + + - - + + - - - + + + - - + + - - + + - - - + + + - - + + - - + + - - - + + + - - + + - - + + - - - + + + - - + + - - + + - - - + + + - - + + - - + + - - - + + + - - + + - - + + - - - + + + - - + + - - + + - - - + + + - - + + - - + + @@ -2470,28 +2477,28 @@ - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + @@ -2502,15 +2509,15 @@ - - - + + + - - + + - - + + @@ -2709,17 +2716,17 @@ - - - + + + - - + + - - - + + + @@ -2818,54 +2825,54 @@ - - - + + + - - + + - - - + + + - - + + - - - + + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + @@ -2878,33 +2885,33 @@ - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + @@ -2912,59 +2919,59 @@ - - - + + + - - - + + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + @@ -2975,6 +2982,14 @@ + + + + + + + + @@ -2993,6 +3008,19 @@ + + + + + + + + + + + + + @@ -3009,6 +3037,14 @@ + + + + + + + + @@ -3046,20 +3082,20 @@ - - - + + + - - + + - - - + + + - - + + @@ -3067,9 +3103,9 @@ - - - + + + @@ -3082,12 +3118,12 @@ - - - + + + - - + + @@ -3098,6 +3134,14 @@ + + + + + + + + @@ -3132,6 +3176,14 @@ + + + + + + + + @@ -3140,6 +3192,14 @@ + + + + + + + + @@ -3148,6 +3208,11 @@ + + + + + @@ -3284,11 +3349,6 @@ - - - - - @@ -3410,11 +3470,6 @@ - - - - - @@ -3450,6 +3505,11 @@ + + + + + @@ -3471,6 +3531,19 @@ + + + + + + + + + + + + + @@ -3479,6 +3552,11 @@ + + + + + @@ -3549,9 +3627,9 @@ - - - + + + @@ -3564,9 +3642,9 @@ - - - + + + @@ -3574,17 +3652,17 @@ - - - + + + - - + + - - - + + + @@ -3592,46 +3670,46 @@ - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - - + + + - - + + - - - + + + @@ -3716,20 +3794,12 @@ - - - - - - - - - - - + + + - - + + @@ -3740,11 +3810,6 @@ - - - - - @@ -3812,11 +3877,6 @@ - - - - - @@ -3887,6 +3947,11 @@ + + + + + @@ -3993,11 +4058,6 @@ - - - - - @@ -5190,14 +5250,6 @@ - - - - - - - - @@ -5211,11 +5263,6 @@ - - - - - @@ -5451,6 +5498,14 @@ + + + + + + + + @@ -5475,6 +5530,14 @@ + + + + + + + + @@ -5531,26 +5594,26 @@ - - - + + + - - + + - - + + - - - + + + - - + + - - + + @@ -5561,15 +5624,15 @@ - - - + + + - - + + - - + + @@ -5580,26 +5643,26 @@ - - - + + + - - + + - - + + - - - + + + - - + + - - + + @@ -5615,23 +5678,23 @@ - - - + + + - - + + - - - + + + - - + + - - + + @@ -5647,12 +5710,12 @@ - - - + + + - - + + @@ -5663,25 +5726,20 @@ - - - + + + - - + + - - - + + + - - - - - - - + + @@ -5723,25 +5781,25 @@ - - - + + + - - - + + + - - + + - - - + + + - - + + @@ -5934,6 +5992,14 @@ + + + + + + + + @@ -6214,12 +6280,12 @@ - - - + + + - - + + @@ -6233,12 +6299,12 @@ - - - + + + - - + + @@ -6262,26 +6328,26 @@ - - - + + + - - + + - - + + - - - + + + - - + + - - + + @@ -6300,15 +6366,15 @@ - - - + + + - - + + - - + + @@ -6319,26 +6385,26 @@ - - - + + + - - + + - - + + - - - + + + - - + + - - + + @@ -6354,15 +6420,15 @@ - - - + + + - - + + - - + + @@ -6373,15 +6439,15 @@ - - - + + + - - + + - - + + @@ -6392,15 +6458,15 @@ - - - + + + - - + + - - + + @@ -6443,12 +6509,12 @@ - - - + + + - - + + @@ -6480,14 +6546,6 @@ - - - - - - - - @@ -6515,15 +6573,15 @@ - - - + + + - - + + - - + + diff --git a/nat/src/main/java/org/hyperledger/besu/nat/kubernetes/KubernetesNatManager.java b/nat/src/main/java/org/hyperledger/besu/nat/kubernetes/KubernetesNatManager.java index f8af2bdddb..6a9c02a31c 100644 --- a/nat/src/main/java/org/hyperledger/besu/nat/kubernetes/KubernetesNatManager.java +++ b/nat/src/main/java/org/hyperledger/besu/nat/kubernetes/KubernetesNatManager.java @@ -84,7 +84,7 @@ public class KubernetesNatManager extends AbstractNatManager { final V1Service service = api .listServiceForAllNamespaces( - null, null, null, null, null, null, null, null, null, null) + null, null, null, null, null, null, null, null, null, null, null) .getItems() .stream() .filter( diff --git a/platform/build.gradle b/platform/build.gradle index 7234a1006d..e42d3e0774 100644 --- a/platform/build.gradle +++ b/platform/build.gradle @@ -27,17 +27,17 @@ javaPlatform { } dependencies { - api platform('com.fasterxml.jackson:jackson-bom:2.17.2') - api platform('io.grpc:grpc-bom:1.66.0') - api platform('io.netty:netty-bom:4.1.112.Final') - api platform('io.opentelemetry:opentelemetry-bom:1.41.0') + api platform('com.fasterxml.jackson:jackson-bom:2.18.0') + api platform('io.grpc:grpc-bom:1.68.0') + api platform('io.netty:netty-bom:4.1.114.Final') + api platform('io.opentelemetry:opentelemetry-bom:1.43.0') api platform('io.prometheus:simpleclient_bom:0.16.0') - api platform('io.vertx:vertx-stack-depchain:4.5.9') - api platform('org.apache.logging.log4j:log4j-bom:2.23.1') + api platform('io.vertx:vertx-stack-depchain:4.5.10') + api platform('org.apache.logging.log4j:log4j-bom:2.24.1') api platform('org.assertj:assertj-bom:3.26.3') api platform('org.immutables:bom:2.10.1') - api platform('org.junit:junit-bom:5.11.0') - api platform('org.mockito:mockito-bom:5.13.0') + api platform('org.junit:junit-bom:5.11.2') + api platform('org.mockito:mockito-bom:5.14.2') api platform('org.slf4j:slf4j-bom:2.0.16') constraints { @@ -60,39 +60,37 @@ dependencies { api 'com.github.ben-manes.caffeine:caffeine:3.1.8' - api 'org.bitbucket.b_c:jose4j:0.9.4' - - api 'com.github.oshi:oshi-core:6.6.3' + api 'com.github.oshi:oshi-core:6.6.5' api 'com.google.auto.service:auto-service:1.1.1' api 'com.google.dagger:dagger-compiler:2.52' api 'com.google.dagger:dagger:2.52' - api 'com.google.guava:guava:33.3.0-jre' + api 'com.google.guava:guava:33.3.1-jre' api 'com.google.protobuf:protobuf-java:3.25.5' - api 'com.graphql-java:graphql-java:22.2' + api 'com.graphql-java:graphql-java:22.3' api 'com.splunk.logging:splunk-library-javalogging:1.11.8' api 'com.squareup.okhttp3:okhttp:4.12.0' - api 'commons-io:commons-io:2.16.1' + api 'commons-io:commons-io:2.17.0' api 'commons-net:commons-net:3.11.1' - api 'dnsjava:dnsjava:3.6.1' + api 'dnsjava:dnsjava:3.6.2' api 'info.picocli:picocli:4.7.6' api 'info.picocli:picocli-codegen:4.7.6' - api 'io.kubernetes:client-java:18.0.1' + api 'io.kubernetes:client-java:21.0.1-legacy' - api 'io.opentelemetry.instrumentation:opentelemetry-okhttp-3.0:2.7.0-alpha' + api 'io.opentelemetry.instrumentation:opentelemetry-okhttp-3.0:2.9.0-alpha' api 'io.opentelemetry.proto:opentelemetry-proto:1.3.2-alpha' - api 'io.opentelemetry.semconv:opentelemetry-semconv:1.27.0-alpha' + api 'io.opentelemetry.semconv:opentelemetry-semconv:1.28.0-alpha' api 'io.opentracing:opentracing-api:0.33.0' api 'io.opentracing:opentracing-util:0.33.0' @@ -113,7 +111,7 @@ dependencies { api 'junit:junit:4.13.2' - api 'net.java.dev.jna:jna:5.14.0' + api 'net.java.dev.jna:jna:5.15.0' api 'org.antlr:antlr4:4.11.1' api 'org.antlr:antlr4-runtime:4.11.1' @@ -123,7 +121,7 @@ dependencies { api 'org.apache.commons:commons-lang3:3.17.0' api 'org.apache.commons:commons-text:1.12.0' - api 'org.apache.maven:maven-artifact:3.9.6' + api 'org.apache.maven:maven-artifact:3.9.9' api 'org.awaitility:awaitility:4.2.2' @@ -146,7 +144,6 @@ dependencies { api 'org.jacoco:org.jacoco.core:0.8.12' api 'org.junit.platform:junit-platform-runner:1.9.2' - api 'org.junit.vintage:junit-vintage-engine:5.10.1' api 'org.jupnp:org.jupnp:3.0.2' api 'org.jupnp:org.jupnp.support:3.0.2' @@ -162,21 +159,21 @@ dependencies { api 'org.springframework.security:spring-security-crypto:6.3.3' - api 'org.testcontainers:testcontainers:1.20.1' + api 'org.testcontainers:testcontainers:1.20.2' api 'org.wiremock:wiremock:3.9.1' - api 'org.web3j:abi:4.12.1' - api 'org.web3j:besu:4.12.1' - api 'org.web3j:core:4.12.1' - api 'org.web3j:crypto:4.12.1' + api 'org.web3j:abi:4.12.2' + api 'org.web3j:besu:4.12.2' + api 'org.web3j:core:4.12.2' + api 'org.web3j:crypto:4.12.2' api 'org.web3j:quorum:4.10.0' - api 'org.xerial.snappy:snappy-java:1.1.10.6' + api 'org.xerial.snappy:snappy-java:1.1.10.7' api 'tech.pegasys:jc-kzg-4844:1.0.0' - api 'tech.pegasys.discovery:discovery:24.6.0' + api 'tech.pegasys.discovery:discovery:24.9.1' } } From 1b0da83f19a11f1f099d5c84f4992714d31e9cc2 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Tue, 22 Oct 2024 06:56:09 +1000 Subject: [PATCH 04/14] use junit5 version of parameterized test (#7789) Signed-off-by: Sally MacFarlane --- .../besu/ForkIdsNetworkConfigTest.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/besu/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java b/besu/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java index 28d4c77036..5a58091577 100644 --- a/besu/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java +++ b/besu/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java @@ -15,6 +15,7 @@ package org.hyperledger.besu; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -46,20 +47,14 @@ import java.util.stream.Stream; import com.google.common.collect.Streams; import org.apache.tuweni.bytes.Bytes; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(Parameterized.class) +@ExtendWith(MockitoExtension.class) public class ForkIdsNetworkConfigTest { - @Parameterized.Parameter public NetworkName chainName; - - @Parameterized.Parameter(1) - public List expectedForkIds; - - @Parameterized.Parameters(name = "{0}") public static Collection parameters() { return List.of( new Object[] { @@ -149,8 +144,8 @@ public class ForkIdsNetworkConfigTest { final AtomicLong blockNumber = new AtomicLong(); when(mockBlockchain.getChainHeadHeader()).thenReturn(mockBlockHeader); - when(mockBlockHeader.getNumber()).thenAnswer(o -> blockNumber.get()); - when(mockBlockHeader.getTimestamp()).thenAnswer(o -> blockNumber.get()); + lenient().when(mockBlockHeader.getNumber()).thenAnswer(o -> blockNumber.get()); + lenient().when(mockBlockHeader.getTimestamp()).thenAnswer(o -> blockNumber.get()); final ForkIdManager forkIdManager = new ForkIdManager( From d8d1237252bd84fa3d797480e47b20bb4c0e5ff1 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Tue, 22 Oct 2024 10:11:28 +1000 Subject: [PATCH 05/14] [TESTING] remove junit4 assumeThat (#7788) * use junit5 assumeTrue/false Signed-off-by: Sally MacFarlane --------- Signed-off-by: Sally MacFarlane --- .../crypto/SECP256R1AcceptanceTest.java | 4 ++-- .../hyperledger/besu/cli/BesuCommandTest.java | 7 +++---- .../besu/cli/PrivacyOptionsTest.java | 10 ++++------ .../vm/BlockchainReferenceTestTools.java | 17 +++++++---------- .../evm/operation/DataCopyOperationTest.java | 6 +++--- 5 files changed, 19 insertions(+), 25 deletions(-) diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/crypto/SECP256R1AcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/crypto/SECP256R1AcceptanceTest.java index 27679463bf..cc2d1a36bc 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/crypto/SECP256R1AcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/crypto/SECP256R1AcceptanceTest.java @@ -15,7 +15,7 @@ package org.hyperledger.besu.tests.acceptance.crypto; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assumptions.assumeThat; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import org.hyperledger.besu.crypto.KeyPair; import org.hyperledger.besu.crypto.SECP256R1; @@ -80,7 +80,7 @@ public class SECP256R1AcceptanceTest extends AcceptanceTestBase { // the signature algorithm instance to SECP256R1 as it could influence other tests running at // the same time. So we only execute the test when ProcessBesuNodeRunner is used, as there is // not conflict because we use separate processes. - assumeThat(BesuNodeRunner.isProcessBesuNodeRunner()).isTrue(); + assumeTrue(BesuNodeRunner.isProcessBesuNodeRunner()); minerNode.verify(net.awaitPeerCount(1)); otherNode.verify(net.awaitPeerCount(1)); 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 e5848ee5f3..399b82be12 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java @@ -16,7 +16,6 @@ package org.hyperledger.besu.cli; import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.is; import static org.hyperledger.besu.cli.config.NetworkName.CLASSIC; import static org.hyperledger.besu.cli.config.NetworkName.DEV; import static org.hyperledger.besu.cli.config.NetworkName.EPHEMERY; @@ -33,7 +32,7 @@ import static org.hyperledger.besu.ethereum.p2p.config.DefaultDiscoveryConfigura import static org.hyperledger.besu.ethereum.p2p.config.DefaultDiscoveryConfiguration.SEPOLIA_BOOTSTRAP_NODES; import static org.hyperledger.besu.ethereum.p2p.config.DefaultDiscoveryConfiguration.SEPOLIA_DISCOVERY_URL; import static org.hyperledger.besu.plugin.services.storage.DataStorageFormat.BONSAI; -import static org.junit.Assume.assumeThat; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.contains; import static org.mockito.ArgumentMatchers.eq; @@ -2392,7 +2391,7 @@ public class BesuCommandTest extends CommandTestAbstract { @Test public void logsWarningWhenFailToLoadJemalloc() { - assumeThat(PlatformDetector.getOSType(), is("linux")); + assumeTrue(PlatformDetector.getOSType().equals("linux")); setEnvironmentVariable("BESU_USING_JEMALLOC", "true"); parseCommand(); verify(mockLogger) @@ -2404,7 +2403,7 @@ public class BesuCommandTest extends CommandTestAbstract { @Test public void logsSuggestInstallingJemallocWhenEnvVarNotPresent() { - assumeThat(PlatformDetector.getOSType(), is("linux")); + assumeTrue(PlatformDetector.getOSType().equals("linux")); parseCommand(); verify(mockLogger) .info("jemalloc library not found, memory usage may be reduced by installing it"); diff --git a/besu/src/test/java/org/hyperledger/besu/cli/PrivacyOptionsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/PrivacyOptionsTest.java index af43535a8f..6a2c376436 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/PrivacyOptionsTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/PrivacyOptionsTest.java @@ -16,8 +16,7 @@ package org.hyperledger.besu.cli; import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.startsWith; -import static org.junit.Assume.assumeThat; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -415,10 +414,9 @@ public class PrivacyOptionsTest extends CommandTestAbstract { @Test public void privEnclaveKeyFileDoesNotExist() { - assumeThat( - "Ignored if system language is not English", - System.getProperty("user.language"), - startsWith("en")); + assumeTrue( + System.getProperty("user.language").startsWith("en"), + "Ignored if system language is not English"); parseCommand("--privacy-enabled=true", "--privacy-public-key-file", "/non/existent/file"); assertThat(commandOutput.toString(UTF_8)).isEmpty(); diff --git a/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/vm/BlockchainReferenceTestTools.java b/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/vm/BlockchainReferenceTestTools.java index aabc674087..f7a15e5eae 100644 --- a/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/vm/BlockchainReferenceTestTools.java +++ b/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/vm/BlockchainReferenceTestTools.java @@ -15,7 +15,7 @@ package org.hyperledger.besu.ethereum.vm; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assumptions.assumeThat; +import static org.junit.jupiter.api.Assumptions.assumeFalse; import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; @@ -148,18 +148,15 @@ public class BlockchainReferenceTestTools { } static void verifyJournaledEVMAccountCompatability( - final MutableWorldState worldState, final ProtocolSpec protocolSpec) { + final MutableWorldState worldState, final ProtocolSpec protocolSpec) { EVM evm = protocolSpec.getEvm(); if (evm.getEvmConfiguration().worldUpdaterMode() == WorldUpdaterMode.JOURNALED) { - assumeThat( + assumeFalse( worldState - .streamAccounts(Bytes32.ZERO, Integer.MAX_VALUE) - .anyMatch(AccountState::isEmpty)) - .withFailMessage("Journaled account configured and empty account detected") - .isFalse(); - assumeThat(EvmSpecVersion.SPURIOUS_DRAGON.compareTo(evm.getEvmVersion()) > 0) - .withFailMessage("Journaled account configured and fork prior to the merge specified") - .isFalse(); + .streamAccounts(Bytes32.ZERO, Integer.MAX_VALUE).anyMatch(AccountState::isEmpty), + "Journaled account configured and empty account detected"); + assumeFalse(EvmSpecVersion.SPURIOUS_DRAGON.compareTo(evm.getEvmVersion()) > 0, + "Journaled account configured and fork prior to the merge specified"); } } } diff --git a/evm/src/test/java/org/hyperledger/besu/evm/operation/DataCopyOperationTest.java b/evm/src/test/java/org/hyperledger/besu/evm/operation/DataCopyOperationTest.java index aa2ed37b5c..a4e93bf9d3 100644 --- a/evm/src/test/java/org/hyperledger/besu/evm/operation/DataCopyOperationTest.java +++ b/evm/src/test/java/org/hyperledger/besu/evm/operation/DataCopyOperationTest.java @@ -15,7 +15,7 @@ package org.hyperledger.besu.evm.operation; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assumptions.assumeThat; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import org.hyperledger.besu.evm.Code; import org.hyperledger.besu.evm.EVM; @@ -136,7 +136,7 @@ class DataCopyOperationTest { "0xef0001010004020001001d04%04x000080000367%016x67%016x67%016xd300%s" .formatted(data.size(), dst, src, len, data.toUnprefixedHexString()); Code code = evm.getCodeUncached(Bytes.fromHexString(eofCode)); - assumeThat(code.isValid()).isTrue(); + assumeTrue(code.isValid()); MessageFrame frame = new TestMessageFrameBuilder() @@ -158,7 +158,7 @@ class DataCopyOperationTest { void legacyCallFails() { DataCopyOperation subject = new DataCopyOperation(new PragueGasCalculator()); Code code = evm.getCodeUncached(Bytes.fromHexString("0x600460046004d3")); - assumeThat(code.isValid()).isTrue(); + assumeTrue(code.isValid()); MessageFrame frame = new TestMessageFrameBuilder() From 73a6042e0b552c62a175295882507c11103af694 Mon Sep 17 00:00:00 2001 From: Simon Dudley Date: Tue, 22 Oct 2024 14:07:11 +1000 Subject: [PATCH 06/14] Update release checklist (#7794) Signed-off-by: Simon Dudley --- .github/ISSUE_TEMPLATE/release-checklist.md | 31 +++++++++++++-------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/release-checklist.md b/.github/ISSUE_TEMPLATE/release-checklist.md index 413d68933f..dcf10977f0 100644 --- a/.github/ISSUE_TEMPLATE/release-checklist.md +++ b/.github/ISSUE_TEMPLATE/release-checklist.md @@ -12,25 +12,34 @@ assignees: '' - [ ] Notify maintainers about updating changelog for in-flight PRs - [ ] Optional: for hotfixes, create a release branch and cherry-pick, e.g. `release--hotfix` - [ ] Optional: for hotfixes, create a PR into main from the hotfix branch to see the CI checks pass -- [ ] On the appropriate branch/commit, create a calver tag for the release candidate, format example: `24.4.0-RC2` - - [ ] git tag 24.4.0-RC2 - - [ ] git push upstream 24.4.0-RC2 +- [ ] On the appropriate branch/commit, create a calver tag for the release candidate, format example: `24.4.0-RC1` + - [ ] git tag 24.4.0-RC1 + - [ ] git push upstream 24.4.0-RC1 - [ ] Sign-off with team; announce the tag in #besu-release in Discord - - [ ] Targeting this tag for the burn-in: https://github.com/hyperledger/besu/releases/tag/24.4.0-RC2 + - [ ] Targeting this tag for the burn-in: https://github.com/hyperledger/besu/releases/tag/24.4.0-RC1 - [ ] Consensys staff start burn-in using this tag - [ ] Seek sign off for burn-in - [ ] Pass? Go ahead and complete the release process - [ ] Fail? Put a message in #besu-release in Discord indicating the release will be aborted because it failed burn-in -- [ ] Using the same git sha, create a calver tag for the FULL RELEASE, example format `24.4.0` -- [ ] Using the FULL RELEASE tag, create a release in github to trigger the workflows. Once published: +- [ ] Optional: Perform a dry run with https://github.com/consensys/protocols-release-sandbox to test the workflows + - [ ] Sync fork + - [ ] git checkout + - [ ] git tag 24.4.0 + - [ ] git push origin 24.4.0 + - [ ] Manually run https://github.com/Consensys/protocols-release-sandbox/actions/workflows/draft-release.yml using `main` branch and `24.4.0` tag +- [ ] Back on besu, using the same git sha as 24.4.0-RC1, create a calver tag for the FULL RELEASE, example format `24.4.0` + - [ ] git checkout 24.4.0-RC1 + - [ ] git tag 24.4.0 + - [ ] git push upstream 24.4.0 +- [ ] Manually run https://github.com/hyperledger/besu/actions/workflows/draft-release.yml using `main` branch` and the FULL RELEASE tag name, i.e. `24.4.0`. Note, this workflow should always be run from `main` branch (hotfix tags will still be released even if they were created based on another branch) + - publishes artefacts and version-specific docker tags but does not fully publish the GitHub release so subscribers are not yet notified +- [ ] Check all draft-release workflow jobs went green +- [ ] Check binary SHAs are correct on the release page +- [ ] Update release notes in the GitHub draft release, save draft and sign-off with team +- [ ] Publish draft release ensuring it is marked as latest release (if appropriate) - this is now public and notifies subscribed users - makes the release "latest" in github - - publishes artefacts and version-specific docker tags - publishes the docker `latest` tag variants -- [ ] Check binary SHAs are correct on the release page -- [ ] Check "Container Verify" GitHub workflow has run successfully -- [ ] Update the besu-docs version [update-version workflow](https://github.com/hyperledger/besu-docs/actions/workflows/update-version.yml) - - If the PR has not been automatically created, create the PR manually using the created branch `besu-version-` - [ ] Create homebrew release using [update-version workflow](https://github.com/hyperledger/homebrew-besu/actions/workflows/update-version.yml) - If the PR has not been automatically created, create the PR manually using the created branch `update-` - Run commands `brew tap hyperledger/besu && brew install besu` on MacOSX and verify latest version has been installed From 76060a0416913b711d7b64072e1218622fd0d52f Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Wed, 23 Oct 2024 07:52:51 +1000 Subject: [PATCH 07/14] [TESTING] remove junit4 dependency (#7793) * migrate to junit5 * remove junit4 dep * remove vintage dep Signed-off-by: Sally MacFarlane --------- Signed-off-by: Sally MacFarlane --- acceptance-tests/dsl/build.gradle | 1 - acceptance-tests/test-plugins/build.gradle | 2 -- acceptance-tests/tests/build.gradle | 3 --- .../tests/acceptance/mining/MiningAcceptanceTest.java | 10 +++++----- ethereum/evmtool/build.gradle | 2 -- platform/build.gradle | 2 -- plugins/rocksdb/build.gradle | 2 -- 7 files changed, 5 insertions(+), 17 deletions(-) diff --git a/acceptance-tests/dsl/build.gradle b/acceptance-tests/dsl/build.gradle index 6c9090fe9b..aa5db9ce1e 100644 --- a/acceptance-tests/dsl/build.gradle +++ b/acceptance-tests/dsl/build.gradle @@ -33,7 +33,6 @@ dependencies { implementation 'info.picocli:picocli' implementation 'io.reactivex.rxjava2:rxjava' implementation 'io.vertx:vertx-core' - implementation 'junit:junit' implementation 'io.opentelemetry:opentelemetry-api' implementation 'io.tmio:tuweni-bytes' implementation 'io.tmio:tuweni-io' diff --git a/acceptance-tests/test-plugins/build.gradle b/acceptance-tests/test-plugins/build.gradle index 65a3dc64dc..7c70c52c81 100644 --- a/acceptance-tests/test-plugins/build.gradle +++ b/acceptance-tests/test-plugins/build.gradle @@ -14,8 +14,6 @@ dependencies { testImplementation 'org.assertj:assertj-core' testImplementation 'org.junit.jupiter:junit-jupiter' - - testRuntimeOnly 'org.junit.vintage:junit-vintage-engine' } task testPluginsJar(type: Jar) { diff --git a/acceptance-tests/tests/build.gradle b/acceptance-tests/tests/build.gradle index 809d82957b..e9724151ab 100644 --- a/acceptance-tests/tests/build.gradle +++ b/acceptance-tests/tests/build.gradle @@ -68,7 +68,6 @@ dependencies { testImplementation 'io.opentracing:opentracing-api' testImplementation 'io.opentracing:opentracing-util' testImplementation 'io.vertx:vertx-core' - testImplementation 'junit:junit' testImplementation 'org.apache.commons:commons-compress' testImplementation 'org.apache.logging.log4j:log4j-core' testImplementation 'io.tmio:tuweni-crypto' @@ -81,8 +80,6 @@ dependencies { testImplementation 'org.web3j:core' testImplementation 'org.wiremock:wiremock' testImplementation project(path: ':acceptance-tests:tests:shanghai') - - testRuntimeOnly 'org.junit.vintage:junit-vintage-engine' } test.enabled = false diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/mining/MiningAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/mining/MiningAcceptanceTest.java index 69d6d19d18..a0de84fb3b 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/mining/MiningAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/mining/MiningAcceptanceTest.java @@ -18,21 +18,21 @@ import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase; import org.hyperledger.besu.tests.acceptance.dsl.account.Account; import org.hyperledger.besu.tests.acceptance.dsl.node.Node; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class MiningAcceptanceTest extends AcceptanceTestBase { +class MiningAcceptanceTest extends AcceptanceTestBase { private Node minerNode; - @Before + @BeforeEach public void setUp() throws Exception { minerNode = besu.createMinerNode("miner1"); cluster.start(minerNode); } @Test - public void shouldMineTransactions() { + void shouldMineTransactions() { final Account sender = accounts.createAccount("account1"); final Account receiver = accounts.createAccount("account2"); minerNode.execute(accountTransactions.createTransfer(sender, 50)); diff --git a/ethereum/evmtool/build.gradle b/ethereum/evmtool/build.gradle index c4c83883b5..b62287b0ca 100644 --- a/ethereum/evmtool/build.gradle +++ b/ethereum/evmtool/build.gradle @@ -65,8 +65,6 @@ dependencies { testImplementation 'org.mockito:mockito-core' testImplementation 'org.mockito:mockito-junit-jupiter' - testRuntimeOnly 'org.junit.vintage:junit-vintage-engine' - // No logging in graalvm EvmTool nativeImageClasspath 'org.slf4j:slf4j-nop' } diff --git a/platform/build.gradle b/platform/build.gradle index e42d3e0774..2fda97e866 100644 --- a/platform/build.gradle +++ b/platform/build.gradle @@ -109,8 +109,6 @@ dependencies { api 'io.tmio:tuweni-toml:2.4.2' api 'io.tmio:tuweni-units:2.4.2' - api 'junit:junit:4.13.2' - api 'net.java.dev.jna:jna:5.15.0' api 'org.antlr:antlr4:4.11.1' diff --git a/plugins/rocksdb/build.gradle b/plugins/rocksdb/build.gradle index e5ca782504..d487cf9824 100644 --- a/plugins/rocksdb/build.gradle +++ b/plugins/rocksdb/build.gradle @@ -58,6 +58,4 @@ dependencies { testImplementation 'org.junit.jupiter:junit-jupiter' testImplementation 'org.assertj:assertj-core' testImplementation 'org.mockito:mockito-junit-jupiter' - - testRuntimeOnly 'org.junit.vintage:junit-vintage-engine' } From b23fd78da272921b24ea3ca6dc3f7d8e2e04c52e Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Wed, 23 Oct 2024 00:37:26 +0200 Subject: [PATCH 08/14] Add metrics related services to the Besu context for acceptance tests (#7797) Signed-off-by: Fabio Di Fabio --- .../acceptance/dsl/node/ThreadBesuNodeRunner.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 d4334fd93c..42c0df73c7 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 @@ -54,6 +54,7 @@ import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.cache.BonsaiCachedMer import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; import org.hyperledger.besu.evm.internal.EvmConfiguration; +import org.hyperledger.besu.metrics.MetricCategoryRegistryImpl; import org.hyperledger.besu.metrics.MetricsSystemModule; import org.hyperledger.besu.metrics.ObservableMetricsSystem; import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; @@ -71,6 +72,7 @@ import org.hyperledger.besu.plugin.services.StorageService; import org.hyperledger.besu.plugin.services.TransactionPoolValidatorService; import org.hyperledger.besu.plugin.services.TransactionSelectionService; import org.hyperledger.besu.plugin.services.TransactionSimulationService; +import org.hyperledger.besu.plugin.services.metrics.MetricCategoryRegistry; import org.hyperledger.besu.plugin.services.storage.rocksdb.RocksDBPlugin; import org.hyperledger.besu.services.BesuConfigurationImpl; import org.hyperledger.besu.services.BesuEventsImpl; @@ -396,6 +398,12 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner { retval.init(blockchain, transactionSimulator); return retval; } + + @Provides + @Singleton + MetricCategoryRegistryImpl provideMetricCategoryRegistry() { + return new MetricCategoryRegistryImpl(); + } } @Module @@ -476,6 +484,8 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner { final RpcEndpointServiceImpl rpcEndpointServiceImpl, final BesuConfiguration commonPluginConfiguration, final PermissioningServiceImpl permissioningService, + final MetricCategoryRegistryImpl metricCategoryRegistry, + final MetricsSystem metricsSystem, final @Named("ExtraCLIOptions") List extraCLIOptions, final @Named("RequestedPlugins") List requestedPlugins) { final CommandLine commandLine = new CommandLine(CommandSpec.create()); @@ -492,6 +502,8 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner { TransactionSimulationService.class, transactionSimulationServiceImpl); besuPluginContext.addService(BlockchainService.class, blockchainServiceImpl); besuPluginContext.addService(BesuConfiguration.class, commonPluginConfiguration); + besuPluginContext.addService(MetricCategoryRegistry.class, metricCategoryRegistry); + besuPluginContext.addService(MetricsSystem.class, metricsSystem); final Path pluginsPath; final String pluginDir = System.getProperty("besu.plugins.dir"); From 653ebcbd70367227b858807459cb98134f5711e4 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Wed, 23 Oct 2024 11:00:07 +1000 Subject: [PATCH 09/14] switch to junit 5 (#7799) Signed-off-by: Sally MacFarlane --- .../dsl/condition/blockchain/ExpectBlockNotCreated.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/blockchain/ExpectBlockNotCreated.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/blockchain/ExpectBlockNotCreated.java index 4deb1c1ee3..42cab06539 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/blockchain/ExpectBlockNotCreated.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/condition/blockchain/ExpectBlockNotCreated.java @@ -14,7 +14,7 @@ */ package org.hyperledger.besu.tests.acceptance.dsl.condition.blockchain; -import static junit.framework.TestCase.fail; +import static org.junit.jupiter.api.Assertions.fail; import org.hyperledger.besu.tests.acceptance.dsl.condition.Condition; import org.hyperledger.besu.tests.acceptance.dsl.node.Node; From d583863225859772559af43dcfa7dcdb804db51c Mon Sep 17 00:00:00 2001 From: Danno Ferrin Date: Wed, 23 Oct 2024 11:04:11 -0600 Subject: [PATCH 10/14] CALLF and JUMPF rules validation updates (#7787) * Check JUMPF stack Rule 2 in EIP-6206 requires us to check stack prior to JUMPF Signed-off-by: Danno Ferrin * CALLF rule 4 rollback Rule 4 is about return stack, not operand stack Signed-off-by: Danno Ferrin --------- Signed-off-by: Danno Ferrin --- .../hyperledger/besu/evm/operation/CallFOperation.java | 3 +-- .../hyperledger/besu/evm/operation/JumpFOperation.java | 8 ++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/evm/src/main/java/org/hyperledger/besu/evm/operation/CallFOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/CallFOperation.java index e1eb96f035..65b14fe295 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/operation/CallFOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/CallFOperation.java @@ -54,8 +54,7 @@ public class CallFOperation extends AbstractOperation { int section = code.readBigEndianU16(pc + 1); CodeSection info = code.getCodeSection(section); int operandStackSize = frame.stackSize(); - if (operandStackSize >= 1024 - || operandStackSize > 1024 - info.getMaxStackHeight() + info.getInputs()) { + if (operandStackSize > 1024 - info.getMaxStackHeight() + info.getInputs()) { return callfStackOverflow; } frame.getReturnStack().push(new ReturnStack.ReturnStackItem(frame.getSection(), pc + 2)); diff --git a/evm/src/main/java/org/hyperledger/besu/evm/operation/JumpFOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/JumpFOperation.java index c76caa9667..bda66546d5 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/operation/JumpFOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/JumpFOperation.java @@ -16,6 +16,7 @@ package org.hyperledger.besu.evm.operation; import org.hyperledger.besu.evm.Code; import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.ExceptionalHaltReason; import org.hyperledger.besu.evm.frame.MessageFrame; import org.hyperledger.besu.evm.gascalculator.GasCalculator; @@ -28,6 +29,9 @@ public class JumpFOperation extends AbstractOperation { /** The Jump F success operation result. */ static final OperationResult jumpfSuccess = new OperationResult(5, null); + static final OperationResult jumpfStackOverflow = + new OperationResult(5, ExceptionalHaltReason.TOO_MANY_STACK_ITEMS); + /** * Instantiates a new Jump F operation. * @@ -46,6 +50,10 @@ public class JumpFOperation extends AbstractOperation { int pc = frame.getPC(); int section = code.readBigEndianU16(pc + 1); var info = code.getCodeSection(section); + int operandStackSize = frame.stackSize(); + if (operandStackSize > 1024 - info.getMaxStackHeight() + info.getInputs()) { + return jumpfStackOverflow; + } frame.setPC(info.getEntryPoint() - 1); // will be +1ed at end of operations loop frame.setSection(section); return jumpfSuccess; From 8e3735fae5580172f47a87c684da2ade77f1cbf3 Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Thu, 24 Oct 2024 09:31:12 +0200 Subject: [PATCH 11/14] Include platform (BOM) project when publishing (#7803) Signed-off-by: Fabio Di Fabio --- build.gradle | 3 ++- platform/build.gradle | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index b3a29ac656..4fe80600c2 100644 --- a/build.gradle +++ b/build.gradle @@ -526,7 +526,8 @@ subprojects { return result } - if (sourceSetIsPopulated("main") || sourceSetIsPopulated("testSupport")) { + + if (sourceSetIsPopulated("main") || sourceSetIsPopulated("testSupport") || project.name == "platform") { apply plugin: 'com.jfrog.artifactory' apply plugin: 'maven-publish' diff --git a/platform/build.gradle b/platform/build.gradle index 2fda97e866..0718d41642 100644 --- a/platform/build.gradle +++ b/platform/build.gradle @@ -15,7 +15,6 @@ plugins { id 'java-platform' id 'com.diffplug.spotless' - id 'maven-publish' } repositories { From 71906fa9d4f0c992c8758256b4abb270996b2370 Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Thu, 24 Oct 2024 10:10:18 +0200 Subject: [PATCH 12/14] Replace custom required options check with standard way (#7738) Signed-off-by: Fabio Di Fabio --- besu/build.gradle | 9 ++- .../org/hyperledger/besu/cli/BesuCommand.java | 14 ---- .../cli/subcommands/PasswordSubCommand.java | 2 + .../subcommands/blocks/BlocksSubCommand.java | 2 + .../cli/subcommands/operator/BackupState.java | 2 + .../operator/GenerateBlockchainConfig.java | 3 + .../subcommands/operator/RestoreState.java | 2 + .../besu/cli/CommandTestAbstract.java | 2 + gradle/verification-metadata.xml | 77 +++++++++++++++++++ platform/build.gradle | 2 + 10 files changed, 97 insertions(+), 18 deletions(-) diff --git a/besu/build.gradle b/besu/build.gradle index fa2b0548c5..fb9aeef9e6 100644 --- a/besu/build.gradle +++ b/besu/build.gradle @@ -68,20 +68,21 @@ dependencies { implementation 'com.google.guava:guava' implementation 'com.google.dagger:dagger' implementation 'com.graphql-java:graphql-java' + implementation 'commons-net:commons-net' implementation 'info.picocli:picocli' implementation 'io.vertx:vertx-core' implementation 'io.vertx:vertx-web' - implementation 'org.apache.commons:commons-lang3' - implementation 'org.apache.logging.log4j:log4j-core' implementation 'io.tmio:tuweni-bytes' implementation 'io.tmio:tuweni-config' implementation 'io.tmio:tuweni-toml' implementation 'io.tmio:tuweni-units' + implementation 'org.apache.commons:commons-lang3' + implementation 'org.apache.logging.log4j:log4j-core' + implementation 'org.hibernate.validator:hibernate-validator' + implementation 'org.rocksdb:rocksdbjni' implementation 'org.springframework.security:spring-security-crypto' implementation 'org.xerial.snappy:snappy-java' implementation 'tech.pegasys:jc-kzg-4844' - implementation 'org.rocksdb:rocksdbjni' - implementation 'commons-net:commons-net' runtimeOnly 'org.apache.logging.log4j:log4j-jul' runtimeOnly 'com.splunk.logging:splunk-library-javalogging' 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 b21305c87a..08f36d7fed 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -1421,7 +1421,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable { } private void validateOptions() { - validateRequiredOptions(); issueOptionWarnings(); validateP2PInterface(p2PDiscoveryOptions.p2pInterface); validateMiningParams(); @@ -1475,19 +1474,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable { dataStorageOptions.validate(commandLine); } - private void validateRequiredOptions() { - commandLine - .getCommandSpec() - .options() - .forEach( - option -> { - if (option.required() && option.stringValues().isEmpty()) { - throw new ParameterException( - this.commandLine, "Missing required option: " + option.longestName()); - } - }); - } - private void validateMiningParams() { miningOptions.validate( commandLine, genesisConfigOptionsSupplier.get(), isMergeEnabled(), logger); diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PasswordSubCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PasswordSubCommand.java index b35cc2f5cf..5f5e8c3fca 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PasswordSubCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/PasswordSubCommand.java @@ -23,6 +23,7 @@ import org.hyperledger.besu.cli.util.VersionProvider; import java.io.PrintWriter; +import jakarta.validation.constraints.NotEmpty; import org.springframework.security.crypto.bcrypt.BCrypt; import picocli.CommandLine.Command; import picocli.CommandLine.Model.CommandSpec; @@ -75,6 +76,7 @@ public class PasswordSubCommand implements Runnable { static class HashSubCommand implements Runnable { @SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings. + @NotEmpty @Option( names = "--password", arity = "1..1", diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java index 9a0a453768..5bd0aacee2 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java @@ -54,6 +54,7 @@ import java.util.function.Function; import java.util.function.Supplier; import io.vertx.core.Vertx; +import jakarta.validation.constraints.NotBlank; import org.apache.tuweni.bytes.Bytes; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -335,6 +336,7 @@ public class BlocksSubCommand implements Runnable { arity = "1..1") private final BlockExportFormat format = BlockExportFormat.RLP; + @NotBlank @Option( names = "--to", required = true, diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/BackupState.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/BackupState.java index 793c817e52..efd924e5e2 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/BackupState.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/BackupState.java @@ -33,6 +33,7 @@ import java.util.Optional; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.LockSupport; +import jakarta.validation.constraints.NotBlank; import picocli.CommandLine.Command; import picocli.CommandLine.Option; import picocli.CommandLine.ParentCommand; @@ -55,6 +56,7 @@ public class BackupState implements Runnable { arity = "1..1") private final Long block = Long.MAX_VALUE; + @NotBlank @Option( names = "--backup-path", required = true, diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/GenerateBlockchainConfig.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/GenerateBlockchainConfig.java index f53f3a8057..d71cf652a5 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/GenerateBlockchainConfig.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/GenerateBlockchainConfig.java @@ -52,6 +52,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; import com.google.common.io.Resources; +import jakarta.validation.constraints.NotBlank; import org.apache.tuweni.bytes.Bytes; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -70,6 +71,7 @@ class GenerateBlockchainConfig implements Runnable { private final Supplier SIGNATURE_ALGORITHM = Suppliers.memoize(SignatureAlgorithmFactory::getInstance); + @NotBlank @Option( required = true, names = "--config-file", @@ -78,6 +80,7 @@ class GenerateBlockchainConfig implements Runnable { arity = "1..1") private final File configurationFile = null; + @NotBlank @Option( required = true, names = "--to", diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/RestoreState.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/RestoreState.java index 52ee255d4f..6480380240 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/RestoreState.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/operator/RestoreState.java @@ -46,6 +46,7 @@ import java.util.ArrayList; import java.util.List; import com.fasterxml.jackson.databind.node.ObjectNode; +import jakarta.validation.constraints.NotBlank; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; import org.slf4j.Logger; @@ -64,6 +65,7 @@ public class RestoreState implements Runnable { private static final Logger LOG = LoggerFactory.getLogger(RestoreState.class); + @NotBlank @Option( names = "--backup-path", required = true, diff --git a/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java b/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java index 00603bec87..8508edc54e 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java @@ -113,6 +113,7 @@ import io.opentelemetry.api.GlobalOpenTelemetry; import io.vertx.core.Vertx; import io.vertx.core.VertxOptions; import io.vertx.core.json.JsonObject; +import jakarta.validation.constraints.NotEmpty; import org.apache.commons.net.util.SubnetUtils.SubnetInfo; import org.apache.commons.text.StringEscapeUtils; import org.apache.tuweni.bytes.Bytes; @@ -621,6 +622,7 @@ public abstract class CommandTestAbstract { @CommandLine.Command public static class TestBesuCommandWithRequiredOption extends TestBesuCommand { + @NotEmpty @CommandLine.Option( names = {"--accept-terms-and-conditions"}, description = "You must explicitly accept terms and conditions", diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index 0c72f91416..d4407855f0 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -123,6 +123,19 @@ + + + + + + + + + + + + + @@ -3008,6 +3021,14 @@ + + + + + + + + @@ -3694,6 +3715,11 @@ + + + + + @@ -3707,6 +3733,11 @@ + + + + + @@ -5015,6 +5046,19 @@ + + + + + + + + + + + + + @@ -5194,6 +5238,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/platform/build.gradle b/platform/build.gradle index 0718d41642..307c54dc1a 100644 --- a/platform/build.gradle +++ b/platform/build.gradle @@ -127,6 +127,8 @@ dependencies { api 'org.fusesource.jansi:jansi:2.4.1' + api 'org.hibernate.validator:hibernate-validator:8.0.1.Final' + api 'org.hyperledger.besu:arithmetic:0.9.7' api 'org.hyperledger.besu:blake2bf:0.9.7' api 'org.hyperledger.besu:bls12-381:0.9.7' From 516559fadcd8657bf5eefa17814e228a216dcd79 Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Thu, 24 Oct 2024 10:36:21 +0200 Subject: [PATCH 13/14] Cleanup: Synchronizer is always present in protocol context (#7791) Signed-off-by: Fabio Di Fabio --- .../besu/controller/BesuControllerBuilder.java | 2 +- .../blockcreation/MergeCoordinatorTest.java | 2 ++ .../besu/ethereum/MainnetBlockValidator.java | 11 +---------- .../besu/ethereum/ProtocolContext.java | 8 +++----- .../besu/ethereum/core/Synchronizer.java | 17 +++++++++++++++++ .../besu/ethereum/core/BlockchainSetupUtil.java | 1 + .../besu/ethereum/core}/DummySynchronizer.java | 13 +++++++++++-- .../ethereum/MainnetBlockValidatorTest.java | 2 ++ .../ethereum/eth/manager/snap/SnapServer.java | 14 +++----------- .../ethereum/eth/sync/DefaultSynchronizer.java | 2 ++ ethereum/retesteth/build.gradle | 1 + .../ethereum/retesteth/RetestethService.java | 1 + 12 files changed, 45 insertions(+), 29 deletions(-) rename ethereum/{retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth => core/src/test-support/java/org/hyperledger/besu/ethereum/core}/DummySynchronizer.java (89%) diff --git a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java index bded2a38ac..91ef6f7cfa 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java @@ -717,7 +717,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides ethPeers.snapServerPeersNeeded(false); } - protocolContext.setSynchronizer(Optional.of(synchronizer)); + protocolContext.setSynchronizer(synchronizer); final Optional maybeSnapProtocolManager = createSnapProtocolManager( diff --git a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java index 09c1b28af4..4efcdc1e0f 100644 --- a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java +++ b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java @@ -59,6 +59,7 @@ import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.Unstable; import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.core.TransactionTestFixture; import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; @@ -189,6 +190,7 @@ public class MergeCoordinatorTest implements MergeGenesisConfigHelper { protocolContext = new ProtocolContext(blockchain, worldStateArchive, mergeContext, badBlockManager); + protocolContext.setSynchronizer(mock(Synchronizer.class)); var mutable = worldStateArchive.getMutable(); genesisState.writeStateTo(mutable); mutable.persist(null); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/MainnetBlockValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/MainnetBlockValidator.java index 0c56a419e3..9cd014f25a 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/MainnetBlockValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/MainnetBlockValidator.java @@ -181,16 +181,7 @@ public class MainnetBlockValidator implements BlockValidator { Optional.of(new BlockProcessingOutputs(worldState, receipts, maybeRequests))); } } catch (MerkleTrieException ex) { - context - .getSynchronizer() - .ifPresentOrElse( - synchronizer -> synchronizer.healWorldState(ex.getMaybeAddress(), ex.getLocation()), - () -> - handleFailedBlockProcessing( - block, - new BlockProcessingResult(Optional.empty(), ex), - // Do not record bad black due to missing data - false)); + context.getSynchronizer().healWorldState(ex.getMaybeAddress(), ex.getLocation()); return new BlockProcessingResult(Optional.empty(), ex); } catch (StorageException ex) { var retval = new BlockProcessingResult(Optional.empty(), ex); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/ProtocolContext.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/ProtocolContext.java index e5ec5ae092..4ca40bc0a9 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/ProtocolContext.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/ProtocolContext.java @@ -32,8 +32,7 @@ public class ProtocolContext { private final WorldStateArchive worldStateArchive; private final BadBlockManager badBlockManager; private final ConsensusContext consensusContext; - - private Optional synchronizer; + private Synchronizer synchronizer; /** * Constructs a new ProtocolContext with the given blockchain, world state archive, consensus @@ -52,7 +51,6 @@ public class ProtocolContext { this.blockchain = blockchain; this.worldStateArchive = worldStateArchive; this.consensusContext = consensusContext; - this.synchronizer = Optional.empty(); this.badBlockManager = badBlockManager; } @@ -85,7 +83,7 @@ public class ProtocolContext { * * @return the synchronizer of the protocol context */ - public Optional getSynchronizer() { + public Synchronizer getSynchronizer() { return synchronizer; } @@ -94,7 +92,7 @@ public class ProtocolContext { * * @param synchronizer the synchronizer to set */ - public void setSynchronizer(final Optional synchronizer) { + public void setSynchronizer(final Synchronizer synchronizer) { this.synchronizer = synchronizer; } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Synchronizer.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Synchronizer.java index 7d60c4d357..4a5d3c7ca1 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Synchronizer.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Synchronizer.java @@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.core; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.plugin.data.SyncStatus; import org.hyperledger.besu.plugin.services.BesuEvents; +import org.hyperledger.besu.plugin.services.BesuEvents.InitialSyncCompletionListener; import java.util.Optional; import java.util.concurrent.CompletableFuture; @@ -82,6 +83,22 @@ public interface Synchronizer { */ boolean unsubscribeInSync(final long listenerId); + /** + * Add a listener that will be notified when this node initial sync status changes. + * + * @param listener The callback to invoke when the initial sync status changes + * @return A subscription id that can be used to unsubscribe from these events + */ + long subscribeInitialSync(final InitialSyncCompletionListener listener); + + /** + * Unsubscribe from initial sync events. + * + * @param listenerId The id returned when subscribing + * @return {@code true} if a subscription was cancelled + */ + boolean unsubscribeInitialSync(final long listenerId); + @FunctionalInterface interface InSyncListener { void onInSyncStatusChange(boolean newSyncStatus); diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java index 62d670c07a..7be6ad12c4 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java @@ -194,6 +194,7 @@ public class BlockchainSetupUtil { genesisState.writeStateTo(worldArchive.getMutable()); final ProtocolContext protocolContext = protocolContextProvider.get(blockchain, worldArchive); + protocolContext.setSynchronizer(new DummySynchronizer()); final Path blocksPath = Path.of(chainResources.getBlocksURL().toURI()); final List blocks = new ArrayList<>(); diff --git a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/DummySynchronizer.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/DummySynchronizer.java similarity index 89% rename from ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/DummySynchronizer.java rename to ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/DummySynchronizer.java index b8d90e9974..0de02d6d52 100644 --- a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/DummySynchronizer.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/DummySynchronizer.java @@ -12,10 +12,9 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.retesteth; +package org.hyperledger.besu.ethereum.core; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.plugin.data.SyncStatus; import org.hyperledger.besu.plugin.services.BesuEvents; @@ -81,4 +80,14 @@ public class DummySynchronizer implements Synchronizer { public boolean unsubscribeInSync(final long listenerId) { return false; } + + @Override + public long subscribeInitialSync(final BesuEvents.InitialSyncCompletionListener listener) { + return 0; + } + + @Override + public boolean unsubscribeInitialSync(final long listenerId) { + return false; + } } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/MainnetBlockValidatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/MainnetBlockValidatorTest.java index 40573ee8d6..a63b736b0e 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/MainnetBlockValidatorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/MainnetBlockValidatorTest.java @@ -31,6 +31,7 @@ import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; import org.hyperledger.besu.ethereum.core.MutableWorldState; +import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.mainnet.BlockBodyValidator; import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator; import org.hyperledger.besu.ethereum.mainnet.BlockProcessor; @@ -90,6 +91,7 @@ public class MainnetBlockValidatorTest { when(protocolContext.getBlockchain()).thenReturn(blockchain); when(protocolContext.getWorldStateArchive()).thenReturn(worldStateArchive); + when(protocolContext.getSynchronizer()).thenReturn(mock(Synchronizer.class)); when(worldStateArchive.getMutable(any(BlockHeader.class), anyBoolean())) .thenReturn(Optional.of(worldState)); when(worldStateArchive.getMutable(any(Hash.class), any(Hash.class))) diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/snap/SnapServer.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/snap/SnapServer.java index 7de933e137..56c3ae0a4a 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/snap/SnapServer.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/snap/SnapServer.java @@ -26,7 +26,6 @@ import org.hyperledger.besu.ethereum.eth.messages.snap.GetTrieNodesMessage; import org.hyperledger.besu.ethereum.eth.messages.snap.SnapV1; import org.hyperledger.besu.ethereum.eth.messages.snap.StorageRangeMessage; import org.hyperledger.besu.ethereum.eth.messages.snap.TrieNodesMessage; -import org.hyperledger.besu.ethereum.eth.sync.DefaultSynchronizer; import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapSyncConfiguration; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData; import org.hyperledger.besu.ethereum.proof.WorldStateProofProvider; @@ -49,7 +48,6 @@ import java.util.NavigableMap; import java.util.Optional; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicLong; import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -84,7 +82,6 @@ class SnapServer implements BesuEvents.InitialSyncCompletionListener { static final Hash HASH_LAST = Hash.wrap(Bytes32.leftPad(Bytes.fromHexString("FF"), (byte) 0xFF)); private final AtomicBoolean isStarted = new AtomicBoolean(false); - private final AtomicLong listenerId = new AtomicLong(); private final EthMessages snapMessages; private final WorldStateStorageCoordinator worldStateStorageCoordinator; @@ -111,14 +108,9 @@ class SnapServer implements BesuEvents.InitialSyncCompletionListener { this.protocolContext = Optional.of(protocolContext); registerResponseConstructors(); - // subscribe to initial sync completed events to start/stop snap server: - this.protocolContext - .flatMap(ProtocolContext::getSynchronizer) - .filter(z -> z instanceof DefaultSynchronizer) - .map(DefaultSynchronizer.class::cast) - .ifPresentOrElse( - z -> this.listenerId.set(z.subscribeInitialSync(this)), - () -> LOGGER.warn("SnapServer created without reference to sync status")); + // subscribe to initial sync completed events to start/stop snap server, + // not saving the listenerId since we never need to unsubscribe. + protocolContext.getSynchronizer().subscribeInitialSync(this); } /** diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/DefaultSynchronizer.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/DefaultSynchronizer.java index b7dc2adb16..2384437299 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/DefaultSynchronizer.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/DefaultSynchronizer.java @@ -388,10 +388,12 @@ public class DefaultSynchronizer implements Synchronizer, UnverifiedForkchoiceLi return syncState.unsubscribeSyncStatus(listenerId); } + @Override public long subscribeInitialSync(final BesuEvents.InitialSyncCompletionListener listener) { return syncState.subscribeCompletionReached(listener); } + @Override public boolean unsubscribeInitialSync(final long listenerId) { return syncState.unsubscribeInitialConditionReached(listenerId); } diff --git a/ethereum/retesteth/build.gradle b/ethereum/retesteth/build.gradle index 2fe2def439..484953a391 100644 --- a/ethereum/retesteth/build.gradle +++ b/ethereum/retesteth/build.gradle @@ -35,6 +35,7 @@ dependencies { implementation project(':ethereum:api') implementation project(':ethereum:blockcreation') implementation project(':ethereum:core') + implementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts') implementation project(':ethereum:eth') implementation project(':ethereum:p2p') implementation project(':ethereum:rlp') diff --git a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethService.java b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethService.java index ceca8ebc11..877c597686 100644 --- a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethService.java +++ b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethService.java @@ -30,6 +30,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.EthSendRawTran import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.Web3ClientVersion; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlockResultFactory; +import org.hyperledger.besu.ethereum.core.DummySynchronizer; import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.retesteth.methods.TestGetLogHash; import org.hyperledger.besu.ethereum.retesteth.methods.TestImportRawBlock; From f16d3526db2e5b22e64d0e975b4b98bfec4b09db Mon Sep 17 00:00:00 2001 From: Jason Frame Date: Thu, 24 Oct 2024 19:02:43 +1000 Subject: [PATCH 14/14] Change execution requests to use flat encoding (#7771) Signed-off-by: Jason Frame --- .../ethereum/PragueAcceptanceTestHelper.java | 21 +- .../src/test/resources/dev/dev_prague.json | 12 +- .../jsonrpc/engine/prague/genesis.json | 23 +- .../test-cases/00_get_genesis_block_info.json | 4 +- .../test-cases/01_cancun_prepare_payload.json | 8 +- .../test-cases/02_cancun_getPayloadV3.json | 8 +- .../test-cases/03_cancun_newPayloadV3.json | 14 +- .../04_cancun_forkchoiceUpdatedV3.json | 8 +- .../05_prague_forkchoiceUpdatedV3.json | 10 +- .../test-cases/06_prague_getPayloadV4.json | 26 +- ...send_raw_transaction_deposit_request.json} | 0 ...null_deposit_request_execute_payload.json} | 16 +- .../test-cases/09_prague_newPayloadV4.json | 34 +-- .../10_prague_forkchoiceUpdatedV3.json | 10 +- .../test-cases/11_prague_getPayloadV4.json | 20 +- .../test-cases/12_cancun_newPayloadV3.json | 21 +- .../15_prague_forkchoiceUpdatedV3.json | 10 +- .../test-cases/16_prague_getPayloadV4.json | 40 ++- .../services/RlpConverterServiceImplTest.java | 2 +- .../besu/consensus/merge/PayloadWrapper.java | 19 +- .../merge/blockcreation/MergeCoordinator.java | 8 +- .../qbft/messagewrappers/ProposalTest.java | 3 +- .../org/hyperledger/besu/datatypes/Hash.java | 12 + .../hyperledger/besu/datatypes/HashTest.java | 8 + .../api/jsonrpc/JsonRpcResponseKey.java | 2 +- .../api/jsonrpc/JsonRpcResponseUtils.java | 8 +- .../execution/TracedJsonRpcProcessor.java | 1 + .../engine/AbstractEngineNewPayload.java | 97 ++++---- .../methods/engine/EngineNewPayloadV2.java | 3 +- .../methods/engine/EngineNewPayloadV3.java | 3 +- .../methods/engine/EngineNewPayloadV4.java | 8 +- .../engine/RequestValidatorProvider.java | 49 +--- .../ConsolidationRequestParameter.java | 102 -------- .../parameters/DepositRequestParameter.java | 144 ----------- .../parameters/EnginePayloadParameter.java | 28 +-- .../WithdrawalRequestParameter.java | 103 -------- .../internal/response/RpcErrorType.java | 1 + .../internal/results/BlockResultFactory.java | 19 +- .../results/EngineGetPayloadResultV4.java | 81 ++---- .../engine/AbstractEngineGetPayloadTest.java | 15 +- .../engine/AbstractEngineNewPayloadTest.java | 99 ++------ .../EngineGetPayloadBodiesByHashV1Test.java | 7 +- .../EngineGetPayloadBodiesByRangeV1Test.java | 19 +- .../engine/EngineGetPayloadV2Test.java | 3 +- .../engine/EngineGetPayloadV3Test.java | 4 +- .../engine/EngineGetPayloadV4Test.java | 29 ++- .../engine/EngineNewPayloadV2Test.java | 43 +--- .../engine/EngineNewPayloadV3Test.java | 25 +- .../engine/EngineNewPayloadV4Test.java | 225 +++++------------ .../DepositParameterTestFixture.java | 42 ---- .../DepositRequestRequestParameterTest.java | 61 ----- .../WithdrawalRequestParameterTest.java | 52 ---- .../WithdrawalRequestTestFixture.java | 31 --- .../blockcreation/AbstractBlockCreator.java | 7 +- .../AbstractBlockCreatorTest.java | 115 +-------- .../besu/ethereum/BlockProcessingResult.java | 10 + .../besu/ethereum/BlockValidator.java | 4 - .../besu/ethereum/MainnetBlockValidator.java | 5 +- .../besu/ethereum/chain/GenesisState.java | 7 +- .../hyperledger/besu/ethereum/core/Block.java | 5 +- .../besu/ethereum/core/BlockBody.java | 34 +-- .../besu/ethereum/core/BlockHeader.java | 22 +- .../ethereum/core/BlockHeaderBuilder.java | 16 +- .../ethereum/core/ConsolidationRequest.java | 90 ------- .../besu/ethereum/core/DepositRequest.java | 112 --------- .../besu/ethereum/core/Request.java | 23 +- .../ethereum/core/SealableBlockHeader.java | 14 +- .../besu/ethereum/core/WithdrawalRequest.java | 89 ------- .../encoding/ConsolidationRequestDecoder.java | 40 --- .../encoding/ConsolidationRequestEncoder.java | 60 ----- .../core/encoding/DepositLogDecoder.java | 40 +++ .../core/encoding/DepositRequestDecoder.java | 70 ------ .../core/encoding/DepositRequestEncoder.java | 42 ---- .../core/encoding/RequestDecoder.java | 106 -------- .../core/encoding/RequestEncoder.java | 83 ------- .../encoding/WithdrawalRequestDecoder.java | 41 --- .../encoding/WithdrawalRequestEncoder.java | 59 ----- .../mainnet/AbstractBlockProcessor.java | 2 +- .../mainnet/BaseFeeBlockBodyValidator.java | 4 +- .../ethereum/mainnet/BlockBodyValidator.java | 4 - .../besu/ethereum/mainnet/BodyValidation.java | 23 +- .../mainnet/MainnetBlockBodyValidator.java | 19 +- .../mainnet/MainnetBlockImporter.java | 8 +- .../mainnet/MainnetProtocolSpecs.java | 6 +- .../besu/ethereum/mainnet/ProtocolSpec.java | 14 +- .../ethereum/mainnet/ProtocolSpecBuilder.java | 12 +- .../ethereum/mainnet/SystemCallProcessor.java | 5 +- .../AbstractSystemCallRequestProcessor.java | 102 -------- .../ConsolidationRequestProcessor.java | 73 ------ .../ConsolidationRequestValidator.java | 92 ------- .../requests/DepositRequestProcessor.java | 37 ++- .../requests/DepositRequestValidator.java | 86 ------- .../requests/MainnetRequestsProcessor.java | 39 +++ .../requests/MainnetRequestsValidator.java | 67 +++-- .../requests/ProhibitedRequestValidator.java | 38 +++ .../requests/ProhibitedRequestsValidator.java | 53 ---- .../requests/RequestContractAddresses.java | 13 +- .../mainnet/requests/RequestProcessor.java | 5 +- .../requests/RequestProcessorCoordinator.java | 25 +- .../mainnet/requests/RequestUtil.java | 85 ------- ...tValidator.java => RequestsValidator.java} | 12 +- .../RequestsValidatorCoordinator.java | 202 --------------- .../requests/SystemCallRequestProcessor.java | 57 +++++ .../requests/WithdrawalRequestProcessor.java | 79 ------ .../requests/WithdrawalRequestValidator.java | 93 ------- .../ethereum/core/BlockDataGenerator.java | 17 +- .../ethereum/core/BlockHeaderTestFixture.java | 8 +- .../ethereum/core/NonBesuBlockHeader.java | 2 +- .../BlockImportExceptionHandlingTest.java | 6 - .../ethereum/MainnetBlockValidatorTest.java | 13 +- .../besu/ethereum/chain/GenesisStateTest.java | 10 +- .../ConsolidationRequestDecoderTest.java | 46 ---- .../ConsolidationRequestEncoderTest.java | 55 ---- ...erTest.java => DepositLogDecoderTest.java} | 45 +--- .../encoding/DepositRequestEncoderTest.java | 61 ----- .../WithdrawalRequestDecoderTest.java | 46 ---- .../WithdrawalRequestEncoderTest.java | 55 ---- .../mainnet/AbstractBlockProcessorTest.java | 4 - .../ethereum/mainnet/BodyValidationTest.java | 28 +++ ...olidationRequestValidatorTestFixtures.java | 136 ---------- .../mainnet/DepositRequestValidatorTest.java | 234 ------------------ .../MainnetBlockBodyValidatorTest.java | 49 +--- .../mainnet/MainnetBlockProcessorTest.java | 3 - ...agueConsolidationRequestValidatorTest.java | 76 ------ .../mainnet/PragueRequestsValidatorTest.java | 120 --------- .../PragueWithdrawalRequestValidatorTest.java | 83 ------- .../mainnet/SystemCallProcessorTest.java | 4 +- .../ethereum/mainnet/ValidationTestUtils.java | 7 +- .../WithdrawalRequestValidatorTest.java | 87 ------- ...ithdrawalRequestValidatorTestFixtures.java | 186 -------------- .../MainnetRequestsValidatorTest.java | 58 +++++ .../ProhibitedRequestValidatorTest.java | 47 ++++ .../manager/task/GetBodiesFromPeerTask.java | 25 +- .../eth/sync/tasks/CompleteBlocksTask.java | 3 +- .../task/GetBodiesFromPeerTaskTest.java | 55 +--- .../eth/messages/MessageWrapperTest.java | 6 +- .../backwardsync/ChainForTestCreator.java | 2 +- .../sync/tasks/CompleteBlocksTaskTest.java | 17 +- .../hyperledger/besu/evmtool/T8nExecutor.java | 47 +--- .../evmtool/block-test/osaka-eof-rjump.json | 4 +- .../besu/evmtool/t8n/prague-deposit.json | 115 ++++----- .../besu/evmtool/t8n/prague-withdrawal.json | 213 +++++----------- .../BlockchainReferenceTestCaseSpec.java | 10 +- .../referencetests/ReferenceTestEnv.java | 2 +- .../NoRewardProtocolScheduleWrapper.java | 2 +- plugin-api/build.gradle | 2 +- .../besu/plugin/data/BlockBody.java | 9 - .../besu/plugin/data/BlockHeader.java | 2 +- .../plugin/data/ConsolidationRequest.java | 45 ---- .../besu/plugin/data/DepositRequest.java | 68 ----- .../hyperledger/besu/plugin/data/Request.java | 9 + .../besu/plugin/data/WithdrawalRequest.java | 49 ---- 152 files changed, 1094 insertions(+), 5067 deletions(-) rename acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/{07_prague_send_raw_transaction.json => 07_prague_send_raw_transaction_deposit_request.json} (100%) rename acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/{08_prague_invalid_null_deposits_execute_payload.json => 08_prague_invalid_null_deposit_request_execute_payload.json} (88%) delete mode 100644 ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/ConsolidationRequestParameter.java delete mode 100644 ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositRequestParameter.java delete mode 100644 ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/WithdrawalRequestParameter.java delete mode 100644 ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositParameterTestFixture.java delete mode 100644 ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositRequestRequestParameterTest.java delete mode 100644 ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/WithdrawalRequestParameterTest.java delete mode 100644 ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/WithdrawalRequestTestFixture.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/ConsolidationRequest.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/DepositRequest.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/WithdrawalRequest.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestDecoder.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestEncoder.java create mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositLogDecoder.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestDecoder.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestEncoder.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/RequestDecoder.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/RequestEncoder.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestDecoder.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestEncoder.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/AbstractSystemCallRequestProcessor.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ConsolidationRequestProcessor.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ConsolidationRequestValidator.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositRequestValidator.java create mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsProcessor.java create mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ProhibitedRequestValidator.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ProhibitedRequestsValidator.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestUtil.java rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/{RequestValidator.java => RequestsValidator.java} (63%) delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestsValidatorCoordinator.java create mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/SystemCallRequestProcessor.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/WithdrawalRequestProcessor.java delete mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/WithdrawalRequestValidator.java delete mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestDecoderTest.java delete mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestEncoderTest.java rename ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/{DepositRequestDecoderTest.java => DepositLogDecoderTest.java} (51%) delete mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestEncoderTest.java delete mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestDecoderTest.java delete mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestEncoderTest.java delete mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ConsolidationRequestValidatorTestFixtures.java delete mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DepositRequestValidatorTest.java delete mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PragueConsolidationRequestValidatorTest.java delete mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PragueRequestsValidatorTest.java delete mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PragueWithdrawalRequestValidatorTest.java delete mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/WithdrawalRequestValidatorTest.java delete mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/WithdrawalRequestValidatorTestFixtures.java create mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsValidatorTest.java create mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/requests/ProhibitedRequestValidatorTest.java delete mode 100644 plugin-api/src/main/java/org/hyperledger/besu/plugin/data/ConsolidationRequest.java delete mode 100644 plugin-api/src/main/java/org/hyperledger/besu/plugin/data/DepositRequest.java delete mode 100644 plugin-api/src/main/java/org/hyperledger/besu/plugin/data/WithdrawalRequest.java diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/ethereum/PragueAcceptanceTestHelper.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/ethereum/PragueAcceptanceTestHelper.java index fa190f3de1..754e28165c 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/ethereum/PragueAcceptanceTestHelper.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/ethereum/PragueAcceptanceTestHelper.java @@ -22,7 +22,9 @@ import org.hyperledger.besu.tests.acceptance.dsl.transaction.eth.EthTransactions import java.io.IOException; import java.util.Optional; +import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import okhttp3.Call; import okhttp3.MediaType; @@ -74,17 +76,15 @@ public class PragueAcceptanceTestHelper { final Call getPayloadRequest = createEngineCall(createGetPayloadRequest(payloadId)); final ObjectNode executionPayload; + final ArrayNode executionRequests; final String newBlockHash; final String parentBeaconBlockRoot; try (final Response getPayloadResponse = getPayloadRequest.execute()) { assertThat(getPayloadResponse.code()).isEqualTo(200); - executionPayload = - (ObjectNode) - mapper - .readTree(getPayloadResponse.body().string()) - .get("result") - .get("executionPayload"); + JsonNode result = mapper.readTree(getPayloadResponse.body().string()).get("result"); + executionPayload = (ObjectNode) result.get("executionPayload"); + executionRequests = (ArrayNode) result.get("executionRequests"); newBlockHash = executionPayload.get("blockHash").asText(); parentBeaconBlockRoot = executionPayload.remove("parentBeaconBlockRoot").asText(); @@ -94,7 +94,8 @@ public class PragueAcceptanceTestHelper { final Call newPayloadRequest = createEngineCall( - createNewPayloadRequest(executionPayload.toString(), parentBeaconBlockRoot)); + createNewPayloadRequest( + executionPayload.toString(), parentBeaconBlockRoot, executionRequests.toString())); try (final Response newPayloadResponse = newPayloadRequest.execute()) { assertThat(newPayloadResponse.code()).isEqualTo(200); } @@ -168,7 +169,9 @@ public class PragueAcceptanceTestHelper { } private String createNewPayloadRequest( - final String executionPayload, final String parentBeaconBlockRoot) { + final String executionPayload, + final String parentBeaconBlockRoot, + final String executionRequests) { return "{" + " \"jsonrpc\": \"2.0\"," + " \"method\": \"engine_newPayloadV4\"," @@ -178,6 +181,8 @@ public class PragueAcceptanceTestHelper { + "\"" + parentBeaconBlockRoot + "\"" + + "," + + executionRequests + "]," + " \"id\": 67" + "}"; diff --git a/acceptance-tests/tests/src/test/resources/dev/dev_prague.json b/acceptance-tests/tests/src/test/resources/dev/dev_prague.json index 26e59992d1..942edc4e70 100644 --- a/acceptance-tests/tests/src/test/resources/dev/dev_prague.json +++ b/acceptance-tests/tests/src/test/resources/dev/dev_prague.json @@ -19,7 +19,9 @@ "period": 5, "epoch": 30000 }, - "depositContractAddress": "0x4242424242424242424242424242424242424242" + "depositContractAddress": "0x4242424242424242424242424242424242424242", + "withdrawalRequestContractAddress": "0x00A3ca265EBcb825B45F985A16CEFB49958cE017", + "consolidationRequestContractAddress": "0x00b42dbF2194e931E80326D950320f7d9Dbeac02" }, "nonce":"0x42", "timestamp":"0x0", @@ -53,9 +55,9 @@ "balance": "1000000000000000000000000000" }, "0x00A3ca265EBcb825B45F985A16CEFB49958cE017": { - "comment": "This is the runtime bytecode for the Withdrawal Request Smart Contract. It was created from the deployment transaction in EIP-7002 (https://eips.ethereum.org/EIPS/eip-7002#deployment)", + "comment": "This is the runtime bytecode for the Withdrawal Request Smart Contract. It was created from the generated alloc section of fork_Prague_blockchain_test_engine_single_block_single_withdrawal_request_from_contract spec test", "balance": "0", - "code": "0x3373fffffffffffffffffffffffffffffffffffffffe146090573615156028575f545f5260205ff35b36603814156101215760115f54600182026001905f5b5f82111560595781019083028483029004916001019190603e565b90939004341061012157600154600101600155600354806003026004013381556001015f3581556001016020359055600101600355005b6003546002548082038060101160a4575060105b5f5b81811460dd5780604c02838201600302600401805490600101805490600101549160601b83528260140152906034015260010160a6565b910180921460ed579060025560f8565b90505f6002555f6003555b5f5460015460028282011161010f5750505f610115565b01600290035b5f555f600155604c025ff35b5f5ffd", + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe1460c7573615156028575f545f5260205ff35b36603814156101f05760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff146101f057600182026001905f5b5f821115608057810190830284830290049160010191906065565b9093900434106101f057600154600101600155600354806003026004013381556001015f35815560010160203590553360601b5f5260385f601437604c5fa0600101600355005b6003546002548082038060101160db575060105b5f5b81811461017f5780604c02838201600302600401805490600101805490600101549160601b83528260140152807fffffffffffffffffffffffffffffffff0000000000000000000000000000000016826034015260401c906044018160381c81600701538160301c81600601538160281c81600501538160201c81600401538160181c81600301538160101c81600201538160081c81600101535360010160dd565b9101809214610191579060025561019c565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14156101c957505f5b6001546002828201116101de5750505f6101e4565b01600290035b5f555f600155604c025ff35b5f5ffd", "storage": { "0x0000000000000000000000000000000000000000000000000000000000000000": "0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000001": "0000000000000000000000000000000000000000000000000000000000000001", @@ -67,9 +69,9 @@ } }, "0x4242424242424242424242424242424242424242": { - "comment": "The deposit contract", + "comment": "This is the runtime bytecode for the Deposit Request Smart Contract. It was created from the generated alloc section of fork_Prague_blockchain_test_engine_single_deposit_from_contract spec test", "balance": "0", - "code": "0x60806040526004361061003f5760003560e01c806301ffc9a71461004457806322895118146100a4578063621fd130146101ba578063c5f2892f14610244575b600080fd5b34801561005057600080fd5b506100906004803603602081101561006757600080fd5b50357fffffffff000000000000000000000000000000000000000000000000000000001661026b565b604080519115158252519081900360200190f35b6101b8600480360360808110156100ba57600080fd5b8101906020810181356401000000008111156100d557600080fd5b8201836020820111156100e757600080fd5b8035906020019184600183028401116401000000008311171561010957600080fd5b91939092909160208101903564010000000081111561012757600080fd5b82018360208201111561013957600080fd5b8035906020019184600183028401116401000000008311171561015b57600080fd5b91939092909160208101903564010000000081111561017957600080fd5b82018360208201111561018b57600080fd5b803590602001918460018302840111640100000000831117156101ad57600080fd5b919350915035610304565b005b3480156101c657600080fd5b506101cf6110b5565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102095781810151838201526020016101f1565b50505050905090810190601f1680156102365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561025057600080fd5b506102596110c7565b60408051918252519081900360200190f35b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102fe57507fffffffff0000000000000000000000000000000000000000000000000000000082167f8564090700000000000000000000000000000000000000000000000000000000145b92915050565b6030861461035d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118056026913960400191505060405180910390fd5b602084146103b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603681526020018061179c6036913960400191505060405180910390fd5b6060821461040f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806118786029913960400191505060405180910390fd5b670de0b6b3a7640000341015610470576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118526026913960400191505060405180910390fd5b633b9aca003406156104cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806117d26033913960400191505060405180910390fd5b633b9aca00340467ffffffffffffffff811115610535576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602781526020018061182b6027913960400191505060405180910390fd5b6060610540826114ba565b90507f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c589898989858a8a6105756020546114ba565b6040805160a0808252810189905290819060208201908201606083016080840160c085018e8e80828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910187810386528c815260200190508c8c808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690920188810386528c5181528c51602091820193918e019250908190849084905b83811015610648578181015183820152602001610630565b50505050905090810190601f1680156106755780820380516001836020036101000a031916815260200191505b5086810383528881526020018989808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018881038452895181528951602091820193918b019250908190849084905b838110156106ef5781810151838201526020016106d7565b50505050905090810190601f16801561071c5780820380516001836020036101000a031916815260200191505b509d505050505050505050505050505060405180910390a1600060028a8a600060801b604051602001808484808284377fffffffffffffffffffffffffffffffff0000000000000000000000000000000090941691909301908152604080517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0818403018152601090920190819052815191955093508392506020850191508083835b602083106107fc57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016107bf565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610859573d6000803e3d6000fd5b5050506040513d602081101561086e57600080fd5b5051905060006002806108846040848a8c6116fe565b6040516020018083838082843780830192505050925050506040516020818303038152906040526040518082805190602001908083835b602083106108f857805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016108bb565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610955573d6000803e3d6000fd5b5050506040513d602081101561096a57600080fd5b5051600261097b896040818d6116fe565b60405160009060200180848480828437919091019283525050604080518083038152602092830191829052805190945090925082918401908083835b602083106109f457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016109b7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610a51573d6000803e3d6000fd5b5050506040513d6020811015610a6657600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610ada57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610a9d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610b37573d6000803e3d6000fd5b5050506040513d6020811015610b4c57600080fd5b50516040805160208101858152929350600092600292839287928f928f92018383808284378083019250505093505050506040516020818303038152906040526040518082805190602001908083835b60208310610bd957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610b9c565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610c36573d6000803e3d6000fd5b5050506040513d6020811015610c4b57600080fd5b50516040518651600291889160009188916020918201918291908601908083835b60208310610ca957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610c6c565b6001836020036101000a0380198251168184511680821785525050505050509050018367ffffffffffffffff191667ffffffffffffffff1916815260180182815260200193505050506040516020818303038152906040526040518082805190602001908083835b60208310610d4e57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610d11565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610dab573d6000803e3d6000fd5b5050506040513d6020811015610dc057600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610e3457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610df7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610e91573d6000803e3d6000fd5b5050506040513d6020811015610ea657600080fd5b50519050858114610f02576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260548152602001806117486054913960600191505060405180910390fd5b60205463ffffffff11610f60576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806117276021913960400191505060405180910390fd5b602080546001019081905560005b60208110156110a9578160011660011415610fa0578260008260208110610f9157fe5b0155506110ac95505050505050565b600260008260208110610faf57fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061102557805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610fe8565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015611082573d6000803e3d6000fd5b5050506040513d602081101561109757600080fd5b50519250600282049150600101610f6e565b50fe5b50505050505050565b60606110c26020546114ba565b905090565b6020546000908190815b60208110156112f05781600116600114156111e6576002600082602081106110f557fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061116b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161112e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156111c8573d6000803e3d6000fd5b5050506040513d60208110156111dd57600080fd5b505192506112e2565b600283602183602081106111f657fe5b015460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061126b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161122e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156112c8573d6000803e3d6000fd5b5050506040513d60208110156112dd57600080fd5b505192505b6002820491506001016110d1565b506002826112ff6020546114ba565b600060401b6040516020018084815260200183805190602001908083835b6020831061135a57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161131d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790527fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000095909516920191825250604080518083037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8018152601890920190819052815191955093508392850191508083835b6020831061143f57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611402565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa15801561149c573d6000803e3d6000fd5b5050506040513d60208110156114b157600080fd5b50519250505090565b60408051600880825281830190925260609160208201818036833701905050905060c082901b8060071a60f81b826000815181106114f457fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060061a60f81b8260018151811061153757fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060051a60f81b8260028151811061157a57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060041a60f81b826003815181106115bd57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060031a60f81b8260048151811061160057fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060021a60f81b8260058151811061164357fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060011a60f81b8260068151811061168657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060001a60f81b826007815181106116c957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535050919050565b6000808585111561170d578182fd5b83861115611719578182fd5b505082019391909203915056fe4465706f736974436f6e74726163743a206d65726b6c6520747265652066756c6c4465706f736974436f6e74726163743a207265636f6e7374727563746564204465706f7369744461746120646f6573206e6f74206d6174636820737570706c696564206465706f7369745f646174615f726f6f744465706f736974436f6e74726163743a20696e76616c6964207769746864726177616c5f63726564656e7469616c73206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c7565206e6f74206d756c7469706c65206f6620677765694465706f736974436f6e74726163743a20696e76616c6964207075626b6579206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f20686967684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f206c6f774465706f736974436f6e74726163743a20696e76616c6964207369676e6174757265206c656e677468a26469706673582212201dd26f37a621703009abf16e77e69c93dc50c79db7f6cc37543e3e0e3decdc9764736f6c634300060b0033", + "code": "0x60806040526004361061003f5760003560e01c806301ffc9a71461004457806322895118146100a4578063621fd130146101ba578063c5f2892f14610244575b600080fd5b34801561005057600080fd5b506100906004803603602081101561006757600080fd5b50357fffffffff000000000000000000000000000000000000000000000000000000001661026b565b604080519115158252519081900360200190f35b6101b8600480360360808110156100ba57600080fd5b8101906020810181356401000000008111156100d557600080fd5b8201836020820111156100e757600080fd5b8035906020019184600183028401116401000000008311171561010957600080fd5b91939092909160208101903564010000000081111561012757600080fd5b82018360208201111561013957600080fd5b8035906020019184600183028401116401000000008311171561015b57600080fd5b91939092909160208101903564010000000081111561017957600080fd5b82018360208201111561018b57600080fd5b803590602001918460018302840111640100000000831117156101ad57600080fd5b919350915035610304565b005b3480156101c657600080fd5b506101cf6110b5565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102095781810151838201526020016101f1565b50505050905090810190601f1680156102365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561025057600080fd5b506102596110c7565b60408051918252519081900360200190f35b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102fe57507fffffffff0000000000000000000000000000000000000000000000000000000082167f8564090700000000000000000000000000000000000000000000000000000000145b92915050565b6030861461035d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118056026913960400191505060405180910390fd5b602084146103b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603681526020018061179c6036913960400191505060405180910390fd5b6060821461040f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806118786029913960400191505060405180910390fd5b670de0b6b3a7640000341015610470576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118526026913960400191505060405180910390fd5b633b9aca003406156104cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806117d26033913960400191505060405180910390fd5b633b9aca00340467ffffffffffffffff811115610535576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602781526020018061182b6027913960400191505060405180910390fd5b6060610540826114ba565b90507f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c589898989858a8a6105756020546114ba565b6040805160a0808252810189905290819060208201908201606083016080840160c085018e8e80828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910187810386528c815260200190508c8c808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690920188810386528c5181528c51602091820193918e019250908190849084905b83811015610648578181015183820152602001610630565b50505050905090810190601f1680156106755780820380516001836020036101000a031916815260200191505b5086810383528881526020018989808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018881038452895181528951602091820193918b019250908190849084905b838110156106ef5781810151838201526020016106d7565b50505050905090810190601f16801561071c5780820380516001836020036101000a031916815260200191505b509d505050505050505050505050505060405180910390a1600060028a8a600060801b604051602001808484808284377fffffffffffffffffffffffffffffffff0000000000000000000000000000000090941691909301908152604080517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0818403018152601090920190819052815191955093508392506020850191508083835b602083106107fc57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016107bf565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610859573d6000803e3d6000fd5b5050506040513d602081101561086e57600080fd5b5051905060006002806108846040848a8c6116fe565b6040516020018083838082843780830192505050925050506040516020818303038152906040526040518082805190602001908083835b602083106108f857805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016108bb565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610955573d6000803e3d6000fd5b5050506040513d602081101561096a57600080fd5b5051600261097b896040818d6116fe565b60405160009060200180848480828437919091019283525050604080518083038152602092830191829052805190945090925082918401908083835b602083106109f457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016109b7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610a51573d6000803e3d6000fd5b5050506040513d6020811015610a6657600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610ada57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610a9d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610b37573d6000803e3d6000fd5b5050506040513d6020811015610b4c57600080fd5b50516040805160208101858152929350600092600292839287928f928f92018383808284378083019250505093505050506040516020818303038152906040526040518082805190602001908083835b60208310610bd957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610b9c565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610c36573d6000803e3d6000fd5b5050506040513d6020811015610c4b57600080fd5b50516040518651600291889160009188916020918201918291908601908083835b60208310610ca957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610c6c565b6001836020036101000a0380198251168184511680821785525050505050509050018367ffffffffffffffff191667ffffffffffffffff1916815260180182815260200193505050506040516020818303038152906040526040518082805190602001908083835b60208310610d4e57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610d11565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610dab573d6000803e3d6000fd5b5050506040513d6020811015610dc057600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610e3457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610df7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610e91573d6000803e3d6000fd5b5050506040513d6020811015610ea657600080fd5b50519050858114610f02576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260548152602001806117486054913960600191505060405180910390fd5b60205463ffffffff11610f60576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806117276021913960400191505060405180910390fd5b602080546001019081905560005b60208110156110a9578160011660011415610fa0578260008260208110610f9157fe5b0155506110ac95505050505050565b600260008260208110610faf57fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061102557805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610fe8565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015611082573d6000803e3d6000fd5b5050506040513d602081101561109757600080fd5b50519250600282049150600101610f6e565b50fe5b50505050505050565b60606110c26020546114ba565b905090565b6020546000908190815b60208110156112f05781600116600114156111e6576002600082602081106110f557fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061116b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161112e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156111c8573d6000803e3d6000fd5b5050506040513d60208110156111dd57600080fd5b505192506112e2565b600283602183602081106111f657fe5b015460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061126b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161122e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156112c8573d6000803e3d6000fd5b5050506040513d60208110156112dd57600080fd5b505192505b6002820491506001016110d1565b506002826112ff6020546114ba565b600060401b6040516020018084815260200183805190602001908083835b6020831061135a57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161131d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790527fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000095909516920191825250604080518083037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8018152601890920190819052815191955093508392850191508083835b6020831061143f57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611402565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa15801561149c573d6000803e3d6000fd5b5050506040513d60208110156114b157600080fd5b50519250505090565b60408051600880825281830190925260609160208201818036833701905050905060c082901b8060071a60f81b826000815181106114f457fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060061a60f81b8260018151811061153757fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060051a60f81b8260028151811061157a57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060041a60f81b826003815181106115bd57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060031a60f81b8260048151811061160057fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060021a60f81b8260058151811061164357fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060011a60f81b8260068151811061168657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060001a60f81b826007815181106116c957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535050919050565b6000808585111561170d578182fd5b83861115611719578182fd5b505082019391909203915056fe4465706f736974436f6e74726163743a206d65726b6c6520747265652066756c6c4465706f736974436f6e74726163743a207265636f6e7374727563746564204465706f7369744461746120646f6573206e6f74206d6174636820737570706c696564206465706f7369745f646174615f726f6f744465706f736974436f6e74726163743a20696e76616c6964207769746864726177616c5f63726564656e7469616c73206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c7565206e6f74206d756c7469706c65206f6620677765694465706f736974436f6e74726163743a20696e76616c6964207075626b6579206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f20686967684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f206c6f774465706f736974436f6e74726163743a20696e76616c6964207369676e6174757265206c656e677468a2646970667358221220dceca8706b29e917dacf25fceef95acac8d90d765ac926663ce4096195952b6164736f6c634300060b0033", "storage": { "0x0000000000000000000000000000000000000000000000000000000000000022": "0xf5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b", "0x0000000000000000000000000000000000000000000000000000000000000023": "0xdb56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71", diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/genesis.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/genesis.json index ac474c0245..ef3d2c1be4 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/genesis.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/genesis.json @@ -19,7 +19,9 @@ "period": 5, "epoch": 30000 }, - "depositContractAddress": "0x4242424242424242424242424242424242424242" + "depositContractAddress": "0x4242424242424242424242424242424242424242", + "withdrawalRequestContractAddress": "0x00A3ca265EBcb825B45F985A16CEFB49958cE017", + "consolidationRequestContractAddress": "0x00b42dbF2194e931E80326D950320f7d9Dbeac02" }, "nonce":"0x42", "timestamp":"0x0", @@ -37,9 +39,10 @@ "balance": "1000000000000000000000000000" }, "0x00A3ca265EBcb825B45F985A16CEFB49958cE017": { - "comment": "This is the runtime bytecode for the Withdrawal Request Smart Contract. It was created from the deployment transaction in EIP-7002 (https://eips.ethereum.org/EIPS/eip-7002#deployment)", - "balance": "0", - "code": "0x3373fffffffffffffffffffffffffffffffffffffffe146090573615156028575f545f5260205ff35b36603814156101215760115f54600182026001905f5b5f82111560595781019083028483029004916001019190603e565b90939004341061012157600154600101600155600354806003026004013381556001015f3581556001016020359055600101600355005b6003546002548082038060101160a4575060105b5f5b81811460dd5780604c02838201600302600401805490600101805490600101549160601b83528260140152906034015260010160a6565b910180921460ed579060025560f8565b90505f6002555f6003555b5f5460015460028282011161010f5750505f610115565b01600290035b5f555f600155604c025ff35b5f5ffd", + "comment": "This is the runtime bytecode for the Withdrawal Request Smart Contract. It was created from the generated alloc section of fork_Prague_blockchain_test_engine_single_block_single_withdrawal_request_from_contract spec test", + "nonce": "0x01", + "balance": "0x00", + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe1460c7573615156028575f545f5260205ff35b36603814156101f05760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff146101f057600182026001905f5b5f821115608057810190830284830290049160010191906065565b9093900434106101f057600154600101600155600354806003026004013381556001015f35815560010160203590553360601b5f5260385f601437604c5fa0600101600355005b6003546002548082038060101160db575060105b5f5b81811461017f5780604c02838201600302600401805490600101805490600101549160601b83528260140152807fffffffffffffffffffffffffffffffff0000000000000000000000000000000016826034015260401c906044018160381c81600701538160301c81600601538160281c81600501538160201c81600401538160181c81600301538160101c81600201538160081c81600101535360010160dd565b9101809214610191579060025561019c565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14156101c957505f5b6001546002828201116101de5750505f6101e4565b01600290035b5f555f600155604c025ff35b5f5ffd", "storage": { "0x0000000000000000000000000000000000000000000000000000000000000000": "0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000001": "0000000000000000000000000000000000000000000000000000000000000001", @@ -51,9 +54,10 @@ } }, "0x00b42dbF2194e931E80326D950320f7d9Dbeac02": { - "comment": "This is the runtime bytecode for the Consolidation Request Smart Contract. It was created from the deployment transaction in EIP-7251 (https://eips.ethereum.org/EIPS/eip-7251#deployment)", - "balance": "0", - "code": "0x3373fffffffffffffffffffffffffffffffffffffffe146098573615156028575f545f5260205ff35b36606014156101445760115f54600182026001905f5b5f82111560595781019083028483029004916001019190603e565b90939004341061014457600154600101600155600354806004026004013381556001015f35815560010160203581556001016040359055600101600355005b6003546002548082038060011160ac575060015b5f5b81811460f15780607402838201600402600401805490600101805490600101805490600101549260601b84529083601401528260340152906054015260010160ae565b9101809214610103579060025561010e565b90505f6002555f6003555b5f548061049d141561011d57505f5b6001546001828201116101325750505f610138565b01600190035b5f555f6001556074025ff35b5f5ffd", + "comment": "This is the runtime bytecode for the Consolidation Request Smart Contract. It was created from the generated alloc section of fork_Prague_blockchain_test_engine_single_block_single_consolidation_request_from_contract spec test", + "nonce": "0x01", + "balance": "0x0", + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe1460cf573615156028575f545f5260205ff35b366060141561019a5760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1461019a57600182026001905f5b5f821115608057810190830284830290049160010191906065565b90939004341061019a57600154600101600155600354806004026004013381556001015f358155600101602035815560010160403590553360601b5f5260605f60143760745fa0600101600355005b6003546002548082038060011160e3575060015b5f5b8181146101295780607402838201600402600401805490600101805490600101805490600101549260601b84529083601401528260340152906054015260010160e5565b910180921461013b5790600255610146565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff141561017357505f5b6001546001828201116101885750505f61018e565b01600190035b5f555f6001556074025ff35b5f5ffd", "storage": { "0x0000000000000000000000000000000000000000000000000000000000000000": "0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000001": "0000000000000000000000000000000000000000000000000000000000000000", @@ -65,8 +69,9 @@ } }, "0x4242424242424242424242424242424242424242": { - "balance": "0", - "code": "0x60806040526004361061003f5760003560e01c806301ffc9a71461004457806322895118146100a4578063621fd130146101ba578063c5f2892f14610244575b600080fd5b34801561005057600080fd5b506100906004803603602081101561006757600080fd5b50357fffffffff000000000000000000000000000000000000000000000000000000001661026b565b604080519115158252519081900360200190f35b6101b8600480360360808110156100ba57600080fd5b8101906020810181356401000000008111156100d557600080fd5b8201836020820111156100e757600080fd5b8035906020019184600183028401116401000000008311171561010957600080fd5b91939092909160208101903564010000000081111561012757600080fd5b82018360208201111561013957600080fd5b8035906020019184600183028401116401000000008311171561015b57600080fd5b91939092909160208101903564010000000081111561017957600080fd5b82018360208201111561018b57600080fd5b803590602001918460018302840111640100000000831117156101ad57600080fd5b919350915035610304565b005b3480156101c657600080fd5b506101cf6110b5565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102095781810151838201526020016101f1565b50505050905090810190601f1680156102365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561025057600080fd5b506102596110c7565b60408051918252519081900360200190f35b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102fe57507fffffffff0000000000000000000000000000000000000000000000000000000082167f8564090700000000000000000000000000000000000000000000000000000000145b92915050565b6030861461035d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118056026913960400191505060405180910390fd5b602084146103b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603681526020018061179c6036913960400191505060405180910390fd5b6060821461040f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806118786029913960400191505060405180910390fd5b670de0b6b3a7640000341015610470576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118526026913960400191505060405180910390fd5b633b9aca003406156104cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806117d26033913960400191505060405180910390fd5b633b9aca00340467ffffffffffffffff811115610535576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602781526020018061182b6027913960400191505060405180910390fd5b6060610540826114ba565b90507f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c589898989858a8a6105756020546114ba565b6040805160a0808252810189905290819060208201908201606083016080840160c085018e8e80828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910187810386528c815260200190508c8c808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690920188810386528c5181528c51602091820193918e019250908190849084905b83811015610648578181015183820152602001610630565b50505050905090810190601f1680156106755780820380516001836020036101000a031916815260200191505b5086810383528881526020018989808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018881038452895181528951602091820193918b019250908190849084905b838110156106ef5781810151838201526020016106d7565b50505050905090810190601f16801561071c5780820380516001836020036101000a031916815260200191505b509d505050505050505050505050505060405180910390a1600060028a8a600060801b604051602001808484808284377fffffffffffffffffffffffffffffffff0000000000000000000000000000000090941691909301908152604080517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0818403018152601090920190819052815191955093508392506020850191508083835b602083106107fc57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016107bf565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610859573d6000803e3d6000fd5b5050506040513d602081101561086e57600080fd5b5051905060006002806108846040848a8c6116fe565b6040516020018083838082843780830192505050925050506040516020818303038152906040526040518082805190602001908083835b602083106108f857805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016108bb565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610955573d6000803e3d6000fd5b5050506040513d602081101561096a57600080fd5b5051600261097b896040818d6116fe565b60405160009060200180848480828437919091019283525050604080518083038152602092830191829052805190945090925082918401908083835b602083106109f457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016109b7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610a51573d6000803e3d6000fd5b5050506040513d6020811015610a6657600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610ada57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610a9d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610b37573d6000803e3d6000fd5b5050506040513d6020811015610b4c57600080fd5b50516040805160208101858152929350600092600292839287928f928f92018383808284378083019250505093505050506040516020818303038152906040526040518082805190602001908083835b60208310610bd957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610b9c565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610c36573d6000803e3d6000fd5b5050506040513d6020811015610c4b57600080fd5b50516040518651600291889160009188916020918201918291908601908083835b60208310610ca957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610c6c565b6001836020036101000a0380198251168184511680821785525050505050509050018367ffffffffffffffff191667ffffffffffffffff1916815260180182815260200193505050506040516020818303038152906040526040518082805190602001908083835b60208310610d4e57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610d11565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610dab573d6000803e3d6000fd5b5050506040513d6020811015610dc057600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610e3457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610df7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610e91573d6000803e3d6000fd5b5050506040513d6020811015610ea657600080fd5b50519050858114610f02576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260548152602001806117486054913960600191505060405180910390fd5b60205463ffffffff11610f60576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806117276021913960400191505060405180910390fd5b602080546001019081905560005b60208110156110a9578160011660011415610fa0578260008260208110610f9157fe5b0155506110ac95505050505050565b600260008260208110610faf57fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061102557805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610fe8565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015611082573d6000803e3d6000fd5b5050506040513d602081101561109757600080fd5b50519250600282049150600101610f6e565b50fe5b50505050505050565b60606110c26020546114ba565b905090565b6020546000908190815b60208110156112f05781600116600114156111e6576002600082602081106110f557fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061116b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161112e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156111c8573d6000803e3d6000fd5b5050506040513d60208110156111dd57600080fd5b505192506112e2565b600283602183602081106111f657fe5b015460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061126b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161122e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156112c8573d6000803e3d6000fd5b5050506040513d60208110156112dd57600080fd5b505192505b6002820491506001016110d1565b506002826112ff6020546114ba565b600060401b6040516020018084815260200183805190602001908083835b6020831061135a57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161131d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790527fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000095909516920191825250604080518083037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8018152601890920190819052815191955093508392850191508083835b6020831061143f57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611402565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa15801561149c573d6000803e3d6000fd5b5050506040513d60208110156114b157600080fd5b50519250505090565b60408051600880825281830190925260609160208201818036833701905050905060c082901b8060071a60f81b826000815181106114f457fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060061a60f81b8260018151811061153757fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060051a60f81b8260028151811061157a57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060041a60f81b826003815181106115bd57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060031a60f81b8260048151811061160057fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060021a60f81b8260058151811061164357fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060011a60f81b8260068151811061168657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060001a60f81b826007815181106116c957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535050919050565b6000808585111561170d578182fd5b83861115611719578182fd5b505082019391909203915056fe4465706f736974436f6e74726163743a206d65726b6c6520747265652066756c6c4465706f736974436f6e74726163743a207265636f6e7374727563746564204465706f7369744461746120646f6573206e6f74206d6174636820737570706c696564206465706f7369745f646174615f726f6f744465706f736974436f6e74726163743a20696e76616c6964207769746864726177616c5f63726564656e7469616c73206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c7565206e6f74206d756c7469706c65206f6620677765694465706f736974436f6e74726163743a20696e76616c6964207075626b6579206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f20686967684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f206c6f774465706f736974436f6e74726163743a20696e76616c6964207369676e6174757265206c656e677468a26469706673582212201dd26f37a621703009abf16e77e69c93dc50c79db7f6cc37543e3e0e3decdc9764736f6c634300060b0033", + "comment": "This is the runtime bytecode for the Deposit Request Smart Contract. It was created from the generated alloc section of fork_Prague_blockchain_test_engine_single_deposit_from_contract spec test", + "balance": "0x0", + "code": "0x60806040526004361061003f5760003560e01c806301ffc9a71461004457806322895118146100a4578063621fd130146101ba578063c5f2892f14610244575b600080fd5b34801561005057600080fd5b506100906004803603602081101561006757600080fd5b50357fffffffff000000000000000000000000000000000000000000000000000000001661026b565b604080519115158252519081900360200190f35b6101b8600480360360808110156100ba57600080fd5b8101906020810181356401000000008111156100d557600080fd5b8201836020820111156100e757600080fd5b8035906020019184600183028401116401000000008311171561010957600080fd5b91939092909160208101903564010000000081111561012757600080fd5b82018360208201111561013957600080fd5b8035906020019184600183028401116401000000008311171561015b57600080fd5b91939092909160208101903564010000000081111561017957600080fd5b82018360208201111561018b57600080fd5b803590602001918460018302840111640100000000831117156101ad57600080fd5b919350915035610304565b005b3480156101c657600080fd5b506101cf6110b5565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102095781810151838201526020016101f1565b50505050905090810190601f1680156102365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561025057600080fd5b506102596110c7565b60408051918252519081900360200190f35b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102fe57507fffffffff0000000000000000000000000000000000000000000000000000000082167f8564090700000000000000000000000000000000000000000000000000000000145b92915050565b6030861461035d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118056026913960400191505060405180910390fd5b602084146103b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603681526020018061179c6036913960400191505060405180910390fd5b6060821461040f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806118786029913960400191505060405180910390fd5b670de0b6b3a7640000341015610470576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118526026913960400191505060405180910390fd5b633b9aca003406156104cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806117d26033913960400191505060405180910390fd5b633b9aca00340467ffffffffffffffff811115610535576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602781526020018061182b6027913960400191505060405180910390fd5b6060610540826114ba565b90507f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c589898989858a8a6105756020546114ba565b6040805160a0808252810189905290819060208201908201606083016080840160c085018e8e80828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910187810386528c815260200190508c8c808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690920188810386528c5181528c51602091820193918e019250908190849084905b83811015610648578181015183820152602001610630565b50505050905090810190601f1680156106755780820380516001836020036101000a031916815260200191505b5086810383528881526020018989808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018881038452895181528951602091820193918b019250908190849084905b838110156106ef5781810151838201526020016106d7565b50505050905090810190601f16801561071c5780820380516001836020036101000a031916815260200191505b509d505050505050505050505050505060405180910390a1600060028a8a600060801b604051602001808484808284377fffffffffffffffffffffffffffffffff0000000000000000000000000000000090941691909301908152604080517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0818403018152601090920190819052815191955093508392506020850191508083835b602083106107fc57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016107bf565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610859573d6000803e3d6000fd5b5050506040513d602081101561086e57600080fd5b5051905060006002806108846040848a8c6116fe565b6040516020018083838082843780830192505050925050506040516020818303038152906040526040518082805190602001908083835b602083106108f857805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016108bb565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610955573d6000803e3d6000fd5b5050506040513d602081101561096a57600080fd5b5051600261097b896040818d6116fe565b60405160009060200180848480828437919091019283525050604080518083038152602092830191829052805190945090925082918401908083835b602083106109f457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016109b7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610a51573d6000803e3d6000fd5b5050506040513d6020811015610a6657600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610ada57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610a9d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610b37573d6000803e3d6000fd5b5050506040513d6020811015610b4c57600080fd5b50516040805160208101858152929350600092600292839287928f928f92018383808284378083019250505093505050506040516020818303038152906040526040518082805190602001908083835b60208310610bd957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610b9c565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610c36573d6000803e3d6000fd5b5050506040513d6020811015610c4b57600080fd5b50516040518651600291889160009188916020918201918291908601908083835b60208310610ca957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610c6c565b6001836020036101000a0380198251168184511680821785525050505050509050018367ffffffffffffffff191667ffffffffffffffff1916815260180182815260200193505050506040516020818303038152906040526040518082805190602001908083835b60208310610d4e57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610d11565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610dab573d6000803e3d6000fd5b5050506040513d6020811015610dc057600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610e3457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610df7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610e91573d6000803e3d6000fd5b5050506040513d6020811015610ea657600080fd5b50519050858114610f02576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260548152602001806117486054913960600191505060405180910390fd5b60205463ffffffff11610f60576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806117276021913960400191505060405180910390fd5b602080546001019081905560005b60208110156110a9578160011660011415610fa0578260008260208110610f9157fe5b0155506110ac95505050505050565b600260008260208110610faf57fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061102557805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610fe8565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015611082573d6000803e3d6000fd5b5050506040513d602081101561109757600080fd5b50519250600282049150600101610f6e565b50fe5b50505050505050565b60606110c26020546114ba565b905090565b6020546000908190815b60208110156112f05781600116600114156111e6576002600082602081106110f557fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061116b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161112e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156111c8573d6000803e3d6000fd5b5050506040513d60208110156111dd57600080fd5b505192506112e2565b600283602183602081106111f657fe5b015460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061126b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161122e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156112c8573d6000803e3d6000fd5b5050506040513d60208110156112dd57600080fd5b505192505b6002820491506001016110d1565b506002826112ff6020546114ba565b600060401b6040516020018084815260200183805190602001908083835b6020831061135a57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161131d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790527fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000095909516920191825250604080518083037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8018152601890920190819052815191955093508392850191508083835b6020831061143f57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611402565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa15801561149c573d6000803e3d6000fd5b5050506040513d60208110156114b157600080fd5b50519250505090565b60408051600880825281830190925260609160208201818036833701905050905060c082901b8060071a60f81b826000815181106114f457fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060061a60f81b8260018151811061153757fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060051a60f81b8260028151811061157a57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060041a60f81b826003815181106115bd57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060031a60f81b8260048151811061160057fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060021a60f81b8260058151811061164357fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060011a60f81b8260068151811061168657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060001a60f81b826007815181106116c957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535050919050565b6000808585111561170d578182fd5b83861115611719578182fd5b505082019391909203915056fe4465706f736974436f6e74726163743a206d65726b6c6520747265652066756c6c4465706f736974436f6e74726163743a207265636f6e7374727563746564204465706f7369744461746120646f6573206e6f74206d6174636820737570706c696564206465706f7369745f646174615f726f6f744465706f736974436f6e74726163743a20696e76616c6964207769746864726177616c5f63726564656e7469616c73206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c7565206e6f74206d756c7469706c65206f6620677765694465706f736974436f6e74726163743a20696e76616c6964207075626b6579206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f20686967684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f206c6f774465706f736974436f6e74726163743a20696e76616c6964207369676e6174757265206c656e677468a2646970667358221220dceca8706b29e917dacf25fceef95acac8d90d765ac926663ce4096195952b6164736f6c634300060b0033", "storage": { "0x0000000000000000000000000000000000000000000000000000000000000022": "0xf5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b", "0x0000000000000000000000000000000000000000000000000000000000000023": "0xdb56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71", diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/00_get_genesis_block_info.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/00_get_genesis_block_info.json index d1a18826a9..ca9c3ef7e7 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/00_get_genesis_block_info.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/00_get_genesis_block_info.json @@ -12,14 +12,14 @@ "id": 67, "result": { "number": "0x0", - "hash" : "0x38d7daa68e8bac41a0a237b7cbfcef480cb9bd9adc7b282d7b0d23ff4eb8d6e5", + "hash" : "0x01f5cbf33268c161f1526d704268db760bf82c9772a8f8ca412e0c6ce5684896", "mixHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "nonce" : "0x0000000000000042", "sha3Uncles" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", "logsBloom" : "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "transactionsRoot" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot" : "0x3ed8435adb5f3526144e6babdd3fc8c661a86097cf7e743441b41fda096fc4dd", + "stateRoot" : "0x860be6ab5a8fc2003c3739bfe2cdbcd9dbb273c8ea42951b832a8e1f22fb3a60", "receiptsRoot" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "miner" : "0x0000000000000000000000000000000000000000", "difficulty" : "0x400000000", diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/01_cancun_prepare_payload.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/01_cancun_prepare_payload.json index ad4b9be2d0..e549da3f30 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/01_cancun_prepare_payload.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/01_cancun_prepare_payload.json @@ -4,8 +4,8 @@ "method": "engine_forkchoiceUpdatedV3", "params": [ { - "headBlockHash": "0x38d7daa68e8bac41a0a237b7cbfcef480cb9bd9adc7b282d7b0d23ff4eb8d6e5", - "safeBlockHash": "0x38d7daa68e8bac41a0a237b7cbfcef480cb9bd9adc7b282d7b0d23ff4eb8d6e5", + "headBlockHash": "0x01f5cbf33268c161f1526d704268db760bf82c9772a8f8ca412e0c6ce5684896", + "safeBlockHash": "0x01f5cbf33268c161f1526d704268db760bf82c9772a8f8ca412e0c6ce5684896", "finalizedBlockHash": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { @@ -24,10 +24,10 @@ "result": { "payloadStatus": { "status": "VALID", - "latestValidHash": "0x38d7daa68e8bac41a0a237b7cbfcef480cb9bd9adc7b282d7b0d23ff4eb8d6e5", + "latestValidHash": "0x01f5cbf33268c161f1526d704268db760bf82c9772a8f8ca412e0c6ce5684896", "validationError": null }, - "payloadId": "0x28264396eca1deef" + "payloadId": "0x282643b677b85211" } }, "statusCode": 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/02_cancun_getPayloadV3.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/02_cancun_getPayloadV3.json index 63cfeec26a..7a29443fef 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/02_cancun_getPayloadV3.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/02_cancun_getPayloadV3.json @@ -3,7 +3,7 @@ "jsonrpc": "2.0", "method": "engine_getPayloadV3", "params": [ - "0x28264396eca1deef" + "0x282643b677b85211" ], "id": 67 }, @@ -12,9 +12,9 @@ "id": 67, "result": { "executionPayload": { - "parentHash": "0x38d7daa68e8bac41a0a237b7cbfcef480cb9bd9adc7b282d7b0d23ff4eb8d6e5", + "parentHash": "0x01f5cbf33268c161f1526d704268db760bf82c9772a8f8ca412e0c6ce5684896", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x3ed8435adb5f3526144e6babdd3fc8c661a86097cf7e743441b41fda096fc4dd", + "stateRoot": "0x860be6ab5a8fc2003c3739bfe2cdbcd9dbb273c8ea42951b832a8e1f22fb3a60", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -29,7 +29,7 @@ "blockNumber": "0x1", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "blobGasUsed": "0x0", - "blockHash": "0x8082deff44f79489ea92415be59afb48b6f46b939553f855479828a6f87f9593" + "blockHash": "0x7cccf6d9ce3e5acaeac9058959c27ace53af3a30b15763e1703bab2d0ae9438e" }, "blockValue": "0x0", "blobsBundle": { diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/03_cancun_newPayloadV3.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/03_cancun_newPayloadV3.json index 9f984b2f35..d2191e8312 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/03_cancun_newPayloadV3.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/03_cancun_newPayloadV3.json @@ -4,9 +4,9 @@ "method": "engine_newPayloadV3", "params": [ { - "parentHash": "0x38d7daa68e8bac41a0a237b7cbfcef480cb9bd9adc7b282d7b0d23ff4eb8d6e5", + "parentHash": "0x01f5cbf33268c161f1526d704268db760bf82c9772a8f8ca412e0c6ce5684896", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x3ed8435adb5f3526144e6babdd3fc8c661a86097cf7e743441b41fda096fc4dd", + "stateRoot": "0x860be6ab5a8fc2003c3739bfe2cdbcd9dbb273c8ea42951b832a8e1f22fb3a60", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -14,13 +14,13 @@ "timestamp": "0x10", "extraData": "0x", "baseFeePerGas": "0x7", + "excessBlobGas": "0x0", "transactions": [], "withdrawals": [], "blockNumber": "0x1", - "blockHash": "0x8082deff44f79489ea92415be59afb48b6f46b939553f855479828a6f87f9593", - "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "excessBlobGas": "0x0", - "blobGasUsed": "0x0" + "blobGasUsed": "0x0", + "blockHash": "0x7cccf6d9ce3e5acaeac9058959c27ace53af3a30b15763e1703bab2d0ae9438e", + "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" }, [], "0x0000000000000000000000000000000000000000000000000000000000000000" @@ -32,7 +32,7 @@ "id": 67, "result": { "status": "VALID", - "latestValidHash": "0x8082deff44f79489ea92415be59afb48b6f46b939553f855479828a6f87f9593", + "latestValidHash": "0x7cccf6d9ce3e5acaeac9058959c27ace53af3a30b15763e1703bab2d0ae9438e", "validationError": null } }, diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/04_cancun_forkchoiceUpdatedV3.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/04_cancun_forkchoiceUpdatedV3.json index b0ce0f70c1..8bbb71be33 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/04_cancun_forkchoiceUpdatedV3.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/04_cancun_forkchoiceUpdatedV3.json @@ -4,9 +4,9 @@ "method": "engine_forkchoiceUpdatedV3", "params": [ { - "headBlockHash": "0x8082deff44f79489ea92415be59afb48b6f46b939553f855479828a6f87f9593", - "safeBlockHash": "0x8082deff44f79489ea92415be59afb48b6f46b939553f855479828a6f87f9593", - "finalizedBlockHash": "0x8082deff44f79489ea92415be59afb48b6f46b939553f855479828a6f87f9593" + "headBlockHash": "0x7cccf6d9ce3e5acaeac9058959c27ace53af3a30b15763e1703bab2d0ae9438e", + "safeBlockHash": "0x7cccf6d9ce3e5acaeac9058959c27ace53af3a30b15763e1703bab2d0ae9438e", + "finalizedBlockHash": "0x7cccf6d9ce3e5acaeac9058959c27ace53af3a30b15763e1703bab2d0ae9438e" }, null ], @@ -18,7 +18,7 @@ "result": { "payloadStatus": { "status": "VALID", - "latestValidHash": "0x8082deff44f79489ea92415be59afb48b6f46b939553f855479828a6f87f9593", + "latestValidHash": "0x7cccf6d9ce3e5acaeac9058959c27ace53af3a30b15763e1703bab2d0ae9438e", "validationError": null }, "payloadId": null diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/05_prague_forkchoiceUpdatedV3.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/05_prague_forkchoiceUpdatedV3.json index 1eae1c881a..7e70a3bcac 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/05_prague_forkchoiceUpdatedV3.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/05_prague_forkchoiceUpdatedV3.json @@ -4,9 +4,9 @@ "method": "engine_forkchoiceUpdatedV3", "params": [ { - "headBlockHash": "0x8082deff44f79489ea92415be59afb48b6f46b939553f855479828a6f87f9593", - "safeBlockHash": "0x8082deff44f79489ea92415be59afb48b6f46b939553f855479828a6f87f9593", - "finalizedBlockHash": "0x8082deff44f79489ea92415be59afb48b6f46b939553f855479828a6f87f9593" + "headBlockHash": "0x7cccf6d9ce3e5acaeac9058959c27ace53af3a30b15763e1703bab2d0ae9438e", + "safeBlockHash": "0x7cccf6d9ce3e5acaeac9058959c27ace53af3a30b15763e1703bab2d0ae9438e", + "finalizedBlockHash": "0x7cccf6d9ce3e5acaeac9058959c27ace53af3a30b15763e1703bab2d0ae9438e" }, { "timestamp": "0x20", @@ -24,10 +24,10 @@ "result": { "payloadStatus": { "status": "VALID", - "latestValidHash": "0x8082deff44f79489ea92415be59afb48b6f46b939553f855479828a6f87f9593", + "latestValidHash": "0x7cccf6d9ce3e5acaeac9058959c27ace53af3a30b15763e1703bab2d0ae9438e", "validationError": null }, - "payloadId": "0x282643d3a905e721" + "payloadId": "0x282643fdcbcb1ddf" } }, "statusCode": 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/06_prague_getPayloadV4.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/06_prague_getPayloadV4.json index 4cb85d5f54..92c1bbcf2e 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/06_prague_getPayloadV4.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/06_prague_getPayloadV4.json @@ -3,7 +3,7 @@ "jsonrpc": "2.0", "method": "engine_getPayloadV4", "params": [ - "0x282643d3a905e721" + "0x282643fdcbcb1ddf" ], "id": 67 }, @@ -12,9 +12,9 @@ "id": 67, "result": { "executionPayload": { - "parentHash": "0x8082deff44f79489ea92415be59afb48b6f46b939553f855479828a6f87f9593", + "parentHash": "0x7cccf6d9ce3e5acaeac9058959c27ace53af3a30b15763e1703bab2d0ae9438e", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x2e59916a57b535875bcd80d8472aeaa0027aa685d159804e8caa2f12d060155e", + "stateRoot": "0xed4093bcd157ba955245906a1cda7695d3b3f233af709f0adf17689abb4d93b4", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -23,22 +23,13 @@ "extraData": "0x", "baseFeePerGas": "0x7", "excessBlobGas": "0x0", + "blobGasUsed": "0x0", "parentBeaconBlockRoot": "0x0000000000000000000000000000000000000000000000000000000000000000", "transactions": [], "withdrawals": [], - "depositRequests": [], - "withdrawalRequests": [ - { - "sourceAddress": "0xa4664c40aacebd82a2db79f0ea36c06bc6a19adb", - "validatorPubkey": "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e", - "amount": "0x0" - } - ], - "consolidationRequests" : [], "blockNumber": "0x2", - "blockHash": "0x27a2bc2ac21b3fc796f636bec1ec9cba100435f9a793176a83a5d4fa7cc13006", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "blobGasUsed": "0x0" + "blockHash": "0x303fb51567c090ed3fb7ac50a082ae3a0bcb8ff522d071011a1ca433561a4569" }, "blockValue": "0x0", "blobsBundle": { @@ -46,7 +37,12 @@ "proofs": [], "blobs": [] }, - "shouldOverrideBuilder": false + "shouldOverrideBuilder": false, + "executionRequests": [ + "0x", + "0xa4664c40aacebd82a2db79f0ea36c06bc6a19adbb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e0000000000000000", + "0x" + ] } }, "statusCode": 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/07_prague_send_raw_transaction.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/07_prague_send_raw_transaction_deposit_request.json similarity index 100% rename from acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/07_prague_send_raw_transaction.json rename to acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/07_prague_send_raw_transaction_deposit_request.json diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/08_prague_invalid_null_deposits_execute_payload.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/08_prague_invalid_null_deposit_request_execute_payload.json similarity index 88% rename from acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/08_prague_invalid_null_deposits_execute_payload.json rename to acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/08_prague_invalid_null_deposit_request_execute_payload.json index ed75e54aaf..14b6fc3d9a 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/08_prague_invalid_null_deposits_execute_payload.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/08_prague_invalid_null_deposit_request_execute_payload.json @@ -17,24 +17,24 @@ "excessBlobGas": "0x0", "transactions": [], "withdrawals": [], - "depositRequests": null, "blockNumber": "0x2", "blockHash": "0x2331b2dc9c453e9a33685099742cbbcd529d42bd5681969f45754f06866c6766", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "blobGasUsed": "0x0" }, [], - "0x0000000000000000000000000000000000000000000000000000000000000000" + "0x0000000000000000000000000000000000000000000000000000000000000000", + null ], "id": 67 }, "response": { - "jsonrpc": "2.0", - "id": 67, - "error": { - "code": -32602, - "message": "Invalid params", - "data": "Missing deposit field" + "jsonrpc" : "2.0", + "id" : 67, + "error" : { + "code" : -32602, + "message" : "Invalid execution requests params", + "data" : "Missing execution requests field" } }, "statusCode": 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/09_prague_newPayloadV4.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/09_prague_newPayloadV4.json index 17496f9ed7..dcbbb3a8df 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/09_prague_newPayloadV4.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/09_prague_newPayloadV4.json @@ -4,9 +4,9 @@ "method": "engine_newPayloadV4", "params": [ { - "parentHash": "0x8082deff44f79489ea92415be59afb48b6f46b939553f855479828a6f87f9593", + "parentHash": "0x7cccf6d9ce3e5acaeac9058959c27ace53af3a30b15763e1703bab2d0ae9438e", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x961878fdcdff52ea42db0026f59aa414a5ec2835e56ed1a8ae50c80a9fe3a04b", + "stateRoot": "0x176ea6dfa3b8efb148a025f759cccfaab02db38427b12a4ede73491eda397196", "logsBloom": "0x10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -15,34 +15,22 @@ "extraData": "0x", "baseFeePerGas": "0x7", "excessBlobGas": "0x0", + "blobGasUsed": "0x0", "transactions": [ "0x02f9021c8217de808459682f008459682f0e830271009442424242424242424242424242424242424242428901bc16d674ec800000b901a422895118000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120749715de5d1226545c6b3790f515d551a5cc5bf1d49c87a696860554d2fc4f14000000000000000000000000000000000000000000000000000000000000003096a96086cff07df17668f35f7418ef8798079167e3f4f9b72ecde17b28226137cf454ab1dd20ef5d924786ab3483c2f9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020003f5102dabe0a27b1746098d1dc17a5d3fbd478759fea9287e4e419b3c3cef20000000000000000000000000000000000000000000000000000000000000060b1acdb2c4d3df3f1b8d3bfd33421660df358d84d78d16c4603551935f4b67643373e7eb63dcb16ec359be0ec41fee33b03a16e80745f2374ff1d3c352508ac5d857c6476d3c3bcf7e6ca37427c9209f17be3af5264c0e2132b3dd1156c28b4e9c080a09f597089338d7f44f5c59f8230bb38f243849228a8d4e9d2e2956e6050f5b2c7a076486996c7e62802b8f95eee114783e4b403fd11093ba96286ff42c595f24452" ], "withdrawals": [], - "depositRequests": [ - { - "amount": "0x773594000", - "index": "0x0", - "pubkey": "0x96a96086cff07df17668f35f7418ef8798079167e3f4f9b72ecde17b28226137cf454ab1dd20ef5d924786ab3483c2f9", - "signature": "0xb1acdb2c4d3df3f1b8d3bfd33421660df358d84d78d16c4603551935f4b67643373e7eb63dcb16ec359be0ec41fee33b03a16e80745f2374ff1d3c352508ac5d857c6476d3c3bcf7e6ca37427c9209f17be3af5264c0e2132b3dd1156c28b4e9", - "withdrawalCredentials": "0x003f5102dabe0a27b1746098d1dc17a5d3fbd478759fea9287e4e419b3c3cef2" - } - ], - "withdrawalRequests": [ - { - "sourceAddress": "0xa4664c40aacebd82a2db79f0ea36c06bc6a19adb", - "amount": "0x0", - "validatorPubkey": "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e" - } - ], - "consolidationRequests": [], "blockNumber": "0x2", - "blockHash": "0xc67a660f5d3c20ee603911bdff1e409e976f306883dff8ef4999dca3176f7dca", "receiptsRoot": "0x79ee3424eb720a3ad4b1c5a372bb8160580cbe4d893778660f34213c685627a9", - "blobGasUsed": "0x0" + "blockHash": "0x14ba5ec415d827d9cab33e6097b307131e8119a1cd7dc1f6a4de088ebfa4c1b6" }, [], - "0x0000000000000000000000000000000000000000000000000000000000000000" + "0x0000000000000000000000000000000000000000000000000000000000000000", + [ + "0xf84794a4664c40aacebd82a2db79f0ea36c06bc6a19adbb0b10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e80", + "0xa4664c40aacebd82a2db79f0ea36c06bc6a19adbb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e0000000000000000", + "0x" + ] ], "id": 67 }, @@ -51,7 +39,7 @@ "id": 67, "result": { "status": "VALID", - "latestValidHash": "0xc67a660f5d3c20ee603911bdff1e409e976f306883dff8ef4999dca3176f7dca", + "latestValidHash": "0x14ba5ec415d827d9cab33e6097b307131e8119a1cd7dc1f6a4de088ebfa4c1b6", "validationError": null } }, diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/10_prague_forkchoiceUpdatedV3.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/10_prague_forkchoiceUpdatedV3.json index ba0f1e8e5b..0c817637b3 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/10_prague_forkchoiceUpdatedV3.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/10_prague_forkchoiceUpdatedV3.json @@ -4,9 +4,9 @@ "method": "engine_forkchoiceUpdatedV3", "params": [ { - "headBlockHash": "0xc67a660f5d3c20ee603911bdff1e409e976f306883dff8ef4999dca3176f7dca", - "safeBlockHash": "0xc67a660f5d3c20ee603911bdff1e409e976f306883dff8ef4999dca3176f7dca", - "finalizedBlockHash": "0xc67a660f5d3c20ee603911bdff1e409e976f306883dff8ef4999dca3176f7dca" + "headBlockHash": "0x14ba5ec415d827d9cab33e6097b307131e8119a1cd7dc1f6a4de088ebfa4c1b6", + "safeBlockHash": "0x14ba5ec415d827d9cab33e6097b307131e8119a1cd7dc1f6a4de088ebfa4c1b6", + "finalizedBlockHash": "0x14ba5ec415d827d9cab33e6097b307131e8119a1cd7dc1f6a4de088ebfa4c1b6" }, { "timestamp": "0x30", @@ -24,10 +24,10 @@ "result": { "payloadStatus": { "status": "VALID", - "latestValidHash": "0xc67a660f5d3c20ee603911bdff1e409e976f306883dff8ef4999dca3176f7dca", + "latestValidHash": "0x14ba5ec415d827d9cab33e6097b307131e8119a1cd7dc1f6a4de088ebfa4c1b6", "validationError": null }, - "payloadId": "0x282643a16a58b5cf" + "payloadId": "0x282643aeecfdbccf" } }, "statusCode": 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/11_prague_getPayloadV4.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/11_prague_getPayloadV4.json index 3b76fac10a..df3080a657 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/11_prague_getPayloadV4.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/11_prague_getPayloadV4.json @@ -3,7 +3,7 @@ "jsonrpc": "2.0", "method": "engine_getPayloadV4", "params": [ - "0x282643a16a58b5cf" + "0x282643aeecfdbccf" ], "id": 67 }, @@ -12,9 +12,9 @@ "id": 67, "result": { "executionPayload": { - "parentHash": "0xc67a660f5d3c20ee603911bdff1e409e976f306883dff8ef4999dca3176f7dca", + "parentHash": "0x14ba5ec415d827d9cab33e6097b307131e8119a1cd7dc1f6a4de088ebfa4c1b6", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x5fc31c01a451fe02f0e938de7ec7044aaba1159a81a1be64357bc70af226f304", + "stateRoot": "0xade3c29cae771ddfa994d3d2994f3bcbe084bc7bb23cdbb9bd7e35b39f007841", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -23,16 +23,13 @@ "extraData": "0x", "baseFeePerGas": "0x7", "excessBlobGas": "0x0", + "blobGasUsed": "0x0", "parentBeaconBlockRoot": "0x0000000000000000000000000000000000000000000000000000000000000000", "transactions": [], "withdrawals": [], - "depositRequests": [], - "withdrawalRequests": [], - "consolidationRequests" : [], "blockNumber": "0x3", - "blockHash": "0xdbb55a049f14b8152695bf3bbd754aa1fd55bbe10b306eb49caa4bd7d7fcb634", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "blobGasUsed": "0x0" + "blockHash": "0x9f157012bdc439f5fe2bb3b4236eb07043e35d16256557d73e80a95d20054929" }, "blockValue": "0x0", "blobsBundle": { @@ -40,7 +37,12 @@ "proofs": [], "blobs": [] }, - "shouldOverrideBuilder": false + "shouldOverrideBuilder": false, + "executionRequests": [ + "0x", + "0x", + "0x" + ] } }, "statusCode": 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/12_cancun_newPayloadV3.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/12_cancun_newPayloadV3.json index 546872807c..e0746e9f7f 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/12_cancun_newPayloadV3.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/12_cancun_newPayloadV3.json @@ -4,9 +4,9 @@ "method": "engine_newPayloadV3", "params": [ { - "parentHash": "0xc67a660f5d3c20ee603911bdff1e409e976f306883dff8ef4999dca3176f7dca", + "parentHash": "0x14ba5ec415d827d9cab33e6097b307131e8119a1cd7dc1f6a4de088ebfa4c1b6", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x5fc31c01a451fe02f0e938de7ec7044aaba1159a81a1be64357bc70af226f304", + "stateRoot": "0xade3c29cae771ddfa994d3d2994f3bcbe084bc7bb23cdbb9bd7e35b39f007841", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", @@ -14,18 +14,21 @@ "timestamp": "0x30", "extraData": "0x", "baseFeePerGas": "0x7", + "excessBlobGas": "0x0", + "blobGasUsed": "0x0", "transactions": [], "withdrawals": [], - "depositRequests": [], - "withdrawalRequests": [], "blockNumber": "0x3", - "blockHash": "0xdbb55a049f14b8152695bf3bbd754aa1fd55bbe10b306eb49caa4bd7d7fcb634", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "excessBlobGas": "0x0", - "blobGasUsed": "0x0" + "blockHash": "0x9f157012bdc439f5fe2bb3b4236eb07043e35d16256557d73e80a95d20054929" }, [], - "0x0000000000000000000000000000000000000000000000000000000000000000" + "0x0000000000000000000000000000000000000000000000000000000000000000", + [ + "0x", + "0x", + "0x" + ] ], "id": 67 }, @@ -34,7 +37,7 @@ "id": 67, "result": { "status": "VALID", - "latestValidHash": "0xdbb55a049f14b8152695bf3bbd754aa1fd55bbe10b306eb49caa4bd7d7fcb634", + "latestValidHash": "0x9f157012bdc439f5fe2bb3b4236eb07043e35d16256557d73e80a95d20054929", "validationError": null } }, diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/15_prague_forkchoiceUpdatedV3.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/15_prague_forkchoiceUpdatedV3.json index 61750afbe7..31903a4f96 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/15_prague_forkchoiceUpdatedV3.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/15_prague_forkchoiceUpdatedV3.json @@ -4,9 +4,9 @@ "method": "engine_forkchoiceUpdatedV3", "params": [ { - "headBlockHash": "0xdbb55a049f14b8152695bf3bbd754aa1fd55bbe10b306eb49caa4bd7d7fcb634", - "safeBlockHash": "0xdbb55a049f14b8152695bf3bbd754aa1fd55bbe10b306eb49caa4bd7d7fcb634", - "finalizedBlockHash": "0xdbb55a049f14b8152695bf3bbd754aa1fd55bbe10b306eb49caa4bd7d7fcb634" + "headBlockHash": "0x9f157012bdc439f5fe2bb3b4236eb07043e35d16256557d73e80a95d20054929", + "safeBlockHash": "0x9f157012bdc439f5fe2bb3b4236eb07043e35d16256557d73e80a95d20054929", + "finalizedBlockHash": "0x9f157012bdc439f5fe2bb3b4236eb07043e35d16256557d73e80a95d20054929" }, { "timestamp": "0x40", @@ -24,10 +24,10 @@ "result": { "payloadStatus": { "status": "VALID", - "latestValidHash": "0xdbb55a049f14b8152695bf3bbd754aa1fd55bbe10b306eb49caa4bd7d7fcb634", + "latestValidHash": "0x9f157012bdc439f5fe2bb3b4236eb07043e35d16256557d73e80a95d20054929", "validationError": null }, - "payloadId": "0x28264396a9634d41" + "payloadId": "0x282643ae671b03bf" } }, "statusCode": 200 diff --git a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/16_prague_getPayloadV4.json b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/16_prague_getPayloadV4.json index 51843931e7..2f2d7c355c 100644 --- a/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/16_prague_getPayloadV4.json +++ b/acceptance-tests/tests/src/test/resources/jsonrpc/engine/prague/test-cases/16_prague_getPayloadV4.json @@ -3,7 +3,7 @@ "jsonrpc": "2.0", "method": "engine_getPayloadV4", "params": [ - "0x28264396a9634d41" + "0x282643ae671b03bf" ], "id": 67 }, @@ -12,50 +12,40 @@ "id": 67, "result": { "executionPayload": { - "parentHash": "0xdbb55a049f14b8152695bf3bbd754aa1fd55bbe10b306eb49caa4bd7d7fcb634", + "parentHash": "0x9f157012bdc439f5fe2bb3b4236eb07043e35d16256557d73e80a95d20054929", "feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "stateRoot": "0x49df1f1a1d28a23fa752230d442077768787d392e9edb70c83d727d31e55eaac", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "stateRoot": "0xc7dbe7764cb5edd271a3e7fc4ffad23736aa1b8d4a5703e05a58db88d4ecbdc3", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000100000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000008000000000000000000000000000000000000000800000000000000000000000000", "prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x1c9c380", - "gasUsed": "0x3ad4d", + "gasUsed": "0x3b6c5", "timestamp": "0x40", "extraData": "0x", "baseFeePerGas": "0x7", "excessBlobGas": "0x0", + "blobGasUsed": "0x0", "parentBeaconBlockRoot": "0x0000000000000000000000000000000000000000000000000000000000000000", "transactions": [ "0xf8a08085e8d4a51000832dc6c09400a3ca265ebcb825b45f985a16cefb49958ce01702b8388706d19a62f28a6a6549f96c5adaebac9124a61d44868ec94f6d2d707c6a2f82c9162071231dfeb40e24bfde4ffdf2430000000000000000822fdfa00476c1a81f80f4c130acb5f8b8075468ba0893d766b7ec51a8d9723c573ad034a03bd3eaedabbaaf745f15023185ba66584ad3ee8bb40b9bef8c0b9ed27f8b1959", "0xf8c80185e8d4a51000832dc6c09400b42dbf2194e931e80326d950320f7d9dbeac0201b860fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe822fe0a05b88b593926d340f448918ef1c6263356c37f2434774e0fdb1cb9d90cfa5a23ba003a86aac4adb774181ba51eda17efb5fbed99ad57895e6eb56ccdf508a88a7cc" ], "withdrawals": [], - "depositRequests": [], - "withdrawalRequests": [ - { - "sourceAddress": "0x23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f", - "amount": "0x0", - "validatorPubkey": "0x8706d19a62f28a6a6549f96c5adaebac9124a61d44868ec94f6d2d707c6a2f82c9162071231dfeb40e24bfde4ffdf243" - } - ], - "consolidationRequests": [ - { - "sourceAddress": "0x23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f", - "sourcePubkey": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "targetPubkey": "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe" - } - ], "blockNumber": "0x4", - "receiptsRoot": "0x970fc81bb3e7fb21435f9a65a184aa9e3fd2f52b89fd859302b46954354266b5", - "blobGasUsed": "0x0", - "blockHash": "0x93df6f3484202f24c692354e2ab96e9948ae45eea6ad85faea121a389e468ea8" + "receiptsRoot": "0x640f4036d53782ca4c5e9273ba6d657db4f5ff4fe526a8ed1997af9d0b8ae2d3", + "blockHash": "0x61642311e6c1e0af50abf17be1fcb6de8bd75af2ca2d188031d074f6e71bf5e6" }, - "blockValue": "0x3581baab15c12e5", + "blockValue": "0x360b8482c4b509d", "blobsBundle": { "commitments": [], "proofs": [], "blobs": [] }, - "shouldOverrideBuilder": false + "shouldOverrideBuilder": false, + "executionRequests": [ + "0x", + "0x23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f8706d19a62f28a6a6549f96c5adaebac9124a61d44868ec94f6d2d707c6a2f82c9162071231dfeb40e24bfde4ffdf2430000000000000000", + "0x23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe" + ] } }, "statusCode": 200, diff --git a/besu/src/test/java/org/hyperledger/besu/services/RlpConverterServiceImplTest.java b/besu/src/test/java/org/hyperledger/besu/services/RlpConverterServiceImplTest.java index 7a3bdbbfe6..b9ce7ccd5c 100644 --- a/besu/src/test/java/org/hyperledger/besu/services/RlpConverterServiceImplTest.java +++ b/besu/src/test/java/org/hyperledger/besu/services/RlpConverterServiceImplTest.java @@ -38,7 +38,7 @@ public class RlpConverterServiceImplTest { new BlockHeaderTestFixture() .timestamp(1710338135 + 1) .baseFeePerGas(Wei.of(1000)) - .requestsRoot(Hash.ZERO) + .requestsHash(Hash.ZERO) .withdrawalsRoot(Hash.ZERO) .blobGasUsed(500L) .excessBlobGas(BlobGas.of(500L)) diff --git a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/PayloadWrapper.java b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/PayloadWrapper.java index 4a8588f84e..603834c869 100644 --- a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/PayloadWrapper.java +++ b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/PayloadWrapper.java @@ -18,12 +18,17 @@ import org.hyperledger.besu.consensus.merge.blockcreation.PayloadIdentifier; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.core.BlockValueCalculator; import org.hyperledger.besu.ethereum.core.BlockWithReceipts; +import org.hyperledger.besu.ethereum.core.Request; + +import java.util.List; +import java.util.Optional; /** Wrapper for payload plus extra info. */ public class PayloadWrapper { private final PayloadIdentifier payloadIdentifier; private final BlockWithReceipts blockWithReceipts; private final Wei blockValue; + private final Optional> requests; /** * Construct a wrapper with the following fields. @@ -32,10 +37,13 @@ public class PayloadWrapper { * @param blockWithReceipts Block with receipts */ public PayloadWrapper( - final PayloadIdentifier payloadIdentifier, final BlockWithReceipts blockWithReceipts) { + final PayloadIdentifier payloadIdentifier, + final BlockWithReceipts blockWithReceipts, + final Optional> requests) { this.blockWithReceipts = blockWithReceipts; this.payloadIdentifier = payloadIdentifier; this.blockValue = BlockValueCalculator.calculateBlockValue(blockWithReceipts); + this.requests = requests; } /** @@ -64,4 +72,13 @@ public class PayloadWrapper { public BlockWithReceipts blockWithReceipts() { return blockWithReceipts; } + + /** + * Get the requests + * + * @return requests + */ + public Optional> requests() { + return requests; + } } diff --git a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java index c62b6e0de8..877d7fb963 100644 --- a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java +++ b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java @@ -302,7 +302,9 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene if (result.isSuccessful()) { mergeContext.putPayloadById( new PayloadWrapper( - payloadIdentifier, new BlockWithReceipts(emptyBlock, result.getReceipts()))); + payloadIdentifier, + new BlockWithReceipts(emptyBlock, result.getReceipts()), + result.getRequests())); LOG.info( "Start building proposals for block {} identified by {}", emptyBlock.getHeader().getNumber(), @@ -469,7 +471,9 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene mergeContext.putPayloadById( new PayloadWrapper( - payloadIdentifier, new BlockWithReceipts(bestBlock, resultBest.getReceipts()))); + payloadIdentifier, + new BlockWithReceipts(bestBlock, resultBest.getReceipts()), + resultBest.getRequests())); LOG.atDebug() .setMessage( "Successfully built block {} for proposal identified by {}, with {} transactions, in {}ms") diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/messagewrappers/ProposalTest.java b/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/messagewrappers/ProposalTest.java index b3c462656a..5b7314f94a 100644 --- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/messagewrappers/ProposalTest.java +++ b/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/messagewrappers/ProposalTest.java @@ -54,8 +54,7 @@ public class ProposalTest { new BlockBody( Collections.emptyList(), Collections.emptyList(), - Optional.of(Collections.emptyList()), - Optional.empty())); + Optional.of(Collections.emptyList()))); @Test public void canRoundTripProposalMessage() { diff --git a/datatypes/src/main/java/org/hyperledger/besu/datatypes/Hash.java b/datatypes/src/main/java/org/hyperledger/besu/datatypes/Hash.java index a53843a247..3777169ed4 100644 --- a/datatypes/src/main/java/org/hyperledger/besu/datatypes/Hash.java +++ b/datatypes/src/main/java/org/hyperledger/besu/datatypes/Hash.java @@ -15,6 +15,7 @@ package org.hyperledger.besu.datatypes; import static org.hyperledger.besu.crypto.Hash.keccak256; +import static org.hyperledger.besu.crypto.Hash.sha256; import org.hyperledger.besu.ethereum.rlp.RLP; @@ -50,6 +51,17 @@ public class Hash extends DelegatingBytes32 { */ public static final Hash EMPTY = hash(Bytes.EMPTY); + /** + * Hash of empty requests or "0x6036c41849da9c076ed79654d434017387a88fb833c2856b32e18218b3341c5f" + */ + public static final Hash EMPTY_REQUESTS_HASH = + Hash.wrap( + sha256( + Bytes.concatenate( + sha256(Bytes.of(RequestType.DEPOSIT.getSerializedType())), + sha256(Bytes.of(RequestType.WITHDRAWAL.getSerializedType())), + sha256(Bytes.of(RequestType.CONSOLIDATION.getSerializedType()))))); + /** * Instantiates a new Hash. * diff --git a/datatypes/src/test/java/org/hyperledger/besu/datatypes/HashTest.java b/datatypes/src/test/java/org/hyperledger/besu/datatypes/HashTest.java index 1ae3b8c14e..a2ef3fe559 100644 --- a/datatypes/src/test/java/org/hyperledger/besu/datatypes/HashTest.java +++ b/datatypes/src/test/java/org/hyperledger/besu/datatypes/HashTest.java @@ -26,4 +26,12 @@ public class HashTest { .isEqualTo( Hash.fromHexString("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470")); } + + @Test + public void shouldGetExpectedValueForEmptyRequestsHash() { + assertThat(Hash.EMPTY_REQUESTS_HASH) + .isEqualTo( + Hash.fromHexString( + "0x6036c41849da9c076ed79654d434017387a88fb833c2856b32e18218b3341c5f")); + } } diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseKey.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseKey.java index a62cc06ec2..bf5d12804b 100644 --- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseKey.java +++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseKey.java @@ -38,5 +38,5 @@ public enum JsonRpcResponseKey { TRANSACTION_ROOT, BASEFEE, WITHDRAWALS_ROOT, - REQUESTS_ROOT + REQUESTS_HASH } diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseUtils.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseUtils.java index 4e067e6ec8..d72db974b0 100644 --- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseUtils.java +++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseUtils.java @@ -27,7 +27,7 @@ import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcResponseKey.NUMBE import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcResponseKey.OMMERS_HASH; import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcResponseKey.PARENT_HASH; import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcResponseKey.RECEIPTS_ROOT; -import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcResponseKey.REQUESTS_ROOT; +import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcResponseKey.REQUESTS_HASH; import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcResponseKey.SIZE; import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcResponseKey.STATE_ROOT; import static org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcResponseKey.TIMESTAMP; @@ -104,8 +104,8 @@ public class JsonRpcResponseUtils { final int size = unsignedInt(values.get(SIZE)); final Hash withdrawalsRoot = values.containsKey(WITHDRAWALS_ROOT) ? hash(values.get(WITHDRAWALS_ROOT)) : null; - final Hash requestsRoot = - values.containsKey(REQUESTS_ROOT) ? hash(values.get(REQUESTS_ROOT)) : null; + final Hash requestsHash = + values.containsKey(REQUESTS_HASH) ? hash(values.get(REQUESTS_HASH)) : null; final List ommers = new ArrayList<>(); final BlockHeader header = @@ -130,7 +130,7 @@ public class JsonRpcResponseUtils { null, // ToDo 4844: set with the value of blob_gas_used field null, // ToDo 4844: set with the value of excess_blob_gas field null, // TODO 4788: set with the value of the parent beacon block root field - requestsRoot, + requestsHash, blockHeaderFunctions); return new JsonRpcSuccessResponse( diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/execution/TracedJsonRpcProcessor.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/execution/TracedJsonRpcProcessor.java index ec0e6aef64..2a38afd630 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/execution/TracedJsonRpcProcessor.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/execution/TracedJsonRpcProcessor.java @@ -79,6 +79,7 @@ public class TracedJsonRpcProcessor implements JsonRpcProcessor { case INVALID_ENGINE_PREPARE_PAYLOAD_PARAMS: case INVALID_ENODE_PARAMS: case INVALID_EXCESS_BLOB_GAS_PARAMS: + case INVALID_EXECUTION_REQUESTS_PARAMS: case INVALID_EXTRA_DATA_PARAMS: case INVALID_FILTER_PARAMS: case INVALID_GAS_PRICE_PARAMS: diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java index 78b96796cb..308940f16a 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java @@ -20,15 +20,14 @@ import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.Executi import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.INVALID_BLOCK_HASH; import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.SYNCING; import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.VALID; -import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.RequestValidatorProvider.getConsolidationRequestValidator; -import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.RequestValidatorProvider.getDepositRequestValidator; -import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.RequestValidatorProvider.getWithdrawalRequestValidator; +import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.RequestValidatorProvider.getRequestsValidator; import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.WithdrawalsValidatorProvider.getWithdrawalsValidator; import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.BlobGas; import org.hyperledger.besu.datatypes.Hash; +import org.hyperledger.besu.datatypes.RequestType; import org.hyperledger.besu.datatypes.VersionedHash; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.BlockProcessingResult; @@ -36,12 +35,9 @@ import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcRequestException; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.ConsolidationRequestParameter; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositRequestParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalRequestParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; @@ -64,7 +60,6 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.mainnet.feemarket.ExcessBlobGasCalculator; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestUtil; import org.hyperledger.besu.ethereum.rlp.RLPException; import org.hyperledger.besu.ethereum.trie.MerkleTrieException; import org.hyperledger.besu.plugin.services.exception.StorageException; @@ -75,6 +70,7 @@ import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; +import java.util.stream.IntStream; import io.vertx.core.Vertx; import io.vertx.core.json.Json; @@ -141,8 +137,22 @@ public abstract class AbstractEngineNewPayload extends ExecutionEngineJsonRpcMet final Optional maybeParentBeaconBlockRoot = maybeParentBeaconBlockRootParam.map(Bytes32::fromHexString); + final Optional> maybeRequestsParam; + try { + maybeRequestsParam = requestContext.getOptionalList(3, String.class); + } catch (JsonRpcParameterException e) { + throw new InvalidJsonRpcRequestException( + "Invalid execution request parameters (index 3)", + RpcErrorType.INVALID_EXECUTION_REQUESTS_PARAMS, + e); + } + final ValidationResult parameterValidationResult = - validateParameters(blockParam, maybeVersionedHashParam, maybeParentBeaconBlockRootParam); + validateParameters( + blockParam, + maybeVersionedHashParam, + maybeParentBeaconBlockRootParam, + maybeRequestsParam); if (!parameterValidationResult.isValid()) { return new JsonRpcErrorResponse(reqId, parameterValidationResult); } @@ -183,45 +193,24 @@ public abstract class AbstractEngineNewPayload extends ExecutionEngineJsonRpcMet return new JsonRpcErrorResponse(reqId, RpcErrorType.INVALID_WITHDRAWALS_PARAMS); } - final Optional> maybeDepositRequests = - Optional.ofNullable(blockParam.getDepositRequests()) - .map(ds -> ds.stream().map(DepositRequestParameter::toDeposit).collect(toList())); - if (!getDepositRequestValidator( - protocolSchedule.get(), blockParam.getTimestamp(), blockParam.getBlockNumber()) - .validateParameter(maybeDepositRequests)) { - return new JsonRpcErrorResponse(reqId, RpcErrorType.INVALID_DEPOSIT_REQUEST_PARAMS); - } - - final Optional> maybeWithdrawalRequests = - Optional.ofNullable(blockParam.getWithdrawalRequests()) - .map( - withdrawalRequest -> - withdrawalRequest.stream() - .map(WithdrawalRequestParameter::toWithdrawalRequest) - .collect(toList())); - if (!getWithdrawalRequestValidator( - protocolSchedule.get(), blockParam.getTimestamp(), blockParam.getBlockNumber()) - .validateParameter(maybeWithdrawalRequests)) { - return new JsonRpcErrorResponse(reqId, RpcErrorType.INVALID_WITHDRAWALS_PARAMS); + final Optional> maybeRequests; + try { + maybeRequests = extractRequests(maybeRequestsParam); + } catch (RuntimeException ex) { + return respondWithInvalid( + reqId, + blockParam, + mergeCoordinator.getLatestValidAncestor(blockParam.getParentHash()).orElse(null), + INVALID, + "Invalid execution requests"); } - final Optional> maybeConsolidationRequests = - Optional.ofNullable(blockParam.getConsolidationRequests()) - .map( - consolidationRequest -> - consolidationRequest.stream() - .map(ConsolidationRequestParameter::toConsolidationRequest) - .collect(toList())); - if (!getConsolidationRequestValidator( + if (!getRequestsValidator( protocolSchedule.get(), blockParam.getTimestamp(), blockParam.getBlockNumber()) - .validateParameter(maybeConsolidationRequests)) { - return new JsonRpcErrorResponse(reqId, RpcErrorType.INVALID_CONSOLIDATION_REQUEST_PARAMS); + .validate(maybeRequests)) { + return new JsonRpcErrorResponse(reqId, RpcErrorType.INVALID_EXECUTION_REQUESTS_PARAMS); } - Optional> maybeRequests = - RequestUtil.combine( - maybeDepositRequests, maybeWithdrawalRequests, maybeConsolidationRequests); - if (mergeContext.get().isSyncing()) { LOG.debug("We are syncing"); return respondWith(reqId, blockParam, null, SYNCING); @@ -289,7 +278,7 @@ public abstract class AbstractEngineNewPayload extends ExecutionEngineJsonRpcMet ? null : BlobGas.fromHexString(blockParam.getExcessBlobGas()), maybeParentBeaconBlockRoot.orElse(null), - maybeRequests.map(BodyValidation::requestsRoot).orElse(null), + maybeRequests.map(BodyValidation::requestsHash).orElse(null), headerFunctions); // ensure the block hash matches the blockParam hash @@ -351,8 +340,7 @@ public abstract class AbstractEngineNewPayload extends ExecutionEngineJsonRpcMet final var block = new Block( - newBlockHeader, - new BlockBody(transactions, Collections.emptyList(), maybeWithdrawals, maybeRequests)); + newBlockHeader, new BlockBody(transactions, Collections.emptyList(), maybeWithdrawals)); if (maybeParentHeader.isEmpty()) { LOG.atDebug() @@ -466,7 +454,8 @@ public abstract class AbstractEngineNewPayload extends ExecutionEngineJsonRpcMet protected ValidationResult validateParameters( final EnginePayloadParameter parameter, final Optional> maybeVersionedHashParam, - final Optional maybeBeaconBlockRootParam) { + final Optional maybeBeaconBlockRootParam, + final Optional> maybeRequestsParam) { return ValidationResult.valid(); } @@ -562,6 +551,18 @@ public abstract class AbstractEngineNewPayload extends ExecutionEngineJsonRpcMet .collect(Collectors.toList())); } + private Optional> extractRequests(final Optional> maybeRequestsParam) { + if (maybeRequestsParam.isEmpty()) { + return Optional.empty(); + } + + return maybeRequestsParam.map( + requests -> + IntStream.range(0, requests.size()) + .mapToObj(i -> new Request(RequestType.of(i), Bytes.fromHexString(requests.get(i)))) + .collect(Collectors.toList())); + } + private void logImportedBlockInfo(final Block block, final int blobCount, final double timeInS) { final StringBuilder message = new StringBuilder(); message.append("Imported #%,d / %d tx"); @@ -572,10 +573,6 @@ public abstract class AbstractEngineNewPayload extends ExecutionEngineJsonRpcMet message.append(" / %d ws"); messageArgs.add(block.getBody().getWithdrawals().get().size()); } - if (block.getBody().getRequests().isPresent()) { - message.append(" / %d rs"); - messageArgs.add(block.getBody().getRequests().get().size()); - } message.append(" / %d blobs / base fee %s / %,d (%01.1f%%) gas / (%s) in %01.3fs. Peers: %d"); messageArgs.addAll( List.of( diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV2.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV2.java index acb177c3e0..00b0f83054 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV2.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV2.java @@ -57,7 +57,8 @@ public class EngineNewPayloadV2 extends AbstractEngineNewPayload { protected ValidationResult validateParameters( final EnginePayloadParameter payloadParameter, final Optional> maybeVersionedHashParam, - final Optional maybeBeaconBlockRootParam) { + final Optional maybeBeaconBlockRootParam, + final Optional> maybeRequestsParam) { if (payloadParameter.getBlobGasUsed() != null) { return ValidationResult.invalid( RpcErrorType.INVALID_BLOB_GAS_USED_PARAMS, "Missing blob gas used field"); diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3.java index 7d13ecc02c..8710e43627 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3.java @@ -55,7 +55,8 @@ public class EngineNewPayloadV3 extends AbstractEngineNewPayload { protected ValidationResult validateParameters( final EnginePayloadParameter payloadParameter, final Optional> maybeVersionedHashParam, - final Optional maybeBeaconBlockRootParam) { + final Optional maybeBeaconBlockRootParam, + final Optional> maybeRequestsParam) { if (payloadParameter.getBlobGasUsed() == null) { return ValidationResult.invalid( RpcErrorType.INVALID_BLOB_GAS_USED_PARAMS, "Missing blob gas used field"); diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4.java index 904ec08e5c..0155e3d721 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4.java @@ -55,7 +55,8 @@ public class EngineNewPayloadV4 extends AbstractEngineNewPayload { protected ValidationResult validateParameters( final EnginePayloadParameter payloadParameter, final Optional> maybeVersionedHashParam, - final Optional maybeBeaconBlockRootParam) { + final Optional maybeBeaconBlockRootParam, + final Optional> maybeRequestsParam) { if (payloadParameter.getBlobGasUsed() == null) { return ValidationResult.invalid( RpcErrorType.INVALID_BLOB_GAS_USED_PARAMS, "Missing blob gas used field"); @@ -69,8 +70,9 @@ public class EngineNewPayloadV4 extends AbstractEngineNewPayload { return ValidationResult.invalid( RpcErrorType.INVALID_PARENT_BEACON_BLOCK_ROOT_PARAMS, "Missing parent beacon block root field"); - } else if (payloadParameter.getDepositRequests() == null) { - return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Missing deposit field"); + } else if (maybeRequestsParam.isEmpty()) { + return ValidationResult.invalid( + RpcErrorType.INVALID_EXECUTION_REQUESTS_PARAMS, "Missing execution requests field"); } else { return ValidationResult.valid(); } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/RequestValidatorProvider.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/RequestValidatorProvider.java index c3d9c8376b..046e630fcc 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/RequestValidatorProvider.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/RequestValidatorProvider.java @@ -14,64 +14,25 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine; -import org.hyperledger.besu.datatypes.RequestType; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; -import org.hyperledger.besu.ethereum.mainnet.requests.ProhibitedRequestsValidator; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestValidator; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; +import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidator; import java.util.Optional; public class RequestValidatorProvider { - public static RequestValidator getDepositRequestValidator( + public static RequestsValidator getRequestsValidator( final ProtocolSchedule protocolSchedule, final long blockTimestamp, final long blockNumber) { - return getRequestValidator(protocolSchedule, blockTimestamp, blockNumber, RequestType.DEPOSIT); - } - - public static RequestValidator getWithdrawalRequestValidator( - final ProtocolSchedule protocolSchedule, final long blockTimestamp, final long blockNumber) { - return getRequestValidator( - protocolSchedule, blockTimestamp, blockNumber, RequestType.WITHDRAWAL); - } - - public static RequestValidator getConsolidationRequestValidator( - final ProtocolSchedule protocolSchedule, final long blockTimestamp, final long blockNumber) { - return getRequestValidator( - protocolSchedule, blockTimestamp, blockNumber, RequestType.CONSOLIDATION); - } - - private static RequestValidator getRequestValidator( - final ProtocolSchedule protocolSchedule, - final long blockTimestamp, - final long blockNumber, - final RequestType requestType) { - - RequestsValidatorCoordinator requestsValidatorCoordinator = - getRequestValidatorCoordinator(protocolSchedule, blockTimestamp, blockNumber); - return requestsValidatorCoordinator - .getRequestValidator(requestType) - .orElse(new ProhibitedRequestsValidator()); - } - - private static RequestsValidatorCoordinator getRequestValidatorCoordinator( - final ProtocolSchedule protocolSchedule, final long blockTimestamp, final long blockNumber) { - final BlockHeader blockHeader = BlockHeaderBuilder.createDefault() .timestamp(blockTimestamp) .number(blockNumber) .buildBlockHeader(); - return getRequestValidatorCoordinator(protocolSchedule.getByBlockHeader(blockHeader)); - } - - private static RequestsValidatorCoordinator getRequestValidatorCoordinator( - final ProtocolSpec protocolSchedule) { - return Optional.ofNullable(protocolSchedule) - .map(ProtocolSpec::getRequestsValidatorCoordinator) - .orElseGet(RequestsValidatorCoordinator::empty); + return Optional.ofNullable(protocolSchedule.getByBlockHeader(blockHeader)) + .map(ProtocolSpec::getRequestsValidator) + .orElse(v -> true); } } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/ConsolidationRequestParameter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/ConsolidationRequestParameter.java deleted file mode 100644 index c6c600329d..0000000000 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/ConsolidationRequestParameter.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.api.jsonrpc.internal.parameters; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.ethereum.core.ConsolidationRequest; - -import java.util.Objects; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonGetter; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class ConsolidationRequestParameter { - - private final String sourceAddress; - private final String sourcePubkey; - private final String targetPubkey; - - @JsonCreator - public ConsolidationRequestParameter( - @JsonProperty("sourceAddress") final String sourceAddress, - @JsonProperty("sourcePubkey") final String sourcePubkey, - @JsonProperty("targetPubkey") final String targetPubkey) { - this.sourceAddress = sourceAddress; - this.sourcePubkey = sourcePubkey; - this.targetPubkey = targetPubkey; - } - - public static ConsolidationRequestParameter fromConsolidationRequest( - final ConsolidationRequest consolidationRequest) { - return new ConsolidationRequestParameter( - consolidationRequest.getSourceAddress().toHexString(), - consolidationRequest.getSourcePubkey().toHexString(), - consolidationRequest.getTargetPubkey().toHexString()); - } - - public ConsolidationRequest toConsolidationRequest() { - return new ConsolidationRequest( - Address.fromHexString(sourceAddress), - BLSPublicKey.fromHexString(sourcePubkey), - BLSPublicKey.fromHexString(targetPubkey)); - } - - @JsonGetter - public String getSourceAddress() { - return sourceAddress; - } - - @JsonGetter - public String getSourcePubkey() { - return sourcePubkey; - } - - @JsonGetter - public String getTargetPubkey() { - return targetPubkey; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final ConsolidationRequestParameter that = (ConsolidationRequestParameter) o; - return Objects.equals(sourceAddress, that.sourceAddress) - && Objects.equals(sourcePubkey, that.sourcePubkey) - && Objects.equals(targetPubkey, that.targetPubkey); - } - - @Override - public int hashCode() { - return Objects.hash(sourceAddress, sourcePubkey, targetPubkey); - } - - @Override - public String toString() { - return "ConsolidationRequestParameter{" - + "sourceAddress='" - + sourceAddress - + '\'' - + ", sourcePubkey='" - + sourcePubkey - + '\'' - + ", targetPubkey='" - + targetPubkey - + '\'' - + '}'; - } -} diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositRequestParameter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositRequestParameter.java deleted file mode 100644 index 39d6476ca4..0000000000 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositRequestParameter.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.api.jsonrpc.internal.parameters; - -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.BLSSignature; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.ethereum.core.DepositRequest; - -import java.util.Objects; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonGetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.vertx.core.json.JsonObject; -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.units.bigints.UInt64; - -public class DepositRequestParameter { - - private final String pubkey; - - private final String withdrawalCredentials; - private final String amount; - - private final String signature; - private final String index; - - @JsonCreator - public DepositRequestParameter( - @JsonProperty("pubkey") final String pubkey, - @JsonProperty("withdrawalCredentials") final String withdrawalCredentials, - @JsonProperty("amount") final String amount, - @JsonProperty("signature") final String signature, - @JsonProperty("index") final String index) { - this.pubkey = pubkey; - this.withdrawalCredentials = withdrawalCredentials; - this.amount = amount; - this.signature = signature; - this.index = index; - } - - public static DepositRequestParameter fromDeposit(final DepositRequest depositRequest) { - return new DepositRequestParameter( - depositRequest.getPubkey().toString(), - depositRequest.getWithdrawalCredentials().toString(), - depositRequest.getAmount().toShortHexString(), - depositRequest.getSignature().toString(), - depositRequest.getIndex().toBytes().toQuantityHexString()); - } - - public DepositRequest toDeposit() { - return new DepositRequest( - BLSPublicKey.fromHexString(pubkey), - Bytes32.fromHexString(withdrawalCredentials), - GWei.fromHexString(amount), - BLSSignature.fromHexString(signature), - UInt64.fromHexString(index)); - } - - public JsonObject asJsonObject() { - return new JsonObject() - .put("pubkey", pubkey) - .put("withdrawalCredentials", withdrawalCredentials) - .put("amount", amount) - .put("signature", signature) - .put("index", index); - } - - @JsonGetter - public String getPubkey() { - return pubkey; - } - - @JsonGetter - public String getWithdrawalCredentials() { - return withdrawalCredentials; - } - - @JsonGetter - public String getAmount() { - return amount; - } - - @JsonGetter - public String getSignature() { - return signature; - } - - @JsonGetter - public String getIndex() { - return index; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final DepositRequestParameter that = (DepositRequestParameter) o; - return Objects.equals(pubkey, that.pubkey) - && Objects.equals(withdrawalCredentials, that.withdrawalCredentials) - && Objects.equals(amount, that.amount) - && Objects.equals(signature, that.signature) - && Objects.equals(index, that.index); - } - - @Override - public int hashCode() { - return Objects.hash(pubkey, withdrawalCredentials, amount, signature, index); - } - - @Override - public String toString() { - return "DepositRequestParameter{" - + "pubKey='" - + pubkey - + '\'' - + ", withdrawalCredentials='" - + withdrawalCredentials - + '\'' - + ", amount='" - + amount - + '\'' - + ", signature='" - + signature - + '\'' - + ", index='" - + index - + '\'' - + '}'; - } -} diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/EnginePayloadParameter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/EnginePayloadParameter.java index fdcec45c6b..415ba3c69b 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/EnginePayloadParameter.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/EnginePayloadParameter.java @@ -43,9 +43,6 @@ public class EnginePayloadParameter { private final List withdrawals; private final Long blobGasUsed; private final String excessBlobGas; - private final List depositRequests; - private final List withdrawalRequests; - private final List consolidationRequests; /** * Creates an instance of EnginePayloadParameter. @@ -67,9 +64,6 @@ public class EnginePayloadParameter { * @param withdrawals Array of Withdrawal * @param blobGasUsed QUANTITY, 64 Bits * @param excessBlobGas QUANTITY, 64 Bits - * @param depositRequests List of deposit parameters. - * @param withdrawalRequestParameters List of withdrawal requests parameters. - * @param consolidationRequests List of consolidation requests parameters. */ @JsonCreator public EnginePayloadParameter( @@ -89,12 +83,7 @@ public class EnginePayloadParameter { @JsonProperty("transactions") final List transactions, @JsonProperty("withdrawals") final List withdrawals, @JsonProperty("blobGasUsed") final UnsignedLongParameter blobGasUsed, - @JsonProperty("excessBlobGas") final String excessBlobGas, - @JsonProperty("depositRequests") final List depositRequests, - @JsonProperty("withdrawalRequests") - final List withdrawalRequestParameters, - @JsonProperty("consolidationRequests") - final List consolidationRequests) { + @JsonProperty("excessBlobGas") final String excessBlobGas) { this.blockHash = blockHash; this.parentHash = parentHash; this.feeRecipient = feeRecipient; @@ -112,9 +101,6 @@ public class EnginePayloadParameter { this.withdrawals = withdrawals; this.blobGasUsed = blobGasUsed == null ? null : blobGasUsed.getValue(); this.excessBlobGas = excessBlobGas; - this.depositRequests = depositRequests; - this.withdrawalRequests = withdrawalRequestParameters; - this.consolidationRequests = consolidationRequests; } public Hash getBlockHash() { @@ -184,16 +170,4 @@ public class EnginePayloadParameter { public String getExcessBlobGas() { return excessBlobGas; } - - public List getDepositRequests() { - return depositRequests; - } - - public List getWithdrawalRequests() { - return withdrawalRequests; - } - - public List getConsolidationRequests() { - return consolidationRequests; - } } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/WithdrawalRequestParameter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/WithdrawalRequestParameter.java deleted file mode 100644 index 3561da37a8..0000000000 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/WithdrawalRequestParameter.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.api.jsonrpc.internal.parameters; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; - -import java.util.Objects; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonGetter; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class WithdrawalRequestParameter { - - private final String sourceAddress; - private final String validatorPubkey; - private final String amount; - - @JsonCreator - public WithdrawalRequestParameter( - @JsonProperty("sourceAddress") final String sourceAddress, - @JsonProperty("validatorPubkey") final String validatorPubkey, - @JsonProperty("amount") final String amount) { - this.sourceAddress = sourceAddress; - this.validatorPubkey = validatorPubkey; - this.amount = amount; - } - - public static WithdrawalRequestParameter fromWithdrawalRequest( - final WithdrawalRequest withdrawalRequest) { - return new WithdrawalRequestParameter( - withdrawalRequest.getSourceAddress().toHexString(), - withdrawalRequest.getValidatorPubkey().toHexString(), - withdrawalRequest.getAmount().toShortHexString()); - } - - public WithdrawalRequest toWithdrawalRequest() { - return new WithdrawalRequest( - Address.fromHexString(sourceAddress), - BLSPublicKey.fromHexString(validatorPubkey), - GWei.fromHexString(amount)); - } - - @JsonGetter - public String getSourceAddress() { - return sourceAddress; - } - - @JsonGetter - public String getValidatorPubkey() { - return validatorPubkey; - } - - @JsonGetter - public String getAmount() { - return amount; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final WithdrawalRequestParameter that = (WithdrawalRequestParameter) o; - return Objects.equals(sourceAddress, that.sourceAddress) - && Objects.equals(validatorPubkey, that.validatorPubkey) - && Objects.equals(amount, that.amount); - } - - @Override - public int hashCode() { - return Objects.hash(sourceAddress, validatorPubkey, amount); - } - - @Override - public String toString() { - return "WithdrawalRequestParameter{" - + "sourceAddress='" - + sourceAddress - + '\'' - + ", validatorPubkey='" - + validatorPubkey - + '\'' - + ", amount='" - + amount - + '\'' - + '}'; - } -} diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/RpcErrorType.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/RpcErrorType.java index 875eab601b..a2b7d17591 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/RpcErrorType.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/RpcErrorType.java @@ -62,6 +62,7 @@ public enum RpcErrorType implements RpcMethodError { INVALID_ENODE_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid enode params"), INVALID_EXCESS_BLOB_GAS_PARAMS( INVALID_PARAMS_ERROR_CODE, "Invalid excess blob gas params (missing or invalid)"), + INVALID_EXECUTION_REQUESTS_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid execution requests params"), INVALID_EXTRA_DATA_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid extra data params"), INVALID_FILTER_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid filter params"), INVALID_GAS_PRICE_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid gas price params"), diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockResultFactory.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockResultFactory.java index b8111c00c7..66bb879569 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockResultFactory.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockResultFactory.java @@ -14,10 +14,6 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.results; -import static org.hyperledger.besu.ethereum.mainnet.requests.RequestUtil.getConsolidationRequests; -import static org.hyperledger.besu.ethereum.mainnet.requests.RequestUtil.getDepositRequests; -import static org.hyperledger.besu.ethereum.mainnet.requests.RequestUtil.getWithdrawalRequests; - import org.hyperledger.besu.consensus.merge.PayloadWrapper; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EngineGetPayloadBodiesResultV1.PayloadBody; @@ -26,10 +22,12 @@ import org.hyperledger.besu.ethereum.api.query.TransactionWithMetadata; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; +import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.encoding.EncodingContext; import org.hyperledger.besu.ethereum.core.encoding.TransactionEncoder; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; @@ -162,6 +160,15 @@ public class BlockResultFactory { TransactionEncoder.encodeOpaqueBytes(transaction, EncodingContext.BLOCK_BODY)) .map(Bytes::toHexString) .collect(Collectors.toList()); + final Optional> requestsWithoutRequestId = + payload + .requests() + .map( + rqs -> + rqs.stream() + .sorted(Comparator.comparing(Request::getType)) + .map(r -> r.getData().toHexString()) + .toList()); final BlobsBundleV1 blobsBundleV1 = new BlobsBundleV1(blockWithReceipts.getBlock().getBody().getTransactions()); @@ -169,9 +176,7 @@ public class BlockResultFactory { blockWithReceipts.getHeader(), txs, blockWithReceipts.getBlock().getBody().getWithdrawals(), - getDepositRequests(blockWithReceipts.getBlock().getBody().getRequests()), - getWithdrawalRequests(blockWithReceipts.getBlock().getBody().getRequests()), - getConsolidationRequests(blockWithReceipts.getBlock().getBody().getRequests()), + requestsWithoutRequestId, Quantity.create(payload.blockValue()), blobsBundleV1); } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV4.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV4.java index 39772ff7db..017de4653c 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV4.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV4.java @@ -14,15 +14,9 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.results; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.ConsolidationRequestParameter; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositRequestParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalRequestParameter; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.ConsolidationRequest; -import org.hyperledger.besu.ethereum.core.DepositRequest; import org.hyperledger.besu.ethereum.core.Withdrawal; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; import java.util.List; import java.util.Optional; @@ -33,33 +27,32 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import org.apache.tuweni.bytes.Bytes32; -@JsonPropertyOrder({"executionPayload", "blockValue", "blobsBundle", "shouldOverrideBuilder"}) +@JsonPropertyOrder({ + "executionPayload", + "blockValue", + "blobsBundle", + "shouldOverrideBuilder", + "executionRequests" +}) public class EngineGetPayloadResultV4 { protected final PayloadResult executionPayload; private final String blockValue; private final BlobsBundleV1 blobsBundle; private final boolean shouldOverrideBuilder; + private final List executionRequests; public EngineGetPayloadResultV4( final BlockHeader header, final List transactions, final Optional> withdrawals, - final Optional> depositRequests, - final Optional> withdrawalRequests, - final Optional> consolidationRequests, + final Optional> executionRequests, final String blockValue, final BlobsBundleV1 blobsBundle) { - this.executionPayload = - new PayloadResult( - header, - transactions, - withdrawals, - depositRequests, - withdrawalRequests, - consolidationRequests); + this.executionPayload = new PayloadResult(header, transactions, withdrawals); this.blockValue = blockValue; this.blobsBundle = blobsBundle; this.shouldOverrideBuilder = false; + this.executionRequests = executionRequests.orElse(null); } @JsonGetter(value = "executionPayload") @@ -82,6 +75,11 @@ public class EngineGetPayloadResultV4 { return shouldOverrideBuilder; } + @JsonGetter(value = "executionRequests") + public List getExecutionRequests() { + return executionRequests; + } + public static class PayloadResult { protected final String blockHash; @@ -103,17 +101,11 @@ public class EngineGetPayloadResultV4 { protected final List transactions; private final List withdrawals; - private final List depositRequests; - private final List withdrawalRequests; - private final List consolidationRequests; public PayloadResult( final BlockHeader header, final List transactions, - final Optional> withdrawals, - final Optional> depositRequests, - final Optional> withdrawalRequests, - final Optional> consolidationRequests) { + final Optional> withdrawals) { this.blockNumber = Quantity.create(header.getNumber()); this.blockHash = header.getHash().toString(); this.parentHash = header.getParentHash().toString(); @@ -136,30 +128,6 @@ public class EngineGetPayloadResultV4 { .map(WithdrawalParameter::fromWithdrawal) .collect(Collectors.toList())) .orElse(null); - this.depositRequests = - depositRequests - .map( - ds -> - ds.stream() - .map(DepositRequestParameter::fromDeposit) - .collect(Collectors.toList())) - .orElse(null); - this.withdrawalRequests = - withdrawalRequests - .map( - wr -> - wr.stream() - .map(WithdrawalRequestParameter::fromWithdrawalRequest) - .collect(Collectors.toList())) - .orElse(null); - this.consolidationRequests = - consolidationRequests - .map( - wr -> - wr.stream() - .map(ConsolidationRequestParameter::fromConsolidationRequest) - .collect(Collectors.toList())) - .orElse(null); this.blobGasUsed = header.getBlobGasUsed().map(Quantity::create).orElse(Quantity.HEX_ZERO); this.excessBlobGas = header.getExcessBlobGas().map(Quantity::create).orElse(Quantity.HEX_ZERO); @@ -237,21 +205,6 @@ public class EngineGetPayloadResultV4 { return withdrawals; } - @JsonGetter(value = "depositRequests") - public List getDepositRequests() { - return depositRequests; - } - - @JsonGetter(value = "withdrawalRequests") - public List getWithdrawalRequests() { - return withdrawalRequests; - } - - @JsonGetter(value = "consolidationRequests") - public List getConsolidationRequests() { - return consolidationRequests; - } - @JsonGetter(value = "feeRecipient") @JsonInclude(JsonInclude.Include.NON_NULL) public String getFeeRecipient() { diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineGetPayloadTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineGetPayloadTest.java index f18b5601cf..1cfc51396d 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineGetPayloadTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineGetPayloadTest.java @@ -99,32 +99,27 @@ public abstract class AbstractEngineGetPayloadTest extends AbstractScheduledApiT protected static final BlockWithReceipts mockBlockWithReceipts = new BlockWithReceipts(mockBlock, Collections.emptyList()); protected static final PayloadWrapper mockPayload = - new PayloadWrapper(mockPid, mockBlockWithReceipts); + new PayloadWrapper(mockPid, mockBlockWithReceipts, Optional.empty()); private static final Block mockBlockWithWithdrawals = new Block( mockHeader, new BlockBody( Collections.emptyList(), Collections.emptyList(), - Optional.of(Collections.emptyList()), - Optional.empty())); + Optional.of(Collections.emptyList()))); private static final Block mockBlockWithDepositRequests = new Block( mockHeader, - new BlockBody( - Collections.emptyList(), - Collections.emptyList(), - Optional.empty(), - Optional.of(Collections.emptyList()))); + new BlockBody(Collections.emptyList(), Collections.emptyList(), Optional.empty())); protected static final BlockWithReceipts mockBlockWithReceiptsAndWithdrawals = new BlockWithReceipts(mockBlockWithWithdrawals, Collections.emptyList()); protected static final PayloadWrapper mockPayloadWithWithdrawals = - new PayloadWrapper(mockPid, mockBlockWithReceiptsAndWithdrawals); + new PayloadWrapper(mockPid, mockBlockWithReceiptsAndWithdrawals, Optional.empty()); protected static final BlockWithReceipts mockBlockWithReceiptsAndDepositRequests = new BlockWithReceipts(mockBlockWithDepositRequests, Collections.emptyList()); protected static final PayloadWrapper mockPayloadWithDepositRequests = - new PayloadWrapper(mockPid, mockBlockWithReceiptsAndDepositRequests); + new PayloadWrapper(mockPid, mockBlockWithReceiptsAndDepositRequests, Optional.empty()); @Mock protected ProtocolContext protocolContext; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayloadTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayloadTest.java index 9b3e94330e..e793ee8b57 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayloadTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayloadTest.java @@ -38,12 +38,9 @@ import org.hyperledger.besu.ethereum.ProtocolContext; 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.methods.ExecutionEngineJsonRpcMethod; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.ConsolidationRequestParameter; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositRequestParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.UnsignedLongParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalRequestParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; @@ -54,20 +51,17 @@ import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; -import org.hyperledger.besu.ethereum.core.DepositRequest; import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Withdrawal; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; import org.hyperledger.besu.ethereum.eth.manager.EthPeers; import org.hyperledger.besu.ethereum.mainnet.BodyValidation; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; import org.hyperledger.besu.ethereum.mainnet.WithdrawalsValidator; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; +import org.hyperledger.besu.ethereum.mainnet.requests.ProhibitedRequestValidator; import org.hyperledger.besu.ethereum.trie.MerkleTrieException; import org.hyperledger.besu.plugin.services.exception.StorageException; import org.hyperledger.besu.plugin.services.rpc.RpcResponseType; -import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Optional; @@ -130,7 +124,6 @@ public abstract class AbstractEngineNewPayloadTest extends AbstractScheduledApiT setupValidPayload( new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))), Optional.empty(), - Optional.empty(), Optional.empty()); lenient() .when(blockchain.getBlockHeader(mockHeader.getParentHash())) @@ -144,10 +137,7 @@ public abstract class AbstractEngineNewPayloadTest extends AbstractScheduledApiT public void shouldReturnInvalidOnBlockExecutionError() { BlockHeader mockHeader = setupValidPayload( - new BlockProcessingResult("error 42"), - Optional.empty(), - Optional.empty(), - Optional.empty()); + new BlockProcessingResult("error 42"), Optional.empty(), Optional.empty()); lenient() .when(blockchain.getBlockHeader(mockHeader.getParentHash())) .thenReturn(Optional.of(mock(BlockHeader.class))); @@ -162,8 +152,7 @@ public abstract class AbstractEngineNewPayloadTest extends AbstractScheduledApiT @Test public void shouldReturnAcceptedOnLatestValidAncestorEmpty() { - BlockHeader mockHeader = - createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()); + BlockHeader mockHeader = createBlockHeader(Optional.empty(), Optional.empty()); when(blockchain.getBlockByHash(mockHeader.getHash())).thenReturn(Optional.empty()); when(blockchain.getBlockHeader(mockHeader.getParentHash())) .thenReturn(Optional.of(mock(BlockHeader.class))); @@ -181,8 +170,7 @@ public abstract class AbstractEngineNewPayloadTest extends AbstractScheduledApiT @Test public void shouldReturnSuccessOnAlreadyPresent() { - BlockHeader mockHeader = - createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()); + BlockHeader mockHeader = createBlockHeader(Optional.empty(), Optional.empty()); Block mockBlock = new Block(mockHeader, new BlockBody(Collections.emptyList(), Collections.emptyList())); @@ -195,8 +183,7 @@ public abstract class AbstractEngineNewPayloadTest extends AbstractScheduledApiT @Test public void shouldReturnInvalidWithLatestValidHashIsABadBlock() { - BlockHeader mockHeader = - createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()); + BlockHeader mockHeader = createBlockHeader(Optional.empty(), Optional.empty()); Hash latestValidHash = Hash.hash(Bytes32.fromHexStringLenient("0xcafebabe")); when(blockchain.getBlockByHash(mockHeader.getHash())).thenReturn(Optional.empty()); @@ -218,7 +205,6 @@ public abstract class AbstractEngineNewPayloadTest extends AbstractScheduledApiT setupValidPayload( new BlockProcessingResult(Optional.empty(), new StorageException("database bedlam")), Optional.empty(), - Optional.empty(), Optional.empty()); lenient() .when(blockchain.getBlockHeader(mockHeader.getParentHash())) @@ -235,7 +221,6 @@ public abstract class AbstractEngineNewPayloadTest extends AbstractScheduledApiT setupValidPayload( new BlockProcessingResult(Optional.empty(), new MerkleTrieException("missing leaf")), Optional.empty(), - Optional.empty(), Optional.empty()); lenient() @@ -250,8 +235,7 @@ public abstract class AbstractEngineNewPayloadTest extends AbstractScheduledApiT @Test public void shouldNotReturnInvalidOnThrownMerkleTrieException() { - BlockHeader mockHeader = - createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()); + BlockHeader mockHeader = createBlockHeader(Optional.empty(), Optional.empty()); when(blockchain.getBlockByHash(mockHeader.getHash())).thenReturn(Optional.empty()); when(blockchain.getBlockHeader(mockHeader.getParentHash())) .thenReturn(Optional.of(mock(BlockHeader.class))); @@ -268,8 +252,7 @@ public abstract class AbstractEngineNewPayloadTest extends AbstractScheduledApiT @Test public void shouldReturnInvalidBlockHashOnBadHashParameter() { - BlockHeader mockHeader = - spy(createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty())); + BlockHeader mockHeader = spy(createBlockHeader(Optional.empty(), Optional.empty())); lenient() .when(mergeCoordinator.getLatestValidAncestor(mockHeader.getBlockHash())) .thenReturn(Optional.empty()); @@ -286,8 +269,7 @@ public abstract class AbstractEngineNewPayloadTest extends AbstractScheduledApiT @Test public void shouldCheckBlockValidityBeforeCheckingByHashForExisting() { - BlockHeader realHeader = - createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()); + BlockHeader realHeader = createBlockHeader(Optional.empty(), Optional.empty()); BlockHeader paramHeader = spy(realHeader); when(paramHeader.getHash()).thenReturn(Hash.fromHexStringLenient("0x1337")); @@ -301,8 +283,7 @@ public abstract class AbstractEngineNewPayloadTest extends AbstractScheduledApiT @Test public void shouldReturnInvalidOnMalformedTransactions() { - BlockHeader mockHeader = - createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()); + BlockHeader mockHeader = createBlockHeader(Optional.empty(), Optional.empty()); when(mergeCoordinator.getLatestValidAncestor(any(Hash.class))) .thenReturn(Optional.of(mockHash)); @@ -317,8 +298,7 @@ public abstract class AbstractEngineNewPayloadTest extends AbstractScheduledApiT @Test public void shouldRespondWithSyncingDuringForwardSync() { - BlockHeader mockHeader = - createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()); + BlockHeader mockHeader = createBlockHeader(Optional.empty(), Optional.empty()); when(mergeContext.isSyncing()).thenReturn(Boolean.TRUE); var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList())); @@ -331,8 +311,7 @@ public abstract class AbstractEngineNewPayloadTest extends AbstractScheduledApiT @Test public void shouldRespondWithSyncingDuringBackwardsSync() { - BlockHeader mockHeader = - createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()); + BlockHeader mockHeader = createBlockHeader(Optional.empty(), Optional.empty()); when(mergeCoordinator.appendNewPayloadToSync(any())) .thenReturn(CompletableFuture.completedFuture(null)); var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList())); @@ -346,8 +325,7 @@ public abstract class AbstractEngineNewPayloadTest extends AbstractScheduledApiT @Test public void shouldRespondWithInvalidIfExtraDataIsNull() { - BlockHeader realHeader = - createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()); + BlockHeader realHeader = createBlockHeader(Optional.empty(), Optional.empty()); BlockHeader paramHeader = spy(realHeader); when(paramHeader.getHash()).thenReturn(Hash.fromHexStringLenient("0x1337")); when(paramHeader.getExtraData().toHexString()).thenReturn(null); @@ -364,8 +342,7 @@ public abstract class AbstractEngineNewPayloadTest extends AbstractScheduledApiT @Test public void shouldReturnInvalidWhenBadBlock() { when(mergeCoordinator.isBadBlock(any(Hash.class))).thenReturn(true); - BlockHeader mockHeader = - createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()); + BlockHeader mockHeader = createBlockHeader(Optional.empty(), Optional.empty()); var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList())); when(protocolSpec.getWithdrawalsValidator()) .thenReturn(new WithdrawalsValidator.AllowedWithdrawals()); @@ -383,7 +360,6 @@ public abstract class AbstractEngineNewPayloadTest extends AbstractScheduledApiT setupValidPayload( new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))), Optional.empty(), - Optional.empty(), Optional.empty()); lenient() .when(blockchain.getBlockHeader(mockHeader.getParentHash())) @@ -404,16 +380,13 @@ public abstract class AbstractEngineNewPayloadTest extends AbstractScheduledApiT protected EnginePayloadParameter mockEnginePayload( final BlockHeader header, final List txs) { - return mockEnginePayload(header, txs, null, null, null, null); + return mockEnginePayload(header, txs, null); } protected EnginePayloadParameter mockEnginePayload( final BlockHeader header, final List txs, - final List withdrawals, - final List depositRequests, - final List withdrawalRequests, - final List consolidationRequests) { + final List withdrawals) { return new EnginePayloadParameter( header.getHash(), header.getParentHash(), @@ -431,23 +404,16 @@ public abstract class AbstractEngineNewPayloadTest extends AbstractScheduledApiT txs, withdrawals, header.getBlobGasUsed().map(UnsignedLongParameter::new).orElse(null), - header.getExcessBlobGas().map(BlobGas::toHexString).orElse(null), - depositRequests, - withdrawalRequests, - consolidationRequests); + header.getExcessBlobGas().map(BlobGas::toHexString).orElse(null)); } protected BlockHeader setupValidPayload( final BlockProcessingResult value, final Optional> maybeWithdrawals, - final Optional> maybeDepositRequests, - final Optional> maybeWithdrawalRequests) { + final Optional> maybeRequests) { - BlockHeader mockHeader = - createBlockHeader(maybeWithdrawals, maybeDepositRequests, maybeWithdrawalRequests); + BlockHeader mockHeader = createBlockHeader(maybeWithdrawals, maybeRequests); when(blockchain.getBlockByHash(mockHeader.getHash())).thenReturn(Optional.empty()); - // when(blockchain.getBlockHeader(mockHeader.getParentHash())) - // .thenReturn(Optional.of(mock(BlockHeader.class))); when(mergeCoordinator.getLatestValidAncestor(any(BlockHeader.class))) .thenReturn(Optional.of(mockHash)); when(mergeCoordinator.rememberBlock(any())).thenReturn(value); @@ -477,27 +443,8 @@ public abstract class AbstractEngineNewPayloadTest extends AbstractScheduledApiT protected BlockHeader createBlockHeader( final Optional> maybeWithdrawals, - final Optional> maybeDepositRequests, - final Optional> maybeWithdrawalRequests) { - return createBlockHeaderFixture(maybeWithdrawals, maybeDepositRequests, maybeWithdrawalRequests) - .buildHeader(); - } - - protected BlockHeaderTestFixture createBlockHeaderFixture( - final Optional> maybeWithdrawals, - final Optional> maybeDepositRequests, - final Optional> maybeWithdrawalRequests) { - - Optional> maybeRequests; - if (maybeDepositRequests.isPresent() || maybeWithdrawalRequests.isPresent()) { - List requests = new ArrayList<>(); - maybeDepositRequests.ifPresent(requests::addAll); - maybeWithdrawalRequests.ifPresent(requests::addAll); - maybeRequests = Optional.of(requests); - } else { - maybeRequests = Optional.empty(); - } - return createBlockHeaderFixture(maybeWithdrawals, maybeRequests); + final Optional> maybeRequests) { + return createBlockHeaderFixture(maybeWithdrawals, maybeRequests).buildHeader(); } protected BlockHeaderTestFixture createBlockHeaderFixture( @@ -512,7 +459,7 @@ public abstract class AbstractEngineNewPayloadTest extends AbstractScheduledApiT .timestamp(parentBlockHeader.getTimestamp() + 1) .withdrawalsRoot(maybeWithdrawals.map(BodyValidation::withdrawalsRoot).orElse(null)) .parentBeaconBlockRoot(maybeParentBeaconBlockRoot) - .requestsRoot(maybeRequests.map(BodyValidation::requestsRoot).orElse(null)); + .requestsHash(maybeRequests.map(BodyValidation::requestsHash).orElse(null)); } protected void assertValidResponse(final BlockHeader mockHeader, final JsonRpcResponse resp) { @@ -524,7 +471,7 @@ public abstract class AbstractEngineNewPayloadTest extends AbstractScheduledApiT } private void mockProhibitedRequestsValidator() { - var validator = RequestsValidatorCoordinator.empty(); - when(protocolSpec.getRequestsValidatorCoordinator()).thenReturn(validator); + var validator = new ProhibitedRequestValidator(); + when(protocolSpec.getRequestsValidator()).thenReturn(validator); } } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByHashV1Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByHashV1Test.java index 8a99fa9439..f7752a7977 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByHashV1Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByHashV1Test.java @@ -180,7 +180,6 @@ public class EngineGetPayloadBodiesByHashV1Test { new BlockBody( List.of(new TransactionTestFixture().createTransaction(sig.generateKeyPair())), Collections.emptyList(), - Optional.empty(), Optional.empty()); when(blockchain.getBlockBody(blockHash1)).thenReturn(Optional.of(preShanghaiBlockBody)); when(blockchain.getBlockBody(blockHash2)).thenReturn(Optional.of(preShanghaiBlockBody2)); @@ -211,15 +210,13 @@ public class EngineGetPayloadBodiesByHashV1Test { new TransactionTestFixture().createTransaction(sig.generateKeyPair()), new TransactionTestFixture().createTransaction(sig.generateKeyPair())), Collections.emptyList(), - Optional.of(List.of(withdrawal)), - Optional.empty()); + Optional.of(List.of(withdrawal))); final BlockBody shanghaiBlockBody2 = new BlockBody( List.of(new TransactionTestFixture().createTransaction(sig.generateKeyPair())), Collections.emptyList(), - Optional.of(List.of(withdrawal2)), - Optional.empty()); + Optional.of(List.of(withdrawal2))); when(blockchain.getBlockBody(blockHash1)).thenReturn(Optional.of(shanghaiBlockBody)); when(blockchain.getBlockBody(blockHash2)).thenReturn(Optional.of(shanghaiBlockBody2)); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByRangeV1Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByRangeV1Test.java index 6bc89ba679..886903ee09 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByRangeV1Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByRangeV1Test.java @@ -179,7 +179,6 @@ public class EngineGetPayloadBodiesByRangeV1Test { new BlockBody( List.of(new TransactionTestFixture().createTransaction(sig.generateKeyPair())), Collections.emptyList(), - Optional.empty(), Optional.empty()); when(blockchain.getChainHeadBlockNumber()).thenReturn(Long.valueOf(130)); when(blockchain.getBlockBody(blockHash1)).thenReturn(Optional.of(preShanghaiBlockBody)); @@ -214,15 +213,13 @@ public class EngineGetPayloadBodiesByRangeV1Test { new TransactionTestFixture().createTransaction(sig.generateKeyPair()), new TransactionTestFixture().createTransaction(sig.generateKeyPair())), Collections.emptyList(), - Optional.of(List.of(withdrawal)), - Optional.empty()); + Optional.of(List.of(withdrawal))); final BlockBody shanghaiBlockBody2 = new BlockBody( List.of(new TransactionTestFixture().createTransaction(sig.generateKeyPair())), Collections.emptyList(), - Optional.of(List.of(withdrawal2)), - Optional.empty()); + Optional.of(List.of(withdrawal2))); when(blockchain.getChainHeadBlockNumber()).thenReturn(Long.valueOf(130)); when(blockchain.getBlockBody(blockHash1)).thenReturn(Optional.of(shanghaiBlockBody)); when(blockchain.getBlockBody(blockHash2)).thenReturn(Optional.of(shanghaiBlockBody2)); @@ -252,8 +249,7 @@ public class EngineGetPayloadBodiesByRangeV1Test { new TransactionTestFixture().createTransaction(sig.generateKeyPair()), new TransactionTestFixture().createTransaction(sig.generateKeyPair())), Collections.emptyList(), - Optional.of(List.of(withdrawal)), - Optional.empty()); + Optional.of(List.of(withdrawal))); when(blockchain.getChainHeadBlockNumber()).thenReturn(Long.valueOf(123)); when(blockchain.getBlockBody(blockHash1)).thenReturn(Optional.of(shanghaiBlockBody)); when(blockchain.getBlockHashByNumber(123)).thenReturn(Optional.of(blockHash1)); @@ -276,20 +272,17 @@ public class EngineGetPayloadBodiesByRangeV1Test { new BlockBody( List.of(new TransactionTestFixture().createTransaction(sig.generateKeyPair())), Collections.emptyList(), - Optional.of(List.of(withdrawal)), - Optional.empty()); + Optional.of(List.of(withdrawal))); final BlockBody shanghaiBlockBody2 = new BlockBody( List.of(new TransactionTestFixture().createTransaction(sig.generateKeyPair())), Collections.emptyList(), - Optional.of(List.of(withdrawal)), - Optional.empty()); + Optional.of(List.of(withdrawal))); final BlockBody shanghaiBlockBody3 = new BlockBody( List.of(new TransactionTestFixture().createTransaction(sig.generateKeyPair())), Collections.emptyList(), - Optional.of(List.of(withdrawal)), - Optional.empty()); + Optional.of(List.of(withdrawal))); when(blockchain.getChainHeadBlockNumber()).thenReturn(Long.valueOf(125)); when(blockchain.getBlockBody(blockHash1)).thenReturn(Optional.of(shanghaiBlockBody)); when(blockchain.getBlockBody(blockHash2)).thenReturn(Optional.of(shanghaiBlockBody2)); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV2Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV2Test.java index 5c455222f1..fcbe179a52 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV2Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV2Test.java @@ -124,7 +124,8 @@ public class EngineGetPayloadV2Test extends AbstractEngineGetPayloadTest { new Block(mockHeader, new BlockBody(Collections.emptyList(), Collections.emptyList())); final BlockWithReceipts mockBlockWithReceipts = new BlockWithReceipts(mockBlock, Collections.emptyList()); - final PayloadWrapper mockPayload = new PayloadWrapper(mockPid, mockBlockWithReceipts); + final PayloadWrapper mockPayload = + new PayloadWrapper(mockPid, mockBlockWithReceipts, Optional.empty()); when(mergeContext.retrievePayloadById(mockPid)).thenReturn(Optional.of(mockPayload)); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV3Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV3Test.java index ac589c1121..1fe3b44d45 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV3Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV3Test.java @@ -128,10 +128,10 @@ public class EngineGetPayloadV3Test extends AbstractEngineGetPayloadTest { new BlockBody( List.of(blobTx), Collections.emptyList(), - Optional.of(Collections.emptyList()), Optional.of(Collections.emptyList()))), List.of(blobReceipt)); - PayloadWrapper payloadPostCancun = new PayloadWrapper(postCancunPid, postCancunBlock); + PayloadWrapper payloadPostCancun = + new PayloadWrapper(postCancunPid, postCancunBlock, Optional.empty()); when(mergeContext.retrievePayloadById(postCancunPid)) .thenReturn(Optional.of(payloadPostCancun)); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV4Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV4Test.java index 134c7a2c0c..744600ddca 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV4Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV4Test.java @@ -14,6 +14,7 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine; +import static java.util.Collections.emptyList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.mock; @@ -27,6 +28,7 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.BlobGas; import org.hyperledger.besu.datatypes.BlobsWithCommitments; import org.hyperledger.besu.datatypes.Hash; +import org.hyperledger.besu.datatypes.RequestType; import org.hyperledger.besu.datatypes.TransactionType; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; @@ -41,12 +43,13 @@ import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.BlockWithReceipts; +import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.core.TransactionTestFixture; import java.math.BigInteger; -import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Optional; @@ -128,19 +131,24 @@ public class EngineGetPayloadV4Test extends AbstractEngineGetPayloadTest { BlockWithReceipts block = new BlockWithReceipts( new Block( - header, - new BlockBody( - List.of(blobTx), - Collections.emptyList(), - Optional.of(Collections.emptyList()), - Optional.of(Collections.emptyList()))), + header, new BlockBody(List.of(blobTx), emptyList(), Optional.of(emptyList()))), List.of(blobReceipt)); - PayloadWrapper payload = new PayloadWrapper(payloadIdentifier, block); + final List requests = + List.of( + new Request(RequestType.DEPOSIT, Bytes.of(1)), + new Request(RequestType.WITHDRAWAL, Bytes.of(1)), + new Request(RequestType.CONSOLIDATION, Bytes.of(1))); + PayloadWrapper payload = new PayloadWrapper(payloadIdentifier, block, Optional.of(requests)); when(mergeContext.retrievePayloadById(payloadIdentifier)).thenReturn(Optional.of(payload)); final var resp = resp(RpcMethod.ENGINE_GET_PAYLOAD_V4.getMethodName(), payloadIdentifier); assertThat(resp).isInstanceOf(JsonRpcSuccessResponse.class); + final List requestsWithoutRequestId = + requests.stream() + .sorted(Comparator.comparing(Request::getType)) + .map(r -> r.getData().toHexString()) + .toList(); Optional.of(resp) .map(JsonRpcSuccessResponse.class::cast) .ifPresent( @@ -148,9 +156,6 @@ public class EngineGetPayloadV4Test extends AbstractEngineGetPayloadTest { assertThat(r.getResult()).isInstanceOf(EngineGetPayloadResultV4.class); final EngineGetPayloadResultV4 res = (EngineGetPayloadResultV4) r.getResult(); assertThat(res.getExecutionPayload().getWithdrawals()).isNotNull(); - assertThat(res.getExecutionPayload().getDepositRequests()).isNotNull(); - assertThat(res.getExecutionPayload().getWithdrawalRequests()).isNotNull(); - assertThat(res.getExecutionPayload().getConsolidationRequests()).isNotNull(); assertThat(res.getExecutionPayload().getHash()) .isEqualTo(header.getHash().toString()); assertThat(res.getBlockValue()).isEqualTo(Quantity.create(0)); @@ -161,6 +166,8 @@ public class EngineGetPayloadV4Test extends AbstractEngineGetPayloadTest { assertThat(res.getExecutionPayload().getExcessBlobGas()).isNotEmpty(); assertThat(res.getExecutionPayload().getExcessBlobGas()) .isEqualTo(expectedQuantityOf10); + assertThat(res.getExecutionRequests()).isNotEmpty(); + assertThat(res.getExecutionRequests()).isEqualTo(requestsWithoutRequestId); }); verify(engineCallListener, times(1)).executionEngineCalled(); } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV2Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV2Test.java index 4e68cca76c..abf2c29767 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV2Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV2Test.java @@ -83,15 +83,11 @@ public class EngineNewPayloadV2Test extends AbstractEngineNewPayloadTest { setupValidPayload( new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))), Optional.of(withdrawals), - Optional.empty(), Optional.empty()); lenient() .when(blockchain.getBlockHeader(mockHeader.getParentHash())) .thenReturn(Optional.of(mock(BlockHeader.class))); - var resp = - resp( - mockEnginePayload( - mockHeader, Collections.emptyList(), withdrawalsParam, null, null, null)); + var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList(), withdrawalsParam)); assertValidResponse(mockHeader, resp); } @@ -105,13 +101,11 @@ public class EngineNewPayloadV2Test extends AbstractEngineNewPayloadTest { setupValidPayload( new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))), Optional.empty(), - Optional.empty(), Optional.empty()); lenient() .when(blockchain.getBlockHeader(mockHeader.getParentHash())) .thenReturn(Optional.of(mock(BlockHeader.class))); - var resp = - resp(mockEnginePayload(mockHeader, Collections.emptyList(), withdrawals, null, null, null)); + var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList(), withdrawals)); assertValidResponse(mockHeader, resp); } @@ -126,13 +120,9 @@ public class EngineNewPayloadV2Test extends AbstractEngineNewPayloadTest { var resp = resp( mockEnginePayload( - createBlockHeader( - Optional.of(Collections.emptyList()), Optional.empty(), Optional.empty()), + createBlockHeader(Optional.of(Collections.emptyList()), Optional.empty()), Collections.emptyList(), - withdrawals, - null, - null, - null)); + withdrawals)); final JsonRpcError jsonRpcError = fromErrorResp(resp); assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode()); @@ -143,13 +133,11 @@ public class EngineNewPayloadV2Test extends AbstractEngineNewPayloadTest { public void shouldValidateBlobGasUsedCorrectly() { // V2 should return error if non-null blobGasUsed BlockHeader blockHeader = - createBlockHeaderFixture( - Optional.of(Collections.emptyList()), Optional.empty(), Optional.empty()) + createBlockHeaderFixture(Optional.of(Collections.emptyList()), Optional.empty()) .blobGasUsed(100L) .buildHeader(); - var resp = - resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of(), null, null, null)); + var resp = resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of())); final JsonRpcError jsonRpcError = fromErrorResp(resp); assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_BLOB_GAS_USED_PARAMS.getCode()); assertThat(jsonRpcError.getData()).isEqualTo("Missing blob gas used field"); @@ -160,13 +148,11 @@ public class EngineNewPayloadV2Test extends AbstractEngineNewPayloadTest { public void shouldValidateExcessBlobGasCorrectly() { // V2 should return error if non-null ExcessBlobGas BlockHeader blockHeader = - createBlockHeaderFixture( - Optional.of(Collections.emptyList()), Optional.empty(), Optional.empty()) + createBlockHeaderFixture(Optional.of(Collections.emptyList()), Optional.empty()) .excessBlobGas(BlobGas.MAX_BLOB_GAS) .buildHeader(); - var resp = - resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of(), null, null, null)); + var resp = resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of())); final JsonRpcError jsonRpcError = fromErrorResp(resp); assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode()); @@ -183,12 +169,9 @@ public class EngineNewPayloadV2Test extends AbstractEngineNewPayloadTest { var resp = resp( mockEnginePayload( - createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()), + createBlockHeader(Optional.empty(), Optional.empty()), Collections.emptyList(), - withdrawals, - null, - null, - null)); + withdrawals)); assertThat(fromErrorResp(resp).getCode()).isEqualTo(INVALID_PARAMS.getCode()); verify(engineCallListener, times(1)).executionEngineCalled(); @@ -199,13 +182,11 @@ public class EngineNewPayloadV2Test extends AbstractEngineNewPayloadTest { // Cancun starte at timestamp 30 final long blockTimestamp = 31L; BlockHeader blockHeader = - createBlockHeaderFixture( - Optional.of(Collections.emptyList()), Optional.empty(), Optional.empty()) + createBlockHeaderFixture(Optional.of(Collections.emptyList()), Optional.empty()) .timestamp(blockTimestamp) .buildHeader(); - var resp = - resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of(), null, null, null)); + var resp = resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of())); final JsonRpcError jsonRpcError = fromErrorResp(resp); assertThat(jsonRpcError.getCode()).isEqualTo(UNSUPPORTED_FORK.getCode()); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java index d8cf86758f..b79cb587eb 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java @@ -44,11 +44,10 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EnginePayloadS import org.hyperledger.besu.ethereum.core.BlobTestFixture; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; -import org.hyperledger.besu.ethereum.core.DepositRequest; +import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionTestFixture; import org.hyperledger.besu.ethereum.core.Withdrawal; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; import org.hyperledger.besu.ethereum.core.encoding.EncodingContext; import org.hyperledger.besu.ethereum.core.encoding.TransactionEncoder; import org.hyperledger.besu.ethereum.mainnet.BodyValidation; @@ -135,24 +134,23 @@ public class EngineNewPayloadV3Test extends EngineNewPayloadV2Test { setupValidPayload( new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))), Optional.empty(), - Optional.empty(), Optional.empty()); final EnginePayloadParameter payload = - mockEnginePayload(mockHeader, Collections.emptyList(), null, null, null, null); + mockEnginePayload(mockHeader, Collections.emptyList(), null); ValidationResult res = method.validateParameters( payload, Optional.of(List.of()), - Optional.of("0x0000000000000000000000000000000000000000000000000000000000000000")); + Optional.of("0x0000000000000000000000000000000000000000000000000000000000000000"), + Optional.empty()); assertThat(res.isValid()).isTrue(); } @Override protected BlockHeader createBlockHeader( final Optional> maybeWithdrawals, - final Optional> maybeDepositRequests, - final Optional> maybeWithdrawalRequests) { + final Optional> maybeRequests) { BlockHeader parentBlockHeader = new BlockHeaderTestFixture() .baseFeePerGas(Wei.ONE) @@ -188,14 +186,12 @@ public class EngineNewPayloadV3Test extends EngineNewPayloadV2Test { public void shouldValidateBlobGasUsedCorrectly() { // V3 must return error if null blobGasUsed BlockHeader blockHeader = - createBlockHeaderFixture( - Optional.of(Collections.emptyList()), Optional.empty(), Optional.empty()) + createBlockHeaderFixture(Optional.of(Collections.emptyList()), Optional.empty()) .excessBlobGas(BlobGas.MAX_BLOB_GAS) .blobGasUsed(null) .buildHeader(); - var resp = - resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of(), null, null, null)); + var resp = resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of())); final JsonRpcError jsonRpcError = fromErrorResp(resp); assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode()); @@ -208,14 +204,12 @@ public class EngineNewPayloadV3Test extends EngineNewPayloadV2Test { public void shouldValidateExcessBlobGasCorrectly() { // V3 must return error if null excessBlobGas BlockHeader blockHeader = - createBlockHeaderFixture( - Optional.of(Collections.emptyList()), Optional.empty(), Optional.empty()) + createBlockHeaderFixture(Optional.of(Collections.emptyList()), Optional.empty()) .excessBlobGas(null) .blobGasUsed(100L) .buildHeader(); - var resp = - resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of(), null, null, null)); + var resp = resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of())); final JsonRpcError jsonRpcError = fromErrorResp(resp); assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode()); @@ -236,7 +230,6 @@ public class EngineNewPayloadV3Test extends EngineNewPayloadV2Test { setupValidPayload( new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))), Optional.empty(), - Optional.empty(), Optional.empty()); var resp = resp(mockEnginePayload(mockHeader, transactions)); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4Test.java index 9ea1721305..c8504e7451 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4Test.java @@ -15,9 +15,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine; import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositParameterTestFixture.DEPOSIT_PARAM_1; -import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalRequestTestFixture.WITHDRAWAL_REQUEST_PARAMETER_1; -import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType.INVALID_PARAMS; +import static org.hyperledger.besu.ethereum.api.graphql.internal.response.GraphQLError.INVALID_PARAMS; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.mock; @@ -25,7 +23,6 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.BlobGas; import org.hyperledger.besu.datatypes.RequestType; import org.hyperledger.besu.datatypes.Wei; @@ -33,28 +30,24 @@ import org.hyperledger.besu.ethereum.BlockProcessingOutputs; import org.hyperledger.besu.ethereum.BlockProcessingResult; 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.parameters.DepositRequestParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadParameter; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalRequestParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; -import org.hyperledger.besu.ethereum.core.DepositRequest; import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Withdrawal; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; import org.hyperledger.besu.ethereum.mainnet.BodyValidation; -import org.hyperledger.besu.ethereum.mainnet.requests.DepositRequestValidator; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; -import org.hyperledger.besu.ethereum.mainnet.requests.WithdrawalRequestValidator; +import org.hyperledger.besu.ethereum.mainnet.requests.MainnetRequestsValidator; +import org.hyperledger.besu.ethereum.mainnet.requests.ProhibitedRequestValidator; import org.hyperledger.besu.evm.gascalculator.PragueGasCalculator; -import java.util.ArrayList; import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Optional; +import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -63,8 +56,6 @@ import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) public class EngineNewPayloadV4Test extends EngineNewPayloadV3Test { - private static final Address depositContractAddress = - Address.fromHexString("0x00000000219ab540356cbb839cbe05303d7705fa"); public EngineNewPayloadV4Test() {} @@ -92,8 +83,7 @@ public class EngineNewPayloadV4Test extends EngineNewPayloadV3Test { } @Test - public void shouldReturnValidIfDepositRequestsIsNull_WhenDepositRequestsProhibited() { - final List depositRequests = null; + public void shouldReturnValidIfRequestsIsNull_WhenRequestsProhibited() { mockProhibitedRequestsValidator(); BlockHeader mockHeader = @@ -101,170 +91,69 @@ public class EngineNewPayloadV4Test extends EngineNewPayloadV3Test { new BlockProcessingResult( Optional.of(new BlockProcessingOutputs(null, List.of(), Optional.empty()))), Optional.empty(), - Optional.empty(), Optional.empty()); when(blockchain.getBlockHeader(mockHeader.getParentHash())) .thenReturn(Optional.of(mock(BlockHeader.class))); when(mergeCoordinator.getLatestValidAncestor(mockHeader)) .thenReturn(Optional.of(mockHeader.getHash())); - var resp = - resp( - mockEnginePayload( - mockHeader, Collections.emptyList(), null, depositRequests, null, null)); + var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList())); assertValidResponse(mockHeader, resp); } @Test - public void shouldReturnInvalidIfDepositRequestsIsNull_WhenDepositRequestsAllowed() { - final List depositRequests = null; - mockAllowedDepositRequestsRequestValidator(); + public void shouldReturnInvalidIfRequestsIsNull_WhenRequestsAllowed() { + mockAllowedRequestsValidator(); var resp = resp( mockEnginePayload( - createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()), - Collections.emptyList(), - null, - depositRequests, - null, - null)); + createBlockHeader(Optional.empty(), Optional.empty()), Collections.emptyList())); assertThat(fromErrorResp(resp).getCode()).isEqualTo(INVALID_PARAMS.getCode()); verify(engineCallListener, times(1)).executionEngineCalled(); } @Test - public void shouldReturnValidIfDepositRequestsIsNotNull_WhenDepositRequestsAllowed() { - final List depositRequestsParam = List.of(DEPOSIT_PARAM_1); - final List depositRequests = List.of(DEPOSIT_PARAM_1.toDeposit()); - - mockAllowedDepositRequestsRequestValidator(); - BlockHeader mockHeader = - setupValidPayload( - new BlockProcessingResult( - Optional.of( - new BlockProcessingOutputs(null, List.of(), Optional.of(depositRequests)))), - Optional.empty(), - Optional.of(List.of(DEPOSIT_PARAM_1.toDeposit())), - Optional.empty()); - when(blockchain.getBlockHeader(mockHeader.getParentHash())) - .thenReturn(Optional.of(mock(BlockHeader.class))); - when(mergeCoordinator.getLatestValidAncestor(mockHeader)) - .thenReturn(Optional.of(mockHeader.getHash())); - var resp = - resp( - mockEnginePayload( - mockHeader, Collections.emptyList(), null, depositRequestsParam, null, null)); - - assertValidResponse(mockHeader, resp); - } - - @Test - public void shouldReturnInvalidIfDepositRequestsIsNotNull_WhenDepositRequestsProhibited() { - final List depositRequests = List.of(); - lenient() - .when(protocolSpec.getRequestsValidatorCoordinator()) - .thenReturn(RequestsValidatorCoordinator.empty()); - - var resp = - resp( - mockEnginePayload( - createBlockHeader( - Optional.empty(), Optional.of(Collections.emptyList()), Optional.empty()), - Collections.emptyList(), - null, - depositRequests, - null, - null)); - - final JsonRpcError jsonRpcError = fromErrorResp(resp); - assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode()); - verify(engineCallListener, times(1)).executionEngineCalled(); - } - - @Test - public void shouldReturnValidIfWithdrawalRequestsIsNull_WhenWithdrawalRequestsAreProhibited() { - mockProhibitedRequestsValidator(); - + public void shouldReturnValidIfRequestsIsNotNull_WhenRequestsAllowed() { + final List requests = + List.of( + new Request(RequestType.DEPOSIT, Bytes.of(1)), + new Request(RequestType.WITHDRAWAL, Bytes.of(1)), + new Request(RequestType.CONSOLIDATION, Bytes.of(1))); + + mockAllowedRequestsValidator(); BlockHeader mockHeader = setupValidPayload( new BlockProcessingResult( - Optional.of(new BlockProcessingOutputs(null, List.of(), Optional.empty()))), - Optional.empty(), + Optional.of(new BlockProcessingOutputs(null, List.of(), Optional.of(requests)))), Optional.empty(), Optional.empty()); when(blockchain.getBlockHeader(mockHeader.getParentHash())) .thenReturn(Optional.of(mock(BlockHeader.class))); when(mergeCoordinator.getLatestValidAncestor(mockHeader)) .thenReturn(Optional.of(mockHeader.getHash())); - - var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList(), null, null, null, null)); + var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList()), requests); assertValidResponse(mockHeader, resp); } @Test - public void shouldReturnInvalidIfWithdrawalRequestsIsNull_WhenWithdrawalRequestsAreAllowed() { - mockAllowedWithdrawalsRequestValidator(); - - var resp = - resp( - mockEnginePayload( - createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()), - Collections.emptyList(), - null, - null, - null, - null)); - - assertThat(fromErrorResp(resp).getCode()).isEqualTo(INVALID_PARAMS.getCode()); - verify(engineCallListener, times(1)).executionEngineCalled(); - } - - @Test - public void shouldReturnValidIfWithdrawalRequestsIsNotNull_WhenWithdrawalRequestsAreAllowed() { - final List withdrawalRequestsParams = - List.of(WITHDRAWAL_REQUEST_PARAMETER_1); - final List withdrawalRequests = - List.of(WITHDRAWAL_REQUEST_PARAMETER_1.toWithdrawalRequest()); - mockAllowedWithdrawalsRequestValidator(); - BlockHeader mockHeader = - setupValidPayload( - new BlockProcessingResult( - Optional.of( - new BlockProcessingOutputs(null, List.of(), Optional.of(withdrawalRequests)))), - Optional.empty(), - Optional.empty(), - Optional.of(List.of(WITHDRAWAL_REQUEST_PARAMETER_1.toWithdrawalRequest()))); - when(blockchain.getBlockHeader(mockHeader.getParentHash())) - .thenReturn(Optional.of(mock(BlockHeader.class))); - when(mergeCoordinator.getLatestValidAncestor(mockHeader)) - .thenReturn(Optional.of(mockHeader.getHash())); - var resp = - resp( - mockEnginePayload( - mockHeader, Collections.emptyList(), null, null, withdrawalRequestsParams, null)); - - assertValidResponse(mockHeader, resp); - } + public void shouldReturnInvalidIfRequestsIsNotNull_WhenRequestsProhibited() { + final List requests = + List.of( + new Request(RequestType.DEPOSIT, Bytes.of(1)), + new Request(RequestType.WITHDRAWAL, Bytes.of(1)), + new Request(RequestType.CONSOLIDATION, Bytes.of(1))); - @Test - public void - shouldReturnInvalidIfWithdrawalRequestsIsNotNull_WhenWithdrawalRequestsAreProhibited() { - final List withdrawalRequests = List.of(); mockProhibitedRequestsValidator(); var resp = resp( mockEnginePayload( - createBlockHeader( - Optional.empty(), Optional.empty(), Optional.of(Collections.emptyList())), - Collections.emptyList(), - null, - null, - withdrawalRequests, - null)); + createBlockHeader(Optional.empty(), Optional.of(Collections.emptyList())), + Collections.emptyList()), + requests); final JsonRpcError jsonRpcError = fromErrorResp(resp); assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode()); @@ -274,8 +163,7 @@ public class EngineNewPayloadV4Test extends EngineNewPayloadV3Test { @Override protected BlockHeader createBlockHeader( final Optional> maybeWithdrawals, - final Optional> maybeDepositRequests, - final Optional> maybeWithdrawalRequests) { + final Optional> maybeRequests) { BlockHeader parentBlockHeader = new BlockHeaderTestFixture() .baseFeePerGas(Wei.ONE) @@ -284,16 +172,6 @@ public class EngineNewPayloadV4Test extends EngineNewPayloadV3Test { .blobGasUsed(0L) .buildHeader(); - Optional> maybeRequests; - if (maybeDepositRequests.isPresent() || maybeWithdrawalRequests.isPresent()) { - List requests = new ArrayList<>(); - maybeDepositRequests.ifPresent(requests::addAll); - maybeWithdrawalRequests.ifPresent(requests::addAll); - maybeRequests = Optional.of(requests); - } else { - maybeRequests = Optional.empty(); - } - BlockHeader mockHeader = new BlockHeaderTestFixture() .baseFeePerGas(Wei.ONE) @@ -303,7 +181,7 @@ public class EngineNewPayloadV4Test extends EngineNewPayloadV3Test { .withdrawalsRoot(maybeWithdrawals.map(BodyValidation::withdrawalsRoot).orElse(null)) .excessBlobGas(BlobGas.ZERO) .blobGasUsed(0L) - .requestsRoot(maybeRequests.map(BodyValidation::requestsRoot).orElse(null)) + .requestsHash(maybeRequests.map(BodyValidation::requestsHash).orElse(null)) .parentBeaconBlockRoot( maybeParentBeaconBlockRoot.isPresent() ? maybeParentBeaconBlockRoot : null) .buildHeader(); @@ -320,24 +198,35 @@ public class EngineNewPayloadV4Test extends EngineNewPayloadV3Test { new JsonRpcRequestContext(new JsonRpcRequest("2.0", this.method.getName(), params))); } - private void mockProhibitedRequestsValidator() { - var validator = RequestsValidatorCoordinator.empty(); - when(protocolSpec.getRequestsValidatorCoordinator()).thenReturn(validator); + protected JsonRpcResponse resp( + final EnginePayloadParameter payload, final List requests) { + final List requestsWithoutRequestId = + requests.stream() + .sorted(Comparator.comparing(Request::getType)) + .map(r -> r.getData().toHexString()) + .toList(); + Object[] params = + maybeParentBeaconBlockRoot + .map( + bytes32 -> + new Object[] { + payload, + Collections.emptyList(), + bytes32.toHexString(), + requestsWithoutRequestId + }) + .orElseGet(() -> new Object[] {payload}); + return method.response( + new JsonRpcRequestContext(new JsonRpcRequest("2.0", this.method.getName(), params))); } - private void mockAllowedDepositRequestsRequestValidator() { - var validator = - new RequestsValidatorCoordinator.Builder() - .addValidator(RequestType.DEPOSIT, new DepositRequestValidator(depositContractAddress)) - .build(); - when(protocolSpec.getRequestsValidatorCoordinator()).thenReturn(validator); + private void mockProhibitedRequestsValidator() { + var validator = new ProhibitedRequestValidator(); + when(protocolSpec.getRequestsValidator()).thenReturn(validator); } - private void mockAllowedWithdrawalsRequestValidator() { - var validator = - new RequestsValidatorCoordinator.Builder() - .addValidator(RequestType.WITHDRAWAL, new WithdrawalRequestValidator()) - .build(); - when(protocolSpec.getRequestsValidatorCoordinator()).thenReturn(validator); + private void mockAllowedRequestsValidator() { + var validator = new MainnetRequestsValidator(); + when(protocolSpec.getRequestsValidator()).thenReturn(validator); } } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositParameterTestFixture.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositParameterTestFixture.java deleted file mode 100644 index f3f5f420bb..0000000000 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositParameterTestFixture.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.api.jsonrpc.internal.parameters; - -public class DepositParameterTestFixture { - - public static final DepositRequestParameter DEPOSIT_PARAM_1 = - createDeposit( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e", - "0x0017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483", - "0x773594000", - "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5", - "0x1"); - static final DepositRequestParameter DEPOSIT_PARAM_2 = - createDeposit( - "0x8706d19a62f28a6a6549f96c5adaebac9124a61d44868ec94f6d2d707c6a2f82c9162071231dfeb40e24bfde4ffdf243", - "0x006a8dc800c6d8dd6977ef53264e2d030350f0145a91bcd167b4f1c3ea21b271", - "0x773594000", - "0x801b08ca107b623eca32ee9f9111b4e50eb9cfe19e38204b72de7dc04c5a5e00f61bab96f10842576f66020ce851083f1583dd9a6b73301bea6c245cf51f27cf96aeb018852c5f70bf485d16b957cfe49ca008913346b431e7653ae3ddb23b07", - "0x3"); - - private static DepositRequestParameter createDeposit( - final String pubKey, - final String withdrawalCredentials, - final String amount, - final String signature, - final String index) { - return new DepositRequestParameter(pubKey, withdrawalCredentials, amount, signature, index); - } -} diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositRequestRequestParameterTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositRequestRequestParameterTest.java deleted file mode 100644 index ce5780641b..0000000000 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositRequestRequestParameterTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.api.jsonrpc.internal.parameters; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositParameterTestFixture.DEPOSIT_PARAM_1; - -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.BLSSignature; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.ethereum.core.DepositRequest; - -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.units.bigints.UInt64; -import org.junit.jupiter.api.Test; - -public class DepositRequestRequestParameterTest { - - @Test - public void toDeposit() { - DepositRequest expected = - new DepositRequest( - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - Bytes32.fromHexString( - "0x0017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483"), - GWei.of(32000000000L), - BLSSignature.fromHexString( - "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"), - UInt64.ONE); - assertThat(DEPOSIT_PARAM_1.toDeposit()).isEqualTo(expected); - } - - @Test - public void fromDeposit() { - DepositRequest depositRequest = - new DepositRequest( - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - Bytes32.fromHexString( - "0x0017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483"), - GWei.of(32000000000L), - BLSSignature.fromHexString( - "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"), - UInt64.ONE); - - assertThat(DepositRequestParameter.fromDeposit(depositRequest)).isEqualTo(DEPOSIT_PARAM_1); - } -} diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/WithdrawalRequestParameterTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/WithdrawalRequestParameterTest.java deleted file mode 100644 index e3e136cb7a..0000000000 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/WithdrawalRequestParameterTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.api.jsonrpc.internal.parameters; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalRequestTestFixture.WITHDRAWAL_REQUEST_PARAMETER_1; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; - -import org.junit.jupiter.api.Test; - -public class WithdrawalRequestParameterTest { - - @Test - public void toWithdrawalRequest() { - WithdrawalRequest expected = - new WithdrawalRequest( - Address.fromHexString("0x814FaE9f487206471B6B0D713cD51a2D35980000"), - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - GWei.ONE); - assertThat(WITHDRAWAL_REQUEST_PARAMETER_1.toWithdrawalRequest()).isEqualTo(expected); - } - - @Test - public void fromWithdrawalRequest() { - WithdrawalRequest withdrawalRequest = - new WithdrawalRequest( - Address.fromHexString("0x814FaE9f487206471B6B0D713cD51a2D35980000"), - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - GWei.ONE); - - assertThat(WithdrawalRequestParameter.fromWithdrawalRequest(withdrawalRequest)) - .isEqualTo(WITHDRAWAL_REQUEST_PARAMETER_1); - } -} diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/WithdrawalRequestTestFixture.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/WithdrawalRequestTestFixture.java deleted file mode 100644 index 2256cc3195..0000000000 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/WithdrawalRequestTestFixture.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.api.jsonrpc.internal.parameters; - -import org.hyperledger.besu.datatypes.GWei; - -public class WithdrawalRequestTestFixture { - - public static final WithdrawalRequestParameter WITHDRAWAL_REQUEST_PARAMETER_1 = - new WithdrawalRequestParameter( - "0x814fae9f487206471b6b0d713cd51a2d35980000", - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e", - GWei.ONE.toShortHexString()); - static final WithdrawalRequestParameter WITHDRAWAL_REQUEST_PARAMETER_2 = - new WithdrawalRequestParameter( - "0x758b8178a9a4b7206d1f648c4a77c515cbac7000", - "0x8706d19a62f28a6a6549f96c5adaebac9124a61d44868ec94f6d2d707c6a2f82c9162071231dfeb40e24bfde4ffdf243", - GWei.ONE.toShortHexString()); -} diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java index b843389c0d..ad9489daf8 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java @@ -265,7 +265,7 @@ public abstract class AbstractBlockCreator implements AsyncBlockCreator { operationTracer); Optional> maybeRequests = - requestProcessor.flatMap(processor -> processor.process(context)); + requestProcessor.map(processor -> processor.process(context)); throwIfStopped(); @@ -304,7 +304,7 @@ public abstract class AbstractBlockCreator implements AsyncBlockCreator { withdrawalsCanBeProcessed ? BodyValidation.withdrawalsRoot(maybeWithdrawals.get()) : null) - .requestsRoot(maybeRequests.map(BodyValidation::requestsRoot).orElse(null)); + .requestsHash(maybeRequests.map(BodyValidation::requestsHash).orElse(null)); if (usage != null) { builder.blobGasUsed(usage.used.toLong()).excessBlobGas(usage.excessBlobGas); } @@ -316,8 +316,7 @@ public abstract class AbstractBlockCreator implements AsyncBlockCreator { final Optional> withdrawals = withdrawalsCanBeProcessed ? maybeWithdrawals : Optional.empty(); final BlockBody blockBody = - new BlockBody( - transactionResults.getSelectedTransactions(), ommers, withdrawals, maybeRequests); + new BlockBody(transactionResults.getSelectedTransactions(), ommers, withdrawals); final Block block = new Block(blockHeader, blockBody); operationTracer.traceEndBlock(blockHeader, blockBody); diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java index ffab847bbd..d30349e3d0 100644 --- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java +++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java @@ -14,9 +14,8 @@ */ package org.hyperledger.besu.ethereum.blockcreation; -import static java.util.Collections.emptyList; import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.mainnet.requests.DepositRequestProcessor.DEFAULT_DEPOSIT_CONTRACT_ADDRESS; +import static org.hyperledger.besu.ethereum.mainnet.requests.RequestContractAddresses.DEFAULT_DEPOSIT_CONTRACT_ADDRESS; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.RETURNS_DEEP_STUBS; @@ -31,8 +30,6 @@ import org.hyperledger.besu.crypto.SECPPrivateKey; import org.hyperledger.besu.crypto.SignatureAlgorithm; import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.BLSSignature; import org.hyperledger.besu.datatypes.BlobGas; import org.hyperledger.besu.datatypes.BlobsWithCommitments; import org.hyperledger.besu.datatypes.GWei; @@ -48,7 +45,6 @@ import org.hyperledger.besu.ethereum.core.BlobTestFixture; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder; -import org.hyperledger.besu.ethereum.core.DepositRequest; import org.hyperledger.besu.ethereum.core.Difficulty; import org.hyperledger.besu.ethereum.core.ExecutionContextTestFixture; import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; @@ -81,10 +77,7 @@ import org.hyperledger.besu.ethereum.mainnet.TransactionValidatorFactory; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.mainnet.WithdrawalsProcessor; import org.hyperledger.besu.ethereum.mainnet.requests.DepositRequestProcessor; -import org.hyperledger.besu.ethereum.mainnet.requests.DepositRequestValidator; import org.hyperledger.besu.ethereum.mainnet.requests.ProcessRequestContext; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestProcessorCoordinator; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; import org.hyperledger.besu.evm.account.Account; import org.hyperledger.besu.evm.internal.EvmConfiguration; @@ -141,83 +134,16 @@ abstract class AbstractBlockCreatorTest { List receipts = List.of(receiptWithoutDeposit1, receiptWithDeposit, receiptWithoutDeposit2); - DepositRequest expectedDepositRequest = - new DepositRequest( - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - Bytes32.fromHexString( - "0x0017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483"), - GWei.of(32000000000L), - BLSSignature.fromHexString( - "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"), - UInt64.valueOf(539967)); - final List expectedDepositRequests = List.of(expectedDepositRequest); + Request expectedDepositRequest = + new Request( + RequestType.DEPOSIT, + Bytes.fromHexString( + "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e0017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa355894830040597307000000a889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb53f3d080000000000")); var depositRequestsFromReceipts = new DepositRequestProcessor(DEFAULT_DEPOSIT_CONTRACT_ADDRESS) .process(new ProcessRequestContext(null, null, null, receipts, null, null)); - assertThat(depositRequestsFromReceipts.get()).isEqualTo(expectedDepositRequests); - } - - @Test - void withAllowedDepositRequestsAndContractAddress_DepositRequestsAreParsed() { - final CreateOn miningOn = - blockCreatorWithAllowedDepositRequests(DEFAULT_DEPOSIT_CONTRACT_ADDRESS); - - final BlockCreationResult blockCreationResult = - miningOn.blockCreator.createBlock( - Optional.empty(), - Optional.empty(), - Optional.of(emptyList()), - Optional.empty(), - Optional.empty(), - 1L, - false, - miningOn.parentHeader); - - List depositRequests = emptyList(); - final Hash requestsRoot = BodyValidation.requestsRoot(depositRequests); - assertThat(blockCreationResult.getBlock().getHeader().getRequestsRoot()).hasValue(requestsRoot); - assertThat(blockCreationResult.getBlock().getBody().getRequests()).hasValue(depositRequests); - } - - @Test - void withAllowedDepositRequestsAndNoContractAddress_DepositRequestsAreNotParsed() { - final CreateOn miningOn = blockCreatorWithAllowedDepositRequests(null); - - final BlockCreationResult blockCreationResult = - miningOn.blockCreator.createBlock( - Optional.empty(), - Optional.empty(), - Optional.of(emptyList()), - Optional.empty(), - Optional.empty(), - 1L, - false, - miningOn.parentHeader); - - assertThat(blockCreationResult.getBlock().getHeader().getRequestsRoot()).isEmpty(); - assertThat(blockCreationResult.getBlock().getBody().getRequests()).isEmpty(); - } - - @Test - void withProhibitedDepositRequests_DepositRequestsAreNotParsed() { - - final CreateOn miningOn = blockCreatorWithProhibitedDepositRequests(); - - final BlockCreationResult blockCreationResult = - miningOn.blockCreator.createBlock( - Optional.empty(), - Optional.empty(), - Optional.of(emptyList()), - Optional.empty(), - Optional.empty(), - 1L, - false, - miningOn.parentHeader); - - assertThat(blockCreationResult.getBlock().getHeader().getRequestsRoot()).isEmpty(); - assertThat(blockCreationResult.getBlock().getBody().getRequests()).isEmpty(); + assertThat(depositRequestsFromReceipts).isEqualTo(expectedDepositRequest); } @Test @@ -355,12 +281,6 @@ abstract class AbstractBlockCreatorTest { return createBlockCreator(protocolSpecAdapters); } - private CreateOn blockCreatorWithProhibitedDepositRequests() { - final ProtocolSpecAdapters protocolSpecAdapters = - ProtocolSpecAdapters.create(0, specBuilder -> specBuilder); - return createBlockCreator(protocolSpecAdapters); - } - private CreateOn blockCreatorWithWithdrawalsProcessor() { final ProtocolSpecAdapters protocolSpecAdapters = ProtocolSpecAdapters.create( @@ -374,27 +294,6 @@ abstract class AbstractBlockCreatorTest { return createBlockCreator(protocolSpecAdapters); } - private CreateOn blockCreatorWithAllowedDepositRequests(final Address depositContractAddress) { - final ProtocolSpecAdapters protocolSpecAdapters = - ProtocolSpecAdapters.create( - 0, - specBuilder -> - specBuilder - .requestsValidator( - new RequestsValidatorCoordinator.Builder() - .addValidator( - RequestType.DEPOSIT, - new DepositRequestValidator((depositContractAddress))) - .build()) - .requestProcessorCoordinator( - new RequestProcessorCoordinator.Builder() - .addProcessor( - RequestType.DEPOSIT, - new DepositRequestProcessor(depositContractAddress)) - .build())); - return createBlockCreator(protocolSpecAdapters); - } - record CreateOn(AbstractBlockCreator blockCreator, BlockHeader parentHeader) {} private CreateOn createBlockCreator(final ProtocolSpecAdapters protocolSpecAdapters) { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/BlockProcessingResult.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/BlockProcessingResult.java index 926dd13abd..f34bd056c6 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/BlockProcessingResult.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/BlockProcessingResult.java @@ -14,6 +14,7 @@ */ package org.hyperledger.besu.ethereum; +import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import java.util.ArrayList; @@ -134,4 +135,13 @@ public class BlockProcessingResult extends BlockValidationResult { return yield.get().getReceipts(); } } + + /** + * Gets the requests of the result. + * + * @return the requests of the result + */ + public Optional> getRequests() { + return yield.flatMap(BlockProcessingOutputs::getRequests); + } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/BlockValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/BlockValidator.java index 8cfafee730..f74f4a9077 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/BlockValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/BlockValidator.java @@ -15,13 +15,11 @@ package org.hyperledger.besu.ethereum; import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.mainnet.BodyValidationMode; import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode; import java.util.List; -import java.util.Optional; /** * The BlockValidator interface defines the methods for validating and processing blocks in the @@ -90,7 +88,6 @@ public interface BlockValidator { * @param context the protocol context * @param block the block to validate * @param receipts the transaction receipts - * @param requests the requests * @param headerValidationMode the header validation mode * @param ommerValidationMode the ommer validation mode * @param bodyValidationMode the body validation mode @@ -100,7 +97,6 @@ public interface BlockValidator { final ProtocolContext context, final Block block, final List receipts, - final Optional> requests, final HeaderValidationMode headerValidationMode, final HeaderValidationMode ommerValidationMode, final BodyValidationMode bodyValidationMode); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/MainnetBlockValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/MainnetBlockValidator.java index 9cd014f25a..b218982c09 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/MainnetBlockValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/MainnetBlockValidator.java @@ -171,7 +171,7 @@ public class MainnetBlockValidator implements BlockValidator { Optional> maybeRequests = result.getYield().flatMap(BlockProcessingOutputs::getRequests); if (!blockBodyValidator.validateBody( - context, block, receipts, maybeRequests, worldState.rootHash(), ommerValidationMode)) { + context, block, receipts, worldState.rootHash(), ommerValidationMode)) { result = new BlockProcessingResult("failed to validate output of imported block"); handleFailedBlockProcessing(block, result, shouldRecordBadBlock); return result; @@ -243,7 +243,6 @@ public class MainnetBlockValidator implements BlockValidator { final ProtocolContext context, final Block block, final List receipts, - final Optional> requests, final HeaderValidationMode headerValidationMode, final HeaderValidationMode ommerValidationMode, final BodyValidationMode bodyValidationMode) { @@ -255,7 +254,7 @@ public class MainnetBlockValidator implements BlockValidator { } if (!blockBodyValidator.validateBodyLight( - context, block, receipts, requests, ommerValidationMode, bodyValidationMode)) { + context, block, receipts, ommerValidationMode, bodyValidationMode)) { badBlockManager.addBadBlock( block, BadBlockCause.fromValidationFailure("Failed body validation (light)")); return false; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java index c2243986c2..2ee997f8cc 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java @@ -28,7 +28,6 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder; import org.hyperledger.besu.ethereum.core.Difficulty; import org.hyperledger.besu.ethereum.core.MutableWorldState; -import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Withdrawal; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions; @@ -145,10 +144,8 @@ public final class GenesisState { private static BlockBody buildBody(final GenesisConfigFile config) { final Optional> withdrawals = isShanghaiAtGenesis(config) ? Optional.of(emptyList()) : Optional.empty(); - final Optional> requests = - isPragueAtGenesis(config) ? Optional.of(emptyList()) : Optional.empty(); - return new BlockBody(emptyList(), emptyList(), withdrawals, requests); + return new BlockBody(emptyList(), emptyList(), withdrawals); } public Block getBlock() { @@ -220,7 +217,7 @@ public final class GenesisState { .excessBlobGas(isCancunAtGenesis(genesis) ? parseExcessBlobGas(genesis) : null) .parentBeaconBlockRoot( (isCancunAtGenesis(genesis) ? parseParentBeaconBlockRoot(genesis) : null)) - .requestsRoot(isPragueAtGenesis(genesis) ? Hash.EMPTY_TRIE_HASH : null) + .requestsHash(isPragueAtGenesis(genesis) ? Hash.EMPTY_REQUESTS_HASH : null) .buildBlockHeader(); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Block.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Block.java index 3c90f77d32..41db458334 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Block.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Block.java @@ -62,7 +62,6 @@ public class Block { out.writeList(body.getTransactions(), Transaction::writeTo); out.writeList(body.getOmmers(), BlockHeader::writeTo); body.getWithdrawals().ifPresent(withdrawals -> out.writeList(withdrawals, Withdrawal::writeTo)); - body.getRequests().ifPresent(requests -> out.writeList(requests, Request::writeTo)); out.endList(); } @@ -74,11 +73,9 @@ public class Block { final List ommers = in.readList(rlp -> BlockHeader.readFrom(rlp, hashFunction)); final Optional> withdrawals = in.isEndOfCurrentList() ? Optional.empty() : Optional.of(in.readList(Withdrawal::readFrom)); - final Optional> requests = - in.isEndOfCurrentList() ? Optional.empty() : Optional.of(in.readList(Request::readFrom)); in.leaveList(); - return new Block(header, new BlockBody(transactions, ommers, withdrawals, requests)); + return new Block(header, new BlockBody(transactions, ommers, withdrawals)); } @Override diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockBody.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockBody.java index 4b8ab92613..7eb49dc04d 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockBody.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockBody.java @@ -37,24 +37,20 @@ public class BlockBody implements org.hyperledger.besu.plugin.data.BlockBody { private final List ommers; private final Optional> withdrawals; - private final Optional> requests; public BlockBody(final List transactions, final List ommers) { this.transactions = transactions; this.ommers = ommers; this.withdrawals = Optional.empty(); - this.requests = Optional.empty(); } public BlockBody( final List transactions, final List ommers, - final Optional> withdrawals, - final Optional> requests) { + final Optional> withdrawals) { this.transactions = transactions; this.ommers = ommers; this.withdrawals = withdrawals; - this.requests = requests; } public static BlockBody empty() { @@ -87,16 +83,6 @@ public class BlockBody implements org.hyperledger.besu.plugin.data.BlockBody { return withdrawals; } - /** - * Returns the withdrawal requests of the block. - * - * @return The optional list of withdrawal requests included in the block. - */ - @Override - public Optional> getRequests() { - return requests; - } - /** * Writes Block to {@link RLPOutput}. * @@ -112,7 +98,6 @@ public class BlockBody implements org.hyperledger.besu.plugin.data.BlockBody { output.writeList(getTransactions(), Transaction::writeTo); output.writeList(getOmmers(), BlockHeader::writeTo); withdrawals.ifPresent(withdrawals -> output.writeList(withdrawals, Withdrawal::writeTo)); - requests.ifPresent(requests -> output.writeList(requests, Request::writeTo)); } public static BlockBody readWrappedBodyFrom( @@ -161,10 +146,7 @@ public class BlockBody implements org.hyperledger.besu.plugin.data.BlockBody { input.readList(rlp -> BlockHeader.readFrom(rlp, blockHeaderFunctions)), input.isEndOfCurrentList() ? Optional.empty() - : Optional.of(input.readList(Withdrawal::readFrom)), - input.isEndOfCurrentList() - ? Optional.empty() - : Optional.of(input.readList(Request::readFrom))); + : Optional.of(input.readList(Withdrawal::readFrom))); } @Override @@ -174,20 +156,16 @@ public class BlockBody implements org.hyperledger.besu.plugin.data.BlockBody { BlockBody blockBody = (BlockBody) o; return Objects.equals(transactions, blockBody.transactions) && Objects.equals(ommers, blockBody.ommers) - && Objects.equals(withdrawals, blockBody.withdrawals) - && Objects.equals(requests, blockBody.requests); + && Objects.equals(withdrawals, blockBody.withdrawals); } @Override public int hashCode() { - return Objects.hash(transactions, ommers, withdrawals, requests); + return Objects.hash(transactions, ommers, withdrawals); } public boolean isEmpty() { - return transactions.isEmpty() - && ommers.isEmpty() - && withdrawals.isEmpty() - && requests.isEmpty(); + return transactions.isEmpty() && ommers.isEmpty() && withdrawals.isEmpty(); } @Override @@ -199,8 +177,6 @@ public class BlockBody implements org.hyperledger.besu.plugin.data.BlockBody { + ommers + ", withdrawals=" + withdrawals - + ", withdrawal_requests=" - + requests + '}'; } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeader.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeader.java index 7ff841280d..6bd1a2aa58 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeader.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeader.java @@ -64,7 +64,7 @@ public class BlockHeader extends SealableBlockHeader final Long blobGasUsed, final BlobGas excessBlobGas, final Bytes32 parentBeaconBlockRoot, - final Hash requestsRoot, + final Hash requestsHash, final BlockHeaderFunctions blockHeaderFunctions) { super( parentHash, @@ -86,7 +86,7 @@ public class BlockHeader extends SealableBlockHeader blobGasUsed, excessBlobGas, parentBeaconBlockRoot, - requestsRoot); + requestsHash); this.nonce = nonce; this.hash = Suppliers.memoize(() -> blockHeaderFunctions.hash(this)); this.parsedExtraData = Suppliers.memoize(() -> blockHeaderFunctions.parseExtraData(this)); @@ -100,8 +100,8 @@ public class BlockHeader extends SealableBlockHeader .map(wsRoot -> wsRoot.equals(Hash.EMPTY_TRIE_HASH)) .orElse(true) && blockHeader - .getRequestsRoot() - .map(reqRoot -> reqRoot.equals(Hash.EMPTY_TRIE_HASH)) + .getRequestsHash() + .map(reqHash -> reqHash.equals(Hash.EMPTY_REQUESTS_HASH)) .orElse(true); } @@ -185,8 +185,8 @@ public class BlockHeader extends SealableBlockHeader if (parentBeaconBlockRoot == null) break; out.writeBytes(parentBeaconBlockRoot); - if (requestsRoot == null) break; - out.writeBytes(requestsRoot); + if (requestsHash == null) break; + out.writeBytes(requestsHash); } while (false); out.endList(); } @@ -218,7 +218,7 @@ public class BlockHeader extends SealableBlockHeader final BlobGas excessBlobGas = !input.isEndOfCurrentList() ? BlobGas.of(input.readUInt64Scalar()) : null; final Bytes32 parentBeaconBlockRoot = !input.isEndOfCurrentList() ? input.readBytes32() : null; - final Hash requestsRoot = !input.isEndOfCurrentList() ? Hash.wrap(input.readBytes32()) : null; + final Hash requestsHash = !input.isEndOfCurrentList() ? Hash.wrap(input.readBytes32()) : null; input.leaveList(); return new BlockHeader( parentHash, @@ -241,7 +241,7 @@ public class BlockHeader extends SealableBlockHeader blobGasUsed, excessBlobGas, parentBeaconBlockRoot, - requestsRoot, + requestsHash, blockHeaderFunctions); } @@ -292,8 +292,8 @@ public class BlockHeader extends SealableBlockHeader if (parentBeaconBlockRoot != null) { sb.append("parentBeaconBlockRoot=").append(parentBeaconBlockRoot).append(", "); } - if (requestsRoot != null) { - sb.append("requestsRoot=").append(requestsRoot); + if (requestsHash != null) { + sb.append("requestsHash=").append(requestsHash); } return sb.append("}").toString(); } @@ -326,7 +326,7 @@ public class BlockHeader extends SealableBlockHeader pluginBlockHeader.getExcessBlobGas().map(BlobGas.class::cast).orElse(null), pluginBlockHeader.getParentBeaconBlockRoot().orElse(null), pluginBlockHeader - .getRequestsRoot() + .getRequestsHash() .map(h -> Hash.fromHexString(h.toHexString())) .orElse(null), blockHeaderFunctions); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeaderBuilder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeaderBuilder.java index 6f485d19ce..a024d53cd2 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeaderBuilder.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeaderBuilder.java @@ -45,7 +45,7 @@ public class BlockHeaderBuilder { private Hash transactionsRoot; private Hash withdrawalsRoot = null; - private Hash requestsRoot = null; + private Hash requestsHash = null; private Hash receiptsRoot; @@ -124,7 +124,7 @@ public class BlockHeaderBuilder { .blobGasUsed(header.getBlobGasUsed().orElse(null)) .excessBlobGas(header.getExcessBlobGas().orElse(null)) .parentBeaconBlockRoot(header.getParentBeaconBlockRoot().orElse(null)) - .requestsRoot(header.getRequestsRoot().orElse(null)); + .requestsHash(header.getRequestsHash().orElse(null)); } public static BlockHeaderBuilder fromBuilder(final BlockHeaderBuilder fromBuilder) { @@ -148,7 +148,7 @@ public class BlockHeaderBuilder { .withdrawalsRoot(fromBuilder.withdrawalsRoot) .excessBlobGas(fromBuilder.excessBlobGas) .parentBeaconBlockRoot(fromBuilder.parentBeaconBlockRoot) - .requestsRoot(fromBuilder.requestsRoot) + .requestsHash(fromBuilder.requestsHash) .blockHeaderFunctions(fromBuilder.blockHeaderFunctions); toBuilder.nonce = fromBuilder.nonce; return toBuilder; @@ -178,7 +178,7 @@ public class BlockHeaderBuilder { blobGasUsed, excessBlobGas, parentBeaconBlockRoot, - requestsRoot, + requestsHash, blockHeaderFunctions); } @@ -220,7 +220,7 @@ public class BlockHeaderBuilder { blobGasUsed, excessBlobGas, parentBeaconBlockRoot, - requestsRoot); + requestsHash); } private void validateBlockHeader() { @@ -284,7 +284,7 @@ public class BlockHeaderBuilder { sealableBlockHeader.getBlobGasUsed().ifPresent(this::blobGasUsed); sealableBlockHeader.getExcessBlobGas().ifPresent(this::excessBlobGas); sealableBlockHeader.getParentBeaconBlockRoot().ifPresent(this::parentBeaconBlockRoot); - requestsRoot(sealableBlockHeader.getRequestsRoot().orElse(null)); + requestsHash(sealableBlockHeader.getRequestsHash().orElse(null)); return this; } @@ -399,8 +399,8 @@ public class BlockHeaderBuilder { return this; } - public BlockHeaderBuilder requestsRoot(final Hash hash) { - this.requestsRoot = hash; + public BlockHeaderBuilder requestsHash(final Hash hash) { + this.requestsHash = hash; return this; } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/ConsolidationRequest.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/ConsolidationRequest.java deleted file mode 100644 index 38345d1a31..0000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/ConsolidationRequest.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.core; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.PublicKey; -import org.hyperledger.besu.datatypes.RequestType; - -import java.util.Objects; - -public class ConsolidationRequest extends Request - implements org.hyperledger.besu.plugin.data.ConsolidationRequest { - - private final Address sourceAddress; - private final BLSPublicKey sourcePubkey; - private final BLSPublicKey targetPubkey; - - public ConsolidationRequest( - final Address sourceAddress, - final BLSPublicKey sourcePubkey, - final BLSPublicKey targetPubkey) { - this.sourceAddress = sourceAddress; - this.sourcePubkey = sourcePubkey; - this.targetPubkey = targetPubkey; - } - - @Override - public RequestType getType() { - return RequestType.CONSOLIDATION; - } - - @Override - public Address getSourceAddress() { - return sourceAddress; - } - - @Override - public PublicKey getSourcePubkey() { - return sourcePubkey; - } - - @Override - public PublicKey getTargetPubkey() { - return targetPubkey; - } - - @Override - public String toString() { - return "ConsolidationRequest{" - + "sourceAddress=" - + sourceAddress - + " sourcePubkey=" - + sourcePubkey - + " targetPubkey=" - + targetPubkey - + '}'; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final ConsolidationRequest that = (ConsolidationRequest) o; - return Objects.equals(sourceAddress, that.sourceAddress) - && Objects.equals(sourcePubkey, that.sourcePubkey) - && Objects.equals(targetPubkey, that.targetPubkey); - } - - @Override - public int hashCode() { - return Objects.hash(sourceAddress, sourcePubkey, targetPubkey); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/DepositRequest.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/DepositRequest.java deleted file mode 100644 index a005fa831e..0000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/DepositRequest.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.core; - -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.BLSSignature; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.datatypes.PublicKey; -import org.hyperledger.besu.datatypes.RequestType; - -import java.util.Objects; - -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.units.bigints.UInt64; - -public class DepositRequest extends Request - implements org.hyperledger.besu.plugin.data.DepositRequest { - - private final BLSPublicKey pubkey; - private final Bytes32 depositWithdrawalCredentials; - private final GWei amount; - private final BLSSignature signature; - private final UInt64 index; - - public DepositRequest( - final BLSPublicKey pubkey, - final Bytes32 depositWithdrawalCredentials, - final GWei amount, - final BLSSignature signature, - final UInt64 index) { - this.pubkey = pubkey; - this.depositWithdrawalCredentials = depositWithdrawalCredentials; - this.amount = amount; - this.signature = signature; - this.index = index; - } - - @Override - public RequestType getType() { - return RequestType.DEPOSIT; - } - - @Override - public PublicKey getPubkey() { - return pubkey; - } - - @Override - public Bytes32 getWithdrawalCredentials() { - return depositWithdrawalCredentials; - } - - @Override - public GWei getAmount() { - return amount; - } - - @Override - public BLSSignature getSignature() { - return signature; - } - - @Override - public UInt64 getIndex() { - return index; - } - - @Override - public String toString() { - return "Deposit{" - + "pubKey=" - + pubkey - + ", withdrawalCredentials=" - + depositWithdrawalCredentials - + ", amount=" - + amount - + ", signature=" - + signature - + ", index=" - + index - + '}'; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final DepositRequest that = (DepositRequest) o; - return Objects.equals(pubkey, that.pubkey) - && Objects.equals(depositWithdrawalCredentials, that.depositWithdrawalCredentials) - && Objects.equals(amount, that.amount) - && Objects.equals(signature, that.signature) - && Objects.equals(index, that.index); - } - - @Override - public int hashCode() { - return Objects.hash(pubkey, depositWithdrawalCredentials, amount, signature, index); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Request.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Request.java index 8f4ea64e31..7d485336ad 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Request.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Request.java @@ -15,27 +15,18 @@ package org.hyperledger.besu.ethereum.core; import org.hyperledger.besu.datatypes.RequestType; -import org.hyperledger.besu.ethereum.core.encoding.RequestDecoder; -import org.hyperledger.besu.ethereum.core.encoding.RequestEncoder; -import org.hyperledger.besu.ethereum.rlp.RLP; -import org.hyperledger.besu.ethereum.rlp.RLPInput; -import org.hyperledger.besu.ethereum.rlp.RLPOutput; import org.apache.tuweni.bytes.Bytes; -public abstract class Request implements org.hyperledger.besu.plugin.data.Request { +public record Request(RequestType type, Bytes data) + implements org.hyperledger.besu.plugin.data.Request { @Override - public abstract RequestType getType(); - - public static Request readFrom(final Bytes rlpBytes) { - return readFrom(RLP.input(rlpBytes)); - } - - public static Request readFrom(final RLPInput rlpInput) { - return RequestDecoder.decode(rlpInput); + public RequestType getType() { + return type(); } - public void writeTo(final RLPOutput out) { - RequestEncoder.encode(this, out); + @Override + public Bytes getData() { + return data(); } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/SealableBlockHeader.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/SealableBlockHeader.java index df3859f2b7..1934c8f8c0 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/SealableBlockHeader.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/SealableBlockHeader.java @@ -43,7 +43,7 @@ public class SealableBlockHeader extends ProcessableBlockHeader { protected final Hash withdrawalsRoot; - protected final Hash requestsRoot; + protected final Hash requestsHash; protected final Long blobGasUsed; @@ -69,7 +69,7 @@ public class SealableBlockHeader extends ProcessableBlockHeader { final Long blobGasUsed, final BlobGas excessBlobGas, final Bytes32 parentBeaconBlockRoot, - final Hash requestsRoot) { + final Hash requestsHash) { super( parentHash, coinbase, @@ -85,7 +85,7 @@ public class SealableBlockHeader extends ProcessableBlockHeader { this.transactionsRoot = transactionsRoot; this.withdrawalsRoot = withdrawalsRoot; this.receiptsRoot = receiptsRoot; - this.requestsRoot = requestsRoot; + this.requestsHash = requestsHash; this.logsBloom = logsBloom; this.gasUsed = gasUsed; this.extraData = extraData; @@ -166,12 +166,12 @@ public class SealableBlockHeader extends ProcessableBlockHeader { } /** - * Returns the block requests root hash. + * Returns the block requests hash. * - * @return the block requests root hash + * @return the block requests hash */ - public Optional getRequestsRoot() { - return Optional.ofNullable(requestsRoot); + public Optional getRequestsHash() { + return Optional.ofNullable(requestsHash); } /** diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/WithdrawalRequest.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/WithdrawalRequest.java deleted file mode 100644 index 0e7afc1595..0000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/WithdrawalRequest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.core; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.datatypes.PublicKey; -import org.hyperledger.besu.datatypes.RequestType; - -import java.util.Objects; - -public class WithdrawalRequest extends Request - implements org.hyperledger.besu.plugin.data.WithdrawalRequest { - - private final Address sourceAddress; - private final BLSPublicKey validatorPubkey; - private final GWei amount; - - public WithdrawalRequest( - final Address sourceAddress, final BLSPublicKey validatorPubkey, final GWei amount) { - this.sourceAddress = sourceAddress; - this.validatorPubkey = validatorPubkey; - this.amount = amount; - } - - @Override - public RequestType getType() { - return RequestType.WITHDRAWAL; - } - - @Override - public Address getSourceAddress() { - return sourceAddress; - } - - @Override - public PublicKey getValidatorPubkey() { - return validatorPubkey; - } - - @Override - public GWei getAmount() { - return amount; - } - - @Override - public String toString() { - return "WithdrawalRequest{" - + "sourceAddress=" - + sourceAddress - + " validatorPubkey=" - + validatorPubkey - + " amount=" - + amount - + '}'; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final WithdrawalRequest that = (WithdrawalRequest) o; - return Objects.equals(sourceAddress, that.sourceAddress) - && Objects.equals(validatorPubkey, that.validatorPubkey) - && Objects.equals(amount, that.amount); - } - - @Override - public int hashCode() { - return Objects.hash(sourceAddress, validatorPubkey, amount); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestDecoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestDecoder.java deleted file mode 100644 index 29be31f46d..0000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestDecoder.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.core.encoding; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.ethereum.core.ConsolidationRequest; -import org.hyperledger.besu.ethereum.rlp.RLP; -import org.hyperledger.besu.ethereum.rlp.RLPInput; - -import org.apache.tuweni.bytes.Bytes; - -public class ConsolidationRequestDecoder { - - public static ConsolidationRequest decode(final RLPInput rlpInput) { - rlpInput.enterList(); - final Address sourceAddress = Address.readFrom(rlpInput); - final BLSPublicKey sourcePublicKey = BLSPublicKey.readFrom(rlpInput); - final BLSPublicKey targetPublicKey = BLSPublicKey.readFrom(rlpInput); - rlpInput.leaveList(); - - return new ConsolidationRequest(sourceAddress, sourcePublicKey, targetPublicKey); - } - - public static ConsolidationRequest decodeOpaqueBytes(final Bytes input) { - return decode(RLP.input(input)); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestEncoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestEncoder.java deleted file mode 100644 index 9551f7b974..0000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestEncoder.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.core.encoding; - -import org.hyperledger.besu.datatypes.RequestType; -import org.hyperledger.besu.ethereum.core.ConsolidationRequest; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.rlp.RLP; -import org.hyperledger.besu.ethereum.rlp.RLPOutput; - -import org.apache.tuweni.bytes.Bytes; - -public class ConsolidationRequestEncoder { - - /** - * Encodes a Request into RLP format if it is a ConsolidationRequest. - * - * @param request The Request to encode, which must be a ConsolidationRequest. - * @param rlpOutput The RLPOutput to write the encoded data to. - * @throws IllegalArgumentException if the provided request is not a ConsolidationRequest. - */ - public static void encode(final Request request, final RLPOutput rlpOutput) { - if (!request.getType().equals(RequestType.CONSOLIDATION)) { - throw new IllegalArgumentException( - "The provided request is not of type ConsolidationRequest."); - } - encodeConsolidationRequest((ConsolidationRequest) request, rlpOutput); - } - - /** - * Encodes the details of a ConsolidationRequest into RLP format. - * - * @param consolidationRequest The ConsolidationRequest to encode. - * @param rlpOutput The RLPOutput to write the encoded data to. - */ - private static void encodeConsolidationRequest( - final ConsolidationRequest consolidationRequest, final RLPOutput rlpOutput) { - rlpOutput.startList(); - rlpOutput.writeBytes(consolidationRequest.getSourceAddress()); - rlpOutput.writeBytes(consolidationRequest.getSourcePubkey()); - rlpOutput.writeBytes(consolidationRequest.getTargetPubkey()); - rlpOutput.endList(); - } - - public static Bytes encodeOpaqueBytes(final Request consolidationRequest) { - return RLP.encode(rlpOutput -> encode(consolidationRequest, rlpOutput)); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositLogDecoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositLogDecoder.java new file mode 100644 index 0000000000..655ee63120 --- /dev/null +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositLogDecoder.java @@ -0,0 +1,40 @@ +/* + * Copyright contributors to Hyperledger Besu. + * + * 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.core.encoding; + +import org.hyperledger.besu.ethereum.core.DepositContract; +import org.hyperledger.besu.evm.log.Log; + +import org.apache.tuweni.bytes.Bytes; +import org.web3j.tx.Contract; + +public class DepositLogDecoder { + + public static Bytes decodeFromLog(final Log log) { + Contract.EventValuesWithLog eventValues = DepositContract.staticExtractDepositEventWithLog(log); + final Bytes rawPublicKey = + Bytes.wrap((byte[]) eventValues.getNonIndexedValues().get(0).getValue()); + final Bytes rawWithdrawalCredential = + Bytes.wrap((byte[]) eventValues.getNonIndexedValues().get(1).getValue()); + final Bytes rawAmount = + Bytes.wrap((byte[]) eventValues.getNonIndexedValues().get(2).getValue()); + final Bytes rawSignature = + Bytes.wrap((byte[]) eventValues.getNonIndexedValues().get(3).getValue()); + final Bytes rawIndex = Bytes.wrap((byte[]) eventValues.getNonIndexedValues().get(4).getValue()); + + return Bytes.concatenate( + rawPublicKey, rawWithdrawalCredential, rawAmount, rawSignature, rawIndex); + } +} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestDecoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestDecoder.java deleted file mode 100644 index 85b56e1a57..0000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestDecoder.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.core.encoding; - -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.BLSSignature; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.ethereum.core.DepositContract; -import org.hyperledger.besu.ethereum.core.DepositRequest; -import org.hyperledger.besu.ethereum.rlp.RLP; -import org.hyperledger.besu.ethereum.rlp.RLPInput; -import org.hyperledger.besu.evm.log.Log; - -import java.nio.ByteOrder; - -import org.apache.tuweni.bytes.Bytes; -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.units.bigints.UInt64; -import org.web3j.tx.Contract; - -public class DepositRequestDecoder { - - public static DepositRequest decode(final RLPInput rlpInput) { - rlpInput.enterList(); - final BLSPublicKey publicKey = BLSPublicKey.readFrom(rlpInput); - final Bytes32 depositWithdrawalCredential = Bytes32.wrap(rlpInput.readBytes()); - final GWei amount = GWei.of(rlpInput.readUInt64Scalar()); - final BLSSignature signature = BLSSignature.readFrom(rlpInput); - final UInt64 index = UInt64.valueOf(rlpInput.readBigIntegerScalar()); - rlpInput.leaveList(); - - return new DepositRequest(publicKey, depositWithdrawalCredential, amount, signature, index); - } - - public static DepositRequest decodeFromLog(final Log log) { - Contract.EventValuesWithLog eventValues = DepositContract.staticExtractDepositEventWithLog(log); - final byte[] rawPublicKey = (byte[]) eventValues.getNonIndexedValues().get(0).getValue(); - final byte[] rawWithdrawalCredential = - (byte[]) eventValues.getNonIndexedValues().get(1).getValue(); - final byte[] rawAmount = (byte[]) eventValues.getNonIndexedValues().get(2).getValue(); - final byte[] rawSignature = (byte[]) eventValues.getNonIndexedValues().get(3).getValue(); - final byte[] rawIndex = (byte[]) eventValues.getNonIndexedValues().get(4).getValue(); - - return new DepositRequest( - BLSPublicKey.wrap(Bytes.wrap(rawPublicKey)), - Bytes32.wrap(Bytes.wrap(rawWithdrawalCredential)), - GWei.of( - Bytes.wrap(rawAmount) - .toLong( - ByteOrder.LITTLE_ENDIAN)), // Amount is little endian as per Deposit Contract - BLSSignature.wrap(Bytes.wrap(rawSignature)), - UInt64.valueOf(Bytes.wrap(rawIndex).reverse().toLong())); - } - - public static DepositRequest decodeOpaqueBytes(final Bytes input) { - return decode(RLP.input(input)); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestEncoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestEncoder.java deleted file mode 100644 index a99b0b761c..0000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestEncoder.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.core.encoding; - -import org.hyperledger.besu.ethereum.core.DepositRequest; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.rlp.RLP; -import org.hyperledger.besu.ethereum.rlp.RLPOutput; - -import org.apache.tuweni.bytes.Bytes; - -public class DepositRequestEncoder { - - public static void encode(final Request request, final RLPOutput rlpOutput) { - if (!(request instanceof DepositRequest depositRequest)) { - throw new IllegalArgumentException("The provided request is not of type deposit."); - } - rlpOutput.startList(); - rlpOutput.writeBytes(depositRequest.getPubkey()); - rlpOutput.writeBytes(depositRequest.getWithdrawalCredentials()); - rlpOutput.writeUInt64Scalar(depositRequest.getAmount()); - rlpOutput.writeBytes(depositRequest.getSignature()); - rlpOutput.writeUInt64Scalar(depositRequest.getIndex()); - rlpOutput.endList(); - } - - public static Bytes encodeOpaqueBytes(final Request deposit) { - return RLP.encode(rlpOutput -> encode(deposit, rlpOutput)); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/RequestDecoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/RequestDecoder.java deleted file mode 100644 index 64191e104b..0000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/RequestDecoder.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.core.encoding; - -import org.hyperledger.besu.datatypes.RequestType; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.rlp.RLP; -import org.hyperledger.besu.ethereum.rlp.RLPInput; - -import java.util.Optional; - -import com.google.common.collect.ImmutableMap; -import org.apache.tuweni.bytes.Bytes; - -/** - * Decodes a request from its RLP encoded form. - * - *

This class provides functionality to decode requests based on their type. - */ -public class RequestDecoder { - - @FunctionalInterface - interface Decoder { - Request decode(RLPInput input); - } - - private static final ImmutableMap DECODERS = - ImmutableMap.of( - RequestType.WITHDRAWAL, - WithdrawalRequestDecoder::decode, - RequestType.DEPOSIT, - DepositRequestDecoder::decode, - RequestType.CONSOLIDATION, - ConsolidationRequestDecoder::decode); - - /** - * Decodes a request from its RLP encoded bytes. - * - *

This method first determines the type of the request and then decodes the request data - * according to the request type. - * - * @param rlpInput The RLP encoded request. - * @return The decoded Request object. - * @throws IllegalArgumentException if the request type is unsupported or invalid. - */ - public static Request decode(final RLPInput rlpInput) { - final Bytes requestBytes = rlpInput.readBytes(); - return getRequestType(requestBytes) - .map(type -> decodeRequest(requestBytes, type)) - .orElseThrow(() -> new IllegalArgumentException("Unsupported or invalid request type")); - } - - /** - * Decodes the request data according to the request type. - * - * @param requestBytes The bytes representing the request, including the request type byte. - * @param requestType The type of the request to decode. - * @return The decoded Request. - * @throws IllegalStateException if no decoder is found for the specified request type. - */ - private static Request decodeRequest(final Bytes requestBytes, final RequestType requestType) { - // Skip the first byte which is the request type - RLPInput requestInput = RLP.input(requestBytes.slice(1)); - Decoder decoder = - Optional.ofNullable(DECODERS.get(requestType)) - .orElseThrow( - () -> - new IllegalStateException( - "Decoder not found for request type: " + requestType)); - return decoder.decode(requestInput); - } - - /** - * Extracts the request type from the given bytes. - * - * @param bytes The bytes from which to extract the request type. - * @return An Optional containing the RequestType if it could be determined, or an empty Optional - * otherwise. - */ - private static Optional getRequestType(final Bytes bytes) { - try { - byte typeByte = bytes.get(0); - return Optional.of(RequestType.of(typeByte)); - } catch (IllegalArgumentException ex) { - return Optional.empty(); - } - } - - public static Request decodeOpaqueBytes(final Bytes input) { - - RequestType type = getRequestType(input).orElseThrow(); - return decodeRequest(input.slice(1), type); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/RequestEncoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/RequestEncoder.java deleted file mode 100644 index 3c61a77ac0..0000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/RequestEncoder.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.core.encoding; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.hyperledger.besu.datatypes.RequestType; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; -import org.hyperledger.besu.ethereum.rlp.RLP; -import org.hyperledger.besu.ethereum.rlp.RLPOutput; - -import com.google.common.collect.ImmutableMap; -import org.apache.tuweni.bytes.Bytes; - -/** Encodes Request objects into RLP format. */ -public class RequestEncoder { - - @FunctionalInterface - interface Encoder { - void encode(Request request, RLPOutput output); - } - - private static final ImmutableMap ENCODERS = - ImmutableMap.of( - RequestType.WITHDRAWAL, - WithdrawalRequestEncoder::encode, - RequestType.DEPOSIT, - DepositRequestEncoder::encode, - RequestType.CONSOLIDATION, - ConsolidationRequestEncoder::encode); - - /** - * Encodes a Request into the provided RLPOutput. - * - * @param request The Request to encode. - * @param rlpOutput The RLPOutput to write the encoded data to. - */ - public static void encode(final Request request, final RLPOutput rlpOutput) { - final RequestEncoder.Encoder encoder = getEncoder(request.getType()); - Bytes requestBytes = RLP.encode(out -> encoder.encode(request, out)); - rlpOutput.writeBytes( - Bytes.concatenate(Bytes.of(request.getType().getSerializedType()), requestBytes)); - } - - /** - * Encodes a Request into a Bytes object representing the RLP-encoded data. - * - * @param request The Request to encode. - * @return The RLP-encoded data as a Bytes object. - */ - public static Bytes encodeOpaqueBytes(final Request request) { - final RequestEncoder.Encoder encoder = getEncoder(request.getType()); - final BytesValueRLPOutput out = new BytesValueRLPOutput(); - out.writeByte(request.getType().getSerializedType()); - encoder.encode(request, out); - return out.encoded(); - } - - /** - * Retrieves the encoder for the specified RequestType. - * - * @param requestType The type of the request. - * @return The encoder for the specified type. - * @throws NullPointerException if no encoder is found for the specified type. - */ - private static RequestEncoder.Encoder getEncoder(final RequestType requestType) { - return checkNotNull( - ENCODERS.get(requestType), "Encoder not found for request type: %s", requestType); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestDecoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestDecoder.java deleted file mode 100644 index 031209284e..0000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestDecoder.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.core.encoding; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; -import org.hyperledger.besu.ethereum.rlp.RLP; -import org.hyperledger.besu.ethereum.rlp.RLPInput; - -import org.apache.tuweni.bytes.Bytes; - -public class WithdrawalRequestDecoder { - - public static WithdrawalRequest decode(final RLPInput rlpInput) { - rlpInput.enterList(); - final Address sourceAddress = Address.readFrom(rlpInput); - final BLSPublicKey validatorPubkey = BLSPublicKey.readFrom(rlpInput); - final GWei amount = GWei.of(rlpInput.readUInt64Scalar()); - rlpInput.leaveList(); - - return new WithdrawalRequest(sourceAddress, validatorPubkey, amount); - } - - public static WithdrawalRequest decodeOpaqueBytes(final Bytes input) { - return decode(RLP.input(input)); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestEncoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestEncoder.java deleted file mode 100644 index c9fdb37fce..0000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestEncoder.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.core.encoding; - -import org.hyperledger.besu.datatypes.RequestType; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; -import org.hyperledger.besu.ethereum.rlp.RLP; -import org.hyperledger.besu.ethereum.rlp.RLPOutput; - -import org.apache.tuweni.bytes.Bytes; - -public class WithdrawalRequestEncoder { - - /** - * Encodes a Request into RLP format if it is a WithdrawalRequest. - * - * @param request The Request to encode, which must be a WithdrawalRequest. - * @param rlpOutput The RLPOutput to write the encoded data to. - * @throws IllegalArgumentException if the provided request is not a WithdrawalRequest. - */ - public static void encode(final Request request, final RLPOutput rlpOutput) { - if (!request.getType().equals(RequestType.WITHDRAWAL)) { - throw new IllegalArgumentException("The provided request is not of type WithdrawalRequest."); - } - encodeWithdrawalRequest((WithdrawalRequest) request, rlpOutput); - } - - /** - * Encodes the details of a WithdrawalRequest into RLP format. - * - * @param withdrawalRequest The WithdrawalRequest to encode. - * @param rlpOutput The RLPOutput to write the encoded data to. - */ - private static void encodeWithdrawalRequest( - final WithdrawalRequest withdrawalRequest, final RLPOutput rlpOutput) { - rlpOutput.startList(); - rlpOutput.writeBytes(withdrawalRequest.getSourceAddress()); - rlpOutput.writeBytes(withdrawalRequest.getValidatorPubkey()); - rlpOutput.writeUInt64Scalar(withdrawalRequest.getAmount()); - rlpOutput.endList(); - } - - public static Bytes encodeOpaqueBytes(final Request withdrawalRequest) { - return RLP.encode(rlpOutput -> encode(withdrawalRequest, rlpOutput)); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java index 480a1d8d7a..b8863fe142 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java @@ -218,7 +218,7 @@ public abstract class AbstractBlockProcessor implements BlockProcessor { blockHashLookup, OperationTracer.NO_TRACING); - maybeRequests = requestProcessor.get().process(context); + maybeRequests = Optional.of(requestProcessor.get().process(context)); } if (!rewardCoinbase(worldState, blockHeader, ommers, skipZeroBlockRewards)) { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BaseFeeBlockBodyValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BaseFeeBlockBodyValidator.java index aabc4ee5d0..0d43a47022 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BaseFeeBlockBodyValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BaseFeeBlockBodyValidator.java @@ -18,7 +18,6 @@ import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; -import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.core.feemarket.TransactionPriceCalculator; @@ -42,12 +41,11 @@ public class BaseFeeBlockBodyValidator extends MainnetBlockBodyValidator { final ProtocolContext context, final Block block, final List receipts, - final Optional> requests, final HeaderValidationMode ommerValidationMode, final BodyValidationMode bodyValidationMode) { return super.validateBodyLight( - context, block, receipts, requests, ommerValidationMode, bodyValidationMode) + context, block, receipts, ommerValidationMode, bodyValidationMode) && validateTransactionGasPrice(block); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BlockBodyValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BlockBodyValidator.java index c84be3771b..32000d12b9 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BlockBodyValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BlockBodyValidator.java @@ -17,11 +17,9 @@ package org.hyperledger.besu.ethereum.mainnet; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import java.util.List; -import java.util.Optional; /** Validates block bodies. */ public interface BlockBodyValidator { @@ -41,7 +39,6 @@ public interface BlockBodyValidator { ProtocolContext context, Block block, List receipts, - Optional> requests, Hash worldStateRootHash, final HeaderValidationMode ommerValidationMode); @@ -58,7 +55,6 @@ public interface BlockBodyValidator { ProtocolContext context, Block block, List receipts, - final Optional> requests, final HeaderValidationMode ommerValidationMode, final BodyValidationMode bodyValidationMode); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BodyValidation.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BodyValidation.java index 15e8c3c804..f9835c2de5 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BodyValidation.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BodyValidation.java @@ -15,6 +15,7 @@ package org.hyperledger.besu.ethereum.mainnet; import static org.hyperledger.besu.crypto.Hash.keccak256; +import static org.hyperledger.besu.crypto.Hash.sha256; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.core.BlockHeader; @@ -23,7 +24,6 @@ import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.core.Withdrawal; import org.hyperledger.besu.ethereum.core.encoding.EncodingContext; -import org.hyperledger.besu.ethereum.core.encoding.RequestEncoder; import org.hyperledger.besu.ethereum.core.encoding.TransactionEncoder; import org.hyperledger.besu.ethereum.core.encoding.WithdrawalEncoder; import org.hyperledger.besu.ethereum.rlp.RLP; @@ -31,6 +31,7 @@ import org.hyperledger.besu.ethereum.trie.MerkleTrie; import org.hyperledger.besu.ethereum.trie.patricia.SimpleMerklePatriciaTrie; import org.hyperledger.besu.evm.log.LogsBloomFilter; +import java.util.ArrayList; import java.util.List; import java.util.stream.IntStream; @@ -89,16 +90,24 @@ public final class BodyValidation { } /** - * Generates the requests root for a list of requests + * Generates the requests hash for a list of requests * * @param requests list of request - * @return the requests root + * @return the requests hash */ - public static Hash requestsRoot(final List requests) { - final MerkleTrie trie = trie(); + public static Hash requestsHash(final List requests) { + List requestHashes = new ArrayList<>(); IntStream.range(0, requests.size()) - .forEach(i -> trie.put(indexKey(i), RequestEncoder.encodeOpaqueBytes(requests.get(i)))); - return Hash.wrap(trie.getRootHash()); + .forEach( + i -> { + final Request request = requests.get(i); + final Bytes requestBytes = + Bytes.concatenate( + Bytes.of(request.getType().getSerializedType()), request.getData()); + requestHashes.add(sha256(requestBytes)); + }); + + return Hash.wrap(sha256(Bytes.wrap(requestHashes))); } /** diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidator.java index 68951f9f2a..1423183e94 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidator.java @@ -19,14 +19,11 @@ import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.TransactionReceipt; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; import org.hyperledger.besu.evm.log.LogsBloomFilter; import java.util.HashSet; import java.util.List; -import java.util.Optional; import java.util.Set; import com.google.common.annotations.VisibleForTesting; @@ -52,12 +49,11 @@ public class MainnetBlockBodyValidator implements BlockBodyValidator { final ProtocolContext context, final Block block, final List receipts, - final Optional> requests, final Hash worldStateRootHash, final HeaderValidationMode ommerValidationMode) { if (!validateBodyLight( - context, block, receipts, requests, ommerValidationMode, BodyValidationMode.FULL)) { + context, block, receipts, ommerValidationMode, BodyValidationMode.FULL)) { return false; } @@ -78,7 +74,6 @@ public class MainnetBlockBodyValidator implements BlockBodyValidator { final ProtocolContext context, final Block block, final List receipts, - final Optional> requests, final HeaderValidationMode ommerValidationMode, final BodyValidationMode bodyValidationMode) { if (bodyValidationMode == BodyValidationMode.NONE) { @@ -119,9 +114,6 @@ public class MainnetBlockBodyValidator implements BlockBodyValidator { return false; } - if (!validateRequests(block, requests, receipts)) { - return false; - } return true; } @@ -324,13 +316,4 @@ public class MainnetBlockBodyValidator implements BlockBodyValidator { return true; } - - private boolean validateRequests( - final Block block, - final Optional> requests, - final List receipts) { - final RequestsValidatorCoordinator requestValidator = - protocolSchedule.getByBlockHeader(block.getHeader()).getRequestsValidatorCoordinator(); - return requestValidator.validate(block, requests, receipts); - } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockImporter.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockImporter.java index 8646467a28..7d655ea4c3 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockImporter.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockImporter.java @@ -66,13 +66,7 @@ public class MainnetBlockImporter implements BlockImporter { final BodyValidationMode bodyValidationMode) { if (blockValidator.validateBlockForSyncing( - context, - block, - receipts, - block.getBody().getRequests(), - headerValidationMode, - ommerValidationMode, - bodyValidationMode)) { + context, block, receipts, headerValidationMode, ommerValidationMode, bodyValidationMode)) { context.getBlockchain().appendBlock(block, receipts); return new BlockImportResult(true); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java index 3426171477..23908664f8 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java @@ -14,8 +14,7 @@ */ package org.hyperledger.besu.ethereum.mainnet; -import static org.hyperledger.besu.ethereum.mainnet.requests.MainnetRequestsValidator.pragueRequestsProcessors; -import static org.hyperledger.besu.ethereum.mainnet.requests.MainnetRequestsValidator.pragueRequestsValidator; +import static org.hyperledger.besu.ethereum.mainnet.requests.MainnetRequestsProcessor.pragueRequestsProcessors; import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.config.PowAlgorithm; @@ -39,6 +38,7 @@ import org.hyperledger.besu.ethereum.mainnet.blockhash.PragueBlockHashProcessor; import org.hyperledger.besu.ethereum.mainnet.feemarket.BaseFeeMarket; import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; import org.hyperledger.besu.ethereum.mainnet.parallelization.MainnetParallelBlockProcessor; +import org.hyperledger.besu.ethereum.mainnet.requests.MainnetRequestsValidator; import org.hyperledger.besu.ethereum.mainnet.requests.RequestContractAddresses; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionValidator; @@ -789,7 +789,7 @@ public abstract class MainnetProtocolSpecs { .precompileContractRegistryBuilder(MainnetPrecompiledContractRegistries::prague) // EIP-7002 Withdrawals / EIP-6610 Deposits / EIP-7685 Requests - .requestsValidator(pragueRequestsValidator(requestContractAddresses)) + .requestsValidator(new MainnetRequestsValidator()) // EIP-7002 Withdrawals / EIP-6610 Deposits / EIP-7685 Requests .requestProcessorCoordinator(pragueRequestsProcessors(requestContractAddresses)) diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpec.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpec.java index b364679aa8..4f74a893fb 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpec.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpec.java @@ -22,7 +22,7 @@ import org.hyperledger.besu.ethereum.core.BlockImporter; import org.hyperledger.besu.ethereum.mainnet.blockhash.BlockHashProcessor; import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; import org.hyperledger.besu.ethereum.mainnet.requests.RequestProcessorCoordinator; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; +import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidator; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor; import org.hyperledger.besu.evm.EVM; import org.hyperledger.besu.evm.gascalculator.GasCalculator; @@ -78,7 +78,7 @@ public class ProtocolSpec { private final WithdrawalsValidator withdrawalsValidator; private final Optional withdrawalsProcessor; - private final RequestsValidatorCoordinator requestsValidatorCoordinator; + private final RequestsValidator requestsValidator; private final Optional requestProcessorCoordinator; private final BlockHashProcessor blockHashProcessor; private final boolean isPoS; @@ -110,7 +110,7 @@ public class ProtocolSpec { * @param feeMarket an {@link Optional} wrapping {@link FeeMarket} class if appropriate. * @param powHasher the proof-of-work hasher * @param withdrawalsProcessor the Withdrawals processor to use - * @param requestsValidatorCoordinator the request validator to use + * @param requestsValidator the request validator to use * @param requestProcessorCoordinator the request processor to use * @param blockHashProcessor the blockHash processor to use * @param isPoS indicates whether the current spec is PoS @@ -142,7 +142,7 @@ public class ProtocolSpec { final Optional powHasher, final WithdrawalsValidator withdrawalsValidator, final Optional withdrawalsProcessor, - final RequestsValidatorCoordinator requestsValidatorCoordinator, + final RequestsValidator requestsValidator, final Optional requestProcessorCoordinator, final BlockHashProcessor blockHashProcessor, final boolean isPoS, @@ -171,7 +171,7 @@ public class ProtocolSpec { this.powHasher = powHasher; this.withdrawalsValidator = withdrawalsValidator; this.withdrawalsProcessor = withdrawalsProcessor; - this.requestsValidatorCoordinator = requestsValidatorCoordinator; + this.requestsValidator = requestsValidator; this.requestProcessorCoordinator = requestProcessorCoordinator; this.blockHashProcessor = blockHashProcessor; this.isPoS = isPoS; @@ -375,8 +375,8 @@ public class ProtocolSpec { return withdrawalsProcessor; } - public RequestsValidatorCoordinator getRequestsValidatorCoordinator() { - return requestsValidatorCoordinator; + public RequestsValidator getRequestsValidator() { + return requestsValidator; } public Optional getRequestProcessorCoordinator() { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java index 0d792b7870..c3b5ef6dc0 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java @@ -31,8 +31,9 @@ import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.FlexiblePrivacyPrecompiledContract; import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.PrivacyPluginPrecompiledContract; import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.PrivacyPrecompiledContract; +import org.hyperledger.besu.ethereum.mainnet.requests.ProhibitedRequestValidator; import org.hyperledger.besu.ethereum.mainnet.requests.RequestProcessorCoordinator; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; +import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidator; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionValidator; import org.hyperledger.besu.evm.EVM; @@ -80,8 +81,7 @@ public class ProtocolSpecBuilder { private WithdrawalsValidator withdrawalsValidator = new WithdrawalsValidator.ProhibitedWithdrawals(); private WithdrawalsProcessor withdrawalsProcessor; - private RequestsValidatorCoordinator requestsValidatorCoordinator = - RequestsValidatorCoordinator.empty(); + private RequestsValidator requestsValidator = new ProhibitedRequestValidator(); private RequestProcessorCoordinator requestProcessorCoordinator; protected BlockHashProcessor blockHashProcessor; private FeeMarket feeMarket = FeeMarket.legacy(); @@ -268,8 +268,8 @@ public class ProtocolSpecBuilder { } public ProtocolSpecBuilder requestsValidator( - final RequestsValidatorCoordinator requestsValidatorCoordinator) { - this.requestsValidatorCoordinator = requestsValidatorCoordinator; + final RequestsValidator requestsValidatorCoordinator) { + this.requestsValidator = requestsValidatorCoordinator; return this; } @@ -402,7 +402,7 @@ public class ProtocolSpecBuilder { Optional.ofNullable(powHasher), withdrawalsValidator, Optional.ofNullable(withdrawalsProcessor), - requestsValidatorCoordinator, + requestsValidator, Optional.ofNullable(requestProcessorCoordinator), blockHashProcessor, isPoS, diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/SystemCallProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/SystemCallProcessor.java index f74de79442..06aa3efd8e 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/SystemCallProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/SystemCallProcessor.java @@ -56,7 +56,8 @@ public class SystemCallProcessor { * @param blockHeader the current block header. * @param operationTracer the operation tracer for tracing EVM operations. * @param blockHashLookup the block hash lookup function. - * @return the output data from the call + * @return the output data from the call. If no code exists at the callAddress then an empty Bytes + * is returned. */ public Bytes process( final Address callAddress, @@ -69,7 +70,7 @@ public class SystemCallProcessor { final Account maybeContract = worldState.get(callAddress); if (maybeContract == null) { LOG.trace("System call address not found {}", callAddress); - return null; + return Bytes.EMPTY; } final AbstractMessageProcessor messageProcessor = diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/AbstractSystemCallRequestProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/AbstractSystemCallRequestProcessor.java deleted file mode 100644 index a7d959f4b9..0000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/AbstractSystemCallRequestProcessor.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.mainnet.requests; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.mainnet.SystemCallProcessor; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -import org.apache.tuweni.bytes.Bytes; - -/** - * Abstract base class for processing system call requests. - * - * @param The type of request to be processed. - */ -public abstract class AbstractSystemCallRequestProcessor - implements RequestProcessor { - - /** - * Processes a system call and converts the result into requests of type T. - * - * @param context The request context being processed. - * @return An {@link Optional} containing a list of {@link T} objects if any are found - */ - @Override - public Optional> process(final ProcessRequestContext context) { - - SystemCallProcessor systemCallProcessor = - new SystemCallProcessor(context.protocolSpec().getTransactionProcessor()); - - Bytes systemCallOutput = - systemCallProcessor.process( - getCallAddress(), - context.mutableWorldState().updater(), - context.blockHeader(), - context.operationTracer(), - context.blockHashLookup()); - - List requests = parseRequests(systemCallOutput); - return Optional.ofNullable(requests); - } - - /** - * Parses the provided bytes into a list of {@link T} objects. - * - * @param bytes The bytes representing requests. - * @return A list of parsed {@link T} objects. - */ - protected List parseRequests(final Bytes bytes) { - if (bytes == null) { - return null; - } - final List requests = new ArrayList<>(); - if (bytes.isEmpty()) { - return requests; - } - int count = bytes.size() / getRequestBytesSize(); - for (int i = 0; i < count; i++) { - Bytes requestBytes = bytes.slice(i * getRequestBytesSize(), getRequestBytesSize()); - requests.add(parseRequest(requestBytes)); - } - return requests; - } - - /** - * Parses a single request from the provided bytes. - * - * @param requestBytes The bytes representing a single request. - * @return A parsed {@link T} object. - */ - protected abstract T parseRequest(final Bytes requestBytes); - - /** - * Gets the call address for the specific request type. - * - * @return The call address. - */ - protected abstract Address getCallAddress(); - - /** - * Gets the size of the bytes representing a single request. - * - * @return The size of the bytes representing a single request. - */ - protected abstract int getRequestBytesSize(); -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ConsolidationRequestProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ConsolidationRequestProcessor.java deleted file mode 100644 index 641720670f..0000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ConsolidationRequestProcessor.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.mainnet.requests; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.ethereum.core.ConsolidationRequest; - -import org.apache.tuweni.bytes.Bytes; - -public class ConsolidationRequestProcessor - extends AbstractSystemCallRequestProcessor { - public static final Address CONSOLIDATION_REQUEST_CONTRACT_ADDRESS = - Address.fromHexString("0x00b42dbF2194e931E80326D950320f7d9Dbeac02"); - - private static final int ADDRESS_BYTES = 20; - private static final int PUBLIC_KEY_BYTES = 48; - private static final int CONSOLIDATION_REQUEST_BYTES_SIZE = - ADDRESS_BYTES + PUBLIC_KEY_BYTES + PUBLIC_KEY_BYTES; - private final Address consolidationRequestContractAddress; - - public ConsolidationRequestProcessor(final Address consolidationRequestContractAddress) { - this.consolidationRequestContractAddress = consolidationRequestContractAddress; - } - - /** - * Gets the call address for consolidation requests. - * - * @return The call address. - */ - @Override - protected Address getCallAddress() { - return consolidationRequestContractAddress; - } - - /** - * Gets the size of the bytes representing a single consolidation request. - * - * @return The size of the bytes representing a single consolidation request. - */ - @Override - protected int getRequestBytesSize() { - return CONSOLIDATION_REQUEST_BYTES_SIZE; - } - - /** - * Parses a single consolidation request from the provided bytes. - * - * @param requestBytes The bytes representing a single consolidation request. - * @return A parsed {@link ConsolidationRequest} object. - */ - @Override - protected ConsolidationRequest parseRequest(final Bytes requestBytes) { - final Address sourceAddress = Address.wrap(requestBytes.slice(0, ADDRESS_BYTES)); - final BLSPublicKey sourcePublicKey = - BLSPublicKey.wrap(requestBytes.slice(ADDRESS_BYTES, PUBLIC_KEY_BYTES)); - final BLSPublicKey targetPublicKey = - BLSPublicKey.wrap(requestBytes.slice(ADDRESS_BYTES + PUBLIC_KEY_BYTES, PUBLIC_KEY_BYTES)); - return new ConsolidationRequest(sourceAddress, sourcePublicKey, targetPublicKey); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ConsolidationRequestValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ConsolidationRequestValidator.java deleted file mode 100644 index f03de5e6b5..0000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ConsolidationRequestValidator.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.mainnet.requests; - -import static org.hyperledger.besu.ethereum.mainnet.requests.RequestUtil.getConsolidationRequests; - -import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.ConsolidationRequest; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.core.TransactionReceipt; - -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ConsolidationRequestValidator implements RequestValidator { - - private static final Logger LOG = LoggerFactory.getLogger(ConsolidationRequestValidator.class); - - public static final int MAX_CONSOLIDATION_REQUESTS_PER_BLOCK = 1; - - private boolean validateConsolidationRequestParameter( - final Optional> consolidationRequests) { - return consolidationRequests.isPresent(); - } - - private boolean validateConsolidationRequestsInBlock( - final Block block, final List consolidationRequests) { - final Hash blockHash = block.getHash(); - - final List consolidationRequestsInBlock = - block - .getBody() - .getRequests() - .flatMap(requests -> getConsolidationRequests(Optional.of(requests))) - .orElse(Collections.emptyList()); - - if (consolidationRequestsInBlock.size() > MAX_CONSOLIDATION_REQUESTS_PER_BLOCK) { - LOG.warn( - "Block {} has more than the allowed maximum number of consolidation requests", blockHash); - return false; - } - - // Validate ConsolidationRequests - final boolean expectedConsolidationRequestMatch = - consolidationRequests.equals(consolidationRequestsInBlock); - if (!expectedConsolidationRequestMatch) { - LOG.warn( - "Block {} has a mismatch between block consolidations and RPC consolidation requests (in_block = {}, " - + "expected = {})", - blockHash, - consolidationRequestsInBlock, - consolidationRequests); - return false; - } - return true; - } - - @Override - public boolean validate( - final Block block, final List requests, final List receipts) { - var consolidationRequests = - getConsolidationRequests(Optional.of(requests)).orElse(Collections.emptyList()); - return validateConsolidationRequestsInBlock(block, consolidationRequests); - } - - @Override - public boolean validateParameter(final Optional> request) { - if (request.isEmpty()) { - return true; - } - var consolidationRequests = - RequestUtil.filterRequestsOfType(request.get(), ConsolidationRequest.class); - return validateConsolidationRequestParameter(Optional.of(consolidationRequests)); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositRequestProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositRequestProcessor.java index 8902ecc510..37e266f015 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositRequestProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositRequestProcessor.java @@ -15,22 +15,19 @@ package org.hyperledger.besu.ethereum.mainnet.requests; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.DepositRequest; +import org.hyperledger.besu.datatypes.RequestType; import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.TransactionReceipt; -import org.hyperledger.besu.ethereum.core.encoding.DepositRequestDecoder; +import org.hyperledger.besu.ethereum.core.encoding.DepositLogDecoder; -import java.util.Collections; import java.util.List; import java.util.Optional; import com.google.common.annotations.VisibleForTesting; +import org.apache.tuweni.bytes.Bytes; public class DepositRequestProcessor implements RequestProcessor { - public static final Address DEFAULT_DEPOSIT_CONTRACT_ADDRESS = - Address.fromHexString("0x00000000219ab540356cbb839cbe05303d7705fa"); - private final Optional

depositContractAddress; public DepositRequestProcessor(final Address depositContractAddress) { @@ -38,26 +35,22 @@ public class DepositRequestProcessor implements RequestProcessor { } @Override - public Optional> process(final ProcessRequestContext context) { + public Request process(final ProcessRequestContext context) { if (depositContractAddress.isEmpty()) { - return Optional.empty(); + return new Request(RequestType.DEPOSIT, Bytes.EMPTY); } - List depositRequests = - findDepositRequestsFromReceipts(context.transactionReceipts()); - return Optional.of(depositRequests); + Optional depositRequests = getDepositRequestData(context.transactionReceipts()); + return new Request(RequestType.DEPOSIT, depositRequests.orElse(Bytes.EMPTY)); } @VisibleForTesting - List findDepositRequestsFromReceipts( - final List transactionReceipts) { - return depositContractAddress - .map( - address -> - transactionReceipts.stream() - .flatMap(receipt -> receipt.getLogsList().stream()) - .filter(log -> address.equals(log.getLogger())) - .map(DepositRequestDecoder::decodeFromLog) - .toList()) - .orElse(Collections.emptyList()); + Optional getDepositRequestData(final List transactionReceipts) { + return depositContractAddress.flatMap( + address -> + transactionReceipts.stream() + .flatMap(receipt -> receipt.getLogsList().stream()) + .filter(log -> address.equals(log.getLogger())) + .map(DepositLogDecoder::decodeFromLog) + .reduce(Bytes::concatenate)); } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositRequestValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositRequestValidator.java deleted file mode 100644 index 6c9eedf305..0000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositRequestValidator.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.mainnet.requests; - -import static org.hyperledger.besu.ethereum.mainnet.requests.RequestUtil.getDepositRequests; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.DepositRequest; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.core.TransactionReceipt; -import org.hyperledger.besu.ethereum.core.encoding.DepositRequestDecoder; -import org.hyperledger.besu.evm.log.Log; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class DepositRequestValidator implements RequestValidator { - - private static final Logger LOG = LoggerFactory.getLogger(DepositRequestValidator.class); - private final Address depositContractAddress; - - public DepositRequestValidator(final Address depositContractAddress) { - this.depositContractAddress = depositContractAddress; - } - - @Override - public boolean validateParameter(final Optional> depositRequests) { - return depositRequests.isPresent(); - } - - public boolean validateDepositRequests( - final Block block, - final List actualDepositRequests, - final List receipts) { - - List expectedDepositRequests = new ArrayList<>(); - - for (TransactionReceipt receipt : receipts) { - for (Log log : receipt.getLogsList()) { - if (depositContractAddress.equals(log.getLogger())) { - DepositRequest depositRequest = DepositRequestDecoder.decodeFromLog(log); - expectedDepositRequests.add(depositRequest); - } - } - } - - boolean isValid = actualDepositRequests.equals(expectedDepositRequests); - - if (!isValid) { - LOG.warn( - "Deposits validation failed. Deposits from block body do not match deposits from logs. Block hash: {}", - block.getHash()); - LOG.debug( - "Deposits from logs: {}, deposits from block body: {}", - expectedDepositRequests, - actualDepositRequests); - } - - return isValid; - } - - @Override - public boolean validate( - final Block block, final List requests, final List receipts) { - var depositRequests = getDepositRequests(Optional.of(requests)).orElse(Collections.emptyList()); - return validateDepositRequests(block, depositRequests, receipts); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsProcessor.java new file mode 100644 index 0000000000..d1c290c407 --- /dev/null +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsProcessor.java @@ -0,0 +1,39 @@ +/* + * Copyright contributors to Hyperledger Besu. + * + * 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.mainnet.requests; + +import org.hyperledger.besu.datatypes.RequestType; + +public class MainnetRequestsProcessor { + + public static RequestProcessorCoordinator pragueRequestsProcessors( + final RequestContractAddresses requestContractAddresses) { + return new RequestProcessorCoordinator.Builder() + .addProcessor( + RequestType.WITHDRAWAL, + new SystemCallRequestProcessor( + requestContractAddresses.getWithdrawalRequestContractAddress(), + RequestType.WITHDRAWAL)) + .addProcessor( + RequestType.CONSOLIDATION, + new SystemCallRequestProcessor( + requestContractAddresses.getConsolidationRequestContractAddress(), + RequestType.CONSOLIDATION)) + .addProcessor( + RequestType.DEPOSIT, + new DepositRequestProcessor(requestContractAddresses.getDepositContractAddress())) + .build(); + } +} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsValidator.java index 9c86d18f7a..fb49ba71fc 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsValidator.java @@ -14,34 +14,47 @@ */ package org.hyperledger.besu.ethereum.mainnet.requests; -import org.hyperledger.besu.datatypes.RequestType; - -public class MainnetRequestsValidator { - public static RequestsValidatorCoordinator pragueRequestsValidator( - final RequestContractAddresses requestContractAddresses) { - return new RequestsValidatorCoordinator.Builder() - .addValidator(RequestType.WITHDRAWAL, new WithdrawalRequestValidator()) - .addValidator(RequestType.CONSOLIDATION, new ConsolidationRequestValidator()) - .addValidator( - RequestType.DEPOSIT, - new DepositRequestValidator(requestContractAddresses.getDepositContractAddress())) - .build(); +import org.hyperledger.besu.ethereum.core.Request; + +import java.util.List; +import java.util.Optional; + +import com.google.common.collect.Ordering; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Validates requests within a block against a set of predefined validators. This class delegates + * the validation of requests of specific types to corresponding validators. It ensures that + * requests are properly ordered, have a valid hash, and meet the criteria defined by their + * validators. + */ +public class MainnetRequestsValidator implements RequestsValidator { + private static final Logger LOG = LoggerFactory.getLogger(MainnetRequestsValidator.class); + + /** + * Validates a block's requests by ensuring they are correctly ordered, have a valid hash, and + * pass their respective type-specific validations. + * + * @param maybeRequests The list of requests to be validated. + * @return true if all validations pass; false otherwise. + */ + @Override + public boolean validate(final Optional> maybeRequests) { + if (maybeRequests.isEmpty()) { + LOG.warn("Must contain requests (even if empty list)"); + return false; + } + + if (!isRequestOrderValid(maybeRequests.get())) { + LOG.warn("Ordering across requests must be ascending by type"); + return false; + } + + return true; } - public static RequestProcessorCoordinator pragueRequestsProcessors( - final RequestContractAddresses requestContractAddresses) { - return new RequestProcessorCoordinator.Builder() - .addProcessor( - RequestType.WITHDRAWAL, - new WithdrawalRequestProcessor( - requestContractAddresses.getWithdrawalRequestContractAddress())) - .addProcessor( - RequestType.CONSOLIDATION, - new ConsolidationRequestProcessor( - requestContractAddresses.getConsolidationRequestContractAddress())) - .addProcessor( - RequestType.DEPOSIT, - new DepositRequestProcessor(requestContractAddresses.getDepositContractAddress())) - .build(); + private static boolean isRequestOrderValid(final List requests) { + return Ordering.natural().onResultOf(Request::getType).isOrdered(requests); } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ProhibitedRequestValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ProhibitedRequestValidator.java new file mode 100644 index 0000000000..4545ff3530 --- /dev/null +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ProhibitedRequestValidator.java @@ -0,0 +1,38 @@ +/* + * Copyright contributors to Besu. + * + * 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.mainnet.requests; + +import org.hyperledger.besu.ethereum.core.Request; + +import java.util.List; +import java.util.Optional; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ProhibitedRequestValidator implements RequestsValidator { + private static final Logger LOG = LoggerFactory.getLogger(MainnetRequestsValidator.class); + + @Override + public boolean validate(final Optional> maybeRequests) { + boolean hasRequests = maybeRequests.isPresent(); + + if (hasRequests) { + LOG.warn("There are requests but requests are prohibited"); + } + + return !hasRequests; + } +} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ProhibitedRequestsValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ProhibitedRequestsValidator.java deleted file mode 100644 index 362da52728..0000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ProhibitedRequestsValidator.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.mainnet.requests; - -import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.core.TransactionReceipt; - -import java.util.List; -import java.util.Optional; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** Validates that a block does not contain any prohibited requests. */ -public class ProhibitedRequestsValidator implements RequestValidator { - private static final Logger LOG = LoggerFactory.getLogger(ProhibitedRequestsValidator.class); - - @Override - public boolean validate( - final Block block, final List request, final List receipts) { - boolean hasRequests = block.getBody().getRequests().isPresent(); - boolean hasRequestsRoot = block.getHeader().getRequestsRoot().isPresent(); - - if (hasRequests) { - LOG.warn("Block {} contains requests but requests are prohibited", block.getHash()); - } - - if (hasRequestsRoot) { - LOG.warn( - "Block {} header contains requests_root but requests are prohibited", block.getHash()); - } - - return !(hasRequests || hasRequestsRoot); - } - - @Override - public boolean validateParameter(final Optional> request) { - return request.isEmpty(); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestContractAddresses.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestContractAddresses.java index b75677dda7..d16d1bddbc 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestContractAddresses.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestContractAddresses.java @@ -14,10 +14,6 @@ */ package org.hyperledger.besu.ethereum.mainnet.requests; -import static org.hyperledger.besu.ethereum.mainnet.requests.ConsolidationRequestProcessor.CONSOLIDATION_REQUEST_CONTRACT_ADDRESS; -import static org.hyperledger.besu.ethereum.mainnet.requests.DepositRequestProcessor.DEFAULT_DEPOSIT_CONTRACT_ADDRESS; -import static org.hyperledger.besu.ethereum.mainnet.requests.WithdrawalRequestProcessor.DEFAULT_WITHDRAWAL_REQUEST_CONTRACT_ADDRESS; - import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.datatypes.Address; @@ -26,6 +22,13 @@ public class RequestContractAddresses { private final Address depositContractAddress; private final Address consolidationRequestContractAddress; + public static final Address DEFAULT_WITHDRAWAL_REQUEST_CONTRACT_ADDRESS = + Address.fromHexString("0x09FC772D0857550724B07B850A4323F39112AAAA"); + public static final Address DEFAULT_CONSOLIDATION_REQUEST_CONTRACT_ADDRESS = + Address.fromHexString("0x01ABEA29659E5E97C95107F20BB753CD3E09BBBB"); + public static final Address DEFAULT_DEPOSIT_CONTRACT_ADDRESS = + Address.fromHexString("0x00000000219ab540356cbb839cbe05303d7705fa"); + public RequestContractAddresses( final Address withdrawalRequestContractAddress, final Address depositContractAddress, @@ -44,7 +47,7 @@ public class RequestContractAddresses { genesisConfigOptions.getDepositContractAddress().orElse(DEFAULT_DEPOSIT_CONTRACT_ADDRESS), genesisConfigOptions .getConsolidationRequestContractAddress() - .orElse(CONSOLIDATION_REQUEST_CONTRACT_ADDRESS)); + .orElse(DEFAULT_CONSOLIDATION_REQUEST_CONTRACT_ADDRESS)); } public Address getWithdrawalRequestContractAddress() { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestProcessor.java index 55f3cd4178..dd471aec1e 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestProcessor.java @@ -16,9 +16,6 @@ package org.hyperledger.besu.ethereum.mainnet.requests; import org.hyperledger.besu.ethereum.core.Request; -import java.util.List; -import java.util.Optional; - public interface RequestProcessor { - Optional> process(final ProcessRequestContext context); + Request process(final ProcessRequestContext context); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestProcessorCoordinator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestProcessorCoordinator.java index b98274729d..7dd3b5c6dd 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestProcessorCoordinator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestProcessorCoordinator.java @@ -17,9 +17,7 @@ package org.hyperledger.besu.ethereum.mainnet.requests; import org.hyperledger.besu.datatypes.RequestType; import org.hyperledger.besu.ethereum.core.Request; -import java.util.ArrayList; import java.util.List; -import java.util.Optional; import com.google.common.collect.ImmutableSortedMap; @@ -37,18 +35,10 @@ public class RequestProcessorCoordinator { this.processors = processors; } - public Optional> process(final ProcessRequestContext context) { - List requests = null; - for (RequestProcessor requestProcessor : processors.values()) { - var r = requestProcessor.process(context); - if (r.isPresent()) { - if (requests == null) { - requests = new ArrayList<>(); - } - requests.addAll(r.get()); - } - } - return Optional.ofNullable(requests); + public List process(final ProcessRequestContext context) { + return processors.values().stream() + .map(requestProcessor -> requestProcessor.process(context)) + .toList(); } public static class Builder { @@ -62,7 +52,12 @@ public class RequestProcessorCoordinator { } public RequestProcessorCoordinator build() { - return new RequestProcessorCoordinator(requestProcessorBuilder.build()); + final ImmutableSortedMap processors = + requestProcessorBuilder.build(); + if (processors.isEmpty()) { + throw new IllegalStateException("No processors added to RequestProcessorCoordinator"); + } + return new RequestProcessorCoordinator(processors); } } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestUtil.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestUtil.java deleted file mode 100644 index f3a10161a4..0000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestUtil.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.mainnet.requests; - -import org.hyperledger.besu.ethereum.core.ConsolidationRequest; -import org.hyperledger.besu.ethereum.core.DepositRequest; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -public class RequestUtil { - - /** - * Filters and returns a list of requests of a specific type from a given list of requests. - * - * @param The type of the request to filter by, extending Request. - * @param requests The list of requests to filter. - * @param requestType The class of the request type to filter for. - * @return A List containing only requests of the specified type, or an empty list if the input - * list is null or contains no requests of the specified type. - */ - public static List filterRequestsOfType( - final List requests, final Class requestType) { - if (requests == null) { - return Collections.emptyList(); - } - return requests.stream().filter(requestType::isInstance).map(requestType::cast).toList(); - } - - public static Optional> getDepositRequests( - final Optional> requests) { - return requests.map(r -> filterRequestsOfType(r, DepositRequest.class)); - } - - public static Optional> getWithdrawalRequests( - final Optional> requests) { - return requests.map(r -> filterRequestsOfType(r, WithdrawalRequest.class)); - } - - public static Optional> getConsolidationRequests( - final Optional> requests) { - return requests.map(r -> filterRequestsOfType(r, ConsolidationRequest.class)); - } - - /** - * Combines multiple optional lists of requests into a single optional list. - * - * @param maybeDepositRequests Optional list of deposit requests. - * @param maybeWithdrawalRequest Optional list of withdrawal requests. - * @param maybeConsolidationRequest Optional list of withdrawal requests. - * @return An Optional containing the combined list of requests, or an empty Optional if all input - * lists are empty. - */ - public static Optional> combine( - final Optional> maybeDepositRequests, - final Optional> maybeWithdrawalRequest, - final Optional> maybeConsolidationRequest) { - if (maybeDepositRequests.isEmpty() - && maybeWithdrawalRequest.isEmpty() - && maybeConsolidationRequest.isEmpty()) { - return Optional.empty(); - } - List requests = new ArrayList<>(); - maybeDepositRequests.ifPresent(requests::addAll); - maybeWithdrawalRequest.ifPresent(requests::addAll); - maybeConsolidationRequest.ifPresent(requests::addAll); - return Optional.of(requests); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestsValidator.java similarity index 63% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestValidator.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestsValidator.java index 74fd8cd7eb..a05afa8128 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestsValidator.java @@ -1,5 +1,5 @@ /* - * Copyright contributors to Hyperledger Besu. + * Copyright contributors to Besu. * * 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 @@ -14,17 +14,11 @@ */ package org.hyperledger.besu.ethereum.mainnet.requests; -import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.core.TransactionReceipt; import java.util.List; import java.util.Optional; -/** Interface for request validation logic. */ -public interface RequestValidator { - boolean validate( - final Block block, final List request, final List receipts); - - boolean validateParameter(final Optional> request); +public interface RequestsValidator { + boolean validate(Optional> maybeRequests); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestsValidatorCoordinator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestsValidatorCoordinator.java deleted file mode 100644 index 7b8f5cf497..0000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestsValidatorCoordinator.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.mainnet.requests; - -import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.datatypes.RequestType; -import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.core.TransactionReceipt; -import org.hyperledger.besu.ethereum.mainnet.BodyValidation; - -import java.util.List; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -import com.google.common.collect.ImmutableSortedMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Validates requests within a block against a set of predefined validators. This class delegates - * the validation of requests of specific types to corresponding validators. It ensures that - * requests are properly ordered, have a valid root, and meet the criteria defined by their - * validators. - */ -public class RequestsValidatorCoordinator { - private static final Logger LOG = LoggerFactory.getLogger(RequestsValidatorCoordinator.class); - private final ImmutableSortedMap validators; - - public static RequestsValidatorCoordinator empty() { - return new Builder().build(); - } - - /** - * Constructs a new RequestsDelegateValidator with a mapping of request types to their respective - * validators. - * - * @param validators An immutable map of request types to their corresponding validators. - */ - private RequestsValidatorCoordinator( - final ImmutableSortedMap validators) { - this.validators = validators; - } - - /** - * Validates a block's requests by ensuring they are correctly ordered, have a valid root, and - * pass their respective type-specific validations. - * - * @param block The block containing the requests to be validated. - * @param maybeRequests The list of requests contained within the block. - * @param receipts The list of transaction receipts corresponding to the requests. - * @return true if all validations pass; false otherwise. - */ - public boolean validate( - final Block block, - final Optional> maybeRequests, - final List receipts) { - - if (validators.isEmpty()) { - return isRequestsEmpty(block, maybeRequests); - } - - if (!isRequestsRootValid(block, maybeRequests)) { - return false; - } - - if (!isRequestOrderValid(maybeRequests.get())) { - final Hash blockHash = block.getHash(); - LOG.warn("Block {} the ordering across requests must be ascending by type", blockHash); - return false; - } - return validateRequests(block, maybeRequests.get(), receipts); - } - - /** - * Validates the requests contained within a block against their respective type-specific - * validators. - * - * @param block The block containing the requests. - * @param requests The list of requests to be validated. - * @param receipts The list of transaction receipts corresponding to the requests. - * @return true if all requests pass their type-specific validations; false otherwise. - */ - private boolean validateRequests( - final Block block, final List requests, final List receipts) { - return requestTypes(requests).stream() - .allMatch(type -> validateRequestOfType(type, block, requests, receipts)); - } - - private boolean isRequestsRootValid(final Block block, final Optional> requests) { - final Hash blockHash = block.getHash(); - final Optional maybeRequestsRoot = block.getHeader().getRequestsRoot(); - - if (maybeRequestsRoot.isEmpty()) { - LOG.warn("Block {} must contain requests root", blockHash); - return false; - } - - if (block.getBody().getRequests().isEmpty()) { - LOG.warn("Block body {} must contain requests (even if empty list)", blockHash); - return false; - } - - if (requests.isEmpty()) { - LOG.warn("Block {} must contain requests (even if empty list)", blockHash); - return false; - } - - final Hash expectedRequestsRoot = BodyValidation.requestsRoot(requests.get()); - if (!expectedRequestsRoot.equals(maybeRequestsRoot.get())) { - LOG.warn( - "Block {} requests root does not match expected hash root for requests in block", - blockHash); - return false; - } - return true; - } - - private boolean isRequestsEmpty(final Block block, final Optional> requests) { - final Hash blockHash = block.getHash(); - final Optional maybeRequestsRoot = block.getHeader().getRequestsRoot(); - - if (maybeRequestsRoot.isPresent()) { - LOG.warn("Block {} must not contain requests root", blockHash); - return false; - } - - if (block.getBody().getRequests().isPresent()) { - LOG.warn("Block body {} must not contain requests", blockHash); - return false; - } - - if (requests.isPresent()) { - LOG.warn("Block {} must not contain requests", blockHash); - return false; - } - return true; - } - - private boolean validateRequestOfType( - final RequestType type, - final Block block, - final List requests, - final List receipts) { - - Optional requestValidator = getRequestValidator(type); - if (requestValidator.isEmpty()) { - LOG.warn("Block {} contains prohibited requests of type: {}", block.getHash(), type); - return false; - } - List typedRequests = filterRequestsOfType(requests, type); - return requestValidator.get().validate(block, typedRequests, receipts); - } - - public Optional getRequestValidator(final RequestType requestType) { - return Optional.ofNullable(validators.get(requestType)); - } - - private static Set requestTypes(final List requests) { - return requests.stream().map(Request::getType).collect(Collectors.toSet()); - } - - private static boolean isRequestOrderValid(final List requests) { - return IntStream.range(0, requests.size() - 1) - .allMatch(i -> requests.get(i).getType().compareTo(requests.get(i + 1).getType()) <= 0); - } - - private static List filterRequestsOfType( - final List requests, final RequestType type) { - return requests.stream() - .filter(request -> request.getType() == type) - .collect(Collectors.toList()); - } - - public static class Builder { - private final ImmutableSortedMap.Builder validatorsBuilder = - ImmutableSortedMap.naturalOrder(); - - public Builder addValidator(final RequestType type, final RequestValidator validator) { - this.validatorsBuilder.put(type, validator); - return this; - } - - public RequestsValidatorCoordinator build() { - return new RequestsValidatorCoordinator(validatorsBuilder.build()); - } - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/SystemCallRequestProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/SystemCallRequestProcessor.java new file mode 100644 index 0000000000..3bcfe02c2a --- /dev/null +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/SystemCallRequestProcessor.java @@ -0,0 +1,57 @@ +/* + * Copyright contributors to Hyperledger Besu. + * + * 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.mainnet.requests; + +import org.hyperledger.besu.datatypes.Address; +import org.hyperledger.besu.datatypes.RequestType; +import org.hyperledger.besu.ethereum.core.Request; +import org.hyperledger.besu.ethereum.mainnet.SystemCallProcessor; + +import org.apache.tuweni.bytes.Bytes; + +/** Processes system call requests. */ +public class SystemCallRequestProcessor implements RequestProcessor { + + private final Address callAddress; + private final RequestType requestType; + + public SystemCallRequestProcessor(final Address callAddress, final RequestType requestType) { + this.callAddress = callAddress; + this.requestType = requestType; + } + + /** + * Processes a system call and converts the result as a Request. + * + * @param context The request context being processed. + * @return A {@link Request} request + */ + @Override + public Request process(final ProcessRequestContext context) { + + SystemCallProcessor systemCallProcessor = + new SystemCallProcessor(context.protocolSpec().getTransactionProcessor()); + + Bytes systemCallOutput = + systemCallProcessor.process( + callAddress, + context.mutableWorldState().updater(), + context.blockHeader(), + context.operationTracer(), + context.blockHashLookup()); + + return new Request(requestType, systemCallOutput); + } +} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/WithdrawalRequestProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/WithdrawalRequestProcessor.java deleted file mode 100644 index d4021c9a10..0000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/WithdrawalRequestProcessor.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.mainnet.requests; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; - -import org.apache.tuweni.bytes.Bytes; -import org.apache.tuweni.units.bigints.UInt64; - -/** Processor for handling withdrawal requests. */ -public class WithdrawalRequestProcessor - extends AbstractSystemCallRequestProcessor { - - public static final Address DEFAULT_WITHDRAWAL_REQUEST_CONTRACT_ADDRESS = - Address.fromHexString("0x00A3ca265EBcb825B45F985A16CEFB49958cE017"); - - private static final int ADDRESS_BYTES = 20; - private static final int PUBLIC_KEY_BYTES = 48; - private static final int AMOUNT_BYTES = 8; - private static final int WITHDRAWAL_REQUEST_BYTES_SIZE = - ADDRESS_BYTES + PUBLIC_KEY_BYTES + AMOUNT_BYTES; - - private final Address withdrawalRequestContractAddress; - - public WithdrawalRequestProcessor(final Address withdrawalRequestContractAddress) { - this.withdrawalRequestContractAddress = withdrawalRequestContractAddress; - } - - /** - * Gets the call address for withdrawal requests. - * - * @return The call address. - */ - @Override - protected Address getCallAddress() { - return withdrawalRequestContractAddress; - } - - /** - * Gets the size of the bytes representing a single withdrawal request. - * - * @return The size of the bytes representing a single withdrawal request. - */ - @Override - protected int getRequestBytesSize() { - return WITHDRAWAL_REQUEST_BYTES_SIZE; - } - - /** - * Parses a single withdrawal request from the provided bytes. - * - * @param requestBytes The bytes representing a single withdrawal request. - * @return A parsed {@link WithdrawalRequest} object. - */ - @Override - protected WithdrawalRequest parseRequest(final Bytes requestBytes) { - final Address sourceAddress = Address.wrap(requestBytes.slice(0, ADDRESS_BYTES)); - final BLSPublicKey validatorPublicKey = - BLSPublicKey.wrap(requestBytes.slice(ADDRESS_BYTES, PUBLIC_KEY_BYTES)); - final UInt64 amount = - UInt64.fromBytes(requestBytes.slice(ADDRESS_BYTES + PUBLIC_KEY_BYTES, AMOUNT_BYTES)); - return new WithdrawalRequest(sourceAddress, validatorPublicKey, GWei.of(amount)); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/WithdrawalRequestValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/WithdrawalRequestValidator.java deleted file mode 100644 index fc108b798f..0000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/WithdrawalRequestValidator.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.mainnet.requests; - -import static org.hyperledger.besu.ethereum.mainnet.requests.RequestUtil.getWithdrawalRequests; - -import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.core.TransactionReceipt; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; - -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class WithdrawalRequestValidator implements RequestValidator { - - public static final int MAX_WITHDRAWAL_REQUESTS_PER_BLOCK = 16; - - private static final Logger LOG = LoggerFactory.getLogger(WithdrawalRequestValidator.class); - - private boolean validateWithdrawalRequestParameter( - final Optional> withdrawalRequests) { - return withdrawalRequests.isPresent(); - } - - private boolean validateWithdrawalRequestsInBlock( - final Block block, final List withdrawalRequests) { - final Hash blockHash = block.getHash(); - - final List withdrawalRequestsInBlock = - block - .getBody() - .getRequests() - .flatMap(requests -> getWithdrawalRequests(Optional.of(requests))) - .orElse(Collections.emptyList()); - - // TODO Do we need to allow for customization? (e.g. if the value changes in the next fork) - if (withdrawalRequestsInBlock.size() > MAX_WITHDRAWAL_REQUESTS_PER_BLOCK) { - LOG.warn( - "Block {} has more than the allowed maximum number of withdrawal requests", blockHash); - return false; - } - - // Validate WithdrawalRequests - final boolean expectedWithdrawalRequestMatch = - withdrawalRequests.equals(withdrawalRequestsInBlock); - if (!expectedWithdrawalRequestMatch) { - LOG.warn( - "Block {} has a mismatch between its withdrawal requests and expected withdrawal requests (in_block = {}, " - + "expected = {})", - blockHash, - withdrawalRequestsInBlock, - withdrawalRequests); - return false; - } - return true; - } - - @Override - public boolean validate( - final Block block, final List requests, final List receipts) { - var withdrawalRequests = - getWithdrawalRequests(Optional.of(requests)).orElse(Collections.emptyList()); - return validateWithdrawalRequestsInBlock(block, withdrawalRequests); - } - - @Override - public boolean validateParameter(final Optional> request) { - if (request.isEmpty()) { - return false; - } - var withdrawalRequests = - RequestUtil.filterRequestsOfType(request.get(), WithdrawalRequest.class); - return validateWithdrawalRequestParameter(Optional.of(withdrawalRequests)); - } -} diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockDataGenerator.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockDataGenerator.java index ea62d7f1fa..acbd8679f4 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockDataGenerator.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockDataGenerator.java @@ -303,7 +303,7 @@ public class BlockDataGenerator { .mixHash(hash()) .nonce(blockNonce) .withdrawalsRoot(options.getWithdrawalsRoot(null)) - .requestsRoot(options.getRequestsRoot(null)) + .requestsHash(options.getRequestsHash(null)) .blockHeaderFunctions( options.getBlockHeaderFunctions(new MainnetBlockHeaderFunctions())); options.getBaseFee(Optional.of(Wei.of(uint256(2)))).ifPresent(blockHeaderBuilder::baseFee); @@ -329,10 +329,7 @@ public class BlockDataGenerator { } return new BlockBody( - options.getTransactions(defaultTxs), - ommers, - options.getWithdrawals(Optional.empty()), - options.getRequests(Optional.empty())); + options.getTransactions(defaultTxs), ommers, options.getWithdrawals(Optional.empty())); } private BlockHeader ommer() { @@ -655,7 +652,7 @@ public class BlockDataGenerator { private Optional> maybeBaseFee = Optional.empty(); private Optional withdrawalsRoot = Optional.empty(); - private Optional requestsRoot = Optional.empty(); + private Optional requestsHash = Optional.empty(); private Optional> maybeMaxFeePerBlobGas = Optional.empty(); @@ -724,8 +721,8 @@ public class BlockDataGenerator { return withdrawals.orElse(defaultValue); } - public Hash getRequestsRoot(final Hash defaultValue) { - return requestsRoot.orElse(defaultValue); + public Hash getRequestsHash(final Hash defaultValue) { + return requestsHash.orElse(defaultValue); } public Optional> getRequests(final Optional> defaultValue) { @@ -852,8 +849,8 @@ public class BlockDataGenerator { return this; } - public BlockOptions setRequestsRoot(final Hash requestsRoot) { - this.requestsRoot = Optional.of(requestsRoot); + public BlockOptions setRequestsHash(final Hash requestsHash) { + this.requestsHash = Optional.of(requestsHash); return this; } diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockHeaderTestFixture.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockHeaderTestFixture.java index 44a4ffd060..99cf2407b8 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockHeaderTestFixture.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockHeaderTestFixture.java @@ -50,7 +50,7 @@ public class BlockHeaderTestFixture { private Hash mixHash = Hash.EMPTY; private long nonce = 0; private Optional withdrawalsRoot = Optional.empty(); - private Optional requestsRoot = Optional.empty(); + private Optional requestsHash = Optional.empty(); private BlockHeaderFunctions blockHeaderFunctions = new MainnetBlockHeaderFunctions(); private Optional excessBlobGas = Optional.empty(); private Optional blobGasUsed = Optional.empty(); @@ -78,7 +78,7 @@ public class BlockHeaderTestFixture { withdrawalsRoot.ifPresent(builder::withdrawalsRoot); excessBlobGas.ifPresent(builder::excessBlobGas); blobGasUsed.ifPresent(builder::blobGasUsed); - requestsRoot.ifPresent(builder::requestsRoot); + requestsHash.ifPresent(builder::requestsHash); parentBeaconBlockRoot.ifPresent(builder::parentBeaconBlockRoot); builder.blockHeaderFunctions(blockHeaderFunctions); @@ -175,8 +175,8 @@ public class BlockHeaderTestFixture { return this; } - public BlockHeaderTestFixture requestsRoot(final Hash requestsRoot) { - this.requestsRoot = Optional.ofNullable(requestsRoot); + public BlockHeaderTestFixture requestsHash(final Hash requestsHash) { + this.requestsHash = Optional.ofNullable(requestsHash); return this; } diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/NonBesuBlockHeader.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/NonBesuBlockHeader.java index 000e727db7..00fbba1833 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/NonBesuBlockHeader.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/NonBesuBlockHeader.java @@ -115,7 +115,7 @@ public class NonBesuBlockHeader implements BlockHeader { } @Override - public Optional getRequestsRoot() { + public Optional getRequestsHash() { return Optional.empty(); } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/BlockImportExceptionHandlingTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/BlockImportExceptionHandlingTest.java index d3a261803f..f9a325f3d7 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/BlockImportExceptionHandlingTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/BlockImportExceptionHandlingTest.java @@ -42,7 +42,6 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; import org.hyperledger.besu.ethereum.mainnet.blockhash.FrontierBlockHashProcessor; import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; import org.hyperledger.besu.ethereum.storage.StorageProvider; import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.BonsaiWorldStateProvider; import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateKeyValueStorage; @@ -117,8 +116,6 @@ class BlockImportExceptionHandlingTest { when(protocolContext.getBlockchain()).thenReturn(blockchain); when(protocolContext.getWorldStateArchive()).thenReturn(worldStateArchive); when(protocolSchedule.getByBlockHeader(any())).thenReturn(protocolSpec); - when(protocolSpec.getRequestsValidatorCoordinator()) - .thenReturn(RequestsValidatorCoordinator.empty()); when(protocolSpec.getBlockHashProcessor()).thenReturn(new FrontierBlockHashProcessor()); when(protocolSpec.getGasCalculator()).thenReturn(gasCalculator); when(protocolSpec.getFeeMarket()).thenReturn(feeMarket); @@ -156,7 +153,6 @@ class BlockImportExceptionHandlingTest { eq(goodBlock), any(), any(), - any(), eq(HeaderValidationMode.DETACHED_ONLY))) .thenReturn(true); assertThat(badBlockManager.getBadBlocks()).isEmpty(); @@ -193,7 +189,6 @@ class BlockImportExceptionHandlingTest { eq(goodBlock), any(), any(), - any(), eq(HeaderValidationMode.DETACHED_ONLY))) .thenReturn(true); assertThat(badBlockManager.getBadBlocks()).isEmpty(); @@ -262,7 +257,6 @@ class BlockImportExceptionHandlingTest { eq(goodBlock), any(), any(), - any(), eq(HeaderValidationMode.DETACHED_ONLY))) .thenThrow(new StorageException("database problem")); assertThat(badBlockManager.getBadBlocks()).isEmpty(); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/MainnetBlockValidatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/MainnetBlockValidatorTest.java index a63b736b0e..013adae51e 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/MainnetBlockValidatorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/MainnetBlockValidatorTest.java @@ -99,10 +99,8 @@ public class MainnetBlockValidatorTest { when(worldStateArchive.getMutable()).thenReturn(worldState); when(blockHeaderValidator.validateHeader(any(), any(), any())).thenReturn(true); when(blockHeaderValidator.validateHeader(any(), any(), any(), any())).thenReturn(true); - when(blockBodyValidator.validateBody(any(), any(), any(), any(), any(), any())) - .thenReturn(true); - when(blockBodyValidator.validateBodyLight(any(), any(), any(), any(), any(), any())) - .thenReturn(true); + when(blockBodyValidator.validateBody(any(), any(), any(), any(), any())).thenReturn(true); + when(blockBodyValidator.validateBodyLight(any(), any(), any(), any(), any())).thenReturn(true); when(blockProcessor.processBlock(any(), any(), any())).thenReturn(successfulProcessingResult); when(blockProcessor.processBlock(any(), any(), any(), any())) .thenReturn(successfulProcessingResult); @@ -167,8 +165,7 @@ public class MainnetBlockValidatorTest { @Test public void validateAndProcessBlock_whenBlockBodyInvalid() { - when(blockBodyValidator.validateBody(any(), eq(block), any(), any(), any(), any())) - .thenReturn(false); + when(blockBodyValidator.validateBody(any(), eq(block), any(), any(), any())).thenReturn(false); BlockProcessingResult result = mainnetBlockValidator.validateAndProcessBlock( @@ -353,7 +350,6 @@ public class MainnetBlockValidatorTest { protocolContext, block, Collections.emptyList(), - block.getBody().getRequests(), HeaderValidationMode.FULL, HeaderValidationMode.FULL, BodyValidationMode.FULL); @@ -375,7 +371,6 @@ public class MainnetBlockValidatorTest { protocolContext, block, Collections.emptyList(), - block.getBody().getRequests(), headerValidationMode, headerValidationMode, bodyValidationMode); @@ -392,7 +387,6 @@ public class MainnetBlockValidatorTest { eq(protocolContext), eq(block), any(), - any(), eq(headerValidationMode), eq(bodyValidationMode))) .thenReturn(false); @@ -402,7 +396,6 @@ public class MainnetBlockValidatorTest { protocolContext, block, Collections.emptyList(), - block.getBody().getRequests(), headerValidationMode, headerValidationMode, bodyValidationMode); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/chain/GenesisStateTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/chain/GenesisStateTest.java index 70c1e64bd1..ba03634708 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/chain/GenesisStateTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/chain/GenesisStateTest.java @@ -275,7 +275,7 @@ final class GenesisStateTest { assertThat(last).isNotNull(); Wei lastBalance = last.getBalance(); assertThat(lastBalance).isEqualTo(Wei.fromHexString("0x123450000000000000000")); - assertThat(header.getRequestsRoot().isPresent()).isFalse(); + assertThat(header.getRequestsHash().isPresent()).isFalse(); } @ParameterizedTest @@ -290,7 +290,7 @@ final class GenesisStateTest { assertThat(header.getHash()) .isEqualTo( Hash.fromHexString( - "0xaad700fd347070b47165c299dd5b843d0a47d4eaee12d3414a5cb58c5c8a8fe4")); + "0x554807b22674e6d335f734485993857bbad7a9543affb0663a10c14d78135ec7")); assertThat(header.getGasLimit()).isEqualTo(0x2fefd8); assertThat(header.getGasUsed()).isZero(); assertThat(header.getNumber()).isZero(); @@ -326,11 +326,11 @@ final class GenesisStateTest { Wei lastBalance = last.getBalance(); assertThat(lastBalance).isEqualTo(Wei.fromHexString("0x123450000000000000000")); - assertThat(header.getRequestsRoot().isPresent()).isTrue(); - assertThat(header.getRequestsRoot().get()) + assertThat(header.getRequestsHash().isPresent()).isTrue(); + assertThat(header.getRequestsHash().get()) .isEqualTo( Hash.fromHexString( - "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")); + "0x6036c41849da9c076ed79654d434017387a88fb833c2856b32e18218b3341c5f")); } @Test diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestDecoderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestDecoderTest.java deleted file mode 100644 index bb264dfa23..0000000000 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestDecoderTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.core.encoding; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.ethereum.core.ConsolidationRequest; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; -import org.hyperledger.besu.ethereum.rlp.RLP; - -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.Test; - -class ConsolidationRequestDecoderTest { - - @Test - public void shouldDecodeWithdrawalRequest() { - final ConsolidationRequest expectedConsolidationRequest = - new ConsolidationRequest( - Address.fromHexString("0x814FaE9f487206471B6B0D713cD51a2D35980000"), - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - BLSPublicKey.fromHexString( - "0xa09a4a15bf67b328c9b101d09e5c6ee6672978f7ad9ef0d9e2c457aee99223555d8601f0cb3bcc4ce1af9864779a416e")); - - final BytesValueRLPOutput out = new BytesValueRLPOutput(); - expectedConsolidationRequest.writeTo(out); - - final Request decodedWithdrawalRequest = RequestDecoder.decode(RLP.input(out.encoded())); - - Assertions.assertThat(decodedWithdrawalRequest).isEqualTo(expectedConsolidationRequest); - } -} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestEncoderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestEncoderTest.java deleted file mode 100644 index 10a53379b8..0000000000 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/ConsolidationRequestEncoderTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.core.encoding; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.ethereum.core.ConsolidationRequest; - -import org.apache.tuweni.bytes.Bytes; -import org.junit.jupiter.api.Test; - -class ConsolidationRequestEncoderTest { - - private final String expectedEncodedBytes = - "f87794763c396673f9c391dce3361a9a71c8e161388000b0b10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416eb0a09a4a15bf67b328c9b101d09e5c6ee6672978f7ad9ef0d9e2c457aee99223555d8601f0cb3bcc4ce1af9864779a416e"; - - final ConsolidationRequest consolidationRequest = - new ConsolidationRequest( - Address.fromHexString("0x763c396673F9c391DCe3361A9A71C8E161388000"), - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - BLSPublicKey.fromHexString( - "0xa09a4a15bf67b328c9b101d09e5c6ee6672978f7ad9ef0d9e2c457aee99223555d8601f0cb3bcc4ce1af9864779a416e")); - - @Test - void shouldEncodeConsolidationRequest() { - final Bytes encoded = ConsolidationRequestEncoder.encodeOpaqueBytes(consolidationRequest); - assertThat(encoded).isEqualTo(Bytes.fromHexString(expectedEncodedBytes)); - } - - @Test - void shouldEncodeRequest() { - final Bytes encoded = RequestEncoder.encodeOpaqueBytes(consolidationRequest); - assertThat(encoded) - .isEqualTo( - Bytes.fromHexString( - String.format( - "0x%02X%s", - consolidationRequest.getType().getSerializedType(), expectedEncodedBytes))); - } -} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestDecoderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositLogDecoderTest.java similarity index 51% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestDecoderTest.java rename to ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositLogDecoderTest.java index 622bd89754..14166553e6 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestDecoderTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositLogDecoderTest.java @@ -17,41 +17,15 @@ package org.hyperledger.besu.ethereum.core.encoding; import static org.assertj.core.api.Assertions.assertThat; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.BLSSignature; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.ethereum.core.DepositRequest; import org.hyperledger.besu.evm.log.Log; import org.hyperledger.besu.evm.log.LogTopic; import java.util.List; import org.apache.tuweni.bytes.Bytes; -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.units.bigints.UInt64; import org.junit.jupiter.api.Test; -class DepositRequestDecoderTest { - @Test - void shouldDecodeDeposit() { - final DepositRequest expectedDepositRequest = - new DepositRequest( - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - Bytes32.fromHexString( - "0x0017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483"), - GWei.of(32000000000L), - BLSSignature.fromHexString( - "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"), - UInt64.ONE); - - final DepositRequest depositRequest = - DepositRequestDecoder.decodeOpaqueBytes( - Bytes.fromHexString( - "0xf8bbb0b10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416ea00017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483850773594000b860a889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb501")); - - assertThat(depositRequest).isEqualTo(expectedDepositRequest); - } +class DepositLogDecoderTest { @Test void shouldDecodeDepositFromLog() { @@ -65,19 +39,12 @@ class DepositRequestDecoderTest { "0x00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030b10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483000000000000000000000000000000000000000000000000000000000000000800405973070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060a889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb500000000000000000000000000000000000000000000000000000000000000083f3d080000000000000000000000000000000000000000000000000000000000"); final Log log = new Log(address, data, topics); - final DepositRequest depositRequest = DepositRequestDecoder.decodeFromLog(log); + final Bytes requestData = DepositLogDecoder.decodeFromLog(log); - final DepositRequest expectedDepositRequest = - new DepositRequest( - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - Bytes32.fromHexString( - "0x0017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483"), - GWei.of(32000000000L), - BLSSignature.fromHexString( - "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"), - UInt64.valueOf(539967)); + final Bytes expectedDepositRequestData = + Bytes.fromHexString( + "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e0017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa355894830040597307000000a889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb53f3d080000000000"); - assertThat(depositRequest).isEqualTo(expectedDepositRequest); + assertThat(requestData).isEqualTo(expectedDepositRequestData); } } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestEncoderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestEncoderTest.java deleted file mode 100644 index 1e6dde6aa8..0000000000 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestEncoderTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.core.encoding; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.BLSSignature; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.ethereum.core.DepositRequest; - -import org.apache.tuweni.bytes.Bytes; -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.units.bigints.UInt64; -import org.junit.jupiter.api.Test; - -class DepositRequestEncoderTest { - private final String expectedDepositEncodedBytes = - "f8bbb0b10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416ea00017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483850773594000b860a889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb501"; - - final DepositRequest depositRequest = - new DepositRequest( - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - Bytes32.fromHexString( - "0x0017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483"), - GWei.of(32000000000L), - BLSSignature.fromHexString( - "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"), - UInt64.ONE); - - @Test - void shouldEncodeDeposit() { - final Bytes encoded = DepositRequestEncoder.encodeOpaqueBytes(depositRequest); - assertThat(encoded).isEqualTo(Bytes.fromHexString(expectedDepositEncodedBytes)); - } - - @Test - void shouldEncodeDepositRequest() { - final Bytes encoded = RequestEncoder.encodeOpaqueBytes(depositRequest); - // Request encoding is Request = RequestType ++ RequestData - assertThat(encoded) - .isEqualTo( - Bytes.fromHexString( - String.format( - "0x%02X%s", - depositRequest.getType().getSerializedType(), expectedDepositEncodedBytes))); - } -} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestDecoderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestDecoderTest.java deleted file mode 100644 index ad6da667c1..0000000000 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestDecoderTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.core.encoding; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; -import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; -import org.hyperledger.besu.ethereum.rlp.RLP; - -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.Test; - -class WithdrawalRequestDecoderTest { - - @Test - public void shouldDecodeWithdrawalRequest() { - final WithdrawalRequest expectedWithdrawalRequest = - new WithdrawalRequest( - Address.fromHexString("0x814FaE9f487206471B6B0D713cD51a2D35980000"), - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - GWei.of(5)); - - final BytesValueRLPOutput out = new BytesValueRLPOutput(); - expectedWithdrawalRequest.writeTo(out); - - final Request decodedWithdrawalRequest = RequestDecoder.decode(RLP.input(out.encoded())); - - Assertions.assertThat(decodedWithdrawalRequest).isEqualTo(expectedWithdrawalRequest); - } -} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestEncoderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestEncoderTest.java deleted file mode 100644 index 14c9cfacef..0000000000 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestEncoderTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.core.encoding; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; - -import org.apache.tuweni.bytes.Bytes; -import org.junit.jupiter.api.Test; - -class WithdrawalRequestEncoderTest { - - private final String expectedEncodedBytes = - "f84794763c396673f9c391dce3361a9a71c8e161388000b0b10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e05"; - - final WithdrawalRequest withdrawalRequest = - new WithdrawalRequest( - Address.fromHexString("0x763c396673F9c391DCe3361A9A71C8E161388000"), - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - GWei.of(5)); - - @Test - void shouldEncodeWithdrawalRequest() { - final Bytes encoded = WithdrawalRequestEncoder.encodeOpaqueBytes(withdrawalRequest); - assertThat(encoded).isEqualTo(Bytes.fromHexString(expectedEncodedBytes)); - } - - @Test - void shouldEncodeRequest() { - final Bytes encoded = RequestEncoder.encodeOpaqueBytes(withdrawalRequest); - assertThat(encoded) - .isEqualTo( - Bytes.fromHexString( - String.format( - "0x%02X%s", - withdrawalRequest.getType().getSerializedType(), expectedEncodedBytes))); - } -} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessorTest.java index 2a66c6e115..33347929cf 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessorTest.java @@ -33,7 +33,6 @@ import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.Withdrawal; import org.hyperledger.besu.ethereum.mainnet.blockhash.FrontierBlockHashProcessor; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; import org.hyperledger.besu.ethereum.referencetests.ReferenceTestBlockchain; import org.hyperledger.besu.ethereum.referencetests.ReferenceTestWorldState; @@ -68,9 +67,6 @@ abstract class AbstractBlockProcessorTest { @BeforeEach void baseSetup() { lenient().when(protocolSchedule.getByBlockHeader(any())).thenReturn(protocolSpec); - lenient() - .when(protocolSpec.getRequestsValidatorCoordinator()) - .thenReturn(RequestsValidatorCoordinator.empty()); lenient() .when(protocolSpec.getBlockHashProcessor()) .thenReturn(new FrontierBlockHashProcessor()); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/BodyValidationTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/BodyValidationTest.java index fd5c4387cc..45ce54f252 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/BodyValidationTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/BodyValidationTest.java @@ -15,12 +15,16 @@ package org.hyperledger.besu.ethereum.mainnet; import org.hyperledger.besu.datatypes.Hash; +import org.hyperledger.besu.datatypes.RequestType; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; +import org.hyperledger.besu.ethereum.core.Request; import java.io.IOException; import java.util.Arrays; +import java.util.List; +import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; @@ -57,4 +61,28 @@ public final class BodyValidationTest { Assertions.assertThat(header.getWithdrawalsRoot()).hasValue(Hash.wrap(withdrawalsRoot)); } } + + @Test + public void calculateRequestsHash() { + List requests = + List.of( + new Request( + RequestType.DEPOSIT, + Bytes.fromHexString( + "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100405973070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000")), + new Request( + RequestType.WITHDRAWAL, + Bytes.fromHexString( + "0x6389e7f33ce3b1e94e4325ef02829cd12297ef710000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000")), + new Request( + RequestType.CONSOLIDATION, + Bytes.fromHexString( + "0x8a0a19589531694250d570040a0c4b74576919b8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"))); + + Bytes32 requestHash = BodyValidation.requestsHash(requests); + Assertions.assertThat(requestHash) + .isEqualTo( + Bytes32.fromHexString( + "0x0e53a6857da18cf29c6ae28be10a333fc0eaafbd3f425f09e5e81f29e4d3d766")); + } } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ConsolidationRequestValidatorTestFixtures.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ConsolidationRequestValidatorTestFixtures.java deleted file mode 100644 index fbd304d1cd..0000000000 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ConsolidationRequestValidatorTestFixtures.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.mainnet; - -import static org.hyperledger.besu.ethereum.mainnet.requests.ConsolidationRequestValidator.MAX_CONSOLIDATION_REQUESTS_PER_BLOCK; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.BlockDataGenerator; -import org.hyperledger.besu.ethereum.core.ConsolidationRequest; -import org.hyperledger.besu.ethereum.core.Request; - -import java.util.List; -import java.util.Optional; -import java.util.stream.IntStream; - -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.bytes.Bytes48; - -public class ConsolidationRequestValidatorTestFixtures { - - private static final BlockDataGenerator blockDataGenerator = new BlockDataGenerator(); - - static ConsolidationRequestTestParameter - blockWithConsolidationRequestsAndWithdrawalRequestsRoot() { - final ConsolidationRequest consolidationRequest = createConsolidationRequest(); - final Optional> maybeConsolidationRequests = - Optional.of(List.of(consolidationRequest)); - - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create() - .setRequestsRoot(BodyValidation.requestsRoot(maybeConsolidationRequests.get())) - .setRequests(maybeConsolidationRequests); - final Block block = blockDataGenerator.block(blockOptions); - - return new ConsolidationRequestTestParameter( - "Block with consolidation requests and withdrawal_requests_root", - block, - Optional.of(List.of(consolidationRequest))); - } - - static ConsolidationRequestTestParameter blockWithConsolidationRequestsMismatch() { - final ConsolidationRequest consolidationRequest = createConsolidationRequest(); - - final Optional> requests = - Optional.of(List.of(consolidationRequest, consolidationRequest)); - - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create() - .setRequestsRoot(BodyValidation.requestsRoot(requests.get())) - .setRequests(requests); - final Block block = blockDataGenerator.block(blockOptions); - - return new ConsolidationRequestTestParameter( - "Block with consolidation requests mismatch", - block, - Optional.of(List.of(consolidationRequest, consolidationRequest)), - List.of(createConsolidationRequest())); - } - - static ConsolidationRequestTestParameter blockWithMoreThanMaximumConsolidationRequests() { - final List consolidationRequests = - IntStream.range(0, MAX_CONSOLIDATION_REQUESTS_PER_BLOCK + 1) - .mapToObj(__ -> createConsolidationRequest()) - .toList(); - - final Optional> maybeConsolidationRequest = - Optional.of(consolidationRequests); - final Optional> maybeRequests = - Optional.of(consolidationRequests.stream().map(r -> (Request) r).toList()); - - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create() - .setRequestsRoot(BodyValidation.requestsRoot(maybeRequests.get())) - .setRequests(maybeRequests); - final Block block = blockDataGenerator.block(blockOptions); - - return new ConsolidationRequestTestParameter( - "Block with more than maximum consolidation requests", block, maybeConsolidationRequest); - } - - static ConsolidationRequest createConsolidationRequest() { - return new ConsolidationRequest( - Address.extract(Bytes32.random()), - BLSPublicKey.wrap(Bytes48.random()), - BLSPublicKey.wrap(Bytes48.random())); - } - - static class ConsolidationRequestTestParameter { - - String description; - Block block; - Optional> maybeConsolidationRequest; - List expectedConsolidationRequest; - - public ConsolidationRequestTestParameter( - final String description, - final Block block, - final Optional> maybeConsolidationRequest) { - this( - description, - block, - maybeConsolidationRequest, - maybeConsolidationRequest.orElseGet(List::of)); - } - - public ConsolidationRequestTestParameter( - final String description, - final Block block, - final Optional> maybeConsolidationRequest, - final List expectedConsolidationRequest) { - this.description = description; - this.block = block; - this.maybeConsolidationRequest = maybeConsolidationRequest; - this.expectedConsolidationRequest = expectedConsolidationRequest; - } - - @Override - public String toString() { - return description; - } - } -} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DepositRequestValidatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DepositRequestValidatorTest.java deleted file mode 100644 index 0360032388..0000000000 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DepositRequestValidatorTest.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.mainnet; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.BLSSignature; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.datatypes.RequestType; -import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.BlockDataGenerator; -import org.hyperledger.besu.ethereum.core.DepositRequest; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.core.TransactionReceipt; -import org.hyperledger.besu.ethereum.mainnet.requests.DepositRequestValidator; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; -import org.hyperledger.besu.ethereum.mainnet.requests.WithdrawalRequestValidator; -import org.hyperledger.besu.evm.log.Log; -import org.hyperledger.besu.evm.log.LogTopic; - -import java.util.List; -import java.util.Optional; - -import org.apache.tuweni.bytes.Bytes; -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.units.bigints.UInt64; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -public class DepositRequestValidatorTest { - private final BlockDataGenerator blockDataGenerator = new BlockDataGenerator(); - private static DepositRequest depositRequest1; - private static DepositRequest depositRequest2; - private static Log LOG_1; - private static Log LOG_2; - private static Address DEPOSIT_CONTRACT_ADDRESS; - private static RequestsValidatorCoordinator requestsValidatorCoordinator; - private static DepositRequestValidator depositRequestValidator; - - @BeforeAll - public static void setup() { - depositRequest1 = - new DepositRequest( - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - Bytes32.fromHexString( - "0x0017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483"), - GWei.of(32000000000L), - BLSSignature.fromHexString( - "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"), - UInt64.valueOf(539967)); - - depositRequest2 = - new DepositRequest( - BLSPublicKey.fromHexString( - "0x8706d19a62f28a6a6549f96c5adaebac9124a61d44868ec94f6d2d707c6a2f82c9162071231dfeb40e24bfde4ffdf243"), - Bytes32.fromHexString( - "0x006a8dc800c6d8dd6977ef53264e2d030350f0145a91bcd167b4f1c3ea21b271"), - GWei.of(32000000000L), - BLSSignature.fromHexString( - "0x801b08ca107b623eca32ee9f9111b4e50eb9cfe19e38204b72de7dc04c5a5e00f61bab96f10842576f66020ce851083f1583dd9a6b73301bea6c245cf51f27cf96aeb018852c5f70bf485d16b957cfe49ca008913346b431e7653ae3ddb23b07"), - UInt64.valueOf(559887)); - - LOG_1 = - new Log( - Address.fromHexString("0x00000000219ab540356cbb839cbe05303d7705fa"), - Bytes.fromHexString( - "0x00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030b10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483000000000000000000000000000000000000000000000000000000000000000800405973070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060a889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb500000000000000000000000000000000000000000000000000000000000000083f3d080000000000000000000000000000000000000000000000000000000000"), - List.of( - LogTopic.fromHexString( - "0x649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5"))); - - LOG_2 = - new Log( - Address.fromHexString("0x00000000219ab540356cbb839cbe05303d7705fa"), - Bytes.fromHexString( - "0x00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000308706d19a62f28a6a6549f96c5adaebac9124a61d44868ec94f6d2d707c6a2f82c9162071231dfeb40e24bfde4ffdf243000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020006a8dc800c6d8dd6977ef53264e2d030350f0145a91bcd167b4f1c3ea21b271000000000000000000000000000000000000000000000000000000000000000800405973070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060801b08ca107b623eca32ee9f9111b4e50eb9cfe19e38204b72de7dc04c5a5e00f61bab96f10842576f66020ce851083f1583dd9a6b73301bea6c245cf51f27cf96aeb018852c5f70bf485d16b957cfe49ca008913346b431e7653ae3ddb23b0700000000000000000000000000000000000000000000000000000000000000080f8b080000000000000000000000000000000000000000000000000000000000"), - List.of( - LogTopic.fromHexString( - "0x649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5"))); - DEPOSIT_CONTRACT_ADDRESS = Address.fromHexString("0x00000000219ab540356cbb839cbe05303d7705fa"); - requestsValidatorCoordinator = createAllowDepositValidator(); - } - - @Test - public void validateAllowedDepositRequests() { - final List request = List.of(depositRequest1, depositRequest2); - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create() - .setRequests(Optional.of(request)) - .setRequestsRoot(BodyValidation.requestsRoot(request)); - final Block block = blockDataGenerator.block(blockOptions); - - final TransactionReceipt receipt = - new TransactionReceipt(null, 0L, List.of(LOG_1, LOG_2), Optional.empty()); - - assertThat(requestsValidatorCoordinator.validate(block, Optional.of(request), List.of(receipt))) - .isTrue(); - } - - @Test - public void validateAllowedDepositRequestsSeparateReceipts() { - - final List requests = List.of(depositRequest1, depositRequest2); - - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create() - .setRequests(Optional.of(requests)) - .setRequestsRoot(BodyValidation.requestsRoot(requests)); - final Block block = blockDataGenerator.block(blockOptions); - - final TransactionReceipt receipt1 = - new TransactionReceipt(null, 0L, List.of(LOG_1), Optional.empty()); - final TransactionReceipt receipt2 = - new TransactionReceipt(null, 0L, List.of(LOG_2), Optional.empty()); - - assertThat( - requestsValidatorCoordinator.validate( - block, Optional.of(requests), List.of(receipt1, receipt2))) - .isTrue(); - } - - @Test - public void invalidateAllowedDepositRequests() { - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create().setRequests(Optional.of(List.of(depositRequest1))); - final Block block = blockDataGenerator.block(blockOptions); - - final TransactionReceipt receipt1 = - new TransactionReceipt(null, 0L, List.of(LOG_2), Optional.empty()); - - assertThat( - requestsValidatorCoordinator.validate(block, Optional.of(List.of()), List.of(receipt1))) - .isFalse(); - } - - @Test - public void invalidateAllowedDepositRequestsMissingLogInReceipt() { - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create() - .setRequests(Optional.of(List.of(depositRequest1, depositRequest2))); - final Block block = blockDataGenerator.block(blockOptions); - - final TransactionReceipt receipt1 = - new TransactionReceipt(null, 0L, List.of(LOG_2), Optional.empty()); - - assertThat( - requestsValidatorCoordinator.validate(block, Optional.of(List.of()), List.of(receipt1))) - .isFalse(); - } - - @Test - public void invalidateAllowedDepositRequestsExtraLogInReceipt() { - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create().setRequests(Optional.of(List.of(depositRequest1))); - final Block block = blockDataGenerator.block(blockOptions); - - final TransactionReceipt receipt1 = - new TransactionReceipt(null, 0L, List.of(LOG_1, LOG_2), Optional.empty()); - - assertThat( - requestsValidatorCoordinator.validate(block, Optional.of(List.of()), List.of(receipt1))) - .isFalse(); - } - - @Test - public void invalidateAllowedDepositRequestsWrongOrder() { - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create() - .setRequests(Optional.of(List.of(depositRequest1, depositRequest2))); - final Block block = blockDataGenerator.block(blockOptions); - - final TransactionReceipt receipt1 = - new TransactionReceipt(null, 0L, List.of(LOG_2, LOG_1), Optional.empty()); - - assertThat( - requestsValidatorCoordinator.validate(block, Optional.of(List.of()), List.of(receipt1))) - .isFalse(); - } - - @Test - public void invalidateAllowedDepositRequestsMismatchContractAddress() { - - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create() - .setRequests(Optional.of(List.of(depositRequest1, depositRequest2))); - final Block block = blockDataGenerator.block(blockOptions); - - final TransactionReceipt receipt1 = - new TransactionReceipt(null, 0L, List.of(LOG_1, LOG_2), Optional.empty()); - - assertThat( - requestsValidatorCoordinator.validate(block, Optional.of(List.of()), List.of(receipt1))) - .isFalse(); - } - - @Test - public void validateAllowedDepositParams() { - final Optional> depositRequests = - Optional.of(List.of(depositRequest1, depositRequest2)); - assertThat(depositRequestValidator.validateParameter(depositRequests)).isTrue(); - - final Optional> emptyDepositRequests = Optional.of(List.of()); - assertThat(depositRequestValidator.validateParameter(emptyDepositRequests)).isTrue(); - } - - @Test - public void invalidateAllowedDepositParams() { - final Optional> depositRequests = Optional.empty(); - assertThat(depositRequestValidator.validateParameter(depositRequests)).isFalse(); - } - - static RequestsValidatorCoordinator createAllowDepositValidator() { - depositRequestValidator = new DepositRequestValidator(DEPOSIT_CONTRACT_ADDRESS); - return new RequestsValidatorCoordinator.Builder() - .addValidator(RequestType.WITHDRAWAL, new WithdrawalRequestValidator()) - .addValidator(RequestType.DEPOSIT, depositRequestValidator) - .build(); - } -} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidatorTest.java index c412a30756..8c25d4f58e 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidatorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidatorTest.java @@ -36,8 +36,7 @@ import org.hyperledger.besu.ethereum.core.BlockDataGenerator.BlockOptions; import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.core.Withdrawal; -import org.hyperledger.besu.ethereum.mainnet.requests.DepositRequestValidator; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; +import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidator; import org.hyperledger.besu.evm.log.LogsBloomFilter; import java.util.Collections; @@ -61,8 +60,7 @@ class MainnetBlockBodyValidatorTest { @Mock private ProtocolSchedule protocolSchedule; @Mock private ProtocolSpec protocolSpec; @Mock private WithdrawalsValidator withdrawalsValidator; - @Mock private DepositRequestValidator depositRequestValidator; - @Mock private RequestsValidatorCoordinator requestValidator; + @Mock private RequestsValidator requestValidator; @BeforeEach public void setUp() { @@ -72,12 +70,8 @@ class MainnetBlockBodyValidatorTest { lenient().when(withdrawalsValidator.validateWithdrawals(any())).thenReturn(true); lenient().when(withdrawalsValidator.validateWithdrawalsRoot(any())).thenReturn(true); - lenient() - .when(depositRequestValidator.validateDepositRequests(any(), any(), any())) - .thenReturn(true); - - lenient().when(protocolSpec.getRequestsValidatorCoordinator()).thenReturn(requestValidator); - lenient().when(requestValidator.validate(any(), any(), any())).thenReturn(true); + lenient().when(protocolSpec.getRequestsValidator()).thenReturn(requestValidator); + lenient().when(requestValidator.validate(any())).thenReturn(true); } @Test @@ -104,7 +98,6 @@ class MainnetBlockBodyValidatorTest { blockchainSetupUtil.getProtocolContext(), block, emptyList(), - any(), NONE, BodyValidationMode.FULL)) .isTrue(); @@ -133,7 +126,6 @@ class MainnetBlockBodyValidatorTest { blockchainSetupUtil.getProtocolContext(), block, emptyList(), - any(), NONE, BodyValidationMode.FULL)) .isFalse(); @@ -162,36 +154,6 @@ class MainnetBlockBodyValidatorTest { blockchainSetupUtil.getProtocolContext(), block, emptyList(), - any(), - NONE, - BodyValidationMode.FULL)) - .isFalse(); - } - - @Test - public void validationFailsIfWithdrawalRequestsValidationFails() { - final Block block = - blockDataGenerator.block( - new BlockOptions() - .setBlockNumber(1) - .setGasUsed(0) - .hasTransactions(false) - .hasOmmers(false) - .setReceiptsRoot(BodyValidation.receiptsRoot(emptyList())) - .setLogsBloom(LogsBloomFilter.empty()) - .setParentHash(blockchainSetupUtil.getBlockchain().getChainHeadHash()) - .setRequests(Optional.of(List.of()))); - blockchainSetupUtil.getBlockchain().appendBlock(block, Collections.emptyList()); - - when(requestValidator.validate(any(), any(), any())).thenReturn(false); - - assertThat( - new MainnetBlockBodyValidator(protocolSchedule) - .validateBodyLight( - blockchainSetupUtil.getProtocolContext(), - block, - emptyList(), - any(), NONE, BodyValidationMode.FULL)) .isFalse(); @@ -210,7 +172,6 @@ class MainnetBlockBodyValidatorTest { blockchainSetupUtil.getProtocolContext(), block, receipts, - Optional.empty(), NONE, BodyValidationMode.NONE)) .isTrue(); @@ -241,7 +202,6 @@ class MainnetBlockBodyValidatorTest { blockchainSetupUtil.getProtocolContext(), block, emptyList(), - Optional.empty(), NONE, BodyValidationMode.LIGHT)) .isTrue(); @@ -272,7 +232,6 @@ class MainnetBlockBodyValidatorTest { blockchainSetupUtil.getProtocolContext(), block, emptyList(), - Optional.empty(), NONE, BodyValidationMode.FULL)) .isTrue(); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessorTest.java index a06aece37b..8baf4d8d03 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessorTest.java @@ -28,7 +28,6 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.mainnet.blockhash.FrontierBlockHashProcessor; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; import org.hyperledger.besu.ethereum.referencetests.ReferenceTestBlockchain; import org.hyperledger.besu.ethereum.referencetests.ReferenceTestWorldState; @@ -50,8 +49,6 @@ public class MainnetBlockProcessorTest extends AbstractBlockProcessorTest { @BeforeEach public void setup() { when(protocolSchedule.getByBlockHeader(any())).thenReturn(protocolSpec); - when(protocolSpec.getRequestsValidatorCoordinator()) - .thenReturn(RequestsValidatorCoordinator.empty()); when(protocolSpec.getBlockHashProcessor()).thenReturn(new FrontierBlockHashProcessor()); } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PragueConsolidationRequestValidatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PragueConsolidationRequestValidatorTest.java deleted file mode 100644 index 9d0c9588cc..0000000000 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PragueConsolidationRequestValidatorTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.mainnet; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.mainnet.ConsolidationRequestValidatorTestFixtures.blockWithConsolidationRequestsAndWithdrawalRequestsRoot; -import static org.hyperledger.besu.ethereum.mainnet.ConsolidationRequestValidatorTestFixtures.blockWithConsolidationRequestsMismatch; -import static org.hyperledger.besu.ethereum.mainnet.ConsolidationRequestValidatorTestFixtures.blockWithMoreThanMaximumConsolidationRequests; - -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.mainnet.ConsolidationRequestValidatorTestFixtures.ConsolidationRequestTestParameter; -import org.hyperledger.besu.ethereum.mainnet.requests.ConsolidationRequestValidator; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.stream.Stream; - -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; - -class PragueConsolidationRequestValidatorTest { - - @ParameterizedTest(name = "{index}: {0}") - @MethodSource("paramsForValidateConsolidationRequestParameter") - public void validateConsolidationRequestParameter( - final String description, - final Optional> maybeRequests, - final boolean expectedValidity) { - assertThat(new ConsolidationRequestValidator().validateParameter(maybeRequests)) - .isEqualTo(expectedValidity); - } - - private static Stream paramsForValidateConsolidationRequestParameter() { - return Stream.of( - Arguments.of( - "Allowed ConsolidationRequests - validating empty ConsolidationRequests", - Optional.empty(), - true), - Arguments.of( - "Allowed ConsolidationRequests - validating present ConsolidationRequests", - Optional.of(List.of()), - true)); - } - - @ParameterizedTest(name = "{index}: {0}") - @MethodSource("validateConsolidationRequestsInBlockParamsForPrague") - public void validateConsolidationRequestsInBlock_WhenPrague( - final ConsolidationRequestTestParameter param, final boolean expectedValidity) { - assertThat( - new ConsolidationRequestValidator() - .validate( - param.block, new ArrayList<>(param.expectedConsolidationRequest), List.of())) - .isEqualTo(expectedValidity); - } - - private static Stream validateConsolidationRequestsInBlockParamsForPrague() { - return Stream.of( - Arguments.of(blockWithConsolidationRequestsAndWithdrawalRequestsRoot(), true), - Arguments.of(blockWithConsolidationRequestsMismatch(), false), - Arguments.of(blockWithMoreThanMaximumConsolidationRequests(), false)); - } -} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PragueRequestsValidatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PragueRequestsValidatorTest.java deleted file mode 100644 index 6158ba44c3..0000000000 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PragueRequestsValidatorTest.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.mainnet; - -import static java.util.Collections.emptyList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode.NONE; -import static org.hyperledger.besu.ethereum.mainnet.requests.ConsolidationRequestProcessor.CONSOLIDATION_REQUEST_CONTRACT_ADDRESS; -import static org.hyperledger.besu.ethereum.mainnet.requests.DepositRequestProcessor.DEFAULT_DEPOSIT_CONTRACT_ADDRESS; -import static org.hyperledger.besu.ethereum.mainnet.requests.MainnetRequestsValidator.pragueRequestsValidator; -import static org.hyperledger.besu.ethereum.mainnet.requests.WithdrawalRequestProcessor.DEFAULT_WITHDRAWAL_REQUEST_CONTRACT_ADDRESS; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.lenient; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.BlockDataGenerator; -import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestContractAddresses; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; -import org.hyperledger.besu.evm.log.LogsBloomFilter; - -import java.util.List; -import java.util.Optional; - -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.bytes.Bytes48; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -@ExtendWith(MockitoExtension.class) -class PragueRequestsValidatorTest { - - private final BlockchainSetupUtil blockchainSetupUtil = BlockchainSetupUtil.forMainnet(); - @Mock private ProtocolSchedule protocolSchedule; - @Mock private ProtocolSpec protocolSpec; - @Mock private WithdrawalsValidator withdrawalsValidator; - private final RequestContractAddresses requestContractAddresses = - new RequestContractAddresses( - DEFAULT_WITHDRAWAL_REQUEST_CONTRACT_ADDRESS, - DEFAULT_DEPOSIT_CONTRACT_ADDRESS, - CONSOLIDATION_REQUEST_CONTRACT_ADDRESS); - - RequestsValidatorCoordinator requestValidator = pragueRequestsValidator(requestContractAddresses); - - @BeforeEach - public void setUp() { - lenient().when(protocolSchedule.getByBlockHeader(any())).thenReturn(protocolSpec); - lenient().when(protocolSpec.getWithdrawalsValidator()).thenReturn(withdrawalsValidator); - lenient().when(withdrawalsValidator.validateWithdrawals(any())).thenReturn(true); - lenient().when(withdrawalsValidator.validateWithdrawalsRoot(any())).thenReturn(true); - lenient().when(protocolSpec.getRequestsValidatorCoordinator()).thenReturn(requestValidator); - } - - private static final BlockDataGenerator blockDataGenerator = new BlockDataGenerator(); - - @Test - void shouldValidateRequestsTest() { - WithdrawalRequest request = - new WithdrawalRequest( - Address.extract(Bytes32.fromHexStringLenient("1")), - BLSPublicKey.wrap(Bytes48.fromHexStringLenient("1")), - GWei.ONE); - - WithdrawalRequest requestTwo = - new WithdrawalRequest( - Address.extract(Bytes32.fromHexStringLenient("1")), - BLSPublicKey.wrap(Bytes48.fromHexStringLenient("1")), - GWei.ZERO); - - Optional> blockRequests = Optional.of(List.of(request)); - Optional> expectedRequests = Optional.of(List.of(requestTwo)); - Hash requestsRoot = BodyValidation.requestsRoot(blockRequests.get()); - - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create() - .setRequestsRoot(requestsRoot) - .setRequests(blockRequests) - .setGasUsed(0) - .setReceiptsRoot(BodyValidation.receiptsRoot(emptyList())) - .hasTransactions(false) - .hasOmmers(false) - .setReceiptsRoot(BodyValidation.receiptsRoot(emptyList())) - .setLogsBloom(LogsBloomFilter.empty()) - .setParentHash(blockchainSetupUtil.getBlockchain().getChainHeadHash()); - - final Block block = blockDataGenerator.block(blockOptions); - assertThat(block).isNotNull(); - assertThat( - new MainnetBlockBodyValidator(protocolSchedule) - .validateBodyLight( - blockchainSetupUtil.getProtocolContext(), - block, - emptyList(), - expectedRequests, - NONE, - BodyValidationMode.FULL)) - .isFalse(); - } -} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PragueWithdrawalRequestValidatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PragueWithdrawalRequestValidatorTest.java deleted file mode 100644 index 8756f85592..0000000000 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PragueWithdrawalRequestValidatorTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.mainnet; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.mainnet.WithdrawalRequestValidatorTestFixtures.blockWithMoreThanMaximumWithdrawalRequests; -import static org.hyperledger.besu.ethereum.mainnet.WithdrawalRequestValidatorTestFixtures.blockWithWithdrawalRequestsAndWithdrawalRequestsRoot; -import static org.hyperledger.besu.ethereum.mainnet.WithdrawalRequestValidatorTestFixtures.blockWithWithdrawalRequestsMismatch; - -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.mainnet.WithdrawalRequestValidatorTestFixtures.WithdrawalRequestTestParameter; -import org.hyperledger.besu.ethereum.mainnet.requests.WithdrawalRequestValidator; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.stream.Stream; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; - -class PragueWithdrawalRequestValidatorTest { - - @ParameterizedTest(name = "{index}: {0}") - @MethodSource("paramsForValidateWithdrawalRequestParameter") - public void validateWithdrawalRequestParameter( - final String description, - final Optional> maybeRequests, - final boolean expectedValidity) { - assertThat(new WithdrawalRequestValidator().validateParameter(maybeRequests)) - .isEqualTo(expectedValidity); - } - - private static Stream paramsForValidateWithdrawalRequestParameter() { - return Stream.of( - Arguments.of( - "Allowed WithdrawalRequests - validating empty WithdrawalRequests", - Optional.empty(), - false), - Arguments.of( - "Allowed WithdrawalRequests - validating present WithdrawalRequests", - Optional.of(List.of()), - true)); - } - - @ParameterizedTest(name = "{index}: {0}") - @MethodSource("validateWithdrawalRequestsInBlockParamsForPrague") - public void validateWithdrawalRequestsInBlock_WhenPrague( - final WithdrawalRequestTestParameter param, final boolean expectedValidity) { - assertThat( - new WithdrawalRequestValidator() - .validate(param.block, new ArrayList<>(param.expectedWithdrawalRequest), List.of())) - .isEqualTo(expectedValidity); - } - - private static Stream validateWithdrawalRequestsInBlockParamsForPrague() { - return Stream.of( - Arguments.of(blockWithWithdrawalRequestsAndWithdrawalRequestsRoot(), true), - Arguments.of(blockWithWithdrawalRequestsMismatch(), false), - Arguments.of(blockWithMoreThanMaximumWithdrawalRequests(), false)); - } - - @Test - void dryRunDetector() { - assertThat(true) - .withFailMessage("This test is here so gradle --dry-run executes this class") - .isTrue(); - } -} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/SystemCallProcessorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/SystemCallProcessorTest.java index e1d3906e73..14275f7d12 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/SystemCallProcessorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/SystemCallProcessorTest.java @@ -87,10 +87,10 @@ public class SystemCallProcessorTest { } @Test - void shouldReturnNullWhenContractDoesNotExist() { + void shouldReturnEmptyWhenContractDoesNotExist() { final MutableWorldState worldState = InMemoryKeyValueStorageProvider.createInMemoryWorldState(); Bytes actualOutput = processSystemCall(worldState); - assertThat(actualOutput).isNull(); + assertThat(actualOutput).isEqualTo(Bytes.EMPTY); } Bytes processSystemCall(final MutableWorldState worldState) { diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ValidationTestUtils.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ValidationTestUtils.java index fa912a6de8..4e1ac520b5 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ValidationTestUtils.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ValidationTestUtils.java @@ -17,7 +17,6 @@ package org.hyperledger.besu.ethereum.mainnet; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Withdrawal; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput; @@ -59,11 +58,7 @@ public final class ValidationTestUtils { input.isEndOfCurrentList() ? Optional.empty() : Optional.of(input.readList(Withdrawal::readFrom)); - final Optional> requests = - input.isEndOfCurrentList() - ? Optional.empty() - : Optional.of(input.readList(Request::readFrom)); - return new BlockBody(transactions, ommers, withdrawals, requests); + return new BlockBody(transactions, ommers, withdrawals); } public static Block readBlock(final long num) throws IOException { diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/WithdrawalRequestValidatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/WithdrawalRequestValidatorTest.java deleted file mode 100644 index f93067d94f..0000000000 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/WithdrawalRequestValidatorTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.mainnet; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.mainnet.WithdrawalRequestValidatorTestFixtures.blockWithWithdrawalRequestsAndWithdrawalRequestsRoot; -import static org.hyperledger.besu.ethereum.mainnet.WithdrawalRequestValidatorTestFixtures.blockWithWithdrawalRequestsWithoutWithdrawalRequestsRoot; -import static org.hyperledger.besu.ethereum.mainnet.WithdrawalRequestValidatorTestFixtures.blockWithoutWithdrawalRequestsAndWithdrawalRequestsRoot; -import static org.hyperledger.besu.ethereum.mainnet.WithdrawalRequestValidatorTestFixtures.blockWithoutWithdrawalRequestsWithWithdrawalRequestsRoot; - -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.mainnet.WithdrawalRequestValidatorTestFixtures.WithdrawalRequestTestParameter; -import org.hyperledger.besu.ethereum.mainnet.requests.ProhibitedRequestsValidator; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.stream.Stream; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; - -class WithdrawalRequestValidatorTest { - - @ParameterizedTest(name = "{index}: {0}") - @MethodSource("paramsForValidateWithdrawalRequestParameter") - public void validateWithdrawalRequestParameter( - final String description, - final Optional> maybeWithdrawalRequests, - final boolean expectedValidity) { - assertThat(new ProhibitedRequestsValidator().validateParameter(maybeWithdrawalRequests)) - .isEqualTo(expectedValidity); - } - - private static Stream paramsForValidateWithdrawalRequestParameter() { - return Stream.of( - Arguments.of( - "Prohibited WithdrawalRequests - validating empty WithdrawalRequests", - Optional.empty(), - true), - Arguments.of( - "Prohibited WithdrawalRequests - validating present WithdrawalRequests", - Optional.of(List.of()), - false)); - } - - @ParameterizedTest(name = "{index}: {0}") - @MethodSource("validateWithdrawalRequestsInBlockParamsForProhibited") - public void validateWithdrawalRequestsInBlock_WhenProhibited( - final WithdrawalRequestTestParameter param, final boolean expectedValidity) { - - var list = param.expectedWithdrawalRequest; - var requests = new ArrayList(list).stream().toList(); - - assertThat(new ProhibitedRequestsValidator().validate(param.block, requests, List.of())) - .isEqualTo(expectedValidity); - } - - private static Stream validateWithdrawalRequestsInBlockParamsForProhibited() { - return Stream.of( - Arguments.of(blockWithWithdrawalRequestsAndWithdrawalRequestsRoot(), false), - Arguments.of(blockWithWithdrawalRequestsWithoutWithdrawalRequestsRoot(), false), - Arguments.of(blockWithoutWithdrawalRequestsWithWithdrawalRequestsRoot(), false), - Arguments.of(blockWithoutWithdrawalRequestsAndWithdrawalRequestsRoot(), true)); - } - - @Test - void dryRunDetector() { - assertThat(true) - .withFailMessage("This test is here so gradle --dry-run executes this class") - .isTrue(); - } -} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/WithdrawalRequestValidatorTestFixtures.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/WithdrawalRequestValidatorTestFixtures.java deleted file mode 100644 index e719810c28..0000000000 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/WithdrawalRequestValidatorTestFixtures.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.mainnet; - -import static org.hyperledger.besu.ethereum.mainnet.requests.WithdrawalRequestValidator.MAX_WITHDRAWAL_REQUESTS_PER_BLOCK; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.BlockDataGenerator; -import org.hyperledger.besu.ethereum.core.Request; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; - -import java.util.List; -import java.util.Optional; -import java.util.stream.IntStream; - -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.bytes.Bytes48; - -public class WithdrawalRequestValidatorTestFixtures { - - private static final BlockDataGenerator blockDataGenerator = new BlockDataGenerator(); - - static WithdrawalRequestTestParameter blockWithWithdrawalRequestsAndWithdrawalRequestsRoot() { - final WithdrawalRequest withdrawalRequest = createWithdrawalRequest(); - final Optional> maybeWithdrawalRequests = - Optional.of(java.util.List.of(withdrawalRequest)); - - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create() - .setRequestsRoot(BodyValidation.requestsRoot(maybeWithdrawalRequests.get())) - .setRequests(maybeWithdrawalRequests); - final Block block = blockDataGenerator.block(blockOptions); - - return new WithdrawalRequestTestParameter( - "Block with withdrawal requests and withdrawal_requests_root", - block, - Optional.of(java.util.List.of(withdrawalRequest))); - } - - static WithdrawalRequestTestParameter blockWithoutWithdrawalRequestsWithWithdrawalRequestsRoot() { - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create() - .setRequestsRoot(Hash.EMPTY) - .setRequests(Optional.empty()); - final Block block = blockDataGenerator.block(blockOptions); - - return new WithdrawalRequestTestParameter( - "Block with withdrawal_requests_root but without withdrawal requests", - block, - Optional.empty()); - } - - static WithdrawalRequestTestParameter blockWithWithdrawalRequestsWithoutWithdrawalRequestsRoot() { - final WithdrawalRequest withdrawalRequest = createWithdrawalRequest(); - final Optional> requests = Optional.of(java.util.List.of(withdrawalRequest)); - - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create().setRequests(requests); - final Block block = blockDataGenerator.block(blockOptions); - - return new WithdrawalRequestTestParameter( - "Block with withdrawal requests but without withdrawal_requests_root", - block, - Optional.of(java.util.List.of(withdrawalRequest))); - } - - static WithdrawalRequestTestParameter blockWithoutWithdrawalRequestsAndWithdrawalRequestsRoot() { - - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create().setRequests(Optional.empty()); - final Block block = blockDataGenerator.block(blockOptions); - - return new WithdrawalRequestTestParameter( - "Block without withdrawal requests and withdrawal_requests_root", block, Optional.empty()); - } - - static WithdrawalRequestTestParameter blockWithWithdrawalRequestsRootMismatch() { - final WithdrawalRequest withdrawalRequest = createWithdrawalRequest(); - - final Optional> requests = Optional.of(java.util.List.of(withdrawalRequest)); - - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create().setRequestsRoot(Hash.EMPTY).setRequests(requests); - final Block block = blockDataGenerator.block(blockOptions); - - return new WithdrawalRequestTestParameter( - "Block with withdrawal_requests_root mismatch", - block, - Optional.of(java.util.List.of(withdrawalRequest))); - } - - static WithdrawalRequestTestParameter blockWithWithdrawalRequestsMismatch() { - final WithdrawalRequest withdrawalRequest = createWithdrawalRequest(); - - final Optional> requests = - Optional.of(java.util.List.of(withdrawalRequest, withdrawalRequest)); - - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create() - .setRequestsRoot(BodyValidation.requestsRoot(requests.get())) - .setRequests(requests); - final Block block = blockDataGenerator.block(blockOptions); - - return new WithdrawalRequestTestParameter( - "Block with withdrawal requests mismatch", - block, - Optional.of(java.util.List.of(withdrawalRequest, withdrawalRequest)), - List.of(createWithdrawalRequest())); - } - - static WithdrawalRequestTestParameter blockWithMoreThanMaximumWithdrawalRequests() { - final List withdrawalRequest = - IntStream.range(0, MAX_WITHDRAWAL_REQUESTS_PER_BLOCK + 1) - .mapToObj(__ -> createWithdrawalRequest()) - .toList(); - - final Optional> maybeWithdrawalRequest = Optional.of(withdrawalRequest); - final Optional> maybeRequests = - Optional.of(withdrawalRequest.stream().map(r -> (Request) r).toList()); - - final BlockDataGenerator.BlockOptions blockOptions = - BlockDataGenerator.BlockOptions.create() - .setRequestsRoot(BodyValidation.requestsRoot(maybeRequests.get())) - .setRequests(maybeRequests); - final Block block = blockDataGenerator.block(blockOptions); - - return new WithdrawalRequestTestParameter( - "Block with more than maximum withdrawal requests", block, maybeWithdrawalRequest); - } - - static WithdrawalRequest createWithdrawalRequest() { - return new WithdrawalRequest( - Address.extract(Bytes32.random()), BLSPublicKey.wrap(Bytes48.random()), GWei.ONE); - } - - static class WithdrawalRequestTestParameter { - - String description; - Block block; - Optional> maybeWithdrawalRequest; - List expectedWithdrawalRequest; - - public WithdrawalRequestTestParameter( - final String description, - final Block block, - final Optional> maybeWithdrawalRequest) { - this( - description, - block, - maybeWithdrawalRequest, - maybeWithdrawalRequest.orElseGet(java.util.List::of)); - } - - public WithdrawalRequestTestParameter( - final String description, - final Block block, - final Optional> maybeWithdrawalRequest, - final List expectedWithdrawalRequest) { - this.description = description; - this.block = block; - this.maybeWithdrawalRequest = maybeWithdrawalRequest; - this.expectedWithdrawalRequest = expectedWithdrawalRequest; - } - - @Override - public String toString() { - return description; - } - } -} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsValidatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsValidatorTest.java new file mode 100644 index 0000000000..410a726304 --- /dev/null +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsValidatorTest.java @@ -0,0 +1,58 @@ +/* + * Copyright contributors to Besu. + * + * 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.mainnet.requests; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.hyperledger.besu.datatypes.RequestType; +import org.hyperledger.besu.ethereum.core.Request; + +import java.util.List; +import java.util.Optional; + +import org.apache.tuweni.bytes.Bytes; +import org.junit.jupiter.api.Test; + +class MainnetRequestsValidatorTest { + + @Test + void validateFalseWhenNoRequests() { + MainnetRequestsValidator validator = new MainnetRequestsValidator(); + assertFalse(validator.validate(Optional.empty())); + } + + @Test + void validateFalseWhenRequestsNotInOrder() { + MainnetRequestsValidator validator = new MainnetRequestsValidator(); + List requests = + List.of( + new Request(RequestType.WITHDRAWAL, Bytes.of(3)), + new Request(RequestType.DEPOSIT, Bytes.of(1)), + new Request(RequestType.CONSOLIDATION, Bytes.of(2))); + assertFalse(validator.validate(Optional.of(requests))); + } + + @Test + void validateTrueForValidRequests() { + MainnetRequestsValidator validator = new MainnetRequestsValidator(); + List requests = + List.of( + new Request(RequestType.DEPOSIT, Bytes.of(1)), + new Request(RequestType.WITHDRAWAL, Bytes.of(2)), + new Request(RequestType.CONSOLIDATION, Bytes.of(3))); + assertTrue(validator.validate(Optional.of(requests))); + } +} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/requests/ProhibitedRequestValidatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/requests/ProhibitedRequestValidatorTest.java new file mode 100644 index 0000000000..3694a58a4b --- /dev/null +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/requests/ProhibitedRequestValidatorTest.java @@ -0,0 +1,47 @@ +/* + * Copyright contributors to Besu. + * + * 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.mainnet.requests; + +import org.hyperledger.besu.datatypes.RequestType; +import org.hyperledger.besu.ethereum.core.Request; + +import java.util.List; +import java.util.Optional; + +import org.apache.tuweni.bytes.Bytes; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class ProhibitedRequestValidatorTest { + + @Test + void validateTrueWhenNoRequests() { + ProhibitedRequestValidator validator = new ProhibitedRequestValidator(); + Assertions.assertThat(validator.validate(Optional.empty())).isTrue(); + } + + @Test + void validateFalseWhenHasEmptyListOfRequests() { + ProhibitedRequestValidator validator = new ProhibitedRequestValidator(); + Assertions.assertThat(validator.validate(Optional.of(List.of()))).isFalse(); + } + + @Test + void validateFalseWhenHasRequests() { + ProhibitedRequestValidator validator = new ProhibitedRequestValidator(); + List requests = List.of(new Request(RequestType.DEPOSIT, Bytes.of(1))); + Assertions.assertThat(validator.validate(Optional.of(requests))).isFalse(); + } +} diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTask.java index 56a85b040b..dcacb31289 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTask.java @@ -20,7 +20,6 @@ import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Withdrawal; import org.hyperledger.besu.ethereum.eth.manager.EthContext; @@ -151,41 +150,34 @@ public class GetBodiesFromPeerTask extends AbstractPeerRequestTask> private final Bytes32 transactionsRoot; private final Bytes32 ommersHash; private final Bytes32 withdrawalsRoot; - private final Bytes32 requestsRoot; + // TODO should requestsHash be included in this? public BodyIdentifier( - final Bytes32 transactionsRoot, - final Bytes32 ommersHash, - final Bytes32 withdrawalsRoot, - final Bytes32 requestsRoot) { + final Bytes32 transactionsRoot, final Bytes32 ommersHash, final Bytes32 withdrawalsRoot) { this.transactionsRoot = transactionsRoot; this.ommersHash = ommersHash; this.withdrawalsRoot = withdrawalsRoot; - this.requestsRoot = requestsRoot; } public BodyIdentifier(final BlockBody body) { - this(body.getTransactions(), body.getOmmers(), body.getWithdrawals(), body.getRequests()); + this(body.getTransactions(), body.getOmmers(), body.getWithdrawals()); } public BodyIdentifier( final List transactions, final List ommers, - final Optional> withdrawals, - final Optional> requests) { + final Optional> withdrawals) { this( BodyValidation.transactionsRoot(transactions), BodyValidation.ommersHash(ommers), - withdrawals.map(BodyValidation::withdrawalsRoot).orElse(null), - requests.map(BodyValidation::requestsRoot).orElse(null)); + withdrawals.map(BodyValidation::withdrawalsRoot).orElse(null)); } public BodyIdentifier(final BlockHeader header) { this( header.getTransactionsRoot(), header.getOmmersHash(), - header.getWithdrawalsRoot().orElse(null), - header.getRequestsRoot().orElse(null)); + header.getWithdrawalsRoot().orElse(null)); } @Override @@ -195,13 +187,12 @@ public class GetBodiesFromPeerTask extends AbstractPeerRequestTask> BodyIdentifier that = (BodyIdentifier) o; return Objects.equals(transactionsRoot, that.transactionsRoot) && Objects.equals(ommersHash, that.ommersHash) - && Objects.equals(withdrawalsRoot, that.withdrawalsRoot) - && Objects.equals(requestsRoot, that.requestsRoot); + && Objects.equals(withdrawalsRoot, that.withdrawalsRoot); } @Override public int hashCode() { - return Objects.hash(transactionsRoot, ommersHash, withdrawalsRoot, requestsRoot); + return Objects.hash(transactionsRoot, ommersHash, withdrawalsRoot); } } } diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTask.java index ec679e53a1..82216ae09f 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTask.java @@ -92,8 +92,7 @@ public class CompleteBlocksTask extends AbstractRetryingPeerTask> { Collections.emptyList(), isWithdrawalsEnabled(protocolSchedule, header) ? Optional.of(Collections.emptyList()) - : Optional.empty(), - Optional.empty()); + : Optional.empty()); } private boolean isWithdrawalsEnabled( diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTaskTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTaskTest.java index b8546ad532..38a56bae93 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTaskTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTaskTest.java @@ -18,16 +18,11 @@ import static java.util.Collections.emptyList; import static org.assertj.core.api.Assertions.assertThat; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.BLSPublicKey; -import org.hyperledger.besu.datatypes.BLSSignature; import org.hyperledger.besu.datatypes.GWei; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.DepositRequest; -import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Withdrawal; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; import org.hyperledger.besu.ethereum.eth.manager.ethtaskutils.PeerMessageTaskTest; import java.util.ArrayList; @@ -35,7 +30,6 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; -import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.units.bigints.UInt64; import org.junit.jupiter.api.Test; @@ -80,58 +74,11 @@ public class GetBodiesFromPeerTaskTest extends PeerMessageTaskTest> final BlockBody emptyBodyBlock = BlockBody.empty(); // Block with no tx, no ommers, 1 withdrawal final BlockBody bodyBlockWithWithdrawal = - new BlockBody(emptyList(), emptyList(), Optional.of(List.of(withdrawal)), Optional.empty()); + new BlockBody(emptyList(), emptyList(), Optional.of(List.of(withdrawal))); assertThat( new GetBodiesFromPeerTask.BodyIdentifier(emptyBodyBlock) .equals(new GetBodiesFromPeerTask.BodyIdentifier(bodyBlockWithWithdrawal))) .isFalse(); } - - @Test - public void assertBodyIdentifierUsesDepositRequestsToGenerateBodyIdentifiers() { - final Request deposit = - new DepositRequest( - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - Bytes32.fromHexString( - "0x0017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483"), - GWei.of(32000000000L), - BLSSignature.fromHexString( - "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"), - UInt64.ONE); - - // Empty body block - final BlockBody emptyBodyBlock = BlockBody.empty(); - // Block with no tx, no ommers, 1 deposit - final BlockBody bodyBlockWithDeposit = - new BlockBody(emptyList(), emptyList(), Optional.empty(), Optional.of(List.of(deposit))); - - assertThat( - new GetBodiesFromPeerTask.BodyIdentifier(emptyBodyBlock) - .equals(new GetBodiesFromPeerTask.BodyIdentifier(bodyBlockWithDeposit))) - .isFalse(); - } - - @Test - public void assertBodyIdentifierUsesWithdrawalRequestsToGenerateBodyIdentifiers() { - final WithdrawalRequest withdrawalRequest = - new WithdrawalRequest( - Address.fromHexString("0x763c396673F9c391DCe3361A9A71C8E161388000"), - BLSPublicKey.fromHexString( - "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), - GWei.ONE); - - // Empty body block - final BlockBody emptyBodyBlock = BlockBody.empty(); - // Block with no tx, no ommers, 1 validator exit - final BlockBody bodyBlockWithValidatorExit = - new BlockBody( - emptyList(), emptyList(), Optional.empty(), Optional.of(List.of(withdrawalRequest))); - - assertThat( - new GetBodiesFromPeerTask.BodyIdentifier(emptyBodyBlock) - .equals(new GetBodiesFromPeerTask.BodyIdentifier(bodyBlockWithValidatorExit))) - .isFalse(); - } } diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/MessageWrapperTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/MessageWrapperTest.java index 78fcbb1c08..2b020cd4ac 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/MessageWrapperTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/MessageWrapperTest.java @@ -259,8 +259,7 @@ public class MessageWrapperTest { new BlockBody( Collections.emptyList(), Collections.emptyList(), - Optional.of(Collections.emptyList()), - Optional.empty())); + Optional.of(Collections.emptyList()))); } @Test @@ -284,8 +283,7 @@ public class MessageWrapperTest { new BlockBody( Collections.emptyList(), Collections.emptyList(), - Optional.of(Collections.emptyList()), - Optional.empty())); + Optional.of(Collections.emptyList()))); } @Test diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/ChainForTestCreator.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/ChainForTestCreator.java index 82d5de4f38..c15f3aa1dc 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/ChainForTestCreator.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/ChainForTestCreator.java @@ -88,7 +88,7 @@ public class ChainForTestCreator { blockHeader.getBlobGasUsed().orElse(null), blockHeader.getExcessBlobGas().orElse(null), blockHeader.getParentBeaconBlockRoot().orElse(null), - blockHeader.getRequestsRoot().orElse(null), + blockHeader.getRequestsHash().orElse(null), new MainnetBlockHeaderFunctions()); } diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTaskTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTaskTest.java index e8049af736..ba0fad675e 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTaskTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/tasks/CompleteBlocksTaskTest.java @@ -116,19 +116,14 @@ public class CompleteBlocksTaskTest extends RetryingMessageTaskTest> final Block block1 = new Block( header1, - new BlockBody( - Collections.emptyList(), - Collections.emptyList(), - Optional.empty(), - Optional.empty())); + new BlockBody(Collections.emptyList(), Collections.emptyList(), Optional.empty())); final Block block2 = new Block( header2, new BlockBody( Collections.emptyList(), Collections.emptyList(), - Optional.of(Collections.emptyList()), - Optional.empty())); + Optional.of(Collections.emptyList()))); final List expectedBlocks = asList(block1, block2); final EthTask> task = @@ -164,18 +159,14 @@ public class CompleteBlocksTaskTest extends RetryingMessageTaskTest> new Block( header2, new BlockBody( - Collections.emptyList(), - Collections.emptyList(), - Optional.of(withdrawals), - Optional.empty())); + Collections.emptyList(), Collections.emptyList(), Optional.of(withdrawals))); final Block block3 = new Block( header3, new BlockBody( Collections.emptyList(), Collections.emptyList(), - Optional.of(Collections.emptyList()), - Optional.empty())); + Optional.of(Collections.emptyList()))); final List expected = asList(block1, block2, block3); final RespondingEthPeer respondingPeer = diff --git a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java index fb0ccf4912..ba55fdf29e 100644 --- a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java +++ b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java @@ -34,19 +34,15 @@ import org.hyperledger.besu.datatypes.VersionedHash; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.ConsolidationRequest; -import org.hyperledger.besu.ethereum.core.DepositRequest; import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; -import org.hyperledger.besu.ethereum.core.WithdrawalRequest; import org.hyperledger.besu.ethereum.mainnet.BodyValidation; import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams; import org.hyperledger.besu.ethereum.mainnet.requests.ProcessRequestContext; -import org.hyperledger.besu.ethereum.mainnet.requests.RequestUtil; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.referencetests.BonsaiReferenceTestWorldState; import org.hyperledger.besu.ethereum.referencetests.ReferenceTestEnv; @@ -530,41 +526,14 @@ public class T8nExecutor { receipts, new CachingBlockHashLookup(blockHeader, blockchain), OperationTracer.NO_TRACING); - Optional> maybeRequests = rpc.process(context); - Hash requestRoot = BodyValidation.requestsRoot(maybeRequests.orElse(List.of())); - - resultObject.put("requestsRoot", requestRoot.toHexString()); - var deposits = resultObject.putArray("depositRequests"); - RequestUtil.filterRequestsOfType(maybeRequests.orElse(List.of()), DepositRequest.class) - .forEach( - deposit -> { - var obj = deposits.addObject(); - obj.put("pubkey", deposit.getPubkey().toHexString()); - obj.put("withdrawalCredentials", deposit.getWithdrawalCredentials().toHexString()); - obj.put("amount", deposit.getAmount().toHexString()); - obj.put("signature", deposit.getSignature().toHexString()); - obj.put("index", deposit.getIndex().toHexString()); - }); - - var withdrawalRequests = resultObject.putArray("withdrawalRequests"); - RequestUtil.filterRequestsOfType(maybeRequests.orElse(List.of()), WithdrawalRequest.class) - .forEach( - wr -> { - var obj = withdrawalRequests.addObject(); - obj.put("sourceAddress", wr.getSourceAddress().toHexString()); - obj.put("validatorPubkey", wr.getValidatorPubkey().toHexString()); - obj.put("amount", wr.getAmount().toHexString()); - }); - - var consolidationRequests = resultObject.putArray("consolidationRequests"); - RequestUtil.filterRequestsOfType(maybeRequests.orElse(List.of()), ConsolidationRequest.class) - .forEach( - cr -> { - var obj = consolidationRequests.addObject(); - obj.put("sourceAddress", cr.getSourceAddress().toHexString()); - obj.put("sourcePubkey", cr.getSourcePubkey().toHexString()); - obj.put("targetPubkey", cr.getTargetPubkey().toHexString()); - }); + Optional> maybeRequests = Optional.of(rpc.process(context)); + Hash requestsHash = BodyValidation.requestsHash(maybeRequests.orElse(List.of())); + + resultObject.put("requestsHash", requestsHash.toHexString()); + ArrayNode requests = resultObject.putArray("requests"); + maybeRequests + .orElseGet(List::of) + .forEach(request -> requests.add(request.getData().toHexString())); } worldState.persist(blockHeader); diff --git a/ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/block-test/osaka-eof-rjump.json b/ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/block-test/osaka-eof-rjump.json index 8cca437e34..a6c5bcc62c 100644 --- a/ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/block-test/osaka-eof-rjump.json +++ b/ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/block-test/osaka-eof-rjump.json @@ -27,7 +27,7 @@ "blobGasUsed": "0x00", "excessBlobGas": "0x00", "parentBeaconBlockRoot": "0x0000000000000000000000000000000000000000000000000000000000000000", - "requestsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "requestsHash": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "hash": "0x367310df4a31070aa9a5c92cb61ab8bb2742db0162619ed77594fbec6f0ddbd9" }, "pre": { @@ -219,7 +219,7 @@ "blobGasUsed": "0x00", "excessBlobGas": "0x00", "parentBeaconBlockRoot": "0x0000000000000000000000000000000000000000000000000000000000000000", - "requestsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "requestsHash": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "hash": "0xfb5d1d0e218fa7873bc188f07f3e0a7c78027ff6e6e199c48ba1facd3c3726fd" }, "transactions": [ diff --git a/ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/t8n/prague-deposit.json b/ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/t8n/prague-deposit.json index 1a32e50e8b..771dc870e6 100644 --- a/ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/t8n/prague-deposit.json +++ b/ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/t8n/prague-deposit.json @@ -132,7 +132,9 @@ "stdout": { "alloc": { "0x00000000219ab540356cbb839cbe05303d7705fa": { + "balance": "0x3782dace9d9000000", "code": "0x60806040526004361061003f5760003560e01c806301ffc9a71461004457806322895118146100a4578063621fd130146101ba578063c5f2892f14610244575b600080fd5b34801561005057600080fd5b506100906004803603602081101561006757600080fd5b50357fffffffff000000000000000000000000000000000000000000000000000000001661026b565b604080519115158252519081900360200190f35b6101b8600480360360808110156100ba57600080fd5b8101906020810181356401000000008111156100d557600080fd5b8201836020820111156100e757600080fd5b8035906020019184600183028401116401000000008311171561010957600080fd5b91939092909160208101903564010000000081111561012757600080fd5b82018360208201111561013957600080fd5b8035906020019184600183028401116401000000008311171561015b57600080fd5b91939092909160208101903564010000000081111561017957600080fd5b82018360208201111561018b57600080fd5b803590602001918460018302840111640100000000831117156101ad57600080fd5b919350915035610304565b005b3480156101c657600080fd5b506101cf6110b5565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102095781810151838201526020016101f1565b50505050905090810190601f1680156102365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561025057600080fd5b506102596110c7565b60408051918252519081900360200190f35b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102fe57507fffffffff0000000000000000000000000000000000000000000000000000000082167f8564090700000000000000000000000000000000000000000000000000000000145b92915050565b6030861461035d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118056026913960400191505060405180910390fd5b602084146103b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603681526020018061179c6036913960400191505060405180910390fd5b6060821461040f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806118786029913960400191505060405180910390fd5b670de0b6b3a7640000341015610470576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118526026913960400191505060405180910390fd5b633b9aca003406156104cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806117d26033913960400191505060405180910390fd5b633b9aca00340467ffffffffffffffff811115610535576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602781526020018061182b6027913960400191505060405180910390fd5b6060610540826114ba565b90507f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c589898989858a8a6105756020546114ba565b6040805160a0808252810189905290819060208201908201606083016080840160c085018e8e80828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910187810386528c815260200190508c8c808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690920188810386528c5181528c51602091820193918e019250908190849084905b83811015610648578181015183820152602001610630565b50505050905090810190601f1680156106755780820380516001836020036101000a031916815260200191505b5086810383528881526020018989808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018881038452895181528951602091820193918b019250908190849084905b838110156106ef5781810151838201526020016106d7565b50505050905090810190601f16801561071c5780820380516001836020036101000a031916815260200191505b509d505050505050505050505050505060405180910390a1600060028a8a600060801b604051602001808484808284377fffffffffffffffffffffffffffffffff0000000000000000000000000000000090941691909301908152604080517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0818403018152601090920190819052815191955093508392506020850191508083835b602083106107fc57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016107bf565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610859573d6000803e3d6000fd5b5050506040513d602081101561086e57600080fd5b5051905060006002806108846040848a8c6116fe565b6040516020018083838082843780830192505050925050506040516020818303038152906040526040518082805190602001908083835b602083106108f857805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016108bb565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610955573d6000803e3d6000fd5b5050506040513d602081101561096a57600080fd5b5051600261097b896040818d6116fe565b60405160009060200180848480828437919091019283525050604080518083038152602092830191829052805190945090925082918401908083835b602083106109f457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016109b7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610a51573d6000803e3d6000fd5b5050506040513d6020811015610a6657600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610ada57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610a9d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610b37573d6000803e3d6000fd5b5050506040513d6020811015610b4c57600080fd5b50516040805160208101858152929350600092600292839287928f928f92018383808284378083019250505093505050506040516020818303038152906040526040518082805190602001908083835b60208310610bd957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610b9c565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610c36573d6000803e3d6000fd5b5050506040513d6020811015610c4b57600080fd5b50516040518651600291889160009188916020918201918291908601908083835b60208310610ca957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610c6c565b6001836020036101000a0380198251168184511680821785525050505050509050018367ffffffffffffffff191667ffffffffffffffff1916815260180182815260200193505050506040516020818303038152906040526040518082805190602001908083835b60208310610d4e57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610d11565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610dab573d6000803e3d6000fd5b5050506040513d6020811015610dc057600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610e3457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610df7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610e91573d6000803e3d6000fd5b5050506040513d6020811015610ea657600080fd5b50519050858114610f02576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260548152602001806117486054913960600191505060405180910390fd5b60205463ffffffff11610f60576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806117276021913960400191505060405180910390fd5b602080546001019081905560005b60208110156110a9578160011660011415610fa0578260008260208110610f9157fe5b0155506110ac95505050505050565b600260008260208110610faf57fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061102557805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610fe8565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015611082573d6000803e3d6000fd5b5050506040513d602081101561109757600080fd5b50519250600282049150600101610f6e565b50fe5b50505050505050565b60606110c26020546114ba565b905090565b6020546000908190815b60208110156112f05781600116600114156111e6576002600082602081106110f557fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061116b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161112e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156111c8573d6000803e3d6000fd5b5050506040513d60208110156111dd57600080fd5b505192506112e2565b600283602183602081106111f657fe5b015460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061126b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161122e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156112c8573d6000803e3d6000fd5b5050506040513d60208110156112dd57600080fd5b505192505b6002820491506001016110d1565b506002826112ff6020546114ba565b600060401b6040516020018084815260200183805190602001908083835b6020831061135a57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161131d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790527fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000095909516920191825250604080518083037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8018152601890920190819052815191955093508392850191508083835b6020831061143f57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611402565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa15801561149c573d6000803e3d6000fd5b5050506040513d60208110156114b157600080fd5b50519250505090565b60408051600880825281830190925260609160208201818036833701905050905060c082901b8060071a60f81b826000815181106114f457fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060061a60f81b8260018151811061153757fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060051a60f81b8260028151811061157a57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060041a60f81b826003815181106115bd57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060031a60f81b8260048151811061160057fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060021a60f81b8260058151811061164357fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060011a60f81b8260068151811061168657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060001a60f81b826007815181106116c957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535050919050565b6000808585111561170d578182fd5b83861115611719578182fd5b505082019391909203915056fe4465706f736974436f6e74726163743a206d65726b6c6520747265652066756c6c4465706f736974436f6e74726163743a207265636f6e7374727563746564204465706f7369744461746120646f6573206e6f74206d6174636820737570706c696564206465706f7369745f646174615f726f6f744465706f736974436f6e74726163743a20696e76616c6964207769746864726177616c5f63726564656e7469616c73206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c7565206e6f74206d756c7469706c65206f6620677765694465706f736974436f6e74726163743a20696e76616c6964207075626b6579206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f20686967684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f206c6f774465706f736974436f6e74726163743a20696e76616c6964207369676e6174757265206c656e677468a2646970667358221220dceca8706b29e917dacf25fceef95acac8d90d765ac926663ce4096195952b6164736f6c634300060b0033", + "nonce": "0x1", "storage": { "0x0000000000000000000000000000000000000000000000000000000000000000": "0x85acb6376c2707b118225da41825974c12b5924a05c6a53b988c9cbc33c55b05", "0x0000000000000000000000000000000000000000000000000000000000000001": "0x2f93f18b1befc457f659e486ce25bbe413fe3943ee7634d2afbe83dc512c3d7a", @@ -168,30 +170,28 @@ "0x000000000000000000000000000000000000000000000000000000000000003e": "0x8869ff2c22b28cc10510d9853292803328be4fb0e80495e8bb8d271f5b889636", "0x000000000000000000000000000000000000000000000000000000000000003f": "0xb5fe28e79f1b850f8658246ce9b6a1e7b49fc06db7143e8fe0b4f2b0c5523a5c", "0x0000000000000000000000000000000000000000000000000000000000000040": "0x985e929f70af28d0bdd1a90a808f977f597c7c778c489e98d3bd8910d31ac0f7" - }, - "balance": "0x3782dace9d9000000", - "nonce": "0x1" - }, - "0x00a3ca265ebcb825b45f985a16cefb49958ce017": { - "code": "0x3373fffffffffffffffffffffffffffffffffffffffe146090573615156028575f545f5260205ff35b366038141561012e5760115f54600182026001905f5b5f82111560595781019083028483029004916001019190603e565b90939004341061012e57600154600101600155600354806003026004013381556001015f3581556001016020359055600101600355005b6003546002548082038060101160a4575060105b5f5b81811460dd5780604c02838201600302600401805490600101805490600101549160601b83528260140152906034015260010160a6565b910180921460ed579060025560f8565b90505f6002555f6003555b5f548061049d141561010757505f5b60015460028282011161011c5750505f610122565b01600290035b5f555f600155604c025ff35b5f5ffd", - "balance": "0x0", - "nonce": "0x1" + } }, "0x000f3df6d732807ef1319fb7b8bb8522d0beac02": { + "balance": "0x0", "code": "0x3373fffffffffffffffffffffffffffffffffffffffe14604d57602036146024575f5ffd5b5f35801560495762001fff810690815414603c575f5ffd5b62001fff01545f5260205ff35b5f5ffd5b62001fff42064281555f359062001fff015500", + "nonce": "0x1", "storage": { "0x000000000000000000000000000000000000000000000000000000000000000c": "0x000000000000000000000000000000000000000000000000000000000000000c" - }, + } + }, + "0x00a3ca265ebcb825b45f985a16cefb49958ce017": { "balance": "0x0", + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe146090573615156028575f545f5260205ff35b366038141561012e5760115f54600182026001905f5b5f82111560595781019083028483029004916001019190603e565b90939004341061012e57600154600101600155600354806003026004013381556001015f3581556001016020359055600101600355005b6003546002548082038060101160a4575060105b5f5b81811460dd5780604c02838201600302600401805490600101805490600101549160601b83528260140152906034015260010160a6565b910180921460ed579060025560f8565b90505f6002555f6003555b5f548061049d141561010757505f5b60015460028282011161011c5750505f610122565b01600290035b5f555f600155604c025ff35b5f5ffd", "nonce": "0x1" }, "0x0aae40965e6800cd9b1f4b05ff21581047e3f91e": { + "balance": "0x0", "code": "0x3373fffffffffffffffffffffffffffffffffffffffe1460575767ffffffffffffffff5f3511605357600143035f3511604b575f35612000014311604b57611fff5f3516545f5260205ff35b5f5f5260205ff35b5f5ffd5b5f35611fff60014303165500", + "nonce": "0x1", "storage": { "0x0000000000000000000000000000000000000000000000000000000000000000": "0xe4fb5d47f70d54b4f36777ea4c882cf767f93d8f8170285d97a1b8275dfe4dbb" - }, - "balance": "0x0", - "nonce": "0x1" + } }, "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": { "balance": "0xaa00be18c288efd690", @@ -200,90 +200,77 @@ }, "body": "0xf90404f901ff8007830f42409400000000219ab540356cbb839cbe05303d7705fa8901bc16d674ec800000b9019422895118000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000d0000000000000000000000000000000000000000000000000000000000000011085acb6376c2707b118225da41825974c12b5924a05c6a53b988c9cbc33c55b05000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000325a0ffeb1d6e7ef8e9ee9b64dcdc3b056f9a1d2b94c1572f1949954e712364604575a03d0f42bad795205de84db8d4ab10b9abd0d081ffe560cbf45f6c281768112a69f901ff0107830f42409400000000219ab540356cbb839cbe05303d7705fa8901bc16d674ec800000b9019422895118000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000d0000000000000000000000000000000000000000000000000000000000000011085acb6376c2707b118225da41825974c12b5924a05c6a53b988c9cbc33c55b05000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000326a05bb08e348c9c4b0a2e15d04f4a89d1a210d013205de8d3d93e38e5c1b0c8d8aba04300c0f575d9908d2cbc3413ab82895678bb8f3ef356224dd1e7cb972f2c4855", "result": { - "stateRoot": "0x3aa7839837ee1564276a0a05554e35215353a97c4e255c3aacbcd7c7819daefa", - "txRoot": "0x2b790bf82ef7259a0e4513d1b89a77d81e99672ba68758ef2ba3fde32851d023", - "receiptsRoot": "0x9c8d7a917ecb3ff2566f264abbf39131e51b08b07eb2b69cb46989d79d985593", - "logsHash": "0x43e31613bfefc1f55d8b3ca2b61f933f3838d523dc11cb5d7ffdd2ecf0ab5d49", + "blobGasUsed": "0x0", + "currentBaseFee": "0x7", + "currentDifficulty": null, + "currentExcessBlobGas": "0x0", + "gasUsed": "0x24f10", "logsBloom": "0x00000000000000000000400000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000020000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000", + "logsHash": "0x43e31613bfefc1f55d8b3ca2b61f933f3838d523dc11cb5d7ffdd2ecf0ab5d49", "receipts": [ { - "root": "0x", - "status": "0x1", + "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "contractAddress": "0x0000000000000000000000000000000000000000", "cumulativeGasUsed": "0x1431e", - "logsBloom": "0x00000000000000000000400000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000020000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000", + "gasUsed": "0x1431e", "logs": [ { "address": "0x00000000219ab540356cbb839cbe05303d7705fa", + "blockHash": "0xb7b43f46d6ee34eaaad5ab38807b451e0e85bacbe59893afc625550aa7c65262", + "blockNumber": 1, + "data": "0x00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000080040597307000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000", + "logIndex": "0x0", + "removed": "false", "topics": [ "0x649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000080040597307000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000", - "blockNumber": 1, "transactionHash": "0x1fe5fcd93d503a72e93ef0a4249e6d9c983cecf33474684f62ece959fc3e8212", - "transactionIndex": "0x0", - "blockHash": "0xb7b43f46d6ee34eaaad5ab38807b451e0e85bacbe59893afc625550aa7c65262", - "logIndex": "0x0", - "removed": "false" + "transactionIndex": "0x0" } ], + "logsBloom": "0x00000000000000000000400000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000020000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000", + "root": "0x", + "status": "0x1", "transactionHash": "0x1fe5fcd93d503a72e93ef0a4249e6d9c983cecf33474684f62ece959fc3e8212", - "contractAddress": "0x0000000000000000000000000000000000000000", - "gasUsed": "0x1431e", - "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "transactionIndex": "0x0" }, { - "root": "0x", - "status": "0x1", + "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "contractAddress": "0x0000000000000000000000000000000000000000", "cumulativeGasUsed": "0x24f10", - "logsBloom": "0x00000000000000000000400000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000020000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000", + "gasUsed": "0x10bf2", "logs": [ { "address": "0x00000000219ab540356cbb839cbe05303d7705fa", + "blockHash": "0xb7b43f46d6ee34eaaad5ab38807b451e0e85bacbe59893afc625550aa7c65262", + "blockNumber": 1, + "data": "0x00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000080040597307000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000080100000000000000000000000000000000000000000000000000000000000000", + "logIndex": "0x0", + "removed": "false", "topics": [ "0x649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000080040597307000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000080100000000000000000000000000000000000000000000000000000000000000", - "blockNumber": 1, "transactionHash": "0x3059d7dbc2df8a05442e50ea529419277c2f45582534f452d2d5676d93273c7d", - "transactionIndex": "0x1", - "blockHash": "0xb7b43f46d6ee34eaaad5ab38807b451e0e85bacbe59893afc625550aa7c65262", - "logIndex": "0x0", - "removed": "false" + "transactionIndex": "0x1" } ], + "logsBloom": "0x00000000000000000000400000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000020000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000", + "root": "0x", + "status": "0x1", "transactionHash": "0x3059d7dbc2df8a05442e50ea529419277c2f45582534f452d2d5676d93273c7d", - "contractAddress": "0x0000000000000000000000000000000000000000", - "gasUsed": "0x10bf2", - "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "transactionIndex": "0x1" } ], - "currentDifficulty": null, - "gasUsed": "0x24f10", - "currentBaseFee": "0x7", - "withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "currentExcessBlobGas": "0x0", - "blobGasUsed": "0x0", - "requestsRoot": "0xfba41d6600776bec2258a06e4bc00a34f7a2a1bc0aa802976d038ef4e3379d29", - "depositRequests": [ - { - "pubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", - "withdrawalCredentials": "0x0000000000000000000000000000000000000000000000000000000000000002", - "amount": "0x0000000773594000", - "signature": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003", - "index": "0x0000000000000000" - }, - { - "pubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", - "withdrawalCredentials": "0x0000000000000000000000000000000000000000000000000000000000000002", - "amount": "0x0000000773594000", - "signature": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003", - "index": "0x0000000000000001" - } + "receiptsRoot": "0x9c8d7a917ecb3ff2566f264abbf39131e51b08b07eb2b69cb46989d79d985593", + "requests": [ + "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200405973070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200405973070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030100000000000000", + "0x", + "0x" ], - "withdrawalRequests": [], - "consolidationRequests":[] + "requestsHash": "0x158ac6beda33cd9341831552555f64c95e074e7024f6c4553c1ed7557077b4c7", + "stateRoot": "0x3aa7839837ee1564276a0a05554e35215353a97c4e255c3aacbcd7c7819daefa", + "txRoot": "0x2b790bf82ef7259a0e4513d1b89a77d81e99672ba68758ef2ba3fde32851d023", + "withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" } } } \ No newline at end of file diff --git a/ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/t8n/prague-withdrawal.json b/ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/t8n/prague-withdrawal.json index 148c7a23e3..35f9843231 100644 --- a/ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/t8n/prague-withdrawal.json +++ b/ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/t8n/prague-withdrawal.json @@ -51,23 +51,29 @@ "0x40": "0x985e929f70af28d0bdd1a90a808f977f597c7c778c489e98d3bd8910d31ac0f7" } }, - "0x00a3ca265ebcb825b45f985a16cefb49958ce017": { + "0x09fc772d0857550724b07b850a4323f39112aaaa": { "nonce": "0x01", "balance": "0x00", - "code": "0x3373fffffffffffffffffffffffffffffffffffffffe146090573615156028575f545f5260205ff35b366038141561012e5760115f54600182026001905f5b5f82111560595781019083028483029004916001019190603e565b90939004341061012e57600154600101600155600354806003026004013381556001015f3581556001016020359055600101600355005b6003546002548082038060101160a4575060105b5f5b81811460dd5780604c02838201600302600401805490600101805490600101549160601b83528260140152906034015260010160a6565b910180921460ed579060025560f8565b90505f6002555f6003555b5f548061049d141561010757505f5b60015460028282011161011c5750505f610122565b01600290035b5f555f600155604c025ff35b5f5ffd", - "storage": { - } + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe1460c7573615156028575f545f5260205ff35b36603814156101f05760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff146101f057600182026001905f5b5f821115608057810190830284830290049160010191906065565b9093900434106101f057600154600101600155600354806003026004013381556001015f35815560010160203590553360601b5f5260385f601437604c5fa0600101600355005b6003546002548082038060101160db575060105b5f5b81811461017f5780604c02838201600302600401805490600101805490600101549160601b83528260140152807fffffffffffffffffffffffffffffffff0000000000000000000000000000000016826034015260401c906044018160381c81600701538160301c81600601538160281c81600501538160201c81600401538160181c81600301538160101c81600201538160081c81600101535360010160dd565b9101809214610191579060025561019c565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14156101c957505f5b6001546002828201116101de5750505f6101e4565b01600290035b5f555f600155604c025ff35b5f5ffd", + "storage": {} }, - "0x000f3df6d732807ef1319fb7b8bb8522d0beac02": { + "0x01abea29659e5e97c95107f20bb753cd3e09bbbb": { "nonce": "0x01", "balance": "0x00", - "code": "0x3373fffffffffffffffffffffffffffffffffffffffe14604d57602036146024575f5ffd5b5f35801560495762001fff810690815414603c575f5ffd5b62001fff01545f5260205ff35b5f5ffd5b62001fff42064281555f359062001fff015500", + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe1460cf573615156028575f545f5260205ff35b366060141561019a5760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1461019a57600182026001905f5b5f821115608057810190830284830290049160010191906065565b90939004341061019a57600154600101600155600354806004026004013381556001015f358155600101602035815560010160403590553360601b5f5260605f60143760745fa0600101600355005b6003546002548082038060011160e3575060015b5f5b8181146101295780607402838201600402600401805490600101805490600101805490600101549260601b84529083601401528260340152906054015260010160e5565b910180921461013b5790600255610146565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff141561017357505f5b6001546001828201116101885750505f61018e565b01600190035b5f555f6001556074025ff35b5f5ffd", "storage": {} }, "0x0aae40965e6800cd9b1f4b05ff21581047e3f91e": { + "nonce": "0x01", + "balance": "0x00", "code": "0x3373fffffffffffffffffffffffffffffffffffffffe1460575767ffffffffffffffff5f3511605357600143035f3511604b575f35612000014311604b57611fff5f3516545f5260205ff35b5f5f5260205ff35b5f5ffd5b5f35611fff60014303165500", - "balance": "0x0", - "nonce": "0x1" + "storage": {} + }, + "0x000f3df6d732807ef1319fb7b8bb8522d0beac02": { + "nonce": "0x01", + "balance": "0x00", + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe14604d57602036146024575f5ffd5b5f35801560495762001fff810690815414603c575f5ffd5b62001fff01545f5260205ff35b5f5ffd5b62001fff42064281555f359062001fff015500", + "storage": {} }, "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": { "nonce": "0x00", @@ -75,10 +81,10 @@ "code": "0x", "storage": {} }, - "0x0000000000000000000000000000000000000200": { + "0x0000000000000000000000000000000000001000": { "nonce": "0x01", "balance": "0xad78ebc5ac62000000", - "code": "0x60386000600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f15060386038600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f15060386070600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f150603860a8600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f150603860e0600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610118600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610150600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610188600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f15060386101c0600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f15060386101f8600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610230600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610268600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f15060386102a0600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f15060386102d8600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610310600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610348600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f150", + "code": "0x60386000600037600060006038600060017309fc772d0857550724b07b850a4323f39112aaaa620f4240f150", "storage": {} } }, @@ -89,12 +95,12 @@ "nonce": "0x0", "gasPrice": "0x7", "gas": "0xf4240", - "to": "0x0000000000000000000000000000000000000200", + "to": "0x0000000000000000000000000000000000001000", "value": "0x0", - "input": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001fffffffffffffffe0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003fffffffffffffffe0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005fffffffffffffffe0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007fffffffffffffffe0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009fffffffffffffffe00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bfffffffffffffffe00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dfffffffffffffffe00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffe0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000", + "input": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000", "v": "0x26", - "r": "0x963cb6620fe5828cbc93bb7139d3f4501067d76275dff648bf48c3c100ca8dd4", - "s": "0x4ac396104a5be4643406718f59a6e74d62a32777f5f6135e55e805e87612013c", + "r": "0xd050db98a60dbe4bbbc6ce154c607f28f1cf803a8882f369b28a5eb4ef1a600f", + "s": "0x7512ca5133bcb887a41f6136cd645839c1bcf0f300325948387a70f3ad9ced1c", "sender": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" } ], @@ -124,9 +130,9 @@ }, "stdout": { "alloc": { - "0x0000000000000000000000000000000000000200": { - "code": "0x60386000600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f15060386038600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f15060386070600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f150603860a8600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f150603860e0600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610118600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610150600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610188600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f15060386101c0600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f15060386101f8600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610230600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610268600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f15060386102a0600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f15060386102d8600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610310600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f1506038610348600037600060006038600060017300a3ca265ebcb825b45f985a16cefb49958ce017620f4240f150", - "balance": "0xad78ebc5ac61fffff0", + "0x0000000000000000000000000000000000001000": { + "code": "0x60386000600037600060006038600060017309fc772d0857550724b07b850a4323f39112aaaa620f4240f150", + "balance": "0xad78ebc5ac61ffffff", "nonce": "0x1" }, "0x00000000219ab540356cbb839cbe05303d7705fa": { @@ -175,44 +181,18 @@ "balance": "0x0", "nonce": "0x1" }, - "0x00a3ca265ebcb825b45f985a16cefb49958ce017": { - "code": "0x3373fffffffffffffffffffffffffffffffffffffffe146090573615156028575f545f5260205ff35b366038141561012e5760115f54600182026001905f5b5f82111560595781019083028483029004916001019190603e565b90939004341061012e57600154600101600155600354806003026004013381556001015f3581556001016020359055600101600355005b6003546002548082038060101160a4575060105b5f5b81811460dd5780604c02838201600302600401805490600101805490600101549160601b83528260140152906034015260010160a6565b910180921460ed579060025560f8565b90505f6002555f6003555b5f548061049d141561010757505f5b60015460028282011161011c5750505f610122565b01600290035b5f555f600155604c025ff35b5f5ffd", + "0x01abea29659e5e97c95107f20bb753cd3e09bbbb": { + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe1460cf573615156028575f545f5260205ff35b366060141561019a5760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1461019a57600182026001905f5b5f821115608057810190830284830290049160010191906065565b90939004341061019a57600154600101600155600354806004026004013381556001015f358155600101602035815560010160403590553360601b5f5260605f60143760745fa0600101600355005b6003546002548082038060011160e3575060015b5f5b8181146101295780607402838201600402600401805490600101805490600101805490600101549260601b84529083601401528260340152906054015260010160e5565b910180921461013b5790600255610146565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff141561017357505f5b6001546001828201116101885750505f61018e565b01600190035b5f555f6001556074025ff35b5f5ffd", + "balance": "0x0", + "nonce": "0x1" + }, + "0x09fc772d0857550724b07b850a4323f39112aaaa": { + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe1460c7573615156028575f545f5260205ff35b36603814156101f05760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff146101f057600182026001905f5b5f821115608057810190830284830290049160010191906065565b9093900434106101f057600154600101600155600354806003026004013381556001015f35815560010160203590553360601b5f5260385f601437604c5fa0600101600355005b6003546002548082038060101160db575060105b5f5b81811461017f5780604c02838201600302600401805490600101805490600101549160601b83528260140152807fffffffffffffffffffffffffffffffff0000000000000000000000000000000016826034015260401c906044018160381c81600701538160301c81600601538160281c81600501538160201c81600401538160181c81600301538160101c81600201538160081c81600101535360010160dd565b9101809214610191579060025561019c565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14156101c957505f5b6001546002828201116101de5750505f6101e4565b01600290035b5f555f600155604c025ff35b5f5ffd", "storage": { - "0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000000000000000000000000000000000000000000e", - "0x0000000000000000000000000000000000000000000000000000000000000004": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x0000000000000000000000000000000000000000000000000000000000000006": "0x00000000000000000000000000000001fffffffffffffffe0000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000007": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x0000000000000000000000000000000000000000000000000000000000000009": "0x0000000000000000000000000000000200000000000000000000000000000000", - "0x000000000000000000000000000000000000000000000000000000000000000a": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x000000000000000000000000000000000000000000000000000000000000000c": "0x00000000000000000000000000000003fffffffffffffffe0000000000000000", - "0x000000000000000000000000000000000000000000000000000000000000000d": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x000000000000000000000000000000000000000000000000000000000000000f": "0x0000000000000000000000000000000400000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000010": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x0000000000000000000000000000000000000000000000000000000000000012": "0x00000000000000000000000000000005fffffffffffffffe0000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000013": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x0000000000000000000000000000000000000000000000000000000000000015": "0x0000000000000000000000000000000600000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000016": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x0000000000000000000000000000000000000000000000000000000000000018": "0x00000000000000000000000000000007fffffffffffffffe0000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000019": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x000000000000000000000000000000000000000000000000000000000000001b": "0x0000000000000000000000000000000800000000000000000000000000000000", - "0x000000000000000000000000000000000000000000000000000000000000001c": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x000000000000000000000000000000000000000000000000000000000000001e": "0x00000000000000000000000000000009fffffffffffffffe0000000000000000", - "0x000000000000000000000000000000000000000000000000000000000000001f": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x0000000000000000000000000000000000000000000000000000000000000021": "0x0000000000000000000000000000000a00000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000022": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x0000000000000000000000000000000000000000000000000000000000000024": "0x0000000000000000000000000000000bfffffffffffffffe0000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000025": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x0000000000000000000000000000000000000000000000000000000000000027": "0x0000000000000000000000000000000c00000000000000000000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000028": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x000000000000000000000000000000000000000000000000000000000000002a": "0x0000000000000000000000000000000dfffffffffffffffe0000000000000000", - "0x000000000000000000000000000000000000000000000000000000000000002b": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x000000000000000000000000000000000000000000000000000000000000002d": "0x0000000000000000000000000000000e00000000000000000000000000000000", - "0x000000000000000000000000000000000000000000000000000000000000002e": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x0000000000000000000000000000000000000000000000000000000000000030": "0x0000000000000000000000000000000ffffffffffffffffe0000000000000000", - "0x0000000000000000000000000000000000000000000000000000000000000031": "0x0000000000000000000000000000000000000000000000000000000000000200", - "0x0000000000000000000000000000000000000000000000000000000000000033": "0x0000000000000000000000000000001000000000000000000000000000000000" + "0x0000000000000000000000000000000000000000000000000000000000000004": "0x0000000000000000000000000000000000000000000000000000000000001000", + "0x0000000000000000000000000000000000000000000000000000000000000006": "0x0000000000000000000000000000000100000000000000000000000000000000" }, - "balance": "0x10", + "balance": "0x1", "nonce": "0x1" }, "0x0aae40965e6800cd9b1f4b05ff21581047e3f91e": { @@ -224,118 +204,51 @@ "nonce": "0x1" }, "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": { - "balance": "0xad78ebc5ac619bbcea", + "balance": "0xad78ebc5ac61f2afcb", "nonce": "0x1" } }, - "body": "0xf903e5f903e28007830f424094000000000000000000000000000000000000020080b90380000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001fffffffffffffffe0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003fffffffffffffffe0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005fffffffffffffffe0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007fffffffffffffffe0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009fffffffffffffffe00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bfffffffffffffffe00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dfffffffffffffffe00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffe000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000026a0963cb6620fe5828cbc93bb7139d3f4501067d76275dff648bf48c3c100ca8dd4a04ac396104a5be4643406718f59a6e74d62a32777f5f6135e55e805e87612013c", + "body": "0xf89bf8998007830f424094000000000000000000000000000000000000100080b838000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000026a0d050db98a60dbe4bbbc6ce154c607f28f1cf803a8882f369b28a5eb4ef1a600fa07512ca5133bcb887a41f6136cd645839c1bcf0f300325948387a70f3ad9ced1c", "result": { - "requestsRoot": "0x415d33e444f917658fd3bd6d3d8d88a1f501f9b83ace92ddacac823252c9fa47", - "depositRequests": [], - "withdrawalRequests": [ - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", - "amount": "0xfffffffffffffffe" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002", - "amount": "0x0000000000000000" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003", - "amount": "0xfffffffffffffffe" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004", - "amount": "0x0000000000000000" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005", - "amount": "0xfffffffffffffffe" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006", - "amount": "0x0000000000000000" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007", - "amount": "0xfffffffffffffffe" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008", - "amount": "0x0000000000000000" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009", - "amount": "0xfffffffffffffffe" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a", - "amount": "0x0000000000000000" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b", - "amount": "0xfffffffffffffffe" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c", - "amount": "0x0000000000000000" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d", - "amount": "0xfffffffffffffffe" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e", - "amount": "0x0000000000000000" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f", - "amount": "0xfffffffffffffffe" - }, - { - "sourceAddress": "0x0000000000000000000000000000000000000200", - "validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010", - "amount": "0x0000000000000000" - } + "requestsHash": "0xab205d558af6253557180e19e89356ed4c7d4b13615ee9560840af3df75ddb12", + "requests": [ + "0x", + "0x00000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000", + "0x" ], - "consolidationRequests":[], - "stateRoot": "0xf63d7552dc407993393315e99272781d04eedfcf369a1acd3e386d1e6710229d", - "txRoot": "0x8521df63211790726b6f1a437bb0fd4b27c00e13e7678d324c4cfddb8d834ad2", - "receiptsRoot": "0x4bd8bd5580caf4ed45f873794ad7ff9d6fd2363ae529269b17b891b68d349d75", - "logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "stateRoot": "0x23d988164325beeeea1044c9f104ff4fe108038369f26a3327198ce40f827430", + "txRoot": "0x0d36638e52999b7beafa00eb94f7ca23139774cd14229c011d0edc1fc66125c9", + "receiptsRoot": "0x3d22e243cbebced1fafba149bce09285797af6c66ce901ff3ab1caf073fca791", + "logsHash": "0xf69b003be75aaafefa35aa30e6367f732dd9b31a6c97196febc285ee9289bb60", + "logsBloom": "0x00000000000000000000000008000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "receipts": [ { "root": "0x", "status": "0x1", - "cumulativeGasUsed": "0xe52ba", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "logs": null, - "transactionHash": "0x04a2d3f252dcc98edb684f7f15b572aaf980d0c2eea4c620a9f1ff1d275b2207", + "cumulativeGasUsed": "0x1e6e3", + "logsBloom": "0x00000000000000000000000008000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "logs": [ + { + "address": "0x09fc772d0857550724b07b850a4323f39112aaaa", + "topics": [], + "data": "0x00000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000", + "blockNumber": 1, + "transactionHash": "0xa888ec4587b7ba70d0127004a96fbb0a83ccb611e61405094e6514b970bf37f6", + "transactionIndex": "0x0", + "blockHash": "0xb7b43f46d6ee34eaaad5ab38807b451e0e85bacbe59893afc625550aa7c65262", + "logIndex": "0x0", + "removed": "false" + } + ], + "transactionHash": "0xa888ec4587b7ba70d0127004a96fbb0a83ccb611e61405094e6514b970bf37f6", "contractAddress": "0x0000000000000000000000000000000000000000", - "gasUsed": "0xe52ba", + "gasUsed": "0x1e6e3", "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "transactionIndex": "0x0" } ], "currentDifficulty": null, - "gasUsed": "0xe52ba", + "gasUsed": "0x1e6e3", "currentBaseFee": "0x7", "withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "currentExcessBlobGas": "0x0", diff --git a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BlockchainReferenceTestCaseSpec.java b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BlockchainReferenceTestCaseSpec.java index a30401e17c..bc60c7ddd0 100644 --- a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BlockchainReferenceTestCaseSpec.java +++ b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BlockchainReferenceTestCaseSpec.java @@ -31,7 +31,6 @@ import org.hyperledger.besu.ethereum.core.Difficulty; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.ParsedExtraData; -import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Withdrawal; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; @@ -165,7 +164,7 @@ public class BlockchainReferenceTestCaseSpec { @JsonProperty("mixHash") final String mixHash, @JsonProperty("nonce") final String nonce, @JsonProperty("withdrawalsRoot") final String withdrawalsRoot, - @JsonProperty("requestsRoot") final String requestsRoot, + @JsonProperty("requestsHash") final String requestsHash, @JsonProperty("blobGasUsed") final String blobGasUsed, @JsonProperty("excessBlobGas") final String excessBlobGas, @JsonProperty("parentBeaconBlockRoot") final String parentBeaconBlockRoot, @@ -195,7 +194,7 @@ public class BlockchainReferenceTestCaseSpec { blobGasUsed != null ? Long.decode(blobGasUsed) : 0, excessBlobGas != null ? BlobGas.fromHexString(excessBlobGas) : null, parentBeaconBlockRoot != null ? Bytes32.fromHexString(parentBeaconBlockRoot) : null, - requestsRoot != null ? Hash.fromHexString(requestsRoot) : null, + requestsHash != null ? Hash.fromHexString(requestsHash) : null, new BlockHeaderFunctions() { @Override public Hash hash(final BlockHeader header) { @@ -290,10 +289,7 @@ public class BlockchainReferenceTestCaseSpec { input.readList(inputData -> BlockHeader.readFrom(inputData, blockHeaderFunctions)), input.isEndOfCurrentList() ? Optional.empty() - : Optional.of(input.readList(Withdrawal::readFrom)), - input.isEndOfCurrentList() - ? Optional.empty() - : Optional.of(input.readList(Request::readFrom))); + : Optional.of(input.readList(Withdrawal::readFrom))); return new Block(header, body); } } diff --git a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestEnv.java b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestEnv.java index 636e23f878..26c124472b 100644 --- a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestEnv.java +++ b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestEnv.java @@ -145,7 +145,7 @@ public class ReferenceTestEnv extends BlockHeader { currentBlobGasUsed == null ? null : Long.decode(currentBlobGasUsed), currentExcessBlobGas == null ? null : BlobGas.of(Long.decode(currentExcessBlobGas)), beaconRoot == null ? null : Bytes32.fromHexString(beaconRoot), - null, // requestsRoot + null, // requestsHash new MainnetBlockHeaderFunctions()); this.parentDifficulty = parentDifficulty; this.parentBaseFee = parentBaseFee; diff --git a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/NoRewardProtocolScheduleWrapper.java b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/NoRewardProtocolScheduleWrapper.java index 99210f57d2..db1ac943f0 100644 --- a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/NoRewardProtocolScheduleWrapper.java +++ b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/NoRewardProtocolScheduleWrapper.java @@ -88,7 +88,7 @@ public class NoRewardProtocolScheduleWrapper implements ProtocolSchedule { Optional.empty(), original.getWithdrawalsValidator(), original.getWithdrawalsProcessor(), - original.getRequestsValidatorCoordinator(), + original.getRequestsValidator(), original.getRequestProcessorCoordinator(), original.getBlockHashProcessor(), original.isPoS(), diff --git a/plugin-api/build.gradle b/plugin-api/build.gradle index 91fb45239d..d400e5abe2 100644 --- a/plugin-api/build.gradle +++ b/plugin-api/build.gradle @@ -71,7 +71,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 = 'WRdnBaP05fItpWHYSFz/vBBlRWL3sLGqzR3tzd+pOkA=' + knownHash = '1VIGlJuGiaEVUksIjTTHDt7SIjjJE9+DU8rYk/ze3XM=' } check.dependsOn('checkAPIChanges') diff --git a/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/BlockBody.java b/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/BlockBody.java index 18a5e07ce6..7c101f414f 100644 --- a/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/BlockBody.java +++ b/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/BlockBody.java @@ -15,7 +15,6 @@ package org.hyperledger.besu.plugin.data; import org.hyperledger.besu.datatypes.Transaction; -import org.hyperledger.besu.plugin.Unstable; import java.util.List; import java.util.Optional; @@ -47,12 +46,4 @@ public interface BlockBody { * @return The list of withdrawals of the block. */ Optional> getWithdrawals(); - - /** - * Returns the list of requests of the block. - * - * @return The list of requests of the block. - */ - @Unstable - Optional> getRequests(); } diff --git a/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/BlockHeader.java b/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/BlockHeader.java index ed8d6b8745..05f0c0304e 100644 --- a/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/BlockHeader.java +++ b/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/BlockHeader.java @@ -128,7 +128,7 @@ public interface BlockHeader extends ProcessableBlockHeader { * request in the request list portion of the block. */ @Unstable - Optional getRequestsRoot(); + Optional getRequestsHash(); /** * The excess_blob_gas of this header. diff --git a/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/ConsolidationRequest.java b/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/ConsolidationRequest.java deleted file mode 100644 index 5d7e66b4ae..0000000000 --- a/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/ConsolidationRequest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.data; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.PublicKey; -import org.hyperledger.besu.plugin.Unstable; - -/** A consolidation request is an operation sent to the Beacon Node for processing. */ -@Unstable -public interface ConsolidationRequest { - - /** - * Withdrawal credential (0x01) associated with the validator - * - * @return withdrawal credential address - */ - Address getSourceAddress(); - - /** - * Public key of the address that sends the consolidation - * - * @return public key of sender - */ - PublicKey getSourcePubkey(); - - /** - * Public key of the address to receives the consolidation - * - * @return public key of target - */ - PublicKey getTargetPubkey(); -} diff --git a/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/DepositRequest.java b/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/DepositRequest.java deleted file mode 100644 index 096554d3c7..0000000000 --- a/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/DepositRequest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.data; - -import org.hyperledger.besu.datatypes.BLSSignature; -import org.hyperledger.besu.datatypes.PublicKey; -import org.hyperledger.besu.datatypes.Quantity; -import org.hyperledger.besu.plugin.Unstable; - -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.units.bigints.UInt64; - -/** - * A deposit is a system-level operation to support validator deposits that are pushed from the EVM - * to beacon chain. - */ -@Unstable -public interface DepositRequest { - - /** - * Public key of the address that sends the deposit - * - * @return public key of sender - */ - PublicKey getPubkey(); - - /** - * Withdrawal credential that contains info that will be used for verifying the destination of - * valid withdrawals - * - * @return withdrawal credential - */ - Bytes32 getWithdrawalCredentials(); - - /** - * Amount of ether to be sent to the deposit contract - * - * @return deposit ether amount - */ - Quantity getAmount(); - - /** - * Signature that will be used together with the public key to verify the validity of this Deposit - * - * @return signature - */ - BLSSignature getSignature(); - - /** - * A monotonically increasing index, starting from 0 that increments by 1 per deposit to uniquely - * identify each deposit - * - * @return deposit index - */ - UInt64 getIndex(); -} diff --git a/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/Request.java b/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/Request.java index 2540f91098..0e55f39980 100644 --- a/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/Request.java +++ b/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/Request.java @@ -17,6 +17,8 @@ package org.hyperledger.besu.plugin.data; import org.hyperledger.besu.datatypes.RequestType; import org.hyperledger.besu.plugin.Unstable; +import org.apache.tuweni.bytes.Bytes; + /** A request is an operation sent to the Beacon Node */ @Unstable public interface Request { @@ -27,4 +29,11 @@ public interface Request { * @return The {@link RequestType} representing the type of this request. */ RequestType getType(); + + /** + * Retrieves the data of this request. + * + * @return The data {@link Bytes} of this request. + */ + Bytes getData(); } diff --git a/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/WithdrawalRequest.java b/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/WithdrawalRequest.java deleted file mode 100644 index f07d0d08d0..0000000000 --- a/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/WithdrawalRequest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright contributors to Hyperledger Besu. - * - * 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.data; - -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.datatypes.PublicKey; -import org.hyperledger.besu.plugin.Unstable; - -/** - * A withdrawal request is an operation sent to the Beacon Node for processing validator withdrawal - * requests (partial or complete) - */ -@Unstable -public interface WithdrawalRequest { - - /** - * Withdrawal credential (0x01) associated with the validator - * - * @return withdrawal credential address - */ - Address getSourceAddress(); - - /** - * Public key of the validator that is going to request a withdrawal - * - * @return public key of validator - */ - PublicKey getValidatorPubkey(); - - /** - * The amount for withdrawal - * - * @return withdrawal amount - */ - GWei getAmount(); -}