mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-11 04:00:05 +00:00
Change to Custom Hashing for BlockHeaders (#4860)
* change to custom hashing * Merge branch 'master' into minorOpt * goimports * Merge branch 'minorOpt' of https://github.com/prysmaticlabs/geth-sharding into minorOpt * gaz * pad to 32 bytes
This commit is contained in:
parent
549b0f66fa
commit
ecfd7bdfa1
@ -25,6 +25,7 @@ go_library(
|
||||
"//shared/mathutil:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
"//shared/sliceutil:go_default_library",
|
||||
"//shared/stateutil:go_default_library",
|
||||
"//shared/trieutil:go_default_library",
|
||||
"@com_github_gogo_protobuf//proto:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
|
@ -25,6 +25,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/shared/mathutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/sliceutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/stateutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/trieutil"
|
||||
"github.com/sirupsen/logrus"
|
||||
"go.opencensus.io/trace"
|
||||
@ -250,7 +251,7 @@ func ProcessBlockHeaderNoVerify(
|
||||
if beaconState.Slot() != block.Slot {
|
||||
return nil, fmt.Errorf("state slot: %d is different then block slot: %d", beaconState.Slot(), block.Slot)
|
||||
}
|
||||
parentRoot, err := ssz.HashTreeRoot(beaconState.LatestBlockHeader())
|
||||
parentRoot, err := stateutil.BlockHeaderRoot(beaconState.LatestBlockHeader())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -20,9 +20,12 @@ func BlockHeaderRoot(header *ethpb.BeaconBlockHeader) ([32]byte, error) {
|
||||
binary.LittleEndian.PutUint64(headerSlotBuf, header.Slot)
|
||||
headerSlotRoot := bytesutil.ToBytes32(headerSlotBuf)
|
||||
fieldRoots[0] = headerSlotRoot[:]
|
||||
fieldRoots[1] = header.ParentRoot
|
||||
fieldRoots[2] = header.StateRoot
|
||||
fieldRoots[3] = header.BodyRoot
|
||||
parentRoot := bytesutil.ToBytes32(header.ParentRoot)
|
||||
fieldRoots[1] = parentRoot[:]
|
||||
stateRoot := bytesutil.ToBytes32(header.StateRoot)
|
||||
fieldRoots[2] = stateRoot[:]
|
||||
bodyRoot := bytesutil.ToBytes32(header.BodyRoot)
|
||||
fieldRoots[3] = bodyRoot[:]
|
||||
}
|
||||
return bitwiseMerkleize(fieldRoots, uint64(len(fieldRoots)), uint64(len(fieldRoots)))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user