diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeTransitionConfiguration.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeTransitionConfiguration.java index f42efd4d70..e4db64e522 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeTransitionConfiguration.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeTransitionConfiguration.java @@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine; import static org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod.ENGINE_EXCHANGE_TRANSITION_CONFIGURATION; import static org.hyperledger.besu.util.Slf4jLambdaHelper.traceLambda; +import org.hyperledger.besu.consensus.merge.MergeContext; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; @@ -82,7 +83,7 @@ public class EngineExchangeTransitionConfiguration extends ExecutionEngineJsonRp () -> Json.encodePrettily(remoteTransitionConfiguration)); final Optional maybeTerminalPoWBlockHeader = - mergeContextOptional.get().getTerminalPoWBlock(); + mergeContextOptional.flatMap(MergeContext::getTerminalPoWBlock); final EngineExchangeTransitionConfigurationResult localTransitionConfiguration = new EngineExchangeTransitionConfigurationResult( diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeTransitionConfigurationTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeTransitionConfigurationTest.java index 88a5dc211b..bc60a44d2b 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeTransitionConfigurationTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineExchangeTransitionConfigurationTest.java @@ -118,7 +118,7 @@ public class EngineExchangeTransitionConfigurationTest { @Test public void shouldReturnDefaultOnNoTerminalTotalDifficultyConfigured() { - when(mergeContext.getTerminalPoWBlock()).thenReturn(Optional.empty()); + when(protocolContext.safeConsensusContext(Mockito.any())).thenReturn(Optional.empty()); var response = resp(