avoid warnings when processing `GasInt` for RLP (#712)

RLP does not support signed integer values, so we have to convert
`GasInt` to `uint64` when decoding / encoding via RLP.
This commit is contained in:
Etan Kissling 2024-07-03 13:21:45 +02:00 committed by GitHub
parent b80c227f52
commit b90483e9d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 0 deletions

View File

@ -70,6 +70,18 @@ proc append*[T](w: var RlpWriter, val: Opt[T]) =
else:
w.append("")
proc read*(rlp: var Rlp, T: type GasInt): T {.inline.} =
var res: uint64
rlp.read(res)
if res > GasInt.high.uint64:
raise (ref MalformedRlpError)(msg:
"GasInt value too large: " & $res)
res.GasInt
proc append*(w: var RlpWriter, value: GasInt) =
doAssert value >= 0
w.append(value.uint64)
proc appendTxLegacy(w: var RlpWriter, tx: Transaction) =
w.startList(9)
w.append(tx.nonce)