[Pkg-bitcoin-commits] [p2pool] 01/01: added some post-release patches from upstream

Dmitry Smirnov onlyjob at moszumanska.debian.org
Sat Apr 12 01:59:05 UTC 2014


This is an automated email from the git hooks/post-receive script.

onlyjob pushed a commit to branch master
in repository p2pool.

commit baa128f (HEAD, master)
Author: Dmitry Smirnov <onlyjob at member.fsf.org>
Date:   Sat Apr 12 01:58:13 2014

    added some post-release patches from upstream
---
 ...rs-that-send-shares-that-fail-to-validate.patch | 89 ++++++++++++++++++++++
 ...nefficiencient-behaviour-when-chain-is-fo.patch | 53 +++++++++++++
 ...print-share-hashes-when-share-check-fails.patch | 25 ++++++
 ...possible-crash-introduced-by-prior-commit.patch | 25 ++++++
 debian/patches/series                              |  4 +
 5 files changed, 196 insertions(+)

diff --git a/debian/patches/0001-ban-peers-that-send-shares-that-fail-to-validate.patch b/debian/patches/0001-ban-peers-that-send-shares-that-fail-to-validate.patch
new file mode 100644
index 0000000..5b5aba1
--- /dev/null
+++ b/debian/patches/0001-ban-peers-that-send-shares-that-fail-to-validate.patch
@@ -0,0 +1,89 @@
+From 012a8830c61226f48d979db9800edf1862d83df4 Mon Sep 17 00:00:00 2001
+From: Forrest Voight <forrest at forre.st>
+Date: Sun, 19 Jan 2014 17:05:35 -0500
+Subject: [PATCH 1/4] ban peers that send shares that fail to validate
+
+---
+ p2pool/data.py |  6 +++++-
+ p2pool/node.py | 11 +++++++++--
+ p2pool/p2p.py  |  3 +--
+ 3 files changed, 15 insertions(+), 5 deletions(-)
+
+diff --git a/p2pool/data.py b/p2pool/data.py
+index 3ebc1f7..0ce4f7a 100644
+--- a/p2pool/data.py
++++ b/p2pool/data.py
+@@ -438,6 +438,7 @@ class OkayTracker(forest.Tracker):
+     
+     def think(self, block_rel_height_func, previous_block, bits, known_txs):
+         desired = set()
++        bad_peer_addresses = set()
+         
+         # O(len(self.heads))
+         #   make 'unverified heads' set?
+@@ -464,6 +465,9 @@ class OkayTracker(forest.Tracker):
+         for bad in bads:
+             assert bad not in self.verified.items
+             assert bad in self.heads
++            bad_share = self.items[bad]
++            if bad_share.peer_addr is not None:
++                bad_peer_addresses.add(bad_share.peer_addr)
+             if p2pool.DEBUG:
+                 print "BAD", bad
+             self.remove(bad)
+@@ -527,7 +531,7 @@ class OkayTracker(forest.Tracker):
+             for peer_addr, hash, ts, targ in desired:
+                 print '   ', None if peer_addr is None else '%s:%i' % peer_addr, format_hash(hash), math.format_dt(time.time() - ts), bitcoin_data.target_to_difficulty(targ), ts >= timestamp_cutoff, targ <= target_cutoff
+         
+-        return best, [(peer_addr, hash) for peer_addr, hash, ts, targ in desired if ts >= timestamp_cutoff], decorated_heads
++        return best, [(peer_addr, hash) for peer_addr, hash, ts, targ in desired if ts >= timestamp_cutoff], decorated_heads, bad_peer_addresses
+     
+     def score(self, share_hash, block_rel_height_func):
+         # returns approximate lower bound on chain's hashrate in the last self.net.CHAIN_LENGTH*15//16*self.net.SHARE_PERIOD time
+diff --git a/p2pool/node.py b/p2pool/node.py
+index 2b25fbe..4a91620 100644
+--- a/p2pool/node.py
++++ b/p2pool/node.py
+@@ -292,16 +292,23 @@ class Node(object):
+         stop_signal.watch(t.stop)
+     
+     def set_best_share(self):
+-        best, desired, decorated_heads = self.tracker.think(self.get_height_rel_highest, self.bitcoind_work.value['previous_block'], self.bitcoind_work.value['bits'], self.known_txs_var.value)
++        best, desired, decorated_heads, bad_peer_addresses = self.tracker.think(self.get_height_rel_highest, self.bitcoind_work.value['previous_block'], self.bitcoind_work.value['bits'], self.known_txs_var.value)
+         
+         self.best_share_var.set(best)
+         self.desired_var.set(desired)
++        if self.p2p_node is not None:
++            for bad_peer_address in bad_peer_addresses:
++                # XXX O(n)
++                for peer in self.p2p_node.peers.itervalues():
++                    if peer.addr == bad_peer_address:
++                        peer.badPeerHappened()
++                        break
+     
+     def get_current_txouts(self):
+         return p2pool_data.get_expected_payouts(self.tracker, self.best_share_var.value, self.bitcoind_work.value['bits'].target, self.bitcoind_work.value['subsidy'], self.net)
+     
+     def clean_tracker(self):
+-        best, desired, decorated_heads = self.tracker.think(self.get_height_rel_highest, self.bitcoind_work.value['previous_block'], self.bitcoind_work.value['bits'], self.known_txs_var.value)
++        best, desired, decorated_heads, bad_peer_addresses = self.tracker.think(self.get_height_rel_highest, self.bitcoind_work.value['previous_block'], self.bitcoind_work.value['bits'], self.known_txs_var.value)
+         
+         # eat away at heads
+         if decorated_heads:
+diff --git a/p2pool/p2p.py b/p2pool/p2p.py
+index 707d346..94db442 100644
+--- a/p2pool/p2p.py
++++ b/p2pool/p2p.py
+@@ -94,8 +94,7 @@ class Protocol(p2protocol.Protocol):
+             self.badPeerHappened()
+     
+     def badPeerHappened(self):
+-        if p2pool.DEBUG:
+-            print "Bad peer banned:", self.addr
++        print "Bad peer banned:", self.addr
+         self.disconnect()
+         if self.transport.getPeer().host != '127.0.0.1': # never ban localhost
+             self.node.bans[self.transport.getPeer().host] = time.time() + 60*60
+-- 
+1.8.5.2
+
diff --git a/debian/patches/0002-deal-with-inefficiencient-behaviour-when-chain-is-fo.patch b/debian/patches/0002-deal-with-inefficiencient-behaviour-when-chain-is-fo.patch
new file mode 100644
index 0000000..7cbaa94
--- /dev/null
+++ b/debian/patches/0002-deal-with-inefficiencient-behaviour-when-chain-is-fo.patch
@@ -0,0 +1,53 @@
+From 11b0d96235a25f678b74151ac93e7e06a1b60c3c Mon Sep 17 00:00:00 2001
+From: Forrest Voight <forrest at forre.st>
+Date: Sun, 19 Jan 2014 19:20:30 -0500
+Subject: [PATCH 2/4] deal with inefficiencient behaviour when chain is forked
+
+---
+ p2pool/data.py | 12 +++++++-----
+ 1 file changed, 7 insertions(+), 5 deletions(-)
+
+diff --git a/p2pool/data.py b/p2pool/data.py
+index 0ce4f7a..0e62a0f 100644
+--- a/p2pool/data.py
++++ b/p2pool/data.py
+@@ -445,15 +445,14 @@ class OkayTracker(forest.Tracker):
+         # for each overall head, attempt verification
+         # if it fails, attempt on parent, and repeat
+         # if no successful verification because of lack of parents, request parent
+-        bads = set()
++        bads = []
+         for head in set(self.heads) - set(self.verified.heads):
+             head_height, last = self.get_height_and_last(head)
+             
+             for share in self.get_chain(head, head_height if last is None else min(5, max(0, head_height - self.net.CHAIN_LENGTH))):
+                 if self.attempt_verify(share):
+                     break
+-                if share.hash in self.heads:
+-                    bads.add(share.hash)
++                bads.append(share.hash)
+             else:
+                 if last is not None:
+                     desired.add((
+@@ -464,13 +463,16 @@ class OkayTracker(forest.Tracker):
+                     ))
+         for bad in bads:
+             assert bad not in self.verified.items
+-            assert bad in self.heads
++            #assert bad in self.heads
+             bad_share = self.items[bad]
+             if bad_share.peer_addr is not None:
+                 bad_peer_addresses.add(bad_share.peer_addr)
+             if p2pool.DEBUG:
+                 print "BAD", bad
+-            self.remove(bad)
++            try:
++                self.remove(bad)
++            except NotImplementedError:
++                pass
+         
+         # try to get at least CHAIN_LENGTH height for each verified head, requesting parents if needed
+         for head in list(self.verified.heads):
+-- 
+1.8.5.2
+
diff --git a/debian/patches/0003-print-share-hashes-when-share-check-fails.patch b/debian/patches/0003-print-share-hashes-when-share-check-fails.patch
new file mode 100644
index 0000000..e0db967
--- /dev/null
+++ b/debian/patches/0003-print-share-hashes-when-share-check-fails.patch
@@ -0,0 +1,25 @@
+From 8c30d486ead72c55906bbb230e78c2fbf75df4a5 Mon Sep 17 00:00:00 2001
+From: Forrest Voight <forrest at forre.st>
+Date: Mon, 20 Jan 2014 02:54:47 -0500
+Subject: [PATCH 3/4] print share hashes when share check fails
+
+---
+ p2pool/data.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/p2pool/data.py b/p2pool/data.py
+index 0e62a0f..7c44878 100644
+--- a/p2pool/data.py
++++ b/p2pool/data.py
+@@ -430,7 +430,7 @@ class OkayTracker(forest.Tracker):
+         try:
+             share.check(self)
+         except:
+-            log.err(None, 'Share check failed:')
++            log.err(None, 'Share check failed: %064x -> %064x' % (share.hash, share.previous_hash))
+             return False
+         else:
+             self.verified.add(share)
+-- 
+1.8.5.2
+
diff --git a/debian/patches/0004-fixed-possible-crash-introduced-by-prior-commit.patch b/debian/patches/0004-fixed-possible-crash-introduced-by-prior-commit.patch
new file mode 100644
index 0000000..34c83b9
--- /dev/null
+++ b/debian/patches/0004-fixed-possible-crash-introduced-by-prior-commit.patch
@@ -0,0 +1,25 @@
+From 39767a2c7da3b22efc8d90623dcda12b6ab4f419 Mon Sep 17 00:00:00 2001
+From: Forrest Voight <forrest at forre.st>
+Date: Mon, 20 Jan 2014 02:58:25 -0500
+Subject: [PATCH 4/4] fixed possible crash introduced by prior commit
+
+---
+ p2pool/data.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/p2pool/data.py b/p2pool/data.py
+index 7c44878..e8fe347 100644
+--- a/p2pool/data.py
++++ b/p2pool/data.py
+@@ -430,7 +430,7 @@ class OkayTracker(forest.Tracker):
+         try:
+             share.check(self)
+         except:
+-            log.err(None, 'Share check failed: %064x -> %064x' % (share.hash, share.previous_hash))
++            log.err(None, 'Share check failed: %064x -> %064x' % (share.hash, share.previous_hash if share.previous_hash is not None else 0))
+             return False
+         else:
+             self.verified.add(share)
+-- 
+1.8.5.2
+
diff --git a/debian/patches/series b/debian/patches/series
index 3893360..dfd5d3a 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,5 @@
 debian.patch
+0001-ban-peers-that-send-shares-that-fail-to-validate.patch
+0002-deal-with-inefficiencient-behaviour-when-chain-is-fo.patch
+0003-print-share-hashes-when-share-check-fails.patch
+0004-fixed-possible-crash-introduced-by-prior-commit.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-bitcoin/p2pool.git



More information about the Pkg-bitcoin-commits mailing list