Forourtimestampnetwork,weimplementtheproof-of-workbyincrementinganonceinthe block untilavalueisfoundthatgivestheblock'shashtherequiredzerobits.OncetheCPUefforthasbeenexpendedtomakeitsatisfytheproof-of-work,theblockcannotbechangedwithoutredoingthework.Aslaterblocksarechainedafterit,theworktochangetheblockwouldincluderedoingalltheblocksafterit.
在我们的时间戳网络中,我们是这样实现工作证明的:不断在区块之中增加一个随机数(Nonce),直到一个满足条件的数值被找到;这个条件就是,这个区块的哈希以指定数量的0开头。一旦CPU的耗费算力所获的的结果满足工作证明,那么这个区块将不再能被更改,除非重新完成之前的所有工作量。随着新的区块不断被添加进来,改变当前区块即意味着说要重新完成所有其后区块的工作。
Theproof-of-workalsosolvestheproblemofdeterminingrepresentationinmajoritydecisionmaking.Ifthemajoritywerebasedonone-IP-address-one-vote,itcouldbesubvertedbyanyoneabletoallocatemanyIPs.Proof-of-workisessentiallyone-CPU-one-vote.Themajoritydecisionisrepresentedbythelongestchain,whichhasthegreatestproof-of-workeffortinvestedinit.IfamajorityofCPUpoweriscontrolledbyhonestnodes, thehonest chainwillgrowthefastestandoutpaceanycompetingchains.Tomodifyapast block,anattackerwouldhavetoredotheproof-of-workoftheblockandallblocksafteritandthencatchupwithandsurpasstheworkofthehonestnodes.Wewillshowlaterthattheprobabilityofaslowerattackercatchingupdiminishesexponentiallyassubsequentblocksareadded.
工作证明同时解决了如何决定谁能代表大多数做决定的问题。如果所谓的大多数是基于一个IP地址一票的方式决定的话,那么任何一个可以搞定很多IP地址的人就可以被认为是大多数。工作证明本质上来看,是一个CPU一票。所谓的大多数决定是由最长链所代表的,因为被投入最多工作的链就是它。如果大多数CPU算力被诚实的节点所控制,那么诚实链成长最为迅速,其速度会远超其他竞争链。为了更改一个已经产生的区块,攻击者将不得不重新完成那个区块以及所有其后区块的的工作证明,而后还要追上并超过诚实节点的工作。后文展示为什么一个被拖延了的攻击者能够追上的可能性将随着区块的不断增加而指数级降低。
Tocompensateforincreasinghardwarespeedandvaryinginterestinrunningnodesovertime,theproof-of-workdifficultyisdeterminedbyamovingaveragetargetinganaveragenumberofblocksperhour.Ifthey'regeneratedtoofast,thedifficultyincreases.
为了应对硬件算力综合的不断增加,以及随着时间推进可能产生的节点参与数量变化,工作证明难度由此决定:基于平均每小时产生的区块数量的一个移动平均值。如果区块生成得过快,那么难度将会增加。
Thestepstorunthenetworkareasfollows:
Newtransactionsarebroadcasttoallnodes.Eachnodecollectsnewtransactionsintoa block.Eachnodeworksonfindingadifficultproof-of-workforitsblock.Whenanodefindsaproof-of-work,itbroadcaststheblocktoallnodes.Nodesaccepttheblockonlyifalltransactionsinitarevalidandnotalreadyspent.Nodesexpresstheiracceptanceoftheblockbyworkingoncreatingthenextblockinthechain,usingthehashoftheacceptedblockastheprevioushash.
运行网络的步骤如下:
所有新的交易向所有节点广播;每个节点将新交易打包到一个区块;每个节点开始为此区块找一个具备难度的工作证明;当某个区块找到其工作证明,它就要将此区块广播给所有节点;众多其他节点当且只当以下条件满足才会接受这个区块:其中所有的交易都是有效的,且未被双重支付;众多节点向网络表示自己接受这个区块的方法是,在创建下一个区块的时候,把被接受区块的哈希当作新区块之前的哈希。
Nodesalwaysconsiderthelongestchaintobethecorrectoneandwill keep workingonextendingit.Iftwonodesbroadcastdifferentversionsofthenext block simultaneously,somenodesmayreceiveoneortheotherfirst.Inthatcase,theyworkonthefirstonetheyreceived,butsavetheotherbranchincaseitbecomeslonger.Thetiewillbebrokenwhenthenextproof-of-workisfoundandonebranchbecomeslonger;thenodesthatwereworkingontheotherbranchwillthenswitchtothelongerone.
节点始终认为最长链是正确的那个,且会不断向其添加新数据。若是有两个节点同时向网络广播了两个不同版本的下一个区块,有些节点会先接收到其中一个,而另外一些节点会先接收到另外一个。这种情况下,节点将在它们先接收到的那个区块上继续工作,但也会把另外一个分支保存下来,以防后者成为最长链。当下一个工作证明被找到,而其中的一个分支成为更长的链之后,这个暂时的分歧会被打消,在另外一个分支上工作的节点们会切换到更长的链上。
Newtransactionbroadcastsdonotnecessarilyneedtoreachallnodes.Aslongastheyreachmanynodes,theywillgetintoa block beforelong.Blockbroadcastsarealsotolerantofdroppedmessages.Ifanodedoesnotreceiveablock,itwillrequestitwhenitreceivesthenextblockandrealizesitmissedone.
新的交易不见得一定要广播到达所有的节点。只要到达足够多的节点,那么没多久这些交易就会被打包进一个区块。区块广播也容许一些消息被丢弃。如果一个节点并未接收到某个区块,那么这个节点会在它接收到下一个区块的时候意识到自己错失了之前的区块,因此会发出补充那个遗失区块的请求。
Byconvention,thefirsttransactionina block isaspecialtransactionthatstartsanewcoinownedbythecreatoroftheblock.Thisaddsanincentivefornodestosupportthenetwork,andprovidesawaytoinitiallydistributecoinsintocirculation,sincethereisnocentralauthoritytoissuethem.Thesteadyadditionofaconstantofamountofnewcoinsisanalogoustogoldminersexpendingresourcestoaddgoldtocirculation.Inourcase,itisCPUtimeandelectricitythatisexpended.
按照约定,每个区块的第一笔交易是一个特殊的交易,它会生成一枚新的硬币,所属权是这个区块的生成者。这么做,使得节点支持网络有所奖励,也提供了一种将硬币发行到流通之中的方式 在这个系统中,反正也没有一个中心化的权威方去发行那些硬币。如此这般稳定地增加一定数量的新硬币进入流通,就好像是黄金开采者不断耗用他们的资源往流通之中增加黄金一样。在我们的系统中,被耗用的资源是CPU工作时间和它们所用的电力。
Theincentivecanalsobefundedwithtransactionfees.Iftheoutputvalueofatransactionislessthanitsinputvalue,thedifferenceisatransactionfeethatisaddedtotheincentivevalueofthe block containingthetransaction.Onceapredeterminednumberofcoinshaveenteredcirculation,theincentivecantransitionentirelytotransactionfeesandbecompletelyinflationfree.
奖励还可以来自交易费用。如果一笔交易的输出值小于它的输入值,那么其中的差额就是交易费;而该交易费就是用来奖励节点把该交易打包进此区块的。一旦既定数量的硬币已经进入流通,那么奖励将全面交由交易手续费来完成,且绝对不会有通货膨胀。
Theincentivemayhelpencouragenodestostayhonest.IfagreedyattackerisabletoassemblemoreCPUpowerthanall thehonest nodes,hewouldhavetochoosebetweenusingittodefraudpeoplebystealingbackhispayments,orusingittogeneratenewcoins.Heoughttofinditmoreprofitabletoplaybytherules,suchrulesthatfavourhimwithmorenewcoinsthaneveryoneelsecombined,thantounderminethesystemandthevalidityofhisownwealth.
奖励机制也可能会鼓励节点保持诚实。如果一个贪婪的攻击者能够网罗比所有诚实节点都更多的CPU算力,他必须做出一个选择:是用这些算力通过把自己花出去的钱偷回来去欺骗别人呢?还是用这些算力去生成新的硬币?他应该能够发现按照规则行事是更划算的,当前规则使得他能够获得比所有其他人加起来都更多的硬币,这显然比暗中摧毁系统并使自己的财富化为虚无更划算。
Oncethelatesttransactioninacoinisburiedunderenoughblocks,thespenttransactionsbeforeitcanbediscardedtosavediskspace.Tofacilitatethiswithoutbreakingtheblock'shash,transactionsarehashedinaMerkleTree[@doi:10.1109/sp.1980.10006; @tag:massias; @doi:10.1145/266420.266430],withonlytherootincludedintheblock'shash.Oldblockscanthenbecompactedbystubbingoffbranchesofthetree.Theinteriorhashesdonotneedtobestored.
如果一枚硬币最近发生的交易发生在足够多的区块之前,那么,这笔交易之前该硬币的花销交易记录可以被丢弃 目的是为了节省磁盘空间。为了在不破坏该区块的哈希的前提下实现此功能,交易记录的哈希将被纳入一个Merkle树[7、2、5]之中,而只有树根被纳入该区块的哈希之中。通过砍掉树枝方法,老区块即可被压缩。内部的哈希并不需要被保存。
A block headerwithnotransactionswouldbeabout80bytes.Ifwesupposeblocksaregeneratedevery10minutes,80bytes*6*24*365=4.2MBperyear.Withcomputersystemstypicallysellingwith2GBofRAMasof2008,andMoore'sLawpredictingcurrentgrowthof1.2GBperyear,storageshouldnotbeaproblemeveniftheblockheadersmustbekeptinmemory.
一个没有任何交易记录的区块头大约是80个字节。假设每十分钟产生一个区块,80字节乘以6乘以24乘以365,等于每年4.2M。截止2008年,大多数在售的计算机配有2GB内存,而按照摩尔定律的预测,每年会增加1.2GB,即便是区块头必须存储在内存之中也不会是什么问题。
HuobiGlobal
Itispossibletoverifypaymentswithoutrunningafullnetworknode.Auseronlyneedsto keep acopyofthe block headersofthelongestproof-of-workchain,whichhecangetbyqueryingnetworknodesuntilhe'sconvincedhehasthelongestchain,andobtaintheMerklebranchlinkingthetransactiontotheblockit'stimestampedin.Hecan'tcheckthetransactionforhimself,butbylinkingittoaplaceinthechain,hecanseethatanetworknodehasacceptedit,andblocksaddedafteritfurtherconfirmthenetworkhasacceptedit.
即便不用运行一个完整网络节点也有可能确认支付。用户只需要有一份拥有工作证明的最长链的区块头拷贝 他可以通过查询在线节点确认自己拥有的确实来自最长链 而后获取Merkle树的树枝节点,进而连接到这个区块被打上时间戳时的交易。用户并不能自己检查交易,但,通过连接到链上的某个地方,他可以看到某个网络节点已经接受了这个交易,而此后加进来的区块进一步确认了网络已经接受了此笔交易。
以上就是比特币白皮书原版(附比特币白皮书中文版)的全部内容,望能这篇比特币白皮书原版(附比特币白皮书中文版)可以帮助您解决问题,能够解决大家的实际问题是非常好学习网一直努力的方向和目标。