Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Upgrade serde to 1.0. #8

Merged
merged 1 commit into from
Jul 30, 2018
Merged

Upgrade serde to 1.0. #8

merged 1 commit into from
Jul 30, 2018

Conversation

jeandudey
Copy link
Contributor

@jeandudey jeandudey commented Jul 25, 2018

Fixes #6

@dpc
Copy link
Contributor

dpc commented Jul 25, 2018

strason was very explicit about preserving order of keys, allowing duplicates and not parsing numbers. Is this necessary for jsonrpc?

@jeandudey
Copy link
Contributor Author

@dpc, It isn't strictly necessary for jsonrpc but necessary for bitcoin rpc related crates, serde_json doesn't parse numbers with the arbitrary_precision feaure and preserves order with the preserve_order, however I don't know if it allows duplicates.

@apoelstra
Copy link
Owner

I'm going to see if I can update strason to use serde 1.0.

I upgraded rust-secp256k1 to serde 1.0 yesterday and have some new ideas about how to preserve strason Json objects through round trips.

@jeandudey
Copy link
Contributor Author

Is there any particular reason to prefer strason over just using serde_json?, I have been trying to rewrite strason to use serde 1.0 and the more I progress the more I'm convinced that it's just a clone of serde_json but without the same API, the features strason offered are now actually implemented by serde_json only missing duplicate fields feature (Is it needed at all for Bitcoin JSON-RPC?).

With the arbitrary_precision feature serde_json uses a similar approach (but without unsafe) that strason uses to not lose precision on integers. 1

Using serde_json is the better option since it's a lot more tested and reviewed, with also high quality code.

@apoelstra
Copy link
Owner

I've updated strason to serde 1.0; the new version is 0.4.0. It is not quite a drop-in replacement but should be close.

@apoelstra
Copy link
Owner

@jeandudey serde_json does not compile with rust 1.14. See serde-rs/json#332

@jeandudey
Copy link
Contributor Author

@apoelstra I've updated the code to use strason and compiles fines on stable, but on 1.15.0 there are problems with hyper dependencies that don't build.

@jeandudey
Copy link
Contributor Author

Also I have updated .travis.yml to build against 1.15.0

@apoelstra
Copy link
Owner

Thanks! Very frustrating about 1.14.0. See servo/unicode-bidi#46 for some history about this.

For now we might have to bump the minimum compiler version for rust-jsonrpc to 1.17. (Which I'm aware brings us down to zero reasons to prefer strason over serde_json -- except that I hope with newer HTTP client dependencies we can get back to 1.14 in the near future.)

@jeandudey jeandudey force-pushed the serde branch 2 times, most recently from ebfbafd to 3915f3c Compare July 30, 2018 17:34
Signed-off-by: Jean Pierre Dudey <[email protected]>
@apoelstra
Copy link
Owner

utACK.

Master is not building for me right now because an openssl dep was introduced at some point (wtf, I'm sure I disabled this, but I guess something re-added it in a patch version), and openssl-sys does not even compile anymore. I'll need to fix that in another PR -- will also add travis support and maybe some fuzzers to bring this project more in line with rust-bitcoin norms.

@apoelstra
Copy link
Owner

apoelstra commented Jul 30, 2018

Never mind - ssl is just on by default in this project. I may change the default, especially since our version openssl-sys is broken, but it's not urgent.

@apoelstra
Copy link
Owner

ACK. The actual minimum compiler version appears to be 1.21 right now, because the rust-url folks have continued increasing their compiler version. But I'll merge this and publish 0.8 so that a latest-serde version is available, and defer fixing hyper to a later rev.

@apoelstra apoelstra merged commit abccc53 into apoelstra:master Jul 30, 2018
@alexreg
Copy link

alexreg commented Aug 6, 2018

Nice work on this. It's great that things have finally moved over to serde, which establishes a consensus. @apoelstra can then take advantage of all the other great features of serde in the future. I'm curious though, is there a reason strason still even exists as a library?

@apoelstra
Copy link
Owner

@alexreg it is the only json parsing library that compiles with Rust 1.14, which is the currently shipping version of rustc in Debian stable on several architectures.

@alexreg
Copy link

alexreg commented Aug 6, 2018

@apoelstra Oh I see, that problem still. That's an issue with Debian of course, but fair enough. So does your library switch to use serde when available, or what?

@apoelstra
Copy link
Owner

@alexreg no, I do plan to deprecate strason. rust-jsonrpc depends on it but I cannot realistically make that compile on 1.14 because there are no HTTP libraries anymore that compile on 1.14 (so rust-jsonrpc will just stay outside of the rust-bitcoin umbrella).

Currently rust-bitcoin depends on strason for some minor/dumb reasons (using its serializer in a hacky way to get default values for objects in a macro_rules macro that can't detect whether Default is implemented, mainly). I'll just remove that dependency rather than replacing it with serde.

@alexreg
Copy link

alexreg commented Aug 8, 2018

@apoelstra Hmm, what do HTTP libraries have to do with anything? I'm not sure I understand the first point.

@apoelstra
Copy link
Owner

@alexreg rust-jsonrpc implements a HTTP jsonrpc client.

@alexreg
Copy link

alexreg commented Aug 8, 2018

Sure, but how is that related to what serialisation library is used?

@apoelstra
Copy link
Owner

@alexreg if we can use serde_json, we'd rather use serde_json. And if we're not supporting 1.14 (and rust-jsonrpc is not, due to lack of HTTP libs), we can use serde_json.

@alexreg
Copy link

alexreg commented Aug 9, 2018

Okay, I see. Very good. So the strason dependencies for rust-jsonrpc and rust-bitcoin will both disappear in time?

@apoelstra
Copy link
Owner

Yes.

@alexreg
Copy link

alexreg commented Aug 9, 2018

Great. Sorry for the confusion.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants