enviodev / hyperindex

📖 Blazing-fast multi-chain indexer
https://envio.dev
78 stars 5 forks source link

Indexing Error: "Cannot read properties of undefined (reading 'hash')" #219

Closed jboetticher closed 2 weeks ago

jboetticher commented 2 months ago

While indexing Axelar events on my local machine, my indexer crashed and would encounter the same error upon restarting. The full error logged is included here:

{
    "level": 50,
    "time": 1726699495477,
    "pid": 48939,
    "hostname": "Jeremys-MacBook-Pro.local",
    "chainId": 250,
    "chainId": 250,
    "logType": "Block Range Query",
    "workerType": "HyperSync",
    "fromBlock": 75157432,
    "toBlock": 92027320,
    "addresses": [
        "0x304acf330bbE08d1e512eefaa92F6a57871fD895"
    ],
    "fetchStateRegister": "root",
    "msg": "Failed to fetch block Range",
    "err": {
        "type": "TypeError",
        "message": "Cannot read properties of undefined (reading 'hash')",
        "stack": "
        TypeError: Cannot read properties of undefined (reading 'hash')\n    
        at /Users/jb/Desktop/glacis/envio-indexer/indexer/generated/src/eventFetching/hypersync/HyperSync.bs.js:102:34\n    
        at forEachU (/Users/jb/Desktop/glacis/envio-indexer/indexer/node_modules/.pnpm/rescript@11.1.3/node_modules/rescript/lib/js/belt_Array.js:289:5)\n    
        at Object.forEach (/Users/jb/Desktop/glacis/envio-indexer/indexer/node_modules/.pnpm/rescript@11.1.3/node_modules/rescript/lib/js/belt_Array.js:294:3)\n    
        at addMissingParams (/Users/jb/Desktop/glacis/envio-indexer/indexer/generated/src/eventFetching/hypersync/HyperSync.bs.js:101:14)\n    
        at /Users/jb/Desktop/glacis/envio-indexer/indexer/generated/src/eventFetching/hypersync/HyperSync.bs.js:136:13\n    
        at mapU (/Users/jb/Desktop/glacis/envio-indexer/indexer/node_modules/.pnpm/rescript@11.1.3/node_modules/rescript/lib/js/belt_Array.js:301:12)\n    
        at Object.map (/Users/jb/Desktop/glacis/envio-indexer/indexer/node_modules/.pnpm/rescript@11.1.3/node_modules/rescript/lib/js/belt_Array.js:307:10)\n    
        at queryLogsPage (/Users/jb/Desktop/glacis/envio-indexer/indexer/generated/src/eventFetching/hypersync/HyperSync.bs.js:132:28)\n    
        at async queryLogsPageWithBackoff (/Users/jb/Desktop/glacis/envio-indexer/indexer/generated/src/eventFetching/chainWorkers/HyperSyncWorker.bs.js:28:11)\n    
        at async /Users/jb/Desktop/glacis/envio-indexer/indexer/generated/src/eventFetching/chainWorkers/HyperSyncWorker.bs.js:133:22"
    }
}

I could not reproduce the error the following day, however it is important to note that this error occurred on chain 250, and chain 250 seems to be lacking a significant amount of data, making me think that the error inducing data has since been skipped.

Screenshot 2024-09-19 at 9 23 28 AM

I have attached the relevant config, handlers, & graphQL schema.

Local Environment

Relevant Files

config.yaml ```yaml name: glacis-v1-testnet unordered_multichain_mode: true field_selection: transaction_fields: - "from" - "to" - "hash" - "chainId" contracts: - name: AxelarGateway handler: src/AxelarEventHandlers.ts events: - event: ContractCall(address indexed sender, string destinationChain, string destinationContractAddress, bytes32 indexed payloadHash, bytes payload) - event: ContractCallWithToken(address indexed sender, string destinationChain, string destinationContractAddress, bytes32 indexed payloadHash, bytes payload, string symbol, uint256 amount) - event: ContractCallApproved(bytes32 indexed commandId, string sourceChain, string sourceAddress, address indexed contractAddress, bytes32 indexed payloadHash, bytes32 sourceTxHash, uint256 sourceEventIndex) - event: ContractCallApprovedWithMint(bytes32 indexed commandId, string sourceChain, string sourceAddress, address indexed contractAddress, bytes32 indexed payloadHash, string symbol, uint256 amount, bytes32 sourceTxHash, uint256 sourceEventIndex) - event: ContractCallExecuted(bytes32 indexed commandId) - event: Executed(bytes32 indexed commandId) networks: # Mainnet - id: 1 start_block: 0 end_block: null # 20257600 contracts: - name: AxelarGateway address: - 0x4F4495243837681061C4743b74B3eEdf548D56A5 - id: 10 start_block: 0 #122396300 end_block: null contracts: - name: AxelarGateway address: - 0xe432150cce91c13a887f7D836923d5597adD8E31 - id: 56 start_block: 0 end_block: null # 40276700 contracts: - name: AxelarGateway address: - 0x304acf330bbE08d1e512eefaa92F6a57871fD895 - id: 137 start_block: 0 end_block: null # 59085200 contracts: - name: AxelarGateway address: - 0x6f015F16De9fC8791b234eF68D486d2bF203FBA8 - id: 250 start_block: 0 end_block: null # 47683300 contracts: - name: AxelarGateway address: - 0x304acf330bbE08d1e512eefaa92F6a57871fD895 - id: 8453 start_block: 0 end_block: null # 16801000 contracts: - name: AxelarGateway address: - 0xe432150cce91c13a887f7D836923d5597adD8E31 - id: 1284 start_block: 0 end_block: null contracts: - name: AxelarGateway address: - 0x4F4495243837681061C4743b74B3eEdf548D56A5 - id: 42161 start_block: 0 end_block: null # 229848700 contracts: - name: AxelarGateway address: - 0xe432150cce91c13a887f7D836923d5597adD8E31 - id: 43114 start_block: 0 end_block: null # 47683300 contracts: - name: AxelarGateway address: - 0x5029C0EFf6C34351a0CEc334542cDb22c7928f78 ```
GraphQL Schema ```graphql type AxelarGateway_ContractCall { id: ID! sender: String! destinationChain: String! destinationContractAddress: String! payloadHash: String! payload: String! transactionHash: String! chainId: Int! blockTimestamp: Int! } type AxelarGateway_ContractCallWithToken { id: ID! sender: String! destinationChain: String! destinationContractAddress: String! payloadHash: String! payload: String! symbol: String! amount: BigInt! transactionHash: String! chainId: Int! blockTimestamp: Int! } type AxelarGateway_ContractCallApproved { id: ID! commandId: String! sourceChain: String! sourceAddress: String! contractAddress: String! payloadHash: String! sourceTxHash: String! sourceEventIndex: BigInt! transactionHash: String! chainId: Int! blockTimestamp: Int! } type AxelarGateway_ContractCallApprovedWithMint { id: ID! commandId: String! sourceChain: String! sourceAddress: String! contractAddress: String! payloadHash: String! symbol: String! amount: BigInt! sourceTxHash: String! sourceEventIndex: BigInt! transactionHash: String! chainId: Int! blockTimestamp: Int! } type AxelarGateway_Executed { id: ID! commandId: String! transactionHash: String! chainId: Int! blockTimestamp: Int! } type AxelarGateway_ContractCallExecuted { id: ID! commandId: String! transactionHash: String! chainId: Int! blockTimestamp: Int! } ```
AxelarEventHandlers.ts ```ts import { AxelarGateway, AxelarGateway_ContractCall, AxelarGateway_ContractCallWithToken, AxelarGateway_ContractCallApproved, AxelarGateway_ContractCallApprovedWithMint, AxelarGateway_Executed, AxelarGateway_ContractCallExecuted } from "generated"; AxelarGateway.ContractCall.handler(async ({ event, context }) => { const axelarGateway_ContractCallEntity: AxelarGateway_ContractCall = { id: event.transaction.hash + event.logIndex.toString(), sender: event.params.sender, destinationChain: event.params.destinationChain, destinationContractAddress: event.params.destinationContractAddress, payloadHash: event.params.payloadHash, payload: event.params.payload, transactionHash: event.transaction.hash, chainId: event.chainId, blockTimestamp: event.block.timestamp }; context.AxelarGateway_ContractCall.set(axelarGateway_ContractCallEntity); }); AxelarGateway.ContractCallWithToken.handler(async ({ event, context }) => { const axelarGateway_ContractCallWithTokenEntity: AxelarGateway_ContractCallWithToken = { id: event.transaction.hash + event.logIndex.toString(), sender: event.params.sender, destinationChain: event.params.destinationChain, destinationContractAddress: event.params.destinationContractAddress, payloadHash: event.params.payloadHash, payload: event.params.payload, symbol: event.params.symbol, amount: event.params.amount, transactionHash: event.transaction.hash, chainId: event.chainId, blockTimestamp: event.block.timestamp }; context.AxelarGateway_ContractCallWithToken.set(axelarGateway_ContractCallWithTokenEntity); }); AxelarGateway.ContractCallApproved.handler(async ({ event, context }) => { const axelarGateway_ContractCallApproved: AxelarGateway_ContractCallApproved = { id: event.transaction.hash + event.logIndex.toString(), commandId: event.params.commandId, sourceChain: event.params.sourceChain, sourceAddress: event.params.sourceAddress, contractAddress: event.params.contractAddress, payloadHash: event.params.payloadHash, sourceTxHash: event.params.sourceTxHash, sourceEventIndex: event.params.sourceEventIndex, transactionHash: event.transaction.hash, chainId: event.chainId, blockTimestamp: event.block.timestamp }; context.AxelarGateway_ContractCallApproved.set(axelarGateway_ContractCallApproved); }); AxelarGateway.ContractCallApprovedWithMint.handler(async ({ event, context }) => { const axelarGateway_ContractCallApprovedWithMint: AxelarGateway_ContractCallApprovedWithMint = { id: event.transaction.hash + event.logIndex.toString(), commandId: event.params.commandId, sourceChain: event.params.sourceChain, sourceAddress: event.params.sourceAddress, contractAddress: event.params.contractAddress, payloadHash: event.params.payloadHash, symbol: event.params.symbol, amount: event.params.amount, sourceTxHash: event.params.sourceTxHash, sourceEventIndex: event.params.sourceEventIndex, transactionHash: event.transaction.hash, chainId: event.chainId, blockTimestamp: event.block.timestamp }; context.AxelarGateway_ContractCallApproved.set(axelarGateway_ContractCallApprovedWithMint); }); AxelarGateway.ContractCallExecuted.handler(async ({ event, context }) => { const axelarGateway_Executed: AxelarGateway_ContractCallExecuted = { id: event.transaction.hash + event.logIndex.toString(), commandId: event.params.commandId, transactionHash: event.transaction.hash, chainId: event.chainId, blockTimestamp: event.block.timestamp }; context.AxelarGateway_ContractCallExecuted.set(axelarGateway_Executed); }); AxelarGateway.Executed.handler(async ({ event, context }) => { const axelarGateway_Executed: AxelarGateway_Executed = { id: event.transaction.hash + event.logIndex.toString(), commandId: event.params.commandId, transactionHash: event.transaction.hash, chainId: event.chainId, blockTimestamp: event.block.timestamp }; context.AxelarGateway_Executed.set(axelarGateway_Executed); }); ```
JasoonS commented 1 month ago

From a telegram chat:

IMG_20240922_225826_598.jpg

I mean that hyperindex occasionally seems to skip ahead to the latest blocks instead of indexing from the start. So situations like this, where fantom opera (250) has only 2 events and is at 100% immediately but other chains are still indexing because they start at the actual start of the data.

Though I've noticed this doesn't reliably reproduce every time I start the indexer

JonoPrest commented 1 month ago

Hey @jboetticher, I've just confirmed this due to bugs on HyperSync with fantom network. Unfortunately it's not stable at the moment and it's using an old version of HyperSync.

JasoonS commented 2 weeks ago

This, as far as I know, has been fixed. I will close the issue now. If there are issues again in the future, please comment and reopen (or let us know in discord).

cc: @jboetticher