-
Notifications
You must be signed in to change notification settings - Fork 62
Conversation
Since #92 is merged maybe we can rebase and un-draft this? |
8780d81
to
d20ba2e
Compare
CI failure is because we need to add a doccomment now to the serde_json re-export. Unrelated to this PR. |
src/simple_minreq.rs
Outdated
pub fn simple_http_minreq( | ||
url: &str, | ||
user: Option<String>, | ||
pass: Option<String>, |
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.
In d20ba2e:
I think we should take &str
rather than String
here for both params. (Ideally it could be generic but that sucks because if the user passes None
then the compiler will complain.)
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.
What value do these helper constructors even add? I rekon we should get rid of them from all the modules.
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.
Can you confirm that you are ok with my removal of these "helper" constrctors mate?
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 a quick check to make sure the new code was not non-uniform and only simlple_http
provides these construtors on Client
so its the odd one out not minreq_http
.
src/simple_minreq.rs
Outdated
impl Default for SimpleHttpTransport { | ||
fn default() -> Self { | ||
SimpleHttpTransport { | ||
url: format!("localhost:{}", DEFAULT_PORT), |
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.
In d20ba2e:
minreq seems to require a http://
prefix on this or else you get the error "was redirected to an absolute url with an invalid protocol".
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"ll add integration testing against a bitcoind instance like we do in rust-bitcoincorerpc
eh, to catch this sort of mistake.
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.
That would be amazing. TBH I usually test nontrivial PRs to this crate by syncing my hot wallet with it, which is probably not the safest testing strategy..
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.
Added http://
to the string, FTR I have not tested this code path.
Done testing d20ba2e. It looks like it "just works", though it's a little bit (1-5% maybe?) slower than simple http. OTOH if it works for Mac users without bullshit, that's a huge win. |
fb645b5
to
017c5f6
Compare
Now includes fuzzing and integration tests pulled out of |
Will need changes in rust-bitcoin/rust-bitcoin#1842 if that merges. |
@tcharding I actually don't think it'll need the #1842 changes, because we still haven't changed this crate to rename |
Oh my bad, I misread the PR. The broken-crypto thing has nothing to do with fuzzing here but do we want to change this one to use |
@tcharding So, I did actually find myself wanting to use actual JSONRPC with network access within a fuzzer recently ... I was doing unholy things, but it did come up. So it's nice to be able to turn it off. Maybe rather than renaming it we should add another feature gate that you have to turn on to re-enable the real stuff. So our |
Or maybe we should just copy the rust-bitcoin/hashes/secp strategy, for consistency's sake. |
If minreq does async, maybe you could see if it also applies to #56? |
@stevenroose it does not, but we would like it to. The maintainers seem pretty friendly so we're hopeful that they'll accept something. |
017c5f6
to
d51e0c8
Compare
I've opened a separate PR to tackle this idea. For now, this PR just uses |
d51e0c8
to
0dd3fb3
Compare
Please don't merge without an ack from @stevenroose because I stole the integration testing from his code and also the |
Can you move all the fuzz stuff to a second commit? |
9710de9
to
30583e1
Compare
Fuzzing stuff looks good now. Now that #98 is merged we could maybe rebase again. I think we still need to tweak the auth stuff. |
Sure thing, thanks man. |
30583e1
to
b2fd962
Compare
Fixed up auth stuff, I ended up doing so by removing all the stuff in the Also , I pull all the fuzzing stuff out of the initial patch and into the final "add fuzzing" patch. |
The new Can you split out the integration stuff into its own commit (which updates the workspace list and CI)? |
Sorry bro, guess I did not run that before re-pushing. Will fix. |
b2fd962
to
d6645cc
Compare
Added file reading code in the integration test and added the integration test to the workspace. |
Add a module that implements `client::Transport` by way of the `minreq` HTTP client crate (https://github.com/neonmoe/minreq/). Includes fuzzing types in the `simple_minreq` module (with the old "fuzzing" cfg), but fuzz tests will be added next commit (including change to use jsonrpc_fuzzing).
Add a integration infrastructure for testing against bitcoind, copied from `rust-bitocincore-rpc`. Add a single simple test.
Update the fuzzing infrastructure by copying scripts etc. from `rust-bitcoin`. Enable usage of `RUSTFLAGS="--cfg=jsonrpc_fuzz` to run fuzz tests instead of "--cfg=fuzzing".
d6645cc
to
ccef3a3
Compare
... and split out the integration tests to a separate patch as requested. |
@tcharding ok 297963b is almost there :) Basically, the fuzz stuff needs to be updated -- in particular the version of honggfuzz needs to be 0.5.55 rather than 0.5, and the We can do this in a followup PR if you'd like, but since this one introduces fuzztesting we might as well go all the way with it. |
Shit, super sloppy. I'll sort it in this PR. Thanks |
Now I'm confused, what code are you looking at? In commit: -[features]
-honggfuzz_fuzz = ["honggfuzz"]
-
[dependencies]
-honggfuzz = { version = "0.5", optional = true, default-features = false }
-jsonrpc = { path = ".." }
+honggfuzz = { version = "0.5.55", default-features = false }
+jsonrpc = { path = "..", features = ["minreq_http"] } I rekon you are on a stale branch. |
Yep, I'm sorry, I think I was looking at the second commit of this branch rather than the last. I think this is good to go :) |
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.
ACK ccef3a3
@tcharding could you open a PR to cut a release? Then I can ACK/merge it. |
Oof actually we have to fix CI first ... https://github.com/apoelstra/rust-jsonrpc/actions/runs/5092343466 <.< I don't know why Github is so shitty at signalling problems with these yaml files. |
I don't think we should blame github for that one, its not even using the correct cfg flags, my bad. Fixed in #99 |
I still blame github. I think if they're gonna use an opaque ad-hoc language to configure their CI, which can only be debugged via reading green checkmarks, then they shouldn't show green checkmarks on PRs that do it wrong. Or they should use a real language so people can review the code. |
let resp = req.send()?; | ||
let json = resp.json()?; |
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.
Shouldn't we check the status_code
of the resp
here?
Otherwise calling json()
on a response that isn't 200
would try to deserialize an empty body and therefore confusingly return a SerdeJsonError
(https://github.com/neonmoe/minreq/blob/75f28d4eba632e7652b6c15adc746a251c657ad2/src/response.rs#L164-L177) whereas it's not a JSON error but an invalid request.
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.
Bitcoin Core does not return an empty body alongside HTTP error codes. It returns a JSON blob with error information.
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.
It depends on the error. For instance when the work queue is exceeded bitcoind
would return a 503 with an error message that is not JSON (see here). It's necessary for application to be able to match
on these errors to determine on which ones to wait and retry vs on which one to crash the software.
A trick to make sure we don't try to parse JSON when bitcoind doesn't send some is to look under which conditions would bitcoin-cli expect JSON or not: https://github.com/bitcoin/bitcoin/blob/d6ee03507f39223889a5f039c4db7204ddfb91d5/src/bitcoin-cli.cpp#L821-L850.
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 think we could just try to parse the JSON, and in the case of error, check whether the response was 200. For 200 we should return the JSON error, for non-200 we should return a status error.
Trying to match Core's exact behavior here, which I doubt is a stable part of their API, seems too fragile.
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.
Sounds good!
…n body 66fb441 minreq_http: return an HTTP error on error with no JSON in body (Antoine Poinsot) Pull request description: It is useful for downstream users to be matching on errors that do not contain a valid JSONRPC error in the HTTP response body. One instance is if the HTTP server work queue depth is exceeded, as they probably want to retry the request later. On such error we would return a JSON deserialization error, without exposing neither the HTTP status code nor the body of the response. This made it impossible to detect such transient errors. Instead, introduce a new HttpError variant that gets returned when the requested is responded to by an error that does not contain valid JSON in its body. See also: #94 (comment). ACKs for top commit: apoelstra: ACK 66fb441 Tree-SHA512: 76c831331c3b84e2f4319d62828b18574fd6af39a49c98d06c0c5a9c7833c828c9e02522b635a52f289e149cfc0a1abc160ac18d5edaf36114126186d39f4e0b
Add a new module
minreq_http
that implementsclient::Transport
usingminreq
as the underlying HTTP transport.rust-bitcoin
simple_http
rust-bitcoincore-rpc
https://github.com/neonmoe/minreq/