Fix ReceiptType in premix + Apply validate flag for receipts (#2012)
This commit is contained in:
parent
beb13b2c40
commit
7b2dc8f8e9
|
@ -120,12 +120,13 @@ proc requestBlock*(
|
||||||
|
|
||||||
if DownloadReceipts in flags:
|
if DownloadReceipts in flags:
|
||||||
result.receipts = requestReceipts(header, client)
|
result.receipts = requestReceipts(header, client)
|
||||||
let
|
if DownloadAndValidate in flags:
|
||||||
receiptRoot = calcReceiptRoot(result.receipts).prefixHex
|
let
|
||||||
receiptRootOK = result.header.receiptRoot.prefixHex
|
receiptRoot = calcReceiptRoot(result.receipts).prefixHex
|
||||||
if receiptRoot != receiptRootOK:
|
receiptRootOK = result.header.receiptRoot.prefixHex
|
||||||
debug "wrong receipt root", receiptRoot, receiptRootOK, blockNumber
|
if receiptRoot != receiptRootOK:
|
||||||
raise newException(ValueError, "Error when validating receipt root")
|
debug "wrong receipt root", receiptRoot, receiptRootOK, blockNumber
|
||||||
|
raise newException(ValueError, "Error when validating receipt root")
|
||||||
|
|
||||||
if DownloadAndValidate in flags:
|
if DownloadAndValidate in flags:
|
||||||
let
|
let
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Nimbus
|
# Nimbus
|
||||||
# Copyright (c) 2020-2023 Status Research & Development GmbH
|
# Copyright (c) 2020-2024 Status Research & Development GmbH
|
||||||
# Licensed under either of
|
# Licensed under either of
|
||||||
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0)
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
||||||
|
@ -15,6 +15,8 @@ import
|
||||||
|
|
||||||
import ../nimbus/transaction, ../nimbus/utils/ec_recover
|
import ../nimbus/transaction, ../nimbus/utils/ec_recover
|
||||||
|
|
||||||
|
from stew/objects import checkedEnumAssign
|
||||||
|
|
||||||
template stripLeadingZeros(value: string): string =
|
template stripLeadingZeros(value: string): string =
|
||||||
var cidx = 0
|
var cidx = 0
|
||||||
# ignore the last character so we retain '0' on zero value
|
# ignore the last character so we retain '0' on zero value
|
||||||
|
@ -225,7 +227,15 @@ proc parseLogs(n: JsonNode): seq[Log] =
|
||||||
result = @[]
|
result = @[]
|
||||||
|
|
||||||
proc parseReceipt*(n: JsonNode): Receipt =
|
proc parseReceipt*(n: JsonNode): Receipt =
|
||||||
var rec = Receipt(receiptType: LegacyReceipt)
|
var recType: byte
|
||||||
|
n.fromJson "type", recType
|
||||||
|
var txVal: ReceiptType
|
||||||
|
var rec =
|
||||||
|
if checkedEnumAssign(txVal, recType):
|
||||||
|
Receipt(receiptType: txVal)
|
||||||
|
else:
|
||||||
|
raise newException(ValueError, "Unknown receipt type")
|
||||||
|
|
||||||
if n.hasKey("root"):
|
if n.hasKey("root"):
|
||||||
var hash: Hash256
|
var hash: Hash256
|
||||||
n.fromJson "root", hash
|
n.fromJson "root", hash
|
||||||
|
|
Loading…
Reference in New Issue