lightnion
lightnion copied to clipboard
Lightnion requires python 3.6 or later
We need dict
to keep insertion order due to implementation details in lightnion/cell
.
For example using python 3.5
we are randomly unable to validate versions cells during negotiation, failing with traces like:
Traceback (most recent call last):
File "examples/link.py", line 13, in <module>
link = lnn.link.initiate(sys_argv.addr, sys_argv.port)
File "/vagrant/lightnion/link.py", line 203, in initiate
version = negotiate_version(peer, versions, as_initiator=True)
File "/vagrant/lightnion/link.py", line 132, in negotiate_version
lnn.cell.versions.send(peer, lnn.cell.versions.pack(versions))
File "/vagrant/lightnion/cell/versions.py", line 35, in pack
length=len(versions))
File "/vagrant/lightnion/cell/view.py", line 559, in set
self.finalize(truncate=True)
File "/vagrant/lightnion/cell/view.py", line 566, in finalize
self._view, self.raw))
RuntimeError: Invalid payload for <lightnion.cell.view.fields object at 0x7f46a55b84e0> view: b'\x00\x04\x07\x00'
…or…
Traceback (most recent call last):
File "examples/link.py", line 13, in <module>
link = lnn.link.initiate(sys_argv.addr, sys_argv.port)
File "/vagrant/lightnion/link.py", line 203, in initiate
version = negotiate_version(peer, versions, as_initiator=True)
File "/vagrant/lightnion/link.py", line 132, in negotiate_version
lnn.cell.versions.send(peer, lnn.cell.versions.pack(versions))
File "/vagrant/lightnion/cell/versions.py", line 35, in pack
length=len(versions))
File "/vagrant/lightnion/cell/view.py", line 559, in set
self.finalize(truncate=True)
File "/vagrant/lightnion/cell/view.py", line 566, in finalize
self._view, self.raw))
RuntimeError: Invalid payload for <lightnion.cell.view.fields object at 0x7f7ece53f518> view: b'\x00\x04\x07'
…or…
Traceback (most recent call last):
File "examples/link.py", line 13, in <module>
link = lnn.link.initiate(sys_argv.addr, sys_argv.port)
File "/vagrant/lightnion/link.py", line 203, in initiate
version = negotiate_version(peer, versions, as_initiator=True)
File "/vagrant/lightnion/link.py", line 132, in negotiate_version
lnn.cell.versions.send(peer, lnn.cell.versions.pack(versions))
File "/vagrant/lightnion/cell/versions.py", line 35, in pack
length=len(versions))
File "/vagrant/lightnion/cell/view.py", line 558, in set
self.write(*kargs, **kwargs)
File "/vagrant/lightnion/cell/view.py", line 555, in write
self.raw = self._view.write(self.raw, value, **kwargs)
File "/vagrant/lightnion/cell/view.py", line 626, in raw
offset = self._parent.offset(self._field)
File "/vagrant/lightnion/cell/view.py", line 547, in offset
return self._view.offset(self.raw, field)
File "/vagrant/lightnion/cell/view.py", line 303, in offset
return super().offset(payload, field=field)
File "/vagrant/lightnion/cell/view.py", line 191, in offset
width = view.width(payload)
File "/vagrant/lightnion/cell/view.py", line 406, in width
offset = self.offset(payload, self.quantity - 1)
File "/vagrant/lightnion/cell/view.py", line 391, in quantity
return self.length.cache()
File "/vagrant/lightnion/cell/common.py", line 5, in cache
return super().cache() // 2
File "/vagrant/lightnion/cell/view.py", line 703, in cache
+ 'Have you called .value() of parent view yet?')
RuntimeError: Bounded value unknown at runtime: Have you called .value() of parent view yet?
…or even sending invalid versions cells to the OR and then silently hanging:
send b'\x00\x04\x00\x00\x07\x00\x04\x00\x05'
^CTraceback (most recent call last):
File "examples/link.py", line 13, in <module>
link = lnn.link.initiate(sys_argv.addr, sys_argv.port)
File "/vagrant/lightnion/link.py", line 203, in initiate
version = negotiate_version(peer, versions, as_initiator=True)
File "/vagrant/lightnion/link.py", line 134, in negotiate_version
vercell = lnn.cell.versions.recv(peer)
File "/vagrant/lightnion/cell/versions.py", line 41, in recv
answer = peer.recv(_cell.header_legacy_view.width())
File "/usr/lib/python3.5/ssl.py", line 922, in recv
return self.read(buflen)
File "/usr/lib/python3.5/ssl.py", line 799, in read
return self._sslobj.read(len, buffer)
File "/usr/lib/python3.5/ssl.py", line 585, in read
v = self._sslobj.read(len)
KeyboardInterrupt
Having ordered dictionaries in python is only guaranteed since python 3.7 and thus makes us rely on a pretty recent guarantee of the python language.
We still have a lot of python 3.4
and python 3.5
out there where lightnion breaks badly, either making the python 3.6+
requirement explicit or supporting python3.4+
can be a good thing.
Started a rewrite of cell/view.py
with proper semantics, testing, coverage and support for python3.4
and later.