Commit Graph

93 Commits

Author SHA1 Message Date
skoupidi
c9c9a7a38a chore: fixed broken darkfid rpc blockchain.get_block clients requests 2025-12-29 19:25:27 +02:00
skoupidi
ecfebc2b71 chore: dropped minerd references 2025-12-29 15:38:12 +02:00
x
add9bb596c chore: Update crate dependencies 2025-12-25 12:22:56 +00:00
x
57717ecf3c Change block nonce to u32 2025-12-24 17:56:19 +00:00
skoupidi
5d47358902 chore: updated sled-overlay to new version 2025-12-24 14:01:20 +02:00
skoupidi
5d9bfe7507 chore: updated sled-overlay to new version 2025-12-22 16:09:09 +02:00
skoupidi
346a3517bd chore: updated sled-overlay to new version 2025-12-22 15:36:52 +02:00
skoupidi
82ac85872c chore: updated sled-overlay to new version 2025-12-22 14:37:17 +02:00
skoupidi
5943f2cd1e explorer/explorerd/error: removed unused import 2025-12-15 14:14:39 +02:00
skoupidi
621e704115 rust: set stable toolchain and clippy chore 2025-11-24 17:03:48 +02:00
x
aa537b9e4b chore: Update crate dependencies 2025-11-24 12:12:14 +02:00
x
a8ead9e5ea Revert "chore: updated blake3 init usage"
This reverts commit d8f4529c726955fccf90031caf71fd66b93c61d9.
2025-11-24 12:12:13 +02:00
skoupidi
98aef1f41f chore: updated blake3 init usage 2025-11-24 12:12:13 +02:00
oars
4b739963c6 bin/explorer/explorerd: replace simplelog with tracing-subscriber for setting up logger for tests
- replaced dynamic targets with static targets since tracing crate only supports setting static targets in the logger macros
2025-11-07 10:15:36 +03:00
oars
d85cf80dbf replace log imports with tracing everywhere 2025-11-07 10:15:36 +03:00
oars
ac0365cc60 Cargo.toml, Cargo.lock: change dependencies used for logging
- replace log crate with tracing,
- replace simple-log crate with tracing-subscriber and tracing-appender
- add nu-ansi-term crate as a dependency which is itself tracing-subscriber's dependency,
  inorder to write colored outputs to the terminal since we override formatting provided
  by tracing-subscriber
2025-11-07 10:15:36 +03:00
skoupidi
d0c49d24d0 chore: updated sled-overlay to new version 2025-10-24 12:58:55 +03:00
parazyd
fda2a84034 chore: Update dependencies 2025-08-05 09:41:05 +02:00
skoupidi
464258698d explorer: chore clippy 2025-06-28 17:16:20 +03:00
parazyd
2e2de47c69 v0.5.0 release 2025-06-06 13:50:10 +02:00
kalm
5cd8c6c035 explorer/site: run testnet and mainnet on WSGI server
This commit updates the explorer web app to run on a Gunicorn-based WSGI server for testnet and mainnet rather than the built-in dev server. In doing so, it provides for improved scalability, reliability, integration with Nginx, and flexible run configuration.

We’ve introduced a dedicated configuration file (gunicorn_config.py) allowing control over the number of worker processes and threads. By adjusting these values, we can handle more simultaneous requests, fine-tune performance based on CPU resources, and tweak other operational parameters to suit deployment needs.

Update Summary:
- Added gunicorn_config.py to configure bind address, workers, threads, pidfile, and logs
- Updated the testnet and mainnet ports to run on 8000 instead of the 5000 dev port
- Created wsgi.py to load and expose the Flask app via `create_app()`
- Updated requirements.txt to include Gunicorn dependency
- Modified makefile start-% target to start with Gunicorn for testnet/mainnet instead of the development server
- Adjusted stop task to stop Gunicorn server when stopping the explorer
- We updated the requirements.txt install to run quietly
- Updated Makefile to export LOG_HOME so it can be accessed by gunicorn_config.py
2025-05-26 15:34:10 -07:00
kalm
15fb9fd8ea explorerd/service/blocks: handle duplicate PoW coin errors after reorgs
This update introduces code to ensure blocks with PoW rewards containing coins already applied to the contract state prior to a reorg are synced. Additionally, it brings awareness to the need for rolling back the contract state to a specific height during reorgs.
2025-05-25 22:51:44 -07:00
kalm
18c2de1ca5 explorerd/service/blocks: fix reset_to_height get_by_range query and enhance debug logging
This fix adjusts the range query in `reset_to_height` to start from `reset_height + 1`, ensuring transactions from `reset_height` are excluded when deleting reset block transactions.

