Skip to content

Commit b610255

Browse files
authored
eip-7251 updated config, epochProcessor interface (Consensys#8210)
- renamed getChurnLimit -> getBalanceChurnLimit - added getMaxPerEpochActivationExitChurnLimit and defaulted value. - added PredicatesElectra.required logic - added queue_entire_balance - added the epochProcessor interface, but haven't built out the electra versions now that more of this is actually merged it should hopefully start to stabilize a bit... Working on the dev (consensus-specs) version, not on PR versions any longer. Signed-off-by: Paul Harris <[email protected]>
1 parent 30bae25 commit b610255

File tree

22 files changed

+266
-44
lines changed

22 files changed

+266
-44
lines changed

ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/DelegatingSpecConfig.java

+5
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ public int getMinPerEpochChurnLimit() {
7171
return specConfig.getMinPerEpochChurnLimit();
7272
}
7373

74+
@Override
75+
public UInt64 getMaxPerEpochActivationExitChurnLimit() {
76+
return specConfig.getMaxPerEpochActivationExitChurnLimit();
77+
}
78+
7479
@Override
7580
public int getChurnLimitQuotient() {
7681
return specConfig.getChurnLimitQuotient();

ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/SpecConfig.java

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ default int getMillisPerSlot() {
6262

6363
int getMinPerEpochChurnLimit();
6464

65+
UInt64 getMaxPerEpochActivationExitChurnLimit();
66+
6567
int getChurnLimitQuotient();
6668

6769
// Config: Fork choice

ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/SpecConfigElectra.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ static SpecConfigElectra required(final SpecConfig specConfig) {
5353

5454
int getMaxPartialWithdrawalsPerPayload();
5555

56-
UInt64 getMinPerEpochChurnLimitElectra();
56+
int getMaxWithdrawalRequestsPerPayload();
5757

58-
UInt64 getMaxPerEpochActivationExitChurnLimit();
58+
UInt64 getMinPerEpochChurnLimitElectra();
5959

6060
Bytes4 getElectraForkVersion();
6161

ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/SpecConfigElectraImpl.java

+9-8
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public class SpecConfigElectraImpl extends DelegatingSpecConfigDeneb implements
2323
private final Bytes4 electraForkVersion;
2424
private final UInt64 electraForkEpoch;
2525
private final UInt64 minPerEpochChurnLimitElectra;
26-
private final UInt64 maxPerEpochActivationExitChurnLimit;
2726

2827
private final int maxDepositReceiptsPerPayload;
2928
private final int maxExecutionLayerExits;
@@ -39,14 +38,15 @@ public class SpecConfigElectraImpl extends DelegatingSpecConfigDeneb implements
3938
private final int maxAttestationsElectra;
4039
private final int maxConsolidations;
4140

41+
private final int maxWithdrawalRequestsPerPayload;
42+
4243
public SpecConfigElectraImpl(
4344
final SpecConfigDeneb specConfig,
4445
final Bytes4 electraForkVersion,
4546
final UInt64 electraForkEpoch,
4647
final int maxDepositReceiptsPerPayload,
4748
final int maxExecutionLayerExits,
4849
final UInt64 minPerEpochChurnLimitElectra,
49-
final UInt64 maxPerEpochActivationExitChurnLimit,
5050
final UInt64 minActivationBalance,
5151
final UInt64 maxEffectiveBalanceElectra,
5252
final int pendingBalanceDepositsLimit,
@@ -57,14 +57,14 @@ public SpecConfigElectraImpl(
5757
final int maxPartialWithdrawalsPerPayload,
5858
final int maxAttesterSlashingsElectra,
5959
final int maxAttestationsElectra,
60-
final int maxConsolidations) {
60+
final int maxConsolidations,
61+
final int maxWithdrawalRequestsPerPayload) {
6162
super(specConfig);
6263
this.electraForkVersion = electraForkVersion;
6364
this.electraForkEpoch = electraForkEpoch;
6465
this.maxDepositReceiptsPerPayload = maxDepositReceiptsPerPayload;
6566
this.maxExecutionLayerExits = maxExecutionLayerExits;
6667
this.minPerEpochChurnLimitElectra = minPerEpochChurnLimitElectra;
67-
this.maxPerEpochActivationExitChurnLimit = maxPerEpochActivationExitChurnLimit;
6868
this.minActivationBalance = minActivationBalance;
6969
this.maxEffectiveBalanceElectra = maxEffectiveBalanceElectra;
7070
this.pendingBalanceDepositsLimit = pendingBalanceDepositsLimit;
@@ -76,6 +76,7 @@ public SpecConfigElectraImpl(
7676
this.maxAttesterSlashingsElectra = maxAttesterSlashingsElectra;
7777
this.maxAttestationsElectra = maxAttestationsElectra;
7878
this.maxConsolidations = maxConsolidations;
79+
this.maxWithdrawalRequestsPerPayload = maxWithdrawalRequestsPerPayload;
7980
}
8081

8182
@Override
@@ -159,13 +160,13 @@ public UInt64 getMinPerEpochChurnLimitElectra() {
159160
}
160161

161162
@Override
162-
public UInt64 getMaxPerEpochActivationExitChurnLimit() {
163-
return maxPerEpochActivationExitChurnLimit;
163+
public Optional<SpecConfigElectra> toVersionElectra() {
164+
return Optional.of(this);
164165
}
165166

166167
@Override
167-
public Optional<SpecConfigElectra> toVersionElectra() {
168-
return Optional.of(this);
168+
public int getMaxWithdrawalRequestsPerPayload() {
169+
return maxWithdrawalRequestsPerPayload;
169170
}
170171

171172
@Override

ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/SpecConfigPhase0.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ public class SpecConfigPhase0 implements SpecConfig {
120120
private final int reorgHeadWeightThreshold;
121121
private final int reorgParentWeightThreshold;
122122

123+
private final UInt64 maxPerEpochActivationExitChurnLimit;
124+
123125
public SpecConfigPhase0(
124126
final Map<String, Object> rawConfig,
125127
final UInt64 eth1FollowDistance,
@@ -188,7 +190,8 @@ public SpecConfigPhase0(
188190
final int attestationSubnetPrefixBits,
189191
final int reorgMaxEpochsSinceFinalization,
190192
final int reorgHeadWeightThreshold,
191-
final int reorgParentWeightThreshold) {
193+
final int reorgParentWeightThreshold,
194+
final UInt64 maxPerEpochActivationExitChurnLimit) {
192195
this.rawConfig = rawConfig;
193196
this.eth1FollowDistance = eth1FollowDistance;
194197
this.maxCommitteesPerSlot = maxCommitteesPerSlot;
@@ -258,6 +261,7 @@ public SpecConfigPhase0(
258261
this.reorgMaxEpochsSinceFinalization = reorgMaxEpochsSinceFinalization;
259262
this.reorgHeadWeightThreshold = reorgHeadWeightThreshold;
260263
this.reorgParentWeightThreshold = reorgParentWeightThreshold;
264+
this.maxPerEpochActivationExitChurnLimit = maxPerEpochActivationExitChurnLimit;
261265
}
262266

263267
@Override
@@ -305,6 +309,11 @@ public int getMinPerEpochChurnLimit() {
305309
return minPerEpochChurnLimit;
306310
}
307311

312+
@Override
313+
public UInt64 getMaxPerEpochActivationExitChurnLimit() {
314+
return maxPerEpochActivationExitChurnLimit;
315+
}
316+
308317
@Override
309318
public int getChurnLimitQuotient() {
310319
return churnLimitQuotient;

ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/builder/ElectraBuilder.java

+10-11
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ public class ElectraBuilder implements ForkConfigBuilder<SpecConfigDeneb, SpecCo
3232
private UInt64 electraForkEpoch;
3333
// TODO: remove default when EIP-7251 become part of the Electra
3434
private UInt64 minPerEpochChurnLimitElectra = UInt64.ZERO;
35-
// TODO: remove default when EIP-7251 become part of the Electra
36-
private UInt64 maxPerEpochActivationExitChurnLimit = UInt64.ZERO;
3735
private Integer maxDepositReceiptsPerPayload;
3836
private Integer maxExecutionLayerExits;
3937
private UInt64 minActivationBalance;
@@ -44,6 +42,7 @@ public class ElectraBuilder implements ForkConfigBuilder<SpecConfigDeneb, SpecCo
4442
private Integer whistleblowerRewardQuotientElectra;
4543
private Integer minSlashingPenaltyQuotientElectra;
4644
private Integer maxPartialWithdrawalsPerPayload;
45+
private Integer maxWithdrawalRequestsPerPayload;
4746
private Integer maxAttesterSlashingsElectra;
4847
private Integer maxAttestationsElectra;
4948
private Integer maxConsolidations;
@@ -59,7 +58,6 @@ public SpecConfigElectra build(final SpecConfigDeneb specConfig) {
5958
maxDepositReceiptsPerPayload,
6059
maxExecutionLayerExits,
6160
minPerEpochChurnLimitElectra,
62-
maxPerEpochActivationExitChurnLimit,
6361
minActivationBalance,
6462
maxEffectiveBalanceElectra,
6563
pendingBalanceDepositsLimit,
@@ -70,7 +68,8 @@ public SpecConfigElectra build(final SpecConfigDeneb specConfig) {
7068
maxPartialWithdrawalsPerPayload,
7169
maxAttesterSlashingsElectra,
7270
maxAttestationsElectra,
73-
maxConsolidations);
71+
maxConsolidations,
72+
maxWithdrawalRequestsPerPayload);
7473
}
7574

7675
public ElectraBuilder electraForkEpoch(final UInt64 electraForkEpoch) {
@@ -103,13 +102,6 @@ public ElectraBuilder minPerEpochChurnLimitElectra(final UInt64 minPerEpochChurn
103102
return this;
104103
}
105104

106-
public ElectraBuilder maxPerEpochActivationExitChurnLimit(
107-
final UInt64 maxPerEpochActivationExitChurnLimit) {
108-
checkNotNull(maxPerEpochActivationExitChurnLimit);
109-
this.maxPerEpochActivationExitChurnLimit = maxPerEpochActivationExitChurnLimit;
110-
return this;
111-
}
112-
113105
public ElectraBuilder minActivationBalance(final UInt64 minActivationBalance) {
114106
checkNotNull(minActivationBalance);
115107
this.minActivationBalance = minActivationBalance;
@@ -162,6 +154,13 @@ public ElectraBuilder maxPartialWithdrawalsPerPayload(
162154
return this;
163155
}
164156

157+
public ElectraBuilder maxWithdrawalRequestsPerPayload(
158+
final Integer maxWithdrawalRequestsPerPayload) {
159+
checkNotNull(maxWithdrawalRequestsPerPayload);
160+
this.maxWithdrawalRequestsPerPayload = maxWithdrawalRequestsPerPayload;
161+
return this;
162+
}
163+
165164
public ElectraBuilder maxAttesterSlashingsElectra(final Integer maxAttesterSlashingsElectra) {
166165
checkNotNull(maxAttesterSlashingsElectra);
167166
this.maxAttesterSlashingsElectra = maxAttesterSlashingsElectra;

ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/builder/SpecConfigBuilder.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ public class SpecConfigBuilder {
130130

131131
private Integer reorgParentWeightThreshold = 160;
132132

133+
private UInt64 maxPerEpochActivationExitChurnLimit = UInt64.valueOf(256000000000L);
133134
private final BuilderChain<SpecConfig, SpecConfigElectra> builderChain =
134135
BuilderChain.create(new AltairBuilder())
135136
.appendBuilder(new BellatrixBuilder())
@@ -214,7 +215,8 @@ public SpecConfig build() {
214215
attestationSubnetPrefixBits,
215216
reorgMaxEpochsSinceFinalization,
216217
reorgHeadWeightThreshold,
217-
reorgParentWeightThreshold);
218+
reorgParentWeightThreshold,
219+
maxPerEpochActivationExitChurnLimit);
218220

219221
return builderChain.build(config);
220222
}
@@ -537,6 +539,13 @@ public SpecConfigBuilder proposerRewardQuotient(final UInt64 proposerRewardQuoti
537539
return this;
538540
}
539541

542+
public SpecConfigBuilder maxPerEpochActivationExitChurnLimit(
543+
final UInt64 maxPerEpochActivationExitChurnLimit) {
544+
checkNotNull(maxPerEpochActivationExitChurnLimit);
545+
this.maxPerEpochActivationExitChurnLimit = maxPerEpochActivationExitChurnLimit;
546+
return this;
547+
}
548+
540549
public SpecConfigBuilder inactivityPenaltyQuotient(final UInt64 inactivityPenaltyQuotient) {
541550
checkNotNull(inactivityPenaltyQuotient);
542551
this.inactivityPenaltyQuotient = inactivityPenaltyQuotient;

ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/common/helpers/Predicates.java

+6
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616
import static tech.pegasys.teku.infrastructure.crypto.Hash.getSha256Instance;
1717
import static tech.pegasys.teku.spec.constants.WithdrawalPrefixes.ETH1_ADDRESS_WITHDRAWAL_BYTE;
1818

19+
import java.util.Optional;
1920
import org.apache.tuweni.bytes.Bytes32;
2021
import tech.pegasys.teku.infrastructure.crypto.Sha256;
2122
import tech.pegasys.teku.infrastructure.ssz.collections.SszBytes32Vector;
2223
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
2324
import tech.pegasys.teku.spec.config.SpecConfig;
2425
import tech.pegasys.teku.spec.datastructures.state.Validator;
26+
import tech.pegasys.teku.spec.logic.versions.electra.helpers.PredicatesElectra;
2527

2628
public class Predicates {
2729

@@ -133,4 +135,8 @@ public boolean isPartiallyWithdrawableValidatorEth1CredentialsChecked(
133135

134136
return hasMaxEffectiveBalance && hasExcessBalance;
135137
}
138+
139+
public Optional<PredicatesElectra> toVersionElectra() {
140+
return Optional.empty();
141+
}
136142
}

ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/common/statetransition/epoch/AbstractEpochProcessor.java

+2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ protected void processEpoch(final BeaconState preState, final MutableBeaconState
118118
processRegistryUpdates(state, validatorStatuses.getStatuses());
119119
processSlashings(state, validatorStatuses);
120120
processEth1DataReset(state);
121+
processPendingBalanceDeposits(state);
122+
processPendingConsolidations(state);
121123
processEffectiveBalanceUpdates(state, validatorStatuses.getStatuses());
122124
processSlashingsReset(state);
123125
processRandaoMixesReset(state);

ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/common/statetransition/epoch/EpochProcessor.java

+4
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,8 @@ void processRegistryUpdates(MutableBeaconState state, List<ValidatorStatus> stat
9999
void processHistoricalSummariesUpdate(MutableBeaconState state);
100100

101101
void processSyncCommitteeUpdates(MutableBeaconState state);
102+
103+
void processPendingBalanceDeposits(MutableBeaconState state);
104+
105+
void processPendingConsolidations(MutableBeaconState state);
102106
}

ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/altair/statetransition/epoch/EpochProcessorAltair.java

+6
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ public void processSyncCommitteeUpdates(final MutableBeaconState genericState) {
129129
}
130130
}
131131

132+
@Override
133+
public void processPendingBalanceDeposits(final MutableBeaconState state) {}
134+
135+
@Override
136+
public void processPendingConsolidations(final MutableBeaconState state) {}
137+
132138
/**
133139
* Replaces the progressive total balances in the state transition caches with an altair one if
134140
* not already in use. This handles both upgrading on milestone transition and switching from the

ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/block/BlockProcessorElectra.java

+5
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,15 @@
4646
import tech.pegasys.teku.spec.logic.versions.altair.helpers.BeaconStateAccessorsAltair;
4747
import tech.pegasys.teku.spec.logic.versions.deneb.block.BlockProcessorDeneb;
4848
import tech.pegasys.teku.spec.logic.versions.deneb.helpers.MiscHelpersDeneb;
49+
import tech.pegasys.teku.spec.logic.versions.electra.helpers.PredicatesElectra;
4950
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsDeneb;
5051
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsElectra;
5152

5253
public class BlockProcessorElectra extends BlockProcessorDeneb {
5354

55+
@SuppressWarnings("unused")
56+
private final PredicatesElectra predicatesElectra;
57+
5458
public BlockProcessorElectra(
5559
final SpecConfigElectra specConfig,
5660
final Predicates predicates,
@@ -77,6 +81,7 @@ public BlockProcessorElectra(
7781
validatorsUtil,
7882
operationValidator,
7983
SchemaDefinitionsDeneb.required(schemaDefinitions));
84+
this.predicatesElectra = PredicatesElectra.required(predicates);
8085
}
8186

8287
@Override

ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/helpers/BeaconStateAccessorsElectra.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public BeaconStateAccessorsElectra(
4949
* @return Return the churn limit for the current epoch dedicated to activations and exits.
5050
*/
5151
public UInt64 getActivationExitChurnLimit(final BeaconStateElectra state) {
52-
return getChurnLimit(state).min(configElectra.getMaxPerEpochActivationExitChurnLimit());
52+
return getBalanceChurnLimit(state).min(configElectra.getMaxPerEpochActivationExitChurnLimit());
5353
}
5454

5555
/**
@@ -84,12 +84,12 @@ public UInt64 getPendingBalanceToWithdraw(
8484
}
8585

8686
/**
87-
* get_churn_limit
87+
* get_balance_churn_limit
8888
*
8989
* @param state the state to read active balance from
9090
* @return Return the churn limit for the current epoch.
9191
*/
92-
public UInt64 getChurnLimit(final BeaconStateElectra state) {
92+
public UInt64 getBalanceChurnLimit(final BeaconStateElectra state) {
9393
final UInt64 churn =
9494
configElectra
9595
.getMinPerEpochChurnLimitElectra()
@@ -104,7 +104,7 @@ public UInt64 getChurnLimit(final BeaconStateElectra state) {
104104
* @return
105105
*/
106106
public UInt64 getConsolidationChurnLimit(final BeaconStateElectra state) {
107-
return getChurnLimit(state).minusMinZero(getActivationExitChurnLimit(state));
107+
return getBalanceChurnLimit(state).minusMinZero(getActivationExitChurnLimit(state));
108108
}
109109

110110
public static BeaconStateAccessorsElectra required(

ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/helpers/PredicatesElectra.java

+16
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import static tech.pegasys.teku.spec.constants.WithdrawalPrefixes.COMPOUNDING_WITHDRAWAL_BYTE;
1717

18+
import java.util.Optional;
1819
import org.apache.tuweni.bytes.Bytes32;
1920
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
2021
import tech.pegasys.teku.spec.config.SpecConfig;
@@ -30,6 +31,21 @@ public PredicatesElectra(SpecConfig specConfig) {
3031
this.configElectra = SpecConfigElectra.required(specConfig);
3132
}
3233

34+
public static PredicatesElectra required(final Predicates predicates) {
35+
return predicates
36+
.toVersionElectra()
37+
.orElseThrow(
38+
() ->
39+
new IllegalArgumentException(
40+
"Expected Electra predicates but got "
41+
+ predicates.getClass().getSimpleName()));
42+
}
43+
44+
@Override
45+
public Optional<PredicatesElectra> toVersionElectra() {
46+
return Optional.of(this);
47+
}
48+
3349
/**
3450
* is_partially_withdrawable_validator
3551
*

0 commit comments

Comments
 (0)