1

I was looking into an issue with RPC calls with eth_getTransactionByHash and recognized for older transactions it returns null for geth full nodes:

Tx 511 days ago: 0x9f15fa4b2fe31afa2953331dfb58662422c6eb6b4fb3a739ae6f40c469979695.

Requesting own local full node:

kuzdogan@kuzdogan-UX331UN:~$ curl --data '{"method":"eth_getTransactionByHash","params":["0x9f15fa4b2fe31afa2953331dfb58662422c6eb6b4fb3a739ae6f40c469979695"],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST http://localhost:8545
{"jsonrpc":"2.0","id":1,"result":null}

Requesting an Infura node:

curl --data '{"method":"eth_getTransactionByHash","params":["0x9f15fa4b2fe31afa2953331dfb58662422c6eb6b4fb3a739ae6f40c469979695"],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST https://mainnet.infura.io/v3/XXXXXXX
{"jsonrpc":"2.0","id":1,"result":{"blockHash":"0x15fac326a1dabb09acbe5727fb670f767733e9cb490e6329e3970990b67e9810","blockNumber":"0xa6116a","from":"0xdc32476dc0d5442836439924697166185f4d9c6b","gas":"0x6270","gasPrice":"0x2cb4178000","hash":"0x9f15fa4b2fe31afa2953331dfb58662422c6eb6b4fb3a739ae6f40c469979695","input":"0x","nonce":"0x21d","r":"0x4f8e7b7ab538f05cb39a0ec1031a0c40961afa067aa3cba1c23621263c435071","s":"0x32b0b5f4c014e2cea9724bc823da3a98e8341b9f29942388fe7aa07ce439fc4a","to":"0xdcb2fb145e86f31245efa748650671fcac39232f","transactionIndex":"0xa0","type":"0x0","v":"0x26","value":"0x69789fbbc4f80000"}}

Noting it is possible to retrieve the same tx via eth_getTransactionByBlockNumberAndIndex. And for recent transactions, eth_getTransactionByHash works.

I guess the full nodes stop indexing transactions when they are old. (Moved to "ancient"? Pruned?).

So my questions are:

  • Is it because the transactions are removed from "index" in a geth full node?
  • If so, when is this done? 1 year? 6 months? N blocks?
  • How could a transaction be retrieved in this case by only knowing the transaction hash?

1 Answer 1

1

I learned this is due to the following option in geth:

--txlookuplimit value               Number of recent blocks to maintain transactions index for (default = about one year, 0 = entire chain) (default: 2350000)

So yeah it is by default set to ~1year and my local node should have this value where Infura nodes probably have the entire chain set.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.