mirror of https://github.com/status-im/nim-eth.git
Fix another Assertion + change error pragma to fatal
This commit is contained in:
parent
dc02a5b28d
commit
21c3c3946d
|
@ -230,7 +230,11 @@ proc read*(rlp: var Rlp, T: typedesc[StUint]): T {.inline.} =
|
||||||
if rlp.isBlob:
|
if rlp.isBlob:
|
||||||
let bytes = rlp.toBytes
|
let bytes = rlp.toBytes
|
||||||
if bytes.len > 0:
|
if bytes.len > 0:
|
||||||
result.initFromBytesBE(bytes.toOpenArray)
|
# be sure the amount of bytes matches the size of the stint
|
||||||
|
if bytes.len <= sizeof(result):
|
||||||
|
result.initFromBytesBE(bytes.toOpenArray)
|
||||||
|
else:
|
||||||
|
raise newException(RlpTypeMismatch, "Unsigned integer expected, but the source RLP has the wrong length")
|
||||||
else:
|
else:
|
||||||
result = 0.to(T)
|
result = 0.to(T)
|
||||||
else:
|
else:
|
||||||
|
@ -250,13 +254,13 @@ proc append*(rlpWriter: var RlpWriter, value: StUint) =
|
||||||
proc read*(rlp: var Rlp, T: typedesc[Stint]): T {.inline.} =
|
proc read*(rlp: var Rlp, T: typedesc[Stint]): T {.inline.} =
|
||||||
# The Ethereum Yellow Paper defines the RLP serialization only
|
# The Ethereum Yellow Paper defines the RLP serialization only
|
||||||
# for unsigned integers:
|
# for unsigned integers:
|
||||||
{.error: "RLP serialization of signed integers is not allowed".}
|
{.fatal: "RLP serialization of signed integers is not allowed".}
|
||||||
discard
|
discard
|
||||||
|
|
||||||
proc append*(rlpWriter: var RlpWriter, value: Stint) =
|
proc append*(rlpWriter: var RlpWriter, value: Stint) =
|
||||||
# The Ethereum Yellow Paper defines the RLP serialization only
|
# The Ethereum Yellow Paper defines the RLP serialization only
|
||||||
# for unsigned integers:
|
# for unsigned integers:
|
||||||
{.error: "RLP serialization of signed integers is not allowed".}
|
{.fatal: "RLP serialization of signed integers is not allowed".}
|
||||||
discard
|
discard
|
||||||
|
|
||||||
proc read*(rlp: var Rlp, t: var Transaction, _: type EthAddress): EthAddress {.inline.} =
|
proc read*(rlp: var Rlp, t: var Transaction, _: type EthAddress): EthAddress {.inline.} =
|
||||||
|
|
|
@ -320,7 +320,7 @@ proc readImpl[R, E](rlp: var Rlp, T: type array[R, E]): T =
|
||||||
|
|
||||||
var bytes = rlp.toBytes
|
var bytes = rlp.toBytes
|
||||||
if result.len != bytes.len:
|
if result.len != bytes.len:
|
||||||
raise newException(RlpTypeMismatch, "Fixed-size array expected, but the source RLP contains a blob of different lenght")
|
raise newException(RlpTypeMismatch, "Fixed-size array expected, but the source RLP contains a blob of different length")
|
||||||
|
|
||||||
copyMem(addr result[0], bytes.baseAddr, bytes.len)
|
copyMem(addr result[0], bytes.baseAddr, bytes.len)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue