Commit Graph

9885 Commits

Author SHA1 Message Date
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
Paul Otten
b02fb8481a contrib/dependency_setup.sh: add "cmake" to pacman_deps.
Without `cmake` installed I get "No such file or directory" while
building `randomx`.
2025-04-14 17:37:44 +03:00
darkfi
19386e4488 research/codes: algebraic codes 2025-04-11 21:11:32 +02:00
skoupidi
15d3e2ea95 chore: updated nightly references version 2025-04-11 19:28:37 +03:00
epiphany
b8331f71b9 fud, fu: handle auto ipv6 external addr, improve fu get, improve fu watch 2025-04-11 16:03:17 +00:00
epiphany
8d22f69cf8 add fud and fu binaries to .gitignore 2025-04-11 16:03:17 +00:00
darkfi
ff112dd6c2 fud: add resource.rs, add fu watch, add fu rm, merge announcing task and pruning task 2025-04-11 16:03:17 +00:00
darkfi
011b80e071 fud: fix add_to_router, add file_hash to MissingChunks 2025-04-11 16:03:17 +00:00
darkfi
8244870639 fud, fu: subscribe rpc method, add FudEvent::DownloadStarted and FudEvent::DownloadError, get improvements 2025-04-11 16:03:17 +00:00
darkfi
8fac16466d geode: replace hex with bs58 in comments 2025-04-11 16:03:17 +00:00
darkfi
540a77aacb fud: add missing channel_sub.unsubscribe() 2025-04-11 16:03:17 +00:00
darkfi
f630e1cd7c fud: remove chunk seeders, change file hash, replace hex with bs58 2025-04-11 16:03:17 +00:00
darkfi
aae5651501 fud, fu: autoseed, get rpc subscriber, progress bar, bug fixes 2025-04-11 16:03:17 +00:00
darkfi
058faffa75 fud: add dht lookups & improvements 2025-04-11 16:03:17 +00:00
darkfi
e219954da2 fud, fu, geode: fixes & improvements 2025-04-11 16:03:17 +00:00
parazyd
10edfbdf1a net/tor: Add missing cache dir layout to TorListener 2025-04-07 16:28:45 +02:00
Paul Otten
8590c929d6 dnet: make colors more consitent
Intended to address tau RefID sccCbF, which complains about text being
hard to read on a (presumably black and white) e ink screen.

The rule in webdev is if you change one color, then change all of them.
Mixing default and custom colors can lead to unreadable color combos.

I've set the primary text color and background color to default.
- On a typical color screen this will be light gray text on a black background.
- On a black and white e ink screen this will be black text on a white background.

I've left the highlighted text color as dark cyan, while explicitly setting the background to black.
- On a typical color screen this will be dark cyan text on a black background.
- On a black and white e ink screen this will be dark gray text on a black background.

The intended result is no visable change on typical color screens,
but a more readable experience on black and white e ink screens.
2025-04-06 19:33:40 +00:00
Paul Otten
cd48ac6c9d dnet: logging enhancements
- added timestamps to log messages
- log rpc errors
- added a specific error message for 'p2p.get_info' rpc errors
2025-04-06 19:33:40 +00:00
skoupidi
87c2198552 darkfid: defined loose metering configuration and max bytes limits for protocol messages 2025-04-04 20:09:07 +03:00
skoupidi
197147463a script/research/gg: added a Makefile and use smol instead of async-std 2025-04-04 20:07:40 +03:00
darkfi
dfe77e9c62 doc: mention mdbook in installation instructions 2025-04-01 13:37:10 +03:00
darkfi
af4d31870c speling: cummulative --> cumulative 2025-04-01 13:35:02 +03:00
darkfi
8b2b71c10e doc: use 14:00 UTC (DST) and 15:00 UTC (ST) for dev meeting times 2025-03-31 16:39:38 +02:00
darkfi
3ac3c3942c doc/philosophy/meetings: suspend philosophy meetings until further notice 2025-03-31 16:39:06 +02:00
darkfi
ea34c42f26 doc/contrib.md: change dev meet time to CET 2025-03-31 14:09:23 +02:00
darkfi
98c01982a7 doc/misc/network-troubleshooting: add section on updating the system clock 2025-03-31 14:07:12 +02:00
darkfi
a290a3a194 app: migrate ui/text to parley/swash 2025-03-30 11:48:46 +02:00
darkfi
83fa980007 app: most basic RTL support (non-joining chars) 2025-03-28 10:01:37 +01:00
darkfi
5ab2692975 app: simplify schema by introducing chatedit:min_height property. 2025-03-26 10:36:59 +01: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
skoupidi
c3268cec47 src/lib: don't export a feature error 2025-03-24 10:57:36 +02:00
kalm
8c92599e67 darkfi: add thiserror to the explorerd package in Cargo.lock
This commit adds `thiserror 2.0.11` as a dependency to the `explorerd` package in the project's `Cargo.lock`.
2025-03-24 01:27:00 -07:00
kalm
83478ad50d explorerd/error: enhance error module with parameterized errors and conversions
Enhanced the `explorerd` error module by introducing parameterized errors, improving error propagation through conversions, renaming for clarity, and refining JSON-RPC error handling.

