dashpay / p2pool-dash

GNU General Public License v3.0
48 stars 85 forks source link

not in pack_to_unpack ({1: 'tx', 2: 'block'}) #9

Closed poiuty closed 9 years ago

poiuty commented 9 years ago

Old bug (not crit) => https://dashtalk.org/threads/nekorrektnye-bloki.3949/

Looks like these errors are caused by our recent shifting to inv messages https://github.com/darkcoin/darkcoin/blob/a119b3008caafc49d1885b280283769570284f52/src/main.cpp#L3882-L3890

This place looks like a good start to fix it https://github.com/UdjinM6/p2pool-drk/blob/master/p2pool/darkcoin/p2p.py#L66-L71

2015-04-05 23:35:38.856114 RECV inv 0108000000a645f9a520167f12389efe58825bee9c6e04580f1515547d44f135d3056ff527
2015-04-05 23:35:38.856539 > Error handling message: (see RECV line)
2015-04-05 23:35:38.856575 > Traceback (most recent call last):
2015-04-05 23:35:38.856596 >   File "/usr/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 214, in doRead
2015-04-05 23:35:38.856614 >     return self._dataReceived(data)
2015-04-05 23:35:38.856632 >   File "/usr/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 220, in _dataReceived
2015-04-05 23:35:38.856650 >     rval = self.protocol.dataReceived(data)
2015-04-05 23:35:38.856667 >   File "/home/darkcoin/p2pool-drk/p2pool/util/p2protocol.py", line 27, in dataReceived
2015-04-05 23:35:38.856684 >     self.dataReceived2(data)
2015-04-05 23:35:38.856700 >   File "/home/darkcoin/p2pool-drk/p2pool/util/datachunker.py", line 40, in _DataChunker
2015-04-05 23:35:38.856717 >     wants = receiver.send(buf.get(wants))
2015-04-05 23:35:38.856733 > --- <exception caught here> ---
2015-04-05 23:35:38.856750 >   File "/home/darkcoin/p2pool-drk/p2pool/util/p2protocol.py", line 57, in dataReceiver
2015-04-05 23:35:38.856766 >     self.packetReceived(command, type_.unpack(payload, self.ignore_trailing_payload))
2015-04-05 23:35:38.856783 >   File "/home/darkcoin/p2pool-drk/p2pool/util/pack.py", line 63, in unpack
2015-04-05 23:35:38.856800 >     obj = self._unpack(data, ignore_trailing)
2015-04-05 23:35:38.856817 >   File "/home/darkcoin/p2pool-drk/p2pool/util/pack.py", line 42, in _unpack
2015-04-05 23:35:38.856834 >     obj, (data2, pos) = self.read((data, 0))
2015-04-05 23:35:38.856850 >   File "/home/darkcoin/p2pool-drk/p2pool/util/pack.py", line 295, in read
2015-04-05 23:35:38.856866 >     item[key], file = type_.read(file)
2015-04-05 23:35:38.856882 >   File "/home/darkcoin/p2pool-drk/p2pool/util/pack.py", line 171, in read
2015-04-05 23:35:38.856898 >     res[i], file = self.type.read(file)
2015-04-05 23:35:38.856914 >   File "/home/darkcoin/p2pool-drk/p2pool/util/pack.py", line 295, in read
2015-04-05 23:35:38.856930 >     item[key], file = type_.read(file)
2015-04-05 23:35:38.856946 >   File "/home/darkcoin/p2pool-drk/p2pool/util/pack.py", line 151, in read
2015-04-05 23:35:38.856963 >     raise ValueError('enum data (%r) not in pack_to_unpack (%r)' % (data, self.pack_to_unpack))
2015-04-05 23:35:38.856979 > exceptions.ValueError: enum data (8) not in pack_to_unpack ({1: 'tx', 2: 'block'})
poiuty commented 9 years ago

So, we have 7 case. https://github.com/darkcoin/darkcoin/blob/master/src/main.cpp

bool static AlreadyHave(const CInv& inv)
{
    switch (inv.type)
    {
    case MSG_TX:
        {
            bool txInMap = false;
            txInMap = mempool.exists(inv.hash);
            return txInMap || mapOrphanTransactions.count(inv.hash) ||
                pcoinsTip->HaveCoins(inv.hash);
        }
    case MSG_BLOCK:
        return mapBlockIndex.count(inv.hash) ||
               mapOrphanBlocks.count(inv.hash);
    case MSG_TXLOCK_REQUEST:
        return mapTxLockReq.count(inv.hash) ||
               mapTxLockReqRejected.count(inv.hash);
    case MSG_TXLOCK_VOTE:
        return mapTxLockVote.count(inv.hash);
    case MSG_SPORK:
        return mapSporks.count(inv.hash);
    case MSG_MASTERNODE_WINNER:
        return mapSeenMasternodeVotes.count(inv.hash);
    case MSG_MASTERNODE_SCANNING_ERROR:
        return mapMasternodeScanningErrors.count(inv.hash);
    }
    // Don't know what it is, just say we already got one
    return true;
}

Try add it => and we get same error.

('type', pack.EnumType(pack.IntType(32), {1: 'tx', 2: 'block', 3: 'txlock_request', 4: 'txlock_vote', 5: 'spork', 6: 'masternode_winner', 7: 'masternode_scanning_error')),

But => exceptions.ValueError: enum data (8) => so what is 8 type? Try add

('type', pack.EnumType(pack.IntType(32), {1: 'tx', 2: 'block', 3: 'txlock_request', 4: 'txlock_vote', 5: 'spork', 6: 'masternode_winner', 7: 'masternode_scanning_error', 8: 'test')),

And get

Unknown inv type {'type': 'test', 'hash': 85018028629704193983546970934772094848258373244713604991801059976327843196613L}`

What is the correct name for the type 8?

poiuty commented 9 years ago

possible fix in /p2pool/bitcoin/p2p.py

    message_inv = pack.ComposedType([
        ('invs', pack.ListType(pack.ComposedType([
            ('type', pack.EnumType(pack.IntType(32), {1: 'tx', 2: 'block', 3: 'txlock_request', 4: 'txlock_vote', 5: 'spork', 6: 'masternode_winner', 7: 'masternode_scanning_error', 8: 'unknown'})),
            ('hash', pack.IntType(256)),
        ]))),
    ])
    def handle_inv(self, invs):
        for inv in invs:
            if inv['type'] == 'tx':
                self.send_getdata(requests=[inv])
            elif inv['type'] == 'block':
                self.factory.new_block.happened(inv['hash'])
#            else:
#                print 'Unknown inv type', inv
jakehaas commented 9 years ago

I believe this is also fixed in pull request #10

poiuty commented 9 years ago

Yes.