Skip to content

Commit dc4df35

Browse files
committed
Merge branch 'master' into graffiti-management
2 parents 1aa9649 + 283f5d6 commit dc4df35

File tree

11 files changed

+218
-15
lines changed

11 files changed

+218
-15
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ jobs:
464464
- run:
465465
name: Create and publish docker manifest
466466
command: |
467-
./gradlew --no-daemon --parallel manifestDocker
467+
./gradlew --no-daemon --parallel -PincludeCommitHashInDockerTag=<< pipeline.parameters.include_commit_hash_in_docker_tag >> manifestDocker
468468
- notify
469469

470470
extractAPISpec:

beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java

+14-4
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import tech.pegasys.teku.spec.schemas.SchemaDefinitions;
6464
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsBellatrix;
6565
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsDeneb;
66+
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsElectra;
6667
import tech.pegasys.teku.statetransition.OperationPool;
6768
import tech.pegasys.teku.statetransition.attestation.AggregatingAttestationPool;
6869
import tech.pegasys.teku.statetransition.attestation.AttestationForkChecker;
@@ -173,12 +174,21 @@ public Function<BeaconBlockBodyBuilder, SafeFuture<Void>> createSelector(
173174
blsToExecutionChangePool.getItemsForBlock(blockSlotState));
174175
}
175176

