Skip to content

Commit

Permalink
Modify get_ptc function to follow the Python spec (#14256)
Browse files Browse the repository at this point in the history
* Modify `get_ptc` function to follow the Python spec

* Assign PTC members from the beginning of beacon committee array
  • Loading branch information
jihoonsong authored and potuz committed Aug 14, 2024
1 parent 6340ed6 commit 32b5971
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
5 changes: 1 addition & 4 deletions beacon-chain/core/helpers/beacon_committee.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,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]
Expand Down
3 changes: 1 addition & 2 deletions beacon-chain/core/helpers/payload_attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/core/helpers/payload_attestation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 32b5971

Please sign in to comment.