From 6063f2a9582e7e8fead2c65e1773cfb207f9155b Mon Sep 17 00:00:00 2001 From: Adrian Gallagher Date: Sun, 29 Jan 2017 07:00:00 -0800 Subject: [PATCH] Litecoin: Protocol and default settings 0) Adjust BIP30 enforcement values 1) Reduce amount that peers can adjust our time to eliminate an attack vector. Thanks to coblee for this fix. 2) Zeitgeist2 patch - thanks to Lolcust and ArtForz. This fixes an issue where a 51% attack can change difficulty at will. Go back the full period unless it's the first retarget after genesis. 3) Avoid overflow in CalculateNextWorkRequired(). Thanks to pooler for the overflow fix. 4) Zeitgeist2 bool fshift bnNew.bits(). Thanks to romanornr for this path. 5) SegWit ContextualCheckBlockHeader adjustment and extra coverage. 6) Reject peer proto version below 70002. Thanks to wtogami for this patch. 7) Send final alert message to nodes warning about removal of the alert system. Thanks to coblee for this patch. 8) Adjust default settings for Litecoin. 9) Adjust STALE_CHECK_INTERVAL value --- contrib/linearize/example-linearize.cfg | 6 ++--- contrib/qos/README.md | 6 ++--- contrib/qos/tc.sh | 34 ++++++++----------------- contrib/seeds/generate-seeds.py | 4 +-- doc/REST-interface.md | 4 +-- doc/developer-notes.md | 4 +-- doc/tor.md | 8 +++--- share/examples/bitcoin.conf | 6 ++--- src/amount.h | 2 +- src/net_processing.cpp | 4 +-- src/netaddress.cpp | 4 +-- src/pow.cpp | 25 +++++++++++++++--- src/qt/intro.cpp | 2 +- src/rpc/net.cpp | 6 ++--- src/rpc/server.cpp | 2 +- src/test/compress_tests.cpp | 4 +-- src/test/miner_tests.cpp | 2 +- src/test/netbase_tests.cpp | 6 ++--- src/timedata.h | 2 +- src/validation.cpp | 10 ++++++-- src/validation.h | 2 +- src/version.h | 2 +- test/functional/feature_nulldummy.py | 7 ++--- test/functional/feature_proxy.py | 8 +++--- test/functional/p2p_segwit.py | 8 +++++- 25 files changed, 92 insertions(+), 76 deletions(-) diff --git a/contrib/linearize/example-linearize.cfg b/contrib/linearize/example-linearize.cfg index 2315898bf..84129f204 100644 --- a/contrib/linearize/example-linearize.cfg +++ b/contrib/linearize/example-linearize.cfg @@ -5,13 +5,13 @@ rpcpassword=somepassword host=127.0.0.1 #mainnet default -port=8332 +port=9332 #testnet default -#port=18332 +#port=19332 #regtest default -#port=18443 +#port=19443 # bootstrap.dat hashlist settings (linearize-hashes) max_height=313000 diff --git a/contrib/qos/README.md b/contrib/qos/README.md index 0ded87c58..d569b6a6f 100644 --- a/contrib/qos/README.md +++ b/contrib/qos/README.md @@ -1,5 +1,5 @@ -### QoS (Quality of service) ### +### Qos ### -This is a Linux bash script that will set up tc to limit the outgoing bandwidth for connections to the Bitcoin network. It limits outbound TCP traffic with a source or destination port of 8333, but not if the destination IP is within a LAN. +This is a Linux bash script that will set up tc to limit the outgoing bandwidth for connections to the Litecoin network. It limits outbound TCP traffic with a source or destination port of 9333, but not if the destination IP is within a LAN (defined as 192.168.x.x). -This means one can have an always-on bitcoind instance running, and another local bitcoind/bitcoin-qt instance which connects to this node and receives blocks from it. +This means one can have an always-on litecoind instance running, and another local litecoind/litecoin-qt instance which connects to this node and receives blocks from it. diff --git a/contrib/qos/tc.sh b/contrib/qos/tc.sh index 738ea70db..25c29fa5e 100644 --- a/contrib/qos/tc.sh +++ b/contrib/qos/tc.sh @@ -1,4 +1,4 @@ -# Copyright (c) 2017 The Bitcoin Core developers +# Copyright (c) 2013 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -7,12 +7,10 @@ export LC_ALL=C IF="eth0" #limit of the network interface in question LINKCEIL="1gbit" -#limit outbound Bitcoin protocol traffic to this rate +#limit outbound Litecoin protocol traffic to this rate LIMIT="160kbit" -#defines the IPv4 address space for which you wish to disable rate limiting -LOCALNET_V4="192.168.0.0/16" -#defines the IPv6 address space for which you wish to disable rate limiting -LOCALNET_V6="fe80::/10" +#defines the address space for which you wish to disable rate limiting +LOCALNET="192.168.0.0/16" #delete existing rules tc qdisc del dev ${IF} root @@ -31,12 +29,6 @@ tc class add dev ${IF} parent 1:1 classid 1:11 htb rate ${LIMIT} ceil ${LIMIT} p tc filter add dev ${IF} parent 1: protocol ip prio 1 handle 1 fw classid 1:10 tc filter add dev ${IF} parent 1: protocol ip prio 2 handle 2 fw classid 1:11 -if [ ! -z "${LOCALNET_V6}" ] ; then - # v6 cannot have the same priority value as v4 - tc filter add dev ${IF} parent 1: protocol ipv6 prio 3 handle 1 fw classid 1:10 - tc filter add dev ${IF} parent 1: protocol ipv6 prio 4 handle 2 fw classid 1:11 -fi - #delete any existing rules #disable for now #ret=0 @@ -45,16 +37,10 @@ fi # ret=$? #done -#limit outgoing traffic to and from port 8333. but not when dealing with a host on the local network -# (defined by $LOCALNET_V4 and $LOCALNET_V6) -# --set-mark marks packages matching these criteria with the number "2" (v4) -# --set-mark marks packages matching these criteria with the number "4" (v6) -# these packets are filtered by the tc filter with "handle 2" +#limit outgoing traffic to and from port 9333. but not when dealing with a host on the local network +# (defined by $LOCALNET) +# --set-mark marks packages matching these criteria with the number "2" +# these packages are filtered by the tc filter with "handle 2" # this filter sends the packages into the 1:11 class, and this class is limited to ${LIMIT} -iptables -t mangle -A OUTPUT -p tcp -m tcp --dport 8333 ! -d ${LOCALNET_V4} -j MARK --set-mark 0x2 -iptables -t mangle -A OUTPUT -p tcp -m tcp --sport 8333 ! -d ${LOCALNET_V4} -j MARK --set-mark 0x2 - -if [ ! -z "${LOCALNET_V6}" ] ; then - ip6tables -t mangle -A OUTPUT -p tcp -m tcp --dport 8333 ! -d ${LOCALNET_V6} -j MARK --set-mark 0x4 - ip6tables -t mangle -A OUTPUT -p tcp -m tcp --sport 8333 ! -d ${LOCALNET_V6} -j MARK --set-mark 0x4 -fi +iptables -t mangle -A OUTPUT -p tcp -m tcp --dport 9333 ! -d ${LOCALNET} -j MARK --set-mark 0x2 +iptables -t mangle -A OUTPUT -p tcp -m tcp --sport 9333 ! -d ${LOCALNET} -j MARK --set-mark 0x2 diff --git a/contrib/seeds/generate-seeds.py b/contrib/seeds/generate-seeds.py index fe7cd1d59..ab96d3374 100755 --- a/contrib/seeds/generate-seeds.py +++ b/contrib/seeds/generate-seeds.py @@ -128,10 +128,10 @@ def main(): g.write(' * IPv4 as well as onion addresses are wrapped inside an IPv6 address accordingly.\n') g.write(' */\n') with open(os.path.join(indir,'nodes_main.txt'), 'r', encoding="utf8") as f: - process_nodes(g, f, 'pnSeed6_main', 8333) + process_nodes(g, f, 'pnSeed6_main', 9333) g.write('\n') with open(os.path.join(indir,'nodes_test.txt'), 'r', encoding="utf8") as f: - process_nodes(g, f, 'pnSeed6_test', 18333) + process_nodes(g, f, 'pnSeed6_test', 19335) g.write('#endif // BITCOIN_CHAINPARAMSSEEDS_H\n') if __name__ == '__main__': diff --git a/doc/REST-interface.md b/doc/REST-interface.md index 7010edfcd..19466bf84 100644 --- a/doc/REST-interface.md +++ b/doc/REST-interface.md @@ -58,7 +58,7 @@ https://github.com/bitcoin/bips/blob/master/bip-0064.mediawiki Example: ``` -$ curl localhost:18332/rest/getutxos/checkmempool/b2cdfd7b89def827ff8af7cd9bff7627ff72e5e8b0f71210f92ea7a4000c5d75-0.json 2>/dev/null | json_pp +$ curl localhost:19332/rest/getutxos/checkmempool/b2cdfd7b89def827ff8af7cd9bff7627ff72e5e8b0f71210f92ea7a4000c5d75-0.json 2>/dev/null | json_pp { "chainHeight" : 325347, "chaintipHash" : "00000000fb01a7f3745a717f8caebee056c484e6e0bfe4a9591c235bb70506fb", @@ -100,4 +100,4 @@ Only supports JSON as output format. Risks ------------- -Running a web browser on the same node with a REST enabled bitcoind can be a risk. Accessing prepared XSS websites could read out tx/block data of your node by placing links like `