draeder / decentralize

Connect decentralized technology stacks together
MIT License
2 stars 1 forks source link

gun on hyperswarm? #1

Open benzmuircroft opened 7 months ago

benzmuircroft commented 7 months ago

Please make an example

draeder commented 7 months ago

@benzmuircroft It looks like the most recent commit isn't working correctly anymore for any of the P2P stacks I built the example adapter for. The core library should be solid (index.js), but the example adapter needs some work.

draeder commented 7 months ago

Okay, I see the issue for hyperswarm-web and the others. 1.) I forgot to npm install (LOL), 2.) the signal peers for hyperswarm-web were all offline. I turned mine back on. I can add another stack for regular hyperswarm if you want.

benzmuircroft commented 7 months ago

not hyperswarm-web, I meant normal hyperswarm https://github.com/holepunchto/hyperswarm

draeder commented 7 months ago

There are some issues with the latest commit that I'm working through. I might re-imagine the API to make it easier for developers to create adapters. Stay tuned . . . Thanks for this issue!

benzmuircroft commented 7 months ago

much love! You seem like a cool dude to watch!

draeder commented 7 months ago

As I'm working through this, I'm curious about your use-case... I've been playing with p2p for a decade and have had a million ideas with hundreds of WIP repos...

benzmuircroft commented 7 months ago

well im building something called hyperdown

It's intended to solve the problem of a user going offline and the server user wan'ts to send you events but, there is no central server for you to hook back up to later and retrieve those messages later!

It's just a gist at the moment and I have received feedback that 1-3 things are currently wrong but I have been given some guidance to make it right that I'm going to study all of tomorrow.

You can have a look and if you have any questions; just ask ...

Here it is:

Hyperdown

https://gist.github.com/benzmuircroft/2dcbbf3aa8b136d87606facc6377140c

draeder commented 7 months ago

Gun is certainly the right P2P stack for this idea.. Decentralized CRDT. What's great about Gun is that it's decentralized, offline first storage and retrieval. What's not great is that storage isn't free, so it depends on volunteers...

You may want to look into automerge, too, from a hyperswarm perspective.

You might be interested in a project a friend of mine is working on MiniGun. I wrote a library called Easypeers-signal which he rewrote to better work with MiniGun's concepts. My initial library Easypeers is a webtorrent extension with partial mesh connectivity and gossip routing and is topic-based; works in the browser 100%, and in node.js using puppeteer ...

It's always fun to revisit old ideas I forgot about like this one..

benzmuircroft commented 7 months ago

volunteers in the hyperdown hyperswarm volunteer themselves!

benzmuircroft commented 7 months ago

You may want to look into automerge, too, from a hyperswarm perspective.

I'm looking at merge OR gun to achieve this

I want the discovery to use holepunching because it is fire

benzmuircroft commented 7 months ago

is merge using hyperswarm?

draeder commented 7 months ago

| You may want to look into automerge, too, from a hyperswarm perspective.

I'm looking at merge OR gun to achieve this

I want the discovery to use holepunching because it is fire

The downside of hyperswarm is it only works on node, which means only native OS/server applications. Easypeers works on either, as does Gun. But the tradeoff for both is that they need a signaling/relay server. Gun is tiny. Easypeers isn't because of the webtorrent library. That's why I wrote Easypeeers-signal. But with EPS, now you need a separate signaling server like Gun needs... Ugh. Bootstrapping P2P sucks because of browser limitations.

is merge using hyperswarm?

Automerge is built on hyperswarm, yes

benzmuircroft commented 7 months ago

I' will not do signal servers because I can swarm and replicate hardcoded seed cores

draeder commented 7 months ago

When you peel back the layers of any p2p tech, they all have signaling / bootstrapping servers at their core..

benzmuircroft commented 7 months ago

hyper-DHT

draeder commented 7 months ago

There too ... the DHT can't work unless there are "super-nodes" telling each other and other nodes what's going on

benzmuircroft commented 7 months ago

i can bootstrap and even tell my users to do the same so they all strengthen the network?

benzmuircroft commented 7 months ago

everyone becomes a super-node a shared autobase of super-nodes?

draeder commented 7 months ago

Yes.. that's what Gun is trying to accomplish with Book. Fundamentally, true P2P is a paradox until the engine is started. Keeping it running is self-referencing as long as nodes in the "engine" stay online. Perhaps that's why I chose this problem as my hobby... solving the unsolveable

benzmuircroft commented 7 months ago

why not swarm.join(b4a.alloc(32).fill('super-nodes')) and the supernodes could be a ipfs-nameserver dns that would hold the list and then the object there could be multiwriter and update the list of the online peers that would signal serve on their own DHT mesh?

