From c106053763deb22b11553c5263c4625dafff3c11 Mon Sep 17 00:00:00 2001 From: Dmitrii Shmatko Date: Sun, 24 Nov 2024 23:00:15 +0100 Subject: [PATCH] Fix EIP7594 activation bugs and delegating SpecConfig --- .../spec/config/DelegatingSpecConfigElectra.java | 2 +- .../statetransition/datacolumns/DasSamplerBasic.java | 7 +++---- .../services/beaconchain/BeaconChainController.java | 12 +++++++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/DelegatingSpecConfigElectra.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/DelegatingSpecConfigElectra.java index 72688be896a..d1b899d1c74 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/DelegatingSpecConfigElectra.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/DelegatingSpecConfigElectra.java @@ -44,7 +44,7 @@ public Optional toVersionElectra() { @Override public Optional getOptionalEip7594Config() { - return eip7594; + return specConfigElectra.getOptionalEip7594Config().or(() -> eip7594); } @Override diff --git a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/datacolumns/DasSamplerBasic.java b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/datacolumns/DasSamplerBasic.java index 8045aadeac0..bfbc13dad72 100644 --- a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/datacolumns/DasSamplerBasic.java +++ b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/datacolumns/DasSamplerBasic.java @@ -29,7 +29,7 @@ import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.spec.Spec; -import tech.pegasys.teku.spec.SpecMilestone; +import tech.pegasys.teku.spec.SpecFeature; import tech.pegasys.teku.spec.config.features.Eip7594; import tech.pegasys.teku.spec.datastructures.blobs.versions.eip7594.DataColumnSidecar; import tech.pegasys.teku.spec.datastructures.blocks.BeaconBlock; @@ -171,9 +171,8 @@ public SafeFuture> checkDataAvailability( } private boolean isEIP7594(final BeaconBlock block) { - return spec.atSlot(block.getSlot()) - .getMilestone() - .isGreaterThanOrEqualTo(SpecMilestone.ELECTRA); + return spec.isFeatureActivatedAtEpoch( + SpecFeature.EIP7594, spec.computeEpochAtSlot(block.getSlot())); } private boolean hasBlobs(final BeaconBlock block) { diff --git a/services/beaconchain/src/main/java/tech/pegasys/teku/services/beaconchain/BeaconChainController.java b/services/beaconchain/src/main/java/tech/pegasys/teku/services/beaconchain/BeaconChainController.java index bb31832e2ed..2867ce6d3c7 100644 --- a/services/beaconchain/src/main/java/tech/pegasys/teku/services/beaconchain/BeaconChainController.java +++ b/services/beaconchain/src/main/java/tech/pegasys/teku/services/beaconchain/BeaconChainController.java @@ -100,6 +100,7 @@ import tech.pegasys.teku.services.executionlayer.ExecutionLayerBlockManagerFactory; import tech.pegasys.teku.services.timer.TimerService; import tech.pegasys.teku.spec.Spec; +import tech.pegasys.teku.spec.SpecFeature; import tech.pegasys.teku.spec.SpecMilestone; import tech.pegasys.teku.spec.config.features.Eip7594; import tech.pegasys.teku.spec.datastructures.attestation.ValidatableAttestation; @@ -654,7 +655,7 @@ protected void initBlobSidecarManager() { } private void initDasSamplerManager() { - if (spec.isMilestoneSupported(SpecMilestone.ELECTRA)) { + if (spec.isFeatureScheduled(SpecFeature.EIP7594)) { LOG.info("Activated DAS Sampler Manager for EIP7594"); this.dasSamplerManager = new DasSamplerManager(() -> dataAvailabilitySampler, kzg, spec); } else { @@ -664,7 +665,7 @@ private void initDasSamplerManager() { } protected void initDataColumnSidecarManager() { - if (spec.isMilestoneSupported(SpecMilestone.ELECTRA)) { + if (spec.isFeatureScheduled(SpecFeature.EIP7594)) { final DataColumnSidecarGossipValidator dataColumnSidecarGossipValidator = DataColumnSidecarGossipValidator.create( spec, @@ -685,9 +686,10 @@ protected void initDataColumnSidecarManager() { } protected void initDasCustody() { - if (!spec.isMilestoneSupported(SpecMilestone.ELECTRA)) { + if (!spec.isFeatureScheduled(SpecFeature.EIP7594)) { return; } + LOG.info("Activating DAS Custody for EIP7594"); Eip7594 configEip7594 = Eip7594.required(spec.forMilestone(SpecMilestone.ELECTRA).getConfig()); MinCustodyPeriodSlotCalculator minCustodyPeriodSlotCalculator = MinCustodyPeriodSlotCalculator.createFromSpec(spec); @@ -1141,7 +1143,7 @@ protected void initSubnetSubscriber() { } protected void initDataColumnSidecarSubnetBackboneSubscriber() { - if (!spec.isMilestoneSupported(SpecMilestone.ELECTRA)) { + if (!spec.isFeatureScheduled(SpecFeature.EIP7594)) { return; } LOG.debug("BeaconChainController.initDataColumnSidecarSubnetBackboneSubscriber"); @@ -1209,7 +1211,7 @@ public void initValidatorApiHandler() { blobSidecarGossipChannel = BlobSidecarGossipChannel.NOOP; } final DataColumnSidecarGossipChannel dataColumnSidecarGossipChannel; - if (spec.isMilestoneSupported(SpecMilestone.ELECTRA)) { + if (spec.isFeatureScheduled(SpecFeature.EIP7594)) { dataColumnSidecarGossipChannel = eventChannels.getPublisher(DataColumnSidecarGossipChannel.class); } else {