mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 21:38:05 -05:00
Add Gloas beacon state package (#15611)
* Add Gloas protobuf definitions with spec tests Add Gloas state fields to beacon state implementation * Remove shared field for pending payment * Radek's feedback * Potuz feedback * use slice concat * Fix comment * Fix concat * Fix comment * Fix correct index
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package stateutil
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/OffchainLabs/prysm/v7/encoding/ssz"
|
||||
)
|
||||
|
||||
// ExecutionPayloadAvailabilityRoot computes the merkle root of an execution payload availability bitvector.
|
||||
func ExecutionPayloadAvailabilityRoot(bitvector []byte) ([32]byte, error) {
|
||||
chunkCount := (len(bitvector) + 31) / 32
|
||||
chunks := make([][32]byte, chunkCount)
|
||||
|
||||
for i := range chunks {
|
||||
start := i * 32
|
||||
end := min(start+32, len(bitvector))
|
||||
copy(chunks[i][:], bitvector[start:end])
|
||||
}
|
||||
|
||||
root, err := ssz.BitwiseMerkleize(chunks, uint64(len(chunks)), uint64(len(chunks)))
|
||||
if err != nil {
|
||||
return [32]byte{}, fmt.Errorf("could not merkleize execution payload availability: %w", err)
|
||||
}
|
||||
return root, nil
|
||||
}
|
||||
Reference in New Issue
Block a user