Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CalculateCommitteeSubscriptionResponse function to eth2exp #1091

Closed
xenowits opened this issue Sep 7, 2022 · 0 comments
Closed

Add CalculateCommitteeSubscriptionResponse function to eth2exp #1091

xenowits opened this issue Sep 7, 2022 · 0 comments
Assignees
Labels
duties This issue is related to duties to be added enhancement New feature or request

Comments

@xenowits
Copy link
Contributor

xenowits commented Sep 7, 2022

Problem to be solved

Add a CalculateCommitteeSubscriptionResponse function to eth2exp/attagg.go that calculates is_aggregator from a BeaconCommitteeSubscription and returns a BeaconCommitteeSubscriptionResponse.

Proposed solution

// CalculateCommitteeSubscriptionResponse returns a BeaconCommitteeSubscriptionResponse with IsAggregator field set to true if the validator is an aggregator.
func CalculateCommitteeSubscriptionResponse(subscription BeaconCommitteeSubscription) BeaconCommitteeSubscriptionResponse {
	// call IsAggregator() here
}

// https://github.com/prysmaticlabs/prysm/blob/b4d2395a38ea6cac15cb720672af12eeaf4d97a1/beacon-chain/core/helpers/attestation.go#L49
func isAggregator(committeeCount uint64, slotSig []byte) (bool, error) {
	var modulo = uint64(1)

	if committeeCount/targetAggregatorsPerCommittee > 1 {
		modulo = committeeCount / targetAggregatorsPerCommittee
	}

	b := eth2util.SHA256(slotSig)

	return binary.LittleEndian.Uint64(b[:8])%modulo == 0, nil
}

// https://github.com/ethereum/consensus-specs/blob/v0.9.3/specs/core/0_beacon-chain.md#hash
func SHA256(data []byte) [32]byte {
	h := sha256.New()
	h.Write(data)

	var b [32]byte
	h.Sum(b[:0])

	return b
}

Out of Scope

None

@dB2510 dB2510 added duties This issue is related to duties to be added enhancement New feature or request labels Sep 8, 2022
obol-bulldozer bot pushed a commit that referenced this issue Sep 9, 2022
Adds `CalculateCommitteeSubscriptionResponse` function to `eth2exp/attagg.go` that calculates `is_aggregator` and returns a `BeaconCommitteeSubscriptionResponse`. 

category: feature
ticket: #1091
@xenowits xenowits closed this as completed Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duties This issue is related to duties to be added enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants