Skip to content

Commit dec3486

Browse files
alpha.1
1 parent 56ef1a4 commit dec3486

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ allprojects {
331331
}
332332

333333
def nightly = System.getenv("NIGHTLY") != null
334-
def refTestVersion = nightly ? "nightly" : "v1.7.0-alpha.0"
334+
def refTestVersion = nightly ? "nightly" : "v1.7.0-alpha.1"
335335
def blsRefTestVersion = 'v0.1.2'
336336
def slashingProtectionInterchangeRefTestVersion = 'v5.3.0'
337337
def refTestBaseUrl = 'https://github.com/ethereum/consensus-specs/releases/download'

ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/capella/withdrawals/WithdrawalsHelpersCapella.java

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ public void processWithdrawals(
171171
expectedWithdrawals.withdrawals(),
172172
expectedWithdrawals.processedBuilderWithdrawalsCount(),
173173
expectedWithdrawals.processedPartialWithdrawalsCount(),
174-
expectedWithdrawals.processedBuildersSweepCount(),
175-
expectedWithdrawals.processedValidatorsSweepCount());
174+
expectedWithdrawals.processedBuildersSweepCount());
176175
}
177176

178177
private void assertWithdrawalsInExecutionPayloadMatchExpected(
@@ -208,17 +207,15 @@ public void processWithdrawals(final MutableBeaconState state) {
208207
expectedWithdrawals.withdrawals(),
209208
expectedWithdrawals.processedBuilderWithdrawalsCount(),
210209
expectedWithdrawals.processedPartialWithdrawalsCount(),
211-
expectedWithdrawals.processedBuildersSweepCount(),
212-
expectedWithdrawals.processedValidatorsSweepCount());
210+
expectedWithdrawals.processedBuildersSweepCount());
213211
}
214212

215213
private void processWithdrawalsUnchecked(
216214
final MutableBeaconState state,
217215
final List<Withdrawal> withdrawals,
218216
final int processedBuilderWithdrawalsCount,
219217
final int processedPartialWithdrawalsCount,
220-
final int processedBuildersSweepCount,
221-
final int processedValidatorsSweepCount) {
218+
final int processedBuildersSweepCount) {
222219

223220
applyWithdrawals(state, withdrawals);
224221

@@ -236,7 +233,7 @@ private void processWithdrawalsUnchecked(
236233

237234
updateNextWithdrawalBuilderIndex(state, processedBuildersSweepCount);
238235

239-
updateNextWithdrawalValidatorIndex(state, processedValidatorsSweepCount);
236+
updateNextWithdrawalValidatorIndex(state, withdrawals);
240237
}
241238

242239
protected void applyWithdrawals(
@@ -274,12 +271,22 @@ protected void updateNextWithdrawalBuilderIndex(
274271
final MutableBeaconState state, final int processedBuildersSweepCount) {}
275272

276273
protected void updateNextWithdrawalValidatorIndex(
277-
final MutableBeaconState state, final int processedValidatorsSweepCount) {
274+
final MutableBeaconState state, final List<Withdrawal> withdrawals) {
278275
final MutableBeaconStateCapella stateCapella = MutableBeaconStateCapella.required(state);
279-
// Update the next validator index to start the next withdrawal sweep
280-
final UInt64 nextIndex =
281-
stateCapella.getNextWithdrawalValidatorIndex().plus(processedValidatorsSweepCount);
282-
final UInt64 nextValidatorIndex = nextIndex.mod(state.getValidators().size());
283-
stateCapella.setNextWithdrawalValidatorIndex(nextValidatorIndex);
276+
277+
if (withdrawals.size() == specConfig.getMaxWithdrawalsPerPayload()) {
278+
// Next sweep starts after the latest withdrawal's validator index
279+
final UInt64 nextValidatorIndex =
280+
withdrawals.getLast().getValidatorIndex().plus(1).mod(state.getValidators().size());
281+
stateCapella.setNextWithdrawalValidatorIndex(nextValidatorIndex);
282+
} else {
283+
// Advance sweep by the max length of the sweep if there was not a full set of withdrawals
284+
final UInt64 nextIndex =
285+
stateCapella
286+
.getNextWithdrawalValidatorIndex()
287+
.plus(specConfig.getMaxValidatorsPerWithdrawalSweep());
288+
final UInt64 nextValidatorIndex = nextIndex.mod(state.getValidators().size());
289+
stateCapella.setNextWithdrawalValidatorIndex(nextValidatorIndex);
290+
}
284291
}
285292
}

0 commit comments

Comments
 (0)