Go-Ethereum函数中的两个未知参数

huangapple go评论87阅读模式
英文:

two unknow parameters in Go-Ethereum function

问题

我是你的中文翻译助手,以下是你要翻译的内容:

我是Go-EVM的新手,前段时间我得到了一个用于获取交易跟踪的源代码。但是源代码中的一些函数已经更新和更改了,我有一些问题想要问:

第一个问题是:如何获取*snapshot.Tree?

stateDB, err := state.New(block.Root(), state.NewDatabase(db))

现在这个语句需要三个参数,丢失的参数的类型是*snapshot.Tree。它是一个结构体,在这里的第164行可以找到它的源代码。

第二个问题是:AsseccList和GasTipFee是什么?

message := types.NewMessage(from, tx.To(), 0, tx.Value(), tx.Gas(), from Address, to Address, nonce, amount, gasLimit, tx.GasPrice(), GasTopfee, GasTipFee, tx.Data(), accesslist AccessList, false)

AccessList也是一个结构体。你可以从这里看到它的结构体。我应该输入什么到AccessList和GasTipFee中?
如果你能帮我解决这些问题,我将非常感激。

英文:

Im new in Go-EVM, and some time ago I got a source code to get transaction tracking. But some functions in the source codes have been updated and changed, here are some questions I wanna ask:

The first one is: How to get *snapshot.Tree?

stateDB, err := state.New(block.Root(), state.NewDatabase(db))   

Now this statements need three parameter and the lost parameter's type is *sanpshot.Tree. It is a struct, here is the link to its source code, in line 164.

The second one is: What are AsseccList and GasTipFee?

message := types.NewMessage(from, tx.To(), 0, tx.Value(), tx.Gas(), from Address, to Address, nonce, amount, gasLimit, tx.GasPrice(), GasTopfee, GasTipFee, tx.Data(), accesslist AccessList, false)   

AccessList is also a struct. You can see its struct from here. What should I input into AccessList and GasTipFee?
Really appreciate it if you can help me solve these questions.

答案1

得分: 1

在你的情况下,如果没有树快照,你不需要传递一个。树快照的目的是,如果快照与块的trie的根匹配,运行他们称之为预取器例程,负责在内存中预加载节点,以便当状态达到提交阶段时,性能更好,因为它已经在内存中有大部分所需的节点。所以在你的情况下,你可以完全放心地将nil传递给该构造函数。

至于AccessListGasTipFee参数:

  • AccessListEIP-2930访问列表。这又是一个可选项,交易可以提供以指定它们需要访问的地址和存储键。同样,你可以提供一个nil切片。
  • 你所称之为GasTipFee的是GasTipCap在主分支上的名称,基本上是一个gas tip的限制值,据我所了解。你可以在官方文档中找到有关gas费用的更多信息。
英文:

In your case you do not need to pass a tree snapshot if you do not have one. The purpose of the tree snapshot is to, if the snapshot matches with the given root of the block's trie, run what they call a pre-fetcher routine, that is in charge of preloading nodes in memory so that when the state reaches the commit phase, it is more performant because it already has most of the required nodes in memory. So in your case, you should be perfectly fine passing nil to that constructor.

As for the AccessList and GasTipFee parameters:

  • AccessList is an EIP-2930 access list. It's once again something optional that transactions can provide to specify the addresses and storage keys that they need access to. Once again you can provide a nil slice.
  • What you have called GasTipFee is called GasTipCap on master and is basically the limit value of a gas tip, as far as I understand. You can find more information on gas fees in the official documentation.

huangapple
  • 本文由 发表于 2022年1月7日 16:48:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/70618706.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定