Commit Graph

10404 Commits

Author SHA1 Message Date
Jack Grigg 47855b599d
Revert "Revert "rpc-tests: re-enable rpc-tests for Windows""
This reverts commit 7fd5d4e30e.

We need to un-revert this before pulling in
https://github.com/bitcoin/bitcoin/pull/6616
2017-03-25 17:37:18 +13:00
Wladimir J. van der Laan e93a3e1945
test: Avoid ConnectionResetErrors during RPC tests
This is necessary on FreeBSD and MacOSX, at least.

See https://github.com/bitcoin/bitcoin/pull/8834#issuecomment-250450213
2017-03-24 18:43:40 +13:00
Pieter Wuille 2edad86b2d
Fix interrupted HTTP RPC connection workaround for Python 3.5+ 2017-03-24 18:43:21 +13:00
paveljanik 17694e4bcf
[TRIVIAL] Fix typo: exactmath -> exactmatch
... but not yet in trivial tree
2017-03-24 18:42:45 +13:00
Jack Grigg a163953929
[depends] libevent 2.1.8 2017-03-24 09:03:59 +13:00
Ian Kelling 629a875229
Docs: add details to -rpcclienttimeout doc 2017-03-24 09:03:59 +13:00
Luke Dashjr c65969a5a6
Skip RAII event tests if libevent is built without event_set_mem_functions 2017-03-24 09:03:59 +13:00
fanquake ec626cc530
[depends] libevent 2.1.7rc 2017-03-24 09:03:59 +13:00
Karl-Johan Alm ca50af75b1
Added EVENT_CFLAGS to test makefile to explicitly include libevent headers. 2017-03-24 09:03:59 +13:00
Karl-Johan Alm e8b6d84b9f
Added some simple tests for the RAII-style events. 2017-03-24 09:03:59 +13:00
Karl-Johan Alm 68377e18a8
Switched bitcoin-cli.cpp to use RAII unique pointers with deleters. 2017-03-24 09:03:59 +13:00
Karl-Johan Alm 17fb609097
Added std::unique_ptr<> wrappers with deleters for libevent modules. 2017-03-24 09:03:59 +13:00
Wladimir J. van der Laan 7c2ab05969
bitcoin-cli: Make error message less confusing
Sorry for the churn on this, but the current message (introduced in #9073)
isn't acceptable:

    $ src/bitcoin-cli getinfo
    rpc: couldn't connect to server
    (make sure server is running and you are connecting to the correct RPC port: -1 unknown)

Putting the error code after the words "RPC port" made me wonder whether
there was a port configuration issue.

This changes it to:

    $ src/bitcoin-cli getinfo
    error: couldn't connect to server: unknown (code -1)
    (make sure server is running and you are connecting to the correct RPC port)
2017-03-24 09:03:59 +13:00
instagibbs 603205e381
Add common failure cases for rpc server connection failure 2017-03-24 09:03:59 +13:00
Wladimir J. van der Laan 32f4e7744c
depends: Add libevent compatibility patch for windows
Add a patch that seems to be necessary for compatibilty of libevent
2.0.22 with recent mingw-w64 gcc versions (at least GCC 5.3.1 from Ubuntu
16.04).

Without this patch the Content-Length in the HTTP header ends up as
`Content-Length: zu`, causing communication between the RPC
client and server to break down. See discussion in #8653.

Source: https://sourceforge.net/p/levent/bugs/363/

Thanks to @sstone for the suggestion.
2017-03-24 09:03:59 +13:00
Wladimir J. van der Laan 6415573a59
bitcoin-cli: More detailed error reporting
Register a evhttp error handler to get a more detailed error message
if the HTTP request fails.
2017-03-24 09:03:59 +13:00
Wladimir J. van der Laan 08c581940a
auto_ptr → unique_ptr
Change the few occurrences of the deprecated `auto_ptr` to c++11 `unique_ptr`.
Silences the deprecation warnings.

Also add a missing `std::` for consistency.
2017-03-24 09:03:59 +13:00
Wladimir J. van der Laan 0e2b1ae259
chain: define enum used as bit field as uint32_t
Bitwise logic combined with `<` with undefined signedness will
potentially results in undefined behavior. Fix this by defining the type
as a c++11 typed enum.

Fixes #6017.
2017-03-24 09:03:59 +13:00
Gregory Maxwell 599d2c4034
Avoid a compile error on hosts with libevent too old for EVENT_LOG_WARN.
This uses _EVENT_LOG_WARN instead, which appears to be defined in the
 old versions of libevent that I have on some systems.
2017-03-24 09:03:59 +13:00
Bob McElrath c922edd00f
Add explicit shared_ptr constructor due to C++11 error 2017-03-24 09:03:59 +13:00
Wladimir J. van der Laan 7b41e725d0
Make RPC tests cope with server-side timeout between requests
Python's httplib does not graciously handle disconnections from the http server, resulting in BadStatusLine errors.
See https://bugs.python.org/issue3566 "httplib persistent connections violate MUST in RFC2616 sec 8.1.4."

This was fixed in Python 3.5.

Work around it for now.
2017-03-24 09:03:59 +13:00
Wladimir J. van der Laan 89bccddcd8
rpc: Split option -rpctimeout into -rpcservertimeout and -rpcclienttimeout
The two timeouts for the server and client, are essentially different:

- In the case of the server it should be a lower value to avoid clients
clogging up connection slots

- In the case of the client it should be a high value to accomedate slow
  responses from the server, for example for slow queries or when the
  lock is contended

Split the options into `-rpcservertimeout` and `-rpcclienttimeout` with
respective defaults of 30 and 900.
2017-03-24 09:03:59 +13:00
Wladimir J. van der Laan a659991a2c
http: Disable libevent debug logging, if not explicitly enabled
Add a option "-debug=libevent" to enable libevent debugging for troubleshooting.
Libevent logging is redirected to our own log.
2017-03-24 09:03:59 +13:00
Wladimir J. van der Laan 7ed4d40c61
init: Ignore SIGPIPE
Ignore SIGPIPE on all non-win32 OSes, otherwise an unexpectedly disconnecting
RPC client will terminate the application. This problem was introduced
with the libhttp-based RPC server.

Fixes #6660.
2017-03-24 09:03:59 +13:00
Jack Grigg 077ddc1187
Add libevent to zcash-gtest 2017-03-24 09:03:59 +13:00
Wladimir J. van der Laan 7fd5d4e30e
Revert "rpc-tests: re-enable rpc-tests for Windows"
This reverts commit bd30c3dced21fca869a14c75081f15195762afe1.

Disable windows RPC tests for now. These should be re-enabled once a
suitable Wine version is used on Travis.
2017-03-24 09:03:59 +13:00
Wladimir J. van der Laan 167b6231c9
Move windows socket init to utility function 2017-03-24 09:03:59 +13:00
Cory Fields 91295c4b4d
libevent: Windows reuseaddr workaround in depends
Make it possible to reuse sockets.
This is necessary to make the RPC tests work in WINE.
2017-03-24 09:03:59 +13:00
Wladimir J. van der Laan 116503c0b8
Fix race condition between starting HTTP server thread and setting EventBase()
Split StartHTTPServer into InitHTTPServer and StartHTTPServer to give
clients a window to register their handlers without race conditions.

Thanks @ajweiss for figuring this out.
2017-03-24 09:03:59 +13:00
Wladimir J. van der Laan 9fb5b94e64
Document options for new HTTP/RPC server in --help 2017-03-24 09:03:59 +13:00
Wladimir J. van der Laan 858afa1a4a
Implement RPCTimerHandler for Qt RPC console
Implement RPCTimerHandler for Qt RPC console, so that `walletpassphrase`
works with GUI and `-server=0`.

Also simplify HTTPEvent-related code by using boost::function directly.

Zcash: QT changes ommitted
2017-03-24 09:03:59 +13:00
Wladimir J. van der Laan afd64f76ea
evhttpd implementation
- *Replace usage of boost::asio with [libevent2](http://libevent.org/)*.
boost::asio is not part of C++11, so unlike other boost there is no
forwards-compatibility reason to stick with it. Together with #4738 (convert
json_spirit to UniValue), this rids Bitcoin Core of the worst offenders with
regard to compile-time slowness.

- *Replace spit-and-duct-tape http server with evhttp*. Front-end http handling
is handled by libevent, a work queue (with configurable depth and parallelism)
is used to handle application requests.

- *Wrap HTTP request in C++ class*; this makes the application code mostly
HTTP-server-neutral

- *Refactor RPC to move all http-specific code to a separate file*.
Theoreticaly this can allow building without HTTP server but with another RPC
backend, e.g. Qt's debug console (currently not implemented) or future RPC
mechanisms people may want to use.

- *HTTP dispatch mechanism*; services (e.g., RPC, REST) register which URL
paths they want to handle.

By using a proven, high-performance asynchronous networking library (also used
by Tor) and HTTP server, problems such as #5674, #5655, #344 should be avoided.

What works? bitcoind, bitcoin-cli, bitcoin-qt. Unit tests and RPC/REST tests
pass. The aim for now is everything but SSL support.

Configuration options:

- `-rpcthreads`: repurposed as "number of  work handler threads". Still
defaults to 4.

- `-rpcworkqueue`: maximum depth of work queue. When this is reached, new
requests will return a 500 Internal Error.

- `-rpctimeout`: inactivity time, in seconds, after which to disconnect a
client.

- `-debug=http`: low-level http activity logging
2017-03-24 09:03:59 +13:00
Wladimir J. van der Laan cc14ac45f4
tests: GET requests cannot have request body, use POST in rest.py
Sending a request body with GET request is not valid in HTTP spec, and
not compatible with evhttpd.
2017-03-24 09:03:59 +13:00
Wladimir J. van der Laan df377ca82c
build: build-system changes for libevent 2017-03-24 09:03:59 +13:00
Cory Fields 505b30ff01
libevent: add depends 2017-03-24 09:03:59 +13:00
Wladimir J. van der Laan 72f52420ec
Remove rpc_boostasiotocnetaddr test
Dropping all use of boost::asio.
2017-03-24 09:03:59 +13:00
Wladimir J. van der Laan 14dcc6ab96
qa: Remove -rpckeepalive tests from httpbasics
This option was a temporary workaround, and is no longer necessary
with the new web server.
2017-03-24 09:03:59 +13:00
Wladimir J. van der Laan b6fbda0982
doc: remove documentation for rpcssl 2017-03-24 09:03:59 +13:00
Jack Grigg bec25c91cb
Revert "Closes #1680, temporary fix for rpc deadlock inherited from upstream."
This reverts commit f4404d7b5b.
2017-03-24 09:03:59 +13:00
zkbot 7d9bf65501 Auto merge of #2168 - str4d:2164-getblock-anchor, r=daira
Add anchor to output of getblock

Closes #2164.
2017-03-23 18:21:10 +00:00
zkbot 00e59e5935 Auto merge of #2175 - str4d:2074-txn-mempool, r=bitcartel
Bitcoin 0.12 mempool memory usage PRs

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#6410
- bitcoin/bitcoin#6453
- bitcoin/bitcoin#6013 (excludes changes to docs we deleted)

Part of #2074.
2017-03-23 17:29:35 +00:00
zkbot 3b11e24f92 Auto merge of #2183 - ebfull:rust-introduction, r=ebfull
Introduce Rust/librustzcash into the zcash build system

Introduces Rust into the build system and brings a trivial xor operation into the code (near where we will likely be working).
2017-03-21 03:40:12 +00:00
zkbot c4a7c9f20f Auto merge of #2157 - arcalinea:1652_submitblock_documentation, r=daira
Document returned results of submitblock

documentation for #1652
2017-03-20 17:11:50 +00:00
Sean Bowe 802ea76b3a Allow Rust-language related assets to be disabled with `--disable-rust`. 2017-03-18 07:47:40 -06:00
Sean Bowe 6a0c7ceae9 Introduce librustzcash and Rust to depends system. 2017-03-17 11:46:41 -06:00
zkbot 7ab5912a78 Auto merge of #2184 - zcash:jackgavigan-COPYING-changes, r=bitcartel
Removed markdown from COPYING

Updated the Copyright statement at the top of the file from "2016" to "2016-2017" and removed markdown markup from the main text.
2017-03-16 23:09:46 +00:00
Jack Gavigan 6c9ebc6bdc Updated the Bitcoin Core copyright statement 2017-03-16 13:40:42 +00:00
zkbot db0f7159c3 Auto merge of #2161 - arcalinea:2160_revise_release_process, r=str4d
Edit release-process.md for clarity

For #2160
2017-03-16 01:47:35 +00:00
Jack Grigg 542a7a40f1
Add tests for getmempoolinfo 2017-03-16 14:30:16 +13:00
Jack Gavigan 472dec5352 Removed markdown from COPYING
Updated the Copyright statement at the top of the file from "2016" to "2016-2017" and removed markdown markup from the main text.
2017-03-15 12:14:28 +00:00