Fix serialization of deposits
This commit is contained in:
parent
47ccae4ad6
commit
2aae54a15f
|
@ -275,42 +275,32 @@ template hash*(x: BlsCurveType): Hash =
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
|
|
||||||
proc writeValue*(writer: var JsonWriter, value: ValidatorPubKey) {.inline.} =
|
proc writeValue*(writer: var JsonWriter, value: ValidatorPubKey) {.inline.} =
|
||||||
when value is BlsValue:
|
|
||||||
doAssert value.kind == Real
|
doAssert value.kind == Real
|
||||||
writer.writeValue($value.blsValue)
|
writer.writeValue(value.blsValue.toHex())
|
||||||
else:
|
|
||||||
writer.writeValue($value)
|
|
||||||
|
|
||||||
proc readValue*(reader: var JsonReader, value: var ValidatorPubKey) {.inline.} =
|
proc readValue*(reader: var JsonReader, value: var ValidatorPubKey) {.inline.} =
|
||||||
value.initFromBytes(fromHex reader.readValue(string))
|
value.initFromBytes(fromHex reader.readValue(string))
|
||||||
|
|
||||||
proc writeValue*(writer: var JsonWriter, value: ValidatorSig) {.inline.} =
|
proc writeValue*(writer: var JsonWriter, value: ValidatorSig) {.inline.} =
|
||||||
when value is BlsValue:
|
|
||||||
if value.kind == Real:
|
if value.kind == Real:
|
||||||
writer.writeValue($value.blsValue)
|
writer.writeValue(value.blsValue.toHex())
|
||||||
else:
|
else:
|
||||||
# Workaround: https://github.com/status-im/nim-beacon-chain/issues/374
|
# Workaround: https://github.com/status-im/nim-beacon-chain/issues/374
|
||||||
let asHex = toHex(value.blob, true)
|
let asHex = value.blob.toHex(lowercase = true)
|
||||||
# echo "[Warning] writing raw opaque signature: ", asHex
|
# echo "[Warning] writing raw opaque signature: ", asHex
|
||||||
writer.writeValue(asHex)
|
writer.writeValue(asHex)
|
||||||
else:
|
|
||||||
writer.writeValue($value)
|
|
||||||
|
|
||||||
proc readValue*(reader: var JsonReader, value: var ValidatorSig) {.inline.} =
|
proc readValue*(reader: var JsonReader, value: var ValidatorSig) {.inline.} =
|
||||||
value.initFromBytes(fromHex reader.readValue(string))
|
value.initFromBytes(fromHex reader.readValue(string))
|
||||||
|
|
||||||
proc writeValue*(writer: var JsonWriter, value: ValidatorPrivKey) {.inline.} =
|
proc writeValue*(writer: var JsonWriter, value: ValidatorPrivKey) {.inline.} =
|
||||||
when value is BlsValue:
|
writer.writeValue(value.toHex())
|
||||||
doAssert value.kind == Real
|
|
||||||
writer.writeValue($value.blsValue)
|
|
||||||
else:
|
|
||||||
writer.writeValue($value)
|
|
||||||
|
|
||||||
proc readValue*(reader: var JsonReader, value: var ValidatorPrivKey) {.inline.} =
|
proc readValue*(reader: var JsonReader, value: var ValidatorPrivKey) {.inline.} =
|
||||||
value.initFromBytes(fromHex reader.readValue(string))
|
value.initFromBytes(fromHex reader.readValue(string))
|
||||||
|
|
||||||
proc writeValue*(writer: var JsonWriter, value: PublicKey) {.inline.} =
|
proc writeValue*(writer: var JsonWriter, value: PublicKey) {.inline.} =
|
||||||
writer.writeValue($value)
|
writer.writeValue(value.toHex())
|
||||||
|
|
||||||
proc readValue*(reader: var JsonReader, value: var PublicKey) {.inline.} =
|
proc readValue*(reader: var JsonReader, value: var PublicKey) {.inline.} =
|
||||||
let hex = reader.readValue(string)
|
let hex = reader.readValue(string)
|
||||||
|
@ -318,7 +308,7 @@ proc readValue*(reader: var JsonReader, value: var PublicKey) {.inline.} =
|
||||||
doAssert ok, "Invalid public key: " & hex
|
doAssert ok, "Invalid public key: " & hex
|
||||||
|
|
||||||
proc writeValue*(writer: var JsonWriter, value: Signature) {.inline.} =
|
proc writeValue*(writer: var JsonWriter, value: Signature) {.inline.} =
|
||||||
writer.writeValue($value)
|
writer.writeValue(value.toHex())
|
||||||
|
|
||||||
proc readValue*(reader: var JsonReader, value: var Signature) {.inline.} =
|
proc readValue*(reader: var JsonReader, value: var Signature) {.inline.} =
|
||||||
let hex = reader.readValue(string)
|
let hex = reader.readValue(string)
|
||||||
|
|
|
@ -49,7 +49,7 @@ proc generateDeposits*(totalValidators: int,
|
||||||
|
|
||||||
let dp = makeDeposit(pubKey, privKey)
|
let dp = makeDeposit(pubKey, privKey)
|
||||||
|
|
||||||
writeTextFile(privKeyFn, $privKey)
|
writeTextFile(privKeyFn, privKey.toHex())
|
||||||
writeFile(depositFn, dp)
|
writeFile(depositFn, dp)
|
||||||
|
|
||||||
result.add(dp)
|
result.add(dp)
|
||||||
|
|
Loading…
Reference in New Issue