• Stars
    star
    606
  • Rank 73,958 (Top 2 %)
  • Language
    Go
  • License
    MIT License
  • Created about 7 years ago
  • Updated over 1 year ago

Reviews

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

Repository Details

Go Implementation of the Spacemesh protocol full node. πŸ’Ύβ°πŸ’ͺ

Spacemesh: A Programmable Cryptocurrency

license release platform go version open help wanted issues discord made by Go Report Card Bors enabled godoc CI: passing

go-spacemesh

πŸ’Ύβ°πŸ’ͺ

Thanks for your interest in this open source project. This repo is the go implementation of the Spacemesh p2p full node software.

Spacemesh is a decentralized blockchain computer using a new race-free consensus protocol that doesn't involve energy-wasteful proof of work.

We aim to create a secure and scalable decentralized computer formed by a large number of desktop PCs at home.

We are designing and coding a modern blockchain platform from the ground up for scale, security and speed based on the learnings of the achievements and mistakes of previous projects in this space.

To learn more about Spacemesh head over to https://spacemesh.io.

To learn more about the Spacemesh protocol watch this video.

Motivation

Spacemesh is designed to create a decentralized blockchain smart contracts computer and a cryptocurrency that is formed by connecting the home PCs of people from around the world into one virtual computer without incurring massive energy waste and mining pools issues that are inherent in other blockchain computers, and provide a provably-secure and incentive-compatible smart contracts execution environment.

Spacemesh is designed to be ASIC-resistant and in a way that doesn’t give an unfair advantage to rich parties who can afford setting up dedicated computers on the network. We achieve this by using a novel consensus protocol and optimize the software to be most effectively be used on home PCs that are also used for interactive apps.

What is this good for?

Provide dapp and app developers with a robust way to add value exchange and other value related features to their apps at scale. Our goal is to create a truly decentralized cryptocurrency that fulfills the original vision behind bitcoin to become a secure trustless store of value as well as a transactional currency with extremely low transaction fees.

Target Users

go-spacemesh is designed to be installed and operated on users' home PCs to form one decentralized computer. It is going to be distributed in the Spacemesh App but people can also build and run it from source code.

Project Status

We are working hard towards our first major milestone - a public permissionless testnet running the Spacemesh consensus protocol.

Contributing

Thank you for considering to contribute to the go-spacemesh open source project!

We welcome contributions large and small and we actively accept contributions.

Diggin' Deeper

Please read the Spacemesh full FAQ.

go-spacemesh Architecture

Architecture

Getting

git clone [email protected]:spacemeshos/go-spacemesh.git

or fork the project from https://github.com/spacemeshos/go-spacemesh

Since the project uses Go Modules it is best to place the code outside your $GOPATH. Read this for alternatives.

Setting Up Local Dev Environment

Building is supported on OS X, Linux, FreeBSD, and Windows.

Install Go 1.19 or later for your platform, if you haven't already.

On Windows you need to install make via msys2, MingGW-w64 or mingw

Ensure that $GOPATH is set correctly and that the $GOPATH/bin directory appears in $PATH.

Before building we need to set up the golang environment. Do this by running:

make install

How to run standalone node?

After you got a binary standalone fully functional network can be launched with a simple command:

./build/go-spacemesh --preset=standalone --genesis-time=2023-06-08T5:30:00.000Z

Network will use short epochs (1 minute), and 10 layers within the epoch (each 6s). Poet is launched in the same process in this mode. So expect that it will periodically hog 1 core. Minimal smeshig is enabled in order for consensus to work.

Public GRPC API are launched on 0.0.0.0:10092. Private - 0.0.0.0:10093.

Building

To build go-spacemesh for your current system architecture, from the project root directory, use:

make build

