blockstack-core

Blockstack的参考实现。(The reference implementation of Blockstack.)

Github星跟蹤圖

Blockstack Core

该软件包提供了Blockstack节点的参考实现,以及用于部署它的工具和脚本。

如果您希望开始使用Blockstack应用程序,我们建议您先从Blockstack浏览器开始。

什么是Blockstack?

Blockstack是用于分散应用程序的网络,用户可以在其中拥有自己的数据。

Blockstack应用程序遵循不可恶的设计理念。他们不能更改、转移或撤销用户的身份,他们无法在未经许可的情况下读取或写入用户的数据。

Blockstack提供平台、网络和SDK,用于使用现有的Web工具构建不可恶的应用程序。如果您是Web开发人员,您的所有技能都可以立即转移到Blockstack。

Blockstack应用程序的外观和感觉就像传统的Web应用程序。在底层,他们使用Blockstack API进行用户身份验证和存储。

Blockstack使用Blockstack命名服务(BNS)处理用户身份验证,BNS是一种基于比特币区块链构建的分散命名和公钥基础结构。它使用Gaia处理存储,Gaia是一个可扩展的分散式键/值存储系统,外观和感觉类似于localStorage,但允许用户通过Dropbox或S3等现有存储系统安全地存储和共享应用程序数据。

Blockstack应用程序在两个关键方面与传统Web应用程序不同。首先,用户拥有自己的身份。 Blockstack浏览器使用户可以直接控制他们的私钥和配置文件数据,并履行SSO提供商对Blockstack应用程序的角色。 Blockstack Core提供BNS作为用户发现彼此公钥的一种方式。

第二个关键区别是用户拥有自己的数据。用户可以选择托管其应用数据的位置,以及允许其读取的人员。 Gaia使用用户选择的存储提供程序加载和存储数据,并使用其特定于应用程序的密钥自动对其进行签名和加密。只有目标收件人才能验证和读取数据;存储提供程序被视为不受信任的中间人。

为什么要使用Blockstack?

Blockstack是用户和开发人员的双赢。用户不会被锁定在应用程序或服务中。相反,用户将他们的身份和数据从应用程序带到应用程序。如果用户选择允许,应用只能读取用户数据。如果应用程序脱机,用户仍会保留其数据。如果用户找到更好的应用程序,他们可以无缝切换到使用它。由于数据是端到端加密的,并且与应用程序分开托管,因此数据泄露对用户来说无关紧要,因为黑客无需窃取。

开发人员也从Blockstack中受益。使用Blockstack构建应用程序更简单,并且需要更少的操作开销,因为它们不再需要存储用户数据。许多非平凡的应用程序可以使用blockstack.js实现为单页面Javascript应用程序,并部署为静态网页。 Blockstack API小巧,简单,易于集成到现有的Web应用程序中。

什么是Blockstack Core?

Blockstack Core实现了Gaia的存储路由系统BNS和Atlas

Blockstack核心节点构成了Blockstack网络的主干。每个节点都对比特币区块链编制索引,并维护所有名称、公钥和存储路由信息的完整副本。这使得Blockstack网络对节点故障具有特别的弹性 -- 应用程序只需要与单个Blockstack Core节点通信即可工作,而新的或恢复节点可以从其对等端快速重建其所有丢失状态。

建议高级用户在其笔记本电脑或家庭/办公室网络上运行本地Blockstack Core节点,以便可靠地访问Blockstack网络。您的本地节点保持与其他Blockstack Core节点相同的状态,因此即使上游节点无法访问或脱机,它也将保留服务名称、公钥和存储路由。

安装Blockstack Core

安装Blockstack Core有三种支持的方法:

从源代码安装

在从源安装Blockstack Core之前,您需要安装libffi-devlibssl-dev。 Mac和Linux用户通常可以从各自的包管理器中获取这些包。

