Quorum是一个许可制的以太坊联盟区块链实现,包含了金融巨头JP摩根开发的一个GETH分支版本,可以在节点之间实现私有和快速的交易。Quorum为保证隐私对节点之间的私有交易进行了专门的设计,它使用Raft和Istanbul算法实现共识,使用Tessara和Constellation实现节点数据的加密和共享。在Quorum网络中交易不需要付费,交易的验证是由投票共识算法完成的。总体上来讲Quorum类似于以太坊,只是它更关注的企业环境下的交易隐私性与可控性,因此每个节点都需要Quorum 网管生成的密钥对。
Quorum is a licensed ETA block chain that includes a version of the GETH branch developed by the financial giant JP Morgan, which allows private and fast transactions between nodes. Quorum has designed private transactions between nodes specifically to ensure privacy, using the Raft and Istanbul algorithms to achieve consensus, encryption and sharing of node data using Tessara and Constellation. There is no payment for transactions in the Quorum network, and the authentication of transactions is done by the voting consensus algorithm. In general, Quorum is similar to Quorum, but it is only concerned with the privacy and controlability of transactions in an enterprise environment, so each node requires a key pair generated by the Quorum network.
学习Quorum区块链的最好的办法,就是运行官方提供的7节点示例。虽然有多种方法来搭建7个节点,我还是建议使用docker,因为这应该是最简单的办法。下面我使用Google云的Ubuntu 8.04。如果你在本地机器或AWS上有ubuntu,也是一样的。请先确认docker和docker-compose已经安装就绪。
The best way to learn about the Quorum block chain is to run the official seven-point example. Although there are many ways to build the seven nodes, I suggest using docker because it should be the simplest. Next, I use the Google cloud Ubuntu 8.04. The same is true if you have ubuntu on the local machine or AWS. Make sure that docker and docker-compose are installed.
在下面的演示中,我们要搭建7个Quorum节点,然后考察节点之间的私有交易是如何运作的。
In the next demonstration, we will build seven Quorum nodes and then look at how private transactions between nodes work.
运行下面的命令来搭建全部7个节点:
Run the following command to build all seven nodes:
默认情况下,使用Tessera交易管理器和Istanbul BTF共识来搭建Quorum网络。因此为了修改为Raft共识算法,我们设置环境变量,然后启动7个节点的后台运行。
By default, use the Tessera trade manager and the Istanbul BTF consensus to set up the Quorum network. So, to change to the Raft consensus algorithm, we set the environmental variables and then start backstage operation of the seven nodes.
你可以运行来查看每个容器的运行状态以及其ID。需要稍等一会儿以便容器启动就绪。
You can run to see the active state of each container and its ID.
如果要快速掌握以太坊区块链开发,推荐汇智网的在线互动课程: java以太坊开发详解 | python以太坊开发详解 | php以太坊开发详解 | C#以太坊开发详解 以太坊智能合约与DApp开发入门 | 以太坊电商DApp实战 | ERC721以太坊通证实战
要在节点上部署智能合约,我们需要运行下面的命令进入该节点的geth控制台:
To deploy a smart contract on a node, we need to run the following command to enter the node's geth console:
命令中的是节点1的容器ID。上面的命令进入节点1的geth控制台,现在我们可以在控制台中进行操作。
The command is the container ID of node 1. The order is entered into the node node node node node node node.
下面我们要运行部署合约的javascript脚本。如果你查看示例代码目录,可以看到在quorum-examples/examples/7nodes目录下有和 文件。在geth控制台运行:
Here we run the deployment contract's javascript script. If you look at the sample code directory, you can see the files under the quorum-examples/examples/7nodes directory. Run at the geth console:
命令执行需要稍等一会儿。一旦部署成功,上面的命令将返回合约地址,记得拷贝下来或者抄到纸上。上述脚本在节点1上部署了一个简单的状态值为42的存储合约,交易是节点1和节点7之间私有的,这意味着其他节点将看不到这个状态值。
The command will be executed for a while. Once deployed, the order will be returned to the contract address, copy it down or copy it on paper. The above script deploys a storage contract with a simple status value of 42 on node 1, the transaction being private between node 1 and node 7, which means that no other node will see the status value.
要验证这一点,我们可以开启节点2的geth终端,使用ABI和合约地址创建合约实例:
To verify this, we can open the geth terminal at No. 2 and create an example of a contract using ABI and the contract address:
果然。
As a matter of fact.
现在进入节点7的geth终端,同样使用ABI和合约地址创建合约实例,然后尝试读取状态值:
Now enter the geth terminal at no. 7 and also create an example of a contract using ABI and the contract address, and then try to read the status value:
和预期一样。
Same as expected.
现在我们尝试在节点7和其他任选节点之间创建一个新的私有交易,调用合约的方法来修改状态值。这需要使用节点的公钥,可以在目录下找到全部7个节点的对应公钥。
Now we try to create a new private transaction between nodes 7 and other optional nodes by calling the contract to modify the status value. This requires using the public key of the node, and you can find the corresponding public key of all seven nodes under the directory.
上面的脚本将设置合约状态值为4,并且仅对指定的节点保持可见。你可以打开这些指定节点 的geth终端查看合约状态值,你看到的应该是4。
The script above will set a contractual status value of 4 and will only be visible for the specified nodes. You can open the geth terminal of these specified nodes to see the contractual status value.
Original: Quorum Enterprises to teach in the neighborhood environment -
(adsbygoogle=window.adsbygoogle || []).push({});
注册有任何问题请添加 微信:MVIP619 拉你进入群
打开微信扫一扫
添加客服
进入交流群
发表评论