Updates include:
- Renamed `RpcError` to `ExplorerdError` for use across all application layers (rpc, service, store)
- Updated `ExplorerdError` to support parameterized error variants for more detailed and flexible error messages
- Added conversions from `ExplorerdError` to `RpcError` and `Error` to aid with error propagation from individual RPC handlers to the `handle_request` method
- Renamed `to_tuple` to `to_error_code_message` for improved readability and updated it to support parameterized errors
- Revised the `server_error` function to construct `JsonError` responses using `ExplorerdError`
- Updated Cargo.toml to include thiserror support
- Updated `mod/ping_darkfid` function to use the updated `ExplorerdError`, including error details for additional context
2025-03-24 01:19:27 -07:00
kalm
6ccf08e924 lib: re-export rpc error from error module for rpc handler access
This commit adds `RpcError` to the list of re-exports from the error module, making it accessible when handling errors in RPC-related modules.
2025-03-24 00:51:51 -07:00
kalm
9ce37ee843 error: enhance RpcError to support custom server errors and method not found
This update extends the `RpcError` enum to include support for two new variants: `ServerError` and `MethodNotFound`.

### Details:
- `ServerError` utilizes a `dyn std::error::Error` trait object, providing flexibility to embed and propagate custom errors defined by RPC-related modules.
- `ServerError` is wrapped in an `Arc`, which automatically implements the `Send` and `Sync` traits. This ensures `RpcError` can be safely shared and propagated across thread boundaries during asynchronous operations, like the `StoppableTask` and other multi-threaded components.
2025-03-24 00:39:01 -07:00
kalm
db3c0a54d4 rpc/jsonrpc: added utility functions and TryFrom impls to streamline JSON-RPC parameter/result handling
Introduced reusable utility functions to streamline JSON-RPC parameter extraction and validation. These functions aim to reduce the amount of code needed to extract RPC parameters. Error handling provides additional context by providing the parameter name responsible for invalid JSON error. Added `TryFrom` trait implementations for converting `JsonResult` into a `JsonResponse` or `JsonError`.

New utility functions include:
- `parse_json_string`: Extracts a `String` from a `JsonValue`.
- `parse_json_number`: Extracts a `f64` from a `JsonValue`.
- `parse_json_array_string`: Extracts a `String` from a `JsonValue` array at a specific index.
- `parse_json_array_number`: Extracts a `f64` from a `JsonValue` array at a specific index.
- `parse_json_response_string`: Extracts a `String` result from a `JsonResponse`.
- `to_json_array`: Converts a `JsonValue` into a JSON array (`Vec<JsonValue>`).
- `validate_empty_params`: Ensures that JSON parameters are empty.
2025-03-24 00:27:57 -07:00
darkfi
734cf91444 app: remove arboard dependency now miniquad::linux_wayland has full clipboard support 2025-03-23 11:55:21 +01:00
darkfi
0f0a770ef1 app: cargo update 2025-03-23 11:42:11 +01:00
skoupidi
df1fa1aea0 net/transport/tor: reset arti folders when net.p2p_datastore is set 2025-03-18 18:16:11 +02:00
skoupidi
3e0cef9eb1 net/transport/tor: use an isolated TorClient for each TorDialer derived from the static one 2025-03-18 17:44:51 +02:00
skoupidi
34f1af6cf6 minerd/main: missing import added 2025-03-18 17:11:38 +02:00
darkfi
c797566804 darkirc: goodbye crypto error messages 2025-03-18 14:58:27 +01:00
kalm
5ade160f63 explorerd: introduce dedicated sync module for block synchronization
This update introduces a dedicated `sync` module, moving explorer synchronization-related logic from the RPC layer to the service layer. The RPC block code has been separated from the explorer's synchronization and reorganization logic. By creating a `sync` module, synchronization—one of the most complex and integral aspects of the explorer's functionality—has been isolated. This restructuring provides a cleaner separation of concerns and simplifies the management of synchronization complexity.

Updates include:
- Created `explorer/service/sync` module and moved the following functions from `rpc/blocks.rs`:
  - `sync_blocks`
  - `subscribe_blocks`
  - `reorg_blocks` (renamed from process_sync_blocks_reorg)
- Updated `mod.rs` to include the `sync` module definition
- Added `darkfid_client` to `ExplorerService` to fetch blocks from a Darkfi blockchain network during sync
- Updated the `contracts.rs` test module setup method to use the new `ExplorerService` constructor
2025-03-17 11:36:03 -07:00
kalm
eb8f7239b9 explorer: add no-sync mode details to explorer quick start guides
Updates include:
- Updated `explorer/README` quick start guide with instructions on starting an explorer environment (site + explorerd) in no-sync mode (skipping blockchain node connections)
- Updated `explorer/explorerd/README` quick start guide with details on running `explorerd` in no-sync mode
2025-03-17 11:35:16 -07:00