Btc和Eth的架构及其异同

资讯 2024-07-09 阅读:95 评论:0
先看看架构的相同点和不同点。简单来说,都是由底层(网络) 核心层(区块数据结构&共识或者合约&安全) 应用层构成。 Btc架构...
美化布局示例

欧易(OKX)最新版本

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

APP下载   全球官网 大陆官网

币安(Binance)最新版本

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

APP下载   官网地址

火币HTX最新版本

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

APP下载   官网地址

先看看架构的相同点和不同点。简单来说,都是由底层(网络) 核心层(区块数据结构&共识或者合约&安全) 应用层构成。

Btc架构:

Btc architecture & #xff1a;
crass=

(1)P2P网络层

& #xff08; 1xff09; P2P network layer

完成P2P的组网,网络连接管理,节点状态的维护,为比特币提供数据传输服务;

Completion of the P2P network xff0c; network connection management xff0c; maintenance of node status xff0c; provision of data transfer services for Bitcoin xff1b;

?(2)安全与共识层

♪ #xff08; 2xff09; security and consensus layer

这一层主要向上层提供安全与数据共识服务,保证比特币中的交易数据的安全与区块链(账本)的一致性,又可以细分成三个主要模块:

This layer mainly provides security and data consensus services at the top & #xff0c; secure and block chains for transaction data in Bitcoin & #xff08; book & #xff09; consistency & #xff0c; and can be broken down into three main modules & #xff1a;

加密算法:提供各种加密算法,如SHA,ECDSA数据签名算法,hash算法以及Base58编码算法等等。

Encryption algorithms & #xff1a; various encryption algorithms & #xff0c; e.g. SHA, ECDSA data signature algorithm & #xff0c; ash algorithm and Base58 encoding algorithms, etc.

认证模块:merkle树用来快速验证交易是否包含在区块中;通过加密算法对交易进行签名,生成锁定和解锁脚本;脚本引擎负责解析并执行脚本;

The authentication module xff1a; the Merkle tree is used to quickly verify whether the transaction is included in the block xff1b; the transaction is signed by encryption algorithms xff0c; the locking and clearing script xff1b; the script engine is responsible for the resolution and execution of the script xff1b;

共识模块:比特币中采用的是PoW。

Consensus module xff1a; PoW used in Bitcoin.

?(3)数据层

♪ #xff08; 3xff09; data layer

比特币中的数据,例如交易,区块,区块链等等。另外该层还包括了数据的存储,例如通过level db存储与加载区块链,内存交易池等。

Data in Bitcoin xff0c; e.g. transactions xff0c; blocks xff0c; block chains, etc. The layer also includes data storage xff0c; storage and loading of block chains xff0c; memory pool, etc.

?(4)RPC

RPC服务端的实现,提供JSON API供客户端访问区块链?。

Implementation of the RPC service end & #xff0c; providing JSON API for client access to block chains?

以上4层构成了bitcoind。

The four floors above constitute bitcoin.

?(5)应用层

♪ #xff08; 5xff09; application layer

各种比特币的应用,例如比特币核心提供的bitcoind client。该层主要是作为RPC客户端,通过JSON API与bitcoind交互,享受各种区块链的服务(查询交易信息、挖矿等等)。

Various bitcoin applications & #xff0c; e.g. bitcoincent provided by bitcoin core. The layer is mainly used as RPC client & #xff0c; interacting with bitcoin through JSON API & bitcoin & #xff0c; enjoying various block chains & #xff08; searching for transaction information, mining etc. xff09;

从图中可以看出,区块链实际上并没有用到什么创新的技术,实际上用的还是密码学、共识算法、P2P等一些已有的技术,但是区块链巧妙的将这些已有技术组合起来,形成了一个能够在金融、物联网、医疗、教育等多个行业都能广泛应用的技术体系。
?

The graph shows xff0c; the block chain actually does not use any innovative technology xff0c; it actually uses some of the available technologies xff0c, such as cryptography, consensus algorithms, P2P; but the block chain is so clever as to combine these available technologies xff0c; it creates a technology system that can be widely applied in a variety of sectors, such as finance, material networking, medical care, education, etc.
?

Eth架构:

Eth Architecture #xff1a;

Eth核心知识点:

Eth Core Knowledge Point #xff1a;

区块:可以定义为记录一段时间内发生的交易和状态结果的数据结构,是对当前账本状态的一次共识。

block xff1a; may be defined as the data structure xff0c that records the results of transactions and status over a period of time; it is a common understanding of the current accountbook status.

区块主要由区块头、交易列表和叔区块头三部分组成:

Blocks consist mainly of block heads, lists of transactions and the first three parts of uncle blocks xff1a;

区块头包含:父块的散列值( Prev Hash )、叔区块的散列值( Uncles Hash )、状态树根散列值( stateRoot ) 、交易树根散列值( Transaction Root ) 、收据树根散列值( Receipt Root )、时间戳( Times tamp )、随机数( Nonce )等;交易列表是由矿工从交易池中选择收入区块中的一系列交易;不在主链上的且被主链上的区块通过Uncles 字段收留进区块链的孤块叫做“叔区块” 。

The head of the block consists of xff1a; parent hash value xff08; Prev Hash & #xff09; uncle has hash value xff08; Uncles Hash & #xff09; status tree root hash value xff08; stateRoot & #xff09; trade root hash value xff08; trade Root & #xff09; transaction log value xff09; receipt root hash value xff08; Receipt #xff09; time stamp xff08; Times tamp & #xff09; random number #xff08; Nonce & #xff09; et al. xff1b; transaction list is a series of transactions from the trading pool by miners from the revenue block xff1b; is not on the main chain and is collected by the main section of the chain via Uncles.

以太坊中每个外部账户都由一对密匙定义,即一个私钥和一个公钥。

Each external account in Etheria is defined by a key pair & #xff0c; that is, a private key and a public key.

帐户:在以太坊系统中存在两种类型的账户,分别是外部账户和合约账户。外部账户存储以太币余额状态,而合约账户除了余额还有智能合约及其变量的状态。外部账户( Externally Owned Account, EOA )由私钥来控制,是由用户实际控制的账户。存储以太币余额状态;合约账户是一个包含合约代码的账户

accounts & #xff1a; accounts in Etheria have two types of accounts & #xff0c; are external and contractual accounts, respectively. External accounts are stored in Tai currency balances & #xff0c; contract accounts have smart contracts and their variables in addition to the balance. External accounts & #xff08; External Owned Account, EOA & Xff09; private key control & #xff0c; accounts that are actually controlled by the user. Storage in Tai currency balances xff1b; contract account is an account with contractual code

数据库:区块、交易等数据最终都是存储在Level DB数据库中。Level DB数据库是一个键值对( key-value )数据库, key一般与散列相关,value则是存储内容的RLP编码。

