sapio-lang / sapio

A Bitcoin Programming Language
Mozilla Public License 2.0
244 stars 43 forks source link

Replace serde-json with a canoncial json library which can support floats? #240

Open JeremyRubin opened 2 years ago

ProofOfKeags commented 2 years ago

IIRC there was a desire to "ban" the use of floats within sapio due to fundamental determinism issues stemming from hardware discrepancies. My position on this is, and has always been, that memory determinism is far less important than a guarantee of referential transparency at the layer the user interacts with. Memory determinism guarantees referential transparency but is a much stronger requirement, and with these hardware differences you've referenced, may not actually be possible.

JeremyRubin commented 2 years ago

i dont think this comment is related. this issue is that the serde-json Values we use in various places cannot contrain floats (it will panic). This is because the matrix.org json canonicalization spec bans floats. so we should ensure that our "generic object serializable" struct is canonicalizable, or else it panics when composed with attest chains.

ProofOfKeags commented 2 years ago

Understood.

Would this be just another serde backend or is the idea that we would replace serde entirely for this purpose?

JeremyRubin commented 2 years ago

seems like maybe CBOR, in partciular the IPFS libraries for it (ipld) might be close to what we're looking for, and are serde compatible.

JeremyRubin commented 2 years ago

"IPLD stands for "InterPlanetary Linked Data, and is a series of standards and formats for describing data in a content-addressing-emphatic way. The people who work on IPLD do so because we want a world where it's easy to build decentralized, distributed, and inter-operable applications, and we believe robust data formats and a clear story for content-addressing them is a key piece of leverage towards that goal."

this sounds right