(On FreeBSD, you should instead use gmake build. You can install gmake with pkg install gmake if it isn't already installed.)

This will build the go-spacemesh binary, saving it in the build/ directory.

On linux or mac you can build a binary for windows using:

make windows

Be aware that this will require a cross-platform gcc like x86_64-w64-mingw32-gcc. Platform-specific binaries are saved to the build/*target* directory.

Using go build and go test without make

To build or test code without using make some golang environment variables must be set appropriately.

The environment variables can be printed by running either make print-env or make print-test-env.

They can be set in 3 ways:

Note: we need to use eval to interpret the commands since there are spaces in the values of the variables so the shell can't correctly split them as arguments.

  1. Setting the variables on the same line as the go command (e.g., eval $(make print-env) go build ./...). This affects the environment for that command invocation only.
  2. Exporting the variables in the shell's environment (e.g., eval export $(make print-env)). The variables will persist for the duration of that shell (and will be passed to subshells).
  3. Setting the variables in the go environment (e.g., eval go env -w $(make print-env)). Persistently adds these values to Go's environment for any future runs.

Running

Note: go-spacemesh relies on a gpu setup dynamic library in order to run. make install puts this file in the build folder, so if you are running spacemesh from the build folder you don't need to take any extra action. However if you have built the binary using go build or moved the binary from the build folder you need to ensure that you have the gpu setup dynamic library (the exact name will vary based on your OS) accessible by the go-spacemesh binary. The simplest way to do this is just copy the library file to be in the same directory as the go-spacemesh binary. Alternatively you can modify your system's library search paths (e.g. LD_LIBRARY_PATH) to ensure that the library is found.

go-spacemesh is p2p software which is designed to form a decentralized network by connecting to other instances of go-spacemesh running on remote computers.

To run go-spacemesh you need to specify the parameters shared between all instances on a specific network.

You specify these parameters by providing go-spacemesh with a json config file. Other CLI flags control local node behavior and override default values.

Joining a Testnet (without mining)

  1. Build go-spacemesh from source code.

  2. Download the testnet's json config file. Make sure your local config file suffix is .json.

  3. Start go-spacemesh with the following arguments:

    ./go-spacemesh --listen [a_multiaddr] --config [configFileLocation] -d [nodeDataFilesPath]

    Example:

    Assuming tn1.json is a testnet config file saved in the same directory as go-spacemesh, use the following command to join the testnet. The data folder will be created in the same directory as go-spacemesh. The node will use TCP port 7513 and UDP port 7513 for p2p connections:

    ./go-spacemesh --listen /ip4/0.0.0.0/tcp/7513 --config ./tn1.json -d ./sm_data
  4. Build the CLI Wallet from source code and run it:

  5. Use the CLI Wallet commands to setup accounts, start smeshing and execute transactions.

./cli_wallet

Joining a Testnet (with mining)

  1. Run go-spacemesh to join a testnet without mining (see above).

  2. Run the CLI Wallet to create a coinbase account. Save your coinbase account public address - you'll need it later.

  3. Stop go-spacemesh and start it with the following params:

    ./go-spacemesh --listen [a_multiaddr] --config [configFileLocation] -d [nodeDataFilesPath] --smeshing-coinbase [coinbase_account] --smeshing-start --smeshing-opts-datadir [dir_for_post_data]

    Example:

    ./go-spacemesh --listen /ip4/0.0.0.0/tcp/7513 --config ./tn1.json -d ./sm_data --smeshing-coinbase stest1qqqqqqp3qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqql50dsa --smeshing-start --smeshing-opts-datadir ./post_data
  4. Use the CLI wallet to check your coinbase account balance and to transact


Smeshing

To be able to initialize your PoST using your Graphics card you will need to install the tools necessary to enable OpenCL support on your system. The exact steps to do this will vary based on your OS and GPU. In general you will need to install the OpenCL runtime for your GPU and ICD loader.

A good starting point to get more info is https://wiki.archlinux.org/title/GPGPU.

If your system doesn't have a GPU or you can use a generic runtime instead. Be aware that we do not recommend this for initialization of PoST. On Ubuntu you need to install the following packages:

apt-get update
apt-get install libpocl2

on Windows you can use Intel OpenAPI:

choco install opencl-intel-cpu-runtime

Testing

NOTE: if tests are hanging try running ulimit -n 400. some tests require that to work.

TEST_LOG_LEVEL="" make test

The optional TEST_LOG_LEVEL environment variable can be set to change the log level during test execution. If not set, tests won't print any logs. Valid values are the error levels of zapcore

For code coverage you can run:

make cover

This will start a local web service and open your browser to render a coverage report. If you just want to generate a cover profile you can run:

make cover-profile

The generated file will be saved to ./cover.out. It can be loaded into your editor or IDE to view which code paths are covered by tests and which not.

Continuous Integration

We've enabled continuous integration on this repository in GitHub. You can read more about our CI workflows.

Docker

A Dockerfile is included in the project allowing anyone to build and run a docker image:

docker build -t spacemesh .
docker run -d --name=spacemesh spacemesh

Windows

On Windows you will need the following prerequisites:

  • Powershell - included by in Windows by default since Windows 7 and Windows Server 2008 R2
  • Git for Windows - after installation remove C:\Program Files\Git\bin from System PATH (if present) and add C:\Program Files\Git\cmd to System PATH (if not already present)
  • Make - after installation add C:\Program Files (x86)\GnuWin32\bin to System PATH
  • Golang
  • GCC. There are several ways to install gcc on Windows, including Cygwin. Instead, we recommend tdm-gcc which we've tested.

Close and reopen powershell to load the new PATH. You can then run the command make install followed by make build as on UNIX-based systems.

Running a Local Testnet

  • You can run a local Spacemesh Testnet with 6 full nodes, 6 user accounts, and 1 POET support service on your computer using docker.
  • The local testnet full nodes are built from this repo.
  • This is a great way to get a feel for the protocol and the platform and to start hacking on Spacemesh.
  • Follow the steps in our Local Testnet Guide

Next Steps

Got Questions?

More Repositories

1

smapp

Spacemesh App (Smesher + Wallet) πŸ¦πŸ“Š
TypeScript
95
star
2

svm

SVM - Spacemesh Virtual Machine
Rust
83
star
3

cosmic

🌱🌌 Seed for a universal (native iOS, native Android, web, desktop) app based on react native web, redux and Typescript
HTML
32
star
4

protocol

This repo contains the Spacemesh protocol specifications and related documentation
CSS
30
star
5

gpu-post

Spacemesh proof of space time gpu optimized setup
C
21
star
6

post

Spacemesh POST protocol implementation
Go
19
star
7

app

[DEPRECATED] The cosmic Spacemesh App containing the Spacemesh Wallet and the Spacemesh Dashboard πŸ¦πŸ“Š
TypeScript
19
star
8

poet

Spacemesh PoET service reference implementation
Go
18
star
9

product

This repo contains the Spacemesh product specifications and designs
CSS
18
star
10

merkle-tree

Efficient on-the-fly Merkle Tree implementation
Go
16
star
11

smrepl

A Spacemesh Terminal wallet app
Go
16
star
12

ed25519

Drop in replacement for golang/crypto/ed25519 with additional functionality
Go
15
star
13

api

Protobuf implementation of the Spacemesh API
Makefile
14
star
14

local-testnet

A local testnet of go-spacemesh full nodes running the Spacemesh protocol and a functional CLI wallet. πŸ’Ύβ°
TypeScript
14
star
15

kboard

Github project kanban board minimal visualization for big screen projection
JavaScript
12
star
16

tytle

The Typed-Turtle Programming Language
Rust
12
star
17

post-rs

Rust implementation of POST proving
Rust
10
star
18

POET-OLD

Spacemesh POET service
Go
9
star
19

SMIPS

Spacemesh Improvement Proposals
7
star
20

testnet-guide

Spacemesh testnet online guide content for https://testnet.spacemesh.io
CSS
6
star
21

ed25519-WASM

Drop in replacement for golang/crypto/ed25519 with additional functionality compiled to WASM
Go
6
star
22

tapbot

Tap bot for discord
Go
4
star
23

explorer-backend

Spacemesh explorer backend designed to provide data for explorer-frontends
Go
4
star
24

pos-server

Rust
4
star
25

smart-contract-experiment

Rust
3
star
26

k8sm

mini spacemesh testnet inside k8s
HCL
3
star
27

dash-backend

A spacemesh dashboard data backend
Go
3
star
28

ws-ops

Spacemesh public web services (dash, explore, api) deploy scripts
HCL
3
star
29

ledger-app

Spacemesh Ledger App
C
2
star
30

spacemesh-watch

Monitoring and Alerting for Nodes
Go
2
star
31

Liberthon

Python
2
star
32

multisig-server

Rust
2
star
33

go-bls

An experimental go-bls sigs lib based on herumi
Go
2
star
34

programmability

Specs repo for Spacemesh programmability. e.g. VM, dev tool-chain and sdk
2
star
35

pm

Project management. Meta-tasks related to research, dev, and specs for the Spacemesh protocol and infrastructure.
2
star
36

dash-frontend

A Spacemesh dashboard frontend
JavaScript
2
star
37

go-svm-old

Go bindings for SVM
Go
2
star
38

research

Spacemesh research tasks tracking issues
2
star
39

fixed

Package fixed implements fixed-point integer types. [Based on golang.org/x/image/math/fixed]
Go
2
star
40

go-ledger-sdk

A golang SDK for using Ledger wallets from Spacemesh wallets
C
2
star
41

go-spacecraft

A CLI tool to deploy Spacemesh Network on GCP
Go
2
star
42

logs-parser

Simple data extraction from Spacemesh full node logs
JavaScript
2
star
43

docs

JavaScript
2
star
44

poet2

Incremental proofs of elapsed time MVP repo
2
star
45

bitstream

Bit-granular stream access (read/write)
Go
2
star
46

quicksync-rs

CLI tool for downloading state.sql from a web server
Rust
2
star
47

explorer-frontend

JavaScript
1
star
48

spacewhale

Researching the depths of the sea to find the optimal spacewhale configuration
1
star
49

ed25519-client

ed25519 extension methods client code example
Go
1
star
50

sm-codec

TypeScript
1
star
51

collector

collects events via node pubsub and writes them to db
Go
1
star
52

lite-env

A small development framework for testing spacemesh miners
Shell
1
star
53

github-actions-runners

Manager Instance Group for dedicated GitHub Actions runners
HCL
1
star
54

smcli

Spacemesh command-line tool
Go
1
star
55

go-spacemesh-mock

1
star
56

sm-net

Spacemesh devnets and testnets releases
JavaScript
1
star
57

node-mock

Mock full node as an API provider
Go
1
star
58

quipu-specs

Specificatons of various Spacemesh components (expressed in Quipu language)
1
star
59

platform-docs

Source for Spacemesh platform documentation website
JavaScript
1
star
60

ledger-sdk

A Javascript sdk for communicating with the Spacemesh ledger app designed to be integrated with Javascript Spacemesh wallets.
JavaScript
1
star
61

ws-helm-charts

Public web service (Explore, Dash, API) charts
Smarty
1
star
62

smops

Repository for spacemesh operations
HCL
1
star
63

wiki

Protocol-wide, project-wide wiki
1
star
64

poet-core-api

Poet service core api
Go
1
star
65

go-bls-example

Demonstration using go-bls
Go
1
star