区块链技术与应用——BTC挖矿

资讯 2024-06-22 阅读:118 评论:0
转载自:https://blog.csdn.net/SHU15121856/article/details/95227564 reprinted from: ˂span style="color: rgba(0, 255, 1)"˂a h...
美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

转载自:https://blog.csdn.net/SHU15121856/article/details/95227564

reprinted from:

 

比特币系统中有两种节点,一种是全节点,一种是轻节点。

There are two nodes in the Bitcoin system, one full node and the other light node.

  •     一直在线
  •     在本地硬盘上维护完整的区块链信息
  •     在内存中维护UTXO集合,以便快速检验交易的正确性
  •     监听比特币网络上的交易信息,验证每个交易的合法性
  •     监听别的矿工挖出的区块,验证其合法性:
  1.         区块中的每个交易都要合法(包括铸币交易及其出块奖励)
  2.         发布的区块是不是符合难度要求、难度目标阈值的设置是否正确、每两周调整的挖矿难度
  3.         区块是在延伸最长合法链
  •     挖矿:
  1.         决定沿着哪条链挖下去
  2.         决定哪些交易被打包进区块
  3.         决定当出现等长分叉时选择哪个分叉(缺省情况是选择最先接收到的区块的分叉)
  •     不是一直在线
  •     不用保存完整区块链,只要保存每个区块块头(这样和全节点的大小相差大约1000倍)
  •     不用保存全部交易,只需要保存和自己相关的交易
  •     没法验证大多数交易的合法性,只能检验与自己相关的交易的合法性
  •     无法检测比特币网络上发布的区块的正确性
  •     可以验证挖矿的难度(因为挖矿时候计算哈希值只用到了块头信息,而块头信息轻节点是保存了的)
  •     只能检测哪个是最长链,不知道哪个是最长合法链(因为无法检测这条链上所包含的交易都是合法的)


轻节点假设矿工(全节点)大多是有理智的,即假设矿工们不会沿着不合法的链一直挖下去。

比特币网络中大部分节点都是轻节点,如果只是想转账,而不是去挖矿的话,只用轻节点就可以了。

The light node of

当在挖矿过程中发现新发布了一个区块,那么应该停止挖矿,重新从UTXO中取出一系列合法交易组成候选区块,在刚发布的这个区块后面开始挖矿。因为一方面这个区块中的交易可能和刚刚在挖的那个区块有重复,另一个本质的原因就是候选区块的块头有指向前一个区块的哈希指针。因为最新的区块已经变了,这个哈希指针也要跟着改变。

那么这样是不是会因为之前的工作都白费了而很可惜?实际上不可惜,因为前面学过挖矿过程的无记忆性(memoryless,progress free),无论是在刚刚的区块上继续挖,还是新组装一个区块继续挖,成功的概率是一样的。

    比特币系统安全性的保证:因为别人没法伪造你的私钥,也就没法把你账户上的BTC转走。但这个密码学上的保证是要以“系统中大部分节点是诚实的”为前提,即大家不会接受那些不合法的交易进入区块链。

When a new block is discovered in the course of mining, it should be stopped, a series of legitimate deals should be removed from the UTXO and a candidate block should be removed from the newly released block. On the one hand, the trade in this block may be duplicated from the block that was just being dug, and the other is because the section of the `strung's candidate block has a Hashi needle . Because the latest block has changed, the Hashi needle will change.
>br> >br> ; nbsp ; nbsp ; nbsp ; Stweak security system , whether to continue digging in the area just now, or to build a new block >, and the probability of success is the same.

最早时候大家都是用普通计算机来挖矿,但如果专门搞一台计算机来挖矿是很不划算的。因为计算机大部分内存是闲置的(挖矿只要用到很少一部分内存),CPU大部分部件是闲置的(计算哈希值的操作只用到通用CPU中的很少一部分指令),硬盘和其它很多资源也都是闲置的。随着挖矿难度提高,用通用计算机上的CPU挖矿很快就无利可图了。

At the earliest, everyone used a common computer to dig, but it would be uneconomical to specialize in a computer to dig. Because most of the computer's memory is idle (only a small portion of it is used for mining), most CPU parts are idle (only a small part of the generic CPU's instructions are used for calculating Hashi values), and hard disks and many other resources are idle. As mining becomes more difficult, the CPU on a common computer will soon be unprofitable.

GPU主要用来做通用的大规模并行计算,用来挖矿还是会有不少浪费,而且GPU的噪音很大,其中很多部件还是浪费了(如用于浮点数计算的部件)。近些年GPU价格涨得很快,这不仅是DL火热的原因,实际上很多GPU是买来挖矿的。不过现在挖矿的难度已经提高到用GPU也有些划不来了,不会再有那么多人买GPU来挖比特币。

GPUs are mainly used for large-scale parallel calculations of general use, and there is a lot of waste in mining, and there is a lot of noise in GPU, many of which are wasted (e.g. for floating-point calculations). The price of GPUs has increased rapidly in recent years, not only because of the heat of the DL, but in fact many GPUs have been bought to dig. But the difficulty of mining has increased to some point in the GPU, and there will be no more GPUs to dig bitcoins.

ASIC即Application Specific Integrated Circuit(专用集成电路),这之中有专门为了挖矿而设计的芯片,没有多余的电路,干不了别的事,它的性价比是最高的,而且为某一种加密货币设计的ASIC芯片只能挖这一种加密货币的矿,除非两个货币用同一个mining puzzle。

    有些加密货币在刚启动的时候,为了吸引更多的人来挖矿,特意用一个和已有的其它加密货币一样的mining puzzle,这种情况叫merge mining。

研制挖特定加密货币的ASIC芯片需要一定周期,但和研制通用芯片的速度相比已经是非常快的了,如研制比特币挖矿的ASIC芯片大约用一年的时间。不过加密货币的价格变化是比较剧烈的,曾经就发生过比特币价格在几个月内下跌80%,因为加密货币多变的价格,这些挖矿设备的研制风险也是很大的。

挖矿的竞争越来越激烈,定制的ASIC芯片可能用了几个月就过时了,到时候又要买新的ASIC芯片参与竞争。ASIC矿机上市后的大部分利润也就在前几个月,这个设备的迭代也是很块的。

要买ASIC矿机往往要先交钱预定,过一段时间厂商才会发过来。实际上有些黑心厂商在生产出来以后也不交付给用户,声称还没成产好,然后自己在这段黄金时间用矿机挖矿赚取比特币。不过这其实看得出来,比特币系统中算力突然有了大的提高,那一般是某个大的厂商生产出了新的矿机。所以真正赚钱的未必是挖矿的,而是卖矿机的。

ASIC chips designed for an encrypted currency can only dig a mine of this encrypted currency unless the two currencies use the same Mining Puzzle.

为了让通用计算机也能参与挖矿过程,抗ASIC芯片化,有些加密货币采用Alternative mining puzzle,以去对抗那些只为了解决特定mining puzzle而设计出来的ASIC矿机。

In order to allow general-purpose computers to participate in the mining process and to counter the fragmentation of ASIC, some encrypted currencies use the Alternative Mining Puzzle to counter those ASIC miners that have been designed solely to address specific Mining Puzzle.

单个矿工挖矿的收益是很不稳定的,平均出块时间10分钟是对于比特币系统中的所有矿工而言的。一个矿工用一个矿机挖出矿的时间可能要很久,并且除了挖矿之外还要承担全结点的其它责任。

矿池将很多矿工组织起来,一般的架构就是一个矿主(pool manager)全结点去驱动很多矿机,下属矿工只负责计算哈希值,全结点的其它职能只由矿主来承担。有了收益以后再大家一起分配。

The profits from individual miners are very volatile, with an average of 10 minutes for all miners in the Bitcoin system. A miner can dig out a mine with a mine machine for a long time and assumes full node responsibility in addition to mining.
br> the ponds organize many miners. The general structure of to drive many machines at the full node, the subordinate miners merely calculate the Hashi value, and the rest of the node is only for the mine owner.

 

如果矿池中的矿机都是属于同一个机构的,那怎么分配就只是公司内部怎么发工资的问题了。

如果矿机来自不同机构,这时候矿工很可能分布在世界各地,只是都加入了这个矿池。矿工和矿主联系,矿主将要计算的哈希值的任务分配给他,矿工计算好后将结果发给矿主,最终得到出块奖励后一起参与分红。

能否平均分配?即挖到区块后奖励平分给所有矿工。这样就完全是吃大锅饭的模式了,有的矿工完全可以不干活或者少干活,所以需要按矿工的贡献大小进行分配,所以这里也需要工作量证明,来证明每个矿工所做的工作。

每个矿工单打独斗之所以收入不稳定,是因为挖矿难度太大了(相比比特币系统的平均出块时间),所以可以考虑矿池将挖矿的难度降下来。比如本来要求前面有70个0,现在矿池只要求前面有60个0,这样挖到的是一个share(almost valid block),即这个区块差不多在一定程度上是符合难度要求的。矿工挖到这样的区块之后,将其提交给矿主,矿主拿到这些区块并没有什么用,仅仅是因为目标空间是这个问题的解空间的子集,并且求解两个问题的过程是一样的(都是计算哈希),因此这些区块可以作为证明矿工所做的工作量的证明。等到某个矿工真正挖到矿,获取出块奖励之后,再按照大家提交的share的多少来进行分配。

If the machines in the pond belong to the same institution, the distribution is only a question of how to distribute the wages within the company.
>
> >, if the machines come from different institutions, it is likely that the miners will spread around the world, but only join the pond. The miners and miners will contact him, and the miners will be assigned the task of calculating Hashi's value, and the miners will be given the results, and the miners will be given a bonus. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > the miners will be asked to pull the pieces up < < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >

是否会有这样的矿工:挖到share提交给矿主,挖到真正的矿自己发布出去以获取出块奖励?这是没法独吞出块奖励的,因为每个矿工的任务是由矿主来分配的,矿主负责组装好区块,然后交给矿工去不断尝试nonce和CoinBase transaction中的extra nonce,有可能就是讲它们划分一下,然后分配给不同的矿工去做,要注意铸币交易CoinBase transaction中的收款人地址是矿主的地址,不是任何一个矿工的地址
如果自己把铸币交易的地址改成自己的,然后去挖矿,这样提交上去的share矿主是不认可的,所以还是没有用。

Is there a miner who digs into the share to the mine's owner, digs into the real mine and makes it out to get a reward? This is not possible because each miner's task is to be distributed by the miner and the miner is to assemble the blocks and then hand them over to the miner to keep trying the extra noce in nónce and CoinBase transport, probably to divide them and then assign them to the different miner, and If he changes the address of the coin transaction to himself, then digs the mine, so that the share mine owner that goes up there is not acceptable or useful.

矿池之间是有竞争对手的,一种竞争方式就是到对方的矿池里去捣乱,即派遣一些矿工去加入到对方的矿池里去挖矿,只提交share,但挖到真正的矿就将其丢弃掉,故意不提交。然而如果这个对手矿池仍然获得了出块奖励,这些矿工也能参与分红。

There are rivals between the pits, and one way of doing it is to go to each other’s ponds, where some miners are sent to join each other’s ponds to dig for the mines, to send them to share, but to dig the real mine and toss it away deliberately. But if the counterparty’s pond still gets a reward, these miners can also be part of the bonus.

如果没有矿池,如果要发动51%攻击,攻击者要花费大量的硬件成本。有了矿池以后,矿池实际上将算力集中了起来,攻击者未必拥有很多算力,只要吸引大量的不明真相的群众将算力集中到自己的矿池就可以。

在2014年的时候GHash矿池的总算力就超过了比特币系统中总算力的一半,引起了恐慌,然后GHash主动减少了算力,以防止大家对比特币失去信心。

In the absence of a pond, the attacker would have incurred a huge hardware cost if it had not been for 51% of the attack. With the pond, the pool would have actually concentrated its calculations, and the attackers would not necessarily have had a lot of them, as long as they had attracted large numbers of people who did not know the truth to focus their calculations on their own.


如今的矿池的算力还算比较分散,有好几家矿池在竞争,但一个集体的算力完全可以潜伏分散在不同矿池中,等到攻击时再集中起来,矿工要转换矿池是很容易的。


The capacity of today's ponds is fairly dispersed and several are competing, but it is perfectly possible for a collective capacity to be scattered in different ponds and concentrate when attacked, and it is easy for miners to convert them.


    这有点类似云计算中ODC(on demand computing)的概念,平时不需要维护这些节点,需要计算时再召集起来。


andnbsp;   & nbsp; this is kind of like the concept of an ODC in cloud computing, which normally does not need to be maintained, but it needs to be counted again.


矿池要收取管理费,有的收取出块奖励中的一部分,有的收取赚取的交易费。有恶意的矿池可以在发动攻击之前故意将管理费降得很低,吸引大量矿工进入矿池。

The
ponds are charged a management fee, some of which is a part of the incentive, or a trading fee that they earn.

假设有矿池占据了半数以上的算力,能够发动下面这些攻击:
[1]分叉攻击
因为算力占了半数以上,并且矿工挖矿任务被分配开并行进行,分叉出来的链的增长速度很快,最终势必成为最长合法链。

Assuming that the pits occupy more than half of the calculus, the following attacks can be launched:
[1] fork attacks
because of the more than half of the calculus and because the miners' mining tasks are distributed in parallel, the chains out of which are growing rapidly and will eventually become the longest legal chain.


[2]Boycott
假设攻击者不喜欢某个账户A,不允许和A有关的所有交易上链。这时如果有人发布了含有和A有关的交易的区块,它可以很快发布一个不包含这些交易的区块,然后不必等候6个确认区块,立即发布到比特币网络上竞争最长合法链。


[2] Boycott[br] assumes that the attacker does not like an account A and does not allow all transactions related to A to be connected to it. When a block containing a transaction related to A is released, it can quickly issue a block that does not contain those transactions, then without waiting for six confirmed blocks, immediately post the longest legitimate chain of competition on the Bitcoin network.

    这里不必等候的原因是,之前普通分叉攻击等候几个确认区块只是为了让收款人认为已经没问题了,已经成功收款了,这里没有这种顾虑。

在之前学习共识协议时学过,大部分节点是诚实节点时,记账权也可能落在有恶意的节点手里,它完全可以不发布某些交易,但在那种情形下总有诚实的节点愿意发布这些交易,所以是没关系的。

但当在这种情况下,即有恶意的节点算力很大时,却可以始终让某些交易不上链。即完全可以公开抵制某些交易,这样一来别的矿工也不敢随便打包这些交易了,因为很可能自己辛苦挖的矿最后沦为丢弃的区块。

& nbsp; & nbsp; & nbsp; The reason why there is no need to wait is that a few confirmed blocks were waiting for the usual break-off attack just to make sure the payee thought they were clean, and that there were no such concerns.
. >br> > >br> learned from learning the consensus agreement earlier. Most nodes may fall in the hands of honest nodes.


[3]无法进行盗币
不论算力再强,因为没法伪造别人账户的签名(除非获得其私钥),所以没法伪造交易将别人账户上的BTC转走。即便是仗着自己算力强,强行将不合法的区块发布到区块链上并沿着这条链继续延伸,诚实的节点依然不会沿着这条不合法的长链延伸,所以还是没用的。

总结一下,矿池对矿工而言将“很小的概率出大奖”变成了“不小的概率获得小收益”。矿池对整个比特币系统而言存在一定的安全威胁。


strang>[3] No currency theft can take place
, no matter how powerful the calculation is, it is not possible to falsify the signature of another person's account (unless it has a private key), and therefore it is not possible to falsify the transaction to transfer BTC from another person's account. Even if, by their own means, they force illegal blocks to be placed on and continue along the chain, the honest nodes will not continue along this unlawful long chain.
br> >br >, summing up that the pits turn “a very small chance out of a small chance” into a “no small gain” for miners. There is a certain security threat to the entire bitcoin system.
>br>

美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址
文字格式和图片示例

注册有任何问题请添加 微信:MVIP619 拉你进入群

弹窗与图片大小一致 文章转载注明

分享:

扫一扫在手机阅读、分享本文

发表评论
平台列表
美化布局示例

欧易(OKX)

  全球官网 大陆官网

币安(Binance)

  官网

火币(HTX)

  官网

Gate.io

  官网

Bitget

  官网

deepcoin

  官网
热门文章
  • 支付領域投下震撼彈!美國數位銀行Chime疑與GuardPay 神盾支付合作!

    支付領域投下震撼彈!美國數位銀行Chime疑與GuardPay 神盾支付合作!
    2020年,新冠肺炎(COVID-19)疫情加速數位貨幣進展。例如:2019年4月,國際清算銀行(BIS)的調查顯示,在全球66家中央銀行中,沒有一家計畫發行跨境支付的數位貨幣。惟到了2020年10月,BIS支付委員會主席康利夫(Jon Cunliffe)指出,肺炎疫情拉高民眾對無現金支付的需求,迫使各國加快數位貨幣的研發進程日本與韓國於2021年進入數位貨幣試驗階段。直到2019年12月,美國聯邦準備理事會(Fed)都尚無數位貨幣規劃,惟到了2020年2月,Fed已開始研擬...
  • 区块链:交易系统开发指南

    区块链:交易系统开发指南
    播报编辑《区块链:交易系统开发指南》使用通俗易懂的语言,从技术的角度详细介绍了区块链交易系统应有的功能架构及工作原理,让人们能够张开双臂轻松地拥抱区块链技术,享受区块链交易系统带来的惊喜与成就感。《区块链:交易系统开发指南》共分 7 章,第 1~2 章主要介绍区块链及数字货币的基本概念,以及各种公有链的 API 接口;第3~5 章主要介绍区块链交易系统的分类架构及功能; 6 章主要介绍区块链交易系统面临的问题及演进方向;第 7 章对全书做了总结。《区块链:交易系统开发指南》是...
  • 5.14加密货币价格:BTC突破6.2万美元以太坊和山寨币反映市场情绪

    5.14加密货币价格:BTC突破6.2万美元以太坊和山寨币反映市场情绪
    今天,随着比特币(BTC)的价格突破62 000美元的门槛,顶级加密货币的价格反弹了。 此外,以铁大幅上涨,维持在2 900美元的水平。 此外,其他顶尖山硬币,如索拉纳(SOL )、XRP、卡达诺(ADA )也大幅上涨。    今天密钥加密货币价格 1. 比特币价格    在5月14日星期二撰写本文时,比特币价格上升了2.57%,达到62 487.50美元。 另一方面,在过去24小时内,交易量从65.26 % 急剧上升至277亿美元。 与此同时,加密货币的市场价值为...
  • OKEx回应用户质疑:合约交易非期货 平台无机器人

    OKEx回应用户质疑:合约交易非期货 平台无机器人
       热点点 自选股份 数据中心 数据中心 研究和资料中心 资金流动 模拟交易 客户客户 具体来说,OKEx回答用户的问题:合同交易不是期货,平台不是机器人。 金融同步化,3月22日。    昨天下午,OKEx公司就维护先前用户线下的权利问题对同步财务公司作出了回应,指出OKEx公司提供的合同交易不是期货交易,在旗下的业务中没有正式的机器人。 同时,OKEX称,它不会以非法为由对任何投资损失索赔作出答复。 答复全文如下: 同步你的财务! 近日来,...
  • 0.00006694个比特币等于多少人民币/美金

    0.00006694个比特币等于多少人民币/美金
    0.00006694比特币等于多少人民币?根据比特币对人民币的最新汇率,0.00006694比特币等于4.53424784美元/32.5436 16人民币。比特币(BTC)美元(USDT)人民币(CNY)0.000066944.53424784【比特币密码】32.82795436 16比特币对人民币的最新汇率为:490408.64 CNY(1比特币=490408.64人民币)(1美元=7.24人民币)(0.00006694USDT=0.0004846456 CNY)汇率更新时...
标签列表