Skip to content

Commit e59cac4

Browse files
Add an option to disable syncing the deposit contract logs for non-validator nodes (Consensys#8178)
1 parent 5afb156 commit e59cac4

File tree

9 files changed

+69
-26
lines changed

9 files changed

+69
-26
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ the [releases page](https://github.com/Consensys/teku/releases).
1313

1414
### Additions and Improvements
1515
- 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.
16-
- Added `peers_direction_current` LIBP2P metric for the number of peers by direction including inbound and outbound.
16+
- Added `peers_direction_current` libp2p metric to track the number of peers by direction (inbound and outbound).
17+
- Deposit tree snapshots will be loaded from database as a default unless custom snapshot has been provided.
18+
- 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. It is advisable to be used alongside with `--Xeth1-missing-deposits-event-logging-enabled=false` to avoid unnecessary logging of missing deposits.
1719

1820
### Bug Fixes

ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/block/BlockProcessorElectra.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ protected void processOperationsNoValidation(
9090
safelyProcess(
9191
() ->
9292
processDepositReceipts(
93-
MutableBeaconStateElectra.required(state),
93+
state,
9494
body.getOptionalExecutionPayload()
9595
.flatMap(ExecutionPayload::toVersionElectra)
9696
.map(ExecutionPayloadElectra::getDepositReceipts)

ethereum/spec/src/test/java/tech/pegasys/teku/spec/logic/versions/electra/block/BlockProcessorElectraTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public void processesDepositReceipts() throws BlockProcessingException {
129129
UInt64.valueOf(firstElectraDepositReceiptIndex + i)))
130130
.toList();
131131

132-
final BeaconState state =
132+
final BeaconStateElectra state =
133133
BeaconStateElectra.required(
134134
preState.updated(
135135
mutableState ->
@@ -139,7 +139,7 @@ public void processesDepositReceipts() throws BlockProcessingException {
139139
depositReceiptsSchema.createFromElements(depositReceipts))));
140140

141141
// verify deposit_receipts_start_index has been set
142-
assertThat(BeaconStateElectra.required(state).getDepositReceiptsStartIndex())
142+
assertThat(state.getDepositReceiptsStartIndex())
143143
.isEqualTo(UInt64.valueOf(firstElectraDepositReceiptIndex));
144144
// verify validators have been added to the state
145145
assertThat(state.getValidators().size())

infrastructure/logging/src/main/java/tech/pegasys/teku/infrastructure/logging/ColorConsolePrinter.java

+10-20
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,15 @@ public static String print(final String message, final Color color) {
3333
}
3434

3535
private static String colorCode(final Color color) {
36-
switch (color) {
37-
case BLACK:
38-
return "\u001b[30m";
39-
case RED:
40-
return "\u001b[31m";
41-
case GREEN:
42-
return "\u001b[32m";
43-
case YELLOW:
44-
return "\u001b[33m";
45-
case BLUE:
46-
return "\u001b[34m";
47-
case PURPLE:
48-
return "\u001b[35m";
49-
case CYAN:
50-
return "\u001b[36m";
51-
case WHITE:
52-
return "\u001b[37m";
53-
default:
54-
return "";
55-
}
36+
return switch (color) {
37+
case BLACK -> "\u001b[30m";
38+
case RED -> "\u001b[31m";
39+
case GREEN -> "\u001b[32m";
40+
case YELLOW -> "\u001b[33m";
41+
case BLUE -> "\u001b[34m";
42+
case PURPLE -> "\u001b[35m";
43+
case CYAN -> "\u001b[36m";
44+
case WHITE -> "\u001b[37m";
45+
};
5646
}
5747
}

infrastructure/logging/src/main/java/tech/pegasys/teku/infrastructure/logging/EventLogger.java

+6
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,12 @@ public void executionLayerStubEnabled() {
309309
Color.RED);
310310
}
311311

312+
public void depositContractLogsSyncingDisabled() {
313+
warn(
314+
"Deposit contract logs syncing from the Execution Client has been disabled! You WILL not be able to produce blocks.",
315+
Color.YELLOW);
316+
}
317+
312318
public void builderBidNotHonouringGasLimit(
313319
final UInt64 parentGasLimit, final UInt64 proposedGasLimit, final UInt64 preferredGasLimit) {
314320
String reorgEventLog =

services/powchain/src/main/java/tech/pegasys/teku/services/powchain/PowchainConfiguration.java

+19-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class PowchainConfiguration {
3131
public static final int DEFAULT_ETH1_LOGS_MAX_BLOCK_RANGE = 10_000;
3232
public static final boolean DEFAULT_USE_MISSING_DEPOSIT_EVENT_LOGGING = false;
3333
public static final boolean DEFAULT_DEPOSIT_SNAPSHOT_ENABLED = true;
34+
public static final boolean DEFAULT_DEPOSIT_CONTRACT_LOGS_SYNCING_ENABLED = true;
3435
public static final String DEPOSIT_SNAPSHOT_URL_PATH = "/eth/v1/beacon/deposit_snapshot";
3536

3637
private final Spec spec;
@@ -40,6 +41,7 @@ public class PowchainConfiguration {
4041
private final DepositTreeSnapshotConfiguration depositTreeSnapshotConfiguration;
4142
private final int eth1LogsMaxBlockRange;
4243
private final boolean useMissingDepositEventLogging;
44+
private final boolean depositContractLogsSyncingEnabled;
4345

4446
private PowchainConfiguration(
4547
final Spec spec,
@@ -48,14 +50,16 @@ private PowchainConfiguration(
4850
final Optional<UInt64> depositContractDeployBlock,
4951
final DepositTreeSnapshotConfiguration depositTreeSnapshotConfiguration,
5052
final int eth1LogsMaxBlockRange,
51-
final boolean useMissingDepositEventLogging) {
53+
final boolean useMissingDepositEventLogging,
54+
final boolean depositContractLogsSyncingEnabled) {
5255
this.spec = spec;
5356
this.eth1Endpoints = eth1Endpoints;
5457
this.depositContract = depositContract;
5558
this.depositContractDeployBlock = depositContractDeployBlock;
5659
this.depositTreeSnapshotConfiguration = depositTreeSnapshotConfiguration;
5760
this.eth1LogsMaxBlockRange = eth1LogsMaxBlockRange;
5861
this.useMissingDepositEventLogging = useMissingDepositEventLogging;
62+
this.depositContractLogsSyncingEnabled = depositContractLogsSyncingEnabled;
5963
}
6064

6165
public static Builder builder() {
@@ -94,6 +98,10 @@ public boolean useMissingDepositEventLogging() {
9498
return useMissingDepositEventLogging;
9599
}
96100

101+
public boolean isDepositContractLogsSyncingEnabled() {
102+
return depositContractLogsSyncingEnabled;
103+
}
104+
97105
public static class Builder {
98106
private Spec spec;
99107
private List<String> eth1Endpoints = new ArrayList<>();
@@ -105,6 +113,8 @@ public static class Builder {
105113
private int eth1LogsMaxBlockRange = DEFAULT_ETH1_LOGS_MAX_BLOCK_RANGE;
106114
private boolean useMissingDepositEventLogging = DEFAULT_USE_MISSING_DEPOSIT_EVENT_LOGGING;
107115
private boolean depositSnapshotEnabled = DEFAULT_DEPOSIT_SNAPSHOT_ENABLED;
116+
private boolean depositContractLogsSyncingEnabled =
117+
DEFAULT_DEPOSIT_CONTRACT_LOGS_SYNCING_ENABLED;
108118

109119
private Builder() {}
110120

@@ -125,7 +135,8 @@ public PowchainConfiguration build() {
125135
bundledDepositSnapshotPath,
126136
isBundledSnapshotEnabled),
127137
eth1LogsMaxBlockRange,
128-
useMissingDepositEventLogging);
138+
useMissingDepositEventLogging,
139+
depositContractLogsSyncingEnabled);
129140
}
130141

131142
private void validate() {
@@ -211,6 +222,12 @@ public Builder depositSnapshotEnabled(final boolean depositSnapshotEnabled) {
211222
return this;
212223
}
213224

225+
public Builder depositContractLogsSyncingEnabled(
226+
final boolean depositContractLogsSyncingEnabled) {
227+
this.depositContractLogsSyncingEnabled = depositContractLogsSyncingEnabled;
228+
return this;
229+
}
230+
214231
public Builder eth1LogsMaxBlockRange(final int eth1LogsMaxBlockRange) {
215232
if (eth1LogsMaxBlockRange < 0) {
216233
throw new InvalidConfigurationException(

teku/src/main/java/tech/pegasys/teku/cli/options/DepositOptions.java

+13
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,18 @@ public class DepositOptions {
6868
fallbackValue = "true")
6969
private boolean depositSnapshotEnabled = PowchainConfiguration.DEFAULT_DEPOSIT_SNAPSHOT_ENABLED;
7070

71+
@Option(
72+
names = {"--Xdeposit-contract-logs-syncing-enabled"},
73+
paramLabel = "<BOOLEAN>",
74+
description =
75+
"Enable syncing of deposit contract logs from the Execution Engine node. This is required for block production.",
76+
hidden = true,
77+
showDefaultValue = Visibility.ALWAYS,
78+
arity = "0..1",
79+
fallbackValue = "true")
80+
private boolean depositContractLogsSyncingEnabled =
81+
PowchainConfiguration.DEFAULT_DEPOSIT_CONTRACT_LOGS_SYNCING_ENABLED;
82+
7183
public void configure(final TekuConfiguration.Builder builder) {
7284
builder.powchain(
7385
b -> {
@@ -76,6 +88,7 @@ public void configure(final TekuConfiguration.Builder builder) {
7688
b.useMissingDepositEventLogging(useMissingDepositEventLogging);
7789
b.customDepositSnapshotPath(depositSnapshotPath);
7890
b.depositSnapshotEnabled(depositSnapshotEnabled);
91+
b.depositContractLogsSyncingEnabled(depositContractLogsSyncingEnabled);
7992
});
8093
}
8194
}

teku/src/main/java/tech/pegasys/teku/services/BeaconNodeServiceController.java

+8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
package tech.pegasys.teku.services;
1515

16+
import static tech.pegasys.teku.infrastructure.logging.EventLogger.EVENT_LOG;
17+
1618
import java.util.Optional;
1719
import java.util.function.Supplier;
1820
import tech.pegasys.teku.config.TekuConfiguration;
@@ -98,6 +100,12 @@ private Optional<PowchainService> powchainService(
98100
|| (!tekuConfig.powchain().isEnabled() && maybeExecutionWeb3jClientProvider.isEmpty())) {
99101
return Optional.empty();
100102
}
103+
if (!tekuConfig.powchain().isDepositContractLogsSyncingEnabled()) {
104+
// PowchainService is only used for deposit contract logs syncing, so no need to initialize it
105+
// if disabled
106+
EVENT_LOG.depositContractLogsSyncingDisabled();
107+
return Optional.empty();
108+
}
101109
final PowchainService powchainService =
102110
new PowchainService(
103111
serviceConfig,

teku/src/test/java/tech/pegasys/teku/cli/options/DepositOptionsTest.java

+7
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,11 @@ public void shouldSetCheckpointSyncDepositSnapshotUrlWhenUsingCheckpointSyncUrl(
183183
assertThat(depositTreeSnapshotConfiguration.getCustomDepositSnapshotPath())
184184
.hasValue("/foo/bar");
185185
}
186+
187+
@Test
188+
public void shouldHaveDepositContractLogsSyncingEnabledByDefault() {
189+
final String[] args = {};
190+
final TekuConfiguration config = getTekuConfigurationFromArguments(args);
191+
assertThat(config.powchain().isDepositContractLogsSyncingEnabled()).isTrue();
192+
}
186193
}

0 commit comments

Comments
 (0)