diff --git a/build.gradle b/build.gradle index fd1d526fc8f..e137f226c0e 100644 --- a/build.gradle +++ b/build.gradle @@ -327,7 +327,7 @@ allprojects { } def nightly = System.getenv("NIGHTLY") != null -def refTestVersion = nightly ? "nightly" : "v1.5.0" +def refTestVersion = nightly ? "nightly" : "v1.6.0-alpha.0" def blsRefTestVersion = 'v0.1.2' def slashingProtectionInterchangeRefTestVersion = 'v5.3.0' def refTestBaseUrl = 'https://github.com/ethereum/consensus-spec-tests/releases/download' diff --git a/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/Eth2ReferenceTestCase.java b/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/Eth2ReferenceTestCase.java index 6ef979d43f0..10400a488c9 100644 --- a/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/Eth2ReferenceTestCase.java +++ b/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/Eth2ReferenceTestCase.java @@ -24,6 +24,8 @@ import tech.pegasys.teku.reference.common.epoch_processing.EpochProcessingTestExecutor; import tech.pegasys.teku.reference.common.operations.OperationsTestExecutor; import tech.pegasys.teku.reference.deneb.merkle_proof.MerkleProofTests; +import tech.pegasys.teku.reference.fulu.network.ComputeColumnsForCustodyGroupTestExecutor; +import tech.pegasys.teku.reference.fulu.network.GetCustodyGroupTestExecutor; import tech.pegasys.teku.reference.phase0.bls.BlsTests; import tech.pegasys.teku.reference.phase0.forkchoice.ForkChoiceTestExecutor; import tech.pegasys.teku.reference.phase0.genesis.GenesisTests; @@ -100,14 +102,14 @@ public abstract class Eth2ReferenceTestCase { private static final ImmutableMap FULU_TEST_TYPES = ImmutableMap.builder() + .putAll(TransitionTestExecutor.TRANSITION_TEST_TYPES) .putAll(ForkUpgradeTestExecutor.FORK_UPGRADE_TEST_TYPES) .putAll(RewardsTestExecutorBellatrix.REWARDS_TEST_TYPES) - .put("merkle_proof/single_merkle_proof", TestExecutor.IGNORE_TESTS) - // TODO-fulu enable merkle proof tests - // .putAll(MerkleProofTests.MERKLE_PROOF_TEST_TYPES) - // TODO-fulu networking test types (networking/compute_columns_for_custody_group) - .put("networking/get_custody_groups", TestExecutor.IGNORE_TESTS) - .put("networking/compute_columns_for_custody_group", TestExecutor.IGNORE_TESTS) + .putAll(MerkleProofTests.MERKLE_PROOF_TEST_TYPES) + .put("networking/get_custody_groups", new GetCustodyGroupTestExecutor()) + .put( + "networking/compute_columns_for_custody_group", + new ComputeColumnsForCustodyGroupTestExecutor()) .build(); protected void runReferenceTest(final TestDefinition testDefinition) throws Throwable { diff --git a/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/altair/fork/TransitionTestExecutor.java b/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/altair/fork/TransitionTestExecutor.java index b36fe979854..29df445f2ba 100644 --- a/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/altair/fork/TransitionTestExecutor.java +++ b/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/altair/fork/TransitionTestExecutor.java @@ -76,6 +76,14 @@ private void processUpgrade(final TestDefinition testDefinition, final MetaData .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 " diff --git a/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/fulu/network/ComputeColumnsForCustodyGroupTestExecutor.java b/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/fulu/network/ComputeColumnsForCustodyGroupTestExecutor.java new file mode 100644 index 00000000000..06f04af6dce --- /dev/null +++ b/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/fulu/network/ComputeColumnsForCustodyGroupTestExecutor.java @@ -0,0 +1,63 @@ +/* + * 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.reference.fulu.network; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.IOException; +import java.util.List; +import java.util.stream.Collectors; +import tech.pegasys.teku.ethtests.finder.TestDefinition; +import tech.pegasys.teku.infrastructure.unsigned.UInt64; +import tech.pegasys.teku.reference.TestDataUtils; +import tech.pegasys.teku.reference.TestExecutor; +import tech.pegasys.teku.spec.logic.versions.fulu.helpers.MiscHelpersFulu; + +public class ComputeColumnsForCustodyGroupTestExecutor implements TestExecutor { + + @Override + public void runTest(final TestDefinition testDefinition) throws Throwable { + final MiscHelpersFulu miscHelpersFulu = + MiscHelpersFulu.required(testDefinition.getSpec().getGenesisSpec().miscHelpers()); + final Data data = loadDataFile(testDefinition, Data.class); + + final List calculatedColumns = + miscHelpersFulu.computeColumnsForCustodyGroup(data.custodyGroup()); + + assertThat(calculatedColumns).isEqualTo(data.expectedColumns()); + } + + private static class Data { + + @JsonProperty(value = "custody_group", required = true) + private Integer custodyGroup; + + @JsonProperty(value = "result", required = true) + private List result; + + public UInt64 custodyGroup() { + return UInt64.valueOf(custodyGroup); + } + + public List expectedColumns() { + return result.stream().map(UInt64::valueOf).collect(Collectors.toList()); + } + } + + protected T loadDataFile(final TestDefinition testDefinition, final Class type) + throws IOException { + return TestDataUtils.loadYaml(testDefinition, "meta.yaml", type); + } +} diff --git a/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/fulu/network/GetCustodyGroupTestExecutor.java b/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/fulu/network/GetCustodyGroupTestExecutor.java new file mode 100644 index 00000000000..822032014e4 --- /dev/null +++ b/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/fulu/network/GetCustodyGroupTestExecutor.java @@ -0,0 +1,68 @@ +/* + * 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.reference.fulu.network; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.IOException; +import java.math.BigInteger; +import java.util.List; +import java.util.stream.Collectors; +import org.apache.tuweni.units.bigints.UInt256; +import tech.pegasys.teku.ethtests.finder.TestDefinition; +import tech.pegasys.teku.infrastructure.unsigned.UInt64; +import tech.pegasys.teku.reference.TestDataUtils; +import tech.pegasys.teku.reference.TestExecutor; +import tech.pegasys.teku.spec.logic.versions.fulu.helpers.MiscHelpersFulu; + +public class GetCustodyGroupTestExecutor implements TestExecutor { + + @Override + public void runTest(final TestDefinition testDefinition) throws Throwable { + final MiscHelpersFulu miscHelpersFulu = + MiscHelpersFulu.required(testDefinition.getSpec().getGenesisSpec().miscHelpers()); + final Data data = loadDataFile(testDefinition, Data.class); + + final List calculatedCustodyGroups = + miscHelpersFulu.getCustodyGroups(data.nodeId(), data.custodyGroupCount); + + assertThat(calculatedCustodyGroups).isEqualTo(data.expectedCustodyGroups()); + } + + private static class Data { + + @JsonProperty(value = "node_id", required = true) + private String nodeId; + + @JsonProperty(value = "custody_group_count", required = true) + private Integer custodyGroupCount; + + @JsonProperty(value = "result", required = true) + private List result; + + public UInt256 nodeId() { + return UInt256.valueOf(new BigInteger(this.nodeId, 10)); + } + + public List expectedCustodyGroups() { + return result.stream().map(UInt64::valueOf).collect(Collectors.toList()); + } + } + + protected T loadDataFile(final TestDefinition testDefinition, final Class type) + throws IOException { + return TestDataUtils.loadYaml(testDefinition, "meta.yaml", type); + } +}