Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8957 #9024

Merged
merged 10 commits into from
Jan 23, 2025
Merged

8957 #9024

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -42,6 +42,7 @@
"EPOCHS_PER_SLASHINGS_VECTOR" : "8192",
"MIN_SLASHING_PENALTY_QUOTIENT" : "128",
"MAX_BLS_TO_EXECUTION_CHANGES" : "16",
"MAX_PAYLOAD_SIZE" : "10485760",
"GOSSIP_MAX_SIZE" : "10485760",
"DOMAIN_BEACON_ATTESTER" : "0x01000000",
"EPOCHS_PER_SUBNET_SUBSCRIPTION" : "256",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public Map<String, String> getConfigMap() {
configAttributes.put("DOMAIN_SELECTION_PROOF", getDomainSelectionProof().toHexString());
configAttributes.put("DOMAIN_AGGREGATE_AND_PROOF", getDomainAggregateAndProof().toHexString());
configAttributes.put("DOMAIN_APPLICATION_BUILDER", getDomainApplicationBuilder().toHexString());
// Backwards compatibility with old phase0 constants, otherwise nodes won't start
configAttributes.put("GOSSIP_MAX_SIZE", configAttributes.get("MAX_PAYLOAD_SIZE"));
getDomainSyncCommittee()
.ifPresent(
committee -> configAttributes.put("DOMAIN_SYNC_COMMITTEE", committee.toHexString()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ DOMAIN_AGGREGATE_AND_PROOF: 0x06000000
# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (= 10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
MAX_PAYLOAD_SIZE: 10485760
# `2**10` (= 1024)
MAX_REQUEST_BLOCKS: 1024
# `2**8` (= 256)
Expand Down
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 @@ -108,7 +108,7 @@ public class SpecConfigBuilder {
private Eth1Address depositContractAddress;

// Networking
private Integer gossipMaxSize;
private Integer maxPayloadSize;
private Integer maxChunkSize;
private Integer maxRequestBlocks;
private Integer epochsPerSubnetSubscription;
Expand Down Expand Up @@ -146,6 +146,18 @@ public SpecConfigAndParent<SpecConfigElectra> build() {
rawConfig.put(key, value);
}
});

if (maxPayloadSize == null && rawConfig.containsKey("GOSSIP_MAX_SIZE")) {
try {
// for compatibility, add this constant if its missing but we got GOSSIP_MAX_SIZE
// both need to be able to initialize due to renamed global config constant.
final String gossipMaxSize = (String) rawConfig.get("GOSSIP_MAX_SIZE");
rawConfig.put("MAX_PAYLOAD_SIZE", gossipMaxSize);
maxPayloadSize(Integer.parseInt(gossipMaxSize));
} catch (NumberFormatException e) {
LOG.error("Failed to parse GOSSIP_MAX_SIZE", e);
}
}
validate();
final SpecConfigAndParent<SpecConfig> config =
SpecConfigAndParent.of(
Expand Down Expand Up @@ -200,7 +212,7 @@ public SpecConfigAndParent<SpecConfigElectra> build() {
depositChainId,
depositNetworkId,
depositContractAddress,
gossipMaxSize,
maxPayloadSize,
github-advanced-security[bot] marked this conversation as resolved.
Dismissed
Show resolved Hide resolved
maxChunkSize,
maxRequestBlocks,
epochsPerSubnetSubscription,
Expand Down Expand Up @@ -274,7 +286,7 @@ private Map<String, Object> getValidationMap() {
constants.put("depositNetworkId", depositNetworkId);
constants.put("depositContractAddress", depositContractAddress);

constants.put("gossipMaxSize", gossipMaxSize);
constants.put("maxPayloadSize", maxPayloadSize);
constants.put("maxChunkSize", maxChunkSize);
constants.put("maxRequestBlocks", maxRequestBlocks);
constants.put("epochsPerSubnetSubscription", epochsPerSubnetSubscription);
Expand Down Expand Up @@ -626,8 +638,8 @@ public SpecConfigBuilder depositContractAddress(final Eth1Address depositContrac
return this;
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ DEPOSIT_CONTRACT_ADDRESS: 0xb97036A26259B7147018913bD58a774cf91acf25
# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (= 10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
MAX_PAYLOAD_SIZE: 10485760
# `2**10` (= 1024)
MAX_REQUEST_BLOCKS: 1024
# `2**8` (= 256)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ DEPOSIT_CONTRACT_ADDRESS: 0x4242424242424242424242424242424242424242
# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (= 10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
MAX_PAYLOAD_SIZE: 10485760
# `2**10` (= 1024)
MAX_REQUEST_BLOCKS: 1024
# `2**8` (= 256)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ DEPOSIT_CONTRACT_ADDRESS: 0x0B98057eA310F4d31F2a452B414647007d1645d9
# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (= 10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
MAX_PAYLOAD_SIZE: 10485760
# `2**10` (= 1024)
MAX_REQUEST_BLOCKS: 1024
# `2**8` (= 256)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ DEPOSIT_CONTRACT_ADDRESS: 0x4242424242424242424242424242424242424242
# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (= 10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
MAX_PAYLOAD_SIZE: 10485760
# `2**10` (= 1024)
MAX_REQUEST_BLOCKS: 1024
# `2**8` (= 256)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ DEPOSIT_CONTRACT_ADDRESS: 0x1234567890123456789012345678901234567890
# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (= 10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
MAX_PAYLOAD_SIZE: 10485760
# `2**10` (= 1024)
MAX_REQUEST_BLOCKS: 1024
# `2**8` (= 256)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ EJECTION_BALANCE: 16000000000
# Extra consensus configuration (Teku)
# ---------------------------------------------------------------
# 10 * 2**20 (= 10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
MAX_PAYLOAD_SIZE: 10485760
# `10 * 2**20` (=10485760, 10 MiB)
MAX_CHUNK_SIZE: 10485760
# `2**10` (= 1024)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ DEPOSIT_CONTRACT_ADDRESS: 0x00000000219ab540356cBB839Cbe05303d7705Fa
# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (= 10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
MAX_PAYLOAD_SIZE: 10485760
# `2**10` (= 1024)
MAX_REQUEST_BLOCKS: 1024
# `2**8` (= 256)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ DEPOSIT_CONTRACT_ADDRESS: 0x1234567890123456789012345678901234567890
# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (= 10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
MAX_PAYLOAD_SIZE: 10485760
# `2**10` (= 1024)
MAX_REQUEST_BLOCKS: 1024
# `2**8` (= 256)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ DEPOSIT_CONTRACT_ADDRESS: 0x7f02C3E3c98b133055B8B348B2Ac625669Ed295D
# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (= 10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
MAX_PAYLOAD_SIZE: 10485760
# `2**10` (= 1024)
MAX_REQUEST_BLOCKS: 1024
# `2**8` (= 256)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ DEPOSIT_CONTRACT_ADDRESS: 0x1234567890123456789012345678901234567890
# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (=10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
MAX_PAYLOAD_SIZE: 10485760
# `2**10` (= 1024)
MAX_REQUEST_BLOCKS: 1024
# `2**8` (= 256)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"TERMINAL_TOTAL_DIFFICULTY": "115792089237316195423570985008687907853269984665640564039457584007913129638912",
"VALIDATOR_REGISTRY_LIMIT": "1099511627776",
"WHISTLEBLOWER_REWARD_QUOTIENT": "512",
"GOSSIP_MAX_SIZE": "10485760",
"MAX_PAYLOAD_SIZE": "10485760",
"MAX_REQUEST_BLOCKS": "1024",
"EPOCHS_PER_SUBNET_SUBSCRIPTION": "256",
"MIN_EPOCHS_FOR_BLOCK_REQUESTS": "33024",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"TERMINAL_TOTAL_DIFFICULTY": "115792089237316195423570985008687907853269984665640564039457584007913129638912",
"VALIDATOR_REGISTRY_LIMIT": "1099511627776",
"WHISTLEBLOWER_REWARD_QUOTIENT": "512",
"GOSSIP_MAX_SIZE": "10485760",
"MAX_PAYLOAD_SIZE": "10485760",
"MAX_REQUEST_BLOCKS": "1024",
"EPOCHS_PER_SUBNET_SUBSCRIPTION": "256",
"MIN_EPOCHS_FOR_BLOCK_REQUESTS": "33024",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ SYNC_COMMITTEE_BRANCH_LENGTH: 5
# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (= 10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
MAX_PAYLOAD_SIZE: 10485760
# `2**10` (= 1024)
MAX_REQUEST_BLOCKS: 1024
# `2**8` (= 256)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP: 16384
# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (= 10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
MAX_PAYLOAD_SIZE: 10485760
# `2**10` (= 1024)
MAX_REQUEST_BLOCKS: 1024
# `2**8` (= 256)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"TERMINAL_TOTAL_DIFFICULTY": "115792089237316195423570985008687907853269984665640564039457584007913129638912",
"VALIDATOR_REGISTRY_LIMIT": "1099511627776",
"WHISTLEBLOWER_REWARD_QUOTIENT": "512",
"GOSSIP_MAX_SIZE": "10485760",
"MAX_PAYLOAD_SIZE": "10485760",
"MAX_REQUEST_BLOCKS": "1024",
"EPOCHS_PER_SUBNET_SUBSCRIPTION": "256",
"MIN_EPOCHS_FOR_BLOCK_REQUESTS": "33024",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ DEPOSIT_CONTRACT_ADDRESS: 0x00000000219ab540356cBB839Cbe05303d7705Fa
# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (= 10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
MAX_PAYLOAD_SIZE: 10485760
# `2**10` (= 1024)
MAX_REQUEST_BLOCKS: 1024
# `2**8` (= 256)
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 @@ -22,7 +22,7 @@

public class SnappyBlockCompressorTest {

private static final long GOSSIP_MAX_SIZE = Long.MAX_VALUE;
private static final long MAX_PAYLOAD_SIZE = Long.MAX_VALUE;

private final SnappyBlockCompressor compressor = new SnappyBlockCompressor();

Expand All @@ -33,7 +33,7 @@ public void roundTrip() throws DecodingException {
final Bytes compressed = compressor.compress(original);
assertThat(compressed).isNotEqualTo(original);
final Bytes uncompressed =
compressor.uncompress(compressed, SszLengthBounds.ofBytes(0, 1000), GOSSIP_MAX_SIZE);
compressor.uncompress(compressed, SszLengthBounds.ofBytes(0, 1000), MAX_PAYLOAD_SIZE);

assertThat(uncompressed).isEqualTo(original);
}
Expand All @@ -43,7 +43,7 @@ public void uncompress_randomData() {
final Bytes data = Bytes.fromHexString("0x0102");

assertThatThrownBy(
() -> compressor.uncompress(data, SszLengthBounds.ofBytes(0, 1000), GOSSIP_MAX_SIZE))
() -> compressor.uncompress(data, SszLengthBounds.ofBytes(0, 1000), MAX_PAYLOAD_SIZE))
.isInstanceOf(DecodingException.class);
}

Expand All @@ -53,7 +53,8 @@ void uncompress_uncompressedLengthLongerThanSszLenghtBounds() {

final Bytes compressed = compressor.compress(original);
assertThatThrownBy(
() -> compressor.uncompress(compressed, SszLengthBounds.ofBytes(0, 4), GOSSIP_MAX_SIZE))
() ->
compressor.uncompress(compressed, SszLengthBounds.ofBytes(0, 4), MAX_PAYLOAD_SIZE))
.isInstanceOf(DecodingException.class)
.hasMessageContaining("not within expected bounds");
}
Expand All @@ -67,7 +68,7 @@ void uncompress_uncompressedLengthShorterThanSszLengthBounds() {
assertThatThrownBy(
() ->
compressor.uncompress(
compressed, SszLengthBounds.ofBytes(100, 200), GOSSIP_MAX_SIZE))
compressed, SszLengthBounds.ofBytes(100, 200), MAX_PAYLOAD_SIZE))
.isInstanceOf(DecodingException.class)
.hasMessageContaining("not within expected bounds");
}
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
Loading
Loading