• Julien Muchembled's avatar
    storage: fix replication of creation undone · c3343279
    Julien Muchembled authored
    For records that undo object creation, None values are used at the backend
    level whereas the protocol is not designed to serialize None for any field.
    
    Therefore, a dance done in many places around packet serialization, using the
    specific 0/ZERO_HASH/'' triplet to represent a deleted oid. For replication,
    it was missing at the sender side, leading to the following crash:
    
      Traceback (most recent call last):
        File "neo/storage/app.py", line 147, in run
          self._run()
        File "neo/storage/app.py", line 178, in _run
          self.doOperation()
        File "neo/storage/app.py", line 257, in doOperation
          next(task_queue[-1]) or task_queue.rotate()
        File "neo/storage/handlers/storage.py", line 271, in push
          conn.send(Packets.AddObject(oid, *object), msg_id)
        File "neo/lib/protocol.py", line 234, in __init__
          self._fmt.encode(buf.write, args)
        File "neo/lib/protocol.py", line 345, in encode
          return self._trace(self._encode, writer, items)
        File "neo/lib/protocol.py", line 334, in _trace
          return method(*args)
        File "neo/lib/protocol.py", line 367, in _encode
          item.encode(writer, value)
        File "neo/lib/protocol.py", line 345, in encode
          return self._trace(self._encode, writer, items)
        File "neo/lib/protocol.py", line 342, in _trace
          raise ParseError(self, trace)
      ParseError: at add_object/checksum:
        File "neo/lib/protocol.py", line 553, in _encode
          assert len(checksum) == 20, (len(checksum), checksum)
      TypeError: object of type 'NoneType' has no len()
    c3343279
testReplication.py 36.3 KB