From 84244b6cfac0d161e0c2cac92f3812c382ba0875 Mon Sep 17 00:00:00 2001 From: terence Date: Fri, 17 May 2024 02:23:35 -0700 Subject: [PATCH] Fix GetPayloadTimelinessCommittee to return correct PTC size (#14012) --- beacon-chain/core/helpers/payload_attestation.go | 2 +- beacon-chain/core/helpers/payload_attestation_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/beacon-chain/core/helpers/payload_attestation.go b/beacon-chain/core/helpers/payload_attestation.go index f91003cf4af9..e7f643be62fd 100644 --- a/beacon-chain/core/helpers/payload_attestation.go +++ b/beacon-chain/core/helpers/payload_attestation.go @@ -76,7 +76,7 @@ func GetPayloadTimelinessCommittee(ctx context.Context, state state.ReadOnlyBeac } committeesPerSlot := math.LargestPowerOfTwo(math.Min(SlotCommitteeCount(activeCount), fieldparams.PTCSize)) membersPerCommittee := fieldparams.PTCSize / committeesPerSlot - for i := uint64(0); i <= committeesPerSlot; i++ { + for i := uint64(0); i < committeesPerSlot; i++ { committee, err := BeaconCommitteeFromState(ctx, state, slot, primitives.CommitteeIndex(i)) if err != nil { return nil, err diff --git a/beacon-chain/core/helpers/payload_attestation_test.go b/beacon-chain/core/helpers/payload_attestation_test.go index 5b9abda5817b..aa2c58c98408 100644 --- a/beacon-chain/core/helpers/payload_attestation_test.go +++ b/beacon-chain/core/helpers/payload_attestation_test.go @@ -84,6 +84,7 @@ func TestGetPayloadTimelinessCommittee(t *testing.T) { ptc, err := helpers.GetPayloadTimelinessCommittee(ctx, state, state.Slot()) require.NoError(t, err) + require.Equal(t, fieldparams.PTCSize, len(ptc)) committee1, err := helpers.BeaconCommitteeFromState(ctx, state, state.Slot(), 0) require.NoError(t, err)