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:
|
||||
result.receipts = requestReceipts(header, client)
|
||||
let
|
||||
receiptRoot = calcReceiptRoot(result.receipts).prefixHex
|
||||
receiptRootOK = result.header.receiptRoot.prefixHex
|
||||
if receiptRoot != receiptRootOK:
|
||||
debug "wrong receipt root", receiptRoot, receiptRootOK, blockNumber
|
||||
raise newException(ValueError, "Error when validating receipt root")
|
||||
if DownloadAndValidate in flags:
|
||||
let
|
||||
receiptRoot = calcReceiptRoot(result.receipts).prefixHex
|
||||
receiptRootOK = result.header.receiptRoot.prefixHex
|
||||
if receiptRoot != receiptRootOK:
|
||||
debug "wrong receipt root", receiptRoot, receiptRootOK, blockNumber
|
||||
raise newException(ValueError, "Error when validating receipt root")
|
||||
|
||||
if DownloadAndValidate in flags:
|
||||
let
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Nimbus
|
||||
# Copyright (c) 2020-2023 Status Research & Development GmbH
|
||||
# Copyright (c) 2020-2024 Status Research & Development GmbH
|
||||
# Licensed under either of
|
||||
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
||||
# http://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
@ -15,6 +15,8 @@ import
|
|||
|
||||
import ../nimbus/transaction, ../nimbus/utils/ec_recover
|
||||
|
||||
from stew/objects import checkedEnumAssign
|
||||
|
||||
template stripLeadingZeros(value: string): string =
|
||||
var cidx = 0
|
||||
# ignore the last character so we retain '0' on zero value
|
||||
|
@ -225,7 +227,15 @@ proc parseLogs(n: JsonNode): seq[Log] =
|
|||
result = @[]
|
||||
|
||||
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"):
|
||||
var hash: Hash256
|
||||
n.fromJson "root", hash
|
||||
|
|
Loading…
Reference in New Issue