Skip to content

Commit

Permalink
Minor clean up on mixing length root (#8875)
Browse files Browse the repository at this point in the history
* Minor clean up on mixing length root

* Update root size to 32

Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>
  • Loading branch information
terencechain and prestonvanloon committed May 10, 2021
1 parent 255354f commit ad4fadb
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions beacon-chain/state/stateutil/validator_root.go
@@ -1,7 +1,6 @@
package stateutil

import (
"bytes"
"encoding/binary"
"fmt"

Expand Down Expand Up @@ -84,13 +83,10 @@ func Uint64ListRootWithRegistryLimit(balances []uint64) ([32]byte, error) {
if err != nil {
return [32]byte{}, errors.Wrap(err, "could not compute balances merkleization")
}
balancesRootsBuf := new(bytes.Buffer)
if err := binary.Write(balancesRootsBuf, binary.LittleEndian, uint64(len(balances))); err != nil {
return [32]byte{}, errors.Wrap(err, "could not marshal balances length")
}
balancesRootsBufRoot := make([]byte, 32)
copy(balancesRootsBufRoot, balancesRootsBuf.Bytes())
return htrutils.MixInLength(balancesRootsRoot, balancesRootsBufRoot), nil

balancesLengthRoot := make([]byte, 32)
binary.LittleEndian.PutUint64(balancesLengthRoot, uint64(len(balances)))
return htrutils.MixInLength(balancesRootsRoot, balancesLengthRoot), nil
}

// ValidatorEncKey returns the encoded key in bytes of input `validator`,
Expand Down

0 comments on commit ad4fadb

Please sign in to comment.