eudemonia-research / spore

Spore is a simple peer-to-peer library for Python.
6 stars 5 forks source link

spore/encodium issue occasionally triggered by cryptonet #11

Open XertroV opened 10 years ago

XertroV commented 10 years ago

This is me starting the program

(dev)xertrov@X-LittleLap:~/src/cryptonet$ python3 examples/grachten.py -addnode 127.0.0.1:32555 -port 32556
set_handlers
chain: new head 0, hash: 00db713a2a561c76caaca9974d87b3b0880e748447ff078dd82e03a94b52f29c
added block 0, hash: 00db713a2a561c76caaca9974d87b3b0880e748447ff078dd82e03a94b52f29c
chain: restarting miner
on_connect_handler
intro_handler
MSG intro : 340763e4997edfc270cd35b1d86249e55f06fa9dcb634d2cf62395a774a5479a
introhand 86095013629261368070412738918955668817178143916441468186807699119688994
on_connect_handler
on_connect_handler

Everything up till here is normal Then:

Exception in callback <bound method _SelectorSocketTransport._read_ready of <asyncio.selector_events._SelectorSocketTransport object at 0x7fedeff18f60>>()
handle: Handle(<bound method _SelectorSocketTransport._read_ready of <asyncio.selector_events._SelectorSocketTransport object at 0x7fedeff18f60>>, ())<cancelled>
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/events.py", line 39, in _run
    self._callback(*self._args)
  File "/usr/lib/python3.4/asyncio/selector_events.py", line 466, in _read_ready
    self._protocol.data_received(data)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/spore-0.9.4-py3.4.egg/spore/__init__.py", line 40, in data_received
    message = Message.make(bytes(self._buffer[4:]))
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 196, in make
    return cls().make(*args, **kwargs)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 105, in make
    return inner_self.deserialize(_data)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 192, in deserialize
    return self.make(**kwargs)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 106, in make
    ret = self.type(*args, **kwargs)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 52, in __init__
    setattr(inner_self, key, value)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 86, in __setattr__
    field.check_optional(value)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 130, in check_optional
    raise ValidationError("cannot be None")
encodium.ValidationError: method cannot be None
Exception in callback <bound method _SelectorSocketTransport._read_ready of <asyncio.selector_events._SelectorSocketTransport object at 0x7fedeff0beb8>>()
handle: Handle(<bound method _SelectorSocketTransport._read_ready of <asyncio.selector_events._SelectorSocketTransport object at 0x7fedeff0beb8>>, ())
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/events.py", line 39, in _run
    self._callback(*self._args)
  File "/usr/lib/python3.4/asyncio/selector_events.py", line 466, in _read_ready
    self._protocol.data_received(data)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/spore-0.9.4-py3.4.egg/spore/__init__.py", line 40, in data_received
    message = Message.make(bytes(self._buffer[4:]))
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 196, in make
    return cls().make(*args, **kwargs)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 105, in make
    return inner_self.deserialize(_data)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 192, in deserialize
    return self.make(**kwargs)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 106, in make
    ret = self.type(*args, **kwargs)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 52, in __init__
    setattr(inner_self, key, value)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 86, in __setattr__
    field.check_optional(value)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 130, in check_optional
    raise ValidationError("cannot be None")
encodium.ValidationError: method cannot be None

I'm unsure what this even means.

XertroV commented 10 years ago

Okay, seems like method is meant to be a String().

More samples with different errors:

set_handlers
chain: new head 0, hash: 00db713a2a561c76caaca9974d87b3b0880e748447ff078dd82e03a94b52f29c
added block 0, hash: 00db713a2a561c76caaca9974d87b3b0880e748447ff078dd82e03a94b52f29c
chain: restarting miner
on_connect_handler
intro_handler
MSG intro : dda3506f321f94de9c32bba22629b8536fe0da0445a9cc3ccef12490031ed4d3
introhand 47227348492293870769123612815547319592405828162236774143894222786167557872
on_connect_handler
on_connect_handler
Exception in callback <bound method _SelectorSocketTransport._read_ready of <asyncio.selector_events._SelectorSocketTransport object at 0x7fc30c7a8ba8>>()
handle: Handle(<bound method _SelectorSocketTransport._read_ready of <asyncio.selector_events._SelectorSocketTransport object at 0x7fc30c7a8ba8>>, ())
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/events.py", line 39, in _run
    self._callback(*self._args)
  File "/usr/lib/python3.4/asyncio/selector_events.py", line 466, in _read_ready
    self._protocol.data_received(data)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/spore-0.9.4-py3.4.egg/spore/__init__.py", line 40, in data_received
    message = Message.make(bytes(self._buffer[4:]))
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 196, in make
    return cls().make(*args, **kwargs)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 105, in make
    return inner_self.deserialize(_data)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 192, in deserialize
    return self.make(**kwargs)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 106, in make
    ret = self.type(*args, **kwargs)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 52, in __init__
    setattr(inner_self, key, value)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 86, in __setattr__
    field.check_optional(value)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 130, in check_optional
    raise ValidationError("cannot be None")
encodium.ValidationError: payload cannot be None

then immediately:

intro_handler
MSG intro : 8aa7b290816fa90e1ade04684d79c01beea38795faa3e02339e602262d40395d
introhand 387720972659100534618445536016010173398493042742960330187510419309462745756
Exception in callback <bound method _SelectorSocketTransport._read_ready of <asyncio.selector_events._SelectorSocketTransport object at 0x7fc30c7bd3c8>>()
handle: Handle(<bound method _SelectorSocketTransport._read_ready of <asyncio.selector_events._SelectorSocketTransport object at 0x7fc30c7bd3c8>>, ())
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/events.py", line 39, in _run
    self._callback(*self._args)
  File "/usr/lib/python3.4/asyncio/selector_events.py", line 466, in _read_ready
    self._protocol.data_received(data)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/spore-0.9.4-py3.4.egg/spore/__init__.py", line 40, in data_received
    message = Message.make(bytes(self._buffer[4:]))
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 196, in make
    return cls().make(*args, **kwargs)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 105, in make
    return inner_self.deserialize(_data)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 192, in deserialize
    return self.make(**kwargs)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 106, in make
    ret = self.type(*args, **kwargs)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 52, in __init__
    setattr(inner_self, key, value)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 86, in __setattr__
    field.check_optional(value)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 130, in check_optional
    raise ValidationError("cannot be None")
encodium.ValidationError: method cannot be None
XertroV commented 10 years ago

I can only trigger this sometimes; it's not consistent.

XertroV commented 10 years ago

This is an example of a message that triggers it:

spore.data_received, buffer: bytearray(b'\x00\x00\x00\x14\x00\x00\x006\x01\x05\x01info\x0c\x01\x01\x01\x00\x04N\xb1.')
failed now

The exact exception produced between the above two lines:

Exception in callback <bound method _SelectorSocketTransport._read_ready of <asyncio.selector_events._SelectorSocketTransport object at 0x7fae2f8d69e8>>()
handle: Handle(<bound method _SelectorSocketTransport._read_ready of <asyncio.selector_events._SelectorSocketTransport object at 0x7fae2f8d69e8>>, ())
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/events.py", line 39, in _run
    self._callback(*self._args)
  File "/usr/lib/python3.4/asyncio/selector_events.py", line 466, in _read_ready
    self._protocol.data_received(data)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/spore-0.9.4-py3.4.egg/spore/__init__.py", line 42, in data_received
    message = Message.make(bytes(self._buffer[4:]))
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 196, in make
    return cls().make(*args, **kwargs)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 105, in make
    return inner_self.deserialize(_data)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 192, in deserialize
    return self.make(**kwargs)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 106, in make
    ret = self.type(*args, **kwargs)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 52, in __init__
    setattr(inner_self, key, value)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 86, in __setattr__
    field.check_optional(value)
  File "/home/xertrov/.virtualenvs/dev/lib/python3.4/site-packages/encodium-0.0.5-py3.4.egg/encodium/__init__.py", line 130, in check_optional
    raise ValidationError("cannot be None")
encodium.ValidationError: method cannot be None
ktofu commented 10 years ago

Can't seem to reproduce it at the moment.

It means the value isn't optional, and the serialised version is set to None.

For now try using the github version of encodium.