Skip to content

Commit

Permalink
rename builder fn
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Harris <[email protected]>
  • Loading branch information
rolfyone committed Jan 22, 2025
1 parent 93b20f3 commit 20cb11b
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
### Breaking Changes

### Additions and Improvements
- Applied spec change to alter `GOSSIP_MAX_SIZE` to `MAX_PAYLOAD_SIZE`.

### Bug Fixes
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ public Eth1Address getDepositContractAddress() {
}

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

public interface NetworkingSpecConfig {

int getGossipMaxSize();
int getMaxPayloadSize();

int getMaxChunkSize();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public class SpecConfigPhase0 implements SpecConfig {
private final Eth1Address depositContractAddress;

// Networking
private final int gossipMaxSize;
private final int maxPayloadSize;
private final int maxChunkSize;
private final int maxRequestBlocks;
private final int epochsPerSubnetSubscription;
Expand Down Expand Up @@ -174,7 +174,7 @@ public SpecConfigPhase0(
final long depositChainId,
final long depositNetworkId,
final Eth1Address depositContractAddress,
final int gossipMaxSize,
final int maxPayloadSize,
final int maxChunkSize,
final int maxRequestBlocks,
final int epochsPerSubnetSubscription,
Expand Down Expand Up @@ -244,7 +244,7 @@ public SpecConfigPhase0(
this.depositNetworkId = depositNetworkId;
this.depositContractAddress = depositContractAddress;
this.squareRootSlotsPerEpoch = MathHelpers.integerSquareRoot(slotsPerEpoch);
this.gossipMaxSize = gossipMaxSize;
this.maxPayloadSize = maxPayloadSize;
this.maxChunkSize = maxChunkSize;
this.maxRequestBlocks = maxRequestBlocks;
this.epochsPerSubnetSubscription = epochsPerSubnetSubscription;
Expand Down Expand Up @@ -561,8 +561,8 @@ public Eth1Address getDepositContractAddress() {
}

@Override
public int getGossipMaxSize() {
return gossipMaxSize;
public int getMaxPayloadSize() {
return maxPayloadSize;
}

@Override
Expand Down Expand Up @@ -683,7 +683,7 @@ public boolean equals(final Object o) {
&& proposerScoreBoost == that.proposerScoreBoost
&& depositChainId == that.depositChainId
&& depositNetworkId == that.depositNetworkId
&& gossipMaxSize == that.gossipMaxSize
&& maxPayloadSize == that.maxPayloadSize
&& maxChunkSize == that.maxChunkSize
&& maxRequestBlocks == that.maxRequestBlocks
&& epochsPerSubnetSubscription == that.epochsPerSubnetSubscription
Expand Down Expand Up @@ -768,7 +768,7 @@ public int hashCode() {
depositChainId,
depositNetworkId,
depositContractAddress,
gossipMaxSize,
maxPayloadSize,
maxChunkSize,
maxRequestBlocks,
epochsPerSubnetSubscription,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public DecodedMessageResult getDecodedMessage() {
if (valueType == null) {
return DecodedMessageResult.failed();
} else {
final Bytes decodedMessage = uncompressPayload(networkingConfig.getGossipMaxSize());
final Bytes decodedMessage = uncompressPayload(networkingConfig.getMaxPayloadSize());
return DecodedMessageResult.successful(decodedMessage);
}
} catch (DecodingException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public PreparedGossipMessage prepareMessage(

@Override
public int getMaxMessageSize() {
return networkingConfig.getGossipMaxSize();
return networkingConfig.getMaxPayloadSize();
}

protected MessageT deserialize(final PreparedGossipMessage message) throws DecodingException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public void getMessageId_generateUniqueIdsBasedOnValidityAndMilestone() {

@Test
public void getDecodedMessage_ShouldPassGossipMaxSizeToUncompressor() throws DecodingException {
final long gossipMaxSize = spec.getNetworkingConfig().getGossipMaxSize();
final long gossipMaxSize = spec.getNetworkingConfig().getMaxPayloadSize();
final Uncompressor uncompressor = mock(Uncompressor.class);
when(uncompressor.uncompress(any(), any(), anyLong())).thenReturn(Bytes.random(1000));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@ private static void addGossipParamsDValues(

private static void addGossipParamsMaxValues(
final NetworkingSpecConfig networkingSpecConfig, final GossipParamsBuilder builder) {
final int gossipMaxSize = networkingSpecConfig.getGossipMaxSize();
final int compressedMaxGossipSize = 32 + gossipMaxSize + (gossipMaxSize / 6);
final int maxPayloadSize = networkingSpecConfig.getMaxPayloadSize();
builder
.maxGossipMessageSize(compressedMaxGossipSize)
.maxGossipMessageSize(maxPayloadSize)
.maxPublishedMessages(1000)
.maxTopicsPerPublishedMessage(1)
.maxSubscriptions(MAX_SUBSCRIPTIONS_PER_MESSAGE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ public void createGossipParams_setGossipMaxSizeFromNetworkSpecConfig() {
LibP2PParamsFactory.createGossipParams(gossipConfig, networkingSpecConfig);

assertThat(gossipParams.getMaxGossipMessageSize()).isEqualTo(expectedGossipMaxSize);
verify(networkingSpecConfig).getGossipMaxSize();
verify(networkingSpecConfig).getMaxPayloadSize();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
public class GossipHandlerTest {

private final Spec spec = TestSpecFactory.createMinimalPhase0();
private final int gossipMaxSize = spec.getNetworkingConfig().getGossipMaxSize();
private final int gossipMaxSize = spec.getNetworkingConfig().getMaxPayloadSize();
private final Topic topic = new Topic("Testing");
private final PubsubPublisherApi publisher = mock(PubsubPublisherApi.class);
private final TopicHandler topicHandler = mock(TopicHandler.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void shouldDefaultNetworkConfigThatMovedFromConstants() throws IOException {
final SpecConfig specConfig = SpecConfigLoader.loadRemoteConfig(data).specConfig();

// Check values not assigned, using default values
assertThat(specConfig.getGossipMaxSize()).isEqualTo(10485760);
assertThat(specConfig.getMaxPayloadSize()).isEqualTo(10485760);
assertThat(specConfig.getMaxChunkSize()).isEqualTo(10485760);
assertThat(specConfig.getMaxRequestBlocks()).isEqualTo(1024);
assertThat(specConfig.getEpochsPerSubnetSubscription()).isEqualTo(256);
Expand Down

0 comments on commit 20cb11b

Please sign in to comment.