-
Notifications
You must be signed in to change notification settings - Fork 83
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
core/dutydb: refactor aggregation bits #182
Conversation
Codecov Report
@@ Coverage Diff @@
## main #182 +/- ##
=======================================
Coverage ? 54.44%
=======================================
Files ? 39
Lines ? 2439
Branches ? 0
=======================================
Hits ? 1328
Misses ? 977
Partials ? 134 Continue to review full report at Codecov.
|
// getAggBitsHex returns the aggregation bits hex for a committee | ||
// with length validators and the validator as index set to true. | ||
func getAggBitsHex(length, index uint64) (string, error) { | ||
if length == 0 { | ||
return "0x00", nil | ||
} | ||
|
||
if length <= index { | ||
return "", errors.New("agg bit index not smaller than length", | ||
z.U64("length", length), z.U64("index", index)) | ||
} | ||
|
||
extra := uint64(1) | ||
if length%8 == 0 { | ||
extra = 0 | ||
} | ||
|
||
buckets := length/8 + extra | ||
bitList := make([]byte, buckets) | ||
|
||
offset := buckets - 1 - index/8 | ||
bitList[offset] = byte(0x01 << (index % 8)) | ||
|
||
return "0x" + hex.EncodeToString(bitList), nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is how the VC calculates the value of aggbits it includes in the attestation
it gets the inputs values from AttestationDuty
aggbits := getAggBitsHex(duty.CommitteeLength, duty.ValidatorCommitteeIndex)
Co-authored-by: Dhruv Bodani <dhruvbodani2510@gmail.com>
Simplifies the pubkey lookup when an attestation is submitted. Instead of using aggregation bits, use the validator committee index explicitly.
category: refactor
ticket: #165