From 4d459b2bbf023ebbdd9bc6bfd38cdc66daa29cdf Mon Sep 17 00:00:00 2001 From: Mehdi AOUADI Date: Mon, 9 Dec 2024 11:17:49 +0100 Subject: [PATCH] add missing electra attestation processing committee check --- .../common/operations/OperationsTestExecutor.java | 9 --------- .../versions/electra/block/BlockProcessorElectra.java | 11 +++++++++++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/common/operations/OperationsTestExecutor.java b/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/common/operations/OperationsTestExecutor.java index 3651eae033d..df11615cc16 100644 --- a/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/common/operations/OperationsTestExecutor.java +++ b/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/common/operations/OperationsTestExecutor.java @@ -21,7 +21,6 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.collect.ImmutableMap; -import java.util.List; import java.util.Optional; import tech.pegasys.teku.ethtests.finder.TestDefinition; import tech.pegasys.teku.infrastructure.ssz.SszData; @@ -68,9 +67,6 @@ public class OperationsTestExecutor implements TestExecutor { public static final String EXPECTED_STATE_FILE = "post.ssz_snappy"; - // TODO remove https://github.com/Consensys/teku/issues/8892 - private static final List IGNORED_TEST = List.of("invalid_nonset_bits_for_one_committee"); - private enum Operation { ATTESTER_SLASHING, PROPOSER_SLASHING, @@ -148,11 +144,6 @@ public OperationsTestExecutor(final String dataFileName, final Operation operati @Override public void runTest(final TestDefinition testDefinition) throws Exception { - // TODO remove https://github.com/Consensys/teku/issues/8892 - if (IGNORED_TEST.contains(testDefinition.getTestName())) { - return; - } - final BeaconState preState = loadStateFromSsz(testDefinition, "pre.ssz_snappy"); final DefaultOperationProcessor standardProcessor = diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/block/BlockProcessorElectra.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/block/BlockProcessorElectra.java index 9bfe1da33b4..9939efd47cb 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/block/BlockProcessorElectra.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/block/BlockProcessorElectra.java @@ -23,6 +23,7 @@ import java.util.List; import java.util.Optional; import java.util.function.Supplier; +import java.util.stream.IntStream; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes32; @@ -732,6 +733,16 @@ private Optional checkCommittees( } final IntList committee = beaconStateAccessorsElectra.getBeaconCommittee(state, slot, committeeIndex); + final int committeeOffset = participantsCount; + long committeeAttesters = + IntStream.range(0, committee.size()) + .filter( + committeeParticipantIndex -> + aggregationBits.isSet(committeeOffset + committeeParticipantIndex)) + .count(); + if (committeeAttesters == 0) { + return Optional.of(AttestationInvalidReason.PARTICIPANTS_COUNT_MISMATCH); + } participantsCount += committee.size(); } if (participantsCount != aggregationBits.size()) {