Commit Graph

16599 Commits

Author SHA1 Message Date
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
jl777
a13fb56e55 Test 2017-03-23 21:40:31 +02:00
jl777
ad8796cf7c Test 2017-03-23 21:35:19 +02:00
jl777
f59302b668 Merge pull request #360 from jl777/dev
Check against pblock->nTime
2017-03-23 20:54:36 +02:00
jl777
628220bc5d Check against pblock->nTime 2017-03-23 20:54:07 +02:00
jl777
741b884ec6 Merge pull request #359 from jl777/dev
Dev
2017-03-23 20:48:48 +02:00
jl777
e40b78e93c Crash fix 2017-03-23 20:47:47 +02:00
jl777
e4f53bd20a Test 2017-03-23 20:23:25 +02: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
jl777
110696f9e1 Test 2017-03-23 20:09:55 +02:00
jl777
88e117ada6 Test 2017-03-23 20:09:07 +02:00
jl777
a2f017de08 Test 2017-03-23 20:05:02 +02:00
jl777
9b7233cf17 Test 2017-03-23 19:58:23 +02:00
jl777
944bf4b091 Test 2017-03-23 19:57:18 +02:00
jl777
0a0ec219d7 Test 2017-03-23 19:44:40 +02:00
jl777
da7775433d Test 2017-03-23 19:40:37 +02:00
jl777
6460b5b19c Test 2017-03-23 19:38:59 +02: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
jl777
55d65e32ca Test 2017-03-23 19:26:19 +02:00
jl777
25d900ccd5 Merge pull request #358 from jl777/dev
Test
2017-03-23 18:37:56 +02:00
jl777
2ef1dfb6f1 Test 2017-03-23 18:35:11 +02:00
jl777
bf49cc6524 Merge pull request #357 from jl777/dev
Dev
2017-03-23 15:44:19 +02:00
jl777
89a2e5273c Test 2017-03-23 15:37:34 +02:00
jl777
9e8b81f637 Remove print 2017-03-23 14:20:16 +02:00
ca333
9fe0c0c126 Merge pull request #6 from jl777/master
master update
2017-03-23 11:34:53 +01:00
Jack Grigg
dec148f498 Fix prioritisetransaction RPC test
Part of #1884.
2017-03-23 18:57:46 +13:00
jl777
7674e37ff8 Merge pull request #356 from jl777/dPoW
DPoW
2017-03-23 07:29:18 +02:00
jl777
58d2e02b85 Merge pull request #355 from jl777/beta
Beta
2017-03-23 07:28:42 +02:00
jl777
cf3fe7e69e Merge pull request #354 from jl777/dev
Post-fork with mining
2017-03-23 07:26:26 +02:00