Skip to content

Commit

Permalink
Add fee_est tool for debugging fee estimation code
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanofsky committed Dec 12, 2017
1 parent 13e0a99 commit d9cc337
Show file tree
Hide file tree
Showing 3 changed files with 401 additions and 2 deletions.
36 changes: 34 additions & 2 deletions src/Makefile.test.include
Expand Up @@ -3,7 +3,7 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

TESTS += test/test_bitcoin
bin_PROGRAMS += test/test_bitcoin
bin_PROGRAMS += test/test_bitcoin test/fee_est/fee_est
noinst_PROGRAMS += test/test_bitcoin_fuzzy
TEST_SRCDIR = test
TEST_BINARY=test/test_bitcoin$(EXEEXT)
Expand Down Expand Up @@ -110,7 +110,7 @@ test_test_bitcoin_LDADD += $(LIBBITCOIN_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRY
test_test_bitcoin_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static

if ENABLE_ZMQ
test_test_bitcoin_LDADD += $(ZMQ_LIBS)
test_test_bitcoin_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS)
endif
#

Expand All @@ -132,6 +132,38 @@ test_test_bitcoin_fuzzy_LDADD = \
test_test_bitcoin_fuzzy_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS)
#

# fee_est/fee_est binary #
test_fee_est_fee_est_SOURCES = test/fee_est/fee_est.cpp
test_fee_est_fee_est_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
test_fee_est_fee_est_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
test_fee_est_fee_est_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
test_fee_est_fee_est_LDADD = \
$(LIBBITCOIN_SERVER)

if ENABLE_WALLET
test_fee_est_fee_est_LDADD += \
$(LIBBITCOIN_WALLET)
endif

test_fee_est_fee_est_LDADD += \
$(LIBBITCOIN_COMMON) \
$(LIBBITCOIN_UTIL) \
$(LIBBITCOIN_CONSENSUS) \
$(LIBBITCOIN_CRYPTO) \
$(LIBLEVELDB) $(LIBLEVELDB_SSE42) $(LIBMEMENV) \
$(LIBSECP256K1) \
$(LIBUNIVALUE) \
$(BDB_LIBS) \
$(BOOST_LIBS) \
$(CRYPTO_LIBS) \
$(EVENT_LIBS) $(EVENT_PTHREADS_LIBS) \
$(MINIUPNPC_LIBS)

if ENABLE_ZMQ
test_fee_est_fee_est_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS)
endif
#

nodist_test_test_bitcoin_SOURCES = $(GENERATED_TEST_FILES)

$(BITCOIN_TESTS): $(GENERATED_TEST_FILES)
Expand Down
37 changes: 37 additions & 0 deletions src/test/fee_est/README.md
@@ -0,0 +1,37 @@
src/test/fee_est -- Fee estimation offline testing tool
=======================================================

The `fee_est` tool is intended to help debug and test changes in bitcoin fee
estimation code using transaction data gathered from live bitcoin nodes.

Transaction data can be collected by running bitcoind with `-estlog` parameter
which will produce newline-delimited json file (http://ndjson.org/,
http://jsonlines.org/) which logs relevant transaction information. The
`fee_est` tool can parse the log to produce graphs of fee estimation data and do
some basic analysis of the results. The implementation is intended to be simple
enough that it can be easily customized to do more specific analysis.

Example usage:

Run bitcoind collecting fee estimation data:

```
$ make -C src bitcoind test/fee_est/fee_est
$ src/bitcoind -estlog=est.log &
```

Run fee estimation tool producing graph of estimates:

```
$ src/test/fee_est/fee_est -ograph=graph.html est.log
$ chrome graph.html
```

Run fee estimation tool computing some basic statistics:

```
$ src/test/fee_est/fee_est -cross est.log
Non-test txs: 1407226
Test txs: 5603 total (4345 kept, 631 discarded unconfirmed, 627 discarded outliers)
Mean squared error: 71.0651
```

0 comments on commit d9cc337

Please sign in to comment.