上一节我们已经完成了整个Besu区块链网络的搭建,本章将介绍通过Alethio区块链浏览器对上链数据进行查看和校验。同时,由于Besu区块链是可以通过EthSigner来实现带权限(token)访问的,那么在权限访问下还需要添加explorer-besu-plugin来实现,这个也会在本节中一并叙述。
In the previous section, we have completed the construction of the entire Besu block chain network xff0c; this chapter will describe the viewing and validation of the upper chain data through the ALETHio block chain browser. xff0c; since the Besu block chain can be accessed through EthSigner xff08; token) visited xff0c; then an explorer-besu-plugin to xff0c; this will also be described in this section.
Alethio浏览器
上面提到的Alethio区块链浏览器其实是一个专门用于以太坊区块链实现可视化的交互平台,全称(以下简称“AELE”)。
The above-mentioned Alethio block chain browser is in fact an interactive platform dedicated to visualization in the Taiwan block chain & #xff0c; full & #xff08; hereinafter referred to as “AELE” & #xff09;
有浏览过的小伙伴应该都清楚AELE是Besu官方推荐的以太浏览器,它开源且界面支持中文这对于中国地区开发者算是相当友好了(连在线翻译的工作都可以省了),并且不用过多的配置可以说说是“开箱即用”级别的了推荐各位使用。
The small partners who have been viewed should be aware that AELE is an official Besu-recommended Ether Browser & #xff0c; that its open source and interface to support Chinese is quite friendly to Chinese district developers & #xff08; that even online translation can save & #xff09; #xff0c; and that it can be used by those recommended at the “open box or use” level without too much configuration.
接下来将分别讲述“不带token”和“带token”的两种实现方式。
2; 6bn_ 61; 2& 6bw_6e_61;
不带token
或许有小伙伴会问,为什么还会有不带token的解决方案呢?基于平台或者系统层面Besu私有链(或联盟链)应“受限访问”才能保证接入安全,关于这点我主要有以下3点考虑:
There may be small partners asking xff0c; why there are solutions without token xff1f; besu-based private chain xff08 at the platform or system level; or Union chain xff09; “limited access” to ensure access xff0c; I have three main considerations xff1a;
- 若只是说“访问白名单”功能的话,建议是在服务器层面进行设定而不是直接在区块链节点中做设定。这是考虑到商业使用前提下宿主机本来就存在访问策略。只需要统一管理即可不需要又另外设定徒增运维难度;
- 由于数据上链都需要先经过EthSigner校验token的有效性,在分布式高并发下网络开销可能会造成性能问题。即使不考虑网络因素,EthSigner节点使用“多租户”模式下也会受制于本地硬件性能(这里跟我使用本地密钥存储方式有关,会产生大量磁盘IO引起性能问题,不过可以通过使用固态硬盘来解决这个问题,只不过成本略高)。
- 获取token进行交易一般是在“隐私交易”场景下作为安全防御机制使用,若不涉及隐私交易的情况下可忽略这部分功能(坦白说,隐私交易这种业务场景非常少,因为需要企业具备资质才能做,并且区块链“受信”问题几乎是无解的。即使你的区块链技术能够公开且通过第三方安全审查,但仍有可能达不到“受信”的要求,至于个中原因相信大家应该懂的)。
回归主题…因此这里其实可以直接使用Besu官方的解决方案 alethio/ethereum-lite-explorer:latest 来部署区块链浏览器。
The theme of return... so it's actually possible to deploy block-chain browsers using the official Besu solution aethio/etheium-lite-explorer:latest.
还是老样子,先下载最新的镜像:
Still the same #xff0c; downloading the latest mirror #xff1a;
接着就能够根据以下命令创建
Then it can be created according to the following command:
启动之后访问 http://192.168.200.206/ 就能够看到效果了,如下图所示
will be able to see effects xff0c; 那带token的时候要怎么做呢?为什么我按照网上说的做但是无法登录的呢?为什么alethio/ethereum-lite-explorer整合插件不成功的呢?… 那是因为网上说的都只说了一半,哪怕是Besu官网。 What do you do with token? #xff1f; why do I do what I say on the Internet but can't log in? #xff1f; why does the aethio/etheium-lite-explorer integration plugin not work? #xff1f;...that's because what I say on the Internet is only half #xff0c; even the Besu network. 首先这个时候我们就按照Besu官方说的那样直接使用版本了。为什么?因为区块链,需要账号登录拿到后方可操作,一般的AELE是不带Header访问的因此无法使用。怎么办呢?那就看一下AELE的Github文档是怎样解决这个问题吧。 First of all, we're using the version directly, as Besu officially said. Why xff1f; because the block chain xff0c; because account login is required to operate xff0c; the normal AELE is not accessible without Header and therefore is not available. What should we do? xff1f; then look at AE's Github file. 如上图所示,我们若要访问带权限的区块链系统需要增加一个验证身份的插件,在AELE处理eth-lite之前就需要先做身份验证。下方还给了个Besu插件的例子连接。如下图所示: xff0c, as shown in the figure above; we need to add an identification plugin xff0c to our access to the section chain system with access rights; we need to authenticate before AELE processeth-lite. An example link to the Besu plugin is given below. xff1a, as shown in the figure below; 按上图所述,的确是存在针对besu私有链登录的插件 & #xff0c as shown above; there are plugins for besu private chain login 并且这里已经给出配置例子,。 And here's an example of configuration #xff0c; 接着还要更新eth-lite的适配器项,。 This will be followed by the updating of the eth-lite adaptor & #xff0c; 在docker hub中只有latest和1.0.3版本,在这里我们选择的是1.0.3版本。如果使用的是latest版本无论config.json怎样修改都会报错,哪怕按照我以下将要说明的方式去改也会报错,但是1.0.3就不会(实践出真知,踩过的坑不想别人再踩了)。 Only latest and 1.0.3 & #xff0c in the docker hb; here we choose version 1.0.3. If a latest version is used, regardless of config.json's modification, it's wrong xff0c; it's wrong xff0c; but it's not ff08; practice is true ff0c; the pedested pit does not want anyone to step on ff09; 哦,原来config.json是从config.default.json演变过来的。那直接将config.default.json拷贝过去改名就可以了。 Oh #xff0c; former config.json evolved from config.default.json. That's a direct copy of config.default.json's name. 这种做法不能说不对,但是可以有更好的办法…最好的做法当然是直接从镜像中拷贝出来。先从docker hub中将1.0.3的镜像下载下来后先简单的运行一次。 This doesn't mean wrong #xff0c; but there's a better way... the best thing is to copy it directly from the mirror. Download the 1.03 mirror from the docker hub and run it once. 然后使用docker cp命令将镜像内的config.json文件拷贝到本地。 Then use the docker cap command to copy the config.json file in the mirror to the local site. 在这个基础上进行loginUrl和nodeUrl的修改,如下图所示: On this basis, changes to loginUrl and nodeUrl xff0c; xff1a as shown in the figure below; 由于这个AELE是部署在我本机不是CentOS中因此ip为92.168.1.164。所有内容修改完成后就可以启动AELE镜像 Since this AELE is deployed on my current plane, not on Centos, the ip is 92.168.1.164. The AELE mirror can be activated once all content changes have been completed. 由于是映射80端口,所以直接通过localhost进行访问,如下图: As it is a map of 80 ports & #xff0c; direct access via localhost & #xff0c; figure #xff1a below; 访问时会让输入用户名和密码,这里输入创建的用户名和密码即可。进入后就能够正常访问了,如下图: Access will allow the username and password to be entered xff0c; this is enough to enter the username and password created. Access will allow normal access to xff0c; chart xff1a below; 为了验证区块链的可用性,我们使用Postman调用一下Besu区块上链API操作,稍微写个Java工具将字符串转换成16进制的hex编码(这里有点懒了,其实可以直接用httpclient写个调用就可以了,ε=(′ο`*)))唉),如下图: In order to verify the availability of block chains & #xff0c; we use Postman to call the upper chain of the Besu block API & #xff0c; slightly write a Java tool to convert the string into a hexadecimal hex code & #xff08; there's a bit of xff0c; it's actually possible to write a call directly from httpclitt ff0c;#61;xff40;*) xff09;xff0c; and #xff1a below; 如上图所示,得到的编码为之后通过JSON RPC接口发起了区块链的上链操作,如下图: xff0c, as shown in the figure above; the code obtained is that the upper chain operation of the block chain was subsequently launched through the JSON RPC interface xff0c; the following figure xff1a; 最终得到tx码返回。,我们将这段tx码拷贝到AELE中通过查询定位到区块内容。如下图: & #xff0c; we'll copy this tx code into AELE and locate it to block content by query. 如上图所示,AELE得知区块链刚刚发生了一次事务提交,在区块中存在数据(INPUT DATA) xff0c, as shown in the figure above; AELE learned that a service had just been submitted to xff0c; data existed in blocks xff08; INPUT DATA) 至此数据上链简单验证完毕。 The data chain is simply validated. 有小伙伴也许会问,为什么上图中显示交易GAS PRICE是0Gwei?大家还记得在《【区块链】HyperLedger Besu集群服务》一文中奖min-gas-price设置为0么,就是在那时候设置上链无需费用,这也是算PoA(权威证明)的一种特色吧,如下图: xff0c may be asked by a small partner; why the trade in GAS PRICE is 0Gwei? in the above figure; remember the Min-gas-price set to 0 in the HyperLedger Besu Cluster Services in the [block chain] & #xff0c; i.e. xff0c; this is also PoA( #xff09; a special feature of #xff0c; #xff1a below;
带token
最后给出了在Docker中运行的启动用脚本,这里主要说的是让我们另外开一个config.json文件在docker run语句中进行挂载(-v),用这个新建config.json文件覆盖掉容器中的config.json文件。同时,我们也留意到这里让我们pull的docker镜像是,那事不宜迟就先pull镜像。
这个时候可能就会有小伙伴会问,我都不知道config.json文件怎么写,那应该怎么修改才对呢?
注册有任何问题请添加 微信:MVIP619 拉你进入群
打开微信扫一扫
添加客服
进入交流群
发表评论