From 91b4e3d121cedfe2df059dc58b8f46f1d011a8eb Mon Sep 17 00:00:00 2001 From: Paul Harris Date: Thu, 11 Apr 2024 08:02:59 +1000 Subject: [PATCH] Electra spec config and builder (#8183) * 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 --- .../teku/spec/config/SpecConfigElectra.java | 26 ++++ .../spec/config/SpecConfigElectraImpl.java | 106 ++++++++++++++- .../spec/config/builder/ElectraBuilder.java | 124 +++++++++++++++++- .../teku/spec/config/configs/mainnet.yaml | 6 +- .../teku/spec/config/configs/minimal.yaml | 6 +- .../spec/config/presets/mainnet/electra.yaml | 30 ++++- .../spec/config/presets/minimal/electra.yaml | 32 ++++- .../spec/config/presets/swift/electra.yaml | 35 ++++- .../spec/config/SpecConfigElectraTest.java | 15 ++- 9 files changed, 369 insertions(+), 11 deletions(-) diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/SpecConfigElectra.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/SpecConfigElectra.java index 73fd3e8c364..88f93843e2a 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/SpecConfigElectra.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/SpecConfigElectra.java @@ -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(); diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/SpecConfigElectraImpl.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/SpecConfigElectraImpl.java index 3d0ba197b03..5bb79a1249f 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/SpecConfigElectraImpl.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/SpecConfigElectraImpl.java @@ -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 @@ -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 toVersionElectra() { return Optional.of(this); diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/builder/ElectraBuilder.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/builder/ElectraBuilder.java index f1ab10bf21b..dc9924dd9c7 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/builder/ElectraBuilder.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/builder/ElectraBuilder.java @@ -30,8 +30,21 @@ public class ElectraBuilder implements ForkConfigBuilder 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; } diff --git a/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/configs/mainnet.yaml b/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/configs/mainnet.yaml index a706330f635..1def514bbf2 100644 --- a/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/configs/mainnet.yaml +++ b/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/configs/mainnet.yaml @@ -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 \ No newline at end of file +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) \ No newline at end of file diff --git a/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/configs/minimal.yaml b/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/configs/minimal.yaml index 87b928277bb..d913bb3b9cb 100644 --- a/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/configs/minimal.yaml +++ b/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/configs/minimal.yaml @@ -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 \ No newline at end of file +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) \ No newline at end of file diff --git a/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/presets/mainnet/electra.yaml b/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/presets/mainnet/electra.yaml index b920664fff2..adac3d4f85b 100644 --- a/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/presets/mainnet/electra.yaml +++ b/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/presets/mainnet/electra.yaml @@ -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 \ No newline at end of file +MAX_EXECUTION_LAYER_EXITS: 16 +# 2**3 (= 8) partial withdrawals +MAX_PARTIAL_WITHDRAWALS_PER_PAYLOAD: 8 \ No newline at end of file diff --git a/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/presets/minimal/electra.yaml b/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/presets/minimal/electra.yaml index ff5bd201834..f36e5a80041 100644 --- a/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/presets/minimal/electra.yaml +++ b/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/presets/minimal/electra.yaml @@ -1,8 +1,38 @@ # Minimal 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 +# [customized] smaller queue +PENDING_PARTIAL_WITHDRAWALS_LIMIT: 64 +# [customized] smaller queue +PENDING_CONSOLIDATIONS_LIMIT: 64 + +# 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 # --------------------------------------------------------------- # [customized] MAX_DEPOSIT_RECEIPTS_PER_PAYLOAD: 4 # 2**4 (= 16) exits -MAX_EXECUTION_LAYER_EXITS: 16 \ No newline at end of file +MAX_EXECUTION_LAYER_EXITS: 16 +# [customized] 2**1 (= 2) +MAX_PARTIAL_WITHDRAWALS_PER_PAYLOAD: 2 \ No newline at end of file diff --git a/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/presets/swift/electra.yaml b/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/presets/swift/electra.yaml index d8a8b77dd38..f36e5a80041 100644 --- a/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/presets/swift/electra.yaml +++ b/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/presets/swift/electra.yaml @@ -1,11 +1,38 @@ # Minimal preset - Electra -# Max operations per block +# Gwei values # --------------------------------------------------------------- -# 2**4 (= 16) -MAX_EXECUTION_LAYER_EXITS: 16 +# 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 +# [customized] smaller queue +PENDING_PARTIAL_WITHDRAWALS_LIMIT: 64 +# [customized] smaller queue +PENDING_CONSOLIDATIONS_LIMIT: 64 + +# 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 # --------------------------------------------------------------- # [customized] -MAX_DEPOSIT_RECEIPTS_PER_PAYLOAD: 4 \ No newline at end of file +MAX_DEPOSIT_RECEIPTS_PER_PAYLOAD: 4 +# 2**4 (= 16) exits +MAX_EXECUTION_LAYER_EXITS: 16 +# [customized] 2**1 (= 2) +MAX_PARTIAL_WITHDRAWALS_PER_PAYLOAD: 2 \ No newline at end of file diff --git a/ethereum/spec/src/test/java/tech/pegasys/teku/spec/config/SpecConfigElectraTest.java b/ethereum/spec/src/test/java/tech/pegasys/teku/spec/config/SpecConfigElectraTest.java index fce8ab80718..e0b79f22f73 100644 --- a/ethereum/spec/src/test/java/tech/pegasys/teku/spec/config/SpecConfigElectraTest.java +++ b/ethereum/spec/src/test/java/tech/pegasys/teku/spec/config/SpecConfigElectraTest.java @@ -83,6 +83,19 @@ private SpecConfigElectra createRandomElectraConfig( dataStructureUtil.randomBytes4(), dataStructureUtil.randomUInt64(999_999), dataStructureUtil.randomPositiveInt(16), - dataStructureUtil.randomPositiveInt(16)) {}; + dataStructureUtil.randomPositiveInt(16), + dataStructureUtil.randomUInt64(128000000000L), + dataStructureUtil.randomUInt64(256000000000L), + dataStructureUtil.randomUInt64(32000000000L), + dataStructureUtil.randomUInt64(2048000000000L), + dataStructureUtil.randomUInt64(134217728L), + dataStructureUtil.randomUInt64(134217728L), + dataStructureUtil.randomUInt64(262144L), + dataStructureUtil.randomPositiveInt(4096), + dataStructureUtil.randomPositiveInt(4096), + dataStructureUtil.randomPositiveInt(8), + dataStructureUtil.randomPositiveInt(8), + dataStructureUtil.randomPositiveInt(8), + dataStructureUtil.randomPositiveInt(8)) {}; } }