Summary of changes:
- Updated the `get_by_range` query to exclude `reset_height` transactions
- Enhanced debug statements to validate transaction deletions and associated block heights during reorgs
2025-05-25 21:26:15 -07:00
kalm
69854c6c3f explorerd/store/metrics: change logs informing insertion of metrics to debug
This commit replaces `info!` log statements with `debug!` for messages informing about the insertion of metrics in the MetricsStore.
2025-05-25 02:59:29 -07:00
kalm
dd94f6de93 explorerd: Add support for VERBOSE variable in makefile start-% targets
This commit adds support for the `$(VERBOSE)` variable in the `start-%` targets, allowing changing verbosity levels when starting the explorer node environment. The help message has also been updated to include more details.
2025-05-25 02:46:32 -07:00
kalm
3d01b5696d explorerd/main: enhance block subscription with retry mechanism when out of sync
This commit enhances subscription initialization to handle scenarios where the explorer database is out of sync with darkfid.

Summary of changes:
- Added "Blockchain not fully synced" error check during block subscription initialization
- Implemented a retry mechanism to resync blocks and reattempt the subscription process
2025-05-25 02:14:29 -07:00
parazyd
46d815ace0 chore: Update crate deps and freeze RandomX git rev 2025-05-21 15:01:54 +02:00
kalm
7e28c41aac explorerd: adjust log search for darkfid startup sync confirmation
This commit modifies the `wait_for_darkfid_startup` target in the Makefile to search for a later log message during darkfid startup. Results from testnet testing revealed that additional synchronization occurs before darkfid starts, necessitating a longer wait time is needed before starting explorerd.
2025-05-21 00:26:56 -07:00
kalm
fc79636cda explorerd/service: removed ducktape
This commit removes temp workaround while code was being updated to apply state changes to WASM runtime during block sync.
2025-05-19 00:50:52 -07:00
kalm
f03f5977b6 explorerd/service: enhance put_block and calculate_tx_gas_data to apply contract state changes, cleanup
This commit updates the `calculate_tx_gas_data` function to apply state changes during contract execution, enabling contract data availability for subsequent contract calls during block sync. Additionally, `put_block` was modified to apply PoW reward transactions to the WASM runtime, ensuring their effects are visible to transaction runtimes used for fee calculations where applicable.

Minor cleanup was performed.
2025-05-19 00:02:56 -07:00
skoupidi
a6fb5f8852 explorer/explorerd/service/transactions: duck taping until refactor 2025-05-18 14:37:09 +03:00
skoupidi
61c4b831e3 chore: updated sled-overlay to new version 2025-05-17 19:10:01 +03:00
parazyd
e002530bb2 chore: Update packages to v0.5.0 2025-05-09 11:32:44 +02:00
skoupidi
56546572e7 explorer/site/templates/block: fucking moron 2025-05-07 17:58:59 +03:00
skoupidi
c38e5f66a5 explorer/site/templates/block: missing pow type added 2025-05-07 17:56:16 +03:00
skoupidi
b054d403de blockchain: proof of work data enum added 2025-05-07 15:01:07 +03:00
skoupidi
be45acd927 chore: fixing my stupidity 2025-05-07 13:38:14 +03:00
skoupidi
7656bde63b blockchain: contracts states checksums monotree(smt) added 2025-05-06 16:28:40 +03:00
parazyd
81f37b7b2a chore: Update crate dependencies 2025-05-03 10:35:40 +02:00
skoupidi
c4f3b4eb11 chore: updated sled-overlay to new version 2025-04-25 14:47:40 +03:00
skoupidi
0d30a230fa chore: fmt 2025-04-15 12:28:08 +03:00
parazyd
c040d9c00f chore: Update crate dependencies 2025-04-15 10:49:43 +02:00
Paul Otten
721502a468 Move from "nightly" toolchain to "stable".
Intended to address tau RefID "Gifn1u".

There are still a few things that require nightly.
- cargo +nightly fmt
- fuzzing
2025-04-14 19:42:15 -04:00
kalm
04209b29e2 explorerd/rpc: added test coverage for invalid/missing parameters
This commit expands the test suite by adding RPC tests that cover invalid/missing parameters, unsupported data types, unparsable inputs, and invalid numeric ranges. It also includes a test case to ensure `ping_darkfid` properly handles error when invoked under a disconnected darkfid endpoint.

New test modules include:
- **rpc/mod/tests**: Tests to ensure that `ping_darkfid` correctly handles non-empty parameters and scenarios where it is invoked with a disconnected darkfid endpoint
- **rpc/blocks/tests**: Tests verifying that invalid/missing parameters for fetching blocks produce the expected error responses
- **rpc/transaction/tests**: Tests confirming that incorrect/missing parameters for retrieving transactions are properly handled
- **rpc/contracts/tests**: Tests ensuring invalid/missing parameter handling for retrieving native contracts data
- **rpc/statistics/tests**: Tests confirming that invalid/missing parameters for retrieving statistics result in correct error handling

Other updates:
- Set the default test log level to 'Off' in test_mod.rs
- Removed the `TEST_DATA_DIR` constant until the test cases are updated to run on a copy of the test `explorerdb`
- Removed the `test_data/explorerd_0` folder until the test cases are updated to use a copy of the test `explorerdb`

Running Tests:

