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

8767 electra blob config params #8790

Closed
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
26 changes: 23 additions & 3 deletions ethereum/spec/src/main/java/tech/pegasys/teku/spec/Spec.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import static tech.pegasys.teku.infrastructure.time.TimeUtilities.millisToSeconds;
import static tech.pegasys.teku.infrastructure.time.TimeUtilities.secondsToMillis;
import static tech.pegasys.teku.spec.SpecMilestone.DENEB;
import static tech.pegasys.teku.spec.SpecMilestone.ELECTRA;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Preconditions;
Expand Down Expand Up @@ -48,9 +49,11 @@
import tech.pegasys.teku.spec.cache.IndexedAttestationCache;
import tech.pegasys.teku.spec.config.NetworkingSpecConfig;
import tech.pegasys.teku.spec.config.NetworkingSpecConfigDeneb;
import tech.pegasys.teku.spec.config.NetworkingSpecConfigElectra;
import tech.pegasys.teku.spec.config.SpecConfig;
import tech.pegasys.teku.spec.config.SpecConfigAltair;
import tech.pegasys.teku.spec.config.SpecConfigDeneb;
import tech.pegasys.teku.spec.config.SpecConfigElectra;
import tech.pegasys.teku.spec.constants.Domain;
import tech.pegasys.teku.spec.datastructures.attestation.ValidatableAttestation;
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.Blob;
Expand Down Expand Up @@ -220,6 +223,16 @@ public Optional<NetworkingSpecConfigDeneb> getNetworkingConfigDeneb() {
.map(specConfig -> (NetworkingSpecConfigDeneb) specConfig.getNetworkingConfig());
}

/**
* Networking config with Electra constants. Use {@link SpecConfigElectra#required(SpecConfig)}
* when you are sure that Electra is available, otherwise use this method
*/
public Optional<NetworkingSpecConfigElectra> getNetworkingConfigElectra() {
return Optional.ofNullable(forMilestone(ELECTRA))
.map(SpecVersion::getConfig)
.map(specConfig -> (NetworkingSpecConfigElectra) specConfig.getNetworkingConfig());
}

public SchemaDefinitions getGenesisSchemaDefinitions() {
return getGenesisSpec().getSchemaDefinitions();
}
Expand Down Expand Up @@ -945,9 +958,10 @@ public Optional<Integer> getMaxBlobsPerBlock(final UInt64 slot) {
}

public UInt64 computeSubnetForBlobSidecar(final BlobSidecar blobSidecar) {
final SpecConfig config = atSlot(blobSidecar.getSlot()).getConfig();
final SpecConfigDeneb specConfigDeneb = SpecConfigDeneb.required(config);
return blobSidecar.getIndex().mod(specConfigDeneb.getBlobSidecarSubnetCount());
final SpecVersion specVersion = atSlot(blobSidecar.getSlot());
return blobSidecar
.getIndex()
.mod(getBlobSidecarSubnetCount(specVersion.getMilestone(), specVersion.getConfig()));
}

