mirror of
https://github.com/vacp2p/vac.dev-experimental-old.git
synced 2025-02-27 12:30:32 +00:00
656 lines
30 KiB
HTML
656 lines
30 KiB
HTML
|
<!DOCTYPE html>
|
|||
|
<html class="h-full" lang="en-US">
|
|||
|
<head>
|
|||
|
|
|||
|
<title>Vac - From Kademlia to Discv5</title>
|
|||
|
|
|||
|
|
|||
|
<meta charset="utf-8" />
|
|||
|
<meta http-equiv="x-ua-compatible" content="ie=edge" />
|
|||
|
<title>Vac</title>
|
|||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|||
|
|
|||
|
<link
|
|||
|
rel="shortcut icon"
|
|||
|
href="/assets/img/favicon.png"
|
|||
|
type="image/png"
|
|||
|
/>
|
|||
|
|
|||
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|||
|
<link
|
|||
|
href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,400;0,600;0,700;1,400;1,600&display=swap"
|
|||
|
rel="stylesheet"
|
|||
|
/>
|
|||
|
<link rel="stylesheet" href="/assets/css/style.css" />
|
|||
|
</head>
|
|||
|
|
|||
|
<body class="h-full flex flex-col">
|
|||
|
<div
|
|||
|
class="flex-grow container max-w-screen-xl mx-auto px-5 md:px-12 lg:pt-6"
|
|||
|
>
|
|||
|
<header>
|
|||
|
<div class="container max-w-screen-xl sm:border-b">
|
|||
|
<div
|
|||
|
class="
|
|||
|
nav-section
|
|||
|
flex
|
|||
|
justify-between
|
|||
|
items-center
|
|||
|
py-3
|
|||
|
md:py-5
|
|||
|
lg:py-10
|
|||
|
"
|
|||
|
>
|
|||
|
<div class="logo md:pr-8 l:p-0">
|
|||
|
<a href="/"
|
|||
|
><img src="/assets/img/logo.png"
|
|||
|
/></a>
|
|||
|
</div>
|
|||
|
<div class="flex justify-between items-center w-9/12">
|
|||
|
<div class="burger block sm:hidden z-50">
|
|||
|
<button
|
|||
|
class="
|
|||
|
burger__button burger__button--open
|
|||
|
fixed
|
|||
|
top-2
|
|||
|
right-5
|
|||
|
w-12
|
|||
|
h-12
|
|||
|
"
|
|||
|
type="button"
|
|||
|
aria-label="Mobile menu button"
|
|||
|
>
|
|||
|
<img
|
|||
|
class="burger__icon"
|
|||
|
src="/assets/img/burger.svg"
|
|||
|
alt="Open menu button"
|
|||
|
/>
|
|||
|
</button>
|
|||
|
<button
|
|||
|
class="
|
|||
|
burger__button burger__button--close
|
|||
|
hidden
|
|||
|
fixed
|
|||
|
top-2
|
|||
|
right-5
|
|||
|
w-12
|
|||
|
h-12
|
|||
|
"
|
|||
|
type="button"
|
|||
|
aria-label="Close mobile menu button"
|
|||
|
>
|
|||
|
<img
|
|||
|
class="burger__icon burger__icon--close"
|
|||
|
src="/assets/img/close.svg"
|
|||
|
alt="Close menu button"
|
|||
|
/>
|
|||
|
</button>
|
|||
|
</div>
|
|||
|
|
|||
|
<nav class="nav max-w-screen-xm md:max-w-screen-sl container">
|
|||
|
<ul
|
|||
|
class="
|
|||
|
nav__list
|
|||
|
hidden
|
|||
|
sm:flex
|
|||
|
justify-between
|
|||
|
container
|
|||
|
text-xs
|
|||
|
font-semibold
|
|||
|
md:pr-8
|
|||
|
l:p-0
|
|||
|
"
|
|||
|
>
|
|||
|
<li class="hover:opacity-50">
|
|||
|
|
|||
|
<a class="nav__link" href="/#work">Work</a>
|
|||
|
|
|||
|
</li>
|
|||
|
<li class="hover:opacity-50">
|
|||
|
|
|||
|
<a class="nav__link" href="/#about">About</a>
|
|||
|
|
|||
|
</li>
|
|||
|
<li class="hover:opacity-50">
|
|||
|
|
|||
|
<a class="nav__link" href="/#join">Join VAC</a>
|
|||
|
|
|||
|
</li>
|
|||
|
<li class="hover:opacity-50">
|
|||
|
|
|||
|
<a class="nav__link" href="/research-log">Research log</a>
|
|||
|
|
|||
|
</li>
|
|||
|
<li class="hover:opacity-50">
|
|||
|
|
|||
|
<a class="nav__link" href="/media">Media</a>
|
|||
|
|
|||
|
</li>
|
|||
|
<li class="hover:opacity-50">
|
|||
|
|
|||
|
<a href="https://specs.vac.dev" target="_blank" rel="noopener noreferrer"
|
|||
|
>Specs</a
|
|||
|
>
|
|||
|
|
|||
|
</li>
|
|||
|
<li class="hover:opacity-50">
|
|||
|
|
|||
|
<a href="https://forum.vac.dev/" target="_blank" rel="noopener noreferrer"
|
|||
|
>Forum</a
|
|||
|
>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
</ul>
|
|||
|
</nav>
|
|||
|
|
|||
|
<ul class="social items-center hidden md:flex">
|
|||
|
<li class="pr-5">
|
|||
|
<a href="https://twitter.com/vacp2p" target="_blank" rel="noopener noreferrer"
|
|||
|
><svg
|
|||
|
width="25"
|
|||
|
height="21"
|
|||
|
viewBox="0 0 25 21"
|
|||
|
fill="none"
|
|||
|
xmlns="http://www.w3.org/2000/svg"
|
|||
|
class="hover:opacity-50"
|
|||
|
>
|
|||
|
<path
|
|||
|
d="M24.8872 3.04499C23.9872 3.43499 23.0572 3.70498 22.0672 3.82499C23.0872 3.22498 23.8672 2.26499 24.2272 1.09499C23.2672 1.66499 22.2172 2.05499 21.1072 2.29499C20.2072 1.33499 18.9172 0.734985 17.5072 0.734985C14.7772 0.734985 12.5872 2.95499 12.5872 5.65499C12.5872 6.04499 12.6172 6.40498 12.7072 6.76498C8.62721 6.58498 5.02721 4.60498 2.59721 1.63499C0.857207 4.75498 2.80721 7.33499 4.09721 8.20499C3.31721 8.20499 2.53721 7.96499 1.87721 7.60499C1.87721 10.035 3.58721 12.045 5.80721 12.495C5.32721 12.645 4.24721 12.735 3.58721 12.585C4.21721 14.535 6.04721 15.975 8.17721 16.005C6.49721 17.325 4.03721 18.375 0.887207 18.045C3.07721 19.455 5.65721 20.265 8.44721 20.265C17.5072 20.265 22.4272 12.765 22.4272 6.28499C22.4272 6.07499 22.4272 5.86499 22.3972 5.65499C23.4172 4.90499 24.2572 4.03499 24.8872 3.04499Z"
|
|||
|
fill="#151512"
|
|||
|
/>
|
|||
|
</svg>
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
<li class="pr-5">
|
|||
|
<a href="https://github.com/vacp2p" target="_blank" rel="noopener noreferrer"
|
|||
|
><svg
|
|||
|
width="26"
|
|||
|
height="25"
|
|||
|
viewBox="0 0 26 25"
|
|||
|
fill="none"
|
|||
|
xmlns="http://www.w3.org/2000/svg"
|
|||
|
class="hover:opacity-50"
|
|||
|
>
|
|||
|
<path
|
|||
|
d="M12.8857 0.856567C6.26021 0.856567 0.915339 6.20154 0.950043 12.7951C0.9778 18.0687 4.43935 22.5427 9.21766 24.1227C9.81824 24.2327 10.0353 23.864 10.0336 23.5474C10.0321 23.2635 10.0177 22.5129 10.0065 21.5171C6.67274 22.238 5.95552 19.9163 5.95552 19.9163C5.40376 18.5369 4.61433 18.1698 4.61433 18.1698C3.51994 17.4296 4.69151 17.4444 4.69151 17.4444C5.89646 17.5291 6.53549 18.6751 6.53549 18.6751C7.61609 20.4989 9.35182 19.9727 10.0342 19.6665C10.1382 18.8951 10.4459 18.3689 10.7878 18.0702C8.12222 17.7684 5.31483 16.7443 5.29076 12.1708C5.2839 10.8672 5.74629 9.80152 6.50989 8.96619C6.3838 8.66445 5.96641 7.45009 6.61027 5.80766C6.61027 5.80766 7.61658 5.4866 9.9167 7.03094C10.8723 6.76636 11.8976 6.63408 12.9191 6.62962C13.9376 6.63556 14.9658 6.76636 15.9257 7.03242C18.2081 5.48809 19.2163 5.80914 19.2163 5.80914C19.8789 7.45306 19.4743 8.66594 19.3529 8.96767C20.1268 9.80301 20.5959 10.8687 20.6028 12.1723C20.6269 16.7577 17.8272 17.767 15.1558 18.0628C15.5882 18.4314 15.976 19.1597 15.9819 20.273C15.9903 21.8693 15.9821 23.1565 15.9841 23.5474C15.9858 23.867 16.2038 24.2386 16.8122 24.1212C21.5663 22.5397 24.9778 18.0672 24.95 12.7951C24.9153 6.20154 19.5142 0.856567 12.8857 0.856567Z"
|
|||
|
fill="#151512"
|
|||
|
/>
|
|||
|
</svg>
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<a
|
|||
|
href="https://discord.gg/PQFdubGt6d"
|
|||
|
target="_blank"
|
|||
|
rel="noopener noreferrer"
|
|||
|
><svg
|
|||
|
width="25"
|
|||
|
height="21"
|
|||
|
viewBox="0 0 25 21"
|
|||
|
fill="none"
|
|||
|
xmlns="http://www.w3.org/2000/svg"
|
|||
|
class="hover:opacity-50"
|
|||
|
>
|
|||
|
<path
|
|||
|
d="M22.7861 9.04256C21.8482 5.74455 20.7799 4.04048 20.7627 4.00991C20.7017 3.93459 19.189 2.104 15.5271 0.75L15.0353 2.0764C16.7774 2.72057 18.0116 3.50643 18.6899 4.01419C16.6599 3.40408 14.2431 3.03041 12.1008 3.03041C9.95851 3.03041 7.53775 3.40408 5.50128 4.01419C6.18496 3.50648 7.42744 2.72057 9.17631 2.0764L8.69846 0.75C5.02238 2.104 3.49044 3.93459 3.42863 4.00991C3.41108 4.04048 2.32479 5.74455 1.35221 9.04256C0.414855 12.2208 0.0415214 16.7045 0.027872 16.8843C0.109225 17.0131 1.97891 20.25 7.12077 20.25L8.43406 18.3536C6.97595 17.964 5.58693 17.3357 4.31689 16.4832L5.10228 15.3069C7.15122 16.6822 9.54509 17.4092 12.0251 17.4092C14.5051 17.4092 16.9067 16.6822 18.9701 15.3069L19.7431 16.4832C18.4641 17.3357 17.0684 17.964 15.6062 18.3536L16.8995 20.25C22.0414 20.25 23.9452 17.0131 24.0279 16.8843C24.0161 16.7045 23.69 12.2208 22.7861 9.04256ZM8.79853 12.7392H7.39228L7.40468 10.3841H8.81093L8.79853 12.7392ZM16.7071 12.7392H15.3008L15.3132 10.3841H16.7195L16.7071 12.7392Z"
|
|||
|
fill="#151512"
|
|||
|
/>
|
|||
|
</svg>
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
|
|||
|
</ul>
|
|||
|
</div>
|
|||
|
|
|||
|
<div
|
|||
|
class="
|
|||
|
overlay
|
|||
|
container
|
|||
|
max-w-screen-sm
|
|||
|
w-full
|
|||
|
hidden
|
|||
|
sm:hidden
|
|||
|
fixed
|
|||
|
top-0
|
|||
|
right-0
|
|||
|
h-screen
|
|||
|
bg-black bg-opacity-40
|
|||
|
z-30
|
|||
|
"
|
|||
|
>
|
|||
|
<nav
|
|||
|
class="
|
|||
|
nav-mobile
|
|||
|
hidden
|
|||
|
fixed
|
|||
|
top-0
|
|||
|
right-0
|
|||
|
flex flex-col
|
|||
|
justify-between
|
|||
|
items-center
|
|||
|
pt-14
|
|||
|
px-12
|
|||
|
pb-5
|
|||
|
bg-white
|
|||
|
w-9/12
|
|||
|
h-3/4
|
|||
|
z-40
|
|||
|
"
|
|||
|
>
|
|||
|
<ul
|
|||
|
class="
|
|||
|
nav__list
|
|||
|
flex flex-col flex-1
|
|||
|
justify-between
|
|||
|
items-center
|
|||
|
container
|
|||
|
box-content
|
|||
|
w-32
|
|||
|
h-auto
|
|||
|
max-h-nav
|
|||
|
text-xs
|
|||
|
font-normal
|
|||
|
"
|
|||
|
>
|
|||
|
<li class="hover:opacity-50">
|
|||
|
|
|||
|
<a class="nav__link" href="/#work">Work</a>
|
|||
|
|
|||
|
</li>
|
|||
|
<li class="hover:opacity-50">
|
|||
|
|
|||
|
<a class="nav__link" href="/#about">About</a>
|
|||
|
|
|||
|
</li>
|
|||
|
<li class="hover:opacity-50">
|
|||
|
|
|||
|
<a class="nav__link" href="/#join">Join VAC</a>
|
|||
|
|
|||
|
</li>
|
|||
|
<li class="hover:opacity-50">
|
|||
|
|
|||
|
<a class="nav__link" href="/research-log">Research log</a>
|
|||
|
|
|||
|
</li>
|
|||
|
<li class="hover:opacity-50">
|
|||
|
|
|||
|
<a class="nav__link" href="/media">Media</a>
|
|||
|
|
|||
|
</li>
|
|||
|
<li class="hover:opacity-50">
|
|||
|
|
|||
|
<a href="https://specs.vac.dev" target="_blank" rel="noopener noreferrer"
|
|||
|
>Specs</a
|
|||
|
>
|
|||
|
|
|||
|
</li>
|
|||
|
<li class="hover:opacity-50">
|
|||
|
|
|||
|
<a href="https://forum.vac.dev/" target="_blank" rel="noopener noreferrer"
|
|||
|
>Forum</a
|
|||
|
>
|
|||
|
|
|||
|
</li>
|
|||
|
|
|||
|
</ul>
|
|||
|
<ul class="social items-center flex mt-8">
|
|||
|
<li class="pr-5">
|
|||
|
<a href="https://twitter.com/vacp2p" target="_blank" rel="noopener noreferrer"
|
|||
|
><svg
|
|||
|
width="25"
|
|||
|
height="21"
|
|||
|
viewBox="0 0 25 21"
|
|||
|
fill="none"
|
|||
|
xmlns="http://www.w3.org/2000/svg"
|
|||
|
class="hover:opacity-50"
|
|||
|
>
|
|||
|
<path
|
|||
|
d="M24.8872 3.04499C23.9872 3.43499 23.0572 3.70498 22.0672 3.82499C23.0872 3.22498 23.8672 2.26499 24.2272 1.09499C23.2672 1.66499 22.2172 2.05499 21.1072 2.29499C20.2072 1.33499 18.9172 0.734985 17.5072 0.734985C14.7772 0.734985 12.5872 2.95499 12.5872 5.65499C12.5872 6.04499 12.6172 6.40498 12.7072 6.76498C8.62721 6.58498 5.02721 4.60498 2.59721 1.63499C0.857207 4.75498 2.80721 7.33499 4.09721 8.20499C3.31721 8.20499 2.53721 7.96499 1.87721 7.60499C1.87721 10.035 3.58721 12.045 5.80721 12.495C5.32721 12.645 4.24721 12.735 3.58721 12.585C4.21721 14.535 6.04721 15.975 8.17721 16.005C6.49721 17.325 4.03721 18.375 0.887207 18.045C3.07721 19.455 5.65721 20.265 8.44721 20.265C17.5072 20.265 22.4272 12.765 22.4272 6.28499C22.4272 6.07499 22.4272 5.86499 22.3972 5.65499C23.4172 4.90499 24.2572 4.03499 24.8872 3.04499Z"
|
|||
|
fill="#151512"
|
|||
|
/>
|
|||
|
</svg>
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
<li class="pr-5">
|
|||
|
<a href="https://github.com/vacp2p" target="_blank" rel="noopener noreferrer"
|
|||
|
><svg
|
|||
|
width="26"
|
|||
|
height="25"
|
|||
|
viewBox="0 0 26 25"
|
|||
|
fill="none"
|
|||
|
xmlns="http://www.w3.org/2000/svg"
|
|||
|
class="hover:opacity-50"
|
|||
|
>
|
|||
|
<path
|
|||
|
d="M12.8857 0.856567C6.26021 0.856567 0.915339 6.20154 0.950043 12.7951C0.9778 18.0687 4.43935 22.5427 9.21766 24.1227C9.81824 24.2327 10.0353 23.864 10.0336 23.5474C10.0321 23.2635 10.0177 22.5129 10.0065 21.5171C6.67274 22.238 5.95552 19.9163 5.95552 19.9163C5.40376 18.5369 4.61433 18.1698 4.61433 18.1698C3.51994 17.4296 4.69151 17.4444 4.69151 17.4444C5.89646 17.5291 6.53549 18.6751 6.53549 18.6751C7.61609 20.4989 9.35182 19.9727 10.0342 19.6665C10.1382 18.8951 10.4459 18.3689 10.7878 18.0702C8.12222 17.7684 5.31483 16.7443 5.29076 12.1708C5.2839 10.8672 5.74629 9.80152 6.50989 8.96619C6.3838 8.66445 5.96641 7.45009 6.61027 5.80766C6.61027 5.80766 7.61658 5.4866 9.9167 7.03094C10.8723 6.76636 11.8976 6.63408 12.9191 6.62962C13.9376 6.63556 14.9658 6.76636 15.9257 7.03242C18.2081 5.48809 19.2163 5.80914 19.2163 5.80914C19.8789 7.45306 19.4743 8.66594 19.3529 8.96767C20.1268 9.80301 20.5959 10.8687 20.6028 12.1723C20.6269 16.7577 17.8272 17.767 15.1558 18.0628C15.5882 18.4314 15.976 19.1597 15.9819 20.273C15.9903 21.8693 15.9821 23.1565 15.9841 23.5474C15.9858 23.867 16.2038 24.2386 16.8122 24.1212C21.5663 22.5397 24.9778 18.0672 24.95 12.7951C24.9153 6.20154 19.5142 0.856567 12.8857 0.856567Z"
|
|||
|
fill="#151512"
|
|||
|
/>
|
|||
|
</svg>
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<a
|
|||
|
href="https://discord.gg/PQFdubGt6d"
|
|||
|
target="_blank"
|
|||
|
rel="noopener noreferrer"
|
|||
|
><svg
|
|||
|
width="25"
|
|||
|
height="21"
|
|||
|
viewBox="0 0 25 21"
|
|||
|
fill="none"
|
|||
|
xmlns="http://www.w3.org/2000/svg"
|
|||
|
class="hover:opacity-50"
|
|||
|
>
|
|||
|
<path
|
|||
|
d="M22.7861 9.04256C21.8482 5.74455 20.7799 4.04048 20.7627 4.00991C20.7017 3.93459 19.189 2.104 15.5271 0.75L15.0353 2.0764C16.7774 2.72057 18.0116 3.50643 18.6899 4.01419C16.6599 3.40408 14.2431 3.03041 12.1008 3.03041C9.95851 3.03041 7.53775 3.40408 5.50128 4.01419C6.18496 3.50648 7.42744 2.72057 9.17631 2.0764L8.69846 0.75C5.02238 2.104 3.49044 3.93459 3.42863 4.00991C3.41108 4.04048 2.32479 5.74455 1.35221 9.04256C0.414855 12.2208 0.0415214 16.7045 0.027872 16.8843C0.109225 17.0131 1.97891 20.25 7.12077 20.25L8.43406 18.3536C6.97595 17.964 5.58693 17.3357 4.31689 16.4832L5.10228 15.3069C7.15122 16.6822 9.54509 17.4092 12.0251 17.4092C14.5051 17.4092 16.9067 16.6822 18.9701 15.3069L19.7431 16.4832C18.4641 17.3357 17.0684 17.964 15.6062 18.3536L16.8995 20.25C22.0414 20.25 23.9452 17.0131 24.0279 16.8843C24.0161 16.7045 23.69 12.2208 22.7861 9.04256ZM8.79853 12.7392H7.39228L7.40468 10.3841H8.81093L8.79853 12.7392ZM16.7071 12.7392H15.3008L15.3132 10.3841H16.7195L16.7071 12.7392Z"
|
|||
|
fill="#151512"
|
|||
|
/>
|
|||
|
</svg>
|
|||
|
</a>
|
|||
|
</li>
|
|||
|
|
|||
|
</ul>
|
|||
|
</nav>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</header>
|
|||
|
|
|||
|
|
|||
|
<main class="bg-white text-black flex flex-col"><section
|
|||
|
class="
|
|||
|
container
|
|||
|
max-w-screen-xl
|
|||
|
flex flex-col
|
|||
|
sm:flex-row
|
|||
|
pt-10
|
|||
|
pb-0
|
|||
|
md:pb-10
|
|||
|
lg:pb-0
|
|||
|
"
|
|||
|
>
|
|||
|
<div
|
|||
|
class="
|
|||
|
heading-block
|
|||
|
w-full
|
|||
|
sm:w-2/12
|
|||
|
lg:w-3/12
|
|||
|
flex
|
|||
|
lg:justify-center
|
|||
|
items-start
|
|||
|
pb-3
|
|||
|
sm:pb-0
|
|||
|
"
|
|||
|
>
|
|||
|
<a class="link link--back" href="/research-log/">Back</a>
|
|||
|
</div>
|
|||
|
<div
|
|||
|
class="info-block w-full sm:w-10/12 lg:w-9/12 pb-5 sm:pb-10 overflow-hidden"
|
|||
|
>
|
|||
|
<div class="post mb-10">
|
|||
|
<h1 class="text-xl md:text-xxl mb-5 sm:max-w-md lg:max-w-2xl">
|
|||
|
From Kademlia to Discv5
|
|||
|
</h1>
|
|||
|
<div>
|
|||
|
<span class="text-s lg:text-base">
|
|||
|
09 Apr 2020 • by
|
|||
|
</span>
|
|||
|
<a
|
|||
|
href="/authors/dean"
|
|||
|
class="text-s lg:text-base font-bold hover:underline"
|
|||
|
>dean</a
|
|||
|
>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="post__content"><p>If you’ve been working on Ethereum or adjacent technologies you’ve probably heard of <a href="https://github.com/ethereum/devp2p/blob/master/discv4.md">discv4</a> or <a href="https://github.com/ethereum/devp2p/blob/master/discv5/discv5.md">discv5</a>. But what are they actually? How do they work and what makes them different? To answer these questions, we need to start at the beginning, so this post will assume that there is little knowledge on the subject so the post should be accessible for anyone.</p>
|
|||
|
|
|||
|
<h2 id="the-beginning">The Beginning</h2>
|
|||
|
|
|||
|
<p>Let’s start right at the beginning: the problem of discovery and organization of nodes in peer-to-peer networks.</p>
|
|||
|
|
|||
|
<p>Early P2P file sharing technologies, such as Napster, would share information about who holds what file using a single server. A node would connect to the central server and give it a list of the files it owns. Another node would then connect to that central server, find a node that has the file it is looking for and contact that node. This however was a flawed system – it was vulnerable to attacks and left a single party open to lawsuits.</p>
|
|||
|
|
|||
|
<p>It became clear that another solution was needed, and after years of research and experimentation, we were given the distributed hash table or DHT.</p>
|
|||
|
|
|||
|
<h2 id="distributed-hash-tables">Distributed Hash Tables</h2>
|
|||
|
|
|||
|
<p>In 2001 4 new protocols for such DHTs were conceived, <a href="https://pdos.csail.mit.edu/~strib/docs/tapestry/tapestry_jsac03.pdf">Tapestry</a>, <a href="https://pdos.csail.mit.edu/papers/chord:sigcomm01/chord_sigcomm.pdf">Chord</a>, <a href="https://people.eecs.berkeley.edu/~sylvia/papers/cans.pdf">CAN</a> and <a href="http://rowstron.azurewebsites.net/PAST/pastry.pdf">Pastry</a>, all of which made various trade-offs and changes in their core functionality, giving them unique characteristics.</p>
|
|||
|
|
|||
|
<p>But as said, they’re all DHTs. So what is a DHT?</p>
|
|||
|
|
|||
|
<p>A distributed hash table (DHT) is essentially a distributed key-value list. Nodes participating in the DHT can easily retrieve the value for a key.</p>
|
|||
|
|
|||
|
<p>If we have a network with 9 key-value pairs and 3 nodes, ideally each node would store 3 (optimally 6 for redundancy) of those key-value pairs, meaning that if a key-value pair were to be updated, only part of the network would responsible for ensuring that it is. The idea is that any node in the network would know where to find the specific key-value pair it is looking for based on how things are distributed amongst the nodes.</p>
|
|||
|
|
|||
|
<h2 id="kademlia">Kademlia</h2>
|
|||
|
|
|||
|
<p>So now that we know what DHTs are, let’s get to Kademlia, the predecessor of discv4. Kademlia was created by Petar Maymounkov and David Mazières in 2002. I will naively say that this is probably one of the most popular and most used DHT protocols. It’s quite simple in how it works, so let’s look at it.</p>
|
|||
|
|
|||
|
<p>In Kademlia, nodes and values are arranged by distance (in a very mathematical definition). This distance is not a geographical one, but rather based on identifiers. It is calculated how far 2 identifiers are from eachother using some distance function.</p>
|
|||
|
|
|||
|
<p>Kademlia uses an <code class="language-plaintext highlighter-rouge">XOR</code> as its distance function. An <code class="language-plaintext highlighter-rouge">XOR</code> is a function that outputs <code class="language-plaintext highlighter-rouge">true</code> only when inputs differ. Here is an example with some binary identifiers:</p>
|
|||
|
|
|||
|
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>XOR 10011001
|
|||
|
00110010
|
|||
|
--------
|
|||
|
10101011
|
|||
|
</code></pre></div></div>
|
|||
|
|
|||
|
<p>The top in decimal numbers means that the distance between <code class="language-plaintext highlighter-rouge">153</code> and <code class="language-plaintext highlighter-rouge">50</code> is <code class="language-plaintext highlighter-rouge">171</code>.</p>
|
|||
|
|
|||
|
<p>There are several reasons why <code class="language-plaintext highlighter-rouge">XOR</code> was taken:</p>
|
|||
|
|
|||
|
<ol>
|
|||
|
<li>The distance from one ID to itself will be <code class="language-plaintext highlighter-rouge">0</code>.</li>
|
|||
|
<li>Distance is symmetric, A to B is the same as B to A.</li>
|
|||
|
<li>Follows triangle inequality, if <code class="language-plaintext highlighter-rouge">A</code>, <code class="language-plaintext highlighter-rouge">B</code> and <code class="language-plaintext highlighter-rouge">C</code> are points on a triangle then the distance <code class="language-plaintext highlighter-rouge">A</code> to <code class="language-plaintext highlighter-rouge">B</code> is closer or equal to that of <code class="language-plaintext highlighter-rouge">A</code> to <code class="language-plaintext highlighter-rouge">C</code> plus the one from <code class="language-plaintext highlighter-rouge">B</code> to <code class="language-plaintext highlighter-rouge">C</code>.</li>
|
|||
|
</ol>
|
|||
|
|
|||
|
<p>In summary, this distance function allows a node to decide what is “close” to it and make decisions based on that “closeness”.</p>
|
|||
|
|
|||
|
<p>Kademlia nodes store a routing table. This table contains multiple lists. Each subsequent list contains nodes which are a little further distanced than the ones included in the previous list. Nodes maintain detailed knowledge about nodes closest to them, and the further away a node is, the less knowledge the node maintains about it.</p>
|
|||
|
|
|||
|
<p>So let’s say I want to find a specific node. What I would do is go to any node which I already know and ask them for all their neighbours closest to my target. I repeat this process for the returned neighbours until I find my target.</p>
|
|||
|
|
|||
|
<p>The same thing happens for values. Values have a certain distance from nodes and their IDs are structured the same way so we can calculate this distance. If I want to find a value, I simply look for the neighbours closest to that value’s key until I find the one storing said value.</p>
|
|||
|
|
|||
|
<p>For Kademlia nodes to support these functions, there are several messages with which the protocol communicates.</p>
|
|||
|
|
|||
|
<ul>
|
|||
|
<li><code class="language-plaintext highlighter-rouge">PING</code> - Used to check whether a node is still running.</li>
|
|||
|
<li><code class="language-plaintext highlighter-rouge">STORE</code> - Stores a value with a given key on a node.</li>
|
|||
|
<li><code class="language-plaintext highlighter-rouge">FINDNODE</code> - Returns the closest nodes requested to a given ID.</li>
|
|||
|
<li><code class="language-plaintext highlighter-rouge">FINDVALUE</code> - The same as <code class="language-plaintext highlighter-rouge">FINDNODE</code>, except if a node stores the specific value it will return it directly.</li>
|
|||
|
</ul>
|
|||
|
|
|||
|
<p><em>This is a <strong>very</strong> simplified explanation of Kademlia and skips various important details. For the full description, make sure to check out the <a href="https://pdos.csail.mit.edu/~petar/papers/maymounkov-kademlia-lncs.pdf">paper</a> or a more in-depth <a href="http://xlattice.sourceforge.net/components/protocol/kademlia/specs.html">design specification</a></em></p>
|
|||
|
|
|||
|
<h2 id="discv4">Discv4</h2>
|
|||
|
|
|||
|
<p>Now after that history lesson, we finally get to discv4 (which stands for discovery v4), Ethereum’s current node discovery protocol. The protocol itself is essentially based off of Kademlia, however it does away with certain aspects of it. For example, it does away with any usage of the value part of the DHT.</p>
|
|||
|
|
|||
|
<p>Kademlia is mainly used for the organisation of the network, so we only use the routing table to locate other nodes. Due to the fact that discv4 doesn’t use the value portion of the DHT at all, we can throw away the <code class="language-plaintext highlighter-rouge">FINDVALUE</code> and <code class="language-plaintext highlighter-rouge">STORE</code> commands described by Kademlia.</p>
|
|||
|
|
|||
|
<p>The lookup method previously described by Kademlia describes how a node gets its peers. A node contacts some node and asks it for the nodes closest to itself. It does so until it can no longer find any new nodes.</p>
|
|||
|
|
|||
|
<p>Additionally, discv4 adds mutual endpoint verification. This is meant to ensure that a peer calling <code class="language-plaintext highlighter-rouge">FINDNODE</code> also participates in the discovery protocol.</p>
|
|||
|
|
|||
|
<p>Finally, all discv4 nodes are expected to maintain up-to-date ENR records. These contain information about a node. They can be requested from any node using a discv4-specific packet called <code class="language-plaintext highlighter-rouge">ENRRequest</code>.</p>
|
|||
|
|
|||
|
<p><em>If you want some more details on ENRs, check out one of my posts <a href="https://dean.eigenmann.me/blog/2020/01/21/network-addresses-in-ethereum/">“Network Addresses in Ethereum”</a></em></p>
|
|||
|
|
|||
|
<p>Discv4 comes with its own range of problems however. Let’s look at a few of them.</p>
|
|||
|
|
|||
|
<p>Firstly, the way discv4 works right now, there is no way to differentiate between node sub-protocols. This means for example that an Ethereum node could add an Ethereum Classic Node, Swarm or Whisper node to its DHT without realizing that it is invalid until more communication has happened. This inability to differentiate sub-protocols makes it harder to find specific nodes, such as Ethereum nodes with light-client support.</p>
|
|||
|
|
|||
|
<p>Next, in order to prevent replay attacks, discv4 uses timestamps. This however can lead to various issues when a host’s clock is wrong. For more details, see the <a href="https://github.com/ethereum/devp2p/blob/master/discv4.md#known-issues-in-the-current-version">“Known Issues”</a> section of the discv4 specification.</p>
|
|||
|
|
|||
|
<p>Finally, we have an issue with the way mutual endpoint verification works. Messages can get dropped and there is no way to tell if both peers have verified eachother. This means that we could consider our peer verified while it does not consider us so making them drop the <code class="language-plaintext highlighter-rouge">FINDNODE</code> packet.</p>
|
|||
|
|
|||
|
<h2 id="discv5">Discv5</h2>
|
|||
|
|
|||
|
<p>Finally, let’s look at discv5. The next iteration of discv4 and the discovery protocol which will be used by Eth 2.0. It aims at fixing various issues present in discv4.</p>
|
|||
|
|
|||
|
<p>The first change is the way <code class="language-plaintext highlighter-rouge">FINDNODE</code> works. In traditional Kademlia as well as in discv5, we pass an identifier. However, in discv5 we instead pass the logarithmic distance, meaning that a <code class="language-plaintext highlighter-rouge">FINDNODE</code> request gets a response containing all nodes at the specified logarithmic distance from the called node.</p>
|
|||
|
|
|||
|
<p>Logarithmic distance means we first calculate the distance and then run it through our log base 2 function. See:</p>
|
|||
|
|
|||
|
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>log2(A xor B)
|
|||
|
</code></pre></div></div>
|
|||
|
|
|||
|
<p>And the second, more important change, is that discv5 aims at solving one of the biggest issues of discv4: the differentiation of sub-protocols. It does this by adding topic tables. Topic tables are <a href="https://en.wikipedia.org/wiki/FIFO_(computing_and_electronics)">first in first out</a> lists that contain nodes which have advertised that they provide a specific service. Nodes get themselves added to this list by registering <code class="language-plaintext highlighter-rouge">ads</code> on their peers.</p>
|
|||
|
|
|||
|
<p>As of writing, there is still an issue with this proposal. There is currently no efficient way for a node to place <code class="language-plaintext highlighter-rouge">ads</code> on multiple peers, since it would require separate requests for every peer which is inefficient in a large-scale network.</p>
|
|||
|
|
|||
|
<p>Additionally, it is unclear how many peers a node should place these <code class="language-plaintext highlighter-rouge">ads</code> on and exactly which peers to place them on. For more details, check out the issue <a href="https://github.com/ethereum/devp2p/issues/136">devp2p#136</a>.</p>
|
|||
|
|
|||
|
<p>There are a bunch more smaller changes to the protocol, but they are less important hence they were ommitted from this summary.</p>
|
|||
|
|
|||
|
<p>Nevertheless, discv5 still does not resolve a couple issues present in discv4, such as unreliable endpoint verification. As of writing this post, there is currently no new method in discv5 to improve the endpoint verification process.</p>
|
|||
|
|
|||
|
<p>As you can see discv5 is still a work in progress and has a few large challenges to overcome. However if it does, it will most likely be a large improvement to a more naive Kademlia implementations.</p>
|
|||
|
|
|||
|
<hr />
|
|||
|
|
|||
|
<p>Hopefully this article helped explain what these discovery protocols are and how they work. If you’re interested in their full specifications you can find them on <a href="https://github.com/ethereum/devp2p">github</a>.</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</section>
|
|||
|
</main>
|
|||
|
</div>
|
|||
|
<footer class="footer bg-black flex flex-shrink-0 justify-center">
|
|||
|
<div
|
|||
|
class="
|
|||
|
container
|
|||
|
max-w-screen-xl
|
|||
|
flex
|
|||
|
sl:justify-between
|
|||
|
lm:justify-start
|
|||
|
p-5
|
|||
|
pb-10
|
|||
|
md:px-12 md:pt-5
|
|||
|
lg:pt-10
|
|||
|
"
|
|||
|
>
|
|||
|
<div class="logo mr-10 sm:mr-0 sm:w-2/12 lg:w-3/12">
|
|||
|
<a href="/"
|
|||
|
><img
|
|||
|
src="/assets/img/logo.png"
|
|||
|
alt="Vac logo"
|
|||
|
class="w-9 h-11"
|
|||
|
/></a>
|
|||
|
</div>
|
|||
|
|
|||
|
<div
|
|||
|
class="flex flex-col xm:flex-row xm:justify-between sm:w-10/12 lg:w-9/12"
|
|||
|
>
|
|||
|
<p
|
|||
|
class="
|
|||
|
hidden
|
|||
|
ml:inline-block ml:mr-10
|
|||
|
w-52
|
|||
|
text-base text-white
|
|||
|
opacity-75
|
|||
|
lm:mr-32
|
|||
|
"
|
|||
|
>
|
|||
|
VAC researches peer-to-peer, private, censorship resistant communication
|
|||
|
</p>
|
|||
|
<nav class="flex max-w-xs mr-0 xm:mr-5 l:mr-32 mb-5 sm:mb-0">
|
|||
|
<div class="flex">
|
|||
|
<div class="flex flex-col mr-5 sm:mr-10 sl:mr-14">
|
|||
|
<p class="text-base text-white mb-5 lg:mb-4">Research</p>
|
|||
|
<ul>
|
|||
|
<li class="text-xxs lg:text-base text-white opacity-75 hover:opacity-50 mb-5">
|
|||
|
<a href="https://status.im/" target="_blank" rel="noopener noreferrer"
|
|||
|
>Log</a
|
|||
|
>
|
|||
|
</li>
|
|||
|
<li class="text-xxs lg:text-base text-white opacity-75 hover:opacity-50 mb-5">
|
|||
|
<a href="https://forum.vac.dev/" target="_blank" rel="noopener noreferrer"
|
|||
|
>Forum</a
|
|||
|
>
|
|||
|
</li>
|
|||
|
<li class="text-xxs lg:text-base text-white opacity-75 hover:opacity-50 mb-5">
|
|||
|
<a href="https://status.im/" target="_blank" rel="noopener noreferrer"
|
|||
|
>Media</a
|
|||
|
>
|
|||
|
</li>
|
|||
|
<li class="text-xxs lg:text-base text-white opacity-75 hover:opacity-50 mb-5">
|
|||
|
<a href="https://jobs.status.im/?search=Vac" target="_blank" rel="noopener noreferrer"
|
|||
|
>Careers</a
|
|||
|
>
|
|||
|
</li>
|
|||
|
|
|||
|
</ul>
|
|||
|
</div>
|
|||
|
<div class="flex flex-col sl:mr-14">
|
|||
|
<p class="text-base text-white mb-5 lg:mb-4 mr-5">Socials</p>
|
|||
|
<ul>
|
|||
|
<li class="text-xxs lg:text-base text-white opacity-75 hover:opacity-50 mb-5">
|
|||
|
<a href="https://twitter.com/vacp2p" target="_blank" rel="noopener noreferrer"
|
|||
|
>Twitter</a
|
|||
|
>
|
|||
|
</li>
|
|||
|
<li class="text-xxs lg:text-base text-white opacity-75 hover:opacity-50 mb-5">
|
|||
|
<a href="https://discord.gg/PQFdubGt6d" target="_blank" rel="noopener noreferrer"
|
|||
|
>Discord</a
|
|||
|
>
|
|||
|
</li>
|
|||
|
<li class="text-xxs lg:text-base text-white opacity-75 hover:opacity-50 mb-5">
|
|||
|
<a href="https://t.me/vacp2p" target="_blank" rel="noopener noreferrer"
|
|||
|
>Telegram</a
|
|||
|
>
|
|||
|
</li>
|
|||
|
|
|||
|
</ul>
|
|||
|
</div>
|
|||
|
</div></nav>
|
|||
|
|
|||
|
<div class="flex flex-col w-52">
|
|||
|
<h3 class="text-base text-white mb-5">Signup for updates</h3>
|
|||
|
<form action="" class="footer__form">
|
|||
|
<div class="flex items-center w-full">
|
|||
|
<input
|
|||
|
class="
|
|||
|
text-xs text-white
|
|||
|
w-full
|
|||
|
bg-black
|
|||
|
border-b border-white
|
|||
|
rounded-none
|
|||
|
mr-2
|
|||
|
focus:outline-none
|
|||
|
placeholder-white placeholder-opacity-50
|
|||
|
"
|
|||
|
type="email"
|
|||
|
placeholder="your email"
|
|||
|
required
|
|||
|
/>
|
|||
|
<button
|
|||
|
class="
|
|||
|
h-10
|
|||
|
w-10
|
|||
|
bg-arrowWhite bg-auto bg-no-repeat bg-left
|
|||
|
focus:outline-none
|
|||
|
hover:opacity-50
|
|||
|
"
|
|||
|
type="submit"
|
|||
|
></button>
|
|||
|
</div>
|
|||
|
</form>
|
|||
|
<p
|
|||
|
class="footer__confirm text-base italic text-white opacity-75 hidden"
|
|||
|
>
|
|||
|
You signed up! Check your e-mail
|
|||
|
</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</footer>
|
|||
|
<script src="/assets/js/main.js"></script>
|
|||
|
<script src="/assets/js/smooth-scroll.js"></script>
|
|||
|
|
|||
|
</body>
|
|||
|
</html>
|