Skip to content

Commit

Permalink
Add an option to disable syncing the deposit contract logs for non-va…
Browse files Browse the repository at this point in the history
…lidator nodes
  • Loading branch information
StefanBratanov committed Apr 8, 2024
1 parent 5afb156 commit d907a86
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 6 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ the [releases page](https://github.com/Consensys/teku/releases).

### Additions and Improvements
- Increased the executor queue default maximum size to 40_000 (previously 20_000), and other queues to 10_000 (previously 5_000). If you have custom settings for these queues, check to ensure they're still required.
- Added `peers_direction_current` LIBP2P metric for the number of peers by direction including inbound and outbound.
- Added `peers_direction_current` metric to track the number of peers by direction (inbound and outbound).
- Deposit tree snapshots will be loaded from database as a default unless custom snapshot has been provided.
- Added hidden option `--Xdeposit-contract-logs-syncing-enabled` to allow disabling the syncing of the deposit contract logs from the EL. This is useful when running a non-validating node.

### Bug Fixes
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected void processOperationsNoValidation(
safelyProcess(
() ->
processDepositReceipts(
MutableBeaconStateElectra.required(state),
state,
body.getOptionalExecutionPayload()
.flatMap(ExecutionPayload::toVersionElectra)
.map(ExecutionPayloadElectra::getDepositReceipts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void processesDepositReceipts() throws BlockProcessingException {
UInt64.valueOf(firstElectraDepositReceiptIndex + i)))
.toList();

final BeaconState state =
final BeaconStateElectra state =
BeaconStateElectra.required(
preState.updated(
mutableState ->
Expand All @@ -139,7 +139,7 @@ public void processesDepositReceipts() throws BlockProcessingException {
depositReceiptsSchema.createFromElements(depositReceipts))));

// verify deposit_receipts_start_index has been set
assertThat(BeaconStateElectra.required(state).getDepositReceiptsStartIndex())
assertThat(state.getDepositReceiptsStartIndex())
.isEqualTo(UInt64.valueOf(firstElectraDepositReceiptIndex));
// verify validators have been added to the state
assertThat(state.getValidators().size())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,12 @@ public void executionLayerStubEnabled() {
Color.RED);
}

public void depositContractLogsSyncingDisabled() {
warn(
"Deposit contract logs syncing from the Execution Client has been disabled! You WILL not be able to produce blocks.",
Color.YELLOW);
}

public void builderBidNotHonouringGasLimit(
final UInt64 parentGasLimit, final UInt64 proposedGasLimit, final UInt64 preferredGasLimit) {
String reorgEventLog =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class PowchainConfiguration {
public static final int DEFAULT_ETH1_LOGS_MAX_BLOCK_RANGE = 10_000;
public static final boolean DEFAULT_USE_MISSING_DEPOSIT_EVENT_LOGGING = false;
public static final boolean DEFAULT_DEPOSIT_SNAPSHOT_ENABLED = true;
public static final boolean DEFAULT_DEPOSIT_CONTRACT_LOGS_SYNCING_ENABLED = true;
public static final String DEPOSIT_SNAPSHOT_URL_PATH = "/eth/v1/beacon/deposit_snapshot";

private final Spec spec;
Expand All @@ -40,6 +41,7 @@ public class PowchainConfiguration {
private final DepositTreeSnapshotConfiguration depositTreeSnapshotConfiguration;
private final int eth1LogsMaxBlockRange;
private final boolean useMissingDepositEventLogging;
private final boolean depositContractLogsSyncingEnabled;

private PowchainConfiguration(
final Spec spec,
Expand All @@ -48,14 +50,16 @@ private PowchainConfiguration(
final Optional<UInt64> depositContractDeployBlock,
final DepositTreeSnapshotConfiguration depositTreeSnapshotConfiguration,
final int eth1LogsMaxBlockRange,
final boolean useMissingDepositEventLogging) {
final boolean useMissingDepositEventLogging,
final boolean depositContractLogsSyncingEnabled) {
this.spec = spec;
this.eth1Endpoints = eth1Endpoints;
this.depositContract = depositContract;
this.depositContractDeployBlock = depositContractDeployBlock;
this.depositTreeSnapshotConfiguration = depositTreeSnapshotConfiguration;
this.eth1LogsMaxBlockRange = eth1LogsMaxBlockRange;
this.useMissingDepositEventLogging = useMissingDepositEventLogging;
this.depositContractLogsSyncingEnabled = depositContractLogsSyncingEnabled;
}

public static Builder builder() {
Expand Down Expand Up @@ -94,6 +98,10 @@ public boolean useMissingDepositEventLogging() {
return useMissingDepositEventLogging;
}

public boolean depositContractLogsSyncingEnabled() {
return depositContractLogsSyncingEnabled;
}

public static class Builder {
private Spec spec;
private List<String> eth1Endpoints = new ArrayList<>();
Expand All @@ -105,6 +113,8 @@ public static class Builder {
private int eth1LogsMaxBlockRange = DEFAULT_ETH1_LOGS_MAX_BLOCK_RANGE;
private boolean useMissingDepositEventLogging = DEFAULT_USE_MISSING_DEPOSIT_EVENT_LOGGING;
private boolean depositSnapshotEnabled = DEFAULT_DEPOSIT_SNAPSHOT_ENABLED;
private boolean depositContractLogsSyncingEnabled =
DEFAULT_DEPOSIT_CONTRACT_LOGS_SYNCING_ENABLED;

private Builder() {}

Expand All @@ -125,7 +135,8 @@ public PowchainConfiguration build() {
bundledDepositSnapshotPath,
isBundledSnapshotEnabled),
eth1LogsMaxBlockRange,
useMissingDepositEventLogging);
useMissingDepositEventLogging,
depositContractLogsSyncingEnabled);
}

private void validate() {
Expand Down Expand Up @@ -211,6 +222,12 @@ public Builder depositSnapshotEnabled(final boolean depositSnapshotEnabled) {
return this;
}

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

public Builder eth1LogsMaxBlockRange(final int eth1LogsMaxBlockRange) {
if (eth1LogsMaxBlockRange < 0) {
throw new InvalidConfigurationException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ public class DepositOptions {
fallbackValue = "true")
private boolean depositSnapshotEnabled = PowchainConfiguration.DEFAULT_DEPOSIT_SNAPSHOT_ENABLED;

@Option(
names = {"--Xdeposit-contract-logs-syncing-enabled"},
paramLabel = "<BOOLEAN>",
description =
"Enable syncing of deposit contract logs from the EL. This is required for block production.",
showDefaultValue = Visibility.ALWAYS,
arity = "0..1",
fallbackValue = "true")
private boolean depositContractLogsSyncingEnabled =
PowchainConfiguration.DEFAULT_DEPOSIT_CONTRACT_LOGS_SYNCING_ENABLED;

public void configure(final TekuConfiguration.Builder builder) {
builder.powchain(
b -> {
Expand All @@ -76,6 +87,7 @@ public void configure(final TekuConfiguration.Builder builder) {
b.useMissingDepositEventLogging(useMissingDepositEventLogging);
b.customDepositSnapshotPath(depositSnapshotPath);
b.depositSnapshotEnabled(depositSnapshotEnabled);
b.depositContractLogsSyncingEnabled(depositContractLogsSyncingEnabled);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

package tech.pegasys.teku.services;

import static tech.pegasys.teku.infrastructure.logging.EventLogger.EVENT_LOG;

import java.util.Optional;
import java.util.function.Supplier;
import tech.pegasys.teku.config.TekuConfiguration;
Expand Down Expand Up @@ -98,6 +100,10 @@ private Optional<PowchainService> powchainService(
|| (!tekuConfig.powchain().isEnabled() && maybeExecutionWeb3jClientProvider.isEmpty())) {
return Optional.empty();
}
if (!tekuConfig.powchain().depositContractLogsSyncingEnabled()) {
EVENT_LOG.depositContractLogsSyncingDisabled();
return Optional.empty();
}
final PowchainService powchainService =
new PowchainService(
serviceConfig,
Expand Down

0 comments on commit d907a86

Please sign in to comment.