Hey guys,
I built an indexer of ERC721 and ERC1155 transfers to save them to my own database. The indexer is using the standard Web3 API to be compatible with different Web3 providers.
Itās running without issue on Ethereum mainnet and ropsten using another provider.
I recently had to index transactions from BSC so I started to use Moralis as a provider using the Speedy nodes.
The indexer is getting a lots of error since.
Here are the three most common errors Iām getting:
- From the block listener:
Error bad response (status=401, headers={"date":"Tue, 22 Feb 2022 13:19:22 GMT","content-type":"text/plain","content-length":"12","connection":"close","cf-cache-status":"DYNAMIC","expect-ct":"max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"","server":"cloudflare","cf-ray":"6e188176d8571875-EWR"}, body="Unauthorized", requestBody="{\"method\":\"eth_blockNumber\",\"params\":[],\"id\":2249,\"jsonrpc\":\"2.0\"}", requestMethod="POST", url="https://speedy-nodes-nyc.moralis.io/XXXX/bsc/mainnet/archive", code=SERVER_ERROR, version=web/5.5.1)
Error timeout (requestBody="{\"method\":\"eth_blockNumber\",\"params\":[],\"id\":5269,\"jsonrpc\":\"2.0\"}", requestMethod="POST", timeout=120000, url="https://speedy-nodes-nyc.moralis.io/XXXX/bsc/mainnet/archive", code=TIMEOUT, version=web/5.5.1)
- From functions that fetch logs:
Error bad response (status=503, headers={"date":"Tue, 22 Feb 2022 07:05:40 GMT","content-type":"text/plain","content-length":"95","connection":"close","x-envoy-upstream-service-time":"0","cf-cache-status":"DYNAMIC","expect-ct":"max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"","server":"cloudflare","cf-ray":"6e165e09db168c30-EWR"}, body="upstream connect error or disconnect/reset before headers. reset reason: connection termination", requestBody="{\"method\":\"eth_getLogs\",\"params\":[{\"fromBlock\":\"0xec158b\",\"toBlock\":\"0xec158b\",\"address\":\"0x3537bd14254a04b0f940c976b4dd481ff91251b5\",\"topics\":[[\"0xc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62\",\"0x4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb\"]]}],\"id\":4766,\"jsonrpc\":\"2.0\"}", requestMethod="POST", url="https://speedy-nodes-nyc.moralis.io/XXXX/bsc/mainnet/archive", code=SERVER_ERROR, version=web/5.5.1)
I checked the quota of my account and it seems ok.
The 4 instances of the indexer Iām currently running are using the same Moralis account and are using around 400,000 requests a day. Thatās an average of 277 requests per minutes, well bellow the 1,500 of the free account.
Anyway, the errors code doesnāt seems to be the ones for rate/usage limit.
Here is what the indexer is requesting from the Web3 provider:
- The indexer is calling
eth_blockNumber
every 2 seconds - On new block:
a. it calls 2 timeseth_getLogs
, one time to get logs from an ERC721 contract and one time to get logs from an ERC1155 contract. The calls are done using the a specific topic, the from and the to block filters.
b. it also calls one time theeth_getBlock
to get more info about the block
c. when the logs are fetched, decoded and saved to database, two calls (one for each contract) are done to verify the correctness of saved information. This uses a the multicall2 smart contract from MakerDAO to batch all the requests into one request.
I would like to know what are the potentials issues and how to fix them.
Could it be some limitation from the archive speedy nodes?
Thank you!