adjust digest hashing not to care about alignment; increase ValidatorPubKey alignment (#5296)
This commit is contained in:
parent
a150bc93a6
commit
22b7b721d0
|
@ -57,12 +57,12 @@ type
|
|||
##
|
||||
## It must be 8-byte aligned because `hash(ValidatorPubKey)` just casts a
|
||||
## ptr to one to a ptr to the other, so it needs a compatible alignment.
|
||||
blob* {.align: sizeof(Hash).}: array[RawPubKeySize, byte]
|
||||
blob* {.align: 16.}: array[RawPubKeySize, byte]
|
||||
|
||||
UncompressedPubKey* = object
|
||||
## Uncompressed variation of ValidatorPubKey - this type is faster to
|
||||
## deserialize but doubles the storage footprint
|
||||
blob*: array[UncompressedPubKeySize, byte]
|
||||
blob* {.align: 16.}: array[UncompressedPubKeySize, byte]
|
||||
|
||||
CookedPubKey* = distinct blscurve.PublicKey ## Valid deserialized key
|
||||
|
||||
|
|
|
@ -130,7 +130,9 @@ template withEth2Hash*(body: untyped): Eth2Digest =
|
|||
template hash*(x: Eth2Digest): Hash =
|
||||
## Hash for digests for Nim hash tables
|
||||
# digests are already good hashes
|
||||
cast[ptr Hash](unsafeAddr x.data[0])[]
|
||||
var h {.noinit.}: Hash
|
||||
copyMem(addr h, unsafeAddr x.data[0], static(sizeof(Hash)))
|
||||
h
|
||||
|
||||
func `==`*(a, b: Eth2Digest): bool =
|
||||
when nimvm:
|
||||
|
|
Loading…
Reference in New Issue