Fix rlpHash of Transaction: remove EIP-4844 blobs before hashing (#643)

This commit is contained in:
andri lim 2023-10-22 14:37:49 +07:00 committed by GitHub
parent e34a9c4e5d
commit 1bae1d8426
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -295,6 +295,8 @@ func destination*(tx: Transaction): EthAddress =
return tx.to.get return tx.to.get
func removeNetworkPayload*(tx: Transaction): Transaction = func removeNetworkPayload*(tx: Transaction): Transaction =
if tx.networkPayload.isNil:
return tx
result = tx result = tx
result.networkPayload = nil result.networkPayload = nil

View File

@ -399,6 +399,9 @@ proc append*(rlpWriter: var RlpWriter, t: EthTime) {.inline.} =
proc rlpHash*[T](v: T): Hash256 = proc rlpHash*[T](v: T): Hash256 =
keccakHash(rlp.encode(v)) keccakHash(rlp.encode(v))
proc rlpHash*(tx: Transaction): Hash256 =
keccakHash(rlp.encode(tx.removeNetworkPayload))
func blockHash*(h: BlockHeader): KeccakHash {.inline.} = rlpHash(h) func blockHash*(h: BlockHeader): KeccakHash {.inline.} = rlpHash(h)
proc append*(rlpWriter: var RlpWriter, id: NetworkId) = proc append*(rlpWriter: var RlpWriter, id: NetworkId) =