draeder commented 7 months ago

Fundamentals.... IPFS won't work without signal servers.

You're right, though, if there are enough nodes participating, the system keeps itself running...

benzmuircroft commented 7 months ago

I think there could be something to this

if enough users in 1 app that has a hard coded channel id embeded in the encrypted v8 code, (that) is a multi-user autobase that gets replicated

and then after a thick layer is in place

noone will need to hit the original hyperswarm-dht layer

the'll all be using a distrbuted signal server db instead!

draeder commented 7 months ago

That's kind of what WebTorrent and HyperSwarm are already... Both of us can just write code and we're connected!

It's really just abstraction of the problem, though, and doesn't solve it.

benzmuircroft commented 7 months ago

what if you could give a server like location?

benzmuircroft commented 7 months ago

On the VPS

apt-get update
apt-get install wireguard
umask 077
wg genkey | tee privatekey | wg pubkey > publickey

nano /etc/wireguard/wg0.conf

[Interface]
PrivateKey = <VPS_PRIVATE_KEY>
Address = <VPS_IPV6>/64
ListenPort = 51820
PostUp = ufw route allow in on wg0 out on enp4s0f0
PostUp = iptables -t nat -I POSTROUTING -o enp4s0f0 -j MASQUERADE
PostUp = ip6tables -t nat -I POSTROUTING -o enp4s0f0 -j MASQUERADE
PreDown = ufw route delete allow in on wg0 out on enp4s0f0
PreDown = iptables -t nat -D POSTROUTING -o enp4s0f0 -j MASQUERADE
PreDown = ip6tables -t nat -D POSTROUTING -o enp4s0f0 -j MASQUERADE

[Peer]
PublicKey = <LOCAL_PUBLIC_KEY>
AllowedIPs = <LOCAL_IPV6>/128

nano /etc/sysctl.conf

net.ipv6.conf.all.forwarding=1
sudo sysctl -p
systemctl start wg-quick@wg0

Enable the WireGuard service to start at boot

systemctl enable wg-quick@wg0

On the local machine

apt-get update
apt-get install wireguard
umask 077
wg genkey | tee privatekey | wg pubkey > publickey

nano /etc/wireguard/wg0.conf

[Interface]
PrivateKey = <LOCAL_PRIVATE_KEY>
Address = <LOCAL_IPV6>/64

[Peer]
PublicKey = <VPS_PUBLIC_KEY>
Endpoint = [<VPS_IPV6>]:51820
AllowedIPs = <VPS_IPV6>/128,<VPS_IPV6>/128
DNS = 8.8.8.8
systemctl start wg-quick@wg0

Enable the WireGuard service to start at boot

systemctl enable wg-quick@wg0
draeder commented 7 months ago

I think that native OS p2p is straight forward, but the world we're in is web-based p2p. That's what Gun is trying to handle, and what I care about, too. If the language of the web is javascript, and our only portal to that is https, then we must find a way to make p2p available that way. That's the big challenge..

benzmuircroft commented 7 months ago

generate an ipv6 on the server

ip -6 address add 2504:f1b0:1d01:bf::1 dev $mainInerface
draeder commented 7 months ago

Feel free to hit me up on twitter DM @DanRaeder so to keep this issue concise

draeder commented 7 months ago

Gun chat is pretty responsive too: https://app.gitter.im/#/room/#amark_gun:gitter.im

benzmuircroft commented 7 months ago

I see what you are saying. every method for signalling rely's on tech that we need to be free of! so we need to look into light transport and corn oil as it has the highest yield in quantum dots

draeder commented 7 months ago

When you are in a room of people who have no senses and you shout into the room that you want to connect, but no-one can sense that shout .......

benzmuircroft commented 7 months ago

@DanRaeder

https://twitter.com/benzmuircroft/status/1734733013194313831

amark commented 7 months ago

🥳

draeder commented 7 months ago

I have a theory: Reality is a Mandelbrot set upon another one and upon another one, in infinite sequence, in an infinite set. Therefore, a random walk upon a random walk, and so-on. The P2P paradox I've described herein follows the same problem, paradox, and solution.

benzmuircroft commented 7 months ago

I have a theory: Reality is a Mandelbrot set upon another one and upon another one, in infinite sequence, in an infinite set. Therefore, a random walk upon a random walk, and so-on. The P2P paradox I've described herein follows the same problem, paradox, and solution.

like this?

https://twitter.com/i/status/1734956267435700650

draeder commented 7 months ago

String theory, sure. The first principal of existence is the Word of God: Truth.

draeder commented 7 months ago

Ohm... lol