From 9e8fe0da0dd52497d96eb4f8245d6a3997a3f7a5 Mon Sep 17 00:00:00 2001 From: Enrico Del Fante Date: Thu, 14 Apr 2022 08:54:18 +0200 Subject: [PATCH] [MEV boost] improve blinded block validator options and flow handling (#5341) * improve blinded block validator options * automatically enable blinded-blocks when mev-boost is enabled --- .../teku/core/signatures/LocalSignerTest.java | 14 +++++++++ .../teku/spec/util/DataStructureUtil.java | 4 +++ .../teku/cli/options/ValidatorOptions.java | 13 -------- .../cli/options/ValidatorProposerOptions.java | 15 +++++++++- .../teku/cli/subcommand/RemoteSpecLoader.java | 5 +--- .../cli/options/ValidatorOptionsTest.java | 22 ++++++++++++-- .../teku/validator/api/ValidatorConfig.java | 30 +++++++++++++------ .../client/ValidatorClientService.java | 11 +++---- .../client/duties/BlockDutyFactory.java | 7 +++-- .../client/duties/BlockProductionDuty.java | 5 +++- .../duties/BlockProductionDutyTest.java | 26 ++++++++++++---- .../validator/remote/RemoteBeaconNodeApi.java | 5 ++-- .../OkHttpValidatorRestApiClient.java | 9 ++---- .../remote/RemoteBeaconNodeApiTest.java | 2 +- .../OkHttpValidatorRestApiClientTest.java | 10 +++---- 15 files changed, 117 insertions(+), 61 deletions(-) diff --git a/ethereum/core/src/test/java/tech/pegasys/teku/core/signatures/LocalSignerTest.java b/ethereum/core/src/test/java/tech/pegasys/teku/core/signatures/LocalSignerTest.java index 5343d4d6431..f99290029fa 100644 --- a/ethereum/core/src/test/java/tech/pegasys/teku/core/signatures/LocalSignerTest.java +++ b/ethereum/core/src/test/java/tech/pegasys/teku/core/signatures/LocalSignerTest.java @@ -56,6 +56,20 @@ public void shouldSignBlock() { assertThat(result).isCompletedWithValue(expectedSignature); } + @Test + public void shouldSignBlindedBlock() { + final BeaconBlock block = dataStructureUtil.randomBlindedBeaconBlock(10); + final BLSSignature expectedSignature = + BLSSignature.fromBytesCompressed( + Bytes.fromBase64String( + "pbSSuf7h70JkzI/U157flTWPZDuaBXgRLj1HLMoCwjA4Xd0hMdGewn7G2HLZiQcNC9G6FSd1+0BT5PwknYez4ya6TccwpaGnsvWYLPf3SNIX5Ug7Yi1CF1fvEr3x9sZ0")); + + final SafeFuture result = signer.signBlock(block, fork); + asyncRunner.executeQueuedActions(); + + assertThat(result).isCompletedWithValue(expectedSignature); + } + @Test public void shouldCreateRandaoReveal() { final BLSSignature expectedSignature = diff --git a/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/util/DataStructureUtil.java b/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/util/DataStructureUtil.java index 488bbba7112..1b5b456f5c8 100644 --- a/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/util/DataStructureUtil.java +++ b/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/util/DataStructureUtil.java @@ -708,6 +708,10 @@ public BeaconBlock randomBeaconBlock(UInt64 slotNum) { body); } + public BeaconBlock randomBlindedBeaconBlock(long slotNum) { + return randomBlindedBeaconBlock(UInt64.valueOf(slotNum)); + } + public BeaconBlock randomBlindedBeaconBlock(UInt64 slotNum) { final UInt64 proposerIndex = randomUInt64(); Bytes32 previousRoot = randomBytes32(); 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 462f2198243..ab1978b7444 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 @@ -13,8 +13,6 @@ package tech.pegasys.teku.cli.options; -import static tech.pegasys.teku.validator.api.ValidatorConfig.DEFAULT_VALIDATOR_BLINDED_BLOCKS_ENABLED; - import java.nio.file.Path; import java.util.Optional; import org.apache.tuweni.bytes.Bytes32; @@ -102,16 +100,6 @@ public class ValidatorOptions { arity = "0..1") private boolean generateEarlyAttestations = ValidatorConfig.DEFAULT_GENERATE_EARLY_ATTESTATIONS; - @Option( - names = {"--Xvalidators-blinded-blocks-api-enabled"}, - paramLabel = "", - showDefaultValue = Visibility.ALWAYS, - description = "Use blinded block api calls", - fallbackValue = "true", - hidden = true, - arity = "0..1") - private boolean blindedBlocksApiEnabled = DEFAULT_VALIDATOR_BLINDED_BLOCKS_ENABLED; - public void configure(TekuConfiguration.Builder builder) { if (validatorPerformanceTrackingEnabled != null) { if (validatorPerformanceTrackingEnabled) { @@ -125,7 +113,6 @@ public void configure(TekuConfiguration.Builder builder) { config -> config .validatorKeystoreLockingEnabled(validatorKeystoreLockingEnabled) - .blindedBeaconBlocksApiEnabled(blindedBlocksApiEnabled) .validatorPerformanceTrackingMode(validatorPerformanceTrackingMode) .validatorExternalSignerSlashingProtectionEnabled( validatorExternalSignerSlashingProtectionEnabled) diff --git a/teku/src/main/java/tech/pegasys/teku/cli/options/ValidatorProposerOptions.java b/teku/src/main/java/tech/pegasys/teku/cli/options/ValidatorProposerOptions.java index cec5556348a..ab15a78a8bc 100644 --- a/teku/src/main/java/tech/pegasys/teku/cli/options/ValidatorProposerOptions.java +++ b/teku/src/main/java/tech/pegasys/teku/cli/options/ValidatorProposerOptions.java @@ -13,6 +13,8 @@ package tech.pegasys.teku.cli.options; +import static tech.pegasys.teku.validator.api.ValidatorConfig.DEFAULT_VALIDATOR_BLINDED_BLOCKS_ENABLED; + import picocli.CommandLine.Help.Visibility; import picocli.CommandLine.Option; import tech.pegasys.teku.config.TekuConfiguration; @@ -56,6 +58,16 @@ public class ValidatorProposerOptions { private boolean proposerMevBoostEnabled = ValidatorConfig.DEFAULT_VALIDATOR_PROPOSER_MEV_BOOST_ENABLED; + @Option( + names = {"--Xvalidators-proposer-blinded-blocks-enabled"}, + paramLabel = "", + showDefaultValue = Visibility.ALWAYS, + description = "Use blinded blocks when in block production duties", + fallbackValue = "true", + hidden = true, + arity = "0..1") + private boolean blindedBlocksEnabled = DEFAULT_VALIDATOR_BLINDED_BLOCKS_ENABLED; + public void configure(TekuConfiguration.Builder builder) { builder.validator( config -> @@ -63,6 +75,7 @@ public void configure(TekuConfiguration.Builder builder) { .proposerDefaultFeeRecipient(proposerDefaultFeeRecipient) .proposerConfigSource(proposerConfig) .refreshProposerConfigFromSource(proposerConfigRefreshEnabled) - .proposerMevBoostEnabled(proposerMevBoostEnabled)); + .proposerMevBoostEnabled(proposerMevBoostEnabled) + .blindedBeaconBlocksEnabled(blindedBlocksEnabled)); } } diff --git a/teku/src/main/java/tech/pegasys/teku/cli/subcommand/RemoteSpecLoader.java b/teku/src/main/java/tech/pegasys/teku/cli/subcommand/RemoteSpecLoader.java index fd8278d7fc3..c8027a7b0a6 100644 --- a/teku/src/main/java/tech/pegasys/teku/cli/subcommand/RemoteSpecLoader.java +++ b/teku/src/main/java/tech/pegasys/teku/cli/subcommand/RemoteSpecLoader.java @@ -13,8 +13,6 @@ package tech.pegasys.teku.cli.subcommand; -import static tech.pegasys.teku.validator.api.ValidatorConfig.DEFAULT_VALIDATOR_BLINDED_BLOCKS_ENABLED; - import java.net.URI; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; @@ -91,7 +89,6 @@ static OkHttpValidatorRestApiClient createApiClient(final URI baseEndpoint) { // Strip any authentication info from the URL to ensure it doesn't get logged. apiEndpoint = apiEndpoint.newBuilder().username("").password("").build(); final OkHttpClient okHttpClient = httpClientBuilder.build(); - return new OkHttpValidatorRestApiClient( - apiEndpoint, okHttpClient, DEFAULT_VALIDATOR_BLINDED_BLOCKS_ENABLED); + return new OkHttpValidatorRestApiClient(apiEndpoint, okHttpClient); } } diff --git a/teku/src/test/java/tech/pegasys/teku/cli/options/ValidatorOptionsTest.java b/teku/src/test/java/tech/pegasys/teku/cli/options/ValidatorOptionsTest.java index 50fe3a88839..43973bed120 100644 --- a/teku/src/test/java/tech/pegasys/teku/cli/options/ValidatorOptionsTest.java +++ b/teku/src/test/java/tech/pegasys/teku/cli/options/ValidatorOptionsTest.java @@ -119,9 +119,9 @@ public void shouldReportAddressIfFeeRecipientSpecified() { @Test public void shouldEnableBlindedBeaconBlocks() { - final String[] args = {"--Xvalidators-blinded-blocks-api-enabled", "true"}; + final String[] args = {"--Xvalidators-proposer-blinded-blocks-enabled", "true"}; final TekuConfiguration config = getTekuConfigurationFromArguments(args); - assertThat(config.validatorClient().getValidatorConfig().isBlindedBeaconBlocksApiEnabled()) + assertThat(config.validatorClient().getValidatorConfig().isBlindedBeaconBlocksEnabled()) .isTrue(); } @@ -129,7 +129,23 @@ public void shouldEnableBlindedBeaconBlocks() { public void shouldNotUseBlindedBeaconBlocksByDefault() { final String[] args = {}; final TekuConfiguration config = getTekuConfigurationFromArguments(args); - assertThat(config.validatorClient().getValidatorConfig().isBlindedBeaconBlocksApiEnabled()) + assertThat(config.validatorClient().getValidatorConfig().isBlindedBeaconBlocksEnabled()) .isFalse(); } + + @Test + public void shouldEnableMevBoostWithBlindedBlocks() { + final String[] args = {"--Xvalidators-proposer-mev-boost-enabled", "true"}; + final TekuConfiguration config = getTekuConfigurationFromArguments(args); + assertThat(config.validatorClient().getValidatorConfig().isProposerMevBoostEnabled()).isTrue(); + assertThat(config.validatorClient().getValidatorConfig().isBlindedBeaconBlocksEnabled()) + .isTrue(); + } + + @Test + public void shouldNotUseMevBoostByDefault() { + final String[] args = {}; + final TekuConfiguration config = getTekuConfigurationFromArguments(args); + assertThat(config.validatorClient().getValidatorConfig().isProposerMevBoostEnabled()).isFalse(); + } } 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 9c1719ea993..efac19d78b4 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 @@ -23,11 +23,14 @@ import java.util.List; import java.util.Optional; import org.apache.commons.lang3.tuple.Pair; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes32; import tech.pegasys.teku.infrastructure.exceptions.InvalidConfigurationException; import tech.pegasys.teku.spec.datastructures.eth1.Eth1Address; public class ValidatorConfig { + private static final Logger LOG = LogManager.getLogger(); private static final int DEFAULT_REST_API_PORT = 5051; public static final String DEFAULT_BEACON_NODE_API_ENDPOINT = @@ -60,7 +63,7 @@ public class ValidatorConfig { private final Optional proposerDefaultFeeRecipient; private final Optional proposerConfigSource; private final boolean refreshProposerConfigFromSource; - private final boolean blindedBeaconBlocksApiEnabled; + private final boolean blindedBeaconBlocksEnabled; private final boolean proposerMevBoostEnabled; private ValidatorConfig( @@ -83,7 +86,7 @@ private ValidatorConfig( final Optional proposerConfigSource, final boolean refreshProposerConfigFromSource, final boolean proposerMevBoostEnabled, - final boolean blindedBeaconBlocksApiEnabled) { + final boolean blindedBeaconBlocksEnabled) { this.validatorKeys = validatorKeys; this.validatorExternalSignerPublicKeySources = validatorExternalSignerPublicKeySources; this.validatorExternalSignerUrl = validatorExternalSignerUrl; @@ -105,7 +108,7 @@ private ValidatorConfig( this.proposerDefaultFeeRecipient = proposerDefaultFeeRecipient; this.proposerConfigSource = proposerConfigSource; this.refreshProposerConfigFromSource = refreshProposerConfigFromSource; - this.blindedBeaconBlocksApiEnabled = blindedBeaconBlocksApiEnabled; + this.blindedBeaconBlocksEnabled = blindedBeaconBlocksEnabled; this.proposerMevBoostEnabled = proposerMevBoostEnabled; } @@ -180,8 +183,8 @@ public boolean getRefreshProposerConfigFromSource() { return refreshProposerConfigFromSource; } - public boolean isBlindedBeaconBlocksApiEnabled() { - return blindedBeaconBlocksApiEnabled; + public boolean isBlindedBeaconBlocksEnabled() { + return blindedBeaconBlocksEnabled; } public boolean isProposerMevBoostEnabled() { @@ -222,7 +225,7 @@ public static final class Builder { private boolean refreshProposerConfigFromSource = DEFAULT_VALIDATOR_PROPOSER_CONFIG_REFRESH_ENABLED; private boolean proposerMevBoostEnabled = DEFAULT_VALIDATOR_PROPOSER_MEV_BOOST_ENABLED; - private boolean blindedBlocksApiEnabled = DEFAULT_VALIDATOR_BLINDED_BLOCKS_ENABLED; + private boolean blindedBlocksEnabled = DEFAULT_VALIDATOR_BLINDED_BLOCKS_ENABLED; private Builder() {} @@ -353,8 +356,8 @@ public Builder proposerMevBoostEnabled(final boolean proposerMevBoostEnabled) { return this; } - public Builder blindedBeaconBlocksApiEnabled(final boolean blindedBeaconBlockEnabled) { - this.blindedBlocksApiEnabled = blindedBeaconBlockEnabled; + public Builder blindedBeaconBlocksEnabled(final boolean blindedBeaconBlockEnabled) { + this.blindedBlocksEnabled = blindedBeaconBlockEnabled; return this; } @@ -363,6 +366,7 @@ public ValidatorConfig build() { validateExternalSignerKeystoreAndPasswordFileConfig(); validateExternalSignerTruststoreAndPasswordFileConfig(); validateExternalSignerURLScheme(); + validateMevBoostAndBlindedBlocks(); return new ValidatorConfig( validatorKeys, validatorExternalSignerPublicKeySources, @@ -383,7 +387,7 @@ public ValidatorConfig build() { proposerConfigSource, refreshProposerConfigFromSource, proposerMevBoostEnabled, - blindedBlocksApiEnabled); + blindedBlocksEnabled); } private void validateExternalSignerUrlAndPublicKeys() { @@ -432,6 +436,14 @@ private void validateExternalSignerURLScheme() { } } + private void validateMevBoostAndBlindedBlocks() { + if (proposerMevBoostEnabled && !blindedBlocksEnabled) { + LOG.info( + "'--Xvalidators-proposer-mev-boost-enabled' requires '--Xvalidators-proposer-blinded-blocks-enabled', enabling it"); + blindedBlocksEnabled = true; + } + } + private static boolean isURLSchemeHttps(final URL url) { final String protocol = url.getProtocol(); return protocol != null && protocol.equalsIgnoreCase("https"); 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 3ff8efe9a27..f4bffc91fe6 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 @@ -99,8 +99,6 @@ public static ValidatorClientService create( final AsyncRunner asyncRunner = services.createAsyncRunner("validator"); final boolean generateEarlyAttestations = config.getValidatorConfig().generateEarlyAttestations(); - final boolean blindedBlocksEnabled = - config.getValidatorConfig().isBlindedBeaconBlocksApiEnabled(); final BeaconNodeApi beaconNodeApi = config .getValidatorConfig() @@ -112,8 +110,7 @@ public static ValidatorClientService create( asyncRunner, endpoint, config.getSpec(), - generateEarlyAttestations, - blindedBlocksEnabled)) + generateEarlyAttestations)) .orElseGet( () -> InProcessBeaconNodeApi.create( @@ -194,7 +191,11 @@ private void initializeValidators( this.validatorIndexProvider = new ValidatorIndexProvider(validators, validatorApiChannel, asyncRunner); final BlockDutyFactory blockDutyFactory = - new BlockDutyFactory(forkProvider, validatorApiChannel, spec); + new BlockDutyFactory( + forkProvider, + validatorApiChannel, + config.getValidatorConfig().isBlindedBeaconBlocksEnabled(), + spec); final AttestationDutyFactory attestationDutyFactory = new AttestationDutyFactory(spec, forkProvider, validatorApiChannel); 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 31bad967f03..fe1a62308b3 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 @@ -24,20 +24,23 @@ public class BlockDutyFactory implements DutyFactory private final ForkProvider forkProvider; private final ValidatorApiChannel validatorApiChannel; private final Spec spec; + private final boolean useBlindedBlock; public BlockDutyFactory( final ForkProvider forkProvider, final ValidatorApiChannel validatorApiChannel, + final boolean useBlindedBlock, final Spec spec) { this.forkProvider = forkProvider; - + this.useBlindedBlock = useBlindedBlock; this.validatorApiChannel = validatorApiChannel; this.spec = spec; } @Override public BlockProductionDuty createProductionDuty(final UInt64 slot, final Validator validator) { - return new BlockProductionDuty(validator, slot, forkProvider, validatorApiChannel, spec); + return new BlockProductionDuty( + validator, slot, forkProvider, validatorApiChannel, useBlindedBlock, spec); } @Override 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 a9df8da5ffb..e2af989d6fc 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 @@ -35,6 +35,7 @@ public class BlockProductionDuty implements Duty { private final UInt64 slot; private final ForkProvider forkProvider; private final ValidatorApiChannel validatorApiChannel; + private final boolean useBlindedBlock; private final Spec spec; public BlockProductionDuty( @@ -42,11 +43,13 @@ public BlockProductionDuty( final UInt64 slot, final ForkProvider forkProvider, final ValidatorApiChannel validatorApiChannel, + final boolean useBlindedBlock, final Spec spec) { this.validator = validator; this.slot = slot; this.forkProvider = forkProvider; this.validatorApiChannel = validatorApiChannel; + this.useBlindedBlock = useBlindedBlock; this.spec = spec; } @@ -82,7 +85,7 @@ private SafeFuture sendBlock(final SignedBeaconBlock signedBlock) { public SafeFuture> createUnsignedBlock(final BLSSignature randaoReveal) { return validatorApiChannel.createUnsignedBlock( - slot, randaoReveal, validator.getGraffiti(), false); + slot, randaoReveal, validator.getGraffiti(), useBlindedBlock); } public SafeFuture createRandaoReveal(final ForkInfo forkInfo) { 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 d03cc6b3e32..0f2be50d2da 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 @@ -28,6 +28,8 @@ import org.apache.tuweni.bytes.Bytes32; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import tech.pegasys.teku.bls.BLSSignature; import tech.pegasys.teku.core.signatures.Signer; import tech.pegasys.teku.infrastructure.async.SafeFuture; @@ -62,22 +64,34 @@ class BlockProductionDutyTest { private final ForkInfo fork = dataStructureUtil.randomForkInfo(); private final ValidatorLogger validatorLogger = mock(ValidatorLogger.class); - private final BlockProductionDuty duty = - new BlockProductionDuty(validator, SLOT, forkProvider, validatorApiChannel, spec); + private BlockProductionDuty duty; @BeforeEach public void setUp() { + duty = new BlockProductionDuty(validator, SLOT, forkProvider, validatorApiChannel, false, spec); when(forkProvider.getForkInfo(any())).thenReturn(completedFuture(fork)); } - @Test - public void shouldCreateAndPublishBlock() { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + public void shouldCreateAndPublishBlock(final boolean isBlindedBlocksEnabled) { + duty = + new BlockProductionDuty( + validator, SLOT, forkProvider, validatorApiChannel, isBlindedBlocksEnabled, spec); final BLSSignature randaoReveal = dataStructureUtil.randomSignature(); final BLSSignature blockSignature = dataStructureUtil.randomSignature(); - final BeaconBlock unsignedBlock = dataStructureUtil.randomBeaconBlock(SLOT.longValue()); + final BeaconBlock unsignedBlock; + + if (isBlindedBlocksEnabled) { + unsignedBlock = dataStructureUtil.randomBlindedBeaconBlock(SLOT); + } else { + unsignedBlock = dataStructureUtil.randomBeaconBlock(SLOT); + } + when(signer.createRandaoReveal(spec.computeEpochAtSlot(SLOT), fork)) .thenReturn(completedFuture(randaoReveal)); - when(validatorApiChannel.createUnsignedBlock(SLOT, randaoReveal, Optional.of(graffiti), false)) + when(validatorApiChannel.createUnsignedBlock( + SLOT, randaoReveal, Optional.of(graffiti), isBlindedBlocksEnabled)) .thenReturn(completedFuture(Optional.of(unsignedBlock))); when(signer.signBlock(unsignedBlock, fork)).thenReturn(completedFuture(blockSignature)); final SignedBeaconBlock signedBlock = diff --git a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/RemoteBeaconNodeApi.java b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/RemoteBeaconNodeApi.java index 8e0c83d82a3..7a455c74c25 100644 --- a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/RemoteBeaconNodeApi.java +++ b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/RemoteBeaconNodeApi.java @@ -54,8 +54,7 @@ public static BeaconNodeApi create( final AsyncRunner asyncRunner, final URI beaconNodeApiEndpoint, final Spec spec, - final boolean generateEarlyAttestations, - final boolean blindedBlocksEnabled) { + final boolean generateEarlyAttestations) { final OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder().readTimeout(READ_TIMEOUT); @@ -70,7 +69,7 @@ public static BeaconNodeApi create( apiEndpoint = apiEndpoint.newBuilder().username("").password("").build(); final OkHttpClient okHttpClient = httpClientBuilder.build(); final OkHttpValidatorRestApiClient apiClient = - new OkHttpValidatorRestApiClient(apiEndpoint, okHttpClient, blindedBlocksEnabled); + new OkHttpValidatorRestApiClient(apiEndpoint, okHttpClient); final ValidatorApiChannel validatorApiChannel = new MetricRecordingValidatorApiChannel( diff --git a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/apiclient/OkHttpValidatorRestApiClient.java b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/apiclient/OkHttpValidatorRestApiClient.java index ff81e8f590b..3f07a3254a8 100644 --- a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/apiclient/OkHttpValidatorRestApiClient.java +++ b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/apiclient/OkHttpValidatorRestApiClient.java @@ -104,15 +104,10 @@ public class OkHttpValidatorRestApiClient implements ValidatorRestApiClient { private final JsonProvider jsonProvider = new JsonProvider(); private final OkHttpClient httpClient; private final HttpUrl baseEndpoint; - private final boolean blindedBlocksEnabled; - public OkHttpValidatorRestApiClient( - final HttpUrl baseEndpoint, - final OkHttpClient okHttpClient, - final boolean blindedBlocksEnabled) { + public OkHttpValidatorRestApiClient(final HttpUrl baseEndpoint, final OkHttpClient okHttpClient) { this.baseEndpoint = baseEndpoint; this.httpClient = okHttpClient; - this.blindedBlocksEnabled = blindedBlocksEnabled; } public Optional getConfigSpec() { @@ -174,7 +169,7 @@ public Optional createUnsignedBlock( queryParams.put("randao_reveal", encodeQueryParam(randaoReveal)); graffiti.ifPresent(bytes32 -> queryParams.put("graffiti", encodeQueryParam(bytes32))); - if (blindedBlocksEnabled || blinded) { + if (blinded) { return createUnsignedBlindedBlock(pathParams, queryParams); } diff --git a/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/RemoteBeaconNodeApiTest.java b/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/RemoteBeaconNodeApiTest.java index b59298ae036..8853e10ce56 100644 --- a/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/RemoteBeaconNodeApiTest.java +++ b/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/RemoteBeaconNodeApiTest.java @@ -34,7 +34,7 @@ void producesExceptionWhenInvalidUrlPassed() { assertThatThrownBy( () -> RemoteBeaconNodeApi.create( - serviceConfig, asyncRunner, new URI("notvalid"), spec, false, false)) + serviceConfig, asyncRunner, new URI("notvalid"), spec, false)) .hasMessageContaining("Failed to convert remote api endpoint"); } } diff --git a/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/apiclient/OkHttpValidatorRestApiClientTest.java b/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/apiclient/OkHttpValidatorRestApiClientTest.java index 1684506a627..ccefb3c51a2 100644 --- a/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/apiclient/OkHttpValidatorRestApiClientTest.java +++ b/validator/remote/src/test/java/tech/pegasys/teku/validator/remote/apiclient/OkHttpValidatorRestApiClientTest.java @@ -84,7 +84,7 @@ class OkHttpValidatorRestApiClientTest { public void beforeEach() throws Exception { mockWebServer.start(); okHttpClient = new OkHttpClient(); - apiClient = new OkHttpValidatorRestApiClient(mockWebServer.url("/"), okHttpClient, false); + apiClient = new OkHttpValidatorRestApiClient(mockWebServer.url("/"), okHttpClient); } @AfterEach @@ -256,7 +256,7 @@ public void createUnsignedBlocks_shouldUseBlindedBlocksIfEnabled() { asJson( new GetNewBlindedBlockResponse( SpecMilestone.BELLATRIX, new BlindedBlockBellatrix(expectedBeaconBlock))))); - apiClient = new OkHttpValidatorRestApiClient(mockWebServer.url("/"), okHttpClient, true); + apiClient = new OkHttpValidatorRestApiClient(mockWebServer.url("/"), okHttpClient); Optional maybeBlock = apiClient.createUnsignedBlock(slot, blsSignature, graffiti, true); assertThat(maybeBlock).isPresent(); @@ -298,9 +298,7 @@ public void sendSignedBlock_MakesExpectedRequest(final boolean isBlindedBlocksEn isBlindedBlocksEnabled ? schemaObjectsBellatrix.signedBlindedBlock() : schemaObjectsBellatrix.signedBeaconBlock(); - apiClient = - new OkHttpValidatorRestApiClient( - mockWebServer.url("/"), okHttpClient, isBlindedBlocksEnabled); + apiClient = new OkHttpValidatorRestApiClient(mockWebServer.url("/"), okHttpClient); // Block has been successfully broadcast, validated and imported mockWebServer.enqueue(new MockResponse().setResponseCode(SC_OK).setBody(asJson(blockRoot))); @@ -731,7 +729,7 @@ void shouldIncludeAuthorizationHeaderWhenBaseUrlIncludesCredentialsForGetRequest throws Exception { final HttpUrl url = mockWebServer.url("/").newBuilder().username("user").password("password").build(); - apiClient = new OkHttpValidatorRestApiClient(url, okHttpClient, false); + apiClient = new OkHttpValidatorRestApiClient(url, okHttpClient); mockWebServer.enqueue(new MockResponse().setResponseCode(SC_NO_CONTENT)); apiClient.getGenesis();