From 5c0fad7b9e6d31ca0ed607f93e3440e4c9f79a2c Mon Sep 17 00:00:00 2001 From: Gabriel Fukushima Date: Tue, 13 Aug 2024 18:33:53 +1000 Subject: [PATCH 01/19] remove experimental flag and useBlindedBlock Signed-off-by: Gabriel Fukushima --- .../validator/coordinator/BlockFactory.java | 1 - .../coordinator/BlockFactoryDeneb.java | 2 - .../coordinator/BlockFactoryPhase0.java | 2 - .../BlockOperationSelectorFactory.java | 13 ++--- .../MilestoneBasedBlockFactory.java | 2 - .../coordinator/ValidatorApiHandler.java | 4 -- .../coordinator/AbstractBlockFactoryTest.java | 1 - .../BlockOperationSelectorFactoryTest.java | 16 +------ .../coordinator/ValidatorApiHandlerTest.java | 9 +--- .../v3/GetNewBlockV3IntegrationTest.java | 14 +++--- .../teku/api/ValidatorDataProvider.java | 15 +----- .../teku/cli/options/ValidatorOptions.java | 11 ----- .../validator/api/ValidatorApiChannel.java | 6 --- .../teku/validator/api/ValidatorConfig.java | 15 ------ .../MetricRecordingValidatorApiChannel.java | 3 +- .../client/ValidatorClientService.java | 8 +--- .../client/duties/BlockDutyFactory.java | 8 ---- .../client/duties/BlockProductionDuty.java | 19 +------- .../duties/BlockProductionDutyTest.java | 48 ++++--------------- .../OkHttpValidatorTypeDefClientTest.java | 4 +- .../remote/FailoverValidatorApiHandler.java | 3 +- .../remote/RemoteValidatorApiHandler.java | 8 ---- .../remote/apiclient/ValidatorApiMethod.java | 2 - .../sentry/SentryValidatorApiChannel.java | 3 +- .../typedef/OkHttpValidatorTypeDefClient.java | 26 +--------- .../typedef/handlers/CreateBlockRequest.java | 10 ++-- .../remote/RemoteValidatorApiHandlerTest.java | 10 ++-- 27 files changed, 40 insertions(+), 223 deletions(-) diff --git a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockFactory.java b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockFactory.java index 766ce6051b9..ae0fa28b71f 100644 --- a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockFactory.java +++ b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockFactory.java @@ -34,7 +34,6 @@ SafeFuture createUnsignedBlock( UInt64 proposalSlot, BLSSignature randaoReveal, Optional optionalGraffiti, - Optional requestedBlinded, Optional requestedBuilderBoostFactor, BlockProductionPerformance blockProductionPerformance); diff --git a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockFactoryDeneb.java b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockFactoryDeneb.java index ee35b270828..b0490b677a2 100644 --- a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockFactoryDeneb.java +++ b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockFactoryDeneb.java @@ -44,7 +44,6 @@ public SafeFuture createUnsignedBlock( final UInt64 proposalSlot, final BLSSignature randaoReveal, final Optional optionalGraffiti, - final Optional requestedBlinded, final Optional requestedBuilderBoostFactor, final BlockProductionPerformance blockProductionPerformance) { return super.createUnsignedBlock( @@ -52,7 +51,6 @@ public SafeFuture createUnsignedBlock( proposalSlot, randaoReveal, optionalGraffiti, - requestedBlinded, requestedBuilderBoostFactor, blockProductionPerformance) .thenCompose( diff --git a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockFactoryPhase0.java b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockFactoryPhase0.java index cc05e2885fa..7b9a90d2044 100644 --- a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockFactoryPhase0.java +++ b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockFactoryPhase0.java @@ -52,7 +52,6 @@ public SafeFuture createUnsignedBlock( final UInt64 proposalSlot, final BLSSignature randaoReveal, final Optional optionalGraffiti, - final Optional requestedBlinded, final Optional requestedBuilderBoostFactor, final BlockProductionPerformance blockProductionPerformance) { checkArgument( @@ -76,7 +75,6 @@ public SafeFuture createUnsignedBlock( blockSlotState, randaoReveal, optionalGraffiti, - requestedBlinded, requestedBuilderBoostFactor, blockProductionPerformance), blockProductionPerformance) diff --git a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java index fdb577f54c4..b77fb881262 100644 --- a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java +++ b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java @@ -115,7 +115,6 @@ public Function> createSelector( final BeaconState blockSlotState, final BLSSignature randaoReveal, final Optional optionalGraffiti, - final Optional requestedBlinded, final Optional requestedBuilderBoostFactor, final BlockProductionPerformance blockProductionPerformance) { @@ -190,7 +189,6 @@ public Function> createSelector( setExecutionData( executionPayloadContext, bodyBuilder, - requestedBlinded, requestedBuilderBoostFactor, SchemaDefinitionsBellatrix.required(schemaDefinitions), blockSlotState, @@ -208,7 +206,6 @@ public Function> createSelector( private SafeFuture setExecutionData( final Optional executionPayloadContext, final BeaconBlockBodyBuilder bodyBuilder, - final Optional requestedBlinded, final Optional requestedBuilderBoostFactor, final SchemaDefinitionsBellatrix schemaDefinitions, final BeaconState blockSlotState, @@ -224,11 +221,9 @@ private SafeFuture setExecutionData( // if requestedBlinded has been specified, we strictly follow it, otherwise we should run // Builder flow (blinded) only if we have a validator registration final boolean shouldTryBuilderFlow = - requestedBlinded.orElseGet( - () -> executionPayloadContext .map(ExecutionPayloadContext::isValidatorRegistrationPresent) - .orElse(false)); + .orElse(false); // pre-Merge Execution Payload / Execution Payload Header if (executionPayloadContext.isEmpty()) { @@ -252,7 +247,7 @@ private SafeFuture setExecutionData( return SafeFuture.allOf( cacheExecutionPayloadValue(executionPayloadResult, blockSlotState), setPayloadOrPayloadHeader( - bodyBuilder, schemaDefinitions, requestedBlinded, executionPayloadResult), + bodyBuilder, schemaDefinitions, executionPayloadResult), setKzgCommitments(bodyBuilder, schemaDefinitions, executionPayloadResult)); } @@ -269,7 +264,6 @@ private SafeFuture cacheExecutionPayloadValue( private SafeFuture setPayloadOrPayloadHeader( final BeaconBlockBodyBuilder bodyBuilder, final SchemaDefinitionsBellatrix schemaDefinitions, - final Optional requestedBlinded, final ExecutionPayloadResult executionPayloadResult) { if (executionPayloadResult.isFromLocalFlow()) { @@ -287,8 +281,7 @@ private SafeFuture setPayloadOrPayloadHeader( builderBidOrFallbackData -> { // we should try to return unblinded content only if no explicit "blindness" has been // requested and builder flow fallbacks to local - if (requestedBlinded.isEmpty() - && builderBidOrFallbackData.getFallbackData().isPresent()) { + if (builderBidOrFallbackData.getFallbackData().isPresent()) { bodyBuilder.executionPayload( builderBidOrFallbackData.getFallbackDataRequired().getExecutionPayload()); } else { diff --git a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/MilestoneBasedBlockFactory.java b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/MilestoneBasedBlockFactory.java index 7b2effbbd8e..b8d0f2ae5ed 100644 --- a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/MilestoneBasedBlockFactory.java +++ b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/MilestoneBasedBlockFactory.java @@ -67,7 +67,6 @@ public SafeFuture createUnsignedBlock( final UInt64 proposalSlot, final BLSSignature randaoReveal, final Optional optionalGraffiti, - final Optional requestedBlinded, final Optional requestedBuilderBoostFactor, final BlockProductionPerformance blockProductionPerformance) { final SpecMilestone milestone = getMilestone(proposalSlot); @@ -78,7 +77,6 @@ public SafeFuture createUnsignedBlock( proposalSlot, randaoReveal, optionalGraffiti, - requestedBlinded, requestedBuilderBoostFactor, blockProductionPerformance); } diff --git a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandler.java b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandler.java index fa0397db5f7..7bab3e36513 100644 --- a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandler.java +++ b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandler.java @@ -335,7 +335,6 @@ public SafeFuture> createUnsignedBlock( final UInt64 slot, final BLSSignature randaoReveal, final Optional graffiti, - final Optional requestedBlinded, final Optional requestedBuilderBoostFactor) { LOG.info("Creating unsigned block for slot {}", slot); performanceTracker.reportBlockProductionAttempt(spec.computeEpochAtSlot(slot)); @@ -357,7 +356,6 @@ public SafeFuture> createUnsignedBlock( slot, randaoReveal, graffiti, - requestedBlinded, requestedBuilderBoostFactor, blockSlotState, blockProductionPerformance)) @@ -368,7 +366,6 @@ private SafeFuture> createBlock( final UInt64 slot, final BLSSignature randaoReveal, final Optional graffiti, - final Optional requestedBlinded, final Optional requestedBuilderBoostFactor, final Optional maybeBlockSlotState, final BlockProductionPerformance blockProductionPerformance) { @@ -390,7 +387,6 @@ private SafeFuture> createBlock( slot, randaoReveal, graffiti, - requestedBlinded, requestedBuilderBoostFactor, blockProductionPerformance) .thenApply( diff --git a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/AbstractBlockFactoryTest.java b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/AbstractBlockFactoryTest.java index e2d7f42cde1..5de4055b6ce 100644 --- a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/AbstractBlockFactoryTest.java +++ b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/AbstractBlockFactoryTest.java @@ -237,7 +237,6 @@ protected BlockContainerAndMetaData assertBlockCreated( newSlot, randaoReveal, Optional.empty(), - Optional.of(blinded), Optional.empty(), BlockProductionPerformance.NOOP)); diff --git a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactoryTest.java b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactoryTest.java index 548d254130b..eebc6a32a3a 100644 --- a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactoryTest.java +++ b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactoryTest.java @@ -256,7 +256,6 @@ void shouldNotSelectOperationsWhenNoneAreAvailable() { dataStructureUtil.randomSignature(), Optional.empty(), Optional.empty(), - Optional.empty(), BlockProductionPerformance.NOOP) .apply(bodyBuilder)); @@ -303,7 +302,6 @@ void shouldIncludeValidOperations() { randaoReveal, Optional.of(defaultGraffiti), Optional.empty(), - Optional.empty(), BlockProductionPerformance.NOOP) .apply(bodyBuilder)); @@ -391,7 +389,6 @@ void shouldNotIncludeInvalidOperations() { randaoReveal, Optional.of(defaultGraffiti), Optional.empty(), - Optional.empty(), BlockProductionPerformance.NOOP) .apply(bodyBuilder)); @@ -422,7 +419,6 @@ void shouldIncludeDefaultExecutionPayload() { blockSlotState, dataStructureUtil.randomSignature(), Optional.empty(), - Optional.of(false), Optional.empty(), BlockProductionPerformance.NOOP) .apply(bodyBuilder)); @@ -443,7 +439,6 @@ void shouldIncludeExecutionPayloadHeaderOfDefaultPayload() { blockSlotState, dataStructureUtil.randomSignature(), Optional.empty(), - Optional.of(true), Optional.empty(), BlockProductionPerformance.NOOP) .apply(bodyBuilder)); @@ -471,7 +466,6 @@ void shouldIncludeNonDefaultExecutionPayload() { blockSlotState, dataStructureUtil.randomSignature(), Optional.empty(), - Optional.of(false), Optional.empty(), BlockProductionPerformance.NOOP) .apply(bodyBuilder)); @@ -503,7 +497,6 @@ void shouldIncludeExecutionPayloadHeaderIfBlindedBlockRequested() { blockSlotState, dataStructureUtil.randomSignature(), Optional.empty(), - Optional.of(true), Optional.empty(), BlockProductionPerformance.NOOP) .apply(bodyBuilder)); @@ -534,7 +527,6 @@ void shouldIncludeExecutionPayloadIfUnblindedBlockRequested() { blockSlotState, dataStructureUtil.randomSignature(), Optional.empty(), - Optional.of(false), Optional.empty(), BlockProductionPerformance.NOOP) .apply(bodyBuilder)); @@ -566,7 +558,6 @@ void shouldIncludeExecutionPayloadIfRequestedBlindedIsEmpty() { dataStructureUtil.randomSignature(), Optional.empty(), Optional.empty(), - Optional.empty(), BlockProductionPerformance.NOOP) .apply(bodyBuilder)); @@ -598,7 +589,6 @@ void shouldIncludeExecutionPayloadIfRequestedBlindedIsEmptyAndBuilderFlowFallsBa dataStructureUtil.randomSignature(), Optional.empty(), Optional.empty(), - Optional.empty(), BlockProductionPerformance.NOOP) .apply(bodyBuilder)); @@ -640,7 +630,6 @@ void shouldIncludeExecutionPayloadIfRequestedBlindedIsEmptyAndBuilderFlowFallsBa dataStructureUtil.randomSignature(), Optional.empty(), Optional.empty(), - Optional.empty(), BlockProductionPerformance.NOOP) .apply(bodyBuilder)); @@ -704,7 +693,6 @@ void shouldIncludeKzgCommitmentsInBlock() { blockSlotState, dataStructureUtil.randomSignature(), Optional.empty(), - Optional.of(false), Optional.empty(), BlockProductionPerformance.NOOP) .apply(bodyBuilder)); @@ -745,8 +733,7 @@ void shouldIncludeKzgCommitmentsInBlindedBlock() { blockSlotState, dataStructureUtil.randomSignature(), Optional.empty(), - Optional.of(true), - Optional.empty(), + Optional.of(UInt64.ONE), BlockProductionPerformance.NOOP) .apply(bodyBuilder)); @@ -979,7 +966,6 @@ void shouldThrowWhenExecutionPayloadContextNotProvided() { blockSlotState, dataStructureUtil.randomSignature(), Optional.empty(), - Optional.of(false), Optional.empty(), BlockProductionPerformance.NOOP) .apply(bodyBuilder)) diff --git a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandlerTest.java b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandlerTest.java index 150a5698d88..7c01945d81b 100644 --- a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandlerTest.java +++ b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandlerTest.java @@ -500,7 +500,6 @@ public void createUnsignedBlock_shouldFailWhenNodeIsSyncing() { ONE, dataStructureUtil.randomSignature(), Optional.empty(), - Optional.of(false), Optional.of(ONE)); assertThat(result).isCompletedExceptionally(); @@ -521,7 +520,6 @@ public void createUnsignedBlock_shouldFailWhenParentBlockIsOptimistic() { newSlot, dataStructureUtil.randomSignature(), Optional.empty(), - Optional.of(false), Optional.of(ONE)); assertThat(result).isCompletedExceptionally(); @@ -544,7 +542,6 @@ public void createUnsignedBlock_shouldCreateBlock() { newSlot, randaoReveal, Optional.empty(), - Optional.of(false), Optional.of(ONE), BlockProductionPerformance.NOOP)) .thenReturn(SafeFuture.completedFuture(blockContainerAndMetaData)); @@ -554,7 +551,7 @@ public void createUnsignedBlock_shouldCreateBlock() { // we still want to check that all parameters are passed down the line to the block factory final SafeFuture> result = validatorApiHandler.createUnsignedBlock( - newSlot, randaoReveal, Optional.empty(), Optional.of(false), Optional.of(ONE)); + newSlot, randaoReveal, Optional.empty(), Optional.of(ONE)); verify(blockFactory) .createUnsignedBlock( @@ -562,7 +559,6 @@ public void createUnsignedBlock_shouldCreateBlock() { newSlot, randaoReveal, Optional.empty(), - Optional.of(false), Optional.of(ONE), BlockProductionPerformance.NOOP); assertThat(result).isCompletedWithValue(Optional.of(blockContainerAndMetaData)); @@ -915,14 +911,13 @@ public void sendSignedBlock_shouldConvertKnownBlockResult() { newSlot, randaoReveal, Optional.empty(), - Optional.of(false), Optional.of(ONE), BlockProductionPerformance.NOOP)) .thenReturn(SafeFuture.completedFuture(blockContainerAndMetaData)); assertThat( validatorApiHandler.createUnsignedBlock( - newSlot, randaoReveal, Optional.empty(), Optional.of(false), Optional.of(ONE))) + newSlot, randaoReveal, Optional.empty(), Optional.of(ONE))) .isCompleted(); final SignedBeaconBlock block = diff --git a/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v3/GetNewBlockV3IntegrationTest.java b/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v3/GetNewBlockV3IntegrationTest.java index 4cb3b9c160c..858218b71b3 100644 --- a/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v3/GetNewBlockV3IntegrationTest.java +++ b/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v3/GetNewBlockV3IntegrationTest.java @@ -77,7 +77,7 @@ void shouldGetUnBlindedBeaconBlockAsJson() throws Exception { final BLSSignature signature = blockContainerAndMetaData.blockContainer().getBlock().getBody().getRandaoReveal(); when(validatorApiChannel.createUnsignedBlock( - eq(UInt64.ONE), eq(signature), any(), any(), any())) + eq(UInt64.ONE), eq(signature), any(), any())) .thenReturn(SafeFuture.completedFuture(Optional.of(blockContainerAndMetaData))); Response response = get(signature, ContentTypes.JSON); assertResponseWithHeaders( @@ -101,7 +101,7 @@ void shouldGetUnblindedBeaconBlockAsSsz() throws IOException { final BLSSignature signature = blockContainerAndMetaData.blockContainer().getBlock().getBody().getRandaoReveal(); when(validatorApiChannel.createUnsignedBlock( - eq(UInt64.ONE), eq(signature), any(), any(), any())) + eq(UInt64.ONE), eq(signature), any(), any())) .thenReturn(SafeFuture.completedFuture(Optional.of(blockContainerAndMetaData))); Response response = get(signature, ContentTypes.OCTET_STREAM); assertResponseWithHeaders( @@ -124,7 +124,7 @@ void shouldGetBlindedBeaconBlockAsJson() throws Exception { final BLSSignature signature = blockContainerAndMetaData.blockContainer().getBlock().getBody().getRandaoReveal(); when(validatorApiChannel.createUnsignedBlock( - eq(UInt64.ONE), eq(signature), any(), any(), any())) + eq(UInt64.ONE), eq(signature), any(), any())) .thenReturn(SafeFuture.completedFuture(Optional.of(blockContainerAndMetaData))); Response response = get(signature, ContentTypes.JSON); assertResponseWithHeaders( @@ -149,7 +149,7 @@ void shouldGetBlindedBeaconBlockAsSsz() throws IOException { final BLSSignature signature = blockContainerAndMetaData.blockContainer().getBlock().getBody().getRandaoReveal(); when(validatorApiChannel.createUnsignedBlock( - eq(UInt64.ONE), eq(signature), any(), any(), any())) + eq(UInt64.ONE), eq(signature), any(), any())) .thenReturn(SafeFuture.completedFuture(Optional.of(blockContainerAndMetaData))); Response response = get(signature, ContentTypes.OCTET_STREAM); assertResponseWithHeaders( @@ -173,7 +173,7 @@ void shouldGetUnBlindedBlockContentPostDenebAsJson() throws Exception { final BLSSignature signature = blockContainerAndMetaData.blockContainer().getBlock().getBody().getRandaoReveal(); when(validatorApiChannel.createUnsignedBlock( - eq(UInt64.ONE), eq(signature), any(), any(), any())) + eq(UInt64.ONE), eq(signature), any(), any())) .thenReturn(SafeFuture.completedFuture(Optional.of(blockContainerAndMetaData))); Response response = get(signature, ContentTypes.JSON); assertResponseWithHeaders( @@ -197,7 +197,7 @@ void shouldGetUnBlindedBlockContentPostDenebAsSsz() throws IOException { dataStructureUtil.randomBlockContainerAndMetaData(blockContents, ONE); final BLSSignature signature = blockContents.getBlock().getBody().getRandaoReveal(); when(validatorApiChannel.createUnsignedBlock( - eq(UInt64.ONE), eq(signature), any(), any(), any())) + eq(UInt64.ONE), eq(signature), any(), any())) .thenReturn(SafeFuture.completedFuture(Optional.of(blockContainerAndMetaData))); Response response = get(signature, ContentTypes.OCTET_STREAM); assertResponseWithHeaders( @@ -218,7 +218,7 @@ void shouldFailWhenNoBlockProduced() throws IOException { final BeaconBlock beaconBlock = dataStructureUtil.randomBeaconBlock(ONE); final BLSSignature signature = beaconBlock.getBlock().getBody().getRandaoReveal(); when(validatorApiChannel.createUnsignedBlock( - eq(UInt64.ONE), eq(signature), any(), any(), any())) + eq(UInt64.ONE), eq(signature), any(), any())) .thenReturn(SafeFuture.completedFuture(Optional.empty())); Response response = get(signature, ContentTypes.JSON); assertThat(response.code()).isEqualTo(SC_INTERNAL_SERVER_ERROR); diff --git a/data/provider/src/main/java/tech/pegasys/teku/api/ValidatorDataProvider.java b/data/provider/src/main/java/tech/pegasys/teku/api/ValidatorDataProvider.java index b5bf6cd529d..b91c92745cc 100644 --- a/data/provider/src/main/java/tech/pegasys/teku/api/ValidatorDataProvider.java +++ b/data/provider/src/main/java/tech/pegasys/teku/api/ValidatorDataProvider.java @@ -97,19 +97,6 @@ public boolean isStoreAvailable() { return combinedChainDataClient.isStoreAvailable(); } - @Deprecated // This method is used within the blockV1 and blockV2 flow. It will be deprecated in - // the future. - public SafeFuture> getUnsignedBeaconBlockAtSlot( - final UInt64 slot, - final BLSSignature randao, - final Optional graffiti, - final boolean isBlinded, - final Optional requestedBuilderBoostFactor) { - checkBlockProducingParameters(slot, randao); - return validatorApiChannel.createUnsignedBlock( - slot, randao, graffiti, Optional.of(isBlinded), requestedBuilderBoostFactor); - } - public SafeFuture> produceBlock( final UInt64 slot, final BLSSignature randao, @@ -117,7 +104,7 @@ public SafeFuture> produceBlock( final Optional requestedBuilderBoostFactor) { checkBlockProducingParameters(slot, randao); return validatorApiChannel.createUnsignedBlock( - slot, randao, graffiti, Optional.empty(), requestedBuilderBoostFactor); + slot, randao, graffiti, requestedBuilderBoostFactor); } private void checkBlockProducingParameters(final UInt64 slot, final BLSSignature randao) { diff --git a/teku/src/main/java/tech/pegasys/teku/cli/options/ValidatorOptions.java b/teku/src/main/java/tech/pegasys/teku/cli/options/ValidatorOptions.java index 3eeb2d07de8..7fa276d1996 100644 --- a/teku/src/main/java/tech/pegasys/teku/cli/options/ValidatorOptions.java +++ b/teku/src/main/java/tech/pegasys/teku/cli/options/ValidatorOptions.java @@ -138,16 +138,6 @@ public class ValidatorOptions { arity = "1") private int executorThreads = DEFAULT_VALIDATOR_EXECUTOR_THREADS; - @Option( - names = {"--Xblock-v3-enabled"}, - paramLabel = "", - description = "Enable the Block V3 API for block production", - hidden = true, - showDefaultValue = CommandLine.Help.Visibility.ALWAYS, - arity = "0..1", - fallbackValue = "true") - private boolean blockV3Enabled = ValidatorConfig.DEFAULT_BLOCK_V3_ENABLED; - @Option( names = {"--exit-when-no-validator-keys-enabled"}, paramLabel = "", @@ -195,7 +185,6 @@ public void configure(final TekuConfiguration.Builder builder) { .generateEarlyAttestations(generateEarlyAttestations) .doppelgangerDetectionEnabled(doppelgangerDetectionEnabled) .executorThreads(executorThreads) - .blockV3enabled(blockV3Enabled) .exitWhenNoValidatorKeysEnabled(exitWhenNoValidatorKeysEnabled) .shutdownWhenValidatorSlashedEnabled(shutdownWhenValidatorSlashed); executorMaxQueueSize.ifPresent(config::executorMaxQueueSize); diff --git a/validator/api/src/main/java/tech/pegasys/teku/validator/api/ValidatorApiChannel.java b/validator/api/src/main/java/tech/pegasys/teku/validator/api/ValidatorApiChannel.java index f403b7ec657..8a4d36f00b2 100644 --- a/validator/api/src/main/java/tech/pegasys/teku/validator/api/ValidatorApiChannel.java +++ b/validator/api/src/main/java/tech/pegasys/teku/validator/api/ValidatorApiChannel.java @@ -96,7 +96,6 @@ public SafeFuture> createUnsignedBlock( UInt64 slot, BLSSignature randaoReveal, Optional graffiti, - Optional requestedBlinded, Optional requestedBuilderBoostFactor) { return SafeFuture.completedFuture(Optional.empty()); } @@ -218,15 +217,10 @@ SafeFuture> getSyncCommitteeDuties( SafeFuture> getPeerCount(); - /** - * @param requestedBlinded can be removed once block creation V2 APIs are removed in favour of V3 - * only - */ SafeFuture> createUnsignedBlock( UInt64 slot, BLSSignature randaoReveal, Optional graffiti, - Optional requestedBlinded, Optional requestedBuilderBoostFactor); SafeFuture> createAttestationData(UInt64 slot, int committeeIndex); diff --git a/validator/api/src/main/java/tech/pegasys/teku/validator/api/ValidatorConfig.java b/validator/api/src/main/java/tech/pegasys/teku/validator/api/ValidatorConfig.java index 1812a899787..b9d149a426b 100644 --- a/validator/api/src/main/java/tech/pegasys/teku/validator/api/ValidatorConfig.java +++ b/validator/api/src/main/java/tech/pegasys/teku/validator/api/ValidatorConfig.java @@ -46,7 +46,6 @@ public class ValidatorConfig { List.of(URI.create("http://127.0.0.1:" + DEFAULT_REST_API_PORT)); public static final boolean DEFAULT_FAILOVERS_SEND_SUBNET_SUBSCRIPTIONS_ENABLED = true; public static final boolean DEFAULT_FAILOVERS_PUBLISH_SIGNED_DUTIES_ENABLED = true; - public static final boolean DEFAULT_BLOCK_V3_ENABLED = true; public static final boolean DEFAULT_EXIT_WHEN_NO_VALIDATOR_KEYS_ENABLED = false; public static final boolean DEFAULT_VALIDATOR_CLIENT_SSZ_BLOCKS_ENABLED = true; public static final boolean DEFAULT_VALIDATOR_CLIENT_USE_POST_VALIDATORS_ENDPOINT_ENABLED = true; @@ -98,7 +97,6 @@ public class ValidatorConfig { private final boolean doppelgangerDetectionEnabled; private final boolean failoversSendSubnetSubscriptionsEnabled; private final boolean failoversPublishSignedDutiesEnabled; - private final boolean blockV3Enabled; private final boolean exitWhenNoValidatorKeysEnabled; private final boolean shutdownWhenValidatorSlashedEnabled; private final UInt64 builderRegistrationDefaultGasLimit; @@ -141,7 +139,6 @@ private ValidatorConfig( final boolean doppelgangerDetectionEnabled, final boolean failoversSendSubnetSubscriptionsEnabled, final boolean failoversPublishSignedDutiesEnabled, - final boolean blockV3Enabled, final boolean exitWhenNoValidatorKeysEnabled, final boolean shutdownWhenValidatorSlashedEnabled, final UInt64 builderRegistrationDefaultGasLimit, @@ -184,7 +181,6 @@ private ValidatorConfig( this.doppelgangerDetectionEnabled = doppelgangerDetectionEnabled; this.failoversSendSubnetSubscriptionsEnabled = failoversSendSubnetSubscriptionsEnabled; this.failoversPublishSignedDutiesEnabled = failoversPublishSignedDutiesEnabled; - this.blockV3Enabled = blockV3Enabled; this.exitWhenNoValidatorKeysEnabled = exitWhenNoValidatorKeysEnabled; this.shutdownWhenValidatorSlashedEnabled = shutdownWhenValidatorSlashedEnabled; this.builderRegistrationDefaultGasLimit = builderRegistrationDefaultGasLimit; @@ -325,10 +321,6 @@ public boolean isFailoversPublishSignedDutiesEnabled() { return failoversPublishSignedDutiesEnabled; } - public boolean isBlockV3Enabled() { - return blockV3Enabled; - } - public boolean isExitWhenNoValidatorKeysEnabled() { return exitWhenNoValidatorKeysEnabled; } @@ -408,7 +400,6 @@ public static final class Builder { DEFAULT_FAILOVERS_SEND_SUBNET_SUBSCRIPTIONS_ENABLED; private boolean failoversPublishSignedDutiesEnabled = DEFAULT_FAILOVERS_PUBLISH_SIGNED_DUTIES_ENABLED; - private boolean blockV3Enabled = DEFAULT_BLOCK_V3_ENABLED; private boolean exitWhenNoValidatorKeysEnabled = DEFAULT_EXIT_WHEN_NO_VALIDATOR_KEYS_ENABLED; private boolean shutdownWhenValidatorSlashedEnabled = DEFAULT_SHUTDOWN_WHEN_VALIDATOR_SLASHED_ENABLED; @@ -609,11 +600,6 @@ public Builder failoversPublishSignedDutiesEnabled( return this; } - public Builder blockV3enabled(final boolean useBlockV3) { - this.blockV3Enabled = useBlockV3; - return this; - } - public Builder exitWhenNoValidatorKeysEnabled(final boolean exitWhenNoValidatorKeysEnabled) { this.exitWhenNoValidatorKeysEnabled = exitWhenNoValidatorKeysEnabled; return this; @@ -715,7 +701,6 @@ public ValidatorConfig build() { doppelgangerDetectionEnabled, failoversSendSubnetSubscriptionsEnabled, failoversPublishSignedDutiesEnabled, - blockV3Enabled, exitWhenNoValidatorKeysEnabled, shutdownWhenValidatorSlashedEnabled, builderRegistrationDefaultGasLimit, diff --git a/validator/beaconnode/src/main/java/tech/pegasys/teku/validator/beaconnode/metrics/MetricRecordingValidatorApiChannel.java b/validator/beaconnode/src/main/java/tech/pegasys/teku/validator/beaconnode/metrics/MetricRecordingValidatorApiChannel.java index 85ccf5ec827..4284d2f8926 100644 --- a/validator/beaconnode/src/main/java/tech/pegasys/teku/validator/beaconnode/metrics/MetricRecordingValidatorApiChannel.java +++ b/validator/beaconnode/src/main/java/tech/pegasys/teku/validator/beaconnode/metrics/MetricRecordingValidatorApiChannel.java @@ -139,11 +139,10 @@ public SafeFuture> createUnsignedBlock( final UInt64 slot, final BLSSignature randaoReveal, final Optional graffiti, - final Optional requestedBlinded, final Optional requestedBuilderBoostFactor) { return countOptionalDataRequest( delegate.createUnsignedBlock( - slot, randaoReveal, graffiti, requestedBlinded, requestedBuilderBoostFactor), + slot, randaoReveal, graffiti, requestedBuilderBoostFactor), BeaconNodeRequestLabels.CREATE_UNSIGNED_BLOCK_METHOD); } diff --git a/validator/client/src/main/java/tech/pegasys/teku/validator/client/ValidatorClientService.java b/validator/client/src/main/java/tech/pegasys/teku/validator/client/ValidatorClientService.java index 2916633f3b1..00fc6cc06fc 100644 --- a/validator/client/src/main/java/tech/pegasys/teku/validator/client/ValidatorClientService.java +++ b/validator/client/src/main/java/tech/pegasys/teku/validator/client/ValidatorClientService.java @@ -458,13 +458,7 @@ private void scheduleValidatorsDuties( final ValidatorDutyMetrics validatorDutyMetrics = ValidatorDutyMetrics.create(metricsSystem); final BlockDutyFactory blockDutyFactory = new BlockDutyFactory( - forkProvider, - validatorApiChannel, - blockContainerSigner, - config.getValidatorConfig().isBlindedBeaconBlocksEnabled(), - config.getValidatorConfig().isBlockV3Enabled(), - spec, - validatorDutyMetrics); + forkProvider, validatorApiChannel, blockContainerSigner, spec, validatorDutyMetrics); final AttestationDutyFactory attestationDutyFactory = new AttestationDutyFactory(spec, forkProvider, validatorApiChannel, validatorDutyMetrics); final BeaconCommitteeSubscriptions beaconCommitteeSubscriptions = diff --git a/validator/client/src/main/java/tech/pegasys/teku/validator/client/duties/BlockDutyFactory.java b/validator/client/src/main/java/tech/pegasys/teku/validator/client/duties/BlockDutyFactory.java index 521a0d6ae4f..d04622e5e08 100644 --- a/validator/client/src/main/java/tech/pegasys/teku/validator/client/duties/BlockDutyFactory.java +++ b/validator/client/src/main/java/tech/pegasys/teku/validator/client/duties/BlockDutyFactory.java @@ -26,23 +26,17 @@ public class BlockDutyFactory implements DutyFactory private final ValidatorApiChannel validatorApiChannel; private final BlockContainerSigner blockContainerSigner; private final Spec spec; - private final boolean useBlindedBlock; - private final boolean blockV3Enabled; private final ValidatorDutyMetrics validatorDutyMetrics; public BlockDutyFactory( final ForkProvider forkProvider, final ValidatorApiChannel validatorApiChannel, final BlockContainerSigner blockContainerSigner, - final boolean useBlindedBlock, - final boolean blockV3Enabled, final Spec spec, final ValidatorDutyMetrics validatorDutyMetrics) { this.forkProvider = forkProvider; this.validatorApiChannel = validatorApiChannel; this.blockContainerSigner = blockContainerSigner; - this.useBlindedBlock = useBlindedBlock; - this.blockV3Enabled = blockV3Enabled; this.spec = spec; this.validatorDutyMetrics = validatorDutyMetrics; } @@ -55,8 +49,6 @@ public BlockProductionDuty createProductionDuty(final UInt64 slot, final Validat forkProvider, validatorApiChannel, blockContainerSigner, - useBlindedBlock, - blockV3Enabled, spec, validatorDutyMetrics); } diff --git a/validator/client/src/main/java/tech/pegasys/teku/validator/client/duties/BlockProductionDuty.java b/validator/client/src/main/java/tech/pegasys/teku/validator/client/duties/BlockProductionDuty.java index 1913eb7f3ab..28492dc1365 100644 --- a/validator/client/src/main/java/tech/pegasys/teku/validator/client/duties/BlockProductionDuty.java +++ b/validator/client/src/main/java/tech/pegasys/teku/validator/client/duties/BlockProductionDuty.java @@ -50,8 +50,6 @@ public class BlockProductionDuty implements Duty { private final ForkProvider forkProvider; private final ValidatorApiChannel validatorApiChannel; private final BlockContainerSigner blockContainerSigner; - private final boolean useBlindedBlock; - private final boolean blockV3Enabled; private final Spec spec; private final ValidatorDutyMetrics validatorDutyMetrics; @@ -61,8 +59,6 @@ public BlockProductionDuty( final ForkProvider forkProvider, final ValidatorApiChannel validatorApiChannel, final BlockContainerSigner blockContainerSigner, - final boolean useBlindedBlock, - final boolean blockV3Enabled, final Spec spec, final ValidatorDutyMetrics validatorDutyMetrics) { this.validator = validator; @@ -70,8 +66,6 @@ public BlockProductionDuty( this.forkProvider = forkProvider; this.validatorApiChannel = validatorApiChannel; this.blockContainerSigner = blockContainerSigner; - this.useBlindedBlock = useBlindedBlock; - this.blockV3Enabled = blockV3Enabled; this.spec = spec; this.validatorDutyMetrics = validatorDutyMetrics; } @@ -113,17 +107,8 @@ private SafeFuture createRandaoReveal(final ForkInfo forkInfo) { private SafeFuture> createUnsignedBlock( final BLSSignature randaoReveal) { - if (blockV3Enabled) { - return validatorApiChannel.createUnsignedBlock( - slot, randaoReveal, validator.getGraffiti(), Optional.empty(), Optional.empty()); - } else { - return validatorApiChannel.createUnsignedBlock( - slot, - randaoReveal, - validator.getGraffiti(), - Optional.of(useBlindedBlock), - Optional.empty()); - } + return validatorApiChannel.createUnsignedBlock( + slot, randaoReveal, validator.getGraffiti(), Optional.empty()); } private SafeFuture validateBlock( diff --git a/validator/client/src/test/java/tech/pegasys/teku/validator/client/duties/BlockProductionDutyTest.java b/validator/client/src/test/java/tech/pegasys/teku/validator/client/duties/BlockProductionDutyTest.java index ea9ab265f4b..0d0560c581e 100644 --- a/validator/client/src/test/java/tech/pegasys/teku/validator/client/duties/BlockProductionDutyTest.java +++ b/validator/client/src/test/java/tech/pegasys/teku/validator/client/duties/BlockProductionDutyTest.java @@ -104,8 +104,6 @@ public void setUp() { forkProvider, validatorApiChannel, blockContainerSigner, - false, - false, spec, validatorDutyMetrics); when(forkProvider.getForkInfo(any())).thenReturn(completedFuture(fork)); @@ -121,8 +119,6 @@ public void shouldCreateAndPublishBlock(final boolean isBlindedBlocksEnabled) { forkProvider, validatorApiChannel, blockContainerSigner, - isBlindedBlocksEnabled, - false, spec, validatorDutyMetrics); final BLSSignature randaoReveal = dataStructureUtil.randomSignature(); @@ -141,11 +137,7 @@ public void shouldCreateAndPublishBlock(final boolean isBlindedBlocksEnabled) { when(signer.createRandaoReveal(spec.computeEpochAtSlot(CAPELLA_SLOT), fork)) .thenReturn(completedFuture(randaoReveal)); when(validatorApiChannel.createUnsignedBlock( - CAPELLA_SLOT, - randaoReveal, - Optional.of(graffiti), - Optional.of(isBlindedBlocksEnabled), - Optional.empty())) + CAPELLA_SLOT, randaoReveal, Optional.of(graffiti), Optional.empty(), Optional.empty())) .thenReturn(completedFuture(Optional.of(blockContainerAndMetaData))); when(signer.signBlock(unsignedBlock, fork)).thenReturn(completedFuture(blockSignature)); final SignedBeaconBlock signedBlock = @@ -182,8 +174,6 @@ public void forDeneb_shouldCreateAndPublishBlockContents() { forkProvider, validatorApiChannel, blockContainerSigner, - false, - false, spec, validatorDutyMetrics); @@ -203,7 +193,7 @@ public void forDeneb_shouldCreateAndPublishBlockContents() { when(signer.signBlock(unsignedBlockContents.getBlock(), fork)) .thenReturn(completedFuture(blockSignature)); when(validatorApiChannel.createUnsignedBlock( - denebSlot, randaoReveal, Optional.of(graffiti), Optional.of(false), Optional.empty())) + denebSlot, randaoReveal, Optional.of(graffiti), Optional.empty(), Optional.empty())) .thenReturn(completedFuture(Optional.of(blockContainerAndMetaData))); when(validatorApiChannel.sendSignedBlock(any(), any())) .thenReturn(completedFuture(SendSignedBlockResult.success(unsignedBlock.getRoot()))); @@ -271,8 +261,6 @@ public void forDeneb_shouldCreateAndPublishBlindedBlock() { forkProvider, validatorApiChannel, blockContainerSigner, - true, - false, spec, validatorDutyMetrics); @@ -287,7 +275,7 @@ public void forDeneb_shouldCreateAndPublishBlindedBlock() { when(signer.signBlock(unsignedBlindedBlock.getBlock(), fork)) .thenReturn(completedFuture(blockSignature)); when(validatorApiChannel.createUnsignedBlock( - denebSlot, randaoReveal, Optional.of(graffiti), Optional.of(true), Optional.empty())) + denebSlot, randaoReveal, Optional.of(graffiti), Optional.empty(), Optional.empty())) .thenReturn(completedFuture(Optional.of(blockContainerAndMetaData))); when(validatorApiChannel.sendSignedBlock(any(), any())) .thenReturn(completedFuture(SendSignedBlockResult.success(unsignedBlindedBlock.getRoot()))); @@ -336,8 +324,6 @@ public void forDeneb_shouldFailWhenNoKzgProofs() { forkProvider, validatorApiChannel, blockContainerSigner, - false, - false, spec, validatorDutyMetrics); @@ -358,7 +344,7 @@ public void forDeneb_shouldFailWhenNoKzgProofs() { when(signer.signBlock(unsignedBlockContentsMock.getBlock(), fork)) .thenReturn(completedFuture(blockSignature)); when(validatorApiChannel.createUnsignedBlock( - denebSlot, randaoReveal, Optional.of(graffiti), Optional.of(false), Optional.empty())) + denebSlot, randaoReveal, Optional.of(graffiti), Optional.empty(), Optional.empty())) .thenReturn(completedFuture(Optional.of(blockContainerAndMetaData))); when(validatorApiChannel.sendSignedBlock(any(), any())) .thenReturn(completedFuture(SendSignedBlockResult.success(blockRoot))); @@ -381,8 +367,6 @@ public void forDeneb_shouldFailWhenNoBlobs() { forkProvider, validatorApiChannel, blockContainerSigner, - false, - false, spec, validatorDutyMetrics); @@ -404,7 +388,7 @@ public void forDeneb_shouldFailWhenNoBlobs() { when(signer.signBlock(unsignedBlockContentsMock.getBlock(), fork)) .thenReturn(completedFuture(blockSignature)); when(validatorApiChannel.createUnsignedBlock( - denebSlot, randaoReveal, Optional.of(graffiti), Optional.of(false), Optional.empty())) + denebSlot, randaoReveal, Optional.of(graffiti), Optional.empty(), Optional.empty())) .thenReturn(completedFuture(Optional.of(blockContainerAndMetaData))); when(validatorApiChannel.sendSignedBlock(any(), any())) .thenReturn(completedFuture(SendSignedBlockResult.success(blockRoot))); @@ -459,11 +443,7 @@ public void shouldFailWhenCreateUnsignedBlockFails() { when(signer.createRandaoReveal(spec.computeEpochAtSlot(CAPELLA_SLOT), fork)) .thenReturn(completedFuture(randaoReveal)); when(validatorApiChannel.createUnsignedBlock( - CAPELLA_SLOT, - randaoReveal, - Optional.of(graffiti), - Optional.of(false), - Optional.empty())) + CAPELLA_SLOT, randaoReveal, Optional.of(graffiti), Optional.empty(), Optional.empty())) .thenReturn(failedFuture(error)); assertDutyFails(error); @@ -479,11 +459,7 @@ public void shouldFailWhenCreateUnsignedBlockReturnsEmpty() { when(signer.createRandaoReveal(spec.computeEpochAtSlot(CAPELLA_SLOT), fork)) .thenReturn(completedFuture(randaoReveal)); when(validatorApiChannel.createUnsignedBlock( - CAPELLA_SLOT, - randaoReveal, - Optional.of(graffiti), - Optional.of(false), - Optional.empty())) + CAPELLA_SLOT, randaoReveal, Optional.of(graffiti), Optional.empty(), Optional.empty())) .thenReturn(completedFuture(Optional.empty())); performAndReportDuty(); @@ -510,11 +486,7 @@ public void shouldFailWhenSigningBlockFails() { when(signer.createRandaoReveal(spec.computeEpochAtSlot(CAPELLA_SLOT), fork)) .thenReturn(completedFuture(randaoReveal)); when(validatorApiChannel.createUnsignedBlock( - CAPELLA_SLOT, - randaoReveal, - Optional.of(graffiti), - Optional.of(false), - Optional.empty())) + CAPELLA_SLOT, randaoReveal, Optional.of(graffiti), Optional.empty(), Optional.empty())) .thenReturn(completedFuture(Optional.of(blockContainerAndMetaData))); when(signer.signBlock(blockContainerAndMetaData.blockContainer().getBlock(), fork)) .thenReturn(failedFuture(error)); @@ -538,8 +510,6 @@ public void shouldUseBlockV3ToCreateAndPublishBlock(final boolean isBlindedBlock forkProvider, validatorApiChannel, blockContainerSigner, - isBlindedBlocksEnabled, - true, spec, validatorDutyMetrics); final BLSSignature randaoReveal = dataStructureUtil.randomSignature(); @@ -598,8 +568,6 @@ public void forDeneb_shouldUseBlockV3ToCreateAndPublishBlockContents() { forkProvider, validatorApiChannel, blockContainerSigner, - false, - true, spec, validatorDutyMetrics); diff --git a/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClientTest.java b/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClientTest.java index 9fe8c5b40ee..9b054cc89da 100644 --- a/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClientTest.java +++ b/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClientTest.java @@ -176,7 +176,7 @@ void blockProductionFallbacksToNonBlindedFlowIfBlindedEndpointIsNotAvailable() dataStructureUtil.randomUInt64(), dataStructureUtil.randomSignature(), Optional.empty(), - true); + Optional.empty()); assertThat(maybeBlockContainerAndMetaData.map(BlockContainerAndMetaData::blockContainer)) .hasValue(blockContainer); @@ -186,7 +186,7 @@ void blockProductionFallbacksToNonBlindedFlowIfBlindedEndpointIsNotAvailable() final RecordedRequest firstRequest = mockWebServer.takeRequest(); assertThat(firstRequest.getPath()).startsWith("/eth/v1/validator/blinded_blocks"); final RecordedRequest secondRequest = mockWebServer.takeRequest(); - assertThat(secondRequest.getPath()).startsWith("/eth/v2/validator/blocks"); + assertThat(secondRequest.getPath()).startsWith("/eth/v3/validator/blocks"); } @TestTemplate diff --git a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/FailoverValidatorApiHandler.java b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/FailoverValidatorApiHandler.java index 42d15b84d8b..4db135d0390 100644 --- a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/FailoverValidatorApiHandler.java +++ b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/FailoverValidatorApiHandler.java @@ -160,13 +160,12 @@ public SafeFuture> createUnsignedBlock( final UInt64 slot, final BLSSignature randaoReveal, final Optional graffiti, - final Optional requestedBlinded, final Optional requestedBuilderBoostFactor) { final ValidatorApiChannelRequest> request = apiChannel -> apiChannel .createUnsignedBlock( - slot, randaoReveal, graffiti, requestedBlinded, requestedBuilderBoostFactor) + slot, randaoReveal, graffiti, requestedBuilderBoostFactor) .thenPeek( blockContainerAndMetaData -> { if (!failoverDelegates.isEmpty() diff --git a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/RemoteValidatorApiHandler.java b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/RemoteValidatorApiHandler.java index ddeebba9574..f36b475d32a 100644 --- a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/RemoteValidatorApiHandler.java +++ b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/RemoteValidatorApiHandler.java @@ -239,19 +239,11 @@ public SafeFuture> sendSignedAttestations( } @Override - @SuppressWarnings("deprecation") public SafeFuture> createUnsignedBlock( final UInt64 slot, final BLSSignature randaoReveal, final Optional graffiti, - final Optional requestedBlinded, final Optional requestedBuilderBoostFactor) { - if (requestedBlinded.isPresent()) { - return sendRequest( - () -> - typeDefClient.createUnsignedBlock( - slot, randaoReveal, graffiti, requestedBlinded.get())); - } return sendRequest( () -> typeDefClient.createUnsignedBlock( diff --git a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/apiclient/ValidatorApiMethod.java b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/apiclient/ValidatorApiMethod.java index b16363bb777..6e364302296 100644 --- a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/apiclient/ValidatorApiMethod.java +++ b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/apiclient/ValidatorApiMethod.java @@ -23,8 +23,6 @@ public enum ValidatorApiMethod { GET_GENESIS("eth/v1/beacon/genesis"), GET_VALIDATORS("eth/v1/beacon/states/head/validators"), GET_DUTIES("validator/duties"), - GET_UNSIGNED_BLOCK_V2("eth/v2/validator/blocks/:slot"), - GET_UNSIGNED_BLINDED_BLOCK("eth/v1/validator/blinded_blocks/:slot"), GET_UNSIGNED_BLOCK_V3("eth/v3/validator/blocks/:slot"), SEND_SIGNED_BLOCK("eth/v1/beacon/blocks"), SEND_SIGNED_BLOCK_V2("eth/v2/beacon/blocks"), diff --git a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/sentry/SentryValidatorApiChannel.java b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/sentry/SentryValidatorApiChannel.java index 0ec631b7059..03ade030440 100644 --- a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/sentry/SentryValidatorApiChannel.java +++ b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/sentry/SentryValidatorApiChannel.java @@ -111,12 +111,11 @@ public SafeFuture> createUnsignedBlock( final UInt64 slot, final BLSSignature randaoReveal, final Optional graffiti, - final Optional requestedBlinded, final Optional requestedBuilderBoostFactor) { return blockHandlerChannel .orElse(dutiesProviderChannel) .createUnsignedBlock( - slot, randaoReveal, graffiti, requestedBlinded, requestedBuilderBoostFactor); + slot, randaoReveal, graffiti, requestedBuilderBoostFactor); } @Override diff --git a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClient.java b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClient.java index 4d865ef2e0d..2661db0b306 100644 --- a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClient.java +++ b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClient.java @@ -139,25 +139,6 @@ public SendSignedBlockResult sendSignedBlock( return sendSignedBlockRequest.submit(blockContainer, broadcastValidationLevel); } - @Deprecated - public Optional createUnsignedBlock( - final UInt64 slot, - final BLSSignature randaoReveal, - final Optional graffiti, - final boolean blinded) { - final CreateBlockRequest createBlockRequest = - new CreateBlockRequest( - getBaseEndpoint(), getOkHttpClient(), spec, slot, blinded, preferSszBlockEncoding); - try { - return createBlockRequest.submit(randaoReveal, graffiti); - } catch (final BlindedBlockEndpointNotAvailableException ex) { - LOG.warn( - "Beacon Node {} does not support blinded block production. Falling back to normal block production.", - getBaseEndpoint()); - return createUnsignedBlock(slot, randaoReveal, graffiti, false); - } - } - public Optional createUnsignedBlock( final UInt64 slot, final BLSSignature randaoReveal, @@ -169,11 +150,8 @@ public Optional createUnsignedBlock( try { return produceBlockRequest.submit(randaoReveal, graffiti, requestedBuilderBoostFactor); } catch (final BlockProductionV3FailedException ex) { - LOG.warn("Produce Block V3 request failed at slot {}. Retrying with Block V2", slot); - - // Falling back to V2, we have to request a blinded block to be able to support both local and - // builder flow. - return createUnsignedBlock(slot, randaoReveal, graffiti, true); + LOG.warn("Produce Block V3 request failed at slot {}.", slot); + return Optional.empty(); } } diff --git a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/typedef/handlers/CreateBlockRequest.java b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/typedef/handlers/CreateBlockRequest.java index 55bed21eb67..ce9a58228a0 100644 --- a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/typedef/handlers/CreateBlockRequest.java +++ b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/typedef/handlers/CreateBlockRequest.java @@ -16,8 +16,7 @@ import static java.util.Collections.emptyMap; import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_NOT_FOUND; import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_OK; -import static tech.pegasys.teku.validator.remote.apiclient.ValidatorApiMethod.GET_UNSIGNED_BLINDED_BLOCK; -import static tech.pegasys.teku.validator.remote.apiclient.ValidatorApiMethod.GET_UNSIGNED_BLOCK_V2; +import static tech.pegasys.teku.validator.remote.apiclient.ValidatorApiMethod.GET_UNSIGNED_BLOCK_V3; import com.google.common.net.MediaType; import java.io.IOException; @@ -67,11 +66,8 @@ public CreateBlockRequest( super(baseEndpoint, okHttpClient); this.slot = slot; this.preferSszBlockEncoding = preferSszBlockEncoding; - apiMethod = blinded ? GET_UNSIGNED_BLINDED_BLOCK : GET_UNSIGNED_BLOCK_V2; - blockContainerSchema = - blinded - ? spec.atSlot(slot).getSchemaDefinitions().getBlindedBlockContainerSchema() - : spec.atSlot(slot).getSchemaDefinitions().getBlockContainerSchema(); + apiMethod = GET_UNSIGNED_BLOCK_V3; + blockContainerSchema = spec.atSlot(slot).getSchemaDefinitions().getBlockContainerSchema(); getBlockResponseDefinition = DeserializableTypeDefinition.object(GetBlockResponse.class) .initializer(GetBlockResponse::new) diff --git a/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/RemoteValidatorApiHandlerTest.java b/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/RemoteValidatorApiHandlerTest.java index e3fd97815e3..39a80695f46 100644 --- a/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/RemoteValidatorApiHandlerTest.java +++ b/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/RemoteValidatorApiHandlerTest.java @@ -523,12 +523,12 @@ public void createUnsignedBlock_WhenFound_ReturnsBlock() { eq(blockContainerAndMetaData.blockContainer().getSlot()), eq(blsSignature), eq(graffiti), - eq(false))) + eq(Optional.empty()))) .thenReturn(Optional.of(blockContainerAndMetaData)); SafeFuture> future = apiHandler.createUnsignedBlock( - ONE, blsSignature, graffiti, Optional.of(false), Optional.empty()); + ONE, blsSignature, graffiti, Optional.empty()); final BlockContainerAndMetaData resultValue = unwrapToValue(future); assertThat(resultValue).isEqualTo(blockContainerAndMetaData); @@ -554,7 +554,7 @@ public void createUnsignedBlock_viaBlockV3_WhenFound_ReturnsBlock() { SafeFuture> future = apiHandler.createUnsignedBlock( - ONE, blsSignature, graffiti, Optional.empty(), Optional.of(ONE)); + ONE, blsSignature, graffiti, Optional.of(ONE)); final BlockContainerAndMetaData resultValue = unwrapToValue(future); assertThat(resultValue).isEqualTo(blockContainerAndMetaData); @@ -575,12 +575,12 @@ public void createUnsignedBlock_WhenFound_ReturnsBlockContents() { eq(blockContentsAndMetaData.blockContainer().getSlot()), eq(blsSignature), eq(graffiti), - eq(false))) + eq(Optional.empty()))) .thenReturn(Optional.of(blockContentsAndMetaData)); SafeFuture> future = apiHandler.createUnsignedBlock( - ONE, blsSignature, graffiti, Optional.of(false), Optional.empty()); + ONE, blsSignature, graffiti, Optional.empty()); final BlockContainerAndMetaData resultValue = unwrapToValue(future); assertThat(resultValue).isEqualTo(blockContentsAndMetaData); From 30854e499c7b047469209ee1e31bd214c974afbb Mon Sep 17 00:00:00 2001 From: Gabriel Fukushima Date: Wed, 14 Aug 2024 10:12:55 +1000 Subject: [PATCH 02/19] remove outdated comment Signed-off-by: Gabriel Fukushima --- .../validator/coordinator/BlockOperationSelectorFactory.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java index b77fb881262..cf216a6b9f7 100644 --- a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java +++ b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java @@ -218,8 +218,7 @@ private SafeFuture setExecutionData( blockSlotState.getSlot())); } - // if requestedBlinded has been specified, we strictly follow it, otherwise we should run - // Builder flow (blinded) only if we have a validator registration + // We should run Builder flow (blinded) only if we have a validator registration final boolean shouldTryBuilderFlow = executionPayloadContext .map(ExecutionPayloadContext::isValidatorRegistrationPresent) From 8fdd44d4a46529e43929b06224e30c5d6c4c9f28 Mon Sep 17 00:00:00 2001 From: Gabriel Fukushima Date: Wed, 14 Aug 2024 10:31:51 +1000 Subject: [PATCH 03/19] remove redundant code Signed-off-by: Gabriel Fukushima --- .../coordinator/BlockOperationSelectorFactory.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java index cf216a6b9f7..e53b55b8fa2 100644 --- a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java +++ b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java @@ -290,16 +290,7 @@ private SafeFuture setPayloadOrPayloadHeader( // from the builder bid .map(BuilderBid::getHeader) // from the local fallback - .orElseGet( - () -> { - final ExecutionPayload executionPayload = - builderBidOrFallbackData - .getFallbackDataRequired() - .getExecutionPayload(); - return schemaDefinitions - .getExecutionPayloadHeaderSchema() - .createFromExecutionPayload(executionPayload); - }); + .orElseThrow(); bodyBuilder.executionPayloadHeader(executionPayloadHeader); } }); From ae20b68a5541f0833fd7aaf879fd643d1ab6820e Mon Sep 17 00:00:00 2001 From: Gabriel Fukushima Date: Wed, 14 Aug 2024 10:41:41 +1000 Subject: [PATCH 04/19] fix tests Signed-off-by: Gabriel Fukushima --- .../teku/api/ValidatorDataProviderTest.java | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/data/provider/src/test/java/tech/pegasys/teku/api/ValidatorDataProviderTest.java b/data/provider/src/test/java/tech/pegasys/teku/api/ValidatorDataProviderTest.java index 02ed8cdaf93..57a583e7ccb 100644 --- a/data/provider/src/test/java/tech/pegasys/teku/api/ValidatorDataProviderTest.java +++ b/data/provider/src/test/java/tech/pegasys/teku/api/ValidatorDataProviderTest.java @@ -118,8 +118,8 @@ void getUnsignedBeaconBlockAtSlot_throwsWithoutSlotDefined() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy( () -> - provider.getUnsignedBeaconBlockAtSlot( - null, null, Optional.empty(), false, Optional.empty())); + provider.produceBlock( + null, null, Optional.empty(), Optional.empty())); } @TestTemplate @@ -127,8 +127,8 @@ void getUnsignedBeaconBlockAtSlot_shouldThrowWithoutRandaoDefined() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy( () -> - provider.getUnsignedBeaconBlockAtSlot( - ONE, null, Optional.empty(), false, Optional.empty())); + provider.produceBlock( + ONE, null, Optional.empty(), Optional.empty())); } @TestTemplate @@ -138,8 +138,8 @@ void getUnsignedBeaconBlockAtSlot_shouldThrowIfHistoricSlotRequested() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy( () -> - provider.getUnsignedBeaconBlockAtSlot( - ZERO, signatureInternal, Optional.empty(), false, Optional.empty())); + provider.produceBlock( + ZERO, signatureInternal, Optional.empty(), Optional.empty())); } @TestTemplate @@ -149,11 +149,10 @@ void getUnsignedBeaconBlockAtSlot_shouldThrowIfFarFutureSlotRequested() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy( () -> - provider.getUnsignedBeaconBlockAtSlot( + provider.produceBlock( UInt64.valueOf(10L), signatureInternal, Optional.empty(), - false, Optional.empty())); } @@ -162,16 +161,16 @@ void getUnsignedBeaconBlockAtSlot_PreDeneb_shouldCreateAnUnsignedBlock() { assumeThat(specMilestone).isLessThan(SpecMilestone.DENEB); when(combinedChainDataClient.getCurrentSlot()).thenReturn(ZERO); when(validatorApiChannel.createUnsignedBlock( - ONE, signatureInternal, Optional.empty(), Optional.of(false), Optional.empty())) + ONE, signatureInternal, Optional.empty(), Optional.empty())) .thenReturn(completedFuture(Optional.of(blockContainerAndMetaDataInternal))); SafeFuture> data = - provider.getUnsignedBeaconBlockAtSlot( - ONE, signatureInternal, Optional.empty(), false, Optional.empty()); + provider.produceBlock( + ONE, signatureInternal, Optional.empty(),Optional.empty()); verify(validatorApiChannel) .createUnsignedBlock( - ONE, signatureInternal, Optional.empty(), Optional.of(false), Optional.empty()); + ONE, signatureInternal, Optional.empty(),Optional.empty()); assertThat(data).isCompleted(); @@ -221,7 +220,7 @@ void produceBlock_shouldCreateAnUnsignedBlock() { .thenReturn(completedFuture(Optional.of(dataStructureUtil.randomBeaconState()))); when(validatorApiChannel.createUnsignedBlock( - ONE, signatureInternal, Optional.empty(), Optional.empty(), Optional.of(ONE))) + ONE, signatureInternal, Optional.empty(), Optional.of(ONE))) .thenReturn(completedFuture(Optional.of(blockContainerAndMetaDataInternal))); SafeFuture> data = @@ -229,7 +228,7 @@ void produceBlock_shouldCreateAnUnsignedBlock() { verify(validatorApiChannel) .createUnsignedBlock( - ONE, signatureInternal, Optional.empty(), Optional.empty(), Optional.of(ONE)); + ONE, signatureInternal, Optional.empty(), Optional.of(ONE)); assertThat(data).isCompleted(); From 73974e4d067a6ecf9e3c0b608babab1a2119e98b Mon Sep 17 00:00:00 2001 From: Gabriel Fukushima Date: Wed, 14 Aug 2024 10:41:49 +1000 Subject: [PATCH 05/19] fix tests Signed-off-by: Gabriel Fukushima --- .../validator/coordinator/ValidatorApiHandlerTest.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandlerTest.java b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandlerTest.java index 7c01945d81b..885083f1da3 100644 --- a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandlerTest.java +++ b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandlerTest.java @@ -497,10 +497,7 @@ public void createUnsignedBlock_shouldFailWhenNodeIsSyncing() { nodeIsSyncing(); final SafeFuture> result = validatorApiHandler.createUnsignedBlock( - ONE, - dataStructureUtil.randomSignature(), - Optional.empty(), - Optional.of(ONE)); + ONE, dataStructureUtil.randomSignature(), Optional.empty(), Optional.of(ONE)); assertThat(result).isCompletedExceptionally(); assertThatThrownBy(result::get).hasRootCauseInstanceOf(NodeSyncingException.class); @@ -517,10 +514,7 @@ public void createUnsignedBlock_shouldFailWhenParentBlockIsOptimistic() { final SafeFuture> result = validatorApiHandler.createUnsignedBlock( - newSlot, - dataStructureUtil.randomSignature(), - Optional.empty(), - Optional.of(ONE)); + newSlot, dataStructureUtil.randomSignature(), Optional.empty(), Optional.of(ONE)); assertThat(result).isCompletedExceptionally(); assertThatThrownBy(result::get).hasRootCauseInstanceOf(NodeSyncingException.class); From 3534683c57d3d25ab8373ed72b1a4188d2060430 Mon Sep 17 00:00:00 2001 From: Gabriel Fukushima Date: Wed, 14 Aug 2024 10:42:02 +1000 Subject: [PATCH 06/19] spotless Signed-off-by: Gabriel Fukushima --- .../BlockOperationSelectorFactory.java | 9 ++++---- .../v3/GetNewBlockV3IntegrationTest.java | 21 +++++++------------ .../MetricRecordingValidatorApiChannel.java | 3 +-- .../remote/FailoverValidatorApiHandler.java | 3 +-- .../sentry/SentryValidatorApiChannel.java | 3 +-- .../typedef/OkHttpValidatorTypeDefClient.java | 3 +-- .../remote/RemoteValidatorApiHandlerTest.java | 9 +++----- 7 files changed, 18 insertions(+), 33 deletions(-) diff --git a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java index e53b55b8fa2..7e174c0d0a9 100644 --- a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java +++ b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java @@ -220,9 +220,9 @@ private SafeFuture setExecutionData( // We should run Builder flow (blinded) only if we have a validator registration final boolean shouldTryBuilderFlow = - executionPayloadContext - .map(ExecutionPayloadContext::isValidatorRegistrationPresent) - .orElse(false); + executionPayloadContext + .map(ExecutionPayloadContext::isValidatorRegistrationPresent) + .orElse(false); // pre-Merge Execution Payload / Execution Payload Header if (executionPayloadContext.isEmpty()) { @@ -245,8 +245,7 @@ private SafeFuture setExecutionData( return SafeFuture.allOf( cacheExecutionPayloadValue(executionPayloadResult, blockSlotState), - setPayloadOrPayloadHeader( - bodyBuilder, schemaDefinitions, executionPayloadResult), + setPayloadOrPayloadHeader(bodyBuilder, schemaDefinitions, executionPayloadResult), setKzgCommitments(bodyBuilder, schemaDefinitions, executionPayloadResult)); } diff --git a/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v3/GetNewBlockV3IntegrationTest.java b/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v3/GetNewBlockV3IntegrationTest.java index 858218b71b3..b8ce8defb5b 100644 --- a/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v3/GetNewBlockV3IntegrationTest.java +++ b/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v3/GetNewBlockV3IntegrationTest.java @@ -76,8 +76,7 @@ void shouldGetUnBlindedBeaconBlockAsJson() throws Exception { dataStructureUtil.randomBlockContainerAndMetaData(ONE); final BLSSignature signature = blockContainerAndMetaData.blockContainer().getBlock().getBody().getRandaoReveal(); - when(validatorApiChannel.createUnsignedBlock( - eq(UInt64.ONE), eq(signature), any(), any())) + when(validatorApiChannel.createUnsignedBlock(eq(UInt64.ONE), eq(signature), any(), any())) .thenReturn(SafeFuture.completedFuture(Optional.of(blockContainerAndMetaData))); Response response = get(signature, ContentTypes.JSON); assertResponseWithHeaders( @@ -100,8 +99,7 @@ void shouldGetUnblindedBeaconBlockAsSsz() throws IOException { dataStructureUtil.randomBlockContainerAndMetaData(ONE); final BLSSignature signature = blockContainerAndMetaData.blockContainer().getBlock().getBody().getRandaoReveal(); - when(validatorApiChannel.createUnsignedBlock( - eq(UInt64.ONE), eq(signature), any(), any())) + when(validatorApiChannel.createUnsignedBlock(eq(UInt64.ONE), eq(signature), any(), any())) .thenReturn(SafeFuture.completedFuture(Optional.of(blockContainerAndMetaData))); Response response = get(signature, ContentTypes.OCTET_STREAM); assertResponseWithHeaders( @@ -123,8 +121,7 @@ void shouldGetBlindedBeaconBlockAsJson() throws Exception { dataStructureUtil.randomBlindedBlockContainerAndMetaData(ONE); final BLSSignature signature = blockContainerAndMetaData.blockContainer().getBlock().getBody().getRandaoReveal(); - when(validatorApiChannel.createUnsignedBlock( - eq(UInt64.ONE), eq(signature), any(), any())) + when(validatorApiChannel.createUnsignedBlock(eq(UInt64.ONE), eq(signature), any(), any())) .thenReturn(SafeFuture.completedFuture(Optional.of(blockContainerAndMetaData))); Response response = get(signature, ContentTypes.JSON); assertResponseWithHeaders( @@ -148,8 +145,7 @@ void shouldGetBlindedBeaconBlockAsSsz() throws IOException { final BeaconBlock blindedBeaconBlock = blockContainerAndMetaData.blockContainer().getBlock(); final BLSSignature signature = blockContainerAndMetaData.blockContainer().getBlock().getBody().getRandaoReveal(); - when(validatorApiChannel.createUnsignedBlock( - eq(UInt64.ONE), eq(signature), any(), any())) + when(validatorApiChannel.createUnsignedBlock(eq(UInt64.ONE), eq(signature), any(), any())) .thenReturn(SafeFuture.completedFuture(Optional.of(blockContainerAndMetaData))); Response response = get(signature, ContentTypes.OCTET_STREAM); assertResponseWithHeaders( @@ -172,8 +168,7 @@ void shouldGetUnBlindedBlockContentPostDenebAsJson() throws Exception { dataStructureUtil.randomBlockContainerAndMetaData(blockContents, ONE); final BLSSignature signature = blockContainerAndMetaData.blockContainer().getBlock().getBody().getRandaoReveal(); - when(validatorApiChannel.createUnsignedBlock( - eq(UInt64.ONE), eq(signature), any(), any())) + when(validatorApiChannel.createUnsignedBlock(eq(UInt64.ONE), eq(signature), any(), any())) .thenReturn(SafeFuture.completedFuture(Optional.of(blockContainerAndMetaData))); Response response = get(signature, ContentTypes.JSON); assertResponseWithHeaders( @@ -196,8 +191,7 @@ void shouldGetUnBlindedBlockContentPostDenebAsSsz() throws IOException { final BlockContainerAndMetaData blockContainerAndMetaData = dataStructureUtil.randomBlockContainerAndMetaData(blockContents, ONE); final BLSSignature signature = blockContents.getBlock().getBody().getRandaoReveal(); - when(validatorApiChannel.createUnsignedBlock( - eq(UInt64.ONE), eq(signature), any(), any())) + when(validatorApiChannel.createUnsignedBlock(eq(UInt64.ONE), eq(signature), any(), any())) .thenReturn(SafeFuture.completedFuture(Optional.of(blockContainerAndMetaData))); Response response = get(signature, ContentTypes.OCTET_STREAM); assertResponseWithHeaders( @@ -217,8 +211,7 @@ void shouldGetUnBlindedBlockContentPostDenebAsSsz() throws IOException { void shouldFailWhenNoBlockProduced() throws IOException { final BeaconBlock beaconBlock = dataStructureUtil.randomBeaconBlock(ONE); final BLSSignature signature = beaconBlock.getBlock().getBody().getRandaoReveal(); - when(validatorApiChannel.createUnsignedBlock( - eq(UInt64.ONE), eq(signature), any(), any())) + when(validatorApiChannel.createUnsignedBlock(eq(UInt64.ONE), eq(signature), any(), any())) .thenReturn(SafeFuture.completedFuture(Optional.empty())); Response response = get(signature, ContentTypes.JSON); assertThat(response.code()).isEqualTo(SC_INTERNAL_SERVER_ERROR); diff --git a/validator/beaconnode/src/main/java/tech/pegasys/teku/validator/beaconnode/metrics/MetricRecordingValidatorApiChannel.java b/validator/beaconnode/src/main/java/tech/pegasys/teku/validator/beaconnode/metrics/MetricRecordingValidatorApiChannel.java index 4284d2f8926..81d17480b9a 100644 --- a/validator/beaconnode/src/main/java/tech/pegasys/teku/validator/beaconnode/metrics/MetricRecordingValidatorApiChannel.java +++ b/validator/beaconnode/src/main/java/tech/pegasys/teku/validator/beaconnode/metrics/MetricRecordingValidatorApiChannel.java @@ -141,8 +141,7 @@ public SafeFuture> createUnsignedBlock( final Optional graffiti, final Optional requestedBuilderBoostFactor) { return countOptionalDataRequest( - delegate.createUnsignedBlock( - slot, randaoReveal, graffiti, requestedBuilderBoostFactor), + delegate.createUnsignedBlock(slot, randaoReveal, graffiti, requestedBuilderBoostFactor), BeaconNodeRequestLabels.CREATE_UNSIGNED_BLOCK_METHOD); } diff --git a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/FailoverValidatorApiHandler.java b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/FailoverValidatorApiHandler.java index 4db135d0390..a9ca5453bcc 100644 --- a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/FailoverValidatorApiHandler.java +++ b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/FailoverValidatorApiHandler.java @@ -164,8 +164,7 @@ public SafeFuture> createUnsignedBlock( final ValidatorApiChannelRequest> request = apiChannel -> apiChannel - .createUnsignedBlock( - slot, randaoReveal, graffiti, requestedBuilderBoostFactor) + .createUnsignedBlock(slot, randaoReveal, graffiti, requestedBuilderBoostFactor) .thenPeek( blockContainerAndMetaData -> { if (!failoverDelegates.isEmpty() diff --git a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/sentry/SentryValidatorApiChannel.java b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/sentry/SentryValidatorApiChannel.java index 03ade030440..b632e81e2cb 100644 --- a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/sentry/SentryValidatorApiChannel.java +++ b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/sentry/SentryValidatorApiChannel.java @@ -114,8 +114,7 @@ public SafeFuture> createUnsignedBlock( final Optional requestedBuilderBoostFactor) { return blockHandlerChannel .orElse(dutiesProviderChannel) - .createUnsignedBlock( - slot, randaoReveal, graffiti, requestedBuilderBoostFactor); + .createUnsignedBlock(slot, randaoReveal, graffiti, requestedBuilderBoostFactor); } @Override diff --git a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClient.java b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClient.java index 850a168c1bb..d846b3b3f45 100644 --- a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClient.java +++ b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClient.java @@ -57,7 +57,6 @@ import tech.pegasys.teku.validator.remote.typedef.handlers.BeaconCommitteeSelectionsRequest; import tech.pegasys.teku.validator.remote.typedef.handlers.CreateAggregateAttestationRequest; import tech.pegasys.teku.validator.remote.typedef.handlers.CreateAttestationDataRequest; -import tech.pegasys.teku.validator.remote.typedef.handlers.CreateBlockRequest; import tech.pegasys.teku.validator.remote.typedef.handlers.CreateSyncCommitteeContributionRequest; import tech.pegasys.teku.validator.remote.typedef.handlers.GetPeerCountRequest; import tech.pegasys.teku.validator.remote.typedef.handlers.GetProposerDutiesRequest; @@ -157,7 +156,7 @@ public Optional createUnsignedBlock( return produceBlockRequest.submit(randaoReveal, graffiti, requestedBuilderBoostFactor); } catch (final BlockProductionV3FailedException ex) { LOG.warn("Produce Block V3 request failed at slot {}.", slot); - return Optional.empty(); + return Optional.empty(); } } diff --git a/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/RemoteValidatorApiHandlerTest.java b/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/RemoteValidatorApiHandlerTest.java index 16becdc2efc..27a9dd76ca9 100644 --- a/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/RemoteValidatorApiHandlerTest.java +++ b/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/RemoteValidatorApiHandlerTest.java @@ -490,8 +490,7 @@ public void createUnsignedBlock_WhenFound_ReturnsBlock() { .thenReturn(Optional.of(blockContainerAndMetaData)); SafeFuture> future = - apiHandler.createUnsignedBlock( - ONE, blsSignature, graffiti, Optional.empty()); + apiHandler.createUnsignedBlock(ONE, blsSignature, graffiti, Optional.empty()); final BlockContainerAndMetaData resultValue = unwrapToValue(future); assertThat(resultValue).isEqualTo(blockContainerAndMetaData); @@ -516,8 +515,7 @@ public void createUnsignedBlock_viaBlockV3_WhenFound_ReturnsBlock() { .thenReturn(Optional.of(blockContainerAndMetaData)); SafeFuture> future = - apiHandler.createUnsignedBlock( - ONE, blsSignature, graffiti, Optional.of(ONE)); + apiHandler.createUnsignedBlock(ONE, blsSignature, graffiti, Optional.of(ONE)); final BlockContainerAndMetaData resultValue = unwrapToValue(future); assertThat(resultValue).isEqualTo(blockContainerAndMetaData); @@ -542,8 +540,7 @@ public void createUnsignedBlock_WhenFound_ReturnsBlockContents() { .thenReturn(Optional.of(blockContentsAndMetaData)); SafeFuture> future = - apiHandler.createUnsignedBlock( - ONE, blsSignature, graffiti, Optional.empty()); + apiHandler.createUnsignedBlock(ONE, blsSignature, graffiti, Optional.empty()); final BlockContainerAndMetaData resultValue = unwrapToValue(future); assertThat(resultValue).isEqualTo(blockContentsAndMetaData); From 0e2c4aefefdc5f00769fb3813d2d00239f4b84e1 Mon Sep 17 00:00:00 2001 From: Gabriel Fukushima Date: Wed, 14 Aug 2024 10:42:26 +1000 Subject: [PATCH 07/19] remove old test used as base of v2 and blindedblock Signed-off-by: Gabriel Fukushima --- .../AbstractGetNewBlockTest.java | 119 ------------------ 1 file changed, 119 deletions(-) delete mode 100644 data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/AbstractGetNewBlockTest.java diff --git a/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/AbstractGetNewBlockTest.java b/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/AbstractGetNewBlockTest.java deleted file mode 100644 index a0561d1d232..00000000000 --- a/data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/AbstractGetNewBlockTest.java +++ /dev/null @@ -1,119 +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.beaconrestapi; - -import static java.nio.charset.StandardCharsets.UTF_8; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.when; -import static tech.pegasys.teku.infrastructure.http.RestApiConstants.RANDAO_REVEAL; -import static tech.pegasys.teku.infrastructure.http.RestApiConstants.SLOT; -import static tech.pegasys.teku.infrastructure.unsigned.UInt64.ONE; - -import com.google.common.io.Resources; -import java.util.Optional; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import tech.pegasys.teku.bls.BLSSignature; -import tech.pegasys.teku.bls.BLSTestUtil; -import tech.pegasys.teku.infrastructure.async.SafeFuture; -import tech.pegasys.teku.infrastructure.restapi.endpoints.RestApiEndpoint; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; -import tech.pegasys.teku.spec.SpecMilestone; -import tech.pegasys.teku.spec.TestSpecFactory; -import tech.pegasys.teku.spec.datastructures.blocks.versions.deneb.BlockContents; -import tech.pegasys.teku.spec.datastructures.metadata.BlockContainerAndMetaData; -import tech.pegasys.teku.spec.util.DataStructureUtil; -import tech.pegasys.teku.storage.client.ChainDataUnavailableException; - -public abstract class AbstractGetNewBlockTest extends AbstractMigratedBeaconHandlerTest { - protected final BLSSignature signature = BLSTestUtil.randomSignature(1234); - - @BeforeEach - public void setup() { - setHandler(getHandler()); - request.setPathParameter(SLOT, "1"); - request.setQueryParameter(RANDAO_REVEAL, signature.toBytesCompressed().toHexString()); - when(validatorDataProvider.getMilestoneAtSlot(UInt64.ONE)).thenReturn(SpecMilestone.ALTAIR); - } - - @SuppressWarnings("unchecked") - @Test - void shouldReturnBlockWithoutGraffiti() throws Exception { - final BlockContainerAndMetaData blockContainerAndMetaData = - dataStructureUtil.randomBlockContainerAndMetaData(ONE); - doReturn(SafeFuture.completedFuture(Optional.of(blockContainerAndMetaData))) - .when(validatorDataProvider) - .getUnsignedBeaconBlockAtSlot( - ONE, signature, Optional.empty(), isBlindedBlocks(), Optional.empty()); - - handler.handleRequest(request); - - assertThat(request.getResponseBody()).isEqualTo(blockContainerAndMetaData.blockContainer()); - // Check block serializes correctly - assertThat(request.getResponseBodyAsJson(handler)) - .isEqualTo( - Resources.toString( - Resources.getResource(AbstractGetNewBlockTest.class, "beaconBlock.json"), UTF_8)); - } - - @Test - void shouldReturnBlindedBeaconBlockPostDeneb() throws Exception { - spec = TestSpecFactory.createMinimalDeneb(); - dataStructureUtil = new DataStructureUtil(spec); - final BlockContainerAndMetaData blockContainerAndMetaData = - dataStructureUtil.randomBlindedBlockContainerAndMetaData(ONE); - doReturn(SafeFuture.completedFuture(Optional.of(blockContainerAndMetaData))) - .when(validatorDataProvider) - .getUnsignedBeaconBlockAtSlot( - ONE, signature, Optional.empty(), isBlindedBlocks(), Optional.empty()); - - handler.handleRequest(request); - - assertThat(request.getResponseBody()).isEqualTo(blockContainerAndMetaData.blockContainer()); - } - - @Test - void shouldReturnBlockContentsPostDeneb() throws Exception { - spec = TestSpecFactory.createMinimalDeneb(); - dataStructureUtil = new DataStructureUtil(spec); - final BlockContents blockContents = dataStructureUtil.randomBlockContents(ONE); - final BlockContainerAndMetaData blockContainerAndMetaData = - dataStructureUtil.randomBlockContainerAndMetaData(blockContents, ONE); - doReturn(SafeFuture.completedFuture(Optional.of(blockContainerAndMetaData))) - .when(validatorDataProvider) - .getUnsignedBeaconBlockAtSlot( - ONE, signature, Optional.empty(), isBlindedBlocks(), Optional.empty()); - - handler.handleRequest(request); - - assertThat(request.getResponseBody()).isEqualTo(blockContents); - } - - @Test - void shouldThrowExceptionWithEmptyBlock() throws Exception { - - doReturn(SafeFuture.completedFuture(Optional.empty())) - .when(validatorDataProvider) - .getUnsignedBeaconBlockAtSlot( - ONE, signature, Optional.empty(), isBlindedBlocks(), Optional.empty()); - - handler.handleRequest(request); - assertThat(request.getResponseError()).containsInstanceOf(ChainDataUnavailableException.class); - } - - public abstract RestApiEndpoint getHandler(); - - public abstract boolean isBlindedBlocks(); -} From d18b280e59871fef0c21c70c78226f7edd4ddd88 Mon Sep 17 00:00:00 2001 From: Gabriel Fukushima Date: Wed, 14 Aug 2024 10:42:42 +1000 Subject: [PATCH 08/19] spotless Signed-off-by: Gabriel Fukushima --- .../teku/api/ValidatorDataProviderTest.java | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/data/provider/src/test/java/tech/pegasys/teku/api/ValidatorDataProviderTest.java b/data/provider/src/test/java/tech/pegasys/teku/api/ValidatorDataProviderTest.java index 57a583e7ccb..c2c5d03cc22 100644 --- a/data/provider/src/test/java/tech/pegasys/teku/api/ValidatorDataProviderTest.java +++ b/data/provider/src/test/java/tech/pegasys/teku/api/ValidatorDataProviderTest.java @@ -116,19 +116,13 @@ public void setup(final SpecContext specContext) { @TestTemplate void getUnsignedBeaconBlockAtSlot_throwsWithoutSlotDefined() { assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy( - () -> - provider.produceBlock( - null, null, Optional.empty(), Optional.empty())); + .isThrownBy(() -> provider.produceBlock(null, null, Optional.empty(), Optional.empty())); } @TestTemplate void getUnsignedBeaconBlockAtSlot_shouldThrowWithoutRandaoDefined() { assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy( - () -> - provider.produceBlock( - ONE, null, Optional.empty(), Optional.empty())); + .isThrownBy(() -> provider.produceBlock(ONE, null, Optional.empty(), Optional.empty())); } @TestTemplate @@ -138,8 +132,7 @@ void getUnsignedBeaconBlockAtSlot_shouldThrowIfHistoricSlotRequested() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy( () -> - provider.produceBlock( - ZERO, signatureInternal, Optional.empty(), Optional.empty())); + provider.produceBlock(ZERO, signatureInternal, Optional.empty(), Optional.empty())); } @TestTemplate @@ -150,10 +143,7 @@ void getUnsignedBeaconBlockAtSlot_shouldThrowIfFarFutureSlotRequested() { .isThrownBy( () -> provider.produceBlock( - UInt64.valueOf(10L), - signatureInternal, - Optional.empty(), - Optional.empty())); + UInt64.valueOf(10L), signatureInternal, Optional.empty(), Optional.empty())); } @TestTemplate @@ -165,12 +155,10 @@ void getUnsignedBeaconBlockAtSlot_PreDeneb_shouldCreateAnUnsignedBlock() { .thenReturn(completedFuture(Optional.of(blockContainerAndMetaDataInternal))); SafeFuture> data = - provider.produceBlock( - ONE, signatureInternal, Optional.empty(),Optional.empty()); + provider.produceBlock(ONE, signatureInternal, Optional.empty(), Optional.empty()); verify(validatorApiChannel) - .createUnsignedBlock( - ONE, signatureInternal, Optional.empty(),Optional.empty()); + .createUnsignedBlock(ONE, signatureInternal, Optional.empty(), Optional.empty()); assertThat(data).isCompleted(); @@ -227,8 +215,7 @@ void produceBlock_shouldCreateAnUnsignedBlock() { provider.produceBlock(ONE, signatureInternal, Optional.empty(), Optional.of(ONE)); verify(validatorApiChannel) - .createUnsignedBlock( - ONE, signatureInternal, Optional.empty(), Optional.of(ONE)); + .createUnsignedBlock(ONE, signatureInternal, Optional.empty(), Optional.of(ONE)); assertThat(data).isCompleted(); From f47afa5af44434d8f0b38680e99d163e3ee164b5 Mon Sep 17 00:00:00 2001 From: Gabriel Fukushima Date: Wed, 14 Aug 2024 16:51:07 +1000 Subject: [PATCH 09/19] remove redundant check Signed-off-by: Gabriel Fukushima --- .../BlockOperationSelectorFactory.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java index 7e174c0d0a9..00342df3a1b 100644 --- a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java +++ b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java @@ -226,12 +226,12 @@ private SafeFuture setExecutionData( // pre-Merge Execution Payload / Execution Payload Header if (executionPayloadContext.isEmpty()) { - if (shouldTryBuilderFlow) { - bodyBuilder.executionPayloadHeader( - schemaDefinitions.getExecutionPayloadHeaderSchema().getHeaderOfDefaultPayload()); - } else { - bodyBuilder.executionPayload(schemaDefinitions.getExecutionPayloadSchema().getDefault()); - } + + bodyBuilder.executionPayloadHeader( + schemaDefinitions.getExecutionPayloadHeaderSchema().getHeaderOfDefaultPayload()); + + bodyBuilder.executionPayload(schemaDefinitions.getExecutionPayloadSchema().getDefault()); + return SafeFuture.COMPLETE; } @@ -245,7 +245,7 @@ private SafeFuture setExecutionData( return SafeFuture.allOf( cacheExecutionPayloadValue(executionPayloadResult, blockSlotState), - setPayloadOrPayloadHeader(bodyBuilder, schemaDefinitions, executionPayloadResult), + setPayloadOrPayloadHeader(bodyBuilder, executionPayloadResult), setKzgCommitments(bodyBuilder, schemaDefinitions, executionPayloadResult)); } @@ -261,7 +261,6 @@ private SafeFuture cacheExecutionPayloadValue( private SafeFuture setPayloadOrPayloadHeader( final BeaconBlockBodyBuilder bodyBuilder, - final SchemaDefinitionsBellatrix schemaDefinitions, final ExecutionPayloadResult executionPayloadResult) { if (executionPayloadResult.isFromLocalFlow()) { From 996085cec9cfbf254bab41b9e054434bbf9d7171 Mon Sep 17 00:00:00 2001 From: Gabriel Fukushima Date: Wed, 14 Aug 2024 16:51:15 +1000 Subject: [PATCH 10/19] fix tests Signed-off-by: Gabriel Fukushima --- .../coordinator/AbstractBlockFactoryTest.java | 15 ++++++++--- ...etricRecordingValidatorApiChannelTest.java | 3 +-- .../duties/BlockProductionDutyTest.java | 26 +++++++++---------- .../FailoverValidatorApiHandlerTest.java | 5 ++-- .../remote/RemoteValidatorApiHandlerTest.java | 2 +- .../sentry/SentryValidatorApiChannelTest.java | 16 +++--------- 6 files changed, 31 insertions(+), 36 deletions(-) diff --git a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/AbstractBlockFactoryTest.java b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/AbstractBlockFactoryTest.java index 5de4055b6ce..e0197e631cd 100644 --- a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/AbstractBlockFactoryTest.java +++ b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/AbstractBlockFactoryTest.java @@ -196,10 +196,17 @@ protected BlockContainerAndMetaData assertBlockCreated( when(voluntaryExitPool.getItemsForBlock(any(), any(), any())).thenReturn(voluntaryExits); when(blsToExecutionChangePool.getItemsForBlock(any())).thenReturn(blsToExecutionChanges); when(eth1DataCache.getEth1Vote(any())).thenReturn(ETH1_DATA); - when(forkChoiceNotifier.getPayloadId(any(), any())) - .thenReturn( - SafeFuture.completedFuture( - Optional.of(dataStructureUtil.randomPayloadExecutionContext(false)))); + if (blinded) { + when(forkChoiceNotifier.getPayloadId(any(), any())) + .thenReturn( + SafeFuture.completedFuture( + Optional.of(dataStructureUtil.randomPayloadExecutionContext(false, true)))); + } else { + when(forkChoiceNotifier.getPayloadId(any(), any())) + .thenReturn( + SafeFuture.completedFuture( + Optional.of(dataStructureUtil.randomPayloadExecutionContext(false)))); + } final BLSSignature randaoReveal = dataStructureUtil.randomSignature(); final Bytes32 bestBlockRoot = recentChainData.getBestBlockRoot().orElseThrow(); diff --git a/validator/beaconnode/src/test/java/tech/pegasys/teku/validator/beaconnode/metrics/MetricRecordingValidatorApiChannelTest.java b/validator/beaconnode/src/test/java/tech/pegasys/teku/validator/beaconnode/metrics/MetricRecordingValidatorApiChannelTest.java index d02c5df5543..e72db7fad81 100644 --- a/validator/beaconnode/src/test/java/tech/pegasys/teku/validator/beaconnode/metrics/MetricRecordingValidatorApiChannelTest.java +++ b/validator/beaconnode/src/test/java/tech/pegasys/teku/validator/beaconnode/metrics/MetricRecordingValidatorApiChannelTest.java @@ -197,8 +197,7 @@ public static Stream getDataRequestArguments() { requestDataTest( "createUnsignedBlock", channel -> - channel.createUnsignedBlock( - slot, signature, Optional.empty(), Optional.of(false), Optional.empty()), + channel.createUnsignedBlock(slot, signature, Optional.empty(), Optional.empty()), BeaconNodeRequestLabels.CREATE_UNSIGNED_BLOCK_METHOD, dataStructureUtil.randomBlockContainerAndMetaData(slot)), requestDataTest( diff --git a/validator/client/src/test/java/tech/pegasys/teku/validator/client/duties/BlockProductionDutyTest.java b/validator/client/src/test/java/tech/pegasys/teku/validator/client/duties/BlockProductionDutyTest.java index 0d0560c581e..6f6eb831243 100644 --- a/validator/client/src/test/java/tech/pegasys/teku/validator/client/duties/BlockProductionDutyTest.java +++ b/validator/client/src/test/java/tech/pegasys/teku/validator/client/duties/BlockProductionDutyTest.java @@ -137,7 +137,7 @@ public void shouldCreateAndPublishBlock(final boolean isBlindedBlocksEnabled) { when(signer.createRandaoReveal(spec.computeEpochAtSlot(CAPELLA_SLOT), fork)) .thenReturn(completedFuture(randaoReveal)); when(validatorApiChannel.createUnsignedBlock( - CAPELLA_SLOT, randaoReveal, Optional.of(graffiti), Optional.empty(), Optional.empty())) + CAPELLA_SLOT, randaoReveal, Optional.of(graffiti), Optional.empty())) .thenReturn(completedFuture(Optional.of(blockContainerAndMetaData))); when(signer.signBlock(unsignedBlock, fork)).thenReturn(completedFuture(blockSignature)); final SignedBeaconBlock signedBlock = @@ -193,7 +193,7 @@ public void forDeneb_shouldCreateAndPublishBlockContents() { when(signer.signBlock(unsignedBlockContents.getBlock(), fork)) .thenReturn(completedFuture(blockSignature)); when(validatorApiChannel.createUnsignedBlock( - denebSlot, randaoReveal, Optional.of(graffiti), Optional.empty(), Optional.empty())) + denebSlot, randaoReveal, Optional.of(graffiti), Optional.empty())) .thenReturn(completedFuture(Optional.of(blockContainerAndMetaData))); when(validatorApiChannel.sendSignedBlock(any(), any())) .thenReturn(completedFuture(SendSignedBlockResult.success(unsignedBlock.getRoot()))); @@ -275,7 +275,7 @@ public void forDeneb_shouldCreateAndPublishBlindedBlock() { when(signer.signBlock(unsignedBlindedBlock.getBlock(), fork)) .thenReturn(completedFuture(blockSignature)); when(validatorApiChannel.createUnsignedBlock( - denebSlot, randaoReveal, Optional.of(graffiti), Optional.empty(), Optional.empty())) + denebSlot, randaoReveal, Optional.of(graffiti), Optional.empty())) .thenReturn(completedFuture(Optional.of(blockContainerAndMetaData))); when(validatorApiChannel.sendSignedBlock(any(), any())) .thenReturn(completedFuture(SendSignedBlockResult.success(unsignedBlindedBlock.getRoot()))); @@ -344,7 +344,7 @@ public void forDeneb_shouldFailWhenNoKzgProofs() { when(signer.signBlock(unsignedBlockContentsMock.getBlock(), fork)) .thenReturn(completedFuture(blockSignature)); when(validatorApiChannel.createUnsignedBlock( - denebSlot, randaoReveal, Optional.of(graffiti), Optional.empty(), Optional.empty())) + denebSlot, randaoReveal, Optional.of(graffiti), Optional.empty())) .thenReturn(completedFuture(Optional.of(blockContainerAndMetaData))); when(validatorApiChannel.sendSignedBlock(any(), any())) .thenReturn(completedFuture(SendSignedBlockResult.success(blockRoot))); @@ -388,7 +388,7 @@ public void forDeneb_shouldFailWhenNoBlobs() { when(signer.signBlock(unsignedBlockContentsMock.getBlock(), fork)) .thenReturn(completedFuture(blockSignature)); when(validatorApiChannel.createUnsignedBlock( - denebSlot, randaoReveal, Optional.of(graffiti), Optional.empty(), Optional.empty())) + denebSlot, randaoReveal, Optional.of(graffiti), Optional.empty())) .thenReturn(completedFuture(Optional.of(blockContainerAndMetaData))); when(validatorApiChannel.sendSignedBlock(any(), any())) .thenReturn(completedFuture(SendSignedBlockResult.success(blockRoot))); @@ -443,7 +443,7 @@ public void shouldFailWhenCreateUnsignedBlockFails() { when(signer.createRandaoReveal(spec.computeEpochAtSlot(CAPELLA_SLOT), fork)) .thenReturn(completedFuture(randaoReveal)); when(validatorApiChannel.createUnsignedBlock( - CAPELLA_SLOT, randaoReveal, Optional.of(graffiti), Optional.empty(), Optional.empty())) + CAPELLA_SLOT, randaoReveal, Optional.of(graffiti), Optional.empty())) .thenReturn(failedFuture(error)); assertDutyFails(error); @@ -459,7 +459,7 @@ public void shouldFailWhenCreateUnsignedBlockReturnsEmpty() { when(signer.createRandaoReveal(spec.computeEpochAtSlot(CAPELLA_SLOT), fork)) .thenReturn(completedFuture(randaoReveal)); when(validatorApiChannel.createUnsignedBlock( - CAPELLA_SLOT, randaoReveal, Optional.of(graffiti), Optional.empty(), Optional.empty())) + CAPELLA_SLOT, randaoReveal, Optional.of(graffiti), Optional.empty())) .thenReturn(completedFuture(Optional.empty())); performAndReportDuty(); @@ -486,7 +486,7 @@ public void shouldFailWhenSigningBlockFails() { when(signer.createRandaoReveal(spec.computeEpochAtSlot(CAPELLA_SLOT), fork)) .thenReturn(completedFuture(randaoReveal)); when(validatorApiChannel.createUnsignedBlock( - CAPELLA_SLOT, randaoReveal, Optional.of(graffiti), Optional.empty(), Optional.empty())) + CAPELLA_SLOT, randaoReveal, Optional.of(graffiti), Optional.empty())) .thenReturn(completedFuture(Optional.of(blockContainerAndMetaData))); when(signer.signBlock(blockContainerAndMetaData.blockContainer().getBlock(), fork)) .thenReturn(failedFuture(error)); @@ -526,7 +526,7 @@ public void shouldUseBlockV3ToCreateAndPublishBlock(final boolean isBlindedBlock when(signer.createRandaoReveal(spec.computeEpochAtSlot(CAPELLA_SLOT), fork)) .thenReturn(completedFuture(randaoReveal)); when(validatorApiChannel.createUnsignedBlock( - CAPELLA_SLOT, randaoReveal, Optional.of(graffiti), Optional.empty(), Optional.empty())) + CAPELLA_SLOT, randaoReveal, Optional.of(graffiti), Optional.empty())) .thenReturn(completedFuture(Optional.of(blockContainerAndMetaData))); when(signer.signBlock(blockContainerAndMetaData.blockContainer().getBlock(), fork)) .thenReturn(completedFuture(blockSignature)); @@ -538,8 +538,7 @@ public void shouldUseBlockV3ToCreateAndPublishBlock(final boolean isBlindedBlock performAndReportDuty(); verify(validatorApiChannel) - .createUnsignedBlock( - CAPELLA_SLOT, randaoReveal, Optional.of(graffiti), Optional.empty(), Optional.empty()); + .createUnsignedBlock(CAPELLA_SLOT, randaoReveal, Optional.of(graffiti), Optional.empty()); verify(validatorApiChannel).sendSignedBlock(signedBlock, BroadcastValidationLevel.GOSSIP); verify(validatorLogger) @@ -588,7 +587,7 @@ public void forDeneb_shouldUseBlockV3ToCreateAndPublishBlockContents() { when(signer.signBlock(unsignedBlockContents.getBlock(), fork)) .thenReturn(completedFuture(blockSignature)); when(validatorApiChannel.createUnsignedBlock( - denebSlot, randaoReveal, Optional.of(graffiti), Optional.empty(), Optional.empty())) + denebSlot, randaoReveal, Optional.of(graffiti), Optional.empty())) .thenReturn(completedFuture(Optional.of(blockContainerAndMetaData))); when(validatorApiChannel.sendSignedBlock(any(), any())) .thenReturn(completedFuture(SendSignedBlockResult.success(unsignedBlock.getRoot()))); @@ -596,8 +595,7 @@ public void forDeneb_shouldUseBlockV3ToCreateAndPublishBlockContents() { performAndReportDuty(denebSlot); verify(validatorApiChannel) - .createUnsignedBlock( - denebSlot, randaoReveal, Optional.of(graffiti), Optional.empty(), Optional.empty()); + .createUnsignedBlock(denebSlot, randaoReveal, Optional.of(graffiti), Optional.empty()); final ArgumentCaptor signedBlockContentsArgumentCaptor = ArgumentCaptor.forClass(SignedBlockContents.class); diff --git a/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/FailoverValidatorApiHandlerTest.java b/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/FailoverValidatorApiHandlerTest.java index c2f8ada3679..0ace2806300 100644 --- a/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/FailoverValidatorApiHandlerTest.java +++ b/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/FailoverValidatorApiHandlerTest.java @@ -584,8 +584,7 @@ public void publishesBlindedBlockOnlyToTheBeaconNodeWhichCreatedIt() { final ValidatorApiChannelRequest> creationRequest = apiChannel -> - apiChannel.createUnsignedBlock( - slot, randaoReveal, Optional.empty(), Optional.of(true), Optional.empty()); + apiChannel.createUnsignedBlock(slot, randaoReveal, Optional.empty(), Optional.empty()); setupFailures(creationRequest, primaryApiChannel); setupSuccesses(creationRequest, Optional.of(blindedBlock), failoverApiChannel1); @@ -687,7 +686,7 @@ private static Stream getRequestsUsingFailover() { "createUnsignedBlock", apiChannel -> apiChannel.createUnsignedBlock( - slot, randaoReveal, Optional.empty(), Optional.of(false), Optional.empty()), + slot, randaoReveal, Optional.empty(), Optional.empty()), BeaconNodeRequestLabels.CREATE_UNSIGNED_BLOCK_METHOD, Optional.of(mock(BlockContainerAndMetaData.class))), getArguments( diff --git a/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/RemoteValidatorApiHandlerTest.java b/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/RemoteValidatorApiHandlerTest.java index 27a9dd76ca9..df985465db5 100644 --- a/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/RemoteValidatorApiHandlerTest.java +++ b/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/RemoteValidatorApiHandlerTest.java @@ -470,7 +470,7 @@ public void createUnsignedBlock_WhenNoneFound_ReturnsEmpty() { SafeFuture> future = apiHandler.createUnsignedBlock( - ONE, blsSignature, Optional.of(Bytes32.random()), Optional.of(false), Optional.empty()); + ONE, blsSignature, Optional.of(Bytes32.random()), Optional.empty()); assertThat(unwrapToOptional(future)).isEmpty(); } diff --git a/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/sentry/SentryValidatorApiChannelTest.java b/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/sentry/SentryValidatorApiChannelTest.java index 95e5ac96803..4a743704c81 100644 --- a/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/sentry/SentryValidatorApiChannelTest.java +++ b/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/sentry/SentryValidatorApiChannelTest.java @@ -124,15 +124,11 @@ void getProposerDutiesShouldUseDutiesProviderChannel() { @Test void createUnsignedBlockShouldUseBlockHandlerChannelWhenAvailable() { sentryValidatorApiChannel.createUnsignedBlock( - UInt64.ZERO, BLSSignature.empty(), Optional.empty(), Optional.of(false), Optional.of(ONE)); + UInt64.ZERO, BLSSignature.empty(), Optional.empty(), Optional.of(ONE)); verify(blockHandlerChannel) .createUnsignedBlock( - eq(UInt64.ZERO), - eq(BLSSignature.empty()), - eq(Optional.empty()), - eq(Optional.of(false)), - eq(Optional.of(ONE))); + eq(UInt64.ZERO), eq(BLSSignature.empty()), eq(Optional.empty()), eq(Optional.of(ONE))); verifyNoInteractions(dutiesProviderChannel); verifyNoInteractions(attestationPublisherChannel); } @@ -144,15 +140,11 @@ void createUnsignedBlockShouldFallbackToDutiesProviderChannel() { dutiesProviderChannel, Optional.empty(), Optional.of(attestationPublisherChannel)); sentryValidatorApiChannel.createUnsignedBlock( - UInt64.ZERO, BLSSignature.empty(), Optional.empty(), Optional.of(false), Optional.of(ONE)); + UInt64.ZERO, BLSSignature.empty(), Optional.empty(), Optional.of(ONE)); verify(dutiesProviderChannel) .createUnsignedBlock( - eq(UInt64.ZERO), - eq(BLSSignature.empty()), - eq(Optional.empty()), - eq(Optional.of(false)), - eq(Optional.of(ONE))); + eq(UInt64.ZERO), eq(BLSSignature.empty()), eq(Optional.empty()), eq(Optional.of(ONE))); verifyNoInteractions(blockHandlerChannel); verifyNoInteractions(attestationPublisherChannel); } From a59953ea73358bf667d74840fb63cca8b0254f6c Mon Sep 17 00:00:00 2001 From: Gabriel Fukushima Date: Wed, 14 Aug 2024 16:54:54 +1000 Subject: [PATCH 11/19] fix tests Signed-off-by: Gabriel Fukushima --- .../BlockOperationSelectorFactoryTest.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactoryTest.java b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactoryTest.java index eebc6a32a3a..5b0311d1cac 100644 --- a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactoryTest.java +++ b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactoryTest.java @@ -484,9 +484,14 @@ void shouldIncludeExecutionPayloadHeaderIfBlindedBlockRequested() { dataStructureUtil.randomExecutionPayloadHeader(); final UInt256 blockExecutionValue = dataStructureUtil.randomUInt256(); + final ExecutionPayloadContext executionPayloadContextWithValidatorRegistration = + dataStructureUtil.randomPayloadExecutionContext(false,true); + when(forkChoiceNotifier.getPayloadId(any(), any())) + .thenReturn(SafeFuture.completedFuture(Optional.of(executionPayloadContextWithValidatorRegistration))); + prepareBlockProductionWithPayloadHeader( randomExecutionPayloadHeader, - executionPayloadContext, + executionPayloadContextWithValidatorRegistration, blockSlotState, Optional.of(blockExecutionValue)); @@ -717,9 +722,14 @@ void shouldIncludeKzgCommitmentsInBlindedBlock() { final SszList blobKzgCommitments = dataStructureUtil.randomBlobKzgCommitments(); + final ExecutionPayloadContext executionPayloadContextWithValidatorRegistration = + dataStructureUtil.randomPayloadExecutionContext(false,true); + when(forkChoiceNotifier.getPayloadId(any(), any())) + .thenReturn(SafeFuture.completedFuture(Optional.of(executionPayloadContextWithValidatorRegistration))); + prepareBlindedBlockAndBlobsProduction( randomExecutionPayloadHeader, - executionPayloadContext, + executionPayloadContextWithValidatorRegistration, blockSlotState, blobKzgCommitments, blockExecutionValue); @@ -733,7 +743,7 @@ void shouldIncludeKzgCommitmentsInBlindedBlock() { blockSlotState, dataStructureUtil.randomSignature(), Optional.empty(), - Optional.of(UInt64.ONE), + Optional.empty(), BlockProductionPerformance.NOOP) .apply(bodyBuilder)); From 46356e25b22fdef4fcf6b35585b4c542e508f691 Mon Sep 17 00:00:00 2001 From: Gabriel Fukushima Date: Wed, 14 Aug 2024 17:12:39 +1000 Subject: [PATCH 12/19] spotless Signed-off-by: Gabriel Fukushima --- .../BlockOperationSelectorFactoryTest.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactoryTest.java b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactoryTest.java index 5b0311d1cac..d44584b3875 100644 --- a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactoryTest.java +++ b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactoryTest.java @@ -485,9 +485,11 @@ void shouldIncludeExecutionPayloadHeaderIfBlindedBlockRequested() { final UInt256 blockExecutionValue = dataStructureUtil.randomUInt256(); final ExecutionPayloadContext executionPayloadContextWithValidatorRegistration = - dataStructureUtil.randomPayloadExecutionContext(false,true); + dataStructureUtil.randomPayloadExecutionContext(false, true); when(forkChoiceNotifier.getPayloadId(any(), any())) - .thenReturn(SafeFuture.completedFuture(Optional.of(executionPayloadContextWithValidatorRegistration))); + .thenReturn( + SafeFuture.completedFuture( + Optional.of(executionPayloadContextWithValidatorRegistration))); prepareBlockProductionWithPayloadHeader( randomExecutionPayloadHeader, @@ -723,9 +725,11 @@ void shouldIncludeKzgCommitmentsInBlindedBlock() { dataStructureUtil.randomBlobKzgCommitments(); final ExecutionPayloadContext executionPayloadContextWithValidatorRegistration = - dataStructureUtil.randomPayloadExecutionContext(false,true); + dataStructureUtil.randomPayloadExecutionContext(false, true); when(forkChoiceNotifier.getPayloadId(any(), any())) - .thenReturn(SafeFuture.completedFuture(Optional.of(executionPayloadContextWithValidatorRegistration))); + .thenReturn( + SafeFuture.completedFuture( + Optional.of(executionPayloadContextWithValidatorRegistration))); prepareBlindedBlockAndBlobsProduction( randomExecutionPayloadHeader, From 6a6a6858e620b7f475dadd71a068c7b6a420be35 Mon Sep 17 00:00:00 2001 From: Gabriel Fukushima Date: Wed, 14 Aug 2024 17:23:00 +1000 Subject: [PATCH 13/19] remove redundant ITs Signed-off-by: Gabriel Fukushima --- .../OkHttpValidatorTypeDefClientTest.java | 77 ------------------- 1 file changed, 77 deletions(-) diff --git a/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClientTest.java b/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClientTest.java index 9b054cc89da..a6cd8164f50 100644 --- a/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClientTest.java +++ b/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClientTest.java @@ -147,48 +147,6 @@ public void createSyncCommitteeContribution_whenNotFound_returnsEmpty() { .isEmpty(); } - @TestTemplate - void blockProductionFallbacksToNonBlindedFlowIfBlindedEndpointIsNotAvailable() - throws JsonProcessingException, InterruptedException { - assumeThat(specMilestone).isGreaterThanOrEqualTo(BELLATRIX); - // simulating blinded endpoint returning 404 Not Found - mockWebServer.enqueue(new MockResponse().setResponseCode(404)); - - final BlockContainer blockContainer; - if (specMilestone.isGreaterThanOrEqualTo(SpecMilestone.DENEB)) { - blockContainer = dataStructureUtil.randomBlockContents(ONE); - } else { - blockContainer = dataStructureUtil.randomBeaconBlock(ONE); - } - - mockWebServer.enqueue( - new MockResponse() - .setResponseCode(200) - .setBody( - "{\"data\": " - + serializeBlockContainer(blockContainer) - + ", \"version\": \"" - + specMilestone - + "\"}")); - - final Optional maybeBlockContainerAndMetaData = - typeDefClient.createUnsignedBlock( - dataStructureUtil.randomUInt64(), - dataStructureUtil.randomSignature(), - Optional.empty(), - Optional.empty()); - - assertThat(maybeBlockContainerAndMetaData.map(BlockContainerAndMetaData::blockContainer)) - .hasValue(blockContainer); - - assertThat(mockWebServer.getRequestCount()).isEqualTo(2); - - final RecordedRequest firstRequest = mockWebServer.takeRequest(); - assertThat(firstRequest.getPath()).startsWith("/eth/v1/validator/blinded_blocks"); - final RecordedRequest secondRequest = mockWebServer.takeRequest(); - assertThat(secondRequest.getPath()).startsWith("/eth/v3/validator/blocks"); - } - @TestTemplate void publishesBlindedBlockSszEncoded() throws InterruptedException { mockWebServer.enqueue(new MockResponse().setResponseCode(200)); @@ -376,41 +334,6 @@ void registerValidators_fallbacksToJsonIfSszNotSupported() throws InterruptedExc verifyRegisterValidatorsPostRequest(mockWebServer.takeRequest(), JSON_CONTENT_TYPE); } - @TestTemplate - void blockV3ShouldFallbacksToBlockV2WhenNotFound() - throws JsonProcessingException, InterruptedException { - mockWebServer.enqueue(new MockResponse().setResponseCode(404)); - - final BlockContainer blockContainer = dataStructureUtil.randomBlindedBeaconBlock(); - - mockWebServer.enqueue( - new MockResponse() - .setResponseCode(200) - .setBody( - "{\"data\": " - + serializeBlockContainer(blockContainer) - + ", \"version\": \"" - + specMilestone - + "\"}")); - - final Optional maybeBlockContainerAndMetaData = - typeDefClient.createUnsignedBlock( - dataStructureUtil.randomUInt64(), - dataStructureUtil.randomSignature(), - Optional.empty(), - Optional.empty()); - - assertThat(maybeBlockContainerAndMetaData.map(BlockContainerAndMetaData::blockContainer)) - .hasValue(blockContainer); - - assertThat(mockWebServer.getRequestCount()).isEqualTo(2); - - final RecordedRequest firstRequest = mockWebServer.takeRequest(); - assertThat(firstRequest.getPath()).startsWith("/eth/v3/validator/blocks"); - final RecordedRequest secondRequest = mockWebServer.takeRequest(); - assertThat(secondRequest.getPath()).startsWith("/eth/v1/validator/blinded_blocks"); - } - @TestTemplate void postValidators_makesExpectedRequest() throws Exception { mockWebServer.enqueue(new MockResponse().setResponseCode(SC_NO_CONTENT)); From 18530587d03b38ad87f27e137a68a1e1f9774031 Mon Sep 17 00:00:00 2001 From: Gabriel Fukushima Date: Wed, 14 Aug 2024 18:07:05 +1000 Subject: [PATCH 14/19] spotless Signed-off-by: Gabriel Fukushima --- .../remote/typedef/OkHttpValidatorTypeDefClientTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClientTest.java b/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClientTest.java index a6cd8164f50..b74977b2182 100644 --- a/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClientTest.java +++ b/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClientTest.java @@ -63,13 +63,11 @@ import tech.pegasys.teku.infrastructure.ssz.SszDataAssert; import tech.pegasys.teku.infrastructure.ssz.SszList; import tech.pegasys.teku.infrastructure.unsigned.UInt64; -import tech.pegasys.teku.spec.SpecMilestone; import tech.pegasys.teku.spec.TestSpecContext; import tech.pegasys.teku.spec.TestSpecInvocationContextProvider.SpecContext; import tech.pegasys.teku.spec.datastructures.blocks.BlockContainer; import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock; import tech.pegasys.teku.spec.datastructures.builder.SignedValidatorRegistration; -import tech.pegasys.teku.spec.datastructures.metadata.BlockContainerAndMetaData; import tech.pegasys.teku.spec.datastructures.metadata.ObjectAndMetaData; import tech.pegasys.teku.spec.datastructures.operations.Attestation; import tech.pegasys.teku.spec.datastructures.operations.versions.altair.SignedContributionAndProof; From 2ec44e8cb6c1a9be62ce1bfa7686c1fe303321f3 Mon Sep 17 00:00:00 2001 From: Gabriel Fukushima Date: Thu, 15 Aug 2024 11:09:03 +1000 Subject: [PATCH 15/19] removed unused method Signed-off-by: Gabriel Fukushima --- .../typedef/OkHttpValidatorTypeDefClientTest.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClientTest.java b/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClientTest.java index b74977b2182..65ad0940c78 100644 --- a/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClientTest.java +++ b/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClientTest.java @@ -65,7 +65,6 @@ import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.spec.TestSpecContext; import tech.pegasys.teku.spec.TestSpecInvocationContextProvider.SpecContext; -import tech.pegasys.teku.spec.datastructures.blocks.BlockContainer; import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock; import tech.pegasys.teku.spec.datastructures.builder.SignedValidatorRegistration; import tech.pegasys.teku.spec.datastructures.metadata.ObjectAndMetaData; @@ -766,13 +765,4 @@ private void assertJsonEquals(final String actual, final String expected) { Assertions.fail(ex); } } - - private String serializeBlockContainer(final BlockContainer blockContainer) - throws JsonProcessingException { - return serialize( - blockContainer, - blockContainer.isBlinded() - ? schemaDefinitions.getBlindedBlockContainerSchema().getJsonTypeDefinition() - : schemaDefinitions.getBlockContainerSchema().getJsonTypeDefinition()); - } } From 8ab3f75cc4b6c146a159a9ecb557006d89f5d1f6 Mon Sep 17 00:00:00 2001 From: Gabriel Fukushima Date: Fri, 16 Aug 2024 11:28:50 +1000 Subject: [PATCH 16/19] PR review suggestion Signed-off-by: Gabriel Fukushima --- .../coordinator/BlockOperationSelectorFactory.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java index 00342df3a1b..43f3683a9f2 100644 --- a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java +++ b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java @@ -218,12 +218,6 @@ private SafeFuture setExecutionData( blockSlotState.getSlot())); } - // We should run Builder flow (blinded) only if we have a validator registration - final boolean shouldTryBuilderFlow = - executionPayloadContext - .map(ExecutionPayloadContext::isValidatorRegistrationPresent) - .orElse(false); - // pre-Merge Execution Payload / Execution Payload Header if (executionPayloadContext.isEmpty()) { @@ -235,6 +229,12 @@ private SafeFuture setExecutionData( return SafeFuture.COMPLETE; } + // We should run Builder flow (blinded) only if we have a validator registration + final boolean shouldTryBuilderFlow = + executionPayloadContext + .map(ExecutionPayloadContext::isValidatorRegistrationPresent) + .orElse(false); + final ExecutionPayloadResult executionPayloadResult = executionLayerBlockProductionManager.initiateBlockProduction( executionPayloadContext.orElseThrow(), From fbe3836cc34026d14e62a4bdaa1bb2d1686d15c2 Mon Sep 17 00:00:00 2001 From: Gabriel Fukushima Date: Mon, 19 Aug 2024 12:11:08 +1000 Subject: [PATCH 17/19] clean up deprecated log warn Signed-off-by: Gabriel Fukushima --- .../remote/typedef/OkHttpValidatorTypeDefClient.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClient.java b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClient.java index d846b3b3f45..ea06b83326b 100644 --- a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClient.java +++ b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClient.java @@ -152,12 +152,7 @@ public Optional createUnsignedBlock( final ProduceBlockRequest produceBlockRequest = new ProduceBlockRequest( getBaseEndpoint(), getOkHttpClient(), spec, slot, preferSszBlockEncoding); - try { - return produceBlockRequest.submit(randaoReveal, graffiti, requestedBuilderBoostFactor); - } catch (final BlockProductionV3FailedException ex) { - LOG.warn("Produce Block V3 request failed at slot {}.", slot); - return Optional.empty(); - } + return produceBlockRequest.submit(randaoReveal, graffiti, requestedBuilderBoostFactor); } public void registerValidators( From 713f7e08dc6b261ddf24b98a6e60968c7a067457 Mon Sep 17 00:00:00 2001 From: Gabriel Fukushima Date: Tue, 20 Aug 2024 12:14:10 +1000 Subject: [PATCH 18/19] fix AT Signed-off-by: Gabriel Fukushima --- .../BlockOperationSelectorFactory.java | 5 ---- .../BlockOperationSelectorFactoryTest.java | 26 ------------------- 2 files changed, 31 deletions(-) diff --git a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java index 43f3683a9f2..be7cc850166 100644 --- a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java +++ b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java @@ -220,12 +220,7 @@ private SafeFuture setExecutionData( // pre-Merge Execution Payload / Execution Payload Header if (executionPayloadContext.isEmpty()) { - - bodyBuilder.executionPayloadHeader( - schemaDefinitions.getExecutionPayloadHeaderSchema().getHeaderOfDefaultPayload()); - bodyBuilder.executionPayload(schemaDefinitions.getExecutionPayloadSchema().getDefault()); - return SafeFuture.COMPLETE; } diff --git a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactoryTest.java b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactoryTest.java index d44584b3875..bc772c4cafa 100644 --- a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactoryTest.java +++ b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactoryTest.java @@ -175,11 +175,6 @@ class BlockOperationSelectorFactoryTest { .getExecutionPayloadSchema() .getDefault(); - private final ExecutionPayloadHeader executionPayloadHeaderOfDefaultPayload = - SchemaDefinitionsBellatrix.required(specBellatrix.getGenesisSpec().getSchemaDefinitions()) - .getExecutionPayloadHeaderSchema() - .getHeaderOfDefaultPayload(); - private final CapturingBeaconBlockBodyBuilder bodyBuilder = new CapturingBeaconBlockBodyBuilder(false); @@ -425,27 +420,6 @@ void shouldIncludeDefaultExecutionPayload() { assertThat(bodyBuilder.executionPayload).isEqualTo(defaultExecutionPayload); } - @Test - void shouldIncludeExecutionPayloadHeaderOfDefaultPayload() { - final UInt64 slot = UInt64.ONE; - final BeaconState blockSlotState = dataStructureUtil.randomBeaconStatePreMerge(slot); - when(forkChoiceNotifier.getPayloadId(any(), any())) - .thenReturn(SafeFuture.completedFuture(Optional.empty())); - - safeJoin( - factoryBellatrix - .createSelector( - parentRoot, - blockSlotState, - dataStructureUtil.randomSignature(), - Optional.empty(), - Optional.empty(), - BlockProductionPerformance.NOOP) - .apply(bodyBuilder)); - assertThat(bodyBuilder.executionPayloadHeader) - .isEqualTo(executionPayloadHeaderOfDefaultPayload); - } - @Test void shouldIncludeNonDefaultExecutionPayload() { final UInt64 slot = UInt64.ONE; From c98b937cd913d547fe153344c9cd13f937f8d6bf Mon Sep 17 00:00:00 2001 From: Gabriel Fukushima Date: Wed, 21 Aug 2024 10:06:48 +1000 Subject: [PATCH 19/19] remove fallback catch and fix IT Signed-off-by: Gabriel Fukushima --- .../remote/typedef/handlers/ProduceBlockRequestTest.java | 8 ++++---- .../remote/typedef/handlers/ProduceBlockRequest.java | 9 +-------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/handlers/ProduceBlockRequestTest.java b/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/handlers/ProduceBlockRequestTest.java index 3b048f72fd3..2a926998a11 100644 --- a/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/handlers/ProduceBlockRequestTest.java +++ b/validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/handlers/ProduceBlockRequestTest.java @@ -272,7 +272,7 @@ public void shouldPassUrlParameters() throws InterruptedException { mockWebServer.enqueue(new MockResponse().setResponseCode(SC_NOT_FOUND)); // no optional parameters - assertThatThrownBy(() -> request.submit(signature, Optional.empty(), Optional.empty())); + assertThat(request.submit(signature, Optional.empty(), Optional.empty())).isEmpty(); recordedRequest = mockWebServer.takeRequest(); @@ -285,9 +285,9 @@ public void shouldPassUrlParameters() throws InterruptedException { mockWebServer.enqueue(new MockResponse().setResponseCode(SC_NOT_FOUND)); // with all parameters - assertThatThrownBy( - () -> - request.submit(signature, Optional.of(Bytes32.ZERO), Optional.of(UInt64.valueOf(48)))); + assertThat( + request.submit(signature, Optional.of(Bytes32.ZERO), Optional.of(UInt64.valueOf(48)))) + .isEmpty(); recordedRequest = mockWebServer.takeRequest(); diff --git a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/typedef/handlers/ProduceBlockRequest.java b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/typedef/handlers/ProduceBlockRequest.java index b6998fb871d..d925dd838e7 100644 --- a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/typedef/handlers/ProduceBlockRequest.java +++ b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/typedef/handlers/ProduceBlockRequest.java @@ -14,7 +14,6 @@ package tech.pegasys.teku.validator.remote.typedef.handlers; import static java.util.Collections.emptyMap; -import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_NOT_FOUND; import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_OK; import static tech.pegasys.teku.infrastructure.http.RestApiConstants.BUILDER_BOOST_FACTOR; import static tech.pegasys.teku.infrastructure.http.RestApiConstants.CONSENSUS_BLOCK_VALUE; @@ -54,7 +53,6 @@ import tech.pegasys.teku.spec.datastructures.blocks.BlockContainer; import tech.pegasys.teku.spec.datastructures.blocks.BlockContainerSchema; import tech.pegasys.teku.spec.datastructures.metadata.BlockContainerAndMetaData; -import tech.pegasys.teku.validator.remote.typedef.BlockProductionV3FailedException; import tech.pegasys.teku.validator.remote.typedef.ResponseHandler; public class ProduceBlockRequest extends AbstractTypeDefRequest { @@ -99,12 +97,7 @@ public ProduceBlockRequest( this.responseHandler = new ResponseHandler<>(produceBlockTypeDefinition) - .withHandler(SC_OK, this::handleBlockContainerResult) - .withHandler( - SC_NOT_FOUND, - (__, ___) -> { - throw new BlockProductionV3FailedException(); - }); + .withHandler(SC_OK, this::handleBlockContainerResult); } public Optional submit(