Implement failover for RPC endpoints in watcher (#506)

* Handle RPC endpoint server errors and switch failover endpoints

* Add config maxNewBlockRetries for switching to failover endpoint

* Upgrade package versions

* Move unknown events removal after event processing for historical sync

* Rename doFailOverEndpoints to switchClients
This commit is contained in:
2024-05-09 16:03:06 +05:30
committed by GitHub
parent 6d837dc824
commit c9696c3d9f
25 changed files with 195 additions and 62 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@cerc-io/codegen",
"version": "0.2.85",
"version": "0.2.86",
"description": "Code generator",
"private": true,
"main": "index.js",
@@ -20,7 +20,7 @@
},
"homepage": "https://github.com/cerc-io/watcher-ts#readme",
"dependencies": {
"@cerc-io/util": "^0.2.85",
"@cerc-io/util": "^0.2.86",
"@graphql-tools/load-files": "^6.5.2",
"@npmcli/package-json": "^5.0.0",
"@poanet/solidity-flattener": "https://github.com/vulcanize/solidity-flattener.git",
@@ -63,7 +63,9 @@
[upstream]
[upstream.ethServer]
gqlApiEndpoint = "http://127.0.0.1:8082/graphql"
rpcProviderEndpoint = "http://127.0.0.1:8081"
rpcProviderEndpoints = [
"http://127.0.0.1:8081"
]
# Boolean flag to specify if rpc-eth-client should be used for RPC endpoint instead of ipld-eth-client (ipld-eth-server GQL client)
rpcClient = false
@@ -100,3 +102,6 @@
# Max block range of historical processing after which it waits for completion of events processing
# If set to -1 historical processing does not wait for events processing and completes till latest canonical block
historicalMaxFetchAhead = 10000
# Max number of retries to fetch new block after which watcher will failover to other RPC endpoints
maxNewBlockRetries = 3
@@ -199,6 +199,15 @@ export class Indexer implements IndexerInterface {
await this._baseIndexer.fetchStateStatus();
}
switchClients ({ ethClient, ethProvider }: { ethClient: EthClient, ethProvider: BaseProvider }): void {
this._ethClient = ethClient;
this._ethProvider = ethProvider;
this._baseIndexer.switchClients({ ethClient, ethProvider });
{{#if (subgraphPath)}}
this._graphWatcher.switchClients({ ethClient, ethProvider });
{{/if}}
}
{{#if (subgraphPath)}}
async getMetaData (block: BlockHeight): Promise<ResultMeta | null> {
return this._baseIndexer.getMetaData(block);
@@ -41,12 +41,12 @@
"homepage": "https://github.com/cerc-io/watcher-ts#readme",
"dependencies": {
"@apollo/client": "^3.3.19",
"@cerc-io/cli": "^0.2.85",
"@cerc-io/ipld-eth-client": "^0.2.85",
"@cerc-io/solidity-mapper": "^0.2.85",
"@cerc-io/util": "^0.2.85",
"@cerc-io/cli": "^0.2.86",
"@cerc-io/ipld-eth-client": "^0.2.86",
"@cerc-io/solidity-mapper": "^0.2.86",
"@cerc-io/util": "^0.2.86",
{{#if (subgraphPath)}}
"@cerc-io/graph-node": "^0.2.85",
"@cerc-io/graph-node": "^0.2.86",
{{/if}}
"@ethersproject/providers": "^5.4.4",
"debug": "^4.3.1",