mirror of https://github.com/status-im/nim-eth.git
fix eip2718 bug
- fixes bug in rlp decoder of Receipt - fixes bug in rlp decoder of Transaction - refactor rlpEncode for AccessListTx in eth/common/transaction.nim
This commit is contained in:
parent
b6b6f3dec7
commit
343d4f25e1
|
@ -369,7 +369,10 @@ proc read*(rlp: var Rlp, T: type Transaction): T =
|
|||
else:
|
||||
let bytes = rlp.read(Blob)
|
||||
var rr = rlpFromBytes(bytes)
|
||||
assert(rr.read(int) == 1)
|
||||
let txType = rr.read(int)
|
||||
if txType != 1:
|
||||
raise newException(UnsupportedRlpError,
|
||||
"TxType expect 1 got " & $txType)
|
||||
result = Transaction(
|
||||
txType: AccessListTxType,
|
||||
accessListTx: rr.read(AccessListTx)
|
||||
|
@ -427,7 +430,10 @@ proc read*(rlp: var Rlp, T: type Receipt): T =
|
|||
else:
|
||||
let bytes = rlp.read(Blob)
|
||||
var rr = rlpFromBytes(bytes)
|
||||
assert(rr.read(int) == 1)
|
||||
let recType = rr.read(int)
|
||||
if recType != 1:
|
||||
raise newException(UnsupportedRlpError,
|
||||
"TxType expect 1 got " & $recType)
|
||||
result = Receipt(
|
||||
receiptType: AccessListReceiptType,
|
||||
accessListReceipt: rr.read(AccessListReceipt)
|
||||
|
|
|
@ -87,11 +87,7 @@ func rlpEncodeEIP155*(tx: LegacyTx): auto =
|
|||
S: 0.u256
|
||||
))
|
||||
|
||||
func txHashNoSignature*(tx: LegacyTx): Hash256 =
|
||||
# Hash transaction without signature
|
||||
return keccak256.digest(if tx.V >= EIP155_CHAIN_ID_OFFSET: tx.rlpEncodeEIP155 else: tx.rlpEncode)
|
||||
|
||||
func txHashNoSignature*(tx: AccessListTx): Hash256 =
|
||||
func rlpEncode*(tx: AccessListTx): auto =
|
||||
let unsignedTx = AccessListUnsignedTx(
|
||||
chainId: tx.chainId,
|
||||
nonce: tx.nonce,
|
||||
|
@ -106,8 +102,14 @@ func txHashNoSignature*(tx: AccessListTx): Hash256 =
|
|||
var rw = initRlpWriter()
|
||||
rw.append(1)
|
||||
rw.append(unsignedTx)
|
||||
let rlpBytes = rlp.encode(rw.finish())
|
||||
return keccak256.digest(rlpBytes)
|
||||
rlp.encode(rw.finish())
|
||||
|
||||
func txHashNoSignature*(tx: LegacyTx): Hash256 =
|
||||
# Hash transaction without signature
|
||||
keccak256.digest(if tx.V >= EIP155_CHAIN_ID_OFFSET: tx.rlpEncodeEIP155 else: tx.rlpEncode)
|
||||
|
||||
func txHashNoSignature*(tx: AccessListTx): Hash256 =
|
||||
keccak256.digest(tx.rlpEncode)
|
||||
|
||||
func txHashNoSignature*(tx: Transaction): Hash256 =
|
||||
if tx.txType == LegacyTxType:
|
||||
|
|
Loading…
Reference in New Issue