mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-22 04:24:05 +00:00
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
|
## 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.
|
## 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
|
UncompressedPubKey* = object
|
||||||
## Uncompressed variation of ValidatorPubKey - this type is faster to
|
## Uncompressed variation of ValidatorPubKey - this type is faster to
|
||||||
## deserialize but doubles the storage footprint
|
## deserialize but doubles the storage footprint
|
||||||
blob*: array[UncompressedPubKeySize, byte]
|
blob* {.align: 16.}: array[UncompressedPubKeySize, byte]
|
||||||
|
|
||||||
CookedPubKey* = distinct blscurve.PublicKey ## Valid deserialized key
|
CookedPubKey* = distinct blscurve.PublicKey ## Valid deserialized key
|
||||||
|
|
||||||
|
@ -130,7 +130,9 @@ template withEth2Hash*(body: untyped): Eth2Digest =
|
|||||||
template hash*(x: Eth2Digest): Hash =
|
template hash*(x: Eth2Digest): Hash =
|
||||||
## Hash for digests for Nim hash tables
|
## Hash for digests for Nim hash tables
|
||||||
# digests are already good hashes
|
# 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 =
|
func `==`*(a, b: Eth2Digest): bool =
|
||||||
when nimvm:
|
when nimvm:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user