diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 6fcbb806c..feaeb0142 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -47,7 +47,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: '1.18.8' + go-version: '1.20.11' check-latest: true - name: Set up Python uses: actions/setup-python@v3 diff --git a/.readthedocs.yml b/.readthedocs.yml index da3f55db0..a65b37e6f 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -4,9 +4,13 @@ sphinx: fail_on_warning: true python: - version: 3.7 install: - requirements: requirements.txt - requirements: requirements-docs.txt - method: pip path: . + +build: + os: ubuntu-22.04 + tools: + python: "3.7" diff --git a/hivemind/p2p/p2p_daemon_bindings/datastructures.py b/hivemind/p2p/p2p_daemon_bindings/datastructures.py index 7fdf0e7c0..920aa920b 100644 --- a/hivemind/p2p/p2p_daemon_bindings/datastructures.py +++ b/hivemind/p2p/p2p_daemon_bindings/datastructures.py @@ -14,28 +14,6 @@ from hivemind.proto import crypto_pb2, p2pd_pb2 -# NOTE: On inlining... -# See: https://github.com/libp2p/specs/issues/138 -# NOTE: enabling to be interoperable w/ the Go implementation -ENABLE_INLINING = True -MAX_INLINE_KEY_LENGTH = 42 - -IDENTITY_MULTIHASH_CODE = 0x00 - -if ENABLE_INLINING: - - class IdentityHash: - def __init__(self) -> None: - self._digest = bytearray() - - def update(self, input: bytes) -> None: - self._digest += input - - def digest(self) -> bytes: - return self._digest - - multihash.FuncReg.register(IDENTITY_MULTIHASH_CODE, "identity", hash_new=IdentityHash) - class PeerID: def __init__(self, peer_id_bytes: bytes) -> None: @@ -96,7 +74,6 @@ def from_identity(cls, data: bytes) -> "PeerID": [1] https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md#peer-ids """ - key_data = crypto_pb2.PrivateKey.FromString(data).data private_key = serialization.load_der_private_key(key_data, password=None) @@ -109,10 +86,10 @@ def from_identity(cls, data: bytes) -> "PeerID": data=encoded_public_key, ).SerializeToString() - algo = multihash.Func.sha2_256 - if ENABLE_INLINING and len(encoded_public_key) <= MAX_INLINE_KEY_LENGTH: - algo = IDENTITY_MULTIHASH_CODE - encoded_digest = multihash.digest(encoded_public_key, algo).encode() + encoded_digest = multihash.encode( + hashlib.sha256(encoded_public_key).digest(), + multihash.coerce_code("sha2-256"), + ) return cls(encoded_digest) diff --git a/requirements.txt b/requirements.txt index 74926e90b..df60317d8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,8 +9,8 @@ uvloop>=0.14.0 grpcio-tools>=1.33.2 protobuf>=3.12.2 configargparse>=1.2.3 -multiaddr>=0.0.9 -pymultihash>=0.8.2 +py-multihash>=0.2.3 +multiaddr @ git+https://github.com/multiformats/py-multiaddr.git@e01dbd38f2c0464c0f78b556691d655265018cce cryptography>=3.4.6 pydantic>=1.8.1,<2.0 packaging>=20.9 diff --git a/setup.py b/setup.py index 65bb93fac..8f0dcedbe 100644 --- a/setup.py +++ b/setup.py @@ -14,17 +14,17 @@ from setuptools.command.build_py import build_py from setuptools.command.develop import develop -P2PD_VERSION = "v0.3.18" +P2PD_VERSION = "v0.5.0.hivemind1" P2PD_SOURCE_URL = f"https://github.com/learning-at-home/go-libp2p-daemon/archive/refs/tags/{P2PD_VERSION}.tar.gz" P2PD_BINARY_URL = f"https://github.com/learning-at-home/go-libp2p-daemon/releases/download/{P2PD_VERSION}/" # The value is sha256 of the binary from the release page P2P_BINARY_HASH = { - "p2pd-darwin-amd64": "a9e5fee6bdcbfb5cc7f1a9b19e3fa4c91ceb18108b20472bf7affa62c590a964", - "p2pd-darwin-arm64": "5868f2000f4d0746c5349f3480cb5450f66d4391570b420a8f888afc9e9152af", - "p2pd-linux-amd64": "a9d456006e915d3cbbc8e5e9902d5b1a3120235f317e113137d6b631e2c810ac", - "p2pd-linux-arm64": "b03c02e6afa47f158183f6267eecf4adb0e17120d534402c99dc33f3a2915cb1", + "p2pd-darwin-amd64": "fe00f9d79e8e4e4c007144d19da10b706c84187b3fb84de170f4664c91ecda80", + "p2pd-darwin-arm64": "0404981a9c2b7cab5425ead2633d006c61c2c7ec85ac564ef69413ed470e65bd", + "p2pd-linux-amd64": "42f8f48e62583b97cdba3c31439c08029fb2b9fc506b5bdd82c46b7cc1d279d8", + "p2pd-linux-arm64": "046f18480c785a84bdf139d7486086d379397ca106cb2f0191598da32f81447a", } here = os.path.abspath(os.path.dirname(__file__)) diff --git a/tests/test_p2p_daemon.py b/tests/test_p2p_daemon.py index e07795d0f..55ff36af5 100644 --- a/tests/test_p2p_daemon.py +++ b/tests/test_p2p_daemon.py @@ -103,7 +103,7 @@ async def test_check_if_identity_free(): "host_maddrs", [ [Multiaddr("/ip4/127.0.0.1/tcp/0")], - [Multiaddr("/ip4/127.0.0.1/udp/0/quic")], + [Multiaddr("/ip4/127.0.0.1/udp/0/quic-v1")], [Multiaddr("/ip4/127.0.0.1/tcp/0"), Multiaddr("/ip4/127.0.0.1/udp/0/quic")], ], )