databasexff1a; blocks, transactions, etc. are ultimately stored in the Level DB database. The Level DB database is a key pair of ( Key-value & #xff09; Database xff0c; Key is usually associated with hash xff0c; value is an RLP code for stored content.

以太坊共识:以太坊由于安全事件,分为Etc(经典以太坊)和Eth(以太坊)。Etc使用PoW达成共识,POW即通过工作结果来证明你完成了相应的工作,Eth中的Pow算法是Ethash(Ethash 算法的特点是挖矿的效率基本与CPU 无关,而与内存大小、带宽正相关,目的是去除专用硬件的优势,抵抗ASIC)。

agrees with the Tails & #xff1a; proves that you have done the work because of security incidents & #xff0c; split into Etc & #xff08; Classic & #xff09; and Eth & #xff08; xff09; xff0c; Etc uses PoW to reach consensus & #xff0c; POW to prove that you have done the work & xff0c; Pow algorithm in Eth is Ethash #xff08; Ethash algorithm is characterized by efficiency in mine mining essentially not related to CPU #xff0c; and #xff0c is related to memory size & bandwidth; aims to remove the advantages of specialized hardware #xff0c; resistance to ASIC #xff09;

算法流程:

Algorithm process #xff1a;

1.对于每一个区块,都能通过扫描区块头的方式计算出一个种子( seed ),该种子只与当前区块有关。

For each block xff0c; a torrent can be calculated by scanning the head of the block xff08; seed & #xff09; xff0c; the torrent relates only to the current block.

2.使用种子能产生一个16MB 的伪随机缓存,轻客户端会存储缓存。

Use a torrent to generate a pseudo-random cache of 16 MB xff0c; a light client will store a cache.

3.基于缓存再生成一个1GB 的数据集,称其为DAG 。数据集中的每一个元素都只依赖于缓存中的某几个元素,也就是说,只要有缓存,就可以快速地计算出DAG 中指定位置的元素。挖矿者存储数据集,数据集随时间线性增长。

The data set xff0c; calls it DAG. Each element in the data set depends only on a few elements in the cache xff0c; that is, xff0c; provided there is a cache xff0c; the element specified in the DAG can be quickly calculated. The miner stored the data set xff0c; the dataset grows with timeline.

4.挖矿可以概括为“矿工”从DAG 中随机选择元素并对其进行散列的过程, DAG 也可以理解为一个完整的搜索空间,挖矿的过程就是从DAG 中随机选择元素(类似比特币挖矿中试探合适nonce 的过程)进行散列运算。

Mining can be summarized as the process of random selection and hashing of elements from DAG by “miners”; DAG can also be understood as a complete search space & #xff0c; the process of mining is random selection of elements from DAG & #xff08; the process of testing suitable nence in bitcoin mining & #xff09; and hash operation.

5.验证者只需要花费少量的内存存储缓存就可以了,因为验证者能够基于缓存计算得到DAG 中自己需要的指定位置的元素,然后验证这些指定元素的散列是不是小于某个散列值,也就是验证“矿工”的工作是否符合要求。

The Certifier only needs to spend a small amount of memory storage cache to xff0c; because the Certifier is able to obtain, on the basis of the cache calculation, the elements of the DAG that it needs to specify a location xff0c; then verify whether the hash of these specified elements is smaller than a hash value xff0c; that is, verify whether the work of the “miner” meets the requirements.

Eth使用PoS进行共识计算。PoS 即基于网络参与者目前所持有的数字货币的数量和时间进行利益分配,是一种对货币所有权的证明。主要为两种类型:基于链的PoS 和BFT (Byzantine Fault Tolerant ,拜占庭容错)风格的PoS 。

Eth uses PoS for consensus calculations. PoS is a distribution of benefits based on the number and time of digital currencies currently held by network participants & #xff0c; it is a certificate of ownership of the currency. It is mainly two types & #xff1a; chain-based PoS and BFT (Byzantine Fault Toolerant & #xff0c; Byzant for misbehaviour #xff09; style PoS.

在基于链的PoS 中,该算法在每个时隙内伪随机地从验证者集合中选择一个验证者(比如,设置每l0s 一个周期,每个周期都是一个时隙),给予验证者创建新区块的权利,但是验证者要确保该块指向最多的块(指向的上一个块通常是最长链的最后一个块) 。因此,随着时间的推移,大多数的块都收敛到一条链上。

In the chain-based PoS & #xff0c; the algorithm selects a certifier & #xff08; e. g. #xff0c; sets a cycle & #xff0c per l0s; each cycle is a time gap & #xff09; #xff0c; gives the certifier the right to create a new block xff0c; but the certifier ensures that the block is pointed to the largest xff08; the pointer is usually the last of the longest chain xff09; #xff0c; over time #xff0c; most blocks fall into a chain.

在BFT 风格的PoS 中,分配给验证者相对的权利,让他们有权提出块并且给被提出的块投票,从而决定哪个块是新块,并在每一轮选出一个新块加入区块链。在每一轮中,每一个验证者都为某一特定的块进行“投票”,最后所有在线和诚实的验证者都将“商量”被给定的块是否可以添加到区块链中,并且意见不能改变。

In the BFT-style PoS & #xff0c; the relative rights assigned to the certifying officers & #xff0c; the right to propose blocks and give the proposed ballot & #xff0c; thus deciding which block is the new & #xff0c; and choosing a new block to add to the block chain in each round. & #xff0c in each round & #xff0c; each certifying person “voting” for a given block & #xff0c; and finally, all online and honest certifying officers will “negotiate” whether the given block can be added to the block chain #xff0c; and the opinion cannot be changed.

?

最后我们来看Btc和Eth的不同之处

1. Btc以虚拟货币 P2P为核心,不需要智能合约。Eth需要做智能合约

Btc uses the virtual currency P2P as a core & #xff0c; no smart contract is required. Eth requires an intelligent contract .

从交易报文中的字段可以看到,Eth可以在「Input Data」栏位输入程式码,部署或操作智慧合约;Btc则只能在「OP_RETURN DATA」栏位单纯做备注。

From the fields in the transaction report & #xff0c; Eth can enter the code in the Input Data field & #xff0c; deploy or operate the Smart Contract & #xff1b; Btc can only make a simple note in the OP_RETURN DATA field.

2.从交易模型来看。Eth更像是Account Model(银行账本),Btc则是UTXO(Unspent Transaction Output)的架构。

According to the transaction model, Eth is more like the structure of Account Model( bank books & #xff09; & #xff0c; Btc is UTXO& #xff08; Unspent Transport Output)

以太坊的架构类似银行帐户,有资料库在记录每个帐号和帐号的余额,透过交易来更新。如下图所示,地址14c5f8ba在一笔交易中发送了10个eth给地址bb75a980 ,于是在交易过后双方的以太币数量便被更新了。

It is similar to a bank account & #xff0c; there is a database that records the balance of each account number and account number & #xff0c; it is updated through a transaction. The following figures show & #xff0c; address 14c5f8ba sent 10 eths to address bb75a980 & #xff0c in a transaction; the number of both parties' NTs has been updated since the transaction passed.

比特币类似钱堆,我们的地址比较像是能够操控这些钱堆的钥匙。可以把钱堆凑在一起做交易;也可以把一坨钱堆拆开来交易。每一笔交易可以有多个input(钱堆),交易后也可以变成一或多个新的钱堆。

Bitcoin is like a pile of money xff0c; our address is more like a key that can manipulate these piles of money. You can put the money together for a transaction xff1b; you can split up a pile of money. Each transaction can have more than one inputxff08; xff09; xff0c; you can turn it into one or more new piles of money after the transaction.

Btc的UTXO的架构,其实是解决了Account model同一个地址(帐户)无法同时进行两笔交易的问题(Account model一定会有先后顺序,即Nonce)。Eth以太币为了避免双重花费(Double Spending:同一笔钱被花了两次),会以Nonce来标注每一笔交易的先后次序,若同时发送多笔交易,一但前面有一笔交易卡住,则后面的交易也都会跟着塞住。

The architecture of the UTXO of Btc & #xff0c; it actually solved the same address as the Account Model & #xff08; account & #xff09; problems in which it was not possible to conduct two transactions simultaneously & #xff08; Account Model must have a sequence & #xff0c; i.e., Nonce #xff09; Eth Eth Ethnexcoco to avoid double costs & #xff08; Double Spending #xff1a; the same money was spent twice xff09; #xff0c; the order of each transaction xff0c; if more transactions were sent at the same time #xff0c; a previous transaction was blocked xff0c; and the subsequent transaction was blocked.

那么明显可见,打个不恰当的比喻:Btc可以同时多线程 异步的,Eth是单线程 同步的(类似于io模型中,异步IO和同步阻塞IO)

is so obvious xff0c; an inappropriate metaphor xff1a; Btc xff0c, which can be multilined at the same time xff0c; Eth is single-line xff08; similar to xff0c in the Io model; asynchronous IO and synchronous block IOxff09;

3. Btc的算法注定通货紧缩,看起来他的货币不是用来流通

Btc's algorithms are destined for deflation #xff0c; it seems his currency is not for circulation.

4. POS机制让ETH持币人终于有了发言的机会,ETH的拥有者能够决定它未来的发展方向。

The POS mechanism has finally given the ETH bearer the opportunity to speak xff0c; the owners of ETH have been able to determine its future direction.

5. 比特币的hash算法很容易通过ASICs(应用型专用集成电路)进行优化,经过定制的ASICs唯一能做的事情就是挖矿,但挖矿效率却比普通GPU高好几个数量级。以太坊平台的Ethash算法是memory hard的,几乎无法通过ASICs进行优化,大矿池和普通人相比并没有明显的优势。

The bitcoin hash algorithm can easily be optimized through ASICs, the only thing custom-made ASICs can do is dig, but mining efficiency is several orders of magnitude higher than ordinary GPUs. The Ethash algorithm for the Taiyo platform is xff0c of memory hard; it is almost impossible to optimize xff0c through ASICs; there is no significant advantage between large ponds and ordinary people.

6. 应用落地及普及方面,似乎Eth得到了更广泛的支持。微软、摩根大通、英特尔牵头成立的EEA(企业以太坊联盟)旨在开发企业级区块链解决方案,用于供应链来源跟踪、银行间支付、参考数据、证券结算等多个领域。

The EEA, led by Microsoft, Morgan Chase and Intel, aims to develop enterprise-level block chain solutions & #xff0c; for supply chain source tracking, inter-bank payments, reference data, securities settlement, etc.

7. 社区可编程性:以太坊致力于将自己发展为一个计算平台。以太坊上可以运行各种各样的分布式应用,并且为此提供了开发框架,稍有编程基础的人就可以在以太坊上开发出属于自己的应用。

Community programability & #xff1a; Ether's commitment to develop itself as a computing platform. Ether's ability to run a variety of distributed applications & #xff0c; and to provide a framework for development & #xff0c; those with a modest programming base can develop their own applications in Ether.

?

美化布局示例

欧易(OKX)最新版本

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

APP下载   全球官网 大陆官网

币安(Binance)最新版本

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

APP下载   官网地址

火币HTX最新版本

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

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

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

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

分享:

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

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

欧易(OKX)

  全球官网 大陆官网

币安(Binance)

  官网

火币(HTX)

  官网

Gate.io

  官网

Bitget

  官网

deepcoin

  官网
热门文章
  • 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)汇率更新时...
  • 0.00003374个比特币等于多少人民币/美金

    0.00003374个比特币等于多少人民币/美金
    0.00003374比特币等于多少人民币?根据比特币对人民币的最新汇率,0.00003374比特币等于2.2826 1222美元/16.5261124728人民币。比特币(BTC)美元(USDT)人民币(CNY)0.00003374克洛克-0/22216.5261124728比特币对人民币的最新汇率为:489807.72 CNY(1比特币=489807.72人民币)(1美元=7.24人民币)(0.00003374USDT=0.0002442776 CNY)。汇率更新于2024...
  • 0.00015693个比特币等于多少人民币/美金

    0.00015693个比特币等于多少人民币/美金
    0.000 15693比特币等于多少人民币?根据比特币对人民币的最新汇率,0.000 15693比特币等于10.6 1678529美元/76.86554996人民币。比特币(BTC)【比特币价格翻倍】美元(USDT)人民币(CNY)0.000/克洛克-0/5693【数字货币矿机】10.6 167852976.8655254996比特币对人民币的最新汇率为:489,807.72 CNY(1比特币= 489,807.72人民币)(1美元=7.24人民币)(0.00015693 U...
  • 区块链社区有哪些?区块链社区是什么?

    区块链社区有哪些?区块链社区是什么?
    展开全文...
  • ?在 App?Store 上的「Opencord: Web3 Social Platform」

    ?在 App?Store 上的「Opencord: Web3 Social Platform」
    Opencord is the Web 3.0 social platform built for DAOs. It is designed for the efficient connections of DAOs, the seamless connections of DApps, and the like-mindedness connections of DAO friends.We make it easy for you t...
标签列表