From 1e90e2c3603910d27c9490c4b2b5b45977bf6c4e Mon Sep 17 00:00:00 2001 From: Jihoon Song Date: Tue, 23 Jul 2024 17:46:39 +0900 Subject: [PATCH 1/2] Modify `get_ptc` function to follow the Python spec --- beacon-chain/core/helpers/payload_attestation.go | 3 +-- beacon-chain/core/helpers/payload_attestation_test.go | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/beacon-chain/core/helpers/payload_attestation.go b/beacon-chain/core/helpers/payload_attestation.go index fd8ce265f3a7..4796223d7d20 100644 --- a/beacon-chain/core/helpers/payload_attestation.go +++ b/beacon-chain/core/helpers/payload_attestation.go @@ -83,8 +83,7 @@ func GetPayloadTimelinessCommittee(ctx context.Context, state state.ReadOnlyBeac if uint64(len(committee)) < membersPerCommittee { return nil, errCommitteeOverflow } - start := uint64(len(committee)) - membersPerCommittee - indices = append(indices, committee[start:]...) + indices = append(indices, committee[:membersPerCommittee]...) } return } diff --git a/beacon-chain/core/helpers/payload_attestation_test.go b/beacon-chain/core/helpers/payload_attestation_test.go index 3b1eca0ed406..91213fb82cd2 100644 --- a/beacon-chain/core/helpers/payload_attestation_test.go +++ b/beacon-chain/core/helpers/payload_attestation_test.go @@ -89,7 +89,7 @@ func TestGetPayloadTimelinessCommittee(t *testing.T) { committee1, err := helpers.BeaconCommitteeFromState(ctx, state, state.Slot(), 0) require.NoError(t, err) - require.DeepEqual(t, committee1[len(committee1)-64:], ptc[:64]) + require.DeepEqual(t, committee1[:64], ptc[:64]) } func Test_PtcAllocation(t *testing.T) { From 8222b9534f2ac2bc037290ac3467e899f09f0645 Mon Sep 17 00:00:00 2001 From: Jihoon Song Date: Tue, 23 Jul 2024 20:29:59 +0900 Subject: [PATCH 2/2] Assign PTC members from the beginning of beacon committee array --- beacon-chain/core/helpers/beacon_committee.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/beacon-chain/core/helpers/beacon_committee.go b/beacon-chain/core/helpers/beacon_committee.go index 8e5364ad7c25..76cd0d4a604a 100644 --- a/beacon-chain/core/helpers/beacon_committee.go +++ b/beacon-chain/core/helpers/beacon_committee.go @@ -325,11 +325,8 @@ func PTCAssignments(committee []primitives.ValidatorIndex, return assignments } - // Calculate the starting index for PTC committee. - ptcStartIndex := committeeLength - membersPerCommittee - // Loop through the selected committee members for PTC assignments. - for i := ptcStartIndex; i < committeeLength; i++ { + for i := uint64(0); i < membersPerCommittee; i++ { vIndex := committee[i] assignment, exists := assignments[vIndex]