Skip to content

Commit

Permalink
Merge pull request #198 from ethpandaops/pk910/fix-duty-panic
Browse files Browse the repository at this point in the history
fix panic in electra duty calculation
  • Loading branch information
pk910 authored Dec 17, 2024
2 parents 65a7268 + 2573998 commit 948bf7b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion indexer/beacon/duties/duties.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,18 @@ func UintToBytes(data any) []byte {
}

func BytesToUint(data []byte) uint64 {
return binary.LittleEndian.Uint64(data)
switch len(data) {
case 1:
return uint64(data[0])
case 2:
return uint64(binary.LittleEndian.Uint16(data))
case 4:
return uint64(binary.LittleEndian.Uint32(data))
case 8:
return binary.LittleEndian.Uint64(data)
default:
return 0
}
}

func SplitOffset(listSize, chunks, index uint64) uint64 {
Expand Down

0 comments on commit 948bf7b

Please sign in to comment.