Files
prysm/beacon-chain/state/stateutil/execution_payload_availability_root.go
terence bc0868e232 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
2025-11-18 15:08:31 +00:00

26 lines
705 B
Go

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
}