This commit relocates the explorer code from the research directory to `bin/explorer` to include it as part of future releases.
### Summary of Updates:
#### Darkfi Project
- Updated `Cargo.toml` to include `bin/explorer/explorerd` as a workspace member
- Updated `Cargo.lock` to include the `explorerd` package
- Updated the `Makefile` to include `explorerd` in the build process
#### Explorer Daemon
- Renamed the project directory from `blockchain-explorer` to `explorer`
- Moved the explorer daemon source code to `bin/explorer/explorerd`
- Updated the cargo package name to `explorerd`
- Updated log statement targets from `blockchain-explorer::` to `explorerd::`
- Renamed the explorer configuration file to `explorerd_config.toml`
- Removed Halo2 patches as they are now included in the root package
- Changed default db_path to use explorerd instead of blockchain-explorer in the path
- Changed binary crate Arg structopt name from blockchain-explorer to explorerd
#### Explorer Site
- Moved the explorer site source code to `bin/explorer/site`
- Updated README.md to include new build instructions for explorerd
This commit integrates blockchain reorg functionality into the explorer’s block syncing and subscriptions, addressing inconsistencies and aligning the explorer state with a Darkfi node. Key improvements include reorg detection and handling in block synchronization and subscriptions, consolidated and refined logging for better observability, state reset methods to reliably handle reorg scenarios, and enhanced safeguards to ensure consistency before starting subscriptions.
Summary of Updates:
## Blocks Module
- Added `get_block_by_height` to retrieve blocks by height to support reorg handling
- Added `reset_to_height` function to reset blocks and related transactions to a specific height, enabling transactional resets. This function was introduced because the blockchain layer's equivalent function could not be reused due to the absence of `StateDiffs` on the explorer side.
- Changed the log level of `reset_blocks` to `debug` to streamline reorg-related logging
## Transaction Module
- Changed the log level of `reset_blocks` to `debug` to streamline reorg-related logging
## Binary Crate (main.rs)
- Added `reset_explorer_state` to reset the explorer state to a given height or to genesis. This ensures consistency across blocks, transactions, and metrics during resets or reorgs
- Updated logging to include transaction count during ExplorerDb initialization
## Rpc Blocks Module
- Refined variable and function names with "darkfid" for improved readability
### Block Sync Reorgs
- Implemented block sync reorg handling to detect and resolve inconsistencies between the Darkfid node and the explorer
- Introduced reorg detection logic based on mismatched block hashes and heights
- Added support for handling reorg scenarios, including genesis related cases
- Extended logging to report detected reorgs and re-alignments
- Updated the `reset` flag handling to purge and resync the explorer state from scratch when enabled
- Added `process_sync_blocks_reorg` to identify mismatched blocks and realign the explorer's blockchain state to the correct height
## Subscription Sync Reorgs
- Added reorg handling in the subscription process to detect reorgs through block height mismatches and reset the explorer state as needed
- Improved safeguards against mismatched last synced and last confirmed blocks before initiating the subscription process
These updates provide explorer nodes the ability to handle blockchain reorgs and ensure alignment with the canonical chain from Darkfi nodes.
This change introduces a reusable function to format error messages, add target-specific logging context, and encapsulate errors into a `DatabaseError`.
Changed the logging level of `darkfid_daemon_request` from `debug` to `trace` to facilitate debugging, particularly during the synchronization of large amounts of blocks.
This commit replaced the transaction link on the blocks page to use the `/tx/` path instead of `/transaction/`. This ensures the transaction URL aligns the updated transaction routing path.
This commit updates the explorer UI to show empty metrics when no metrics are available, replacing the previous behavior of displaying a "Gas consumption details are not available" message.