177+
final SchemaDefinitions schemaDefinitions =
178+
spec.atSlot(blockSlotState.getSlot()).getSchemaDefinitions();
179+
180+
// Post-electra: consolidations supported
181+
if (bodyBuilder.supportsConsolidations()) {
182+
// devnet0 blocks are empty of consolidations, so just default their list.
183+
bodyBuilder.consolidations(
184+
SchemaDefinitionsElectra.required(schemaDefinitions)
185+
.getConsolidationsSchema()
186+
.createFromElements(List.of()));
187+
}
188+
176189
// Execution Payload / Execution Payload Header / KZG Commitments
177190
final SafeFuture<Void> blockProductionComplete;
178191
if (bodyBuilder.supportsExecutionPayload()) {
179-
final SchemaDefinitionsBellatrix schemaDefinitions =
180-
SchemaDefinitionsBellatrix.required(
181-
spec.atSlot(blockSlotState.getSlot()).getSchemaDefinitions());
182192
blockProductionComplete =
183193
forkChoiceNotifier
184194
.getPayloadId(parentRoot, blockSlotState.getSlot())
@@ -189,7 +199,7 @@ public Function<BeaconBlockBodyBuilder, SafeFuture<Void>> createSelector(
189199
bodyBuilder,
190200
requestedBlinded,
191201
requestedBuilderBoostFactor,
192-
schemaDefinitions,
202+
SchemaDefinitionsBellatrix.required(schemaDefinitions),
193203
blockSlotState,
194204
blockProductionPerformance));
195205
} else {

beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactoryTest.java

+62-5
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
class BlockOperationSelectorFactoryTest {
103103
private final Spec spec = TestSpecFactory.createMinimalDeneb();
104104
private final Spec specBellatrix = TestSpecFactory.createMinimalBellatrix();
105+
final Spec specElectra = TestSpecFactory.createMinimalElectra();
105106
private final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec);
106107

107108
private final Function<UInt64, BeaconBlockBodySchema<?>> beaconBlockSchemaSupplier =
@@ -182,11 +183,25 @@ class BlockOperationSelectorFactoryTest {
182183
.getHeaderOfDefaultPayload();
183184

184185
private final CapturingBeaconBlockBodyBuilder bodyBuilder =
185-
new CapturingBeaconBlockBodyBuilder(false);
186+
new CapturingBeaconBlockBodyBuilder(false, false);
186187

187188
private final GraffitiBuilder graffitiBuilder =
188189
new GraffitiBuilder(ClientGraffitiAppendFormat.DISABLED, Optional.empty());
189190

191+
private final BlockOperationSelectorFactory factoryElectra =
192+
new BlockOperationSelectorFactory(
193+
specElectra,
194+
attestationPool,
195+
attesterSlashingPool,
196+
proposerSlashingPool,
197+
voluntaryExitPool,
198+
blsToExecutionChangePool,
199+
contributionPool,
200+
depositProvider,
201+
eth1DataCache,
202+
graffitiBuilder,
203+
forkChoiceNotifier,
204+
executionLayer);
190205
private final BlockOperationSelectorFactory factory =
191206
new BlockOperationSelectorFactory(
192207
spec,
@@ -622,7 +637,8 @@ void shouldIncludeExecutionPayloadIfRequestedBlindedIsEmptyAndBuilderFlowFallsBa
622637

623638
final UInt256 blockExecutionValue = dataStructureUtil.randomUInt256();
624639

625-
final CapturingBeaconBlockBodyBuilder bodyBuilder = new CapturingBeaconBlockBodyBuilder(true);
640+
final CapturingBeaconBlockBodyBuilder bodyBuilder =
641+
new CapturingBeaconBlockBodyBuilder(true, false);
626642

627643
when(forkChoiceNotifier.getPayloadId(any(), any()))
628644
.thenReturn(SafeFuture.completedFuture(Optional.of(executionPayloadContext)));
@@ -696,7 +712,8 @@ void shouldIncludeKzgCommitmentsInBlock() {
696712
blobsBundle,
697713
blockExecutionValue);
698714

699-
final CapturingBeaconBlockBodyBuilder bodyBuilder = new CapturingBeaconBlockBodyBuilder(true);
715+
final CapturingBeaconBlockBodyBuilder bodyBuilder =
716+
new CapturingBeaconBlockBodyBuilder(true, false);
700717

701718
safeJoin(
702719
factory
@@ -718,6 +735,37 @@ void shouldIncludeKzgCommitmentsInBlock() {
718735
.hasSameElementsAs(blobsBundle.getCommitments());
719736
}
720737

738+
@Test
739+
void shouldIncludeConsolidationsInBlock() {
740+
final BeaconState blockSlotState = dataStructureUtil.randomBeaconState();
741+
final ExecutionPayload randomExecutionPayload = dataStructureUtil.randomExecutionPayload();
742+
final UInt256 blockExecutionValue = dataStructureUtil.randomUInt256();
743+
final BlobsBundle blobsBundle = dataStructureUtil.randomBlobsBundle();
744+
745+
prepareBlockAndBlobsProduction(
746+
randomExecutionPayload,
747+
executionPayloadContext,
748+
blockSlotState,
749+
blobsBundle,
750+
blockExecutionValue);
751+
752+
final CapturingBeaconBlockBodyBuilder bodyBuilder =
753+
new CapturingBeaconBlockBodyBuilder(true, true);
754+
safeJoin(
755+
factoryElectra
756+
.createSelector(
757+
parentRoot,
758+
blockSlotState,
759+
dataStructureUtil.randomSignature(),
760+
Optional.empty(),
761+
Optional.of(false),
762+
Optional.empty(),
763+
BlockProductionPerformance.NOOP)
764+
.apply(bodyBuilder));
765+
766+
assertThat(bodyBuilder.consolidations).isEmpty();
767+
}
768+
721769
@Test
722770
void shouldIncludeKzgCommitmentsInBlindedBlock() {
723771
final BeaconState blockSlotState = dataStructureUtil.randomBeaconState();
@@ -737,7 +785,8 @@ void shouldIncludeKzgCommitmentsInBlindedBlock() {
737785
blobKzgCommitments,
738786
blockExecutionValue);
739787

740-
final CapturingBeaconBlockBodyBuilder bodyBuilder = new CapturingBeaconBlockBodyBuilder(true);
788+
final CapturingBeaconBlockBodyBuilder bodyBuilder =
789+
new CapturingBeaconBlockBodyBuilder(true, false);
741790

742791
safeJoin(
743792
factory
@@ -1180,6 +1229,7 @@ private void prepareCachedFallbackData(
11801229
private static class CapturingBeaconBlockBodyBuilder implements BeaconBlockBodyBuilder {
11811230

11821231
private final boolean supportsKzgCommitments;
1232+
private final boolean supportsConsolidations;
11831233

11841234
protected BLSSignature randaoReveal;
11851235
protected Bytes32 graffiti;
@@ -1195,8 +1245,10 @@ private static class CapturingBeaconBlockBodyBuilder implements BeaconBlockBodyB
11951245
@SuppressWarnings("unused")
11961246
protected SszList<SignedConsolidation> consolidations;
11971247

1198-
public CapturingBeaconBlockBodyBuilder(final boolean supportsKzgCommitments) {
1248+
public CapturingBeaconBlockBodyBuilder(
1249+
final boolean supportsKzgCommitments, final boolean supportsConsolidations) {
11991250
this.supportsKzgCommitments = supportsKzgCommitments;
1251+
this.supportsConsolidations = supportsConsolidations;
12001252
}
12011253

12021254
@Override
@@ -1293,6 +1345,11 @@ public Boolean supportsKzgCommitments() {
12931345
return supportsKzgCommitments;
12941346
}
12951347

1348+
@Override
1349+
public Boolean supportsConsolidations() {
1350+
return supportsConsolidations;
1351+
}
1352+
12961353
@Override
12971354
public BeaconBlockBodyBuilder blobKzgCommitments(
12981355
final SszList<SszKZGCommitment> blobKzgCommitments) {

build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -633,10 +633,10 @@ task manifestDocker {
633633
}
634634

635635
for (def tag in tags) {
636-
platforms.forEach { platform -> cmd += "${tag}-${platform} " }
636+
platforms.forEach { platform -> cmd += "${tag}-${platform}${commitHashTag} " }
637637
exec {
638638
executable executableAndArg[0]
639-
args executableAndArg[1], "docker manifest create ${tag} ${cmd} && docker manifest push ${tag}"
639+
args executableAndArg[1], "docker manifest create ${tag}${commitHashTag} ${cmd} && docker manifest push ${tag}${commitHashTag}"
640640
}
641641
}
642642
}

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

+4
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ public boolean isPartiallyWithdrawableValidatorEth1CredentialsChecked(
138138
return hasMaxEffectiveBalance && hasExcessBalance;
139139
}
140140

141+
public UInt64 getValidatorMaxEffectiveBalance(final Validator validator) {
142+
return specConfig.getMaxEffectiveBalance();
143+
}
144+
141145
public Optional<PredicatesElectra> toVersionElectra() {
142146
return Optional.empty();
143147
}

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,10 @@ public void processEffectiveBalanceUpdates(
463463
hysteresisUpwardMultiplier,
464464
maxEffectiveBalance)) {
465465
final Validator validator = validators.get(index);
466+
final UInt64 effectiveBalanceLimit = getEffectiveBalanceLimitForValidator(validator);
466467
final UInt64 newEffectiveBalance =
467-
balance.minus(balance.mod(effectiveBalanceIncrement)).min(maxEffectiveBalance);
468+
effectiveBalanceLimit.min(
469+
balance.minus(balance.mod(effectiveBalanceIncrement)).min(maxEffectiveBalance));
468470
BeaconStateCache.getTransitionCaches(state)
469471
.getProgressiveTotalBalances()
470472
.onEffectiveBalanceChange(status, newEffectiveBalance);
@@ -473,6 +475,10 @@ public void processEffectiveBalanceUpdates(
473475
}
474476
}
475477

478+
protected UInt64 getEffectiveBalanceLimitForValidator(final Validator validator) {
479+
return specConfig.getMaxEffectiveBalance();
480+
}
481+
476482
private boolean shouldIncreaseEffectiveBalance(
477483
final UInt64 balance,
478484
final UInt64 hysteresisIncrement,

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

+11
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,15 @@ public static BeaconStateAccessorsElectra required(
116116
beaconStateAccessors.getClass());
117117
return (BeaconStateAccessorsElectra) beaconStateAccessors;
118118
}
119+
120+
/**
121+
* implements get_validator_max_effective_balance state accessor
122+
*
123+
* @param validator - a validator from a state.
124+
* @return the max effective balance for the specified validator based on its withdrawal
125+
* credentials.
126+
*/
127+
public UInt64 getValidatorMaxEffectiveBalance(final Validator validator) {
128+
return predicatesElectra.getValidatorMaxEffectiveBalance(validator);
129+
}
119130
}

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

+11
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
package tech.pegasys.teku.spec.logic.versions.electra.helpers;
1515

16+
import static com.google.common.base.Preconditions.checkArgument;
1617
import static tech.pegasys.teku.spec.config.SpecConfig.FAR_FUTURE_EPOCH;
1718

1819
import java.util.function.Supplier;
@@ -24,6 +25,7 @@
2425
import tech.pegasys.teku.spec.datastructures.state.beaconstate.MutableBeaconState;
2526
import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.electra.MutableBeaconStateElectra;
2627
import tech.pegasys.teku.spec.logic.common.helpers.BeaconStateAccessors;
28+
import tech.pegasys.teku.spec.logic.common.helpers.BeaconStateMutators;
2729
import tech.pegasys.teku.spec.logic.common.helpers.MiscHelpers;
2830
import tech.pegasys.teku.spec.logic.versions.bellatrix.helpers.BeaconStateMutatorsBellatrix;
2931

@@ -33,6 +35,15 @@ public class BeaconStateMutatorsElectra extends BeaconStateMutatorsBellatrix {
3335

3436
private final SpecConfigElectra specConfigElectra;
3537

38+
public static BeaconStateMutatorsElectra required(final BeaconStateMutators beaconStateMutators) {
39+
checkArgument(
40+
beaconStateMutators instanceof BeaconStateMutatorsElectra,
41+
"Expected %s but it was %s",
42+
BeaconStateMutatorsElectra.class,
43+
beaconStateMutators.getClass());
44+
return (BeaconStateMutatorsElectra) beaconStateMutators;
45+
}
46+
3647
public BeaconStateMutatorsElectra(
3748
final SpecConfig specConfig,
3849
final MiscHelpers miscHelpers,

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

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ public boolean isCompoundingWithdrawalCredential(final Bytes32 withdrawalCredent
115115
* @return the max effective balance for the specified validator based on its withdrawal
116116
* credentials.
117117
*/
118+
@Override
118119
public UInt64 getValidatorMaxEffectiveBalance(final Validator validator) {
119120
return hasCompoundingWithdrawalCredential(validator)
120121
? configElectra.getMaxEffectiveBalanceElectra()

0 commit comments

Comments
 (0)