-
Notifications
You must be signed in to change notification settings - Fork 36.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert entire source tree from json_spirit to UniValue #6121
Conversation
@@ -142,8 +142,8 @@ Object CallRPC(const string& strMethod, const Array& params) | |||
throw runtime_error("no response from server"); | |||
|
|||
// Parse reply | |||
Value valReply; | |||
if (!read_string(strReply, valReply)) | |||
Value valReply(UniValue::VSTR); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UniValue required explicit type definition during constructing.
Value
should be replaced with UniValue
soon.
I did use merge instead of rebase to clearly see my adaptations from #4738. |
if (!jVal.read(strVal) || (jVal.isNull() && strVal.size() > 0)) | ||
if(!jVal.setNumStr(strVal) || jVal.isNull()) | ||
throw runtime_error(string("Error parsing JSON:")+strVal); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to extend this to gain compatibility between JSON Spirit and UniValue. UniValue is more strict in case of JSON encoding.
0d57ecc
to
95c9b49
Compare
ut ACK - reviewed the whole thing Will do some testing later this week. Thanks for moving this forward! |
Thanks for doing this work. One remark: I see Ideally a new JSON implementation will avoid this and can interpret and generate Numbers from/to fixed-point or decimal directly. Similar to Python's
|
Agree w/ your gripe @laanwj. However, I think of that as a separate logical step:
Separated thusly it is easier to test the conversion before moving on to more ambitious cleanups. |
eee8acb
to
2a3126c
Compare
This is now complete. Just added another commit (2a3126c) which does completely remove JSON Spirit (also the UniValue wrapper) from the sources and the compile process. Passes all tests. If the diff size makes this PR to risky, there would also be the chance to pull this in without 2a3126c or / and separate 2a3126c into another PR. I think it would be good to remove JSON Spirit in this PR while not breaking the RPC API. After this has been done, we could focus on optimizing the monetary values. |
2a3126c
to
2f292e2
Compare
Gitian was also happy with this: http://builds.jonasschnelli.ch/pulls/6121/ |
Yes, I agree JSON-spirit should be removed in this PR. Reviewing & testing right now... |
d8f0bd1
to
8412abd
Compare
(apparantly) spurious travis failure with the comparison tool, retriggering |
Looks good to me. Tested and reviewed ACK. |
This breaks
(expected output: a list of block hashes) |
Thanks for testing. Nice catch! |
RPC batching issue is fixed. |
7f442e7
to
c023092
Compare
44c7474 univalue: add type check unit tests (Jonas Schnelli) c023092 univalue: add strict type checking (Wladimir J. van der Laan) 7e98a3c util: Add ParseInt64 and ParseDouble functions (Wladimir J. van der Laan) 043df2b Simplify RPCclient, adapt json_parse_error test (Wladimir J. van der Laan) 519eede fix univalue json parse tests (Jonas Schnelli) c7fbbc7 fix missing univalue types during constructing (Jonas Schnelli) 8f7e4ab fix rpc batching univalue issue (Jonas Schnelli) 9a8897f Remove JSON Spirit wrapper, remove JSON Spirit leftovers (Jonas Schnelli) 3df0411 remove JSON Spirit UniValue wrapper (Jonas Schnelli) 1f263c8 fix rpc unit test, plain numbers are not JSON compatible object (Jonas Schnelli) e04d9c2 univalue: correct bool support (Jonas Schnelli) 0c5b2cf univalue: add support for real, fix percision and make it json_spirit compatible (Jonas Schnelli) 21c10de special threatment for null,true,false because they are non valid json (Jonas Schnelli) 6c7bee0 expicit set UniValue type to avoid empty values (Jonas Schnelli) 53b4671 extend conversion to UniValue (Jonas Schnelli) 15982a8 Convert tree to using univalue. Eliminate all json_spirit uses. (Jeff Garzik) 5e3060c UniValue: export NullUniValue global constant (Jeff Garzik) efc7883 UniValue: prefer .size() to .count(), to harmonize w/ existing tree (Jeff Garzik)
I'm getting an error now when running Looks like it's here:
|
Odd that I missed that in my testing. Anyway, re-ACK! Tested. |
@jonasschnelli Sorry for not getting to a final review in time. I'll still look over it again in master for good measure. Great work! |
was introduced with bitcoin#6121
was introduced with bitcoin#6121
strict checking of the precision of real numbers. See: https://bitcoin.org/en/release/v0.12.0#rpc-low-level-api-changes and: bitcoin/bitcoin#6121
strict checking of the precision of real numbers. See: https://bitcoin.org/en/release/v0.12.0#rpc-low-level-api-changes and: bitcoin/bitcoin#6121
…=<try> Convert entire source tree from json_spirit to UniValue This PR cherry-picks bitcoin/bitcoin#6121 and then migrates the Zcash-specific code to UniValue. Also cherry-picks: - bitcoin/bitcoin#6241 - bitcoin/bitcoin#6234 Closes #1985.
…=str4d Convert entire source tree from json_spirit to UniValue This PR cherry-picks bitcoin/bitcoin#6121 and then migrates the Zcash-specific code to UniValue. Also cherry-picks: - bitcoin/bitcoin#6241 - bitcoin/bitcoin#6234 Closes #1985.
was introduced with #6121
Change `read_string` to fail when not the entire input has been consumed. This avoids unexpected, even dangerous behavior (fixes bitcoin#6223). The new JSON parser adapted in bitcoin#6121 also solves this problem so in master this is a temporary fix, but should be backported to older releases. Also adds tests for the new behavior. Github-Pull: bitcoin#6226 Rebased-From: 4e157fc (cherry picked from commit 181771b)
Takes up and supersedes #4738.
This PR keeps the JSON Spirit "backward-compatibility" and passes all tests. Therefore there is a new
UniValue
number typeVREAL
to distinct between int and double with the current JSON spirit precision of 8 digits after point.Because after rfc4627 (and UniValue honors that) some basic types/strings like
"null"
or"0"
and"string"
are not valid JSON strings, i had to slightly change some unit tests (will comment below directly in the code).