安装这些依赖项后,您可以通过附带的setup.py脚本从源安装Blockstack Core,如下所示:

$ git clone https://github.com/blockstack/blockstack-core
$ cd blockstack-core
$ python2 ./setup.py build
$ sudo python2 ./setup.py install

您还可以使用virtualenv在非系统目录中安装Blockstack Core。

使用 pip 进行安装

Blockstack是针对Python 2.7构建的。 如果你有pip2而不是pip,你应该使用pip2。 如果您没有pip2,则应验证您的pip是否已配置为Python 2。

在Mac上:

# Install blockstack
$ pip install blockstack --upgrade

在CentOS 7 和 RHEL上:

# Install dependencies
$ yum install epel-release
$ yum install python-pip python-devel openssl-devel libffi-devel rng-tools gmp-devel zlib-devel
# Install blockstack
$ sudo pip install blockstack --upgrade

您需要打开端口TCP:6264和TCP:6270。 如果您在启动blockstack-core时遇到问题,可以尝试禁用SELinux和/或firewalld,如下所示:

# Disable SELinux
$ setenforce 0
$ sed -i --follow-symlinks 's/^SELINUX=.*/SELINUX=disabled/g' /etc/sysconfig/selinux && cat /etc/sysconfig/selinux
# Stop firewalld
$ systemctl stop firewalld && systemctl disable firewalld

在Debian和Ubuntu上:

# Install dependancies
$ sudo apt-get update && sudo apt-get install -y python-pip python-dev libssl-dev libffi-dev rng-tools libgmp3-dev
$ sudo pip install pyparsing
# Install blockstack
$ sudo pip install blockstack --upgrade

以 docker 方式安装

注意:只有稳定版本(即master)才支持使用docker。

另一种运行blockstack-core的方法是通过docker。 我们提供了此存储库的每个提交映像构建,可在quay.io上使用

$ git clone git@github.com:blockstack/blockstack-core.git
$ cd blockstack-core
$ docker build -t blockstack-core:master .
# create directory to store Blockstack Core state
$ export BLOCKSTACK_DIR="/var/blockstack-core-data"
$ mkdir -p "$BLOCKSTACK_DIR"
$ docker run \
   -v $BLOCKSTACK_DIR:/root/.blockstack-server \
   -p 6264:6264 \
   -p 6270:6270 \
   blockstack-core:master

这些命令将在大约10分钟内快速同步并运行Blockstack Core节点。 Blockstack Core节点的状态将存储到$ BLOCKSTACK_DIR。 您可以使用docker logs -f或tail -f "$BLOCKSTACK_DIR/blockstack-server.log"查看节点的日志。

笔记:

  • 目前只在Linux上完全支持此方法。
  • 您将需要sudo访问权来运行上述脚本,和/或成为docker组的成员。
  • 您可以为每个主机运行此设置的多个实例。 每个容器至少允许1个CPU核心。
  • 要配置其他bitcoind节点,必须在运行./docker-tools.sh init-* 命令之前编辑blockstack-server.ini文件。 在运行init-*之后,您必须编辑data/core/server/blockstack-server.ini以更改这些设置。

运行Blockstack核心节点

在执行任何操作之前,您应该配置Blockstack Core节点。

$ blockstack-core configure

接受所有默认值是安全的。它将在~/.blockstack-server/中生成一些配置状态。

因为每个Blockstack Core节点都在本地维护网络状态的完整副本,所以当它第一次启动时,它需要将其状态与比特币区块链同步。这可能需要数天时间。为了解决这个问题,我们运行了一些“快速同步”服务器,它们将为新的Blockstack Core节点提供网络状态的最新快照。快速同步只需几分钟。

要从快照启动Blockstack Core节点,您应该运行

$ blockstack-core --debug fast_sync

默认情况下,它将从http://fast-sync.blockstack.org/snapshot.bsk中提取快照,并使用内置公钥来验证其真实性。它将使用最近的网络状态快照(不到24小时)填充~/.blockstack-server/目录。

