Skip to content

Commit

Permalink
Improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov committed Feb 24, 2025
1 parent b7dc4bf commit f0168bb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public SyncSource getOrCreateSyncSource(final Eth2Peer peer, final Spec spec) {
peer,
source ->
new ThrottlingSyncSource(
spec,
asyncRunner,
timeProvider,
source,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import tech.pegasys.teku.networking.p2p.peer.DisconnectReason;
import tech.pegasys.teku.networking.p2p.reputation.ReputationAdjustment;
import tech.pegasys.teku.networking.p2p.rpc.RpcResponseListener;
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.SpecMilestone;
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecar;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
import tech.pegasys.teku.spec.datastructures.execution.SignedExecutionPayloadEnvelope;
Expand All @@ -47,6 +49,7 @@ public class ThrottlingSyncSource implements SyncSource {
private final RateTracker executionPayloadEnvelopesRateTracker;

public ThrottlingSyncSource(
final Spec spec,
final AsyncRunner asyncRunner,
final TimeProvider timeProvider,
final SyncSource delegate,
Expand All @@ -64,7 +67,9 @@ public ThrottlingSyncSource(
RateTracker.create(maxBlobSidecarsPerMinute, TIMEOUT_SECONDS, timeProvider))
.orElse(RateTracker.NOOP);
this.executionPayloadEnvelopesRateTracker =
RateTracker.create(maxBlocksPerMinute, TIMEOUT_SECONDS, timeProvider);
spec.isMilestoneSupported(SpecMilestone.EIP7732)
? RateTracker.create(maxBlocksPerMinute, TIMEOUT_SECONDS, timeProvider)
: RateTracker.NOOP;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import tech.pegasys.teku.networking.eth2.peers.SyncSource;
import tech.pegasys.teku.networking.p2p.peer.DisconnectReason;
import tech.pegasys.teku.networking.p2p.rpc.RpcResponseListener;
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.TestSpecFactory;
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecar;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;

Expand All @@ -43,6 +45,8 @@ class ThrottlingSyncSourceTest {
private static final int MAX_BLOBS_PER_BLOCK = 6;
private static final int MAX_BLOB_SIDECARS_PER_MINUTE = 100;

private final Spec spec = TestSpecFactory.createMinimalEip7732();

private final StubAsyncRunner asyncRunner = new StubAsyncRunner();
private final StubTimeProvider timeProvider = StubTimeProvider.withTimeInSeconds(0);
private final SyncSource delegate = mock(SyncSource.class);
Expand All @@ -55,6 +59,7 @@ class ThrottlingSyncSourceTest {

private final ThrottlingSyncSource source =
new ThrottlingSyncSource(
spec,
asyncRunner,
timeProvider,
delegate,
Expand Down

0 comments on commit f0168bb

Please sign in to comment.