Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
- Added `--p2p-static-peers-url` option to read static peers from a URL or file
- Added node epoch and computed slot to the sync committee duties failure message for more context about the failure condition.
- Updated third party libraries.
- Added an info message on startup for the highest supported milestone and associated epoch.

### Bug Fixes
10 changes: 10 additions & 0 deletions ethereum/spec/src/main/java/tech/pegasys/teku/spec/Spec.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import java.util.function.Function;
import java.util.function.Supplier;
import javax.annotation.CheckReturnValue;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import tech.pegasys.teku.bls.BLSPublicKey;
Expand Down Expand Up @@ -106,6 +108,7 @@
import tech.pegasys.teku.spec.schemas.registry.SchemaRegistryBuilder;

public class Spec {
private static final Logger LOG = LogManager.getLogger();
private final Map<SpecMilestone, SpecVersion> specVersions;
private final ForkSchedule forkSchedule;
private final StateTransition stateTransition;
Expand Down Expand Up @@ -144,6 +147,13 @@ static Spec create(

final ForkSchedule forkSchedule = forkScheduleBuilder.build();

final UInt64 lastForkActivationEpoch =
forkSchedule.getActiveMilestones().getLast().getFork().getEpoch();
LOG.info(
"Creating network specification. Highest milestone supported: {}, from epoch {}",
highestMilestoneSupported.lowerCaseName(),
lastForkActivationEpoch);

return new Spec(specConfigAndParent, specVersions, forkSchedule);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*
* Copyright Consensys Software Inc., 2025
*
* 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;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestTemplate;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.spec.config.SpecConfig;
import tech.pegasys.teku.spec.config.SpecConfigAndParent;
import tech.pegasys.teku.spec.config.SpecConfigLoader;

@TestSpecContext(allMilestones = true)
class SpecFactoryTest {
private static final Logger LOG = LogManager.getLogger();
private SpecMilestone milestone;
private TestSpecInvocationContextProvider.SpecContext specContext;

@BeforeEach
void setup(final TestSpecInvocationContextProvider.SpecContext specContext) {
this.milestone = specContext.getSpecMilestone();
this.specContext = specContext;
}

@TestTemplate
void shouldSetHighestSupportedMilestone() {
final UInt64 forkEpoch = UInt64.valueOf(1);
final SpecConfigAndParent<? extends SpecConfig> config =
SpecConfigLoader.loadConfig(
specContext.getNetwork().configName(),
builder -> {
switch (milestone) {
case PHASE0 -> LOG.info("PHASE0");
case ALTAIR -> builder.altairBuilder(a -> a.altairForkEpoch(forkEpoch));
case BELLATRIX ->
builder
.altairBuilder(a -> a.altairForkEpoch(UInt64.ZERO))
.bellatrixBuilder(b -> b.bellatrixForkEpoch(forkEpoch));
case CAPELLA ->
builder
.altairBuilder(a -> a.altairForkEpoch(UInt64.ZERO))
.bellatrixBuilder(b -> b.bellatrixForkEpoch(UInt64.ZERO))
.capellaBuilder(c -> c.capellaForkEpoch(forkEpoch));
case DENEB ->
builder
.altairBuilder(a -> a.altairForkEpoch(UInt64.ZERO))
.bellatrixBuilder(b -> b.bellatrixForkEpoch(UInt64.ZERO))
.capellaBuilder(c -> c.capellaForkEpoch(UInt64.ZERO))
.denebBuilder(d -> d.denebForkEpoch(forkEpoch));
case ELECTRA ->
builder
.altairBuilder(a -> a.altairForkEpoch(UInt64.ZERO))
.bellatrixBuilder(b -> b.bellatrixForkEpoch(UInt64.ZERO))
.capellaBuilder(c -> c.capellaForkEpoch(UInt64.ZERO))
.denebBuilder(d -> d.denebForkEpoch(UInt64.ZERO))
.electraBuilder(e -> e.electraForkEpoch(forkEpoch));
case FULU ->
builder
.altairBuilder(a -> a.altairForkEpoch(UInt64.ZERO))
.bellatrixBuilder(b -> b.bellatrixForkEpoch(UInt64.ZERO))
.capellaBuilder(c -> c.capellaForkEpoch(UInt64.ZERO))
.denebBuilder(d -> d.denebForkEpoch(UInt64.ZERO))
.electraBuilder(e -> e.electraForkEpoch(UInt64.ZERO))
.fuluBuilder(f -> f.fuluForkEpoch(forkEpoch));
default ->
throw new IllegalStateException(
"Unhandled fork transition for test "
+ specContext.getDisplayName()
+ ": "
+ milestone);
}
});
final Spec testSpec = SpecFactory.create(config);
for (SpecMilestone currentMilestone : SpecMilestone.getAllPriorMilestones(milestone)) {
LOG.info("Previous milestone " + currentMilestone);
assertThat(testSpec.getForkSchedule().getFork(currentMilestone).getEpoch())
.isEqualTo(UInt64.ZERO);
}
LOG.info("Highest milestone supported " + milestone);
assertThat(testSpec.atEpoch(forkEpoch).getMilestone()).isEqualTo(milestone);

for (SpecMilestone currentMilestone : SpecMilestone.getAllMilestonesFrom(milestone)) {
if (currentMilestone == milestone) {
continue;
}
LOG.info("Undefined milestone " + currentMilestone);
assertThatThrownBy(() -> testSpec.getForkSchedule().getFork(currentMilestone))
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("not a part of fork schedule");
}
}
}
3 changes: 1 addition & 2 deletions teku/src/main/java/tech/pegasys/teku/AbstractNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ private void reportBellatrixMergeOverrides(final TekuConfiguration tekuConfig) {
reportTerminalBlockHashOverride = true;
reportTerminalBlockHashEpochOverride = true;
} else {
final Eth2NetworkConfiguration defaultConfiguration =
Eth2NetworkConfiguration.builder().applyNetworkDefaults(maybeEth2Network.get()).build();
final Eth2NetworkConfiguration defaultConfiguration = tekuConfig.eth2NetworkConfiguration();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was interesting - we recreated spec here which was made evident when the log.info was added

reportTerminalBlockHashOverride =
!defaultConfiguration
.getTerminalBlockHashOverride()
Expand Down