• This repository has been archived on 02/Aug/2021
  • Stars
    star
    488
  • Rank 88,171 (Top 2 %)
  • Language
    Go
  • License
    GNU Lesser Genera...
  • Created over 10 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Swarm: Censorship resistant storage and communication infrastructure for a truly sovereign digital society

Swarm

https://swarm.ethereum.org

Swarm is a distributed storage platform and content distribution service, a native base layer service of the ethereum web3 stack. The primary objective of Swarm is to provide a decentralized and redundant store for dapp code and data as well as block chain and state data. Swarm is also set out to provide various base layer services for web3, including node-to-node messaging, media streaming, decentralised database services and scalable state-channel infrastructure for decentralised service economies.

New Bee client

In the effort to release a production-ready version of Swarm, the Swarm dev team has migrated their effort to build the new Bee client, a brand-new implementation of Swarm. The main reason for this switch was the availability of a more mature networking layer (libp2p) and the secondary reason being that the insight gained from developing Swarm taught us many lessons which can be implemented best from scratch. While Bee does not currently expose every feature in the original Swarm client, development is happening at lightspeed and soon, it will surpass Swarm in functionality and stability!

Please refer to Swarm webpage for more information about the state of the Bee client and to the Bee documentation for info on installing and using the new client.

Original Swarm client

The old Swarm client, contained in this repository, can still be used while the network exists, however no maintenance or upgrades are planned for it.

Please read the The sun is setting for the old Swarm network blog post for more information and also how to reach out for help with migration.

Compatibility of Bee with the first Swarm

No compatibility on the network layer with the first Ethereum Swarm implementation can be provided, mainly due to the migration in underlying network protocol from devp2p to libp2p. This means that a Bee node cannot join first Swarm network and vice versa. Migrating data is possible, please get in touch for more info on how to approach this. 🐝

How to get in touch

Please use any of the following channels for help with migration or any other questions:

The Swarm team is reachable on Mattermost. Join the Swarm Orange Lounge on Telegram. Follow us on Twitter.

Travis Gitter

Table of Contents

Building the source

It's recommended to use Go 1.14 to build Swarm.

To simply compile the swarm binary without a GOPATH:

$ git clone https://github.com/ethersphere/swarm
$ cd swarm
$ make swarm

You will find the binary under ./build/bin/swarm.

To build a vendored swarm using go get you must have GOPATH set. Then run:

$ go get -d github.com/ethersphere/swarm
$ go install github.com/ethersphere/swarm/cmd/swarm

Running Swarm

$ swarm

If you don't have an account yet, then you will be prompted to create one and secure it with a password:

Your new account is locked with a password. Please give a password. Do not forget this password.
Passphrase:
Repeat passphrase:

If you have multiple accounts created, then you'll have to choose one of the accounts by using the --bzzaccount flag.

$ swarm --bzzaccount <your-account-here>

# example
$ swarm --bzzaccount 2f1cd699b0bf461dcfbf0098ad8f5587b038f0f1

Verifying that your local Swarm node is running

When running, Swarm is accessible through an HTTP API on port 8500.

Confirm that it is up and running by pointing your browser to http://localhost:8500

Ethereum Name Service resolution

The Ethereum Name Service is the Ethereum equivalent of DNS in the classic web. In order to use ENS to resolve names to Swarm content hashes (e.g. bzz://theswarm.eth), swarm has to connect to a geth instance, which is synced with the Ethereum mainnet. This is done using the --ens-api flag.

$ swarm --bzzaccount <your-account-here> \
        --ens-api '$HOME/.ethereum/geth.ipc'

# in our example
$ swarm --bzzaccount 2f1cd699b0bf461dcfbf0098ad8f5587b038f0f1 \
        --ens-api '$HOME/.ethereum/geth.ipc'

For more information on usage, features or command line flags, please consult the Documentation.

Documentation

Swarm documentation can be found at https://swarm-guide.readthedocs.io.

Docker

Swarm container images are available at Docker Hub: ethersphere/swarm

Docker tags

  • latest - latest stable release
  • edge - latest build from master
  • v0.x.y - specific stable release

Swarm command line arguments

All Swarm command line arguments are supported and can be sent as part of the CMD field to the Docker container.

Examples:

Running a Swarm container from the command line

$ docker run -it ethersphere/swarm \
                            --debug \
                            --verbosity 4

Running a Swarm container with custom ENS endpoint

$ docker run -it ethersphere/swarm \
                            --ens-api http://1.2.3.4:8545 \
                            --debug \
                            --verbosity 4

Running a Swarm container with metrics enabled

$ docker run -it ethersphere/swarm \
                            --debug \
                            --metrics \
                            --metrics.influxdb.export \
                            --metrics.influxdb.endpoint "http://localhost:8086" \
                            --metrics.influxdb.username "user" \
                            --metrics.influxdb.password "pass" \
                            --metrics.influxdb.database "metrics" \
                            --metrics.influxdb.host.tag "localhost" \
                            --verbosity 4

Running a Swarm container with tracing and pprof server enabled

$ docker run -it ethersphere/swarm \
                            --debug \
                            --tracing \
                            --tracing.endpoint 127.0.0.1:6831 \
                            --tracing.svc myswarm \
                            --pprof \
                            --pprofaddr 0.0.0.0 \
                            --pprofport 6060

Running a Swarm container with a custom data directory mounted from a volume and a password file to unlock the swarm account

$ docker run -it -v $PWD/hostdata:/data \
                 -v $PWD/password:/password \
                 ethersphere/swarm \
                            --datadir /data \
                            --password /password \
                            --debug \
                            --verbosity 4

Developers Guide

Go Environment

We assume that you have Go v1.11 installed, and GOPATH is set.

You must have your working copy under $GOPATH/src/github.com/ethersphere/swarm.

Most likely you will be working from your fork of swarm, let's say from github.com/nirname/swarm. Clone or move your fork into the right place:

$ git clone [email protected]:nirname/swarm.git $GOPATH/src/github.com/ethersphere/swarm

Vendored Dependencies

Vendoring is done by Makefile rule make vendor which uses go mod vendor and additionally copies cgo dependencies into vendor directory from go modules cache.

If you want to add a new dependency, run go get <import-path>, vendor it make vendor, then commit the result.

If you want to update all dependencies to their latest upstream version, run go get -u all and vendor them with make vendor.

By default, go tool will use dependencies defined in go.mod file from modules cache. In order to import code from vendor directory, an additional flag -mod=vendor must be provided when calling go run, go test, go build and go install. If vendor directory is in sync with go.mod file by updating it with make vendor, there should be no difference to use the flag or not. All Swarm build tools are using code only from the vendor directory and it is encouraged to do the same in the development process, as well.

Testing

This section explains how to run unit, integration, and end-to-end tests in your development sandbox.

Testing one library:

$ go test -v -cpu 4 ./api

Note: Using options -cpu (number of cores allowed) and -v (logging even if no error) is recommended.

Testing only some methods:

$ go test -v -cpu 4 ./api -run TestMethod

Note: here all tests with prefix TestMethod will be run, so if you got TestMethod, TestMethod1, then both!

Running benchmarks:

$ go test -v -cpu 4 -bench . -run BenchmarkJoin

Profiling Swarm

This section explains how to add Go pprof profiler to Swarm

If swarm is started with the --pprof option, a debugging HTTP server is made available on port 6060.

You can bring up http://localhost:6060/debug/pprof to see the heap, running routines etc.

By clicking full goroutine stack dump (clicking http://localhost:6060/debug/pprof/goroutine?debug=2) you can generate trace that is useful for debugging.

Metrics and Instrumentation in Swarm

This section explains how to visualize and use existing Swarm metrics and how to instrument Swarm with a new metric.

Swarm metrics system is based on the go-metrics library.

The most common types of measurements we use in Swarm are counters and resetting timers. Consult the go-metrics documentation for full reference of available types.

// incrementing a counter
metrics.GetOrRegisterCounter("network/stream/received_chunks", nil).Inc(1)

// measuring latency with a resetting timer
start := time.Now()
t := metrics.GetOrRegisterResettingTimer("http/request/GET/time"), nil)
...
t := UpdateSince(start)

Visualizing metrics

Swarm supports an InfluxDB exporter. Consult the help section to learn about the command line arguments used to configure it:

$ swarm --help | grep metrics

We use Grafana and InfluxDB to visualise metrics reported by Swarm. We keep our Grafana dashboards under version control at https://github.com/ethersphere/grafana-dashboards. You could use them or design your own.

We have built a tool to help with automatic start of Grafana and InfluxDB and provisioning of dashboards at https://github.com/nonsense/stateth, which requires that you have Docker installed.

Once you have stateth installed, and you have Docker running locally, you have to:

  1. Run stateth and keep it running in the background
$ stateth --rm --grafana-dashboards-folder $GOPATH/src/github.com/ethersphere/grafana-dashboards --influxdb-database metrics
  1. Run swarm with at least the following params:
--metrics \
--metrics.influxdb.export \
--metrics.influxdb.endpoint "http://localhost:8086" \
--metrics.influxdb.username "admin" \
--metrics.influxdb.password "admin" \
--metrics.influxdb.database "metrics"
  1. Open Grafana at http://localhost:3000 and view the dashboards to gain insight into Swarm.

Public Gateways

Swarm offers a local HTTP proxy API that Dapps can use to interact with Swarm. The Ethereum Foundation is hosting a public gateway, which allows free access so that people can try Swarm without running their own node.

The Swarm public gateways are temporary and users should not rely on their existence for production services.

The Swarm public gateway can be found at https://swarm-gateways.net and is always running the latest stable Swarm release.

Swarm Dapps

You can find a few reference Swarm decentralised applications at: https://swarm-gateways.net/bzz:/swarmapps.eth

Their source code can be found at: https://github.com/ethersphere/swarm-dapps

Contributing

Thank you for considering to help out with the source code! We welcome contributions from anyone on the internet, and are grateful for even the smallest of fixes!

If you'd like to contribute to Swarm, please fork, fix, commit and send a pull request for the maintainers to review and merge into the main code base. If you wish to submit more complex changes though, please check up with the core devs first on our Swarm gitter channel to ensure those changes are in line with the general philosophy of the project and/or get some early feedback which can make both your efforts much lighter as well as our review and merge procedures quick and simple.

Please make sure your contributions adhere to our coding guidelines:

  • Code must adhere to the official Go formatting guidelines (i.e. uses gofmt).
  • Code must be documented adhering to the official Go commentary guidelines.
  • Pull requests need to be based on and opened against the master branch.
  • Code review guidelines.
  • Commit messages should be prefixed with the package(s) they modify.
    • E.g. "fuse: ignore default manifest entry"

License

The swarm library (i.e. all code outside of the cmd directory) is licensed under the GNU Lesser General Public License v3.0, also included in our repository in the COPYING.LESSER file.

The swarm binaries (i.e. all code inside of the cmd directory) is licensed under the GNU General Public License v3.0, also included in our repository in the COPYING file.

More Repositories

1

bee

Bee is a Swarm client implemented in Go. It’s the basic building block for the Swarm network: a private; decentralized; and self-sustaining network for permissionless publishing and access to your (application) data.
Go
1,435
star
2

eth-utils

ethereum utilities, dev tools, scripts, etc
Shell
146
star
3

bee-dashboard

An app which helps users to setup their Bee node and do actions like cash out cheques
TypeScript
144
star
4

bee-clef

bee-clef is official ethereum clef binary wrapped and preconfigured for bee as a service
Shell
82
star
5

swarm-guide

Swarm Documentation
Python
76
star
6

bee-js

Javascript client library for connecting to Bee decentralised storage
TypeScript
62
star
7

beekeeper

Swarm Beekeeper is an orchestrator that can manage a cluster of Bee nodes and call into their API. It allows various scenario’s to be performed on these nodes. The Swarm team uses Beekeeper internally for integration tests.
Go
52
star
8

swap-swear-and-swindle

Contracts for Swap, Swear and Swindle. Swap is a protocol for p2p accounting. This is the basis for Swarm’s incentivization model.
TypeScript
52
star
9

swarm-cli

Manage your Bee node and interact with the Swarm network via the CLI
TypeScript
49
star
10

bzzaar-contracts

JavaScript
37
star
11

bee-docs

Documentation for the Swarm Bee Client. View at docs.ethswarm.org, contributions welcome!
JavaScript
36
star
12

helm

Ethersphere Helm Charts
Mustache
33
star
13

awesome-swarm

This is a list of free and open source projects related to Swarm and its growing ecosystem.
29
star
14

swarm-desktop

Electron Desktop app that helps you easily spin up and manage Swarm node
JavaScript
25
star
15

storage-incentives

Smart contracts for Swarm storage incentives
TypeScript
18
star
16

the-book-of-swarm

the book of swarm - base-layer infrastructure for self-sovereign digital society
TeX
17
star
17

bee-factory

Builds up a test environment with Bee clients and with a test blockchain.
TypeScript
17
star
18

swarm-extension

PoC for Swarm Browser Extension
TypeScript
14
star
19

ethereum-environments

ethereum environments provisioning and automated vm builds
Puppet
14
star
20

swarm-home

Source code for the Swarm homepage hosted at bzz:/theswarm.eth/
HTML
14
star
21

grafana-dashboards

Various Grafana dashboards for Swarm
Jsonnet
13
star
22

swarm-docs

TeX
11
star
23

gateway-ui

Swarm Gateway website
TypeScript
11
star
24

gateway-proxy

Proxy service for the Bee client
TypeScript
9
star
25

swarm-kubernetes

Swarm on Kubernetes
HCL
9
star
26

swarm-cluster

docker (+kubernetes) config for a swarm cluster
Shell
8
star
27

ethproxy

Ethproxy is a websocket reverse proxy for ethereum JsonRPC calls.
Go
6
star
28

mantaray-js

Mantaray data structure in JS
TypeScript
6
star
29

helm-charts

Helm charts to deploy Swarm and Geth
Smarty
6
star
30

etherjot

TypeScript
6
star
31

user-stories

Repository for maintaining user stories
5
star
32

SWIPs

The SWarm Improvement Proposal repository
5
star
33

eks-local-disk-provisioner

AWS EKS local disk provisioner
Shell
5
star
34

etherproxy

Etherproxy is a JSON-RPC reverse proxy tool designed for caching requests.
JavaScript
5
star
35

rise-of-bee-airdrop

Rise of Bee Airdrop
TypeScript
4
star
36

swarm-oracles

obsolete - This repository holds the smart-contracts for on-chain oracles, used for updating global variables in the Swarm network
JavaScript
4
star
37

examples-js

Example code how to interact with Swarm
TypeScript
4
star
38

nonce-reset

Go
4
star
39

repo-maintainer

Description of Repo Maintainer
3
star
40

swarm-actions

TypeScript
3
star
41

sw3paper

LaTeX code for the Swap-Swear-Swindle Orange paper
TeX
3
star
42

eth-on-bzz

Ethereum blockchain data on Swarm.
Go
3
star
43

gitbook-plugin-sections

cherry pick section of an included doc on gitbook page
JavaScript
3
star
44

beelocal

Shell
2
star
45

swarm-visual-guidelines

2
star
46

frontpage.github.io

The front page of Swarm.
TypeScript
2
star
47

docker-setup-contracts

Shell
2
star
48

onboarding-faucet

TypeScript
2
star
49

bee-js-docs

JavaScript
2
star
50

swarm-orange-summit

swarm summit 2017 website
HTML
2
star
51

devconV

Holds all content for the Swarm breakout programme at the Ethereum Devcon in Osaka
2
star
52

manifest

Go implementation for bee manifests.
Go
2
star
53

docker-clef

docker for clef
Shell
2
star
54

nft-example

A very simple project which can be used to deploy and mint an NFT which stores it's metadata and image decentralised in the Swarm.
Solidity
2
star
55

scoop

Scoop repo for Ethersphere
2
star
56

ethswarm-nextjs

JavaScript
2
star
57

etherjot-web

TypeScript
2
star
58

bee-argo

This repo is used for automatic cluster deployments by ArgoCD
2
star
59

homebrew-tap

Homebrew tap for Ethersphere
Ruby
1
star
60

bee-load-test

Spin up 100 node isolated cluster
Shell
1
star
61

swap-deployment

Deployment helm charts and scripts for swap-enabled Swarm clusters
Shell
1
star
62

swarm-bot

JavaScript
1
star
63

resolver

Go
1
star
64

repo-sync-action

Synchronize files from master repo to another repo
1
star
65

helm-charts-artifacts

Packaged Helm charts for running Swarm
HTML
1
star
66

node-implementer-spec

Documentation on how to create a custom Swarm node implementation
Go
1
star
67

bee-runner

A GitHub App built with Probot
JavaScript
1
star
68

swent-docs

Swarm Enterprise documentation
HTML
1
star
69

ethswarm-blog-hugo

CSS
1
star
70

bee-local

definitions for the Bee local cluster development used by the Swarm Team
Shell
1
star
71

tokenexporter

Go
1
star
72

bee-diagrams

1
star
73

ethexporter

Go
1
star
74

ethercomb

TypeScript
1
star
75

node-funder

tool to fund bee nodes
Go
1
star
76

swarm-tools

Swarm tools - a collection of tools that are helpful during development of Swarm
Go
1
star
77

kibana-exports

1
star
78

bee-staging

Definitions for the bee staging releases used by the Swarm team.
Shell
1
star
79

swarm-donation

TypeScript
1
star
80

beelon-musk-nft-example

1
star
81

bee-scripts

Scripts by the Bee team to help debug and monitor testnet and mainnet nodes.
Go
1
star
82

ethercast

TypeScript
1
star