Geth无法获取早期block的transaction信息

问题

自己搭的Arbitrum主网全节点,在同步的时候出现了这个日志

..Unindexed transactions blocks=1 txs=1 tail=7,762,405..

表现:数据同步方式是full,数据肯定是存在的,但根据交易hash查不到交易,如:

eth.getTransaction("0x546ee96921c3b9c5053d98be8da482cf9221f06804297a506b3c9a63ba3655be") 

返回null。

原因

排查后发现是因为Geth为了节省空间,从1.10.0版本开始,很多旧的transaction都不建索引了,只建立了近一年的transaction的索引。

解决

需要在启动参数上加上参数 --node.tx-lookup-limit=0 0表示建立所有交易的索引。

--node.tx-lookup-limit uint    retain the ability to lookup transactions by hash for the past N blocks (0 = all blocks) (default 126230400)

我的节点是用docker方式搭建的,需要停止容器,在/var/lib/docker/containers/容器id/config.v2.json配置文件中的Args和Cmd添加参数 --node.tx-lookup-limit=0, 重新启动即可。启动后节点可能需要做一些事情,需要等等才能恢复正常,我的等了6个小时恢复正常。

注意:这个参数只适用arb,不同链参数名字不同,值代表的意思也可能不同,如在以太坊里这个参数叫这个 --txlookuplimit,需要找对应链的启动参数,但都原理都差不多。我就是因为名字用成了txlookuplimit,启动后容器提示找不到这个参数,卡了一会儿,哈哈!

参考

Geth无法获取早期block的transaction信息
Command-line options
Geth v1.10.0

猜你喜欢

转载自blog.csdn.net/Theflowerofac/article/details/133275184