You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Structs with u128 members related to the puzzle are starting to get into sizes that can only be represented in u128 numbers (i.e. the cumulative_weight member of the Header object). As a side effect, Serde based deserializers are starting to have the behavior of interpreting these numbers as floats during deserialization causing Serde deserialization of objects like Block to fail when deserializing from JSON.
For context as to why this happens, the Number enum in serde-json without the arbitraryprecision flag can hold a u64, i64, or f64. Thus without the arbitraryprecision flag, Number isn't capable of holding a u128 directly as an integer type and defaults to storing it as an f64. SnarkVM doesn't handle this explicitly causing deserialization to fail.
This will affect Rust code deserializing Blocks from JSON.
Steps to Reproduce
Use GET request using the reqwest library to download block 1243302
Attempt to deserialize the json object into a Block
A deserialization failure occurs
A workaround for now for libraries deserializing Blocks with using Serde in Rust is to use the arbitrary_precision feature. A longer term fix would be to examine visitor patterns that work over u128 numbers and ensure the logic explicitly deserializes them into u128.
The text was updated successfully, but these errors were encountered:
iamalwaysuncomfortable
changed the title
[Bug] Serde Deserialization
[Bug] Serde Deserialization of u128 numbers in Blocks defaults to float instead of u128
Oct 17, 2024
iamalwaysuncomfortable
changed the title
[Bug] Serde Deserialization of u128 numbers in Blocks defaults to float instead of u128
[Bug] Serde deserialization of u128 numbers in blocks defaults to float instead of u128
Oct 17, 2024
iamalwaysuncomfortable
changed the title
[Bug] Serde deserialization of u128 numbers in blocks defaults to float instead of u128
[Bug] Serde deserialization of u128 numbers in block data defaults to float instead of u128
Oct 17, 2024
🐛 Bug Report
Structs with
u128
members related to the puzzle are starting to get into sizes that can only be represented in u128 numbers (i.e. thecumulative_weight
member of theHeader
object). As a side effect, Serde based deserializers are starting to have the behavior of interpreting these numbers as floats during deserialization causing Serde deserialization of objects likeBlock
to fail when deserializing from JSON.For context as to why this happens, the Number enum in serde-json without the
arbitraryprecision
flag can hold au64
,i64
, orf64
. Thus without thearbitraryprecision
flag, Number isn't capable of holding a u128 directly as an integer type and defaults to storing it as an f64. SnarkVM doesn't handle this explicitly causing deserialization to fail.This will affect Rust code deserializing Blocks from JSON.
Steps to Reproduce
GET
request using thereqwest
library to download block1243302
A workaround for now for libraries deserializing Blocks with using
Serde
in Rust is to use thearbitrary_precision
feature. A longer term fix would be to examine visitor patterns that work over u128 numbers and ensure the logic explicitly deserializes them into u128.The text was updated successfully, but these errors were encountered: