Skip to content

Commit

Permalink
Electra spec config and builder (Consensys#8183)
Browse files Browse the repository at this point in the history
* Electra spec config and builder

There were fields missing for EIP-7251, and also some of the attestation fields. I added the entire diff from consensus-specs while I was going, it seemed easiest...

Signed-off-by: Paul Harris <paul.harris@consensys.net>
  • Loading branch information
rolfyone authored Apr 10, 2024
1 parent 2c2249a commit 91b4e3d
Show file tree
Hide file tree
Showing 9 changed files with 369 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,32 @@ static SpecConfigElectra required(final SpecConfig specConfig) {
+ specConfig.getClass().getSimpleName()));
}

UInt64 getMinActivationBalance();

UInt64 getMaxEffectiveBalanceElectra();

UInt64 getPendingBalanceDepositsLimit();

UInt64 getPendingPartialWithdrawalsLimit();

UInt64 getPendingConsolidationsLimit();

int getWhistleblowerRewardQuotientElectra();

int getMinSlashingPenaltyQuotientElectra();

int getMaxAttesterSlashingsElectra();

int getMaxAttestationsElectra();

int getMaxConsolidations();

int getMaxPartialWithdrawalsPerPayload();

UInt64 getMinPerEpochChurnLimitElectra();

UInt64 getMaxPerEpochActivationExitChurnLimit();

Bytes4 getElectraForkVersion();

UInt64 getElectraForkEpoch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,60 @@ public class SpecConfigElectraImpl extends DelegatingSpecConfigDeneb implements

private final Bytes4 electraForkVersion;
private final UInt64 electraForkEpoch;
private final UInt64 minPerEpochChurnLimitElectra;
private final UInt64 maxPerEpochActivationExitChurnLimit;

private final int maxDepositReceiptsPerPayload;
private final int maxExecutionLayerExits;
private final UInt64 minActivationBalance;
private final UInt64 maxEffectiveBalanceElectra;
private final UInt64 pendingBalanceDepositsLimit;
private final UInt64 pendingPartialWithdrawalsLimit;
private final UInt64 pendingConsolidationsLimit;
private final int whistleblowerRewardQuotientElectra;
private final int minSlashingPenaltyQuotientElectra;
private final int maxPartialWithdrawalsPerPayload;
private final int maxAttesterSlashingsElectra;
private final int maxAttestationsElectra;
private final int maxConsolidations;

public SpecConfigElectraImpl(
final SpecConfigDeneb specConfig,
final Bytes4 electraForkVersion,
final UInt64 electraForkEpoch,
final int maxDepositReceiptsPerPayload,
final int maxExecutionLayerExits) {
final int maxExecutionLayerExits,
final UInt64 minPerEpochChurnLimitElectra,
final UInt64 maxPerEpochActivationExitChurnLimit,
final UInt64 minActivationBalance,
final UInt64 maxEffectiveBalanceElectra,
final UInt64 pendingBalanceDepositsLimit,
final UInt64 pendingPartialWithdrawalsLimit,
final UInt64 pendingConsolidationsLimit,
final int whistleblowerRewardQuotientElectra,
final int minSlashingPenaltyQuotientElectra,
final int maxPartialWithdrawalsPerPayload,
final int maxAttesterSlashingsElectra,
final int maxAttestationsElectra,
final int maxConsolidations) {
super(specConfig);
this.electraForkVersion = electraForkVersion;
this.electraForkEpoch = electraForkEpoch;
this.maxDepositReceiptsPerPayload = maxDepositReceiptsPerPayload;
this.maxExecutionLayerExits = maxExecutionLayerExits;
this.minPerEpochChurnLimitElectra = minPerEpochChurnLimitElectra;
this.maxPerEpochActivationExitChurnLimit = maxPerEpochActivationExitChurnLimit;
this.minActivationBalance = minActivationBalance;
this.maxEffectiveBalanceElectra = maxEffectiveBalanceElectra;
this.pendingBalanceDepositsLimit = pendingBalanceDepositsLimit;
this.pendingPartialWithdrawalsLimit = pendingPartialWithdrawalsLimit;
this.pendingConsolidationsLimit = pendingConsolidationsLimit;
this.whistleblowerRewardQuotientElectra = whistleblowerRewardQuotientElectra;
this.minSlashingPenaltyQuotientElectra = minSlashingPenaltyQuotientElectra;
this.maxPartialWithdrawalsPerPayload = maxPartialWithdrawalsPerPayload;
this.maxAttesterSlashingsElectra = maxAttesterSlashingsElectra;
this.maxAttestationsElectra = maxAttestationsElectra;
this.maxConsolidations = maxConsolidations;
}

@Override
Expand All @@ -59,6 +98,71 @@ public int getMaxExecutionLayerExits() {
return maxExecutionLayerExits;
}

@Override
public UInt64 getMinActivationBalance() {
return minActivationBalance;
}

@Override
public UInt64 getMaxEffectiveBalanceElectra() {
return maxEffectiveBalanceElectra;
}

@Override
public UInt64 getPendingBalanceDepositsLimit() {
return pendingBalanceDepositsLimit;
}

@Override
public UInt64 getPendingPartialWithdrawalsLimit() {
return pendingPartialWithdrawalsLimit;
}

@Override
public UInt64 getPendingConsolidationsLimit() {
return pendingConsolidationsLimit;
}

@Override
public int getWhistleblowerRewardQuotientElectra() {
return whistleblowerRewardQuotientElectra;
}

@Override
public int getMinSlashingPenaltyQuotientElectra() {
return minSlashingPenaltyQuotientElectra;
}

@Override
public int getMaxAttesterSlashingsElectra() {
return maxAttesterSlashingsElectra;
}

@Override
public int getMaxAttestationsElectra() {
return maxAttestationsElectra;
}

@Override
public int getMaxConsolidations() {
return maxConsolidations;
}

@Override
public int getMaxPartialWithdrawalsPerPayload() {
return maxPartialWithdrawalsPerPayload;
}

@Override
public UInt64 getMinPerEpochChurnLimitElectra() {
return minPerEpochChurnLimitElectra;
}

@Override
public UInt64 getMaxPerEpochActivationExitChurnLimit() {
return maxPerEpochActivationExitChurnLimit;
}

@Override
public Optional<SpecConfigElectra> toVersionElectra() {
return Optional.of(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,21 @@ public class ElectraBuilder implements ForkConfigBuilder<SpecConfigDeneb, SpecCo

private Bytes4 electraForkVersion;
private UInt64 electraForkEpoch;
private UInt64 minPerEpochChurnLimitElectra;
private UInt64 maxPerEpochActivationExitChurnLimit;
private Integer maxDepositReceiptsPerPayload;
private Integer maxExecutionLayerExits;
private UInt64 minActivationBalance;
private UInt64 maxEffectiveBalanceElectra;
private UInt64 pendingBalanceDepositsLimit;
private UInt64 pendingPartialWithdrawalsLimit;
private UInt64 pendingConsolidationsLimit;
private Integer whistleblowerRewardQuotientElectra;
private Integer minSlashingPenaltyQuotientElectra;
private Integer maxPartialWithdrawalsPerPayload;
private Integer maxAttesterSlashingsElectra;
private Integer maxAttestationsElectra;
private Integer maxConsolidations;

ElectraBuilder() {}

Expand All @@ -42,7 +55,20 @@ public SpecConfigElectra build(final SpecConfigDeneb specConfig) {
electraForkVersion,
electraForkEpoch,
maxDepositReceiptsPerPayload,
maxExecutionLayerExits);
maxExecutionLayerExits,
minPerEpochChurnLimitElectra,
maxPerEpochActivationExitChurnLimit,
minActivationBalance,
maxEffectiveBalanceElectra,
pendingBalanceDepositsLimit,
pendingPartialWithdrawalsLimit,
pendingConsolidationsLimit,
whistleblowerRewardQuotientElectra,
minSlashingPenaltyQuotientElectra,
maxPartialWithdrawalsPerPayload,
maxAttesterSlashingsElectra,
maxAttestationsElectra,
maxConsolidations);
}

