以太坊一个区块可以包含多少交易

资讯 2024-06-21 阅读:118 评论:0
今天在做以太坊开发时,突然想到一个问题,以太坊一个区块包含的交易个数由什么决定?Today, in the development of Etheria, a question comes to mind: What determines...
美化布局示例

欧易(OKX)最新版本

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

APP下载   全球官网 大陆官网

币安(Binance)最新版本

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

APP下载   官网地址

火币HTX最新版本

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

APP下载   官网地址

今天在做以太坊开发时,突然想到一个问题,以太坊一个区块包含的交易个数由什么决定?

Today, in the development of Etheria, a question comes to mind: What determines the number of transactions included in an Etheraya block?

如果交易池中有足够的交易,一个区块最多可容纳多少交易?

If there are enough transactions in the pool, how many transactions can a block accommodate?

带着这个问题,我阅读了一下go-ethereum中关于挖矿的源代码,找到了答案。

With this question, I read the source code of the go-etheium for mining, and I found the answer.

先抛出结论:

drops its conclusion:

影响一个区块交易个数的因素有两个:

Two factors influence the number of blocks traded:

  1. 交易池中的交易个数。这个很好理解,交易池的交易个数直接决定了一个矿工可以打包多少交易到区块中。
  2. 区块允许的GasLimit。GasLimit又由父块GasLimit、GasFloor和GasCeil共同决定(1.8版本以前只受父块GasLimit影响),当交易的gas总计大于GasLimit时,交易将不在打包的区块中。

其中gasFloor和gasCeil是在geth的中mine的两个配置项。详见文档:https://geth.ethereum.org/docs/interface/command-line-options

Of these, GasFloor and GasCeil are two configurations for centralmine in Geth. For details, see the document:

image.png

结论主要从"go-ethereum/miner/worker.go"源文件中得出。worker相当于一个挖矿工人,负责具体的挖矿工作流程。在worker对象中有一个“commitNewWork”方法,是创建一个新的区块,其中计算了该区块的GasLimit和需要处理的交易池中的交易。相关代码如下:

The conclusions are drawn mainly from the source document ".


“commitNewWork”方法中获取到交易池中的交易后将交易提交给了“commitTransactions”方法对交易进行验证。

Once the transaction in the trading pool was captured in the “committeeNewWork” method, the transaction was submitted to the “committeeTransactions” method for validation of the transaction.


将交易提交给“commitTransaction”方法后,回调用

Call back when the transaction is submitted to the "committeeTransation" method


在ApplyTransaction方法中会将gasPool中的gas值减去该笔交易的gas,当gasPool的gas值小于21000时,剩下的交易将不在打包的该区块中。

In the ApplyTransaction method, the gas value in GasPool is subtracted from the gas in the transaction, and when the gasPool value is less than 21,000, the remainder of the transaction will not be in the packaged block.

回头在来看一下区块中的GasLimit是怎么计算的。

Turn around and see what GasLimit calculates in the block.

core.CalcGasLimit(parent, w.config.GasFloor, w.config.GasCeil)方法在“go-ethereum/core/block_validator.go”,代码如下:

CalcGasLimit (parent, w.config. GasFloor, w.config. GasCeil) at ), code as follows:


计算GasLimit的策略很有意思,受父块的GasLimit、挖矿的gas上限gasCeil和gas下限gasFloor三者共同决定。

The strategy for calculating GasLimit is interesting and is determined jointly by the fatherless GasLimit, the mining cap GasCeil and the lower limit GasFloor.

当父块的交易里的gas总和大于父块GasLimit的2/3时,则增加当前块的GasLimit,反之减少当前块的GasLimit,同时,保证GasLimit的范围在gasFloor和gasCeil之间。

When the sum of the gass in the patrilineal transaction is more than two thirds of the patrilineal GasLimit, the current section is added to GasLimit, while the current section is reduced to GasLimit, while the scope of GasLimit is guaranteed to be between GasFloor and GasCeil.

美化布局示例

欧易(OKX)最新版本

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

APP下载   全球官网 大陆官网

币安(Binance)最新版本

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

APP下载   官网地址

火币HTX最新版本

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

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

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

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

分享:

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

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

欧易(OKX)

  全球官网 大陆官网

币安(Binance)

  官网

火币(HTX)

  官网

Gate.io

  官网

Bitget

  官网

deepcoin

  官网
热门文章
  • usdt钱包开发,比特币协议 Omni 层协议 USDT

    usdt钱包开发,比特币协议 Omni 层协议 USDT
    usdt钱包开发Usdt Wallet Development 比特币协议 -> Omni 层协议 -> USDTBitcoin -> Omni Layer -> USDT USDT是基于比特币omni协议的一种代币: https://omniexplorer.info/asset/31 ID是31USDT is a token based on the Bitcomni agreement:   ˂a href="ht...
  • ?基于区块链的数字货币,下一代货币等价物

    ?基于区块链的数字货币,下一代货币等价物
    文 | 诗与星空Psalms and stars. 10月25日晚间,一则关于区块链的消息引爆了市场,虽然A股已经关门歇业,但是大洋彼岸的美股却喧嚣起来,号称使用了区块链技术的迅雷股价暴涨107%。On the evening of 25 October, a news about the block chain detonated the market. Although the A share was closed, the United States shares...
  • LikeCoin 2022 年度回顧

    LikeCoin 2022 年度回顧
    2022 即將過去,今年是風高浪急的一年,LikeCoin 社群繼續於驚濤中為實踐分散式出版而前進,感謝各位的同行。讓我們趁機回顧一下今年發生過的大小事。 2022 Towards the end of the year, this year is a year of great turmoil, and the community of ˂a href=https://like.co/"target="_blank" data-type="link" data-i...
  • 一个“币”卖出6930多万美元,它是何来头

    一个“币”卖出6930多万美元,它是何来头
    这是一个新的投机性市场,有许多未知的风险——包括100%损失的风险於兴中当我们看到有人花了近百万美元在网络上的虚拟空间里买了一块地,可能会觉得不可思议。但是,比这更不可思议的是,在上个月的佳士得拍卖会上,一个不可替换代币(NFT)卖出了令人瞠目结舌的6930多万美元。这个代币所代表的便是目前人们热议的数字艺术家毕朋(Beeple)的作品《日复一日:最初的5000天(2021)》。不仅如此,不可替换代币市场正在被大张旗鼓地建构。篮球视频集锦的不可替换代币在美国职业...
  • 以太坊质押挖矿收益率

    以太坊质押挖矿收益率
    展开全部 52%左右。根据跟踪公司StakingRewards的数据,质押的以太坊将产生回报,预计在合并后将达到52%左右。再加上预计在升级更新后不久以太坊供应量的净减少,这应该会使该币对投资者更具吸引力。According to the tracking company StakingRewards, the pledge will yield returns that are expected to reach about 52% after the merg...
标签列表