Hash bump

This commit is contained in:
Jacek Sieka 2024-08-08 07:46:35 +02:00
parent 3cefd7ed38
commit 094486d0ce
No known key found for this signature in database
GPG Key ID: A1B09461ABB656B8
4 changed files with 5 additions and 23 deletions

View File

@ -397,23 +397,6 @@ func `$`*(vids: HashSet[VertexID]): string =
"$" & it.uint64.toHex.strip(trailing=false,chars={'0'})
).join(",") & "}"
func `$`*(key: Hash256): string =
let w = UInt256.fromBytesBE key.data
if w == high(UInt256):
"2^256-1"
elif w == 0.u256:
"0"
elif w == 2.u256.pow 255:
"2^255" # 800...
elif w == 2.u256.pow 254:
"2^254" # 400..
elif w == 2.u256.pow 253:
"2^253" # 200...
elif w == 2.u256.pow 251:
"2^252" # 100...
else:
w.toHex
func `$`*(key: HashKey): string =
toHex(key.data)

View File

@ -41,7 +41,7 @@ template toStackElem(v: EvmStackInts, elem: EvmStackElement) =
template toStackElem(v: EthAddress, elem: EvmStackElement) =
elem.initFromBytesBE(v)
template toStackElem(v: MDigest, elem: EvmStackElement) =
template toStackElem(v: Hash256, elem: EvmStackElement) =
elem.initFromBytesBE(v.data)
template toStackElem(v: openArray[byte], elem: EvmStackElement) =
@ -254,4 +254,3 @@ template unaryAddress*(stack: EvmStack, unOp): EvmResultVoid =
EvmResultVoid.ok()
else:
EvmResultVoid.err(stackErr(StackInsufficient))

View File

@ -120,7 +120,7 @@ func pp*(q: openArray[int]; itemsPerLine: int; lineSep: string): string =
.mapIt(it.mapIt(&"0x{it:02x}").join(", "))
.join("," & lineSep)
func pp*(a: MDigest[256]; collapse = true): string =
func pp*(a: Hash256; collapse = true): string =
if not collapse:
a.data.toHex
elif a == ZERO_HASH256:
@ -136,7 +136,7 @@ func pp*(a: MDigest[256]; collapse = true): string =
else:
"£" & a.data.toHex.join[0..6] & ".." & a.data.toHex.join[56..63]
func pp*(a: openArray[MDigest[256]]; collapse = true): string =
func pp*(a: openArray[Hash256]; collapse = true): string =
"@[" & a.toSeq.mapIt(it.pp).join(" ") & "]"
func pp*(q: openArray[int]; itemsPerLine: int; indent: int): string =
@ -146,7 +146,7 @@ func pp*(q: openArray[byte]; noHash = false): string =
if q.len == 32 and not noHash:
var a: array[32,byte]
for n in 0..31: a[n] = q[n]
MDigest[256](data: a).pp
Hash256(data: a).pp
else:
q.toHex.pp(hex = true)

2
vendor/nim-eth vendored

@ -1 +1 @@
Subproject commit ebfe63b9b6523a1823e4505f0972d81047a77cf5
Subproject commit 864d54467e09c08d62b508149e9184001a813363