public Optional<UInt64> computeFirstSlotWithBlobSupport() {
Expand All @@ -961,6 +975,12 @@ public boolean isFormerDepositMechanismDisabled(final BeaconState state) {
return atState(state).miscHelpers().isFormerDepositMechanismDisabled(state);
}

private int getBlobSidecarSubnetCount(final SpecMilestone milestone, final SpecConfig config) {
return milestone.isGreaterThanOrEqualTo(ELECTRA)
? SpecConfigElectra.required(config).getBlobSidecarSubnetCountElectra()
: SpecConfigDeneb.required(config).getBlobSidecarSubnetCount();
}

// Deneb private helpers
private Optional<SpecConfigDeneb> getSpecConfigDeneb() {
final SpecMilestone highestSupportedMilestone =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright Consensys Software Inc., 2024
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/

package tech.pegasys.teku.spec.config;

/**
* Networking constants
*
* <p>These constants are unified among forks and are not overridden, new constant name is used if
* it's changed in the new fork
*/
public interface NetworkingSpecConfigElectra {

int getMaxRequestBlobSidecarsElectra();

int getBlobSidecarSubnetCountElectra();
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import tech.pegasys.teku.infrastructure.bytes.Bytes4;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;

public interface SpecConfigElectra extends SpecConfigDeneb {
public interface SpecConfigElectra extends SpecConfigDeneb, NetworkingSpecConfigElectra {

UInt64 UNSET_DEPOSIT_REQUESTS_START_INDEX = UInt64.MAX_VALUE;
UInt64 FULL_EXIT_REQUEST_AMOUNT = UInt64.ZERO;
Expand Down Expand Up @@ -66,6 +66,10 @@ static SpecConfigElectra required(final SpecConfig specConfig) {

int getMaxPendingDepositsPerEpoch();

int getMaxBlobsPerBlockElectra();

int getTargetBlobsPerBlockElectra();

@Override
Optional<SpecConfigElectra> toVersionElectra();
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public class SpecConfigElectraImpl extends DelegatingSpecConfigDeneb implements
private final int maxWithdrawalRequestsPerPayload;
private final int maxPendingPartialsPerWithdrawalsSweep;
private final int maxPendingDepositsPerEpoch;
private final int maxBlobsPerBlockElectra;
private final int targetBlobsPerBlockElectra;
private final int maxRequestBlobSidecarsElectra;
private final int blobSidecarSubnetCountElectra;

public SpecConfigElectraImpl(
final SpecConfigDeneb specConfig,
Expand All @@ -58,7 +62,11 @@ public SpecConfigElectraImpl(
final int maxDepositRequestsPerPayload,
final int maxWithdrawalRequestsPerPayload,
final int maxPendingPartialsPerWithdrawalsSweep,
final int maxPendingDepositsPerEpoch) {
final int maxPendingDepositsPerEpoch,
final int maxBlobsPerBlockElectra,
final int targetBlobsPerBlockElectra,
final int maxRequestBlobSidecarsElectra,
final int blobSidecarSubnetCountElectra) {
super(specConfig);
this.electraForkVersion = electraForkVersion;
this.electraForkEpoch = electraForkEpoch;
Expand All @@ -77,6 +85,10 @@ public SpecConfigElectraImpl(
this.maxWithdrawalRequestsPerPayload = maxWithdrawalRequestsPerPayload;
this.maxPendingPartialsPerWithdrawalsSweep = maxPendingPartialsPerWithdrawalsSweep;
this.maxPendingDepositsPerEpoch = maxPendingDepositsPerEpoch;
this.maxBlobsPerBlockElectra = maxBlobsPerBlockElectra;
this.targetBlobsPerBlockElectra = targetBlobsPerBlockElectra;
this.maxRequestBlobSidecarsElectra = maxRequestBlobSidecarsElectra;
this.blobSidecarSubnetCountElectra = blobSidecarSubnetCountElectra;
}

@Override
Expand Down Expand Up @@ -164,6 +176,26 @@ public int getMaxPendingDepositsPerEpoch() {
return maxPendingDepositsPerEpoch;
}

@Override
public int getMaxBlobsPerBlockElectra() {
return maxBlobsPerBlockElectra;
}

@Override
public int getTargetBlobsPerBlockElectra() {
return targetBlobsPerBlockElectra;
}

@Override
public int getBlobSidecarSubnetCountElectra() {
return blobSidecarSubnetCountElectra;
}

@Override
public int getMaxRequestBlobSidecarsElectra() {
return maxRequestBlobSidecarsElectra;
}

@Override
public Optional<SpecConfigElectra> toVersionElectra() {
return Optional.of(this);
Expand Down Expand Up @@ -195,7 +227,11 @@ public boolean equals(final Object o) {
&& maxDepositRequestsPerPayload == that.maxDepositRequestsPerPayload
&& maxWithdrawalRequestsPerPayload == that.maxWithdrawalRequestsPerPayload
&& maxPendingPartialsPerWithdrawalsSweep == that.maxPendingPartialsPerWithdrawalsSweep
&& maxPendingDepositsPerEpoch == that.maxPendingDepositsPerEpoch;
&& maxPendingDepositsPerEpoch == that.maxPendingDepositsPerEpoch
&& maxBlobsPerBlockElectra == that.maxBlobsPerBlockElectra
&& targetBlobsPerBlockElectra == that.targetBlobsPerBlockElectra
&& maxRequestBlobSidecarsElectra == that.maxRequestBlobSidecarsElectra
&& blobSidecarSubnetCountElectra == that.blobSidecarSubnetCountElectra;
}

@Override
Expand All @@ -218,6 +254,10 @@ public int hashCode() {
maxDepositRequestsPerPayload,
maxWithdrawalRequestsPerPayload,
maxPendingPartialsPerWithdrawalsSweep,
maxPendingDepositsPerEpoch);
maxPendingDepositsPerEpoch,
maxBlobsPerBlockElectra,
targetBlobsPerBlockElectra,
maxRequestBlobSidecarsElectra,
blobSidecarSubnetCountElectra);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public class ElectraBuilder implements ForkConfigBuilder<SpecConfigDeneb, SpecCo
private Integer maxWithdrawalRequestsPerPayload;
private Integer maxPendingPartialsPerWithdrawalsSweep;
private Integer maxPendingDepositsPerEpoch;
private Integer maxBlobsPerBlockElectra;
private Integer targetBlobsPerBlockElectra;
private Integer maxRequestBlobSidecarsElectra;
private Integer blobSidecarSubnetCountElectra;

ElectraBuilder() {}

Expand All @@ -69,7 +73,11 @@ public SpecConfigElectra build(final SpecConfigDeneb specConfig) {
maxDepositRequestsPerPayload,
maxWithdrawalRequestsPerPayload,
maxPendingPartialsPerWithdrawalsSweep,
maxPendingDepositsPerEpoch);
maxPendingDepositsPerEpoch,
maxBlobsPerBlockElectra,
targetBlobsPerBlockElectra,
maxRequestBlobSidecarsElectra,
blobSidecarSubnetCountElectra);
}

public ElectraBuilder electraForkEpoch(final UInt64 electraForkEpoch) {
Expand Down Expand Up @@ -180,6 +188,30 @@ public ElectraBuilder maxPendingDepositsPerEpoch(final Integer maxPendingDeposit
return this;
}

public ElectraBuilder maxBlobsPerBlockElectra(final Integer maxBlobsPerBlockElectra) {
checkNotNull(maxBlobsPerBlockElectra);
this.maxBlobsPerBlockElectra = maxBlobsPerBlockElectra;
return this;
}

public ElectraBuilder targetBlobsPerBlockElectra(final Integer targetBlobsPerBlockElectra) {
checkNotNull(targetBlobsPerBlockElectra);
this.targetBlobsPerBlockElectra = targetBlobsPerBlockElectra;
return this;
}

public ElectraBuilder maxRequestBlobSidecarsElectra(final Integer maxRequestBlobSidecarsElectra) {
checkNotNull(maxRequestBlobSidecarsElectra);
this.maxRequestBlobSidecarsElectra = maxRequestBlobSidecarsElectra;
return this;
}

public ElectraBuilder blobSidecarSubnetCountElectra(final Integer blobSidecarSubnetCountElectra) {
checkNotNull(blobSidecarSubnetCountElectra);
this.blobSidecarSubnetCountElectra = blobSidecarSubnetCountElectra;
return this;
}

@Override
public void validate() {
if (electraForkEpoch == null) {
Expand Down Expand Up @@ -216,6 +248,10 @@ public Map<String, Object> getValidationMap() {
constants.put("maxWithdrawalRequestsPerPayload", maxWithdrawalRequestsPerPayload);
constants.put("maxPendingPartialsPerWithdrawalsSweep", maxPendingPartialsPerWithdrawalsSweep);
constants.put("maxPendingDepositsPerEpoch", maxPendingDepositsPerEpoch);
constants.put("maxBlobsPerBlockElectra", maxBlobsPerBlockElectra);
constants.put("targetBlobsPerBlockElectra", targetBlobsPerBlockElectra);
constants.put("maxRequestBlobSidecarsElectra", maxRequestBlobSidecarsElectra);
constants.put("blobSidecarSubnetCountElectra", blobSidecarSubnetCountElectra);

return constants;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,18 @@ public UInt64 getMaxRequestBlocks() {
return UInt64.valueOf(specConfig.getNetworkingConfig().getMaxRequestBlocks());
}

public int getMaxRequestBlobSidecars() {
throw new UnsupportedOperationException("No Blob Sidecars before Deneb");
}

public int getMaxBlobsPerBlock() {
throw new UnsupportedOperationException("No Blob Sidecars before Deneb");
}

public int getBlobSidecarSubnetCount() {
throw new UnsupportedOperationException("No Blob Sidecars before Deneb");
}

public UInt64 getMaxEffectiveBalance(final Validator validator) {
return specConfig.getMaxEffectiveBalance();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,21 @@ public Optional<MiscHelpersDeneb> toVersionDeneb() {
return Optional.of(this);
}

@Override
public int getMaxRequestBlobSidecars() {
return SpecConfigDeneb.required(specConfig).getMaxRequestBlobSidecars();
}

@Override
public int getMaxBlobsPerBlock() {
return SpecConfigDeneb.required(specConfig).getMaxBlobsPerBlock();
}

@Override
public int getBlobSidecarSubnetCount() {
return SpecConfigDeneb.required(specConfig).getBlobSidecarSubnetCount();
}

public int getBlobKzgCommitmentsCount(final SignedBeaconBlock signedBeaconBlock) {
return signedBeaconBlock
.getMessage()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,19 @@ public boolean isFormerDepositMechanismDisabled(final BeaconState state) {
.getEth1DepositIndex()
.equals(BeaconStateElectra.required(state).getDepositRequestsStartIndex());
}

@Override
public int getMaxRequestBlobSidecars() {
return SpecConfigElectra.required(specConfig).getMaxRequestBlobSidecarsElectra();
}

@Override
public int getMaxBlobsPerBlock() {
return SpecConfigElectra.required(specConfig).getMaxBlobsPerBlockElectra();
}

@Override
public int getBlobSidecarSubnetCount() {
return SpecConfigElectra.required(specConfig).getBlobSidecarSubnetCountElectra();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,11 @@ MAX_REQUEST_BLOB_SIDECARS: 768
# `2**14` (= 16384 epochs, ~15 days)
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: 16384
# `6`
BLOB_SIDECAR_SUBNET_COUNT: 6
BLOB_SIDECAR_SUBNET_COUNT: 6

# Electra
MAX_BLOBS_PER_BLOCK_ELECTRA: 8
TARGET_BLOBS_PER_BLOCK_ELECTRA: 4
# MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_ELECTRA
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: 1024
BLOB_SIDECAR_SUBNET_COUNT_ELECTRA: 8
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: 4096
# `6`
BLOB_SIDECAR_SUBNET_COUNT: 6

# Electra
MAX_BLOBS_PER_BLOCK_ELECTRA: 8
TARGET_BLOBS_PER_BLOCK_ELECTRA: 4
# MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_ELECTRA
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: 1024
BLOB_SIDECAR_SUBNET_COUNT_ELECTRA: 8

# [New in Electra:EIP7251]
MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA: 128000000000 # 2**7 * 10**9 (= 128,000,000,000)
MAX_PER_EPOCH_ACTIVATION_EXIT_CHURN_LIMIT: 256000000000 # 2**8 * 10**9 (= 256,000,000,000)
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,11 @@ MAX_REQUEST_BLOB_SIDECARS: 768
# `2**14` (= 16384 epochs, ~15 days)
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: 16384
# `6`
BLOB_SIDECAR_SUBNET_COUNT: 6
BLOB_SIDECAR_SUBNET_COUNT: 6

# Electra
MAX_BLOBS_PER_BLOCK_ELECTRA: 8
TARGET_BLOBS_PER_BLOCK_ELECTRA: 4
# MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_ELECTRA
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: 1024
BLOB_SIDECAR_SUBNET_COUNT_ELECTRA: 8
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,11 @@ MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: 4096
# `6`
BLOB_SIDECAR_SUBNET_COUNT: 6
# `uint64(6)`
MAX_BLOBS_PER_BLOCK: 6
MAX_BLOBS_PER_BLOCK: 6

# Electra
MAX_BLOBS_PER_BLOCK_ELECTRA: 8
TARGET_BLOBS_PER_BLOCK_ELECTRA: 4
# MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_ELECTRA
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: 1024
BLOB_SIDECAR_SUBNET_COUNT_ELECTRA: 8
Loading