public ElectraBuilder electraForkEpoch(final UInt64 electraForkEpoch) {
Expand All @@ -69,6 +95,89 @@ public ElectraBuilder maxExecutionLayerExits(final Integer maxExecutionLayerExit
return this;
}

public ElectraBuilder minPerEpochChurnLimitElectra(final UInt64 minPerEpochChurnLimitElectra) {
checkNotNull(minPerEpochChurnLimitElectra);
this.minPerEpochChurnLimitElectra = minPerEpochChurnLimitElectra;
return this;
}

public ElectraBuilder maxPerEpochActivationExitChurnLimit(
final UInt64 maxPerEpochActivationExitChurnLimit) {
checkNotNull(maxPerEpochActivationExitChurnLimit);
this.maxPerEpochActivationExitChurnLimit = maxPerEpochActivationExitChurnLimit;
return this;
}

public ElectraBuilder minActivationBalance(final UInt64 minActivationBalance) {
checkNotNull(minActivationBalance);
this.minActivationBalance = minActivationBalance;
return this;
}

public ElectraBuilder maxEffectiveBalanceElectra(final UInt64 maxEffectiveBalanceElectra) {
checkNotNull(maxEffectiveBalanceElectra);
this.maxEffectiveBalanceElectra = maxEffectiveBalanceElectra;
return this;
}

public ElectraBuilder pendingBalanceDepositsLimit(final UInt64 pendingBalanceDepositsLimit) {
checkNotNull(pendingBalanceDepositsLimit);
this.pendingBalanceDepositsLimit = pendingBalanceDepositsLimit;
return this;
}

public ElectraBuilder pendingPartialWithdrawalsLimit(
final UInt64 pendingPartialWithdrawalsLimit) {
checkNotNull(pendingPartialWithdrawalsLimit);
this.pendingPartialWithdrawalsLimit = pendingPartialWithdrawalsLimit;
return this;
}

public ElectraBuilder pendingConsolidationsLimit(final UInt64 pendingConsolidationsLimit) {
checkNotNull(pendingConsolidationsLimit);
this.pendingConsolidationsLimit = pendingConsolidationsLimit;
return this;
}

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

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

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

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

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

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

@Override
public void validate() {
if (electraForkEpoch == null) {
Expand All @@ -91,6 +200,19 @@ public Map<String, Object> getValidationMap() {
constants.put("electraForkEpoch", electraForkEpoch);
constants.put("electraForkVersion", electraForkVersion);
constants.put("maxDepositReceiptsPerPayload", maxDepositReceiptsPerPayload);
constants.put("minPerEpochChurnLimitElectra", minPerEpochChurnLimitElectra);
constants.put("maxExecutionLayerExits", maxExecutionLayerExits);
constants.put("minActivationBalance", minActivationBalance);
constants.put("maxEffectiveBalanceElectra", maxEffectiveBalanceElectra);
constants.put("pendingBalanceDepositsLimit", pendingBalanceDepositsLimit);
constants.put("pendingPartialWithdrawalsLimit", pendingPartialWithdrawalsLimit);
constants.put("pendingConsolidationsLimit", pendingConsolidationsLimit);
constants.put("whistleblowerRewardQuotientElectra", whistleblowerRewardQuotientElectra);
constants.put("minSlashingPenaltyQuotientElectra", minSlashingPenaltyQuotientElectra);
constants.put("maxPartialWithdrawalsPerPayload", maxPartialWithdrawalsPerPayload);
constants.put("maxAttesterSlashingsElectra", maxAttesterSlashingsElectra);
constants.put("maxAttestationsElectra", maxAttestationsElectra);
constants.put("maxConsolidations", maxConsolidations);

return constants;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,8 @@ MAX_REQUEST_BLOB_SIDECARS: 768
# `2**12` (= 4096 epochs, ~18 days)
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: 4096
# `6`
BLOB_SIDECAR_SUBNET_COUNT: 6
BLOB_SIDECAR_SUBNET_COUNT: 6

# [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 @@ -141,4 +141,8 @@ MAX_REQUEST_BLOB_SIDECARS: 768
# `2**12` (= 4096 epochs, ~18 days)
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: 4096
# `6`
BLOB_SIDECAR_SUBNET_COUNT: 6
BLOB_SIDECAR_SUBNET_COUNT: 6

# [New in Electra:EIP7251]
MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA: 64000000000 # 2**6 * 10**9 (= 64,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
@@ -1,8 +1,36 @@
# Mainnet preset - Electra

# Gwei values
# ---------------------------------------------------------------
# 2**5 * 10**9 (= 32,000,000,000) Gwei
MIN_ACTIVATION_BALANCE: 32000000000
# 2**11 * 10**9 (= 2,048,000,000,000) Gwei
MAX_EFFECTIVE_BALANCE_ELECTRA: 2048000000000

# State list lengths
# ---------------------------------------------------------------
PENDING_BALANCE_DEPOSITS_LIMIT: 134217728
PENDING_PARTIAL_WITHDRAWALS_LIMIT: 134217728
PENDING_CONSOLIDATIONS_LIMIT: 262144

# Reward and penalty quotients
# ---------------------------------------------------------------
MIN_SLASHING_PENALTY_QUOTIENT_ELECTRA: 4096
WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA: 4096

# # Max operations per block
# ---------------------------------------------------------------
# `uint64(2**0)` (= 1)
MAX_ATTESTER_SLASHINGS_ELECTRA: 1
# `uint64(2 * 3)` (= 8)
MAX_ATTESTATIONS_ELECTRA: 8
MAX_CONSOLIDATIONS: 1

# Execution
# ---------------------------------------------------------------
# 2**13 (= 8192) receipts
MAX_DEPOSIT_RECEIPTS_PER_PAYLOAD: 8192
# 2**4 (= 16) exits
MAX_EXECUTION_LAYER_EXITS: 16
MAX_EXECUTION_LAYER_EXITS: 16
# 2**3 (= 8) partial withdrawals
MAX_PARTIAL_WITHDRAWALS_PER_PAYLOAD: 8
Loading

0 comments on commit 91b4e3d

Please sign in to comment.