diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/DelegatingSpecConfig.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/DelegatingSpecConfig.java index 403dae93aba..b513c9b16bf 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/DelegatingSpecConfig.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/DelegatingSpecConfig.java @@ -327,6 +327,16 @@ public int getMaxChunkSize() { return specConfig.getMaxChunkSize(); } + @Override + public int getTtfbTimeout() { + return specConfig.getTtfbTimeout(); + } + + @Override + public int getRespTimeout() { + return specConfig.getRespTimeout(); + } + @Override public int getAttestationPropagationSlotRange() { return specConfig.getAttestationPropagationSlotRange(); diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/NetworkingSpecConfig.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/NetworkingSpecConfig.java index a41f0d5f920..ef5b229dfcc 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/NetworkingSpecConfig.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/NetworkingSpecConfig.java @@ -27,6 +27,12 @@ public interface NetworkingSpecConfig { int getMinEpochsForBlockRequests(); + // in seconds + int getTtfbTimeout(); + + // in seconds + int getRespTimeout(); + int getAttestationPropagationSlotRange(); // in millis diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/SpecConfigPhase0.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/SpecConfigPhase0.java index 52654dfdd29..6d41969704c 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/SpecConfigPhase0.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/SpecConfigPhase0.java @@ -107,6 +107,8 @@ public class SpecConfigPhase0 implements SpecConfig { private final int maxRequestBlocks; private final int epochsPerSubnetSubscription; private final int minEpochsForBlockRequests; + private final int ttfbTimeout; + private final int respTimeout; private final int attestationPropagationSlotRange; private final int maximumGossipClockDisparity; private final Bytes4 messageDomainInvalidSnappy; @@ -177,6 +179,8 @@ public SpecConfigPhase0( final int maxRequestBlocks, final int epochsPerSubnetSubscription, final int minEpochsForBlockRequests, + final int ttfbTimeout, + final int respTimeout, final int attestationPropagationSlotRange, final int maximumGossipClockDisparity, final Bytes4 messageDomainInvalidSnappy, @@ -245,6 +249,8 @@ public SpecConfigPhase0( this.maxRequestBlocks = maxRequestBlocks; this.epochsPerSubnetSubscription = epochsPerSubnetSubscription; this.minEpochsForBlockRequests = minEpochsForBlockRequests; + this.ttfbTimeout = ttfbTimeout; + this.respTimeout = respTimeout; this.attestationPropagationSlotRange = attestationPropagationSlotRange; this.maximumGossipClockDisparity = maximumGossipClockDisparity; this.messageDomainInvalidSnappy = messageDomainInvalidSnappy; @@ -579,6 +585,16 @@ public int getMinEpochsForBlockRequests() { return minEpochsForBlockRequests; } + @Override + public int getTtfbTimeout() { + return ttfbTimeout; + } + + @Override + public int getRespTimeout() { + return respTimeout; + } + @Override public int getAttestationPropagationSlotRange() { return attestationPropagationSlotRange; @@ -675,6 +691,8 @@ public boolean equals(final Object o) { && attestationSubnetCount == that.attestationSubnetCount && attestationSubnetExtraBits == that.attestationSubnetExtraBits && attestationSubnetPrefixBits == that.attestationSubnetPrefixBits + && ttfbTimeout == that.ttfbTimeout + && respTimeout == that.respTimeout && attestationPropagationSlotRange == that.attestationPropagationSlotRange && maximumGossipClockDisparity == that.maximumGossipClockDisparity && Objects.equals(eth1FollowDistance, that.eth1FollowDistance) @@ -754,6 +772,8 @@ public int hashCode() { maxChunkSize, maxRequestBlocks, epochsPerSubnetSubscription, + ttfbTimeout, + respTimeout, attestationPropagationSlotRange, maximumGossipClockDisparity, messageDomainInvalidSnappy, diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/builder/SpecConfigBuilder.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/builder/SpecConfigBuilder.java index e731ec925fe..5e48e29614c 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/builder/SpecConfigBuilder.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/builder/SpecConfigBuilder.java @@ -112,6 +112,8 @@ public class SpecConfigBuilder { private Integer maxChunkSize; private Integer maxRequestBlocks; private Integer epochsPerSubnetSubscription; + private Integer ttfbTimeout; + private Integer respTimeout; private Integer attestationPropagationSlotRange; private Integer maximumGossipClockDisparity; private Bytes4 messageDomainInvalidSnappy; @@ -203,6 +205,8 @@ public SpecConfigAndParent build() { maxRequestBlocks, epochsPerSubnetSubscription, minEpochsForBlockRequests, + ttfbTimeout, + respTimeout, attestationPropagationSlotRange, maximumGossipClockDisparity, messageDomainInvalidSnappy, @@ -275,6 +279,8 @@ private Map getValidationMap() { constants.put("maxRequestBlocks", maxRequestBlocks); constants.put("epochsPerSubnetSubscription", epochsPerSubnetSubscription); constants.put("minEpochsForBlockRequests", minEpochsForBlockRequests); + constants.put("ttfbTimeout", ttfbTimeout); + constants.put("respTimeout", respTimeout); constants.put("attestationPropagationSlotRange", attestationPropagationSlotRange); constants.put("maximumGossipClockDisparity", maximumGossipClockDisparity); constants.put("messageDomainInvalidSnappy", messageDomainInvalidSnappy); @@ -645,6 +651,16 @@ public SpecConfigBuilder minEpochsForBlockRequests(final Integer minEpochsForBlo return this; } + public SpecConfigBuilder ttfbTimeout(final Integer ttfbTimeout) { + this.ttfbTimeout = ttfbTimeout; + return this; + } + + public SpecConfigBuilder respTimeout(final Integer respTimeout) { + this.respTimeout = respTimeout; + return this; + } + public SpecConfigBuilder attestationPropagationSlotRange( final Integer attestationPropagationSlotRange) { this.attestationPropagationSlotRange = attestationPropagationSlotRange; diff --git a/teku/src/test/java/tech/pegasys/teku/cli/subcommand/RemoteSpecLoaderTest.java b/teku/src/test/java/tech/pegasys/teku/cli/subcommand/RemoteSpecLoaderTest.java index 5747896cae1..a6818600c2c 100644 --- a/teku/src/test/java/tech/pegasys/teku/cli/subcommand/RemoteSpecLoaderTest.java +++ b/teku/src/test/java/tech/pegasys/teku/cli/subcommand/RemoteSpecLoaderTest.java @@ -78,6 +78,8 @@ void shouldDefaultNetworkConfigThatMovedFromConstants() throws IOException { assertThat(specConfig.getMaxRequestBlocks()).isEqualTo(1024); assertThat(specConfig.getEpochsPerSubnetSubscription()).isEqualTo(256); assertThat(specConfig.getMinEpochsForBlockRequests()).isEqualTo(33024); + assertThat(specConfig.getTtfbTimeout()).isEqualTo(5); + assertThat(specConfig.getRespTimeout()).isEqualTo(10); assertThat(specConfig.getAttestationPropagationSlotRange()).isEqualTo(32); assertThat(specConfig.getMaximumGossipClockDisparity()).isEqualTo(500); }