diff --git a/fluffy/network/history/history_network.nim b/fluffy/network/history/history_network.nim index c5c19ea5d..d9584c12b 100644 --- a/fluffy/network/history/history_network.nim +++ b/fluffy/network/history/history_network.nim @@ -230,7 +230,8 @@ proc validateBlockBody( let calculatedTxsRoot = calcTxsRoot(body.transactions) if calculatedTxsRoot != header.txRoot: - return err("Invalid transactions root") + return err("Invalid transactions root: expected " & + $header.txRoot & " - got " & $calculatedTxsRoot) ok() @@ -239,23 +240,26 @@ proc validateBlockBody( Result[void, string] = ## Validate the block body against the txRoot, ommersHash and withdrawalsRoot ## from the header. - # Shortcutting the ommersHash calculation as uncles needs to be empty - # TODO: This is since post-merge, however, we would need an additional object - # type for that period to do this. - if body.uncles.len > 0: - return err("Invalid ommers hash") + # Shortcut the ommersHash calculation as uncles must be an RLP encoded + # empty list + if body.uncles.asSeq() != @[byte 0xc0]: + return err("Invalid ommers hash, uncles list is not empty") let calculatedTxsRoot = calcTxsRoot(body.transactions) if calculatedTxsRoot != header.txRoot: - return err("Invalid transactions root") + return err("Invalid transactions root: expected " & + $header.txRoot & " - got " & $calculatedTxsRoot) # TODO: This check is done higher up but perhaps this can become cleaner with # some refactor. doAssert(header.withdrawalsRoot.isSome()) - let calculatedWithdrawalsRoot = calcWithdrawalsRoot(body.withdrawals) - if calculatedWithdrawalsRoot != header.txRoot: - return err("Invalid transactions root") + let + calculatedWithdrawalsRoot = calcWithdrawalsRoot(body.withdrawals) + headerWithdrawalsRoot = header.withdrawalsRoot.get() + if calculatedWithdrawalsRoot != headerWithdrawalsRoot: + return err("Invalid withdrawals root: expected " & + $headerWithdrawalsRoot & " - got " & $calculatedWithdrawalsRoot) ok()