Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VC slashing Part 3 - vc slashing option #7915

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import static tech.pegasys.teku.networks.Eth2NetworkConfiguration.DEFAULT_VALIDATOR_EXECUTOR_THREADS;
import static tech.pegasys.teku.validator.api.ValidatorConfig.DEFAULT_DOPPELGANGER_DETECTION_ENABLED;
import static tech.pegasys.teku.validator.api.ValidatorConfig.DEFAULT_SHUTDOWN_WHEN_VALIDATOR_SLASHED_ENABLED;
import static tech.pegasys.teku.validator.api.ValidatorConfig.DEFAULT_VALIDATOR_IS_LOCAL_SLASHING_PROTECTION_SYNCHRONIZED_ENABLED;

import java.nio.file.Path;
Expand Down Expand Up @@ -152,6 +153,17 @@ public class ValidatorOptions {
private boolean isLocalSlashingProtectionSynchronizedEnabled =
DEFAULT_VALIDATOR_IS_LOCAL_SLASHING_PROTECTION_SYNCHRONIZED_ENABLED;

@Option(
names = {"--Xshut-down-when-validator-slashed-enabled"},
paramLabel = "<BOOLEAN>",
description =
"If an owned validator key is detected as slashed, the node should terminate with exit code 2. In this case, the service should not be restarted.",
showDefaultValue = CommandLine.Help.Visibility.ALWAYS,
arity = "0..1",
hidden = true,
fallbackValue = "true")
private boolean shutdownWhenValidatorSlashed = DEFAULT_SHUTDOWN_WHEN_VALIDATOR_SLASHED_ENABLED;

public void configure(TekuConfiguration.Builder builder) {
builder.validator(
config ->
Expand All @@ -170,7 +182,8 @@ public void configure(TekuConfiguration.Builder builder) {
.doppelgangerDetectionEnabled(doppelgangerDetectionEnabled)
.executorThreads(executorThreads)
.blockV3enabled(blockV3Enabled)
.exitWhenNoValidatorKeysEnabled(exitWhenNoValidatorKeysEnabled));
.exitWhenNoValidatorKeysEnabled(exitWhenNoValidatorKeysEnabled)
.shutdownWhenValidatorSlashedEnabled(shutdownWhenValidatorSlashed));
validatorProposerOptions.configure(builder);
validatorKeysOptions.configure(builder);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,20 @@ public void shouldSetExitWhenNoValidatorKeysEnabled() {
.getValidatorConfig();
assertThat(config.isExitWhenNoValidatorKeysEnabled()).isTrue();
}

@Test
public void shouldDefaultFalseShutdownWhenValidatorSlashedEnabled() {
final ValidatorConfig config =
getTekuConfigurationFromArguments().validatorClient().getValidatorConfig();
assertThat(config.isShutdownWhenValidatorSlashedEnabled()).isFalse();
}

@Test
public void shouldSetShutdownWhenValidatorSlashedEnabled() {
final ValidatorConfig config =
getTekuConfigurationFromArguments("--Xshut-down-when-validator-slashed-enabled=true")
.validatorClient()
.getValidatorConfig();
assertThat(config.isShutdownWhenValidatorSlashedEnabled()).isTrue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class ValidatorConfig {
public static final boolean DEFAULT_VALIDATOR_CLIENT_SSZ_BLOCKS_ENABLED = true;
public static final boolean DEFAULT_VALIDATOR_CLIENT_USE_POST_VALIDATORS_ENDPOINT_ENABLED = true;
public static final boolean DEFAULT_DOPPELGANGER_DETECTION_ENABLED = false;
public static final boolean DEFAULT_SHUTDOWN_WHEN_VALIDATOR_SLASHED_ENABLED = false;
public static final boolean DEFAULT_VALIDATOR_IS_LOCAL_SLASHING_PROTECTION_SYNCHRONIZED_ENABLED =
true;
public static final int DEFAULT_EXECUTOR_MAX_QUEUE_SIZE = 20_000;
Expand Down Expand Up @@ -93,6 +94,7 @@ public class ValidatorConfig {
private final boolean failoversPublishSignedDutiesEnabled;
private final boolean blockV3Enabled;
private final boolean exitWhenNoValidatorKeysEnabled;
private final boolean shutdownWhenValidatorSlashedEnabled;
private final UInt64 builderRegistrationDefaultGasLimit;
private final int builderRegistrationSendingBatchSize;
private final Optional<UInt64> builderRegistrationTimestampOverride;
Expand Down Expand Up @@ -133,6 +135,7 @@ private ValidatorConfig(
final boolean failoversPublishSignedDutiesEnabled,
final boolean blockV3Enabled,
final boolean exitWhenNoValidatorKeysEnabled,
final boolean shutdownWhenValidatorSlashedEnabled,
final UInt64 builderRegistrationDefaultGasLimit,
final int builderRegistrationSendingBatchSize,
final Optional<UInt64> builderRegistrationTimestampOverride,
Expand Down Expand Up @@ -173,6 +176,7 @@ private ValidatorConfig(
this.failoversPublishSignedDutiesEnabled = failoversPublishSignedDutiesEnabled;
this.blockV3Enabled = blockV3Enabled;
this.exitWhenNoValidatorKeysEnabled = exitWhenNoValidatorKeysEnabled;
this.shutdownWhenValidatorSlashedEnabled = shutdownWhenValidatorSlashedEnabled;
this.builderRegistrationDefaultGasLimit = builderRegistrationDefaultGasLimit;
this.builderRegistrationSendingBatchSize = builderRegistrationSendingBatchSize;
this.builderRegistrationTimestampOverride = builderRegistrationTimestampOverride;
Expand Down Expand Up @@ -311,6 +315,10 @@ public boolean isExitWhenNoValidatorKeysEnabled() {
return exitWhenNoValidatorKeysEnabled;
}

public boolean isShutdownWhenValidatorSlashedEnabled() {
return shutdownWhenValidatorSlashedEnabled;
}

public boolean isBuilderRegistrationDefaultEnabled() {
return builderRegistrationDefaultEnabled;
}
Expand Down Expand Up @@ -378,6 +386,8 @@ public static final class Builder {
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;
private UInt64 builderRegistrationDefaultGasLimit = DEFAULT_BUILDER_REGISTRATION_GAS_LIMIT;
private int builderRegistrationSendingBatchSize =
DEFAULT_VALIDATOR_REGISTRATION_SENDING_BATCH_SIZE;
Expand Down Expand Up @@ -580,6 +590,12 @@ public Builder exitWhenNoValidatorKeysEnabled(final boolean exitWhenNoValidatorK
return this;
}

public Builder shutdownWhenValidatorSlashedEnabled(
final boolean shutdownWhenValidatorSlashedEnabled) {
this.shutdownWhenValidatorSlashedEnabled = shutdownWhenValidatorSlashedEnabled;
return this;
}

public Builder builderRegistrationDefaultGasLimit(
final UInt64 builderRegistrationDefaultGasLimit) {
this.builderRegistrationDefaultGasLimit = builderRegistrationDefaultGasLimit;
Expand Down Expand Up @@ -659,6 +675,7 @@ public ValidatorConfig build() {
failoversPublishSignedDutiesEnabled,
blockV3Enabled,
exitWhenNoValidatorKeysEnabled,
shutdownWhenValidatorSlashedEnabled,
builderRegistrationDefaultGasLimit,
builderRegistrationSendingBatchSize,
builderRegistrationTimestampOverride,
Expand Down
Loading