Skip to content

Commit

Permalink
Replace TTFB, RESP_TIMEOUT with MAX_CONCURRENT_REQUESTS
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov committed Nov 21, 2024
1 parent af1320e commit 0ce2fe1
Show file tree
Hide file tree
Showing 31 changed files with 91 additions and 284 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,5 @@ SUBNETS_PER_NODE: 2
ATTESTATION_SUBNET_COUNT: 64
ATTESTATION_SUBNET_EXTRA_BITS: 0
# ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS
ATTESTATION_SUBNET_PREFIX_BITS: 6
ATTESTATION_SUBNET_PREFIX_BITS: 6
MAX_CONCURRENT_REQUESTS: 2
Original file line number Diff line number Diff line change
Expand Up @@ -327,16 +327,6 @@ 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();
Expand Down Expand Up @@ -392,6 +382,11 @@ public int getAttestationSubnetPrefixBits() {
return specConfig.getAttestationSubnetPrefixBits();
}

@Override
public int getMaxConcurrentRequests() {
return specConfig.getMaxConcurrentRequests();
}

@Override
public int getProposerScoreBoost() {
return specConfig.getProposerScoreBoost();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ public interface NetworkingSpecConfig {

int getMinEpochsForBlockRequests();

// in seconds
int getTtfbTimeout();

// in seconds
int getRespTimeout();

int getAttestationPropagationSlotRange();

// in millis
Expand All @@ -54,6 +48,8 @@ public interface NetworkingSpecConfig {
// int(ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS)
int getAttestationSubnetPrefixBits();

int getMaxConcurrentRequests();

default NetworkingSpecConfig getNetworkingConfig() {
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ 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;
Expand All @@ -117,6 +115,7 @@ public class SpecConfigPhase0 implements SpecConfig {
private final int attestationSubnetCount;
private final int attestationSubnetExtraBits;
private final int attestationSubnetPrefixBits;
private final int maxConcurrentRequests;
private final int reorgMaxEpochsSinceFinalization;
private final int reorgHeadWeightThreshold;
private final int reorgParentWeightThreshold;
Expand Down Expand Up @@ -179,8 +178,6 @@ 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,
Expand All @@ -189,6 +186,7 @@ public SpecConfigPhase0(
final int attestationSubnetCount,
final int attestationSubnetExtraBits,
final int attestationSubnetPrefixBits,
final int maxConcurrentRequests,
final int reorgMaxEpochsSinceFinalization,
final int reorgHeadWeightThreshold,
final int reorgParentWeightThreshold,
Expand Down Expand Up @@ -249,8 +247,6 @@ 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;
Expand All @@ -259,6 +255,7 @@ public SpecConfigPhase0(
this.attestationSubnetCount = attestationSubnetCount;
this.attestationSubnetExtraBits = attestationSubnetExtraBits;
this.attestationSubnetPrefixBits = attestationSubnetPrefixBits;
this.maxConcurrentRequests = maxConcurrentRequests;
this.reorgMaxEpochsSinceFinalization = reorgMaxEpochsSinceFinalization;
this.reorgHeadWeightThreshold = reorgHeadWeightThreshold;
this.reorgParentWeightThreshold = reorgParentWeightThreshold;
Expand Down Expand Up @@ -585,16 +582,6 @@ public int getMinEpochsForBlockRequests() {
return minEpochsForBlockRequests;
}

@Override
public int getTtfbTimeout() {
return ttfbTimeout;
}

@Override
public int getRespTimeout() {
return respTimeout;
}

@Override
public int getAttestationPropagationSlotRange() {
return attestationPropagationSlotRange;
Expand Down Expand Up @@ -635,6 +622,11 @@ public int getAttestationSubnetPrefixBits() {
return attestationSubnetPrefixBits;
}

@Override
public int getMaxConcurrentRequests() {
return maxConcurrentRequests;
}

@Override
public SpecMilestone getMilestone() {
return SpecMilestone.PHASE0;
Expand Down Expand Up @@ -691,8 +683,7 @@ public boolean equals(final Object o) {
&& attestationSubnetCount == that.attestationSubnetCount
&& attestationSubnetExtraBits == that.attestationSubnetExtraBits
&& attestationSubnetPrefixBits == that.attestationSubnetPrefixBits
&& ttfbTimeout == that.ttfbTimeout
&& respTimeout == that.respTimeout
&& maxConcurrentRequests == that.maxConcurrentRequests
&& attestationPropagationSlotRange == that.attestationPropagationSlotRange
&& maximumGossipClockDisparity == that.maximumGossipClockDisparity
&& Objects.equals(eth1FollowDistance, that.eth1FollowDistance)
Expand Down Expand Up @@ -772,15 +763,14 @@ public int hashCode() {
maxChunkSize,
maxRequestBlocks,
epochsPerSubnetSubscription,
ttfbTimeout,
respTimeout,
attestationPropagationSlotRange,
maximumGossipClockDisparity,
messageDomainInvalidSnappy,
messageDomainValidSnappy,
subnetsPerNode,
attestationSubnetCount,
attestationSubnetExtraBits,
attestationSubnetPrefixBits);
attestationSubnetPrefixBits,
maxConcurrentRequests);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ 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;
Expand All @@ -123,6 +121,7 @@ public class SpecConfigBuilder {
private Integer attestationSubnetCount;
private Integer attestationSubnetExtraBits;
private Integer attestationSubnetPrefixBits;
private Integer maxConcurrentRequests;

// added after Phase0, so add default values, or will be compatibility issue
private Integer reorgMaxEpochsSinceFinalization = 2;
Expand Down Expand Up @@ -205,8 +204,6 @@ public SpecConfigAndParent<SpecConfigElectra> build() {
maxRequestBlocks,
epochsPerSubnetSubscription,
minEpochsForBlockRequests,
ttfbTimeout,
respTimeout,
attestationPropagationSlotRange,
maximumGossipClockDisparity,
messageDomainInvalidSnappy,
Expand All @@ -215,6 +212,7 @@ public SpecConfigAndParent<SpecConfigElectra> build() {
attestationSubnetCount,
attestationSubnetExtraBits,
attestationSubnetPrefixBits,
maxConcurrentRequests,
reorgMaxEpochsSinceFinalization,
reorgHeadWeightThreshold,
reorgParentWeightThreshold,
Expand Down Expand Up @@ -279,8 +277,6 @@ private Map<String, Object> 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);
Expand All @@ -289,6 +285,7 @@ private Map<String, Object> getValidationMap() {
constants.put("attestationSubnetCount", attestationSubnetCount);
constants.put("attestationSubnetExtraBits", attestationSubnetExtraBits);
constants.put("attestationSubnetPrefixBits", attestationSubnetPrefixBits);
constants.put("maxConcurrentRequests", maxConcurrentRequests);
constants.put("reorgMaxEpochsSinceFinalization", reorgMaxEpochsSinceFinalization);
constants.put("reorgHeadWeightThreshold", reorgHeadWeightThreshold);
constants.put("reorgParentWeightThreshold", reorgParentWeightThreshold);
Expand Down Expand Up @@ -651,16 +648,6 @@ 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;
Expand Down Expand Up @@ -702,6 +689,11 @@ public SpecConfigBuilder attestationSubnetPrefixBits(final Integer attestationSu
return this;
}

public SpecConfigBuilder maxConcurrentRequests(final Integer maxConcurrentRequests) {
this.maxConcurrentRequests = maxConcurrentRequests;
return this;
}

public SpecConfigBuilder reorgMaxEpochsSinceFinalization(
final Integer reorgMaxEpochsSinceFinalization) {
this.reorgMaxEpochsSinceFinalization = reorgMaxEpochsSinceFinalization;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ ATTESTATION_SUBNET_COUNT: 64
ATTESTATION_SUBNET_EXTRA_BITS: 0
# ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS
ATTESTATION_SUBNET_PREFIX_BITS: 6
MAX_CONCURRENT_REQUESTS: 2

# Deneb
# `2**7` (=128)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ ATTESTATION_SUBNET_COUNT: 64
ATTESTATION_SUBNET_EXTRA_BITS: 0
# ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS
ATTESTATION_SUBNET_PREFIX_BITS: 6
MAX_CONCURRENT_REQUESTS: 2

# Deneb
# `2**7` (=128)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ ATTESTATION_SUBNET_COUNT: 64
ATTESTATION_SUBNET_EXTRA_BITS: 0
# ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS
ATTESTATION_SUBNET_PREFIX_BITS: 6
MAX_CONCURRENT_REQUESTS: 2

# Deneb
# `2**7` (=128)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ ATTESTATION_SUBNET_COUNT: 64
ATTESTATION_SUBNET_EXTRA_BITS: 0
# ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS
ATTESTATION_SUBNET_PREFIX_BITS: 6
MAX_CONCURRENT_REQUESTS: 2

# Deneb
# `2**7` (=128)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ ATTESTATION_SUBNET_COUNT: 64
ATTESTATION_SUBNET_EXTRA_BITS: 0
# ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS
ATTESTATION_SUBNET_PREFIX_BITS: 6
MAX_CONCURRENT_REQUESTS: 2

# Deneb
# `2**7` (=128)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ ATTESTATION_SUBNET_COUNT: 64
ATTESTATION_SUBNET_EXTRA_BITS: 0
# ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS
ATTESTATION_SUBNET_PREFIX_BITS: 6
MAX_CONCURRENT_REQUESTS: 2

# Deneb
# `2**7` (=128)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ ATTESTATION_SUBNET_COUNT: 64
ATTESTATION_SUBNET_EXTRA_BITS: 0
# ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS
ATTESTATION_SUBNET_PREFIX_BITS: 6
MAX_CONCURRENT_REQUESTS: 2

# Deneb
# `2**7` (=128)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ ATTESTATION_SUBNET_COUNT: 64
ATTESTATION_SUBNET_EXTRA_BITS: 0
# ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS
ATTESTATION_SUBNET_PREFIX_BITS: 6
MAX_CONCURRENT_REQUESTS: 2

# Deneb
# `2**7` (=128)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ ATTESTATION_SUBNET_COUNT: 64
ATTESTATION_SUBNET_EXTRA_BITS: 0
# ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS
ATTESTATION_SUBNET_PREFIX_BITS: 6
MAX_CONCURRENT_REQUESTS: 2

# Deneb
# `2**7` (=128)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ ATTESTATION_SUBNET_COUNT: 64
ATTESTATION_SUBNET_EXTRA_BITS: 0
# ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS
ATTESTATION_SUBNET_PREFIX_BITS: 6
MAX_CONCURRENT_REQUESTS: 2

# Deneb
# `2**7` (=128)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,5 @@ SUBNETS_PER_NODE: 2
ATTESTATION_SUBNET_COUNT: 64
ATTESTATION_SUBNET_EXTRA_BITS: 0
# ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS
ATTESTATION_SUBNET_PREFIX_BITS: 6
ATTESTATION_SUBNET_PREFIX_BITS: 6
MAX_CONCURRENT_REQUESTS: 2
Original file line number Diff line number Diff line change
Expand Up @@ -280,4 +280,5 @@ SUBNETS_PER_NODE: 2
ATTESTATION_SUBNET_COUNT: 64
ATTESTATION_SUBNET_EXTRA_BITS: 0
# ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS
ATTESTATION_SUBNET_PREFIX_BITS: 6
ATTESTATION_SUBNET_PREFIX_BITS: 6
MAX_CONCURRENT_REQUESTS: 2
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,5 @@ SUBNETS_PER_NODE: 2
ATTESTATION_SUBNET_COUNT: 64
ATTESTATION_SUBNET_EXTRA_BITS: 0
# ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS
ATTESTATION_SUBNET_PREFIX_BITS: 6
ATTESTATION_SUBNET_PREFIX_BITS: 6
MAX_CONCURRENT_REQUESTS: 2
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import tech.pegasys.teku.networking.p2p.peer.Peer;
import tech.pegasys.teku.networking.p2p.peer.PeerConnectedSubscriber;
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.config.SpecConfig;
import tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.metadata.MetadataMessage;
import tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.metadata.MetadataMessageSchema;
import tech.pegasys.teku.spec.datastructures.state.Checkpoint;
Expand All @@ -66,7 +65,6 @@ public class Eth2PeerManager implements PeerLookup, PeerHandler {
private final int eth2RpcOutstandingPingThreshold;

private final Duration eth2StatusUpdateInterval;
private final SpecConfig specConfig;

Eth2PeerManager(
final Spec spec,
Expand Down Expand Up @@ -99,7 +97,6 @@ public class Eth2PeerManager implements PeerLookup, PeerHandler {
this.eth2RpcPingInterval = eth2RpcPingInterval;
this.eth2RpcOutstandingPingThreshold = eth2RpcOutstandingPingThreshold;
this.eth2StatusUpdateInterval = eth2StatusUpdateInterval;
this.specConfig = spec.getGenesisSpecConfig();
}

public static Eth2PeerManager create(
Expand Down Expand Up @@ -237,7 +234,8 @@ private void ensureStatusReceived(final Eth2Peer peer) {
.ifExceptionGetsHereRaiseABug();
}
},
Duration.ofSeconds(specConfig.getRespTimeout()))
// TODO: change with a constant
Duration.ofSeconds(10))
.finish(
() -> {},
error -> {
Expand Down
Loading

0 comments on commit 0ce2fe1

Please sign in to comment.