Skip to content

Commit

Permalink
Fixed gossipMaxSize and maxChunkSize to use bellatrix derivitives and…
Browse files Browse the repository at this point in the history
… be in presets properly. (#7217)

Signed-off-by: Paul Harris <paul.harris@consensys.net>
  • Loading branch information
rolfyone authored Jun 2, 2023
1 parent fee5763 commit 81ed42f
Show file tree
Hide file tree
Showing 28 changed files with 176 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,14 @@ public UInt256 getTerminalTotalDifficulty() {
public int getSafeSlotsToImportOptimistically() {
return specConfigBellatrix.getSafeSlotsToImportOptimistically();
}

@Override
public int getGossipMaxSizeBellatrix() {
return specConfigBellatrix.getGossipMaxSizeBellatrix();
}

@Override
public int getMaxChunkSizeBellatrix() {
return specConfigBellatrix.getMaxChunkSizeBellatrix();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,8 @@ static SpecConfigBellatrix required(SpecConfig specConfig) {
UInt256 getTerminalTotalDifficulty();

int getSafeSlotsToImportOptimistically();

int getGossipMaxSizeBellatrix();

int getMaxChunkSizeBellatrix();
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public class SpecConfigBellatrixImpl extends DelegatingSpecConfigAltair
// Optimistic Sync
private final int safeSlotsToImportOptimistically;

// network
private final int gossipMaxSizeBellatrix;
private final int maxChunkSizeBellatrix;

public SpecConfigBellatrixImpl(
final SpecConfigAltair specConfig,
final Bytes4 bellatrixForkVersion,
Expand All @@ -56,7 +60,9 @@ public SpecConfigBellatrixImpl(
final UInt256 terminalTotalDifficulty,
final Bytes32 terminalBlockHash,
final UInt64 terminalBlockHashActivationEpoch,
final int safeSlotsToImportOptimistically) {
final int safeSlotsToImportOptimistically,
final int gossipMaxSizeBellatrix,
final int maxChunkSizeBellatrix) {
super(specConfig);
this.bellatrixForkVersion = bellatrixForkVersion;
this.bellatrixForkEpoch = bellatrixForkEpoch;
Expand All @@ -71,6 +77,8 @@ public SpecConfigBellatrixImpl(
this.terminalBlockHash = terminalBlockHash;
this.terminalBlockHashActivationEpoch = terminalBlockHashActivationEpoch;
this.safeSlotsToImportOptimistically = safeSlotsToImportOptimistically;
this.gossipMaxSizeBellatrix = gossipMaxSizeBellatrix;
this.maxChunkSizeBellatrix = maxChunkSizeBellatrix;
}

public static SpecConfigBellatrix required(final SpecConfig specConfig) {
Expand Down Expand Up @@ -148,6 +156,16 @@ public int getSafeSlotsToImportOptimistically() {
return safeSlotsToImportOptimistically;
}

@Override
public int getGossipMaxSizeBellatrix() {
return gossipMaxSizeBellatrix;
}

@Override
public int getMaxChunkSizeBellatrix() {
return maxChunkSizeBellatrix;
}

@Override
public Optional<SpecConfigBellatrix> toVersionBellatrix() {
return Optional.of(this);
Expand All @@ -169,6 +187,8 @@ public boolean equals(final Object o) {
&& maxTransactionsPerPayload == that.maxTransactionsPerPayload
&& bytesPerLogsBloom == that.bytesPerLogsBloom
&& maxExtraDataBytes == that.maxExtraDataBytes
&& gossipMaxSizeBellatrix == that.gossipMaxSizeBellatrix
&& maxChunkSizeBellatrix == that.maxChunkSizeBellatrix
&& Objects.equals(bellatrixForkVersion, that.bellatrixForkVersion)
&& Objects.equals(bellatrixForkEpoch, that.bellatrixForkEpoch)
&& Objects.equals(
Expand All @@ -193,6 +213,8 @@ public int hashCode() {
maxExtraDataBytes,
terminalTotalDifficulty,
terminalBlockHash,
terminalBlockHashActivationEpoch);
terminalBlockHashActivationEpoch,
gossipMaxSizeBellatrix,
maxChunkSizeBellatrix);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,8 @@ public boolean equals(final Object o) {
&& proposerScoreBoost == that.proposerScoreBoost
&& depositChainId == that.depositChainId
&& depositNetworkId == that.depositNetworkId
&& gossipMaxSize == that.gossipMaxSize
&& maxChunkSize == that.maxChunkSize
&& Objects.equals(eth1FollowDistance, that.eth1FollowDistance)
&& Objects.equals(minGenesisTime, that.minGenesisTime)
&& Objects.equals(hysteresisQuotient, that.hysteresisQuotient)
Expand Down Expand Up @@ -621,6 +623,8 @@ public int hashCode() {
depositChainId,
depositNetworkId,
depositContractAddress,
progressiveBalancesMode);
progressiveBalancesMode,
gossipMaxSize,
maxChunkSize);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public class BellatrixBuilder implements ForkConfigBuilder<SpecConfigAltair, Spe
// Optimistic Sync
private int safeSlotsToImportOptimistically = DEFAULT_SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY;

private int gossipMaxSizeBellatrix;
private int maxChunkSizeBellatrix;

BellatrixBuilder() {}

@Override
Expand All @@ -66,7 +69,9 @@ public SpecConfigBellatrix build(final SpecConfigAltair specConfig) {
terminalTotalDifficulty,
terminalBlockHash,
terminalBlockHashActivationEpoch,
safeSlotsToImportOptimistically);
safeSlotsToImportOptimistically,
gossipMaxSizeBellatrix,
maxChunkSizeBellatrix);
}

@Override
Expand All @@ -87,6 +92,8 @@ public void validate() {
SpecBuilderUtil.validateConstant("maxTransactionsPerPayload", maxTransactionsPerPayload);
SpecBuilderUtil.validateConstant("bytesPerLogsBloom", bytesPerLogsBloom);
SpecBuilderUtil.validateConstant("maxExtraDataBytes", maxExtraDataBytes);
SpecBuilderUtil.validateConstant("gossipMaxSizeBellatrix", gossipMaxSizeBellatrix);
SpecBuilderUtil.validateConstant("maxChunkSizeBellatrix", maxChunkSizeBellatrix);

// temporary, provide default values for backward compatibility
if (terminalTotalDifficulty == null) {
Expand Down Expand Up @@ -182,4 +189,14 @@ public BellatrixBuilder safeSlotsToImportOptimistically(
this.safeSlotsToImportOptimistically = safeSlotsToImportOptimistically;
return this;
}

public BellatrixBuilder gossipMaxSizeBellatrix(final int gossipMaxSizeBellatrix) {
this.gossipMaxSizeBellatrix = gossipMaxSizeBellatrix;
return this;
}

public BellatrixBuilder maxChunkSizeBellatrix(final int maxChunkSizeBellatrix) {
this.maxChunkSizeBellatrix = maxChunkSizeBellatrix;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,12 @@ DEPOSIT_CONTRACT_ADDRESS: 0x00000000219ab540356cBB839Cbe05303d7705Fa

# Networking
# ---------------------------------------------------------------
# `2**20` (= 1048576, 1 MiB)
GOSSIP_MAX_SIZE: 1048576
# `2**10` (= 1024)
#MAX_REQUEST_BLOCKS: 1024
## `2**8` (= 256)
#EPOCHS_PER_SUBNET_SUBSCRIPTION: 256
## `MIN_VALIDATOR_WITHDRAWABILITY_DELAY + CHURN_LIMIT_QUOTIENT // 2` (= 33024, ~5 months)
#MIN_EPOCHS_FOR_BLOCK_REQUESTS: 33024
# `2**20` (=1048576, 1 MiB)
MAX_CHUNK_SIZE: 1048576
## 5s
#TTFB_TIMEOUT: 5
## 10s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,12 @@ DEPOSIT_CONTRACT_ADDRESS: 0x1234567890123456789012345678901234567890

# Networking
# ---------------------------------------------------------------
# `2**20` (= 1048576, 1 MiB)
GOSSIP_MAX_SIZE: 1048576
# `2**10` (= 1024)
#MAX_REQUEST_BLOCKS: 1024
## `2**8` (= 256)
#EPOCHS_PER_SUBNET_SUBSCRIPTION: 256
## [customized] `MIN_VALIDATOR_WITHDRAWABILITY_DELAY + CHURN_LIMIT_QUOTIENT // 2` (= 272)
#MIN_EPOCHS_FOR_BLOCK_REQUESTS: 272
# `2**20` (=1048576, 1 MiB)
MAX_CHUNK_SIZE: 1048576
## 5s
#TTFB_TIMEOUT: 5
## 10s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ MAX_EXTRA_DATA_BYTES: 32
# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (= 10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
GOSSIP_MAX_SIZE_BELLATRIX: 10485760

# `10 * 2**20` (= 10485760, 10 MiB)
MAX_CHUNK_SIZE: 10485760
# `10 * 2**20` (= 10,485,760, 10 MiB)
MAX_CHUNK_SIZE_BELLATRIX: 10485760
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,12 @@ MAX_ATTESTATIONS: 128
# 2**4 (= 16)
MAX_DEPOSITS: 16
# 2**4 (= 16)
MAX_VOLUNTARY_EXITS: 16
MAX_VOLUNTARY_EXITS: 16


# Networking
# ---------------------------------------------------------------
# `2**20` (= 1048576, 1 MiB)
GOSSIP_MAX_SIZE: 1048576
# `2**20` (=1048576, 1 MiB)
MAX_CHUNK_SIZE: 1048576
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ MAX_EXTRA_DATA_BYTES: 32
# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (= 10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
GOSSIP_MAX_SIZE_BELLATRIX: 10485760

# `10 * 2**20` (= 10485760, 10 MiB)
MAX_CHUNK_SIZE: 10485760
# `10 * 2**20` (= 10,485,760, 10 MiB)
MAX_CHUNK_SIZE_BELLATRIX: 10485760
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,12 @@ MAX_ATTESTATIONS: 128
# 2**4 (= 16)
MAX_DEPOSITS: 16
# 2**4 (= 16)
MAX_VOLUNTARY_EXITS: 16
MAX_VOLUNTARY_EXITS: 16


# Networking
# ---------------------------------------------------------------
# `2**20` (= 1048576, 1 MiB)
GOSSIP_MAX_SIZE: 1048576
# `2**20` (=1048576, 1 MiB)
MAX_CHUNK_SIZE: 1048576
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ MAX_EXTRA_DATA_BYTES: 32
# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (= 10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
GOSSIP_MAX_SIZE_BELLATRIX: 10485760

# `10 * 2**20` (= 10485760, 10 MiB)
MAX_CHUNK_SIZE: 10485760
# `10 * 2**20` (= 10,485,760, 10 MiB)
MAX_CHUNK_SIZE_BELLATRIX: 10485760
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,12 @@ MAX_ATTESTATIONS: 128
# 2**4 (= 16)
MAX_DEPOSITS: 16
# 2**4 (= 16)
MAX_VOLUNTARY_EXITS: 16
MAX_VOLUNTARY_EXITS: 16


# Networking
# ---------------------------------------------------------------
# `2**20` (= 1048576, 1 MiB)
GOSSIP_MAX_SIZE: 1048576
# `2**20` (=1048576, 1 MiB)
MAX_CHUNK_SIZE: 1048576
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ MAX_EXTRA_DATA_BYTES: 32
# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (= 10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
GOSSIP_MAX_SIZE_BELLATRIX: 10485760

# `10 * 2**20` (= 10485760, 10 MiB)
MAX_CHUNK_SIZE: 10485760
# `10 * 2**20` (= 10,485,760, 10 MiB)
MAX_CHUNK_SIZE_BELLATRIX: 10485760
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,12 @@ MAX_ATTESTATIONS: 128
# 2**4 (= 16)
MAX_DEPOSITS: 16
# 2**4 (= 16)
MAX_VOLUNTARY_EXITS: 16
MAX_VOLUNTARY_EXITS: 16


# Networking
# ---------------------------------------------------------------
# `2**20` (= 1048576, 1 MiB)
GOSSIP_MAX_SIZE: 1048576
# `2**20` (=1048576, 1 MiB)
MAX_CHUNK_SIZE: 1048576
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public void equals_mainnet() {
public void equals_sameRandomValues() {
SpecConfigAltair altair =
SpecConfigLoader.loadConfig("mainnet").toVersionAltair().orElseThrow();
;
SpecConfigBellatrix configA = createRandomBellatrixConfig(altair, 1);
SpecConfigBellatrix configB = createRandomBellatrixConfig(altair, 1);

Expand Down Expand Up @@ -94,6 +93,8 @@ private SpecConfigBellatrix createRandomBellatrixConfig(
dataStructureUtil.randomUInt256(),
dataStructureUtil.randomBytes32(),
dataStructureUtil.randomUInt64(),
dataStructureUtil.randomPositiveInt(),
dataStructureUtil.randomPositiveInt(),
dataStructureUtil.randomPositiveInt());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ MAX_EXTRA_DATA_BYTES: 32
# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (= 10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
GOSSIP_MAX_SIZE_BELLATRIX: 10485760

# `10 * 2**20` (= 10485760, 10 MiB)
MAX_CHUNK_SIZE: 10485760
# `10 * 2**20` (= 10,485,760, 10 MiB)
MAX_CHUNK_SIZE_BELLATRIX: 10485760
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,12 @@ MAX_ATTESTATIONS: 128
# 2**4 (= 16)
MAX_DEPOSITS: 16
# 2**4 (= 16)
MAX_VOLUNTARY_EXITS: 16
MAX_VOLUNTARY_EXITS: 16


# Networking
# ---------------------------------------------------------------
# `2**20` (= 1048576, 1 MiB)
GOSSIP_MAX_SIZE: 1048576
# `2**20` (=1048576, 1 MiB)
MAX_CHUNK_SIZE: 1048576
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ MAX_EXTRA_DATA_BYTES: 32
# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (= 10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
GOSSIP_MAX_SIZE_BELLATRIX: 10485760

# `10 * 2**20` (= 10485760, 10 MiB)
MAX_CHUNK_SIZE: 10485760
# `10 * 2**20` (= 10,485,760, 10 MiB)
MAX_CHUNK_SIZE_BELLATRIX: 10485760
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,12 @@ MAX_ATTESTATIONS: 128
# 2**4 (= 16)
MAX_DEPOSITS: 16
# 2**4 (= 16)
MAX_VOLUNTARY_EXITS: 16
MAX_VOLUNTARY_EXITS: 16


# Networking
# ---------------------------------------------------------------
# `2**20` (= 1048576, 1 MiB)
GOSSIP_MAX_SIZE: 1048576
# `2**20` (=1048576, 1 MiB)
MAX_CHUNK_SIZE: 1048576
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ MAX_EXTRA_DATA_BYTES: 32
# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (= 10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
GOSSIP_MAX_SIZE_BELLATRIX: 10485760

# `10 * 2**20` (= 10485760, 10 MiB)
MAX_CHUNK_SIZE: 10485760
# `10 * 2**20` (= 10,485,760, 10 MiB)
MAX_CHUNK_SIZE_BELLATRIX: 10485760
Loading

0 comments on commit 81ed42f

Please sign in to comment.