cargo test rpc
2025-03-24 06:53:45 -07:00
kalm
ba628d0d9d explorerd/test: introduce auxiliary RPC parameter validation functions and add shared Explorerd instance support
This commit enhances `test_utils` module by introducing a shared `Explorerd` instance and auxiliary functions for verifying invalid JSON-RPC parameter handling. By initializing the `Explorerd` once, tests can run asynchronously. The auxiliary functions cover invalid or missing parameters, ensuring that the Explorerd API correctly handles and reports invalid inputs.

Updates include:
- Defined a global `Explorerd` instance that is shared across tests, improving efficiency
- Updated the test setup so the `Explorerd` instance is initialized on the first invocation and then shared among subsequent calls
- Added `validate_invalid_rpc_parameter` to test JSON-RPC methods for invalid parameter handling, verifying correct error codes and messages
- Added `validate_empty_rpc_parameters`, which checks whether methods that expect no parameters properly reject non-empty parameters
- Added helper functions (`validate_invalid_rpc_contract_id`, `validate_invalid_rpc_header_hash`, `validate_invalid_rpc_tx_hash`, and `validate_invalid_rpc_hash_parameter`) to test invalid hash parameter handling
- Temporarily added `#[allow(dead_code)]` for `test_util` until the test code that utilizes the new utility functions is checked in
2025-03-24 04:56:29 -07:00
kalm
ea1433d25f explorerd/test_utils: add initial test data with preloaded native smart contracts
Adds an initial test data into a `explorerd` sled database with preloaded native smart contracts to the `test_utils` module. This test data will be updated over time, but currently optimizes testing by eliminating the need to load smart contracts for every test run.
2025-03-24 04:36:42 -07:00
kalm
47b3add0ef explorerd: guard test_utils module with #[cfg(test)]
Adds a `#[cfg(test)]` attribute to the `test_utils` module in `main.rs` to ensure it is only included during testing.
2025-03-24 04:28:51 -07:00
kalm
67c43d0b12 explorerd/service: enhance error clarity for invalid header hash parsing
Updates the service layer to map failed `header_hash` parsing to `ExplorerdError::InvalidHeaderHash`. This improves error messages by including the invalid hash value, making them more actionable.
2025-03-24 04:23:30 -07:00
kalm
34e0fdd7be explorer/site: accommodate new RPC parameter handling of numerics
Change the index route code in explore.py to call `get_last_n_blocks` with an integer instead of a string to accommodate the updated RPC layer, which now expects numeric types rather than strings for numbers.
2025-03-24 04:18:38 -07:00
kalm
db23d77da9 explorerd/rpc: streamline parameter processing, result handling, error handling, and logging
Refactored the RPC layer to unify parameter extraction/validation, error handling, result construction, and request failure logging. These updates simplify the rpc layer, reduce individual method handler code by approximately 20%, enhance error context, and aim to improve the overall user and developer experience.

### Key Improvements:

Streamlined Error Handling:
- Unified error handling within the `handle_request` function enables RPC method handlers to use the `?` operator to return errors for unified processing. This streamlines error handling and provides consistent translation of `JsonError` responses.

Parameter Parsing and Validation:
- Incorporated use of new `jsonrpc` utilities for streamlined parameter extraction and validation. This eliminates parameter boilerplate extract and validation logic across handlers, reduces the risk of inconsistencies, and establishes a unified parameter processing approach for all RPC methods.

Simplified `JsonResult` Construction:
- Replaced direct `JsonResult` construction in handlers with a unified approach. Handlers now return a `JsonValue` wrapped in a `darkfi::Result`, simplifying implementation by removing the need to construct `JsonResponse`/`JsonError` within individual RPC method handlers.

Enhanced Error Context:
- Added detailed error information, including parameter names, indices, and values that caused validation failures. These enhancements make it easier to pinpoint the root causes of errors, benefiting both developers and API users.

Unified Logging:
- Added consolidated logging for RPC request failures in the `handle_request` function. Errors are logged with details like RPC method name, parameters, and the JSON-RPC error returned back to the caller, ensuring consistent and informative reporting.

### Highlight:

Cleaner and More Consistent Code:
By consolidating error handling, result construction, and parameter processing with the new `jsonrpc` utilities, RPC method handlers are now more concise. These changes reduce the code required for implementation, allowing developers to focus on core RPC logic and service integration.

### Module Update Details:

mod.rs:
- Refactored the `handle_request` method to streamline JSON-RPC request handling
- Unified error processing, logging, and result transformation using `JsonResult`
- Reorganized JSON-RPC methods in the match block into logical order (blocks, transactions, statistics, contracts, then miscellaneous)
- Added a utility function for failure logging, capturing method names, parameters, and error details

blocks.rs: contracts.rs, statistics.rs, transactions.rs:
- Updated individual modules to align with the refactored `handle_request` logic
- Updated numeric parameters to be processed as `JsonValue::Number` instead of strings
2025-03-24 04:04:44 -07:00