要启动Blockstack Core节点,您应该运行

$ blockstack-core --debug start

这将在后台启动Blockstack Core节点。我们建议传递--debug标志,这样您将收到详细输出,这将有助于诊断您可能遇到的任何问题。

您可以在~/.blockstack-server/blockstack-server.log中找到节点的日志。

使用Blockstack Core

与Blockstack Core交互的标准方法是通过其RESTful接口。这里提供了API端点的完整文档。以下是一些常见的例子。

要检查您的API端点是否已启动,您可以使用以下命令ping它:

$ curl http://localhost:6270/v1/ping
{"status": "alive", "version": "20.0.0.0"}

您可以通过查找名称来确认您的API端点是否可以联系blockstack-core守护程序,如下所示:

$ curl http://localhost:6270/v1/names/muneeb.id
{"status": "registered", "zonefile": "$ORIGIN muneeb.id\n$TTL 3600\n_http._tcp URI 10 1 \"https://gaia.blockstack.org/hub/1J3PUxY5uDShUnHRrMyU6yKtoHEUPhKULs/0/profile.json\"\n", "expire_block": 599266, "blockchain": "bitcoin", "last_txid": "7e16e8688ca0413a398bbaf16ad4b10d3c9439555fc140f58e5ab4e50793c476", "address": "1J3PUxY5uDShUnHRrMyU6yKtoHEUPhKULs", "zonefile_hash": "37aecf837c6ae9bdc9dbd98a268f263dacd00361"}

您可以使用以下命令停止Blockstack Core守护程序:

$ blockstack-core stop
获得详细的调试输出

默认情况下,Blockstack Core不会记录非常多的非错误信息。要获得详细输出,可以将--debug传递给blockstack-core和blockstack api,如下所示:

$ blockstack-core --debug start && tail -f ~/.blockstack-server/blockstack-server.log

另外,blockstack-core可以在前台运行,而不会成为守护进程。 为此,请将它们运行为:

$ blockstack-core --debug start --foreground

开发者资源

v20.0.0.0是Blockstack Core的当前稳定版本。它在主分支上可用。

下一个版本正在开发中。请将所有拉取请求提交给开发分支。

在发行说明列表中,您可以找到每个发行版中已更改的内容。

Blockstack Core有一个广泛的集成测试框架,可让您在沙盒环境中试验Blockstack。测试框架为您的Blockstack Core节点提供了一个本地的私有比特币区块链,让您可以安全地尝试不同的名称和命名空间交易,而无需花费比特币。我们使用集成测试框架来测试从新的API调用到新的Blockstack Browser功能的所有内容。请参阅相关文档以开始使用。

我们欢迎任何小的或大的贡献!请花点时间查看为开源做贡献的指南,以便让参与者轻松有效地完成贡献过程。

社区

除了这个Github项目,Blockstack还有一个公共论坛和一个允许的Slack频道。此外,该项目还有一个邮件列表,用于发送社区公告。

更大的Blockstack社区定期举办面对面的聚会。该项目的YouTube频道包括来自其中一些聚会的视频,以及帮助新用户入门的视频教程,并帮助开发人员围绕系统的设计。

进一步阅读

您可以访问Blockstack网站并查看深入的文章和文档,了解更多信息:

您还可以阅读同行评审的Blockstack论文:

如果您有关于Blockstack的高级问题,请尝试搜索我们的论坛,如果您的问题没有得到解答,请开始一个新问题。

版权和许可

代码和文档版权归属于2018年的blockstack.org。

此代码根据GPL v3许可证发布,文档根据Creative Commons许可证发布。

概覽

名稱與所有者stacks-network/stacks-core
主編程語言Rust
編程語言Shell (語言數: 8)
平台Docker, Linux, Mac
許可證GNU General Public License v3.0
發布數214
最新版本名稱2.5.0.0.3 (發布於 )
第一版名稱0.0.10.8 (發布於 2016-06-06 16:18:32)
創建於2014-09-23 14:40:43
推送於2024-04-26 21:17:20
最后一次提交2024-04-25 14:39:59
星數2.9k
關注者數193
派生數645
提交數22.6k
已啟用問題?
問題數2558
打開的問題數315
拉請求數1658
打開的拉請求數23
關閉的拉請求數340
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?

Blockstack Core

PyPI
Slack

This repo provides the packaged reference implementation of a Blockstack node, as well as tools and scripts for deploying it. Use the following table to learn more about Blockstack:, Blockstack Topic/Tech, Where to learn more more, ---------------------------------, ------------------------------------------------------------------------------, Stacks blockchain v1, master branch, Stacks blockchain v2, develop branch, Clarity smart contract language (preview), develop branch, Use the package, our core docs, Develop a Blockstack App, our developer docs, Use a Blockstack App, our browser docs, Blockstack the company, our website, ### Interested in the Clarity Smart Contracting language?

Active development of Clarity and the Stacks blockchain is ongoing in the develop branch. This branch contains preview builds of Clarity.

Table of Contents

What is Blockstack?

Blockstack is a network for decentralized apps where users own their data.

Blockstack applications follow a can't-be-evil design
philosophy. They cannot alter, transfer, or revoke the user's identity, and
they cannot read or write the user's data without permission. Blockstack provides the
platform, network, and SDKs for building can't-be-evil
applications using existing Web tools.
If you are Web developer, all of your skills are
immediately transferrable to Blockstack.

Blockstack applications look and feel like traditional Web applications.
Under the hood they use Blockstack APIs for user authentication and storage.
Blockstack handles user authentication using the Blockstack Naming
Service

(BNS), a decentralized naming and public key infrastructure built on top of the Bitcoin
blockchain. It handles storage using Gaia, a scalable decentralized
key/value storage system that looks and feels like localStorage,
but lets users securely store and share application data
via user-selected storage systems.

Blockstack applications differ from traditional Web applications in two key
ways. First, users own their identities.
The Blockstack Browser
gives users direct control over their private keys and profile data,
and fulfills the role of a SSO provider to Blockstack apps.
Blockstack Core provides BNS as a way for users to discover each other's public
keys.

The second key difference is that users own their data. Users
choose where their app data gets hosted, and who is allowed to read it.
Gaia loads and stores data with the user's
chosen storage providers, and automatically signs and encrypts it with
their app-specific keys. Only the intended recipients can authenticate and read
the data; the storage providers are treated as untrusted middlemen.

Why use Blockstack?

Blockstack is a win/win for users and developers. Users are not locked into
apps or services. Instead, users take their identities and data with them from app to app.
Apps can only read user data if the user chooses to allow it. If an app goes
offline, the user still keeps their data. If users find a better app, they
can seamlessly switch over to using it. Because data is end-to-end encrypted
and hosted separately from the app, data breaches are inconsequential to users
because there is nothing for hackers to steal.

Developers benefit from Blockstack as well. Apps are simpler to build with
Blockstack and require less operational overhead, since they no longer have to
store user data. Many non-trivial applications can be implemented
as single-page Javascript applications using
blockstack.js, and deployed as a
static Web page. The Blockstack API is small, simple, and straightforward to
integrate into existing Web apps.

What is Blockstack Core?

Blockstack Core implements BNS and Atlas, the storage
routing system for Gaia. Blockstack Core
nodes form the backbone of the Blockstack network. Each node indexes the
Bitcoin blockchain and maintains a full replica of all names,
public keys, and storage routing information. This makes the Blockstack network
particularly resilient to node failure---applications only need to talk to a
single Blockstack Core node to work, and a new or recovering node
can quickly reconstruct all of its missing state from its peers.

Power users are encouraged to run local Blockstack Core nodes on their laptops
or home/office networks in order to have reliable access to the Blockstack
network. Your local node maintains the same state as the rest of the Blockstack
Core nodes, so it will keep serving names, public keys, and storage routes even
if upstream nodes are unreachable or go offline.

Installing Blockstack Core

There are three supported methods to install Blockstack Core:

Install from Source

Before installing Blockstack Core from source, you will need to install
libffi-dev and
libssl-dev. Mac and Linux users can
usually grab these packages from their respective package managers.

Once these dependencies are installed, you can install Blockstack Core
from source via the included setup.py script, as follows:

$ git clone https://github.com/blockstack/blockstack-core
$ cd blockstack-core
$ python2 ./setup.py build
$ sudo python2 ./setup.py install

You can also use a virtualenv to
install Blockstack Core in a non-system directory.

Install with pip

NOTE: Using pip is only supported for stable releases (i.e. master).

Blockstack is built against Python 2.7. You should use pip2 if you have it instead of pip. If you do not have pip2, you should verify that your pip is configured for Python 2.

On Mac:

# Install blockstack
$ pip install blockstack --upgrade

On CentOS 7 & RHEL:

# Install dependencies
$ yum install epel-release
$ yum install python-pip python-devel openssl-devel libffi-devel rng-tools gmp-devel zlib-devel

# Install blockstack
$ sudo pip install blockstack --upgrade

You will need to open ports TCP:6264 and TCP:6270. If you have trouble starting
blockstack-core, you can try disabling SELinux and/or firewalld as follows:

# Disable SELinux
$ setenforce 0
$ sed -i --follow-symlinks 's/^SELINUX=.*/SELINUX=disabled/g' /etc/sysconfig/selinux && cat /etc/sysconfig/selinux

# Stop firewalld
$ systemctl stop firewalld && systemctl disable firewalld

On Debian & Ubuntu:

# Install dependancies
$ sudo apt-get update && sudo apt-get install -y python-pip python-dev libssl-dev libffi-dev rng-tools libgmp3-dev
$ sudo pip install pyparsing

# Install blockstack
$ sudo pip install blockstack --upgrade

Install with docker

NOTE: Using docker is only supported for stable releases (i.e. master).

Another way to run blockstack-core is through docker. We provide per-commit image builds of this repository that are available on quay.io.

$ git clone git@github.com:blockstack/blockstack-core.git
$ cd blockstack-core
$ docker build -t blockstack-core:master .

# create directory to store Blockstack Core state
$ export BLOCKSTACK_DIR="/var/blockstack-core-data"
$ mkdir -p "$BLOCKSTACK_DIR"
$ docker run \
   -v $BLOCKSTACK_DIR:/root/.blockstack-server \
   -p 6264:6264 \
   -p 6270:6270 \
   blockstack-core:master

These commands will fast-sync and run a Blockstack Core node in about 10
minutes. The state for the Blockstack Core node will be stored to
$BLOCKSTACK_DIR. You can see the node's logs with docker logs -f or with
tail -f "$BLOCKSTACK_DIR/blockstack-server.log".

Notes:

  • This method is currently only fully supported on Linux.
  • You will need sudo access to run the above scripts, and/or be a member of the docker group.
  • You can run more than one instance of this setup per host. Allow at least 1 CPU core for each container
  • To configure a different bitcoind node, you must edit your blockstack-server.ini file before running the ./docker-tools.sh init-* commands. After init-* has been run you must edit the data/core/server/blockstack-server.ini to change those settings.

Running a Blockstack Core Node

Before doing anything, you should configure your Blockstack Core node.

$ blockstack-core configure

It is safe to accept all defaults. It will generate some configuration state in
~/.blockstack-server/.

Because each Blockstack Core node maintains a full copy of the network state
locally, it will need to synchronize its state with the Bitcoin blockchain when
it starts for the first time. This can take days. To overcome this,
we run some "fast-sync" servers that will serve a new Blockstack Core node a
recent snapshot of the network state. Fast-sync only takes a few minutes.

To start up a Blockstack Core node from a snapshot, you should run

$ blockstack-core --debug fast_sync

By default, it will pull a snapshot from
http://fast-sync.blockstack.org/snapshot.bsk and use a built-in public key to
verify its authenticity. It will populate your ~/.blockstack-server/
directory with a recent snapshot of the network state (less than 24 hours old).

To start your Blockstack Core node, you should run

$ blockstack-core --debug start

This will start a Blockstack Core node in the background. We recommend passing
the --debug flag so you will receive verbose output, which will help diagnose
any problems you may have.

You can find the node's log in ~/.blockstack-server/blockstack-server.log.

Using Blockstack Core

The standard way to interact with Blockstack Core is through its RESTful interface. The full documentation for the API endpoints is available here. Below are some common examples.

To check that your API endpoint is up, you can ping it with:

$ curl http://localhost:6270/v1/ping
{"status": "alive", "version": "20.0.0.0"}

You can confirm that your API endpoint can contact the blockstack-core daemon
by looking up a name as follows:

$ curl http://localhost:6270/v1/names/muneeb.id
{"status": "registered", "zonefile": "$ORIGIN muneeb.id\n$TTL 3600\n_http._tcp URI 10 1 \"https://gaia.blockstack.org/hub/1J3PUxY5uDShUnHRrMyU6yKtoHEUPhKULs/0/profile.json\"\n", "expire_block": 599266, "blockchain": "bitcoin", "last_txid": "7e16e8688ca0413a398bbaf16ad4b10d3c9439555fc140f58e5ab4e50793c476", "address": "1J3PUxY5uDShUnHRrMyU6yKtoHEUPhKULs", "zonefile_hash": "37aecf837c6ae9bdc9dbd98a268f263dacd00361"}

You can stop the Blockstack Core daemon with the following command:

$ blockstack-core stop

Getting Verbose Debugging Output

Blockstack Core does not log very much non-error information by default. To get
verbose output, you can pass --debug to both blockstack-core and blockstack api, as follows:

$ blockstack-core --debug start && tail -f ~/.blockstack-server/blockstack-server.log

In addition blockstack-core can run in the
foreground, without becoming daemons. To do so, run them as:

$ blockstack-core --debug start --foreground

Developer Resources

v20.0.0.0 is the current stable release of Blockstack Core. It available on the master branch.

The next release is being built on the develop. Please submit all
pull requests to the develop branch.

In the list of release notes you can find what has changed in each release.

Blockstack Core has an extensive integration test framework, which lets you
experiment with Blockstack in a sandboxed environment. The test framework gives your Blockstack
Core node a local, private Bitcoin blockchain that lets you safely experiment
with different name and namespace transactions without spending Bitcoin.
We use the integration test
framework to test everything from new API calls to new Blockstack Browser
features. Please see the relevant
documentation to get started.

We welcome any small or big contributions! Please take a moment to
review the guidelines for contributing to open source in order to make the contribution process easy and effective for everyone involved.

Community

Beyond this Github project,
Blockstack maintains a public forum and a
permissioned Slack channel. In addition, the project
maintains a mailing list which sends out
community announcements.

The greater Blockstack community regularly hosts in-person
meetups. The project's
YouTube channel includes
videos from some of these meetups, as well as video tutorials to help new
users get started and help developers wrap their heads around the system's
design.

Further Reading

You can learn more by visiting the Blockstack Website and checking out the in-depth articles and documentation:

You can also read peer-reviewed Blockstack papers:

If you have high-level questions about Blockstack, try searching our forum and start a new question if your question is not answered there.

The code and documentation copyright are attributed to blockstack.org for the year of 2018.

This code is released under the GPL v3 license, and the docs are released under the Creative Commons license.

去到頂部