diff --git a/CHANGELOG.md b/CHANGELOG.md index 494a41b5039..10af80958e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,5 +17,6 @@ For information on changes in released versions of Teku, see the [releases page] ### Additions and Improvements - `--validators-external-signer-public-keys` parameter now accepts `external-signer` value. It will enable public key retrieval from external signer standard API, making sure that configured keystore and trustStore will be used, if any. +- Will stop calling `engine_exchangeTransitionConfigurationV1` Engine API method, since the method has been deprecated. ### Bug Fixes diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/ExecutionEngineClient.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/ExecutionEngineClient.java index c2f988a25a3..fe7f9284ab9 100644 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/ExecutionEngineClient.java +++ b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/ExecutionEngineClient.java @@ -27,7 +27,6 @@ import tech.pegasys.teku.ethereum.executionclient.schema.PayloadAttributesV2; import tech.pegasys.teku.ethereum.executionclient.schema.PayloadStatusV1; import tech.pegasys.teku.ethereum.executionclient.schema.Response; -import tech.pegasys.teku.ethereum.executionclient.schema.TransitionConfigurationV1; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.bytes.Bytes8; import tech.pegasys.teku.spec.datastructures.execution.PowBlock; @@ -59,8 +58,5 @@ SafeFuture> forkChoiceUpdatedV1( SafeFuture> forkChoiceUpdatedV2( ForkChoiceStateV1 forkChoiceState, Optional payloadAttributes); - SafeFuture> exchangeTransitionConfiguration( - TransitionConfigurationV1 transitionConfiguration); - SafeFuture>> exchangeCapabilities(List capabilities); } diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/ThrottlingExecutionEngineClient.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/ThrottlingExecutionEngineClient.java index 322982a55c5..9ed5fd7ab09 100644 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/ThrottlingExecutionEngineClient.java +++ b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/ThrottlingExecutionEngineClient.java @@ -28,7 +28,6 @@ import tech.pegasys.teku.ethereum.executionclient.schema.PayloadAttributesV2; import tech.pegasys.teku.ethereum.executionclient.schema.PayloadStatusV1; import tech.pegasys.teku.ethereum.executionclient.schema.Response; -import tech.pegasys.teku.ethereum.executionclient.schema.TransitionConfigurationV1; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.async.ThrottlingTaskQueue; import tech.pegasys.teku.infrastructure.bytes.Bytes8; @@ -112,13 +111,6 @@ public SafeFuture> forkChoiceUpdatedV2( () -> delegate.forkChoiceUpdatedV2(forkChoiceState, payloadAttributes)); } - @Override - public SafeFuture> exchangeTransitionConfiguration( - final TransitionConfigurationV1 transitionConfiguration) { - return taskQueue.queueTask( - () -> delegate.exchangeTransitionConfiguration(transitionConfiguration)); - } - @Override public SafeFuture>> exchangeCapabilities(final List capabilities) { return taskQueue.queueTask(() -> delegate.exchangeCapabilities(capabilities)); diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/methods/EngineApiMethod.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/methods/EngineApiMethod.java index 79d5201fc94..6ec4501e192 100644 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/methods/EngineApiMethod.java +++ b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/methods/EngineApiMethod.java @@ -18,8 +18,7 @@ public enum EngineApiMethod { ETH_GET_BLOCK_BY_NUMBER("eth_getBlockByNumber"), ENGINE_NEW_PAYLOAD("engine_newPayload"), ENGINE_GET_PAYLOAD("engine_getPayload"), - ENGINE_FORK_CHOICE_UPDATED("engine_forkchoiceUpdated"), - ENGINE_EXCHANGE_TRANSITION_CONFIGURATION("engine_exchangeTransitionConfiguration"); + ENGINE_FORK_CHOICE_UPDATED("engine_forkchoiceUpdated"); private final String name; diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/methods/EngineExchangeTransitionConfigurationV1.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/methods/EngineExchangeTransitionConfigurationV1.java deleted file mode 100644 index 3aab99ad91e..00000000000 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/methods/EngineExchangeTransitionConfigurationV1.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright ConsenSys Software Inc., 2023 - * - * 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. - */ - -package tech.pegasys.teku.ethereum.executionclient.methods; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import tech.pegasys.teku.ethereum.executionclient.ExecutionEngineClient; -import tech.pegasys.teku.ethereum.executionclient.response.ResponseUnwrapper; -import tech.pegasys.teku.ethereum.executionclient.schema.TransitionConfigurationV1; -import tech.pegasys.teku.infrastructure.async.SafeFuture; -import tech.pegasys.teku.spec.executionlayer.TransitionConfiguration; - -public class EngineExchangeTransitionConfigurationV1 - extends AbstractEngineJsonRpcMethod { - - private static final Logger LOG = LogManager.getLogger(); - - public EngineExchangeTransitionConfigurationV1( - final ExecutionEngineClient executionEngineClient) { - super(executionEngineClient); - } - - @Override - public String getName() { - return EngineApiMethod.ENGINE_EXCHANGE_TRANSITION_CONFIGURATION.getName(); - } - - @Override - public int getVersion() { - return 1; - } - - @Override - public SafeFuture execute(final JsonRpcRequestParams params) { - final TransitionConfiguration transitionConfiguration = - params.getRequiredParameter(0, TransitionConfiguration.class); - - LOG.trace( - "calling engineExchangeTransitionConfiguration(transitionConfiguration={})", - transitionConfiguration); - - return executionEngineClient - .exchangeTransitionConfiguration( - TransitionConfigurationV1.fromInternalTransitionConfiguration(transitionConfiguration)) - .thenApply(ResponseUnwrapper::unwrapExecutionClientResponseOrThrow) - .thenApply(TransitionConfigurationV1::asInternalTransitionConfiguration) - .thenPeek( - remoteTransitionConfiguration -> - LOG.trace( - "engineExchangeTransitionConfiguration(transitionConfiguration={}) -> {}", - transitionConfiguration, - remoteTransitionConfiguration)); - } -} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/metrics/MetricRecordingExecutionEngineClient.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/metrics/MetricRecordingExecutionEngineClient.java index 52924c6f0c8..f728b9983e3 100644 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/metrics/MetricRecordingExecutionEngineClient.java +++ b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/metrics/MetricRecordingExecutionEngineClient.java @@ -30,7 +30,6 @@ import tech.pegasys.teku.ethereum.executionclient.schema.PayloadAttributesV2; import tech.pegasys.teku.ethereum.executionclient.schema.PayloadStatusV1; import tech.pegasys.teku.ethereum.executionclient.schema.Response; -import tech.pegasys.teku.ethereum.executionclient.schema.TransitionConfigurationV1; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.bytes.Bytes8; import tech.pegasys.teku.infrastructure.metrics.MetricsCountersByIntervals; @@ -141,12 +140,6 @@ public SafeFuture> forkChoiceUpdatedV2( : FORKCHOICE_UPDATED_V2_METHOD); } - @Override - public SafeFuture> exchangeTransitionConfiguration( - final TransitionConfigurationV1 transitionConfiguration) { - return delegate.exchangeTransitionConfiguration(transitionConfiguration); - } - @Override public SafeFuture>> exchangeCapabilities(final List capabilities) { return delegate.exchangeCapabilities(capabilities); diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/TransitionConfigurationV1.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/TransitionConfigurationV1.java deleted file mode 100644 index 5d895274f71..00000000000 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/TransitionConfigurationV1.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright ConsenSys Software Inc., 2022 - * - * 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. - */ - -package tech.pegasys.teku.ethereum.executionclient.schema; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.google.common.base.MoreObjects; -import java.util.Objects; -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.units.bigints.UInt256; -import tech.pegasys.teku.ethereum.executionclient.serialization.Bytes32Deserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.BytesSerializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.UInt256AsHexDeserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.UInt256AsHexSerializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.UInt64AsHexDeserializer; -import tech.pegasys.teku.ethereum.executionclient.serialization.UInt64AsHexSerializer; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; -import tech.pegasys.teku.spec.executionlayer.TransitionConfiguration; - -public class TransitionConfigurationV1 { - @JsonSerialize(using = UInt256AsHexSerializer.class) - @JsonDeserialize(using = UInt256AsHexDeserializer.class) - public final UInt256 terminalTotalDifficulty; - - @JsonSerialize(using = BytesSerializer.class) - @JsonDeserialize(using = Bytes32Deserializer.class) - public final Bytes32 terminalBlockHash; - - @JsonSerialize(using = UInt64AsHexSerializer.class) - @JsonDeserialize(using = UInt64AsHexDeserializer.class) - public final UInt64 terminalBlockNumber; - - @JsonCreator - public TransitionConfigurationV1( - @JsonProperty("terminalTotalDifficulty") UInt256 terminalTotalDifficulty, - @JsonProperty("terminalBlockHash") Bytes32 terminalBlockHash, - @JsonProperty("terminalBlockNumber") UInt64 terminalBlockNumber) { - checkNotNull(terminalTotalDifficulty, "terminalTotalDifficulty is required"); - checkNotNull(terminalBlockHash, "terminalBlockHash is required"); - checkNotNull(terminalBlockNumber, "terminalBlockNumber is required"); - - this.terminalTotalDifficulty = terminalTotalDifficulty; - this.terminalBlockHash = terminalBlockHash; - this.terminalBlockNumber = terminalBlockNumber; - } - - public TransitionConfiguration asInternalTransitionConfiguration() { - return new TransitionConfiguration( - terminalTotalDifficulty, terminalBlockHash, terminalBlockNumber); - } - - public static TransitionConfigurationV1 fromInternalTransitionConfiguration( - TransitionConfiguration transitionConfiguration) { - return new TransitionConfigurationV1( - transitionConfiguration.getTerminalTotalDifficulty(), - transitionConfiguration.getTerminalBlockHash(), - transitionConfiguration.getTerminalBlockNumber()); - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final TransitionConfigurationV1 that = (TransitionConfigurationV1) o; - return Objects.equals(terminalTotalDifficulty, that.terminalTotalDifficulty) - && Objects.equals(terminalBlockHash, that.terminalBlockHash) - && Objects.equals(terminalBlockNumber, that.terminalBlockNumber); - } - - @Override - public int hashCode() { - return Objects.hash(terminalTotalDifficulty, terminalBlockHash, terminalBlockNumber); - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("terminalTotalDifficulty", terminalTotalDifficulty) - .add("terminalBlockHash", terminalBlockHash) - .add("terminalBlockNumber", terminalBlockNumber) - .toString(); - } -} diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/web3j/DefaultExecutionWeb3jClientProvider.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/web3j/DefaultExecutionWeb3jClientProvider.java index 835aa8871b9..c39ddf7471e 100644 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/web3j/DefaultExecutionWeb3jClientProvider.java +++ b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/web3j/DefaultExecutionWeb3jClientProvider.java @@ -50,7 +50,7 @@ private synchronized void buildClient() { if (alreadyBuilt) { return; } - Web3jClientBuilder web3JClientBuilder = new Web3jClientBuilder(); + final Web3jClientBuilder web3JClientBuilder = new Web3jClientBuilder(); this.web3JClient = web3JClientBuilder .endpoint(eeEndpoint) @@ -58,8 +58,7 @@ private synchronized void buildClient() { .jwtConfigOpt(jwtConfig) .timeProvider(timeProvider) .executionClientEventsPublisher(executionClientEventsPublisher) - .nonCriticalMethods( - "engine_exchangeCapabilities", "engine_exchangeTransitionConfigurationV1") + .nonCriticalMethods("engine_exchangeCapabilities") .build(); this.alreadyBuilt = true; } diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/web3j/Web3JExecutionEngineClient.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/web3j/Web3JExecutionEngineClient.java index 35333be3e83..facdb3f3bd2 100644 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/web3j/Web3JExecutionEngineClient.java +++ b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/web3j/Web3JExecutionEngineClient.java @@ -39,7 +39,6 @@ import tech.pegasys.teku.ethereum.executionclient.schema.PayloadAttributesV2; import tech.pegasys.teku.ethereum.executionclient.schema.PayloadStatusV1; import tech.pegasys.teku.ethereum.executionclient.schema.Response; -import tech.pegasys.teku.ethereum.executionclient.schema.TransitionConfigurationV1; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.bytes.Bytes8; import tech.pegasys.teku.infrastructure.unsigned.UInt64; @@ -48,7 +47,6 @@ public class Web3JExecutionEngineClient implements ExecutionEngineClient { - private static final Duration EXCHANGE_TRANSITION_CONFIGURATION_TIMEOUT = Duration.ofSeconds(8); private static final Duration EXCHANGE_CAPABILITIES_TIMEOUT = Duration.ofSeconds(8); private final Web3JClient web3JClient; @@ -182,18 +180,6 @@ public SafeFuture> forkChoiceUpdatedV2( return web3JClient.doRequest(web3jRequest, EL_ENGINE_BLOCK_EXECUTION_TIMEOUT); } - @Override - public SafeFuture> exchangeTransitionConfiguration( - TransitionConfigurationV1 transitionConfiguration) { - Request web3jRequest = - new Request<>( - "engine_exchangeTransitionConfigurationV1", - Collections.singletonList(transitionConfiguration), - web3JClient.getWeb3jService(), - TransitionConfigurationV1Web3jResponse.class); - return web3JClient.doRequest(web3jRequest, EXCHANGE_TRANSITION_CONFIGURATION_TIMEOUT); - } - @Override public SafeFuture>> exchangeCapabilities(final List capabilities) { Request web3jRequest = @@ -220,9 +206,6 @@ static class PayloadStatusV1Web3jResponse static class ForkChoiceUpdatedResultWeb3jResponse extends org.web3j.protocol.core.Response {} - static class TransitionConfigurationV1Web3jResponse - extends org.web3j.protocol.core.Response {} - static class ExchangeCapabilitiesWeb3jResponse extends org.web3j.protocol.core.Response> {} diff --git a/ethereum/executionclient/src/test/java/tech/pegasys/teku/ethereum/executionclient/SchemaSerializationTests.java b/ethereum/executionclient/src/test/java/tech/pegasys/teku/ethereum/executionclient/SchemaSerializationTests.java index 12e2c233f9e..c822114588c 100644 --- a/ethereum/executionclient/src/test/java/tech/pegasys/teku/ethereum/executionclient/SchemaSerializationTests.java +++ b/ethereum/executionclient/src/test/java/tech/pegasys/teku/ethereum/executionclient/SchemaSerializationTests.java @@ -29,7 +29,6 @@ import java.io.StringWriter; import java.io.Writer; import java.util.Optional; -import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.units.bigints.UInt256; import org.junit.jupiter.api.BeforeEach; @@ -39,7 +38,6 @@ import tech.pegasys.teku.ethereum.executionclient.schema.ForkChoiceUpdatedResult; import tech.pegasys.teku.ethereum.executionclient.schema.PayloadAttributesV1; import tech.pegasys.teku.ethereum.executionclient.schema.PayloadStatusV1; -import tech.pegasys.teku.ethereum.executionclient.schema.TransitionConfigurationV1; import tech.pegasys.teku.ethereum.executionclient.serialization.Bytes20Deserializer; import tech.pegasys.teku.ethereum.executionclient.serialization.Bytes20Serializer; import tech.pegasys.teku.ethereum.executionclient.serialization.Bytes32Deserializer; @@ -58,7 +56,6 @@ import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload; import tech.pegasys.teku.spec.executionlayer.ExecutionPayloadStatus; import tech.pegasys.teku.spec.executionlayer.PayloadStatus; -import tech.pegasys.teku.spec.executionlayer.TransitionConfiguration; import tech.pegasys.teku.spec.util.DataStructureUtil; @TestSpecContext(milestone = SpecMilestone.BELLATRIX) @@ -450,83 +447,6 @@ void shouldSerializePayloadAttributes() throws IOException { assertThat(serialized).isNotEmpty(); } - @TestTemplate - void shouldSerializeTransitionConfigurationV1() throws IOException { - final TransitionConfigurationV1 externalTransitionConfiguration = - new TransitionConfigurationV1( - dataStructureUtil.randomUInt256(), - dataStructureUtil.randomBytes32(), - dataStructureUtil.randomUInt64()); - - String serialized = objectMapper.writeValueAsString(externalTransitionConfiguration); - - assertThat(serialized).isNotEmpty(); - } - - @TestTemplate - void shouldDeserializeTransitionConfigurationV1() throws IOException { - final String json = - "{\"terminalTotalDifficulty\": \"0xF123657934589000000000000000001\", " - + "\"terminalBlockHash\": \"0x95b8e2ba063ab62f68ebe7db0a9669ab9e7906aa4e060e1cc0b67b294ce8c5e4\", " - + "\"terminalBlockNumber\": \"0xa79345890\" }"; - - final TransitionConfigurationV1 externalTransitionConfiguration = - objectMapper.readValue(json, TransitionConfigurationV1.class); - - assertThat(externalTransitionConfiguration.terminalTotalDifficulty) - .isEqualTo(UInt256.fromHexString("0xF123657934589000000000000000001")); - assertThat(externalTransitionConfiguration.terminalBlockHash) - .isEqualTo( - Bytes32.fromHexString( - "0x95b8e2ba063ab62f68ebe7db0a9669ab9e7906aa4e060e1cc0b67b294ce8c5e4")); - assertThat(externalTransitionConfiguration.terminalBlockNumber) - .isEqualTo( - UInt64.valueOf(Bytes.fromHexStringLenient("0xa79345890").toUnsignedBigInteger())); - } - - @TestTemplate - void shouldSerializeDeserializeTransitionConfigurationV1() throws IOException { - final TransitionConfigurationV1 externalTransitionConfiguration = - new TransitionConfigurationV1( - dataStructureUtil.randomUInt256(), - dataStructureUtil.randomBytes32(), - dataStructureUtil.randomUInt64()); - - String serialized = objectMapper.writeValueAsString(externalTransitionConfiguration); - - assertThat(serialized).isNotEmpty(); - - TransitionConfigurationV1 externalTransitionConfiguration2 = - objectMapper.readValue(serialized, TransitionConfigurationV1.class); - - assertThat(externalTransitionConfiguration).isEqualTo(externalTransitionConfiguration2); - } - - @TestTemplate - void shouldTransitionConfigurationRoundtrip() { - final TransitionConfigurationV1 externalTransitionConfiguration = - new TransitionConfigurationV1( - dataStructureUtil.randomUInt256(), - dataStructureUtil.randomBytes32(), - dataStructureUtil.randomUInt64()); - - final TransitionConfiguration internalTransitionConfiguration = - externalTransitionConfiguration.asInternalTransitionConfiguration(); - - assertThat(internalTransitionConfiguration.getTerminalBlockHash()) - .isEqualTo(externalTransitionConfiguration.terminalBlockHash); - assertThat(internalTransitionConfiguration.getTerminalBlockNumber()) - .isEqualTo(externalTransitionConfiguration.terminalBlockNumber); - assertThat(internalTransitionConfiguration.getTerminalTotalDifficulty()) - .isEqualTo(externalTransitionConfiguration.terminalTotalDifficulty); - - final TransitionConfigurationV1 externalTransitionConfiguration2 = - TransitionConfigurationV1.fromInternalTransitionConfiguration( - internalTransitionConfiguration); - - assertThat(externalTransitionConfiguration2).isEqualTo(externalTransitionConfiguration); - } - private ForkChoiceUpdatedResult createExternalForkChoiceUpdatedResult( ExecutionPayloadStatus status, Bytes32 latestValidHash, Bytes8 payloadId) { return new ForkChoiceUpdatedResult( diff --git a/ethereum/executionclient/src/test/java/tech/pegasys/teku/ethereum/executionclient/methods/EngineExchangeTransitionConfigurationV1Test.java b/ethereum/executionclient/src/test/java/tech/pegasys/teku/ethereum/executionclient/methods/EngineExchangeTransitionConfigurationV1Test.java deleted file mode 100644 index 3bf98c45135..00000000000 --- a/ethereum/executionclient/src/test/java/tech/pegasys/teku/ethereum/executionclient/methods/EngineExchangeTransitionConfigurationV1Test.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright ConsenSys Software Inc., 2023 - * - * 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. - */ - -package tech.pegasys.teku.ethereum.executionclient.methods; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; - -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import tech.pegasys.teku.ethereum.executionclient.ExecutionEngineClient; -import tech.pegasys.teku.ethereum.executionclient.response.InvalidRemoteResponseException; -import tech.pegasys.teku.ethereum.executionclient.schema.Response; -import tech.pegasys.teku.ethereum.executionclient.schema.TransitionConfigurationV1; -import tech.pegasys.teku.infrastructure.async.SafeFuture; -import tech.pegasys.teku.spec.Spec; -import tech.pegasys.teku.spec.TestSpecFactory; -import tech.pegasys.teku.spec.executionlayer.TransitionConfiguration; -import tech.pegasys.teku.spec.util.DataStructureUtil; - -class EngineExchangeTransitionConfigurationV1Test { - - private final Spec spec = TestSpecFactory.createMinimalBellatrix(); - private final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec); - private final ExecutionEngineClient executionEngineClient = mock(ExecutionEngineClient.class); - private EngineExchangeTransitionConfigurationV1 jsonRpcMethod; - - @BeforeEach - public void setUp() { - jsonRpcMethod = new EngineExchangeTransitionConfigurationV1(executionEngineClient); - } - - @Test - public void shouldReturnExpectedNameAndVersion() { - assertThat(jsonRpcMethod.getName()).isEqualTo("engine_exchangeTransitionConfiguration"); - assertThat(jsonRpcMethod.getVersion()).isEqualTo(1); - assertThat(jsonRpcMethod.getVersionedName()) - .isEqualTo("engine_exchangeTransitionConfigurationV1"); - } - - @Test - public void transitionConfigurationParamIsRequired() { - final JsonRpcRequestParams params = new JsonRpcRequestParams.Builder().build(); - - assertThatThrownBy(() -> jsonRpcMethod.execute(params)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("Missing required parameter at index 0"); - - verifyNoInteractions(executionEngineClient); - } - - @Test - public void shouldReturnFailedExecutionWhenEngineClientRequestFails() { - final TransitionConfiguration consensusTransitionConfiguration = dummyTransitionConfiguration(); - final String errorResponseFromClient = "error!"; - - when(executionEngineClient.exchangeTransitionConfiguration( - TransitionConfigurationV1.fromInternalTransitionConfiguration( - consensusTransitionConfiguration))) - .thenReturn(dummyFailedResponse(errorResponseFromClient)); - - final JsonRpcRequestParams params = - new JsonRpcRequestParams.Builder().add(consensusTransitionConfiguration).build(); - - assertThat(jsonRpcMethod.execute(params)) - .failsWithin(1, TimeUnit.SECONDS) - .withThrowableOfType(ExecutionException.class) - .withRootCauseInstanceOf(InvalidRemoteResponseException.class) - .withMessageContaining( - "Invalid remote response from the execution client: %s", errorResponseFromClient); - } - - @Test - public void shouldCallExchangeTransitionConfigurationV1() { - final TransitionConfiguration consensusTransitionConfiguration = dummyTransitionConfiguration(); - final TransitionConfiguration executionTransitionConfiguration = dummyTransitionConfiguration(); - - when(executionEngineClient.exchangeTransitionConfiguration(any())) - .thenReturn(dummySuccessfulResponse(executionTransitionConfiguration)); - - final JsonRpcRequestParams params = - new JsonRpcRequestParams.Builder().add(consensusTransitionConfiguration).build(); - - assertThat(jsonRpcMethod.execute(params)) - .isCompletedWithValue(executionTransitionConfiguration); - - verify(executionEngineClient) - .exchangeTransitionConfiguration( - TransitionConfigurationV1.fromInternalTransitionConfiguration( - consensusTransitionConfiguration)); - verifyNoMoreInteractions(executionEngineClient); - } - - private TransitionConfiguration dummyTransitionConfiguration() { - return new TransitionConfiguration( - dataStructureUtil.randomUInt256(), - dataStructureUtil.randomBytes32(), - dataStructureUtil.randomUInt64()); - } - - private SafeFuture> dummySuccessfulResponse( - TransitionConfiguration transitionConfiguration) { - return SafeFuture.completedFuture( - new Response<>( - TransitionConfigurationV1.fromInternalTransitionConfiguration( - transitionConfiguration))); - } - - private SafeFuture> dummyFailedResponse( - final String errorMessage) { - return SafeFuture.completedFuture(Response.withErrorMessage(errorMessage)); - } -} diff --git a/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionClientHandler.java b/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionClientHandler.java index 6665b66c35f..333edaf007f 100644 --- a/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionClientHandler.java +++ b/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionClientHandler.java @@ -25,7 +25,6 @@ import tech.pegasys.teku.spec.executionlayer.ForkChoiceUpdatedResult; import tech.pegasys.teku.spec.executionlayer.PayloadBuildingAttributes; import tech.pegasys.teku.spec.executionlayer.PayloadStatus; -import tech.pegasys.teku.spec.executionlayer.TransitionConfiguration; public interface ExecutionClientHandler { @@ -41,7 +40,4 @@ SafeFuture engineGetPayload( ExecutionPayloadContext executionPayloadContext, UInt64 slot); SafeFuture engineNewPayload(NewPayloadRequest newPayloadRequest); - - SafeFuture engineExchangeTransitionConfiguration( - TransitionConfiguration transitionConfiguration); } diff --git a/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionClientHandlerImpl.java b/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionClientHandlerImpl.java index 1a853b02632..0e11857ee6d 100644 --- a/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionClientHandlerImpl.java +++ b/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionClientHandlerImpl.java @@ -28,7 +28,6 @@ import tech.pegasys.teku.spec.executionlayer.ForkChoiceUpdatedResult; import tech.pegasys.teku.spec.executionlayer.PayloadBuildingAttributes; import tech.pegasys.teku.spec.executionlayer.PayloadStatus; -import tech.pegasys.teku.spec.executionlayer.TransitionConfiguration; public class ExecutionClientHandlerImpl implements ExecutionClientHandler { @@ -111,16 +110,4 @@ public SafeFuture engineNewPayload(final NewPayloadRequest newPay PayloadStatus.class) .execute(paramsBuilder.build()); } - - @Override - public SafeFuture engineExchangeTransitionConfiguration( - final TransitionConfiguration transitionConfiguration) { - final JsonRpcRequestParams params = - new JsonRpcRequestParams.Builder().add(transitionConfiguration).build(); - - return methodsResolver - .getMethod( - EngineApiMethod.ENGINE_EXCHANGE_TRANSITION_CONFIGURATION, TransitionConfiguration.class) - .execute(params); - } } diff --git a/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionLayerManagerImpl.java b/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionLayerManagerImpl.java index 92f19c8de49..ad31b9cfcdd 100644 --- a/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionLayerManagerImpl.java +++ b/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionLayerManagerImpl.java @@ -59,7 +59,6 @@ import tech.pegasys.teku.spec.executionlayer.ForkChoiceUpdatedResult; import tech.pegasys.teku.spec.executionlayer.PayloadBuildingAttributes; import tech.pegasys.teku.spec.executionlayer.PayloadStatus; -import tech.pegasys.teku.spec.executionlayer.TransitionConfiguration; public class ExecutionLayerManagerImpl implements ExecutionLayerManager { @@ -228,12 +227,6 @@ public SafeFuture engineNewPayload(final NewPayloadRequest newPay return executionClientHandler.engineNewPayload(newPayloadRequest); } - @Override - public SafeFuture engineExchangeTransitionConfiguration( - final TransitionConfiguration transitionConfiguration) { - return executionClientHandler.engineExchangeTransitionConfiguration(transitionConfiguration); - } - @Override public SafeFuture builderRegisterValidators( final SszList signedValidatorRegistrations, final UInt64 slot) { diff --git a/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/MilestoneBasedExecutionJsonRpcMethodsResolver.java b/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/MilestoneBasedExecutionJsonRpcMethodsResolver.java index 7f55daf5aba..db6da4b1d08 100644 --- a/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/MilestoneBasedExecutionJsonRpcMethodsResolver.java +++ b/ethereum/executionlayer/src/main/java/tech/pegasys/teku/ethereum/executionlayer/MilestoneBasedExecutionJsonRpcMethodsResolver.java @@ -22,7 +22,6 @@ import java.util.function.Supplier; import tech.pegasys.teku.ethereum.executionclient.ExecutionEngineClient; import tech.pegasys.teku.ethereum.executionclient.methods.EngineApiMethod; -import tech.pegasys.teku.ethereum.executionclient.methods.EngineExchangeTransitionConfigurationV1; import tech.pegasys.teku.ethereum.executionclient.methods.EngineForkChoiceUpdatedV1; import tech.pegasys.teku.ethereum.executionclient.methods.EngineForkChoiceUpdatedV2; import tech.pegasys.teku.ethereum.executionclient.methods.EngineGetPayloadV1; @@ -55,7 +54,6 @@ public MilestoneBasedExecutionJsonRpcMethodsResolver( // Non-milestone specific methods nonMilestoneMethods.add(new EthGetBlockByHash(executionEngineClient)); nonMilestoneMethods.add(new EthGetBlockByNumber(executionEngineClient)); - nonMilestoneMethods.add(new EngineExchangeTransitionConfigurationV1(executionEngineClient)); // Milestone specific methods spec.getEnabledMilestones().stream() diff --git a/ethereum/executionlayer/src/test/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionHandlerClientTest.java b/ethereum/executionlayer/src/test/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionHandlerClientTest.java index f045b5c0348..5e4287c01f7 100644 --- a/ethereum/executionlayer/src/test/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionHandlerClientTest.java +++ b/ethereum/executionlayer/src/test/java/tech/pegasys/teku/ethereum/executionlayer/ExecutionHandlerClientTest.java @@ -13,7 +13,6 @@ package tech.pegasys.teku.ethereum.executionlayer; -import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -21,12 +20,9 @@ import org.apache.tuweni.bytes.Bytes32; import org.junit.jupiter.api.Test; import tech.pegasys.teku.ethereum.executionclient.ExecutionEngineClient; -import tech.pegasys.teku.ethereum.executionclient.schema.Response; -import tech.pegasys.teku.ethereum.executionclient.schema.TransitionConfigurationV1; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.spec.Spec; import tech.pegasys.teku.spec.datastructures.execution.PowBlock; -import tech.pegasys.teku.spec.executionlayer.TransitionConfiguration; import tech.pegasys.teku.spec.util.DataStructureUtil; public abstract class ExecutionHandlerClientTest { @@ -35,25 +31,6 @@ public abstract class ExecutionHandlerClientTest { protected DataStructureUtil dataStructureUtil; protected final ExecutionEngineClient executionEngineClient = mock(ExecutionEngineClient.class); - @SuppressWarnings("FutureReturnValueIgnored") - @Test - void engineExchangeTransitionConfiguration_shouldCallExecutionClient() { - ExecutionClientHandler handler = getHandler(); - TransitionConfiguration config = - new TransitionConfiguration( - dataStructureUtil.randomUInt256(), - dataStructureUtil.randomBytes32(), - dataStructureUtil.randomUInt64()); - TransitionConfigurationV1 v1Config = - TransitionConfigurationV1.fromInternalTransitionConfiguration(config); - - when(executionEngineClient.exchangeTransitionConfiguration(v1Config)) - .thenReturn(SafeFuture.completedFuture(new Response<>(v1Config))); - handler.engineExchangeTransitionConfiguration(config); - verify(executionEngineClient) - .exchangeTransitionConfiguration(any(TransitionConfigurationV1.class)); - } - @SuppressWarnings("FutureReturnValueIgnored") @Test void eth1GetPowBlock_shouldCallExecutionClient() { diff --git a/ethereum/executionlayer/src/test/java/tech/pegasys/teku/ethereum/executionlayer/MilestoneBasedExecutionJsonRpcMethodsResolverTest.java b/ethereum/executionlayer/src/test/java/tech/pegasys/teku/ethereum/executionlayer/MilestoneBasedExecutionJsonRpcMethodsResolverTest.java index c469a58d80f..1390bbe1d2b 100644 --- a/ethereum/executionlayer/src/test/java/tech/pegasys/teku/ethereum/executionlayer/MilestoneBasedExecutionJsonRpcMethodsResolverTest.java +++ b/ethereum/executionlayer/src/test/java/tech/pegasys/teku/ethereum/executionlayer/MilestoneBasedExecutionJsonRpcMethodsResolverTest.java @@ -26,7 +26,6 @@ import org.junit.jupiter.params.provider.MethodSource; import tech.pegasys.teku.ethereum.executionclient.ExecutionEngineClient; import tech.pegasys.teku.ethereum.executionclient.methods.EngineApiMethod; -import tech.pegasys.teku.ethereum.executionclient.methods.EngineExchangeTransitionConfigurationV1; import tech.pegasys.teku.ethereum.executionclient.methods.EngineForkChoiceUpdatedV1; import tech.pegasys.teku.ethereum.executionclient.methods.EngineForkChoiceUpdatedV2; import tech.pegasys.teku.ethereum.executionclient.methods.EngineGetPayloadV1; @@ -68,10 +67,7 @@ void shouldProvideExpectedMethodsForNonMilestoneMethods( private static Stream nonMilestoneMethods() { return Stream.of( arguments(EngineApiMethod.ETH_GET_BLOCK_BY_HASH, EthGetBlockByHash.class), - arguments(EngineApiMethod.ETH_GET_BLOCK_BY_NUMBER, EthGetBlockByNumber.class), - arguments( - EngineApiMethod.ENGINE_EXCHANGE_TRANSITION_CONFIGURATION, - EngineExchangeTransitionConfigurationV1.class)); + arguments(EngineApiMethod.ETH_GET_BLOCK_BY_NUMBER, EthGetBlockByNumber.class)); } @ParameterizedTest diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ExecutionLayerChannel.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ExecutionLayerChannel.java index c0ac3cbe9c5..1f78361ded2 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ExecutionLayerChannel.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ExecutionLayerChannel.java @@ -66,12 +66,6 @@ public SafeFuture engineNewPayload( return SafeFuture.completedFuture(PayloadStatus.SYNCING); } - @Override - public SafeFuture engineExchangeTransitionConfiguration( - final TransitionConfiguration transitionConfiguration) { - return SafeFuture.completedFuture(transitionConfiguration); - } - @Override public SafeFuture builderRegisterValidators( final SszList signedValidatorRegistrations, @@ -106,9 +100,6 @@ SafeFuture engineForkChoiceUpdated( SafeFuture engineNewPayload(NewPayloadRequest newPayloadRequest); - SafeFuture engineExchangeTransitionConfiguration( - TransitionConfiguration transitionConfiguration); - /** * This is low level method, use {@link * ExecutionLayerBlockProductionManager#initiateBlockProduction(ExecutionPayloadContext, diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ExecutionLayerChannelStub.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ExecutionLayerChannelStub.java index 24f57805c05..d43e226f89f 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ExecutionLayerChannelStub.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ExecutionLayerChannelStub.java @@ -34,7 +34,6 @@ import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.bytes.Bytes8; import tech.pegasys.teku.infrastructure.collections.cache.LRUCache; -import tech.pegasys.teku.infrastructure.logging.EventLogger; import tech.pegasys.teku.infrastructure.ssz.SszList; import tech.pegasys.teku.infrastructure.time.SystemTimeProvider; import tech.pegasys.teku.infrastructure.time.TimeProvider; @@ -90,7 +89,6 @@ public class ExecutionLayerChannelStub implements ExecutionLayerChannel { private PowBlock terminalBlock; private boolean terminalBlockSent; private UInt64 transitionTime; - private Optional transitionConfiguration = Optional.empty(); // block, payload and blobs tracking private Optional lastBuilderPayloadToBeUnblinded = Optional.empty(); @@ -296,30 +294,6 @@ public SafeFuture engineNewPayload(final NewPayloadRequest newPay return SafeFuture.completedFuture(returnedStatus); } - @Override - public SafeFuture engineExchangeTransitionConfiguration( - final TransitionConfiguration transitionConfiguration) { - final TransitionConfiguration transitionConfigurationResponse; - - this.transitionConfiguration = Optional.of(transitionConfiguration); - - if (transitionConfiguration.getTerminalBlockHash().isZero()) { - transitionConfigurationResponse = transitionConfiguration; - } else { - transitionConfigurationResponse = - new TransitionConfiguration( - transitionConfiguration.getTerminalTotalDifficulty(), - transitionConfiguration.getTerminalBlockHash(), - UInt64.ONE); - } - EventLogger.EVENT_LOG.executionLayerStubEnabled(); - LOG.info( - "exchangeTransitionConfiguration: {} -> {}", - transitionConfiguration, - transitionConfigurationResponse); - return SafeFuture.completedFuture(transitionConfigurationResponse); - } - @Override public SafeFuture builderRegisterValidators( final SszList signedValidatorRegistrations, final UInt64 slot) { @@ -483,18 +457,9 @@ private void prepareTransitionBlocks(final UInt64 bellatrixActivationTime) { final Bytes32 configTerminalBlockHash; final UInt256 terminalTotalDifficulty; - // let's try to use last received transition configuration, otherwise fallback to spec - // we can't wait for transitionConfiguration because we may receive it too late, - // so we may not be able to respond do transition block validation - if (transitionConfiguration.isPresent()) { - LOG.info("Preparing transition blocks using received transitionConfiguration"); - configTerminalBlockHash = transitionConfiguration.get().getTerminalBlockHash(); - terminalTotalDifficulty = transitionConfiguration.get().getTerminalTotalDifficulty(); - } else { - LOG.info("Preparing transition blocks using spec"); - configTerminalBlockHash = specConfigBellatrix.getTerminalBlockHash(); - terminalTotalDifficulty = specConfigBellatrix.getTerminalTotalDifficulty(); - } + LOG.info("Preparing transition blocks using spec"); + configTerminalBlockHash = specConfigBellatrix.getTerminalBlockHash(); + terminalTotalDifficulty = specConfigBellatrix.getTerminalTotalDifficulty(); if (configTerminalBlockHash.isZero()) { // TTD emulation diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/TransitionConfiguration.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/TransitionConfiguration.java deleted file mode 100644 index c38d8602cfb..00000000000 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/TransitionConfiguration.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright ConsenSys Software Inc., 2022 - * - * 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. - */ - -package tech.pegasys.teku.spec.executionlayer; - -import com.google.common.base.MoreObjects; -import java.util.Objects; -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.units.bigints.UInt256; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; - -public class TransitionConfiguration { - private final UInt256 terminalTotalDifficulty; - private final Bytes32 terminalBlockHash; - private final UInt64 terminalBlockNumber; - - public TransitionConfiguration( - final UInt256 terminalTotalDifficulty, - final Bytes32 terminalBlockHash, - final UInt64 terminalBlockNumber) { - this.terminalTotalDifficulty = terminalTotalDifficulty; - this.terminalBlockHash = terminalBlockHash; - this.terminalBlockNumber = terminalBlockNumber; - } - - public UInt256 getTerminalTotalDifficulty() { - return terminalTotalDifficulty; - } - - public Bytes32 getTerminalBlockHash() { - return terminalBlockHash; - } - - public UInt64 getTerminalBlockNumber() { - return terminalBlockNumber; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final TransitionConfiguration that = (TransitionConfiguration) o; - return Objects.equals(terminalTotalDifficulty, that.terminalTotalDifficulty) - && Objects.equals(terminalBlockHash, that.terminalBlockHash) - && Objects.equals(terminalBlockNumber, that.terminalBlockNumber); - } - - @Override - public int hashCode() { - return Objects.hash(terminalTotalDifficulty, terminalBlockHash, terminalBlockNumber); - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("terminalTotalDifficulty", terminalTotalDifficulty) - .add("terminalBlockHash", terminalBlockHash) - .add("terminalBlockNumber", terminalBlockNumber) - .toString(); - } -} diff --git a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/MergeTransitionConfigCheck.java b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/MergeTransitionConfigCheck.java deleted file mode 100644 index cbc2c57f44f..00000000000 --- a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/MergeTransitionConfigCheck.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright ConsenSys Software Inc., 2022 - * - * 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. - */ - -package tech.pegasys.teku.statetransition.forkchoice; - -import java.time.Duration; -import java.util.Optional; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import tech.pegasys.teku.infrastructure.async.AsyncRunner; -import tech.pegasys.teku.infrastructure.async.Cancellable; -import tech.pegasys.teku.infrastructure.async.SafeFuture; -import tech.pegasys.teku.infrastructure.logging.EventLogger; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; -import tech.pegasys.teku.service.serviceutils.Service; -import tech.pegasys.teku.spec.Spec; -import tech.pegasys.teku.spec.SpecMilestone; -import tech.pegasys.teku.spec.SpecVersion; -import tech.pegasys.teku.spec.config.SpecConfigBellatrix; -import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; -import tech.pegasys.teku.spec.executionlayer.TransitionConfiguration; - -public class MergeTransitionConfigCheck extends Service { - - /** - * From the execution engine spec: - * - *
- * - * Consensus Layer client software SHOULD poll this endpoint every 60 seconds - * - *
- */ - private static final Duration POLLING_PERIOD = Duration.ofSeconds(60); - - private static final Logger LOG = LogManager.getLogger(); - - private final EventLogger eventLogger; - private final Spec spec; - private final ExecutionLayerChannel executionLayer; - private final AsyncRunner asyncRunner; - - private Optional timer = Optional.empty(); - private TransitionConfiguration localTransitionConfiguration; - - public MergeTransitionConfigCheck( - final EventLogger eventLogger, - final Spec spec, - final ExecutionLayerChannel executionLayer, - final AsyncRunner asyncRunner) { - this.eventLogger = eventLogger; - this.spec = spec; - this.executionLayer = executionLayer; - this.asyncRunner = asyncRunner; - } - - @Override - protected synchronized SafeFuture doStart() { - final SpecVersion bellatrixMilestone = spec.forMilestone(SpecMilestone.BELLATRIX); - if (bellatrixMilestone == null) { - LOG.debug("Bellatrix is not scheduled. Not checking transition configuration."); - return SafeFuture.COMPLETE; - } - final SpecConfigBellatrix specConfigBellatrix = - bellatrixMilestone.getConfig().toVersionBellatrix().orElseThrow(); - - localTransitionConfiguration = - new TransitionConfiguration( - specConfigBellatrix.getTerminalTotalDifficulty(), - specConfigBellatrix.getTerminalBlockHash(), - UInt64.ZERO); - - timer = - Optional.of( - asyncRunner.runWithFixedDelay( - this::verifyTransitionConfiguration, - POLLING_PERIOD, - (error) -> LOG.error("An error occurred while executing the monitor task", error))); - return SafeFuture.COMPLETE; - } - - @Override - protected synchronized SafeFuture doStop() { - timer.ifPresent(Cancellable::cancel); - timer = Optional.empty(); - return SafeFuture.COMPLETE; - } - - private synchronized void verifyTransitionConfiguration() { - executionLayer - .engineExchangeTransitionConfiguration(localTransitionConfiguration) - .thenAccept( - remoteTransitionConfiguration -> { - if (!localTransitionConfiguration - .getTerminalTotalDifficulty() - .equals(remoteTransitionConfiguration.getTerminalTotalDifficulty()) - || !localTransitionConfiguration - .getTerminalBlockHash() - .equals(remoteTransitionConfiguration.getTerminalBlockHash())) { - - eventLogger.transitionConfigurationTtdTbhMismatch( - localTransitionConfiguration.toString(), - remoteTransitionConfiguration.toString()); - } else if (remoteTransitionConfiguration.getTerminalBlockHash().isZero() - && !remoteTransitionConfiguration.getTerminalBlockNumber().isZero()) { - - eventLogger.transitionConfigurationRemoteTbhTbnInconsistency( - remoteTransitionConfiguration.toString()); - } - }) - .finish( - error -> - LOG.error( - "An error occurred while querying remote transition configuration", error)); - } -} diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/MergeTransitionConfigCheckTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/MergeTransitionConfigCheckTest.java deleted file mode 100644 index b0446ed2e9c..00000000000 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/MergeTransitionConfigCheckTest.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright ConsenSys Software Inc., 2022 - * - * 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. - */ - -package tech.pegasys.teku.statetransition.forkchoice; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; - -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.units.bigints.UInt256; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; -import tech.pegasys.teku.infrastructure.async.SafeFuture; -import tech.pegasys.teku.infrastructure.async.StubAsyncRunner; -import tech.pegasys.teku.infrastructure.logging.EventLogger; -import tech.pegasys.teku.infrastructure.time.StubTimeProvider; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; -import tech.pegasys.teku.spec.Spec; -import tech.pegasys.teku.spec.TestSpecFactory; -import tech.pegasys.teku.spec.config.SpecConfigLoader; -import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; -import tech.pegasys.teku.spec.executionlayer.TransitionConfiguration; -import tech.pegasys.teku.spec.util.DataStructureUtil; - -class MergeTransitionConfigCheckTest { - - private static final UInt64 BELLATRIX_FORK_EPOCH = UInt64.ONE; - private static final Bytes32 TERMINAL_BLOCK_HASH = Bytes32.random(); - private static final UInt64 TERMINAL_BLOCK_EPOCH = UInt64.valueOf(2); - - private final ExecutionLayerChannel executionLayer = mock(ExecutionLayerChannel.class); - private final StubTimeProvider timeProvider = StubTimeProvider.withTimeInSeconds(10_000); - private final StubAsyncRunner asyncRunner = new StubAsyncRunner(timeProvider); - private final EventLogger eventLogger = Mockito.mock(EventLogger.class); - - private Spec spec; - - private final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec); - private TransitionConfiguration localTransitionConfiguration; - private TransitionConfiguration remoteTransitionConfiguration; - private MergeTransitionConfigCheck mergeTransitionConfigCheck; - - private final UInt256 wrongRemoteTTD = dataStructureUtil.randomUInt256(); - private final Bytes32 wrongRemoteTBH = dataStructureUtil.randomBytes32(); - - @BeforeEach - void setUp() { - this.spec = - TestSpecFactory.createBellatrix( - SpecConfigLoader.loadConfig( - "minimal", - phase0Builder -> - phase0Builder - .altairBuilder(altairBuilder -> altairBuilder.altairForkEpoch(UInt64.ZERO)) - .bellatrixBuilder( - bellatrixBuilder -> - bellatrixBuilder - .bellatrixForkEpoch(BELLATRIX_FORK_EPOCH) - .terminalBlockHash(TERMINAL_BLOCK_HASH) - .terminalBlockHashActivationEpoch(TERMINAL_BLOCK_EPOCH)))); - this.localTransitionConfiguration = - new TransitionConfiguration( - spec.getGenesisSpecConfig() - .toVersionBellatrix() - .orElseThrow() - .getTerminalTotalDifficulty(), - spec.getGenesisSpecConfig().toVersionBellatrix().orElseThrow().getTerminalBlockHash(), - UInt64.ZERO); - this.mergeTransitionConfigCheck = - new MergeTransitionConfigCheck(eventLogger, spec, executionLayer, asyncRunner); - setRemoteTransitionConfiguration( - new TransitionConfiguration( - localTransitionConfiguration.getTerminalTotalDifficulty(), - localTransitionConfiguration.getTerminalBlockHash(), - dataStructureUtil.randomUInt64())); - - assertThat(mergeTransitionConfigCheck.start()).isCompleted(); - } - - @Test - void shouldReportInconsistencyReportedByRemote() { - spec = - TestSpecFactory.createBellatrix( - SpecConfigLoader.loadConfig( - "minimal", - phase0Builder -> - phase0Builder - .altairBuilder(altairBuilder -> altairBuilder.altairForkEpoch(UInt64.ZERO)) - .bellatrixBuilder( - bellatrixBuilder -> - bellatrixBuilder - .bellatrixForkEpoch(UInt64.ZERO) - .terminalBlockHash(Bytes32.ZERO) - .terminalBlockHashActivationEpoch(UInt64.ZERO)))); - this.localTransitionConfiguration = - new TransitionConfiguration( - localTransitionConfiguration.getTerminalTotalDifficulty(), Bytes32.ZERO, UInt64.ZERO); - mergeTransitionConfigCheck = - new MergeTransitionConfigCheck(eventLogger, spec, executionLayer, asyncRunner); - setRemoteTransitionConfiguration( - new TransitionConfiguration( - localTransitionConfiguration.getTerminalTotalDifficulty(), Bytes32.ZERO, UInt64.ONE)); - assertThat(mergeTransitionConfigCheck.start()).isCompleted(); - asyncRunner.executeQueuedActions(); - - verify(eventLogger) - .transitionConfigurationRemoteTbhTbnInconsistency(remoteTransitionConfiguration.toString()); - verifyNoMoreInteractions(eventLogger); - } - - @Test - void shouldReportWrongTotalTerminalDifficulty() { - setRemoteTransitionConfiguration( - new TransitionConfiguration( - wrongRemoteTTD, localTransitionConfiguration.getTerminalBlockHash(), UInt64.ZERO)); - - asyncRunner.executeQueuedActions(); - - verify(eventLogger) - .transitionConfigurationTtdTbhMismatch( - localTransitionConfiguration.toString(), remoteTransitionConfiguration.toString()); - } - - @Test - void shouldDetectWrongTerminalBlockHash() { - setRemoteTransitionConfiguration( - new TransitionConfiguration( - localTransitionConfiguration.getTerminalTotalDifficulty(), - wrongRemoteTBH, - UInt64.ZERO)); - - asyncRunner.executeQueuedActions(); - - verify(eventLogger) - .transitionConfigurationTtdTbhMismatch( - localTransitionConfiguration.toString(), remoteTransitionConfiguration.toString()); - } - - @Test - void shouldPassWithEqualConfiguration() { - setRemoteTransitionConfiguration( - new TransitionConfiguration( - localTransitionConfiguration.getTerminalTotalDifficulty(), - localTransitionConfiguration.getTerminalBlockHash(), - localTransitionConfiguration.getTerminalBlockNumber())); - - asyncRunner.executeQueuedActions(); - verifyNoMoreInteractions(eventLogger); - } - - private void setRemoteTransitionConfiguration( - final TransitionConfiguration transitionConfiguration) { - this.remoteTransitionConfiguration = transitionConfiguration; - when(executionLayer.engineExchangeTransitionConfiguration(localTransitionConfiguration)) - .thenReturn(SafeFuture.completedFuture(remoteTransitionConfiguration)); - } -} diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/TerminalPowBlockMonitorTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/TerminalPowBlockMonitorTest.java index 8a667b195aa..50c37061776 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/TerminalPowBlockMonitorTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/TerminalPowBlockMonitorTest.java @@ -36,7 +36,6 @@ import org.mockito.Mockito; import tech.pegasys.infrastructure.logging.LogCaptor; import tech.pegasys.teku.bls.BLSSignatureVerifier; -import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.async.StubAsyncRunner; import tech.pegasys.teku.infrastructure.logging.EventLogger; import tech.pegasys.teku.infrastructure.time.StubTimeProvider; @@ -48,7 +47,6 @@ import tech.pegasys.teku.spec.datastructures.blocks.SignedBlockAndState; import tech.pegasys.teku.spec.datastructures.execution.PowBlock; import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel; -import tech.pegasys.teku.spec.executionlayer.TransitionConfiguration; import tech.pegasys.teku.spec.generator.ChainBuilder; import tech.pegasys.teku.spec.logic.common.block.AbstractBlockProcessor; import tech.pegasys.teku.spec.util.DataStructureUtil; @@ -74,7 +72,6 @@ public class TerminalPowBlockMonitorTest { private StorageSystem storageSystem; private RecentChainData recentChainData; private TerminalPowBlockMonitor terminalPowBlockMonitor; - private TransitionConfiguration localTransitionConfiguration; @BeforeAll public static void initSession() { @@ -94,23 +91,12 @@ private void setUpTerminalBlockHashConfig() { .bellatrixForkEpoch(BELLATRIX_FORK_EPOCH) .terminalBlockHash(TERMINAL_BLOCK_HASH) .terminalBlockHashActivationEpoch(TERMINAL_BLOCK_EPOCH)); - - when(executionLayer.engineExchangeTransitionConfiguration(localTransitionConfiguration)) - .thenReturn( - SafeFuture.completedFuture( - new TransitionConfiguration( - localTransitionConfiguration.getTerminalTotalDifficulty(), - localTransitionConfiguration.getTerminalBlockHash(), - dataStructureUtil.randomUInt64()))); } private void setUpTTDConfig() { setUpCommon( bellatrixBuilder -> bellatrixBuilder.bellatrixForkEpoch(BELLATRIX_FORK_EPOCH).terminalTotalDifficulty(TTD)); - - when(executionLayer.engineExchangeTransitionConfiguration(localTransitionConfiguration)) - .thenReturn(SafeFuture.completedFuture(localTransitionConfiguration)); } private void setUpCommon(Consumer bellatrixBuilder) { @@ -127,15 +113,6 @@ private void setUpCommon(Consumer bellatrixBuilder) { storageSystem.chainUpdater().initializeGenesis(false); recentChainData = storageSystem.recentChainData(); - localTransitionConfiguration = - new TransitionConfiguration( - spec.getGenesisSpecConfig() - .toVersionBellatrix() - .orElseThrow() - .getTerminalTotalDifficulty(), - spec.getGenesisSpecConfig().toVersionBellatrix().orElseThrow().getTerminalBlockHash(), - UInt64.ZERO); - terminalPowBlockMonitor = new TerminalPowBlockMonitor( executionLayer, diff --git a/infrastructure/logging/src/main/java/tech/pegasys/teku/infrastructure/logging/EventLogger.java b/infrastructure/logging/src/main/java/tech/pegasys/teku/infrastructure/logging/EventLogger.java index 3332d077699..5c13b11651f 100644 --- a/infrastructure/logging/src/main/java/tech/pegasys/teku/infrastructure/logging/EventLogger.java +++ b/infrastructure/logging/src/main/java/tech/pegasys/teku/infrastructure/logging/EventLogger.java @@ -247,26 +247,6 @@ public void terminalPowBlockTtdEta(final UInt256 ttd, final Duration eta, final log.info(String.format("TTD ETA: %s - Current Total Difficulty: %s", etaString, ttd)); } - public void transitionConfigurationTtdTbhMismatch( - final String localConfig, final String remoteConfig) { - final String configurationErrorEventLog = - String.format( - "Merge *** Transition Configuration error: local TerminalTotalDifficulty and TerminalBlockHash not matching remote Execution Client values\n" - + " local configuration: %s\n" - + " remote configuration: %s", - localConfig, remoteConfig); - error(configurationErrorEventLog, Color.RED); - } - - public void transitionConfigurationRemoteTbhTbnInconsistency(final String remoteConfig) { - final String configurationErrorEventLog = - String.format( - "Merge *** Transition Configuration error: remote Execution Client TerminalBlockHash and TerminalBlockNumber are inconsistent\n" - + " remote configuration: %s", - remoteConfig); - warn(configurationErrorEventLog, Color.YELLOW); - } - public void lateBlockImport( final Bytes32 root, final UInt64 slot, final UInt64 proposer, final String timings) { String slowBlockLog = diff --git a/services/beaconchain/src/main/java/tech/pegasys/teku/services/beaconchain/BeaconChainController.java b/services/beaconchain/src/main/java/tech/pegasys/teku/services/beaconchain/BeaconChainController.java index fa37bd48a15..aeb28678f04 100644 --- a/services/beaconchain/src/main/java/tech/pegasys/teku/services/beaconchain/BeaconChainController.java +++ b/services/beaconchain/src/main/java/tech/pegasys/teku/services/beaconchain/BeaconChainController.java @@ -125,7 +125,6 @@ import tech.pegasys.teku.statetransition.forkchoice.ForkChoiceStateProvider; import tech.pegasys.teku.statetransition.forkchoice.ForkChoiceTrigger; import tech.pegasys.teku.statetransition.forkchoice.MergeTransitionBlockValidator; -import tech.pegasys.teku.statetransition.forkchoice.MergeTransitionConfigCheck; import tech.pegasys.teku.statetransition.forkchoice.ProposersDataManager; import tech.pegasys.teku.statetransition.forkchoice.TerminalPowBlockMonitor; import tech.pegasys.teku.statetransition.forkchoice.TickProcessingPerformance; @@ -253,8 +252,6 @@ public class BeaconChainController extends Service implements BeaconChainControl protected volatile GossipValidationHelper gossipValidationHelper; protected volatile BlobSidecarManager blobSidecarManager; protected volatile Optional terminalPowBlockMonitor = Optional.empty(); - protected volatile Optional mergeTransitionConfigCheck = - Optional.empty(); protected volatile Optional dataUnavailableBlockPool = Optional.empty(); protected volatile ProposersDataManager proposersDataManager; protected volatile KeyValueStore keyValueStore; @@ -329,10 +326,7 @@ protected void startServices() { blockManager.start(), syncService.start(), SafeFuture.fromRunnable( - () -> terminalPowBlockMonitor.ifPresent(TerminalPowBlockMonitor::start)), - mergeTransitionConfigCheck - .map(MergeTransitionConfigCheck::start) - .orElse(SafeFuture.completedFuture(null))) + () -> terminalPowBlockMonitor.ifPresent(TerminalPowBlockMonitor::start))) .finish( error -> { Throwable rootCause = Throwables.getRootCause(error); @@ -360,10 +354,7 @@ protected SafeFuture doStop() { p2pNetwork.stop(), timerService.stop(), SafeFuture.fromRunnable( - () -> terminalPowBlockMonitor.ifPresent(TerminalPowBlockMonitor::stop)), - mergeTransitionConfigCheck - .map(MergeTransitionConfigCheck::stop) - .orElse(SafeFuture.completedFuture(null))) + () -> terminalPowBlockMonitor.ifPresent(TerminalPowBlockMonitor::stop))) .thenRun(forkChoiceExecutor::stop); } @@ -500,10 +491,6 @@ protected void initMergeMonitors() { beaconAsyncRunner, EVENT_LOG, timeProvider)); - - mergeTransitionConfigCheck = - Optional.of( - new MergeTransitionConfigCheck(EVENT_LOG, spec, executionLayer, beaconAsyncRunner)); } }