Skip to content

Commit

Permalink
feat: Add logic to append validator position in attestation
Browse files Browse the repository at this point in the history
  • Loading branch information
mattevans committed Mar 5, 2025
1 parent b342262 commit 0cb4e33
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/clmimicry/gossipsub_single_attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

"github.com/attestantio/go-eth2-client/spec/phase0"
v1 "github.com/ethpandaops/xatu/pkg/proto/eth/v1"
"github.com/ethpandaops/xatu/pkg/proto/libp2p"
"github.com/ethpandaops/xatu/pkg/proto/xatu"
Expand Down Expand Up @@ -138,5 +139,21 @@ func (m *Mimicry) createAdditionalGossipSubSingleAttestationData(
extra.MessageId = wrapperspb.String(payload.MsgID)
extra.MessageSize = wrapperspb.UInt32(uint32(payload.MsgSize))

// If the attestation is not aggregated, we can append the validator position within the committee.
if payload.SingleAttestation.GetAggregationBits().Count() == 1 {
validatorIndex, err := m.ethereum.Duties().GetValidatorIndex(
phase0.Epoch(epoch.Number()),
phase0.Slot(attestationData.GetSlot()),
phase0.CommitteeIndex(attestationData.GetCommitteeIndex()),
uint64(payload.SingleAttestation.GetAggregationBits().BitIndices()[0]),
)
if err == nil {
extra.AttestingValidator = &xatu.AttestingValidatorV2{
CommitteeIndex: &wrapperspb.UInt64Value{Value: uint64(attestationData.GetCommitteeIndex())},
Index: &wrapperspb.UInt64Value{Value: uint64(validatorIndex)},
}
}
}

return extra, nil
}

0 comments on commit 0cb4e33

Please sign in to comment.