Rinke Hendriksen
    • Create new note
    • Create a note from template
      • 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
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • 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
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy 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
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • 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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # SWAP pricing # SWIP --- SWIP: TODO: update title: TODO author: Daniel A. Nagy <daniel@ethswarm.org> (@nagydani) discussions-to: https://swarmresear.ch/t/postage-ex-proof-of-burn/ status: Draft type: Standards Track category: Core created: 2019-07-12 --- <!--You can leave these HTML comments in your merged SWIP and delete the visible duplicate text guides, they will not appear and may be helpful to refer to if you edit it again. This is the suggested template for new SWIPs. Note that a SWIP number will be assigned by an editor. When opening a pull request to submit your SWIP, please use an abbreviated title in the filename, `SWIP-draft_title_abbrev.md`. The title should be 44 characters or less.--> # SWAP pricing ## Simple Summary <!--"If you can't explain it simply, you don't understand it well enough." Provide a simplified and layman-accessible explanation of the SWIP.--> We describe a protocol which nodes use to communicate their price for delivering chunks in the Swarm network. On top of this protocol, strategies can be implemented by nodes who wish to compete with other nodes on quality/price. A minimal strategy is presented which makes nodes request different prices, depending on the proximity of the requested chunk. While this strategy implies that nodes don't initiate price changes by themselves, they need to react to price changes from upstream peers when it is essential or profitable to do so. The price signalling is closely coupled with actual retrieve requests and therefore is formulated as part of the retrieve protocol ## Abstract <!--A short (~200 word) description of the technical issue being addressed.--> ## Motivation <!--The motivation is critical for SWIPs that want to change the Swarm protocol. It should clearly explain why the existing protocol specification is inadequate to address the problem that the SWIP solves. SWIP submissions without sufficient motivation may be rejected outright.--> This SWIP lays the foundation for a Swarm network where the price for the Swarm accounting Protocol (SWAP) is dynamic and based on local decisions. This is essential for the following reasons: - Bandwidth costs are not heterogenous around the world. Allowing nodes to express their cost-structure via their price will enable competition on price/quality, ultimately benefitting the end-user of Swarm. - Bandwidth costs are constantly changing. Being able to react directly to these changes is essential for a node as without this possibility, the node operator might decide to shut down their node when costs go up or end-users might overpay for an extended period of time when prices decrease and there is no competitive pressure for nodes to reduce their price as well. The choice was made to leave out the implementation of an active response to changes in cost structure / bandwidth usage, as there exists an economic incentive for nodes to use a strategy that is better than we ever think of. To facilitate such tinkering, a minimal and passive reaction to price changes by other nodes is included. Ultimately, we expect competetive pressure to automatically fade out our presented passive strategy. ## Specification <!--The technical specification should describe the syntax and semantics of any new feature. The specification should be detailed enough to allow competing, interoperable implementations for the current Swarm platform and future client implementations. --> This specification distinguishes between protocol and strategy. The protocol *must* be implemented and cannot be different between peers in the same network. A strategy should be implemented, but because different strategies can co-exist on the same network, it suffices to start with the most minimal strategy. ### Protocol TODO: describe the specific encoding/serialization of the messages. - `RetrieveRequest: {price, chunkAddress, Ruid}`. Sent by a requesting peer to an another peer to request a chunk. `price` is defined by the strategy and should be the best-effort guess by the originating peer about the price for deliverying the chunk. `chunkAddress` is the Swarm hash of the desired `chunkContent`. A `RetrieveRequest` may be answered by a `ChunkDelivery` or `NewPrice` message (described below). Upon receiving a new price message, requestor can rerequest, now with the given new price. Measures must be taken not to retry endlessly after receiving a `NewPrice` message. - `ChunkDelivery: {chunkContent, Ruid}`. Sent by a node that has got the chunk to deliver a requested chunk. The applied price by SWAP is the `price` from the `RetrieveRequest` with the same `Ruid`. - `NewPrice: {price, chunkReference}`. Sent by an upstream peer to a downstream peer to signal that for this particular `chunkReference`, the downstream peer has to pay `price`. The `chunkReference` may be synthetic, meaning that there is no actual `chunkContent` mapping to the `chunkReference`. A peer that receives a `NewPrice` message is supposed to update it's state (see below). ## Strategy The minimum strategy to be implemented is the strategy which sufficiently incentivizes other people to come up with better strategies, but which not The following strategy is a basic way on how nodes *can* use the protocol described above. The strategy intends to be as easy as possible to implement, while balbalbala ### State Nodes keep track for each (historical) peer which prices they paid for each distance and when this price was last updated. Schematically, this mapping may looks like: ``` priceInformationRegistry: { peerID1 => priceInformation, ... , peerIDN => priceInformation } ``` where ``` priceInformation: [ proximity0: {price, lastUpdated}, ... , proximityN: {price, lastUpdated} ] ``` where `proximity` is `proximity` as defined in the [architecture docs](https://swarm-guide.readthedocs.io/en/latest/architecture.html#logarithmic-distance) between the peer and the `chunkReference` and `N` is the `saturation depth - 1`. ` ### Filling the state Nodes learn about the prices of their peers by trial and error: initially, the `priceInformationRegistry` is empty which means that the best-effort guess for the price of a `ChunkDelivery` equals zero. If storer nodes and/or forwarding nodes have a non-zero margin, the peer to whom the `ChunkDeliveryRequest` was send will answer the request with a `NewPrice` message, thus populating the `priceInformationRegistry` of the node. NOTE: Why not just putting it in the handshake? As the expected amount of hops is a function of the network size, it might happen that the price for a certain distance changes without ### Margin Margin is a configuration variable and it specifies the SWAP profit a node wishes to make for every `ChunkDelivery`. Hence, the price of a `ChunkDelivery` can be defined as, at least, the `margin` + the price of the cheapest upstream peer. ### Reacting to upstream price differences Nodes define their preferred supplier for chunks based on the following: For any chunk request: - Select the bin to forward the request to - Select the peer with the lowest price in that bin - Do a round-robin load balancing if there are multiple peers with the same price Based on this, we conclude that the reaction to a decrease in price for a peer in a certain bin is that we are more likely to send requests to him and that the opposite holds for an increase in price. ``` Note that a peer who has a very low margin and is connected to very cheap upstream peers might still be more expensive for a certain request than a peer with a high margin and expensive upstream peers, as the distance of the expensive peer to the chunk might be much less than the distance of a cheap peer to a chunk. ``` The other reaction is that when our upstream peers increase their prices, we need to increase our prices as well to still be able to get our desired margin. If the upstream peers decrease their price, we might want to decrease our price as well, as this way, we can get more traffic. ### Notifying about price changes It is in the interest of the network, that when there is a price change this gets propagated as soon as possible to the relevant parties. A price change can be initiated by a change of `margin` (by any upstream peer), or by a change of the network size. In both cases, a peer might decide not to notify other peers about the decrease in price--the only thing which changes is that it will accept `RetrieveRequests` with a lower price than before. Without notifying the downstream peers, however, a node might not get the expected amount of additional clients directly, as the downstream peers might never propose a lower price than before. For this reason, we propose that nodes pro-actively send `NewPrice` messages to his peers, essentially requesting them to update their `priceInformationRegistry`. In the case of pro-active `NewPrice` messages, the `chunkReference` may be synthetic, meaning it does not have to respond to an actual chunk; all that is important is that peers update their `priceInformationRegistry`. ### Overpriced bins Since the price of a node depends on the price of his upstream peers, it might happen that by change, all his upstream peer-connections in a certain bin are populated by expensive peers—effectively making the node itself to be too expensive as well for his downstream peers. To solve this issue, we propose to do statistical analysis: if a node has sensible prices for all distances, it is expected that half of his requests are in bin zero, a quarter in bin 1, 1/8th in bin 2, etc... up to (but excluding) the bin of the saturation depth. If a node receives statistically significantly less requests for one bin compared to the expected amount of requests in that bin, he marks the supposedly overpriced peers as non-functional and the hive protocol should kick in to suggest new peer connections. ### Reacting to demand increases/decreases A node that decreases its price such that he is the cheapest, is expected to get much more traffic. Without an adequate respose to an increase in traffic, a node might be forced to go offline as he is incapable of handling the increased traffic. In order to prevent this from happening, nodes must adapt their price actively, based on their bandwidth utilization. ### Swarmholes A Swarmhole is created by running one node (one database) with multiple peer identities. If a node has a sufficient number of peer identities, the expected amount of hops for any request to this node can be decreased to 0 (that is: he stores all data in the Swarm network). Due to competitive pressure, it is expected that nodes will create multiple peer identities (probably not to store the whole network if the network is sufficiently big) or collaborate in a centralized overlay network to share and pool requests (effectively achieving the same as one very big node). Such Swarmholes will decrease the price of `RetrieveRequest`s and decrease the latency. There are also problems: - Anybody who does not run a Swarmhole node (or is connected to a Swarmhole) cartel, will not be able to compete with the Swarmhole and hence cannot make a profit on SWAP. - Swarmhole nodesdesdes will be able to figure out which chunks belong together - Swarmholes can censor content or blacklist peers, making resp. the content more expensive and increase the price for the blacklisted peers (it/they must now route through "normal Swarm"). ## Rationale <!--The rationale fleshes out the specification by describing what motivated the design and why particular design decisions were made. It should describe alternate designs that were considered and related work, e.g. how the feature is supported in other languages. The rationale may also provide evidence of consensus within the community, and should discuss important objections or concerns raised during discussion.--> TODO ## Copyright Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). ## Questions: What is the price to serve a cached chunk? => minimum price == margin, but peers might offer a higher price because they don't know that you cached it. For some popular chunks, the price might be different than for non-popular chunk. What if the distance of the popular chunk is very far. How do I distinguish between NewPrice for the popular chunk and NewPrice for the non-popular chunk?

    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