Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump p2pd version #598

Merged
merged 12 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
31 changes: 4 additions & 27 deletions hivemind/p2p/p2p_daemon_bindings/datastructures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand All @@ -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)


Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
Expand Down
2 changes: 1 addition & 1 deletion tests/test_p2p_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")],
],
)
Expand Down
Loading