FuelLabs / fuel-indexer

🗃 The Fuel indexer is a standalone service that can be used to index various components of the Fuel blockchain.
https://docs.fuel.network/docs/indexer/
140 stars 66 forks source link

fix: add instantiating indexer status, and display error if instantiation fails #1460

Closed lostman closed 10 months ago

lostman commented 10 months ago

Description

On develop, when indexer instantiation fails, forc index status will display the last status from the database. This may be running, Indexed 12345 blocks.

This PR adds IndexerStatusKind::Instantiating to avoid this situation.

In addition, if the indexer instantiation fails, the status is set to error and a proper message is displayed:

Indexers:

─ fuellabs
   ├─ explorer
   |  • id: 1
   |  • created at: 2023-11-08 11:54:53.323558 UTC (6h 45m ago)
   |  • status: error
   |  • status message:
   |      Error instantiating wasm interpreter: Link(
   |          Import(
   |              "env",
   |              "ff_single_select",
   |              UnknownImport(
   |                  Function(
   |                      FunctionType {
   |                          params: [
   |                              I64,
   |                              I32,
   |                              I32,
   |                          ],
   |                          results: [
   |                              I32,
   |                          ],
   |                      },
   |                  ),
   |              ),
   |          ),
   |      )

Testing steps

  1. Check out maciej/1437-entity-find and start the indexer:
    cargo run --bin fuel-indexer -- run --run-migrations --fuel-node-host beta-4.fuel.network --fuel-node-port 80 --replace-indexer --manifest examples/fuel-explorer/fuel-explorer/fuel_explorer.manifest.yaml
  2. Check out develop, and restart the indexer without --manifest to keep the incompatible indexer in the database.
  3. Run forc index status to see the incorrect status.
  4. Check out maciej/add-more-indexer-statuses, and restart the indexer (again, without --manifest).
  5. Run forc index status to see the correct status and error.