Skip to content

Commit

Permalink
Moved gossip_max_size into out of constants into spec. (#7209)
Browse files Browse the repository at this point in the history
All of the move constants are in the mainnet.yaml and minimal.yaml, just that they are all disabled except for gossip_max_size. This will be the 'todo' list of #7179.

partially addresses #7179

Signed-off-by: Paul Harris <paul.harris@consensys.net>
  • Loading branch information
rolfyone authored Jun 1, 2023
1 parent b0278a3 commit e1a73d5
Show file tree
Hide file tree
Showing 34 changed files with 185 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
public class Constants {

// Networking
public static final int GOSSIP_MAX_SIZE = 1048576; // bytes
public static final int GOSSIP_MAX_SIZE_BELLATRIX = 10485760; // bytes
public static final UInt64 MAX_REQUEST_BLOCKS = UInt64.valueOf(1024);
public static final int MAX_CHUNK_SIZE = 1048576; // bytes
public static final int MAX_CHUNK_SIZE_BELLATRIX = 10485760; // bytes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ public ProgressiveBalancesMode getProgressiveBalancesMode() {
return specConfig.getProgressiveBalancesMode();
}

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

@Override
public int getProposerScoreBoost() {
return specConfig.getProposerScoreBoost();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ static SpecConfigBuilder builder() {

ProgressiveBalancesMode getProgressiveBalancesMode();

int getGossipMaxSize();

default int getMinEpochsForBlockRequests() {
return getMinValidatorWithdrawabilityDelay() + getChurnLimitQuotient() / 2;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ public class SpecConfigPhase0 implements SpecConfig {

private final ProgressiveBalancesMode progressiveBalancesMode;

private final int gossipMaxSize;

public SpecConfigPhase0(
final Map<String, Object> rawConfig,
final UInt64 eth1FollowDistance,
Expand Down Expand Up @@ -153,7 +155,8 @@ public SpecConfigPhase0(
final long depositChainId,
final long depositNetworkId,
final Eth1Address depositContractAddress,
final ProgressiveBalancesMode progressiveBalancesMode) {
final ProgressiveBalancesMode progressiveBalancesMode,
final int gossipMaxSize) {
this.rawConfig = rawConfig;
this.eth1FollowDistance = eth1FollowDistance;
this.maxCommitteesPerSlot = maxCommitteesPerSlot;
Expand Down Expand Up @@ -206,6 +209,7 @@ public SpecConfigPhase0(
this.depositContractAddress = depositContractAddress;
this.squareRootSlotsPerEpoch = MathHelpers.integerSquareRoot(slotsPerEpoch);
this.progressiveBalancesMode = progressiveBalancesMode;
this.gossipMaxSize = gossipMaxSize;
}

@Override
Expand Down Expand Up @@ -488,6 +492,11 @@ public ProgressiveBalancesMode getProgressiveBalancesMode() {
return progressiveBalancesMode;
}

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

@Override
public boolean equals(final Object o) {
if (this == o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public class SpecConfigBuilder {

private ProgressiveBalancesMode progressiveBalancesMode = ProgressiveBalancesMode.FULL;

private int gossipMaxSize;

private final BuilderChain<SpecConfig, SpecConfigDeneb> builderChain =
BuilderChain.create(new AltairBuilder())
.appendBuilder(new BellatrixBuilder())
Expand Down Expand Up @@ -170,7 +172,8 @@ public SpecConfig build() {
depositChainId,
depositNetworkId,
depositContractAddress,
progressiveBalancesMode);
progressiveBalancesMode,
gossipMaxSize);

return builderChain.build(config);
}
Expand Down Expand Up @@ -542,6 +545,11 @@ public SpecConfigBuilder progressiveBalancesMode(
return this;
}

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

public SpecConfigBuilder altairBuilder(final Consumer<AltairBuilder> consumer) {
builderChain.withBuilder(AltairBuilder.class, consumer);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,34 @@ PROPOSER_SCORE_BOOST: 40
# Ethereum PoW Mainnet
DEPOSIT_CHAIN_ID: 1
DEPOSIT_NETWORK_ID: 1
DEPOSIT_CONTRACT_ADDRESS: 0x00000000219ab540356cBB839Cbe05303d7705Fa
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
#RESP_TIMEOUT: 10
#ATTESTATION_PROPAGATION_SLOT_RANGE: 32
## 500ms
#MAXIMUM_GOSSIP_CLOCK_DISPARITY: 500
#MESSAGE_DOMAIN_INVALID_SNAPPY: 0x00000000
#MESSAGE_DOMAIN_VALID_SNAPPY: 0x01000000
## 2 subnets per node
#SUBNETS_PER_NODE: 2
## 2**8 (= 64)
#ATTESTATION_SUBNET_COUNT: 64
#ATTESTATION_SUBNET_EXTRA_BITS: 0
## ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS
#ATTESTATION_SUBNET_PREFIX_BITS: 6
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,34 @@ PROPOSER_SCORE_BOOST: 40
DEPOSIT_CHAIN_ID: 5
DEPOSIT_NETWORK_ID: 5
# Configured on a per testnet basis
DEPOSIT_CONTRACT_ADDRESS: 0x1234567890123456789012345678901234567890
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
#RESP_TIMEOUT: 10
#ATTESTATION_PROPAGATION_SLOT_RANGE: 32
## 500ms
#MAXIMUM_GOSSIP_CLOCK_DISPARITY: 500
#MESSAGE_DOMAIN_INVALID_SNAPPY: 0x00000000
#MESSAGE_DOMAIN_VALID_SNAPPY: 0x01000000
## 2 subnets per node
#SUBNETS_PER_NODE: 2
## 2**8 (= 64)
#ATTESTATION_SUBNET_COUNT: 64
#ATTESTATION_SUBNET_EXTRA_BITS: 0
## ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS
#ATTESTATION_SUBNET_PREFIX_BITS: 6
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ MAX_TRANSACTIONS_PER_PAYLOAD: 1048576
# 2**8 (= 256)
BYTES_PER_LOGS_BLOOM: 256
# 2**5 (= 32)
MAX_EXTRA_DATA_BYTES: 32
MAX_EXTRA_DATA_BYTES: 32

# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (= 10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ MAX_TRANSACTIONS_PER_PAYLOAD: 1048576
# 2**8 (= 256)
BYTES_PER_LOGS_BLOOM: 256
# 2**5 (= 32)
MAX_EXTRA_DATA_BYTES: 32
MAX_EXTRA_DATA_BYTES: 32

# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (= 10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ MAX_TRANSACTIONS_PER_PAYLOAD: 1048576
# 2**8 (= 256)
BYTES_PER_LOGS_BLOOM: 256
# 2**5 (= 32)
MAX_EXTRA_DATA_BYTES: 32
MAX_EXTRA_DATA_BYTES: 32

# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (= 10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ MAX_TRANSACTIONS_PER_PAYLOAD: 1048576
# 2**8 (= 256)
BYTES_PER_LOGS_BLOOM: 256
# 2**5 (= 32)
MAX_EXTRA_DATA_BYTES: 32
MAX_EXTRA_DATA_BYTES: 32

# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (= 10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ MAX_TRANSACTIONS_PER_PAYLOAD: 1048576
# 2**8 (= 256)
BYTES_PER_LOGS_BLOOM: 256
# 2**5 (= 32)
MAX_EXTRA_DATA_BYTES: 32
MAX_EXTRA_DATA_BYTES: 32

# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (= 10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ MAX_TRANSACTIONS_PER_PAYLOAD: 1048576
# 2**8 (= 256)
BYTES_PER_LOGS_BLOOM: 256
# 2**5 (= 32)
MAX_EXTRA_DATA_BYTES: 32
MAX_EXTRA_DATA_BYTES: 32

# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (= 10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ MAX_TRANSACTIONS_PER_PAYLOAD: 1048576
# 2**8 (= 256)
BYTES_PER_LOGS_BLOOM: 256
# 2**5 (= 32)
MAX_EXTRA_DATA_BYTES: 32
MAX_EXTRA_DATA_BYTES: 32

# Networking
# ---------------------------------------------------------------
# `10 * 2**20` (= 10485760, 10 MiB)
GOSSIP_MAX_SIZE: 10485760
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import tech.pegasys.teku.networking.eth2.gossip.topics.OperationProcessor;
import tech.pegasys.teku.networking.p2p.discovery.DiscoveryNetwork;
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.config.SpecConfig;
import tech.pegasys.teku.spec.datastructures.attestation.ValidatableAttestation;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
import tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing;
Expand Down Expand Up @@ -84,6 +85,7 @@ public GossipForkSubscriptionsAltair(
void addSignedContributionAndProofGossipManager(final ForkInfo forkInfo) {
final SchemaDefinitionsAltair schemaDefinitions =
SchemaDefinitionsAltair.required(spec.atEpoch(getActivationEpoch()).getSchemaDefinitions());
final SpecConfig specConfig = spec.atEpoch(getActivationEpoch()).getConfig();
syncCommitteeContributionGossipManager =
new SignedContributionAndProofGossipManager(
recentChainData,
Expand All @@ -93,13 +95,14 @@ void addSignedContributionAndProofGossipManager(final ForkInfo forkInfo) {
gossipEncoding,
forkInfo,
signedContributionAndProofOperationProcessor,
getMessageMaxSize());
specConfig.getGossipMaxSize());
addGossipManager(syncCommitteeContributionGossipManager);
}

void addSyncCommitteeMessageGossipManager(final ForkInfo forkInfo) {
final SchemaDefinitionsAltair schemaDefinitions =
SchemaDefinitionsAltair.required(spec.atEpoch(getActivationEpoch()).getSchemaDefinitions());
final SpecConfig specConfig = spec.atEpoch(getActivationEpoch()).getConfig();
final SyncCommitteeSubnetSubscriptions syncCommitteeSubnetSubscriptions =
new SyncCommitteeSubnetSubscriptions(
spec,
Expand All @@ -110,7 +113,7 @@ void addSyncCommitteeMessageGossipManager(final ForkInfo forkInfo) {
asyncRunner,
syncCommitteeMessageOperationProcessor,
forkInfo,
getMessageMaxSize());
specConfig.getGossipMaxSize());
syncCommitteeMessageGossipManager =
new SyncCommitteeMessageGossipManager(
metricsSystem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

package tech.pegasys.teku.networking.eth2.gossip.forks.versions;

import static tech.pegasys.teku.spec.config.Constants.GOSSIP_MAX_SIZE_BELLATRIX;

import org.hyperledger.besu.plugin.services.MetricsSystem;
import tech.pegasys.teku.infrastructure.async.AsyncRunner;
import tech.pegasys.teku.networking.eth2.gossip.encoding.GossipEncoding;
Expand Down Expand Up @@ -68,9 +66,4 @@ public GossipForkSubscriptionsBellatrix(
signedContributionAndProofOperationProcessor,
syncCommitteeMessageOperationProcessor);
}

@Override
protected int getMessageMaxSize() {
return GOSSIP_MAX_SIZE_BELLATRIX;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import tech.pegasys.teku.networking.eth2.gossip.topics.OperationProcessor;
import tech.pegasys.teku.networking.p2p.discovery.DiscoveryNetwork;
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.config.SpecConfig;
import tech.pegasys.teku.spec.datastructures.attestation.ValidatableAttestation;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
import tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing;
Expand Down Expand Up @@ -92,6 +93,7 @@ void addSignedBlsToExecutionChangeGossipManager(final ForkInfo forkInfo) {
final SchemaDefinitionsCapella schemaDefinitions =
SchemaDefinitionsCapella.required(
spec.atEpoch(getActivationEpoch()).getSchemaDefinitions());
final SpecConfig specConfig = spec.atEpoch(getActivationEpoch()).getConfig();

final SignedBlsToExecutionChangeGossipManager gossipManager =
new SignedBlsToExecutionChangeGossipManager(
Expand All @@ -102,7 +104,7 @@ void addSignedBlsToExecutionChangeGossipManager(final ForkInfo forkInfo) {
gossipEncoding,
forkInfo,
signedBlsToExecutionChangeOperationProcessor,
getMessageMaxSize());
specConfig.getGossipMaxSize());

addGossipManager(gossipManager);
this.signedBlsToExecutionChangeGossipManager = Optional.of(gossipManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import tech.pegasys.teku.networking.eth2.gossip.topics.OperationProcessor;
import tech.pegasys.teku.networking.p2p.discovery.DiscoveryNetwork;
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.config.SpecConfig;
import tech.pegasys.teku.spec.datastructures.attestation.ValidatableAttestation;
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.SignedBlobSidecar;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
Expand Down Expand Up @@ -90,6 +91,7 @@ protected void addGossipManagers(final ForkInfo forkInfo) {
}

void addBlobSidecarGossipManager(final ForkInfo forkInfo) {
final SpecConfig specConfig = spec.atEpoch(getActivationEpoch()).getConfig();
blobSidecarGossipManager =
BlobSidecarGossipManager.create(
recentChainData,
Expand All @@ -99,7 +101,7 @@ void addBlobSidecarGossipManager(final ForkInfo forkInfo) {
gossipEncoding,
forkInfo,
blobSidecarProcessor,
getMessageMaxSize());
specConfig.getGossipMaxSize());
addGossipManager(blobSidecarGossipManager);
}

Expand Down
Loading

0 comments on commit e1a73d5

Please sign in to comment.