Commit Graph

9994 Commits

Author SHA1 Message Date
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
kalm
a9939f47e9 explorer: incorporate no-sync mode into respective explorer Makefiles
This commit adds targets to the explorer's Makefiles for starting the explorer in no-sync mode. This allows node environments to launch without connecting to a Darkfi blockchain network, relying instead on existing explorer databases. A `check-contracts` target was added to ensure required WASM files are built to start explorerd in no-sync mode. This setup enhances the mode implementation by simplifying the process of starting environments without sync.

Summary of Updates:
- Introduced `start-no-sync-%` targets in `explorer/Makefile` and `explorer/explorerd/Makefile`
- Added `await-startup-no-sync-%` in `explorer/explorerd/Makefile` to wait for explorerd startup while skipping the Darkfid connection and sync
- Implemented a `check-contracts` target to verify the presence of required contract artifacts and build them if necessary
2025-03-17 07:12:30 -07:00
kalm
39e0abfe78 explorer: add no-sync mode to run explorerd without connecting or syncing with darkfid
Introduced a `no-sync` mode to the `explorerd` daemon, allowing the application to operate solely on a local explorer database without connecting to a `darkfid` blockchain network or syncing new blocks. This feature is particularly
useful for UI development, testing, development tasks that don't require syncing, or exploring functionality without the overhead of running a blockchain node or miner.

This setup reduces resource consumption and accelerates the development workflow by avoiding the need to sync or connect to a blockchain network when it is not needed. It also simplifies the build setup, as the explorer can run without building `darkfid` or `minerd`, reducing dependencies.

Updates include:
- Added a `--no-sync` CLI argument to toggle this mode
- Updated the sync logic to skip tasks like `subscriber_task` and `listener_task` when `no-sync` mode is enabled
- Enhanced the `Explorerd` struct to support conditional connection handling
- Updated the startup banner to display `(No-Sync Mode)` and to show "Not connected" for the connected node in `no-sync` mode
2025-03-17 07:04:30 -07:00
kalm
9e65d6aff2 explorerd: introduce DarkfidRpcClient for darkfid interactions
Refactored Darkfid JSON-RPC interaction methods into the new `DarkfidRpcClient` struct. This change consolidates functionality for reuse across ownership boundaries and introduces support for operating the explorer in no-sync mode.

Summary of Updates:
- Created `DarkfidRpcClient` and moved core methods like `ping` and block retrieval (`get_block_by_height`, `get_last_confirmed_block`) from `Explorerd` into it
- Updated `rpc_client` to use the `RwLock<Option<RpcClient>>` type for internally immutability and defer its creation to the `connect` method, allowing initialization without an active connection
- Added a `connect` method to establish connections to Darkfid on demand
- Updated the `stop` method to set the `RpcClient` to `None`
- Renamed and updated the `request` method to return an error when a request is made without an active connection to Darkfid
- Updated the `Explorerd` struct and implementation to integrate with `DarkfidRpcClient`
- Updated the `explorerd` binary to explicitly call `connect`

Design considerations:
- Changed `Explorerd.darkfid_client` to an `Arc` and used an `RwLock` for `DarkfidRpcClient.rpc_client` to enable shared access across ownership boundaries
- Updated `RpcClient` to be an `Option`, deferring initialization until `connect` is called. This allows startup without an active connection (`None`), supporting use cases like the explorer no-sync mode
- The `RwLock` in `DarkfidRpcClient` provides internal mutability for the connection state, ensuring that callers remain unaffected by implementation changes, such as adding a `connect` function to the `RpcClient` to delegate connection management and removing the need for `DarkfidRpcClient` to handle the connection state

Future considerations:
- The `RwLock` may be removed later by refactoring `RpcClient` for lazy connections with a `connect` method, but is kept for now to avoid wider system changes
- Plan to move `DarkfidRpcClient` to the Darkfi SDK, laying the foundation for an easy-to-use client to accelerate the creation of future Darkfi DApps
2025-03-17 04:01:07 -07:00
kalm
826b6dbc50 explorerd: folder-based modules for rpc, service, and store
This commit reorganizes the project structure by grouping RPC, service, and store functionalities into dedicated module folders:

- `rpc`: Handles JSON-RPC interactions, migrated from `rpc_*.rs` (e.g., `rpc_transactions.rs` → `rpc/transactions.rs`)
- `service`: structured to contain the core logic for block synchronization, chain data access, metadata storage/retrieval, and statistics computation
- `store`: manages persistent storage for blockchain, contracts, metrics, and metadata

This structural refactor introduces no functional changes.

Benefits:
- Simplifies the crate root
- Groups related functionality into cohesive module boundaries
- Removes need for file prefixes and suffixes (e.g., `rpc_`, `_store`) by relying on folder-based module names for context (e.g., `rpc::blocks`, `store::metrics`)
- Enhances separation of concerns with defined responsibilities across the `rpc`, `service`, and `store` modules
- Implements domain-based boundaries that reflect the system's architecture
- Aims to improve maintainability and readability, particularly for new contributors
2025-03-14 21:07:27 -07:00
kalm
8ef29926a1 explorerd: clean up and further document makefile
This commit cleans up the explorerd Makefile by:

- Adding named variables for all binary and configuration paths
- Enhancing the `bundle_contracts_src` target's documentation
- Cleaning up path handling to use variable references
- Improving comments in the `start-%` target to explain the workflow
- Updating all project root path references to use the `$(PROJECT_ROOT)` variable
- Reorganizing the `await-startup-%` target to group it with other targets
2025-03-13 22:38:13 -07:00
kalm
2d02bbae50 explorerd: refine prerequisites section
This commit streamlines the prerequisites section and adds a note indicating that Darkfid and Minerd are automatically built when using the make commands referenced in the Quick Start Guide.
2025-03-13 19:19:30 -07:00
kalm
a6ea6cc37c explorer: update README with clearer prerequisites and guidance for confirming successful start
This update improves documentation usability by providing more context in the prerequisites section and adding step-by-step guidance for verifying a successful Explorer environment startup.

Summary of Updates:
- Refactored the prerequisites section for better clarity and organization
- Introduced a new "Confirming Successful Start" section with guidance on environment initialization
- Updated the Quick Start Guide overview paragraph
- Adjusted the Table of Contents to reflect the prerequisites refactor
2025-03-13 19:14:34 -07:00
kalm
2cce6d4860 explorerd: enhance explorerd README with quick-start guide
This commit improves the explorerd documentation by:
- Adding a "Quick-Start Guide" section allowing users to start different explorer node network configurations using a single make command
- Adding "Network Status" section explaining testnet/mainnet availability
- Provided more details and clarifications in the prerequisites section
- Adding "Confirming Successful Start" section with startup banner example
- Adding "Getting Help" section with make help command
- Restructuring documentation with clearer section organization
- Improving guidance for running against different network configurations
2025-03-13 00:01:49 -07:00
kalm
c4e22941d9 explorerd: improve process termination in 'stop' makefile target
This commit enhances the process termination mechanism in the 'stop' target by:
- Adding a check to verify that a PID is running before attempting to terminate it
- Implementing a more graceful termination approach by first sending SIGTERM (15) and only using SIGKILL (9) as a fallback
2025-03-12 23:11:02 -07:00
kalm
bec2f5c55e explorerd: improve cross-platform native contract bundling, add witness proof files
This commit replaces the GNU tar-specific `--transform` flag with a more portable solution, ensuring contract bundling works correctly on both Linux and BSD/macOS systems. It also includes witness proof JSON files in the native contract source code.

Summary of Updates
- Removed dependency on the GNU-specific `--transform` option
- Specified PAX format explicitly (`--format=pax`) for better cross-platform compatibility
- Refactored to use a temporary directory structure that mirrors the desired archive layout before generating tar files
- Included proof witness JSON files as part of the native contract bundling
2025-03-12 22:48:55 -07:00
kalm
0772c82eb5 explorer: update README home image to include network label
Updated the README's explorer home image to reflect the latest version, which includes a network label indicating the network the explorer is running on. Currently, "localnet" is the default, with plans to switch to testnet as the default once it is released.
2025-03-12 10:14:23 -07:00
kalm
6d73b6e36f explorer: add Darkfi project dependencies to README prerequisites.
Added core Darkfi project dependencies to the prerequisites section in explorer/README.md.
2025-03-12 10:08:11 -07:00
kalm
9862d26100 explorer: updated README quick-start guide, clarified network status
This commit enhances the explorer README by updating the quick-start guide to work with new enhancements that automatically start node environments including installing missing dependencies. Additionally, it clarifies the current network status for testnet and mainnet environments.

Summary of Updates:
- Added Quick-Start Guide section to README documenting new make commands to start explorer environments
- Added Network Status section explaining the current placeholder state of testnet and mainnet
- Reorganized and updated the prerequisites section to reflect automatic building from source for missing node dependencies
- Added help command information (make help) for quick reference
- Updated table of contents to reflect new organization
2025-03-10 06:06:09 -07:00
oars
1cb7c2a915 doc/misc/nodes/tor-guide: socks5 proxy transport setup guide 2025-03-10 13:56:44 +02:00
oars
499c517573 bin: add default socks5 proxy address to darkirc, darkfid and taud configs 2025-03-10 13:56:44 +02:00
oars
7e28e2d52f net: implement socks5 transport mixing 2025-03-10 13:56:44 +02:00
kalm
753dc262f2 explorer/site: add quick-start guide to explorer site README, clarified network status
This commit enhances the explorer site README by adding a quick-start guide. Additionally, it clarifies the current network status for testnet and mainnet environments, and improves the overall document organization.

Summary of Updates:
- Added Quick-Start Guide section to README documenting new make commands for server management
- Added Network Status section explaining the current placeholder state of testnet and mainnet
- Reorganized README structure into Quick-Start and Detailed Guide sections for better navigation
- Added help command information (make help) for quick reference
2025-03-10 04:54:22 -07:00
darkfi
219895d507 net/session: do not panic if fetch_last_seen() cannot retrieve a host
It's possible that we cannot find a host on any active hostlist if
the host has been blacklisted just prior to the downgrade inside
subscribe_on_stop(). Instead of panicking, we simply return an error
and do not proceed with the downgrade operation.
2025-03-09 21:48:10 +01:00
kalm
d22d96d17d explorer: introduce single command explorer launch
This commit adds the ability to start an explorer environment with a single command. The new Makefile addition streamlines the process of working with the DarkFi explorer across various network configurations, catering to users with diverse needs.

The implementation automates startup and shutdown for explorer environments while managing dependencies efficiently, ensuring that missing components are automatically built. It also launches the explorer site (UI), verifying that all required dependencies are installed beforehand. The startup process is orchestrated so that `darkfid` initializes first, followed by `explorerd`, and the UI is launched after verifying that the explorer node is fully operational.

These improvements allow a diverse community of users to focus on what matters most to them without concern for environment setup, startup, or shutdown.

For usage details, run: `make help`

Key Features:
- Single-command to start/stop explorer environments for Darkfi localnet, testnet, or mainnet networks
- Automatic dependency management and node building
- Graceful shutdown with a single keyboard interrupt (Ctrl-C)
- Sequential startup to prevent race conditions
- Organized node logging for each network (localnet, testnet, mainnet)
- Enhanced `make help` help documentation
2025-03-09 07:42:08 -07:00
kalm
a0bc5ae51f explorerd: automate starting explorer node environments
Enhanced Makefile with capabilities to automate the startup and shutdown of explorerd and its dependencies using a single `make` command. These additions create a streamlined user experience for running explorer nodes across the DarkFi networks, orchestrating the process by automatically building necessary dependencies prior to starting an explorer node environment. Ordered startup sequencing has been implemented to ensure darkfid starts before launching explorerd, with a mechanism to wait for explorerd to complete initialization to avoid startup race conditions.

The implementation maintains PID tracking for graceful process shutdown. Additionally, it organizes logs by network type (localnet, testnet, mainnet) in dedicated directories (`~/.local/share/darkfi/logs/NETWORK`) that are monitored to determine when nodes are initialized.

To view a list of available make commands (targets), run: `make help`.

Key Features:
- Single Command Launch: Provides targets to start explorer node environments with a single command (`make start-localnet/testnet/mainnet`)
- Automatic Dependency Checks and Builds: Automatic dependency resolution that builds missing `darkfid`, `explorerd`, and `minerd` binaries before starting nodes
- Graceful Shutdown: Added graceful network shutdown capability with PID tracking (`make stop`)
- Ordered Initialization: Implemented ordered startup sequencing for network nodes, ensuring `darkfid` starts before launching `explorerd`, and waiting for explorerd to complete initialization before it is marked as started
- Organized Logging: Logs for each started network (localnet, testnet, mainnet) are saved in their respective directories (~/.local/share/darkfi/logs/NETWORK)
- Log Monitoring: Implemented log monitoring to ensure that nodes are not started before their dependencies are ready
- Error Handling: Ensures invalid or unsupported network arguments are reported with an error message
2025-03-09 06:46:35 -07:00
kalm
27d8618e84 explorer/site: Add help target and reorganize Makefile
- Add help target with organized documentation of available commands
- Rename 'stop-server' target to more concise 'stop'
- Fix Python executable path (use generic 'python' instead of hard-coded path)
- Reorganize sections for better logical grouping
- Generalized naming to explorer site
- Added console statements to show the testnet and mainnet log locations on startup to see server startup details
2025-03-09 05:37:17 -07:00
kalm
a839603b2c explorer/site: Add Makefile for simplified Flask Explorer site management
Introduced a Makefile to streamline the setup, startup, and shutdown of the Flask Explorer site across different networks (localnet, testnet, mainnet). It simplifies server management and cleanup with straightforward commands.

In future iterations, `testnet` and `mainnet` environments may transition to production-ready setups (e.g., running behind a reverse proxy). This implementation serves as a starting point and is expected to be expanded upon.

Summary of Updates:
- Automatic virtual environment setup and dependency installation (`all`, ``install` targets)
- Added targets to start the Flask server for localnet, testnet, and mainnet networks
- Implemented the use of a `flask.pid` file to track the Flask server’s process ID (PID), enabling proper process termination during the `stop-server` target
- Provided a `clean` target to remove the virtual environment and reset the workspace
2025-03-07 21:58:08 -08:00
kalm
5a56634929 explorer/site: display running network in the explorer site nav bar
This commit enables users to identify which network the explorer site is currently running, improving clarity for users navigating the site.

- Added a `<div>` in `base.html` to display the current network in the nav bar
- Updated `app.py` to store the network environment in app config, making it accessible for use in the nav bar
- Renamed references from env to network in app.py
2025-03-07 21:22:10 -08:00
kalm
d6815b217d explorer/site: improved text color consistency across components
- Added new CSS variables: `--color-input-background: #3B3B3B;`, `--color-source-code-link: #D1CDC7;`, `--color-text-primary: #D1CDC7;`
- Set the default color of the content container to `--color-text-primary`
- Updated the search input to explicitly set the background color (`--color-input-background`) and border color (`--color-border-primary`)
- Explicitly set the table text color to `--color-text-primary`
- Overrode Bootstrap's default `pre` and `pre code` styles to use `--color-text-primary`
2025-03-06 21:58:31 -08:00
kalm
582a3e1e6b explorer: introduce top-level explorer README
Created the initial top-level README documentation for the DarkFi Blockchain Explorer, with the expectation of future refinements, updates to align with the latest UI design, and the addition of more details over time.

Summary of Updates:
- Introduced a project description, highlighting the Explorer’s purpose and core functionalities
- Added a Key Features section outlining the Explorer's capabilities
- Provided a Quick Start Guide with prerequisites, installation steps, and instructions for running on localnet
- Documented Explorer Components, including the explorer nodes and web interface
- Included a Configuration section covering configuration files and supported networks
- Detailed Feature Highlights, such as block exploration, gas analytics, and contract source navigation
- Integrated initial explorer screenshots to help with clarity and user guidance
2025-03-06 21:40:23 -08:00
kalm
aa42428f23 explorer/site: enhance explorer site README.md
Expanded site README documentation to provide updated instructions reflecting the latest code.

Summary of Updates:
- Updated overall project description
- Included a key features section detailing core site functionality
- Reorganized the Usage section into a Getting Started section, separating prerequisites, installation, and running the application
- Moved supporting daemons and explorerd-related setup to explorerd/README.md and explorer/README.md
- Added a configuration section describing the site's configuration options
- Added a Logging section providing insights on the site's use of logs, log locations, log output, and log level configuration
2025-03-06 14:56:25 -08:00
skoupidi
6c02b4a450 net/message: optional metering infra for rate limitting added 2025-03-06 20:16:41 +02:00
dasman
a4cc48a819 sdk/python: fix clippy useless conversion 2025-03-06 20:43:27 +03:00
darkfi
d84d4a2c5e darkirc: no messages on unjoined channels from paired identities
Upon restarting darkirc, messages from paired identities (i.e.  users
who have exchanged and configured chacha keypairs) on unjoined
channels would be nevertheless be delivered.  IRC clients like
`weechat` would ignore such events, but other clients such as `ERC`
would deliver such messages without joining the channel resulting in
confusing "phantom" channels popping up.
2025-03-06 12:59:11 +01:00
darkfi
270099e197 darkirc: provide a manual script for four client testing scenarios 2025-03-06 12:59:04 +01:00
dasman
b93f851e38 sdk/python: use proof.verify() instead of proof.assert_satisfied() and still return errors to stderr 2025-03-06 03:26:15 +03:00
dasman
012f5dec23 darkirc/script/bots: fix accidentally messed up telegram bot 2025-03-06 03:23:59 +03:00
dasman
1b3454dd29 darkirc/script/bots: all bots exit on empty buffer 2025-03-06 03:16:45 +03:00
dasman
2acd3c60bb darkirc: deathloop fix, clients(bots) closing unexpectly causing an unhandled read buffer of 0 to continue endlessly 2025-03-06 03:13:48 +03:00
skoupidi
ee2fc468be chore: clippy 2025-03-05 13:26:39 +02:00
darkfi
c7c551ce8a research/zk: circle-stark.sage 2025-03-02 21:42:33 +01:00
skoupidi
9a9917705f script/research/dam: better flood control 2025-03-01 16:36:25 +02:00
parazyd
78109ca8ab tau: Use python3 2025-02-28 15:32:17 +01:00
kalm
5390516ec2 explorerd: Introduce README for explorerd daemon
Added a README to document the `explorerd` daemon, including its key functionality, configuration, supported networks, setup, and instructions for running it.

Summary of Updates:
- Added an overview of `explorerd` functionality, including synchronization, reorg mitigation, and real-time updates
- Documented key features such as full blockchain synchronization and analytics support
- Included a configuration section with example configurations aligned to DarkFi network setups
- Documented supported networks (`localnet`, `testnet`, and `mainnet`)
- Provided instructions for building, installing, configuring, and starting explorer nodes
- Included steps to start supporting daemons (`darkfid` and `minerd`) for synchronization
2025-02-28 05:16:21 -08:00
skoupidi
b27dec9b45 net/message: optional max message bytes limit added 2025-02-28 15:03:35 +02:00
skoupidi
7678346e95 doc/arch/net/p2p-network.md: fixed relative path 2025-02-27 15:33:12 +02:00