Codex Storage
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Help
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Swarm Networking Swarm seems to try to use DHT replication for storage. As usual, Blake and Rodrigues[^blake_03] come to mind in that this is not a good idea unless churn is under control, so this is the framing I started reading this with. **DHT.** Swarm uses a forwarding Kademlia in which connections are postulated to be "quasi-permanent". I was again under the impression this would be at odds with a dynamic system (churn means stable connections are not a reality) and this is indeed the case, but it turns out that if "active acknowledgements" are added onto a forwarding Kademlia, then the expected latency of recursive routing can be actually smaller. This is stated both analytically[^wu_06], and empirically[^heep_10]. The lookup variant described in [^wu_06], however, requires nodes along a query path to contact the initial sender _directly_, which is at odds with the "backwarding" (forwarding backwards along the query path) responses that Swarm employs to preserve sender privacy. I am therefore not convinced that this will perform well under churn. In fact, multihop backward forwarding will probably be a big problem under churn and will fail to reduce lookup path lengths on timeouts. **DISC.** Data is stored as $4\text{KB}$ chunks, which are either regular content-addressed or "single-owner" chunks. Content-addressed chunks are what one expects, whereas "single-owner" chunks decouple the chunk's key from its content. At first I thought "single-owner" chunks were a form of mutable data, but the book states that: "_(...) if the owner of the private key signs two different payloads with the same identifier and uploads both chunks to Swarm, the behaviour of the network is unpredictable._ Since the identifier is part of the address, I get this to mean that single-owner chunks are not meant to be mutable, meaning I do not really get their point (maybe I will as I read on). **Encryption.** Chunks are encrypted with a symmetric key $s$ which might be provided externally. For each of the $127$ $32$-byte segments that make up a $4\text{KB}$ chunk, Swarm derives a separate key by computing $k_i = H(s\ ||\ i)$, where $0 \leq i \leq 127$ is the index of the chunk, where $H$ outputs a $256$-bit ($32$-byte) byte string. Encryption then consists of XOR'ing $k_i$ with the actual content fo the segment. Since segments have separate keys, they can be decrypted separatelly. One could provide the key for a segment $k_i$ without revealing $k$, which would allow a third party to learn the contents of segment $i$ alone. This looks a bit too granular to me, but apparently Swarm needs this for on-chain computations of some sort (again, maybe this will make sense as I read on). **Replication.** Swarm replicates a chunk over the $r$ closest nodes to its "intended" location. By looking at Swarm code, nodes will attempt to keep between $8$ to $18$ nodes per Kademlia $k$-bucket, and will attempt to sync with all the nodes in the highest proximity-order bucket ($8$ to $18$ peers). Because a node will be in the proximity neighborhood for at least as many peers, the number of peers connected for sync is about twice as big ($16$ - $36$). There are several things about the synchronization approach that worry me. **1. Churn.** Nodes entering or leaving the network will trigger full syncs in all of their neighborhoods. Although this does not necessarily mean that everything needs to be copied to the replacement nodes every time[^1], I do not see this working well under heavier churn - there will be a lot of data copying going on. In fact, this is _exactly_ the situation in Blake and Rodrigues' paper.[^blake_03]. **2. Storage guarantees.** Nodes adopt an eviction strategy in which chunks deemed with "lower value" are evicted in favour of chunks with "higher value". This means there are no storage guarantees - at any time, a node might decide to just purge your data because something of higher value came along. Then, the text says things like: "_If chunks are synced in the order they are stored, this may not result in the node always having the most profitable (most often requested) chunks_" If this is correct, it says that valuable chunks are popular chunks, which means unpopular content will likely disappear from the system over time making it wholy inadequate for private content, and very adequate for popular; e.g., Bittorrent-like use-cases instead, except the performance of retrieval is likely nowhere even near to Bittorrent. I need to read the incentives section first but this alone would make the system quite restrictive. **3. Order-by-value syncs.** The book starts saying that chunks are totally ordered within a peer by a timestamp that indicates when that peer stored the chunk, which hints at a very simple approach for checking whether or not a given peer is in sync with the other; i.e., you can assign an integer to every chunk (totally order them) and then peers trying to sync with you just have to keep track of what that integer was. But then, it says later: _If chunks are synced in the order they are stored, this may not result in the node always having the most profitable (most often requested) chunks. Thus it may be advisable to sync chunks starting with the most popular ones according to upstream peers and finish syncing when storage capacity is reached. In this way, a node’s limited storage will be optimised._ Popularity is a dynamic entity, so this will cause ordering to change. The single-integer sync mechanism therefore does not work anymore - in fact, nodes are trying to solve an optimization problem at that point; i.e., which subset of the chunks from my neighbors should I keep to maximize profit, and trying to do so over a synchronization protocol. This does not sound simple/efficient to do at all. [^1]: The book flip-flops a bit about this but pull sync apparently orders records in a stream by insertion order, so checking for sync with a peer amounts to transmitting and comparing an integer. If a node disconnects and reconnects, the re-sync cost can therefore be small -- just check an integer with a bunch of nodes and figure out there is nothing to do. [^wu_06]: Di Wu, Ye Tian and Kam-Wing Ng, "Analytical Study on Improving DHT Lookup Performance under Churn," Sixth IEEE International Conference on Peer-to-Peer Computing (P2P'06), Cambridge, 2006, pp. 249-258, doi: 10.1109/P2P.2006.4. [^heep_10]: B. Heep, "R/Kademlia: Recursive and topology-aware overlay routing", 2010 Australasian Telecommunication Networks and Applications Conference, New Zealand, 2010, pp. 102-107, doi: 10.1109/ATNAC.2010.5680244. [^blake_03]: Charles Blake and Rodrigo Rodrigues, "High Availability, Scalable Storage, Dynamic Peer Networks: Pick Two," 9th Workshop on Hot Topics in Operating Systems (HotOS IX), https://www.usenix.org/events/hotos03/tech/full_papers/blake/blake.pdf

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully