Skip to content

Commit

Permalink
Fix Fulu bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
zilm13 committed Nov 27, 2024
1 parent 463d203 commit b6fbe82
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.Optional;
import tech.pegasys.teku.infrastructure.bytes.Bytes4;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.spec.SpecMilestone;

public class SpecConfigFuluImpl extends DelegatingSpecConfigElectra implements SpecConfigFulu {

Expand All @@ -42,6 +43,11 @@ public UInt64 getFuluForkEpoch() {
return fuluForkEpoch;
}

@Override
public SpecMilestone getMilestone() {
return SpecMilestone.FULU;
}

@Override
public Optional<SpecConfigFulu> toVersionFulu() {
return Optional.of(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public SpecConfigAndParent<SpecConfigElectra> build(
minEpochsForDataColumnSidecarsRequests,
maxRequestDataColumnSidecars);
return SpecConfigAndParent.of(
new DelegatingSpecConfigElectra(specConfigAndParent.specConfig(), Optional.of(eip7594)));
new DelegatingSpecConfigElectra(specConfigAndParent.specConfig(), Optional.of(eip7594)),
specConfigAndParent);
}

public Eip7594Builder eip7594ForkEpoch(final UInt64 eip7594ForkEpoch) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ public class ElectraBuilder implements ForkConfigBuilder<SpecConfigDeneb, SpecCo
private Integer maxConsolidationRequestsPerPayload;
private Integer maxPendingPartialsPerWithdrawalsSweep;
private Integer maxPendingDepositsPerEpoch;
private Integer maxBlobsPerBlockElectra;
private Integer targetBlobsPerBlockElectra;
private Integer maxRequestBlobSidecarsElectra;
private Integer blobSidecarSubnetCountElectra;
// FIXME: remove hardcode, missed in Kurtosis config
private Integer maxBlobsPerBlockElectra = 6;
private Integer targetBlobsPerBlockElectra = 3;
private Integer maxRequestBlobSidecarsElectra = 768;
private Integer blobSidecarSubnetCountElectra = 6;

ElectraBuilder() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public class FuluBuilder implements ForkConfigBuilder<SpecConfigElectra, SpecCon
public SpecConfigAndParent<SpecConfigFulu> build(
final SpecConfigAndParent<SpecConfigElectra> specConfigAndParent) {
return SpecConfigAndParent.of(
new SpecConfigFuluImpl(specConfigAndParent.specConfig(), fuluForkVersion, fuluForkEpoch));
new SpecConfigFuluImpl(specConfigAndParent.specConfig(), fuluForkVersion, fuluForkEpoch),
specConfigAndParent);
}

public FuluBuilder fuluForkEpoch(final UInt64 fuluForkEpoch) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import java.util.Optional;
import tech.pegasys.teku.infrastructure.time.TimeProvider;
import tech.pegasys.teku.spec.config.SpecConfigElectra;
import tech.pegasys.teku.spec.config.SpecConfigFulu;
import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ExecutionRequestsDataCodec;
import tech.pegasys.teku.spec.logic.common.AbstractSpecLogic;
import tech.pegasys.teku.spec.logic.common.helpers.Predicates;
Expand All @@ -38,7 +38,6 @@
import tech.pegasys.teku.spec.logic.versions.deneb.helpers.MiscHelpersDeneb;
import tech.pegasys.teku.spec.logic.versions.deneb.util.ForkChoiceUtilDeneb;
import tech.pegasys.teku.spec.logic.versions.electra.block.BlockProcessorElectra;
import tech.pegasys.teku.spec.logic.versions.electra.forktransition.ElectraStateUpgrade;
import tech.pegasys.teku.spec.logic.versions.electra.helpers.BeaconStateAccessorsElectra;
import tech.pegasys.teku.spec.logic.versions.electra.helpers.BeaconStateMutatorsElectra;
import tech.pegasys.teku.spec.logic.versions.electra.helpers.MiscHelpersElectra;
Expand All @@ -47,6 +46,7 @@
import tech.pegasys.teku.spec.logic.versions.electra.operations.validation.VoluntaryExitValidatorElectra;
import tech.pegasys.teku.spec.logic.versions.electra.statetransition.epoch.EpochProcessorElectra;
import tech.pegasys.teku.spec.logic.versions.electra.util.AttestationUtilElectra;
import tech.pegasys.teku.spec.logic.versions.fulu.forktransition.FuluStateUpgrade;
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsElectra;

public class SpecLogicFulu extends AbstractSpecLogic {
Expand All @@ -71,7 +71,7 @@ private SpecLogicFulu(
final BlindBlockUtil blindBlockUtil,
final SyncCommitteeUtil syncCommitteeUtil,
final LightClientUtil lightClientUtil,
final ElectraStateUpgrade stateUpgrade) {
final FuluStateUpgrade stateUpgrade) {
super(
predicates,
miscHelpers,
Expand All @@ -94,7 +94,7 @@ private SpecLogicFulu(
}

public static SpecLogicFulu create(
final SpecConfigElectra config,
final SpecConfigFulu config,
final SchemaDefinitionsElectra schemaDefinitions,
final TimeProvider timeProvider) {
// Helpers
Expand Down Expand Up @@ -180,9 +180,7 @@ public static SpecLogicFulu create(
final BlindBlockUtilBellatrix blindBlockUtil = new BlindBlockUtilBellatrix(schemaDefinitions);

// State upgrade
final ElectraStateUpgrade stateUpgrade =
new ElectraStateUpgrade(
config, schemaDefinitions, beaconStateAccessors, beaconStateMutators);
final FuluStateUpgrade stateUpgrade = new FuluStateUpgrade(config, beaconStateAccessors);

return new SpecLogicFulu(
predicates,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright Consensys Software Inc., 2024
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/

package tech.pegasys.teku.spec.logic.versions.fulu.forktransition;

import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.spec.config.SpecConfigFulu;
import tech.pegasys.teku.spec.datastructures.state.Fork;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.electra.BeaconStateElectra;
import tech.pegasys.teku.spec.logic.common.forktransition.StateUpgrade;
import tech.pegasys.teku.spec.logic.versions.electra.helpers.BeaconStateAccessorsElectra;

public class FuluStateUpgrade implements StateUpgrade<BeaconStateElectra> {

private final SpecConfigFulu specConfig;
private final BeaconStateAccessorsElectra beaconStateAccessors;

public FuluStateUpgrade(
final SpecConfigFulu specConfig, final BeaconStateAccessorsElectra beaconStateAccessors) {
this.specConfig = specConfig;
this.beaconStateAccessors = beaconStateAccessors;
}

@Override
public BeaconStateElectra upgrade(final BeaconState preState) {
final UInt64 epoch = beaconStateAccessors.getCurrentEpoch(preState);
final BeaconStateElectra preStateElectra = BeaconStateElectra.required(preState);
return preStateElectra.updatedElectra(
state ->
state.setFork(
new Fork(
preState.getFork().getCurrentVersion(),
specConfig.getFuluForkVersion(),
epoch)));
}
}

0 comments on commit b6fbe82

Please sign in to comment.