diff --git a/@l10n/ru/docs/development/building.md b/@l10n/ru/docs/development/building.md index 7ba29470f0..cdd27517d6 100644 --- a/@l10n/ru/docs/development/building.md +++ b/@l10n/ru/docs/development/building.md @@ -26,10 +26,8 @@ chmod +x build-linux.sh ```bash ./build-linux.sh # Release-сборка (по умолчанию) -./build-linux.sh -l # LOW_MEMORY_NODE (узлы-валидаторы) ./build-linux.sh -n # Testnet-сборка ./build-linux.sh -t Debug -j4 # Debug-сборка с 4 параллельными задачами -./build-linux.sh --skip-deps # Пропустить установку зависимостей ./build-linux.sh --install # Установить в систему после сборки # Пользовательские пути к зависимостям @@ -54,7 +52,6 @@ chmod +x build-mac.sh **Параметры:** ```bash -./build-mac.sh -l # Low-memory узел ./build-mac.sh -n # Testnet ./build-mac.sh --skip-deps # Пропустить установки Homebrew ./build-mac.sh --boost-root /opt/boost_1_74_0 @@ -77,7 +74,6 @@ build-mingw.bat | Переменная | По умолчанию | Описание | |-----------|-------------|---------| | `VIZ_BUILD_TYPE` | Release | Release или Debug | -| `VIZ_LOW_MEMORY` | OFF | Включить low-memory узел | | `VIZ_BUILD_TESTNET` | OFF | Testnet-сборка | | `VIZ_FULL_STATIC` | OFF | Полностью статический бинарник | | `VIZ_CMAKE_EXTRA` | — | Дополнительные флаги CMake | @@ -100,7 +96,6 @@ build-msvc.bat |-----------|-------------|---------| | `VIZ_VS_VERSION` | "Visual Studio 17 2022" | Генератор Visual Studio | | `VIZ_BUILD_TYPE` | Release | Тип сборки | -| `VIZ_LOW_MEMORY` | OFF | Low-memory узел | | `VIZ_BUILD_TESTNET` | OFF | Testnet-сборка | **Требования:** Visual Studio 2019+ с нагрузкой "Desktop development with C++", CMake 3.16+. @@ -125,7 +120,6 @@ build-msvc.bat | Параметр | По умолчанию | Описание | |---------|-------------|---------| | `BUILD_TESTNET` | OFF | Сборка для testnet | -| `LOW_MEMORY_NODE` | OFF | Исключить неконсенсусные данные (уменьшает RAM) | | `CHAINBASE_CHECK_LOCKING` | OFF | Включить проверку блокировок (только для разработки) | | `BUILD_SHARED_LIBRARIES` | OFF | Собирать разделяемые библиотеки | | `USE_PCH` | OFF | Включить предкомпилированные заголовки (ускоряет пересборку) | @@ -140,9 +134,6 @@ build-msvc.bat # Release-сборка python3 programs/build_helpers/configure_build.py --release --src ../.. -# Debug с low-memory -python3 programs/build_helpers/configure_build.py --debug --low-memory - # Кросс-компиляция для Windows с MinGW python3 programs/build_helpers/configure_build.py --win --release diff --git a/@l10n/ru/docs/node/building.md b/@l10n/ru/docs/node/building.md index 60f278784d..3c70eceb8a 100644 --- a/@l10n/ru/docs/node/building.md +++ b/@l10n/ru/docs/node/building.md @@ -46,9 +46,6 @@ chmod +x build-linux.sh ### Основные флаги сборки ```bash -# Низкопамятный узел (для валидаторов/сид-узлов — без плагинов индексирования истории) -./build-linux.sh -l - # Сборка для тестнета ./build-linux.sh -n @@ -58,9 +55,6 @@ chmod +x build-linux.sh # Параллельные задания ./build-linux.sh -j 8 -# Пропустить установку зависимостей (уже установлены) -./build-linux.sh --skip-deps - # Пользовательские пути к Boost / OpenSSL ./build-linux.sh --boost-root /opt/boost_1_74_0 --openssl-root /opt/openssl ``` @@ -99,7 +93,6 @@ build-mingw.bat | Переменная | По умолчанию | Описание | |------------|--------------|----------| | `VIZ_BUILD_TYPE` | `Release` | `Release` или `Debug` | -| `VIZ_LOW_MEMORY` | `OFF` | `ON` для низкопамятного узла | | `VIZ_BUILD_TESTNET` | `OFF` | `ON` для сборки тестнета | | `VIZ_FULL_STATIC` | `OFF` | `ON` для полностью статического бинарного файла | @@ -124,7 +117,6 @@ build-msvc.bat | Опция | По умолчанию | Описание | |-------|--------------|----------| | `BUILD_TESTNET` | `OFF` | Включить код для тестнета | -| `LOW_MEMORY_NODE` | `OFF` | Исключить плагины истории/индексирования | | `CHAINBASE_CHECK_LOCKING` | `OFF` | Включить проверки блокировок (debug) | | `BUILD_SHARED_LIBRARIES` | `OFF` | Собрать разделяемые библиотеки | | `USE_PCH` | `OFF` | Включить предкомпилированные заголовки (ускоряет пересборку) | @@ -134,7 +126,6 @@ build-msvc.bat ```bash mkdir build && cd build cmake -DCMAKE_BUILD_TYPE=Release \ - -DLOW_MEMORY_NODE=ON \ -DCMAKE_INSTALL_PREFIX=/usr/local \ .. make -j$(nproc) diff --git a/@l10n/ru/docs/node/docker.md b/@l10n/ru/docs/node/docker.md index 94ef93829d..4d51bf0eb1 100644 --- a/@l10n/ru/docs/node/docker.md +++ b/@l10n/ru/docs/node/docker.md @@ -129,10 +129,10 @@ docker build \ ### CMake-флаги для каждого образа -| Образ | `LOW_MEMORY_NODE` | `BUILD_TESTNET` | -|-------|:-----------------:|:---------------:| -| production | OFF | OFF | -| testnet | OFF | ON | +| Образ | `BUILD_TESTNET` | +|-------|:---------------:| +| production | OFF | +| testnet | ON | --- diff --git a/@l10n/ru/docs/node/getting-started.md b/@l10n/ru/docs/node/getting-started.md index 538b83ee05..2540d782c6 100644 --- a/@l10n/ru/docs/node/getting-started.md +++ b/@l10n/ru/docs/node/getting-started.md @@ -133,7 +133,7 @@ shared-file-size = 4G # Плагины (полный узел) plugin = chain p2p webserver json_rpc database_api network_broadcast_api -plugin = social_network tags follow account_history +plugin = account_history ``` Для узла-валидатора см. [Узел-валидатор](./validator-node.md). @@ -172,7 +172,6 @@ curl -s -X POST http://localhost:8090 \ | Полный узел | `config.ini` | Все плагины, публичные RPC-эндпоинты | | Валидатор | `config_witness.ini` | Производство блоков, RPC только на localhost | | Тестовая сеть | `config_testnet.ini` | Разработка и тестирование | -| Малая память | `config.ini` + флаг сборки `LOW_MEMORY_NODE` | Только консенсус, без индексов истории | --- diff --git a/@l10n/zh-CN/docs/development/building.md b/@l10n/zh-CN/docs/development/building.md index f7c1cb5125..8eb6279129 100644 --- a/@l10n/zh-CN/docs/development/building.md +++ b/@l10n/zh-CN/docs/development/building.md @@ -26,10 +26,8 @@ chmod +x build-linux.sh ```bash ./build-linux.sh # Release 构建(默认) -./build-linux.sh -l # LOW_MEMORY_NODE(验证者节点) ./build-linux.sh -n # Testnet 构建 ./build-linux.sh -t Debug -j4 # Debug 构建,4 个并行任务 -./build-linux.sh --skip-deps # 跳过依赖安装 ./build-linux.sh --install # 构建后安装到系统 # 自定义依赖路径 @@ -54,7 +52,6 @@ chmod +x build-mac.sh **选项:** ```bash -./build-mac.sh -l # 低内存节点 ./build-mac.sh -n # Testnet ./build-mac.sh --skip-deps # 跳过 Homebrew 安装 ./build-mac.sh --boost-root /opt/boost_1_74_0 @@ -77,7 +74,6 @@ build-mingw.bat | 变量 | 默认值 | 描述 | |------|--------|------| | `VIZ_BUILD_TYPE` | Release | Release 或 Debug | -| `VIZ_LOW_MEMORY` | OFF | 启用低内存节点 | | `VIZ_BUILD_TESTNET` | OFF | Testnet 构建 | | `VIZ_FULL_STATIC` | OFF | 完全静态二进制文件 | | `VIZ_CMAKE_EXTRA` | — | 附加 CMake 标志 | @@ -100,7 +96,6 @@ build-msvc.bat |------|--------|------| | `VIZ_VS_VERSION` | "Visual Studio 17 2022" | Visual Studio 生成器 | | `VIZ_BUILD_TYPE` | Release | 构建类型 | -| `VIZ_LOW_MEMORY` | OFF | 低内存节点 | | `VIZ_BUILD_TESTNET` | OFF | Testnet 构建 | **要求:** Visual Studio 2019+(带"Desktop development with C++"工作负载)、CMake 3.16+。 @@ -125,7 +120,6 @@ build-msvc.bat | 选项 | 默认值 | 描述 | |------|--------|------| | `BUILD_TESTNET` | OFF | 为 testnet 构建 | -| `LOW_MEMORY_NODE` | OFF | 排除非共识数据(减少 RAM) | | `CHAINBASE_CHECK_LOCKING` | OFF | 启用锁检查(仅用于开发) | | `BUILD_SHARED_LIBRARIES` | OFF | 构建共享库 | | `USE_PCH` | OFF | 启用预编译头文件(加速重新构建) | @@ -140,9 +134,6 @@ build-msvc.bat # Release 构建 python3 programs/build_helpers/configure_build.py --release --src ../.. -# 带低内存的 Debug -python3 programs/build_helpers/configure_build.py --debug --low-memory - # 使用 MinGW 交叉编译 Windows 版本 python3 programs/build_helpers/configure_build.py --win --release diff --git a/@l10n/zh-CN/docs/node/building.md b/@l10n/zh-CN/docs/node/building.md index 839144dc0c..f40637cbde 100644 --- a/@l10n/zh-CN/docs/node/building.md +++ b/@l10n/zh-CN/docs/node/building.md @@ -46,9 +46,6 @@ chmod +x build-linux.sh ### 常用构建标志 ```bash -# 低内存节点(验证者/种子节点 — 排除历史索引) -./build-linux.sh -l - # 测试网构建 ./build-linux.sh -n @@ -58,9 +55,6 @@ chmod +x build-linux.sh # 并行任务数 ./build-linux.sh -j 8 -# 跳过依赖安装(已安装) -./build-linux.sh --skip-deps - # 自定义 Boost / OpenSSL 路径 ./build-linux.sh --boost-root /opt/boost_1_74_0 --openssl-root /opt/openssl ``` @@ -99,7 +93,6 @@ build-mingw.bat | 变量 | 默认值 | 描述 | |------|-------|------| | `VIZ_BUILD_TYPE` | `Release` | `Release` 或 `Debug` | -| `VIZ_LOW_MEMORY` | `OFF` | `ON` 构建低内存节点 | | `VIZ_BUILD_TESTNET` | `OFF` | `ON` 用于测试网构建 | | `VIZ_FULL_STATIC` | `OFF` | `ON` 构建完全静态二进制文件 | @@ -124,7 +117,6 @@ build-msvc.bat | 选项 | 默认值 | 描述 | |------|-------|------| | `BUILD_TESTNET` | `OFF` | 启用测试网专用代码 | -| `LOW_MEMORY_NODE` | `OFF` | 排除历史/索引插件 | | `CHAINBASE_CHECK_LOCKING` | `OFF` | 启用锁断言检查(debug) | | `BUILD_SHARED_LIBRARIES` | `OFF` | 构建共享库 | | `USE_PCH` | `OFF` | 启用预编译头文件(加快重新构建) | @@ -134,7 +126,6 @@ build-msvc.bat ```bash mkdir build && cd build cmake -DCMAKE_BUILD_TYPE=Release \ - -DLOW_MEMORY_NODE=ON \ -DCMAKE_INSTALL_PREFIX=/usr/local \ .. make -j$(nproc) diff --git a/@l10n/zh-CN/docs/node/docker.md b/@l10n/zh-CN/docs/node/docker.md index e8e96a14a9..57ec5dbd62 100644 --- a/@l10n/zh-CN/docs/node/docker.md +++ b/@l10n/zh-CN/docs/node/docker.md @@ -129,10 +129,10 @@ docker build \ ### 各镜像的 CMake 标志 -| 镜像 | `LOW_MEMORY_NODE` | `BUILD_TESTNET` | -|------|:-----------------:|:---------------:| -| production | OFF | OFF | -| testnet | OFF | ON | +| 镜像 | `BUILD_TESTNET` | +|------|:---------------:| +| production | OFF | +| testnet | ON | --- diff --git a/@l10n/zh-CN/docs/node/getting-started.md b/@l10n/zh-CN/docs/node/getting-started.md index e499476b82..41961058c1 100644 --- a/@l10n/zh-CN/docs/node/getting-started.md +++ b/@l10n/zh-CN/docs/node/getting-started.md @@ -172,7 +172,6 @@ curl -s -X POST http://localhost:8090 \ | 全节点 | `config.ini` | 所有插件,公共 RPC 端点 | | 验证者 | `config_witness.ini` | 区块生产,RPC 仅限本地 | | 测试网 | `config_testnet.ini` | 开发和测试 | -| 低内存 | `config.ini` + `LOW_MEMORY_NODE` 构建标志 | 仅共识,无历史索引 | --- diff --git a/docs/development/building.md b/docs/development/building.md index f25d27de5f..60d74805fb 100644 --- a/docs/development/building.md +++ b/docs/development/building.md @@ -26,10 +26,8 @@ chmod +x build-linux.sh ```bash ./build-linux.sh # Release build (default) -./build-linux.sh -l # LOW_MEMORY_NODE (validator nodes) ./build-linux.sh -n # Testnet build ./build-linux.sh -t Debug -j4 # Debug build with 4 parallel jobs -./build-linux.sh --skip-deps # Skip dependency installation ./build-linux.sh --install # Install to system after build # Custom dependency paths @@ -54,7 +52,6 @@ Requires Xcode Command Line Tools and Homebrew. The script installs: `boost`, `c **Options:** ```bash -./build-mac.sh -l # Low-memory node ./build-mac.sh -n # Testnet ./build-mac.sh --skip-deps # Skip Homebrew installs ./build-mac.sh --boost-root /opt/boost_1_74_0 @@ -77,7 +74,6 @@ build-mingw.bat | Variable | Default | Description | |----------|---------|-------------| | `VIZ_BUILD_TYPE` | Release | Release or Debug | -| `VIZ_LOW_MEMORY` | OFF | Enable low-memory node | | `VIZ_BUILD_TESTNET` | OFF | Testnet build | | `VIZ_FULL_STATIC` | OFF | Fully static binary | | `VIZ_CMAKE_EXTRA` | — | Additional CMake flags | @@ -100,7 +96,6 @@ build-msvc.bat |----------|---------|-------------| | `VIZ_VS_VERSION` | "Visual Studio 17 2022" | Visual Studio generator | | `VIZ_BUILD_TYPE` | Release | Build type | -| `VIZ_LOW_MEMORY` | OFF | Low-memory node | | `VIZ_BUILD_TESTNET` | OFF | Testnet build | **Requirements:** Visual Studio 2019+ with "Desktop development with C++" workload, CMake 3.16+. @@ -125,7 +120,6 @@ All Dockerfiles use a two-stage build to minimize image size and use Boost 1.71 | Option | Default | Description | |--------|---------|-------------| | `BUILD_TESTNET` | OFF | Build for testnet | -| `LOW_MEMORY_NODE` | OFF | Exclude non-consensus data (reduces RAM) | | `CHAINBASE_CHECK_LOCKING` | OFF | Enable lock checking (development only) | | `BUILD_SHARED_LIBRARIES` | OFF | Build shared libraries | | `USE_PCH` | OFF | Enable precompiled headers (faster rebuilds) | @@ -140,9 +134,6 @@ Wraps CMake with sensible defaults and cross-compilation support: # Release build python3 programs/build_helpers/configure_build.py --release --src ../.. -# Debug with low-memory -python3 programs/build_helpers/configure_build.py --debug --low-memory - # Cross-compile for Windows with MinGW python3 programs/build_helpers/configure_build.py --win --release diff --git a/docs/introduction/key-concepts.md b/docs/introduction/key-concepts.md index 3dd3154150..e6b53d3e26 100644 --- a/docs/introduction/key-concepts.md +++ b/docs/introduction/key-concepts.md @@ -45,6 +45,12 @@ An authority is a multi-sig structure: `{ weight_threshold, account_auths[], key - Created by staking VIZ; withdrawn back to VIZ over 28 intervals (≈28 days) - Not directly transferable; can be delegated to other accounts +### Community Symbol: Ƶ + +The community has chosen **Ƶ** as the short symbol for VIZ. Most wallets, explorers, and applications display it instead of the full ticker. + +It is also common practice to show balances with **2 decimal places** regardless of the underlying token type. Even staked funds (SHARES) are often displayed as `Ƶ` with a note that they are staked in the account, rather than switching to the `SHARES` unit and its 6-decimal format. + --- ## Energy System diff --git a/docs/node/building.md b/docs/node/building.md index 682aff4ed2..f7887aa811 100644 --- a/docs/node/building.md +++ b/docs/node/building.md @@ -46,9 +46,6 @@ Output binary: `build/programs/vizd/vizd` ### Common build flags ```bash -# Low-memory node (validators/seed nodes — excludes history indexing) -./build-linux.sh -l - # Testnet build ./build-linux.sh -n @@ -58,9 +55,6 @@ Output binary: `build/programs/vizd/vizd` # Parallel jobs ./build-linux.sh -j 8 -# Skip dependency installation (already installed) -./build-linux.sh --skip-deps - # Custom Boost / OpenSSL paths ./build-linux.sh --boost-root /opt/boost_1_74_0 --openssl-root /opt/openssl ``` @@ -99,7 +93,6 @@ Optional environment variables: | Variable | Default | Description | |----------|---------|-------------| | `VIZ_BUILD_TYPE` | `Release` | `Release` or `Debug` | -| `VIZ_LOW_MEMORY` | `OFF` | `ON` to build low-memory node | | `VIZ_BUILD_TESTNET` | `OFF` | `ON` for testnet build | | `VIZ_FULL_STATIC` | `OFF` | `ON` for fully static binary | @@ -124,7 +117,6 @@ For direct CMake usage (advanced): | Option | Default | Description | |--------|---------|-------------| | `BUILD_TESTNET` | `OFF` | Enable testnet-specific code | -| `LOW_MEMORY_NODE` | `OFF` | Exclude history/indexing plugins | | `CHAINBASE_CHECK_LOCKING` | `OFF` | Enable lock assertion checks (debug) | | `BUILD_SHARED_LIBRARIES` | `OFF` | Build shared libraries | | `USE_PCH` | `OFF` | Enable precompiled headers (faster rebuilds) | @@ -134,7 +126,6 @@ Example: ```bash mkdir build && cd build cmake -DCMAKE_BUILD_TYPE=Release \ - -DLOW_MEMORY_NODE=ON \ -DCMAKE_INSTALL_PREFIX=/usr/local \ .. make -j$(nproc) diff --git a/docs/node/docker.md b/docs/node/docker.md index 3205a19072..014ae11859 100644 --- a/docs/node/docker.md +++ b/docs/node/docker.md @@ -129,10 +129,10 @@ docker build \ ### CMake flags per image -| Image | `LOW_MEMORY_NODE` | `BUILD_TESTNET` | -|-------|:-----------------:|:---------------:| -| production | OFF | OFF | -| testnet | OFF | ON | +| Image | `BUILD_TESTNET` | +|-------|:---------------:| +| production | OFF | +| testnet | ON | --- diff --git a/docs/node/getting-started.md b/docs/node/getting-started.md index b7dae55713..5c8864e78b 100644 --- a/docs/node/getting-started.md +++ b/docs/node/getting-started.md @@ -171,7 +171,6 @@ Check `head_block_number` — it should increase every 3 seconds once synced. | Full node | `config.ini` | All plugins, public RPC endpoints | | Validator | `config_witness.ini` | Block production, RPC on localhost only | | Testnet | `config_testnet.ini` | Development and testing | -| Low-memory | `config.ini` + `LOW_MEMORY_NODE` build flag | Consensus only, no history indexes | --- diff --git a/docs/plugins/webserver.md b/docs/plugins/webserver.md index c8262af9f9..64f56709af 100644 --- a/docs/plugins/webserver.md +++ b/docs/plugins/webserver.md @@ -93,6 +93,25 @@ Subscriptions require a persistent WebSocket connection. They are not available --- +## CORS + +The webserver plugin handles browser cross-origin requests natively — no reverse proxy is required for local or development setups. + +**Preflight requests** (`OPTIONS`) are answered immediately with: + +| Response header | Value | +|----------------|-------| +| `Access-Control-Allow-Origin` | `*` | +| `Access-Control-Allow-Methods` | `POST, GET, OPTIONS` | +| `Access-Control-Allow-Headers` | `Content-Type, Authorization` | +| `Access-Control-Max-Age` | `86400` | + +**All other HTTP responses** include `Access-Control-Allow-Origin: *`. + +This allows browser-based wallets and dApps to call the JSON-RPC endpoint directly. For production deployments behind nginx, CORS is handled at the proxy layer (see [Exposing the API via HTTPS](#exposing-the-api-via-https-nginx--certbot)) — both layers setting the header is harmless. + +--- + ## Security - **Bind to localhost** (`127.0.0.1`) and use a reverse proxy (nginx/Caddy) for public exposure. Binding to `0.0.0.0` exposes the RPC directly to the network. diff --git a/libraries/network/dlt_p2p_node.cpp b/libraries/network/dlt_p2p_node.cpp index 766dc495aa..2e11dddac2 100644 --- a/libraries/network/dlt_p2p_node.cpp +++ b/libraries/network/dlt_p2p_node.cpp @@ -285,7 +285,7 @@ void dlt_p2p_node::connect_to_peer(const fc::ip::endpoint& ep) { // Send hello send_message(pid, message(build_hello_message())); - ilog(DLT_LOG_GREEN "Connected to peer ${ep}, sent DLT hello" DLT_LOG_RESET, ("ep", ep)); + dlog(DLT_LOG_GREEN "Connected to peer ${ep}, sent DLT hello" DLT_LOG_RESET, ("ep", ep)); // Start read loop as a fiber on the p2p thread start_read_loop(pid); @@ -342,23 +342,29 @@ void dlt_p2p_node::handle_disconnect(peer_id peer, const std::string& reason, bo } } - // Cancel read fiber — cancel_and_wait yields, allowing drain_send_queue - // to resume on this thread. The reentrancy guard above ensures that - // reentrant handle_disconnect call returns immediately without touching - // _peer_states, so state/it remain valid when we resume here. - auto fiber_it = _read_fibers.find(peer); - if (fiber_it != _read_fibers.end()) { - try { if (fiber_it->second.valid()) fiber_it->second.cancel_and_wait(__FUNCTION__); } catch (...) {} - _read_fibers.erase(fiber_it); - } - - // Close connection + // Close the socket FIRST — this immediately unblocks any pending readsome/writesome + // in the read fiber and drain_send_queue fiber, causing them to throw and exit. + // drain_send_queue holds sock by owning shared_ptr copy, so erasing _connections + // here does not leave it with a dangling reference. + // If we closed AFTER cancel_and_wait, the fiber would be stuck waiting for network + // I/O that can never arrive on a dead peer — causing a multi-second hang per peer, + // and a full deadlock when N peers disconnect simultaneously (p82: silent reboot). auto conn_it = _connections.find(peer); if (conn_it != _connections.end()) { try { if (conn_it->second) conn_it->second->close(); } catch (...) {} _connections.erase(conn_it); } + // Cancel read fiber — cancel_and_wait yields, but the fiber exits immediately + // because its socket I/O is already unblocked by the close() above. + // The reentrancy guard above ensures that reentrant handle_disconnect calls + // return immediately without touching _peer_states, so state/it remain valid. + auto fiber_it = _read_fibers.find(peer); + if (fiber_it != _read_fibers.end()) { + try { if (fiber_it->second.valid()) fiber_it->second.cancel_and_wait(__FUNCTION__); } catch (...) {} + _read_fibers.erase(fiber_it); + } + // Clear send guard and drain any queued messages _peer_sending.erase(peer); state.send_queue.clear(); @@ -514,6 +520,10 @@ void dlt_p2p_node::send_message(peer_id peer, const message& msg) { ++state.send_queue_total; } else { // Queue is at max depth — peer can't consume data fast enough. + // Skip if disconnect is already in progress: handle_disconnect yields + // at cancel_and_wait, allowing other fibers to call send_message for + // the same peer, which would re-enter this branch and spam the log. + if (_disconnect_in_progress.count(peer)) return; // Capture info before handle_disconnect potentially erases the state. std::string ep = std::string(state.endpoint); uint32_t dropped = state.send_queue_dropped; @@ -538,7 +548,7 @@ void dlt_p2p_node::drain_send_queue(peer_id peer, std::vector buf) { _peer_sending.erase(peer); return; } - auto& sock = conn_it->second; + auto sock = conn_it->second; // owning copy — handle_disconnect may erase _connections while we yield in writesome // Cache endpoint before entering the try block — handle_disconnect may // remove the peer from _peer_states before the catch block runs, making @@ -1770,7 +1780,7 @@ void dlt_p2p_node::on_dlt_peer_exchange_reply(peer_id peer, const dlt_peer_excha void dlt_p2p_node::on_dlt_peer_exchange_rate_limited(peer_id peer, const dlt_peer_exchange_rate_limited& msg) { auto it = _peer_states.find(peer); auto ep = (it != _peer_states.end()) ? std::string(it->second.endpoint) : std::to_string(peer); - ilog(DLT_LOG_DGRAY "Peer ${ep} rate-limited our exchange request, wait ${w}s" DLT_LOG_RESET, + dlog(DLT_LOG_DGRAY "Peer ${ep} rate-limited our exchange request, wait ${w}s" DLT_LOG_RESET, ("ep", ep)("w", msg.wait_seconds)); // Record the rate-limit locally so periodic_peer_exchange() stops diff --git a/plugins/snapshot/plugin.cpp b/plugins/snapshot/plugin.cpp index f89b3dc81b..d4e9177caf 100644 --- a/plugins/snapshot/plugin.cpp +++ b/plugins/snapshot/plugin.cpp @@ -975,6 +975,18 @@ fc::mutable_variant_object snapshot_plugin::plugin_impl::serialize_state() { EXPORT_INDEX(account_authority_index, account_authority_object, "account_authority") EXPORT_INDEX(validator_index, validator_object, "validator") EXPORT_INDEX(validator_vote_index, validator_vote_object, "validator_vote") + // Sanity: if validators exist but votes are absent, the chainbase type enum + // likely shifted (types added/removed before validator_vote_object_type). + // This would silently corrupt the snapshot. + { + auto n_validators = state["validator"].get_array().size(); + auto n_votes = state["validator_vote"].get_array().size(); + if (n_validators > 0 && n_votes == 0) + wlog("SNAPSHOT INTEGRITY: ${v} validators but 0 validator votes — " + "validator_vote_index may be empty due to chainbase type-enum mismatch. " + "Snapshot will be INCOMPLETE.", + ("v", n_validators)); + } EXPORT_INDEX(block_summary_index, block_summary_object, "block_summary") EXPORT_INDEX(content_index, content_object, "content") EXPORT_INDEX(content_vote_index, content_vote_object, "content_vote") @@ -1560,6 +1572,14 @@ void snapshot_plugin::plugin_impl::load_snapshot(const fc::path& input_path) { if (state.contains("validator_vote")) { auto n = detail::import_validator_votes(db, state["validator_vote"].get_array()); ilog(CLOG_ORANGE "Imported ${n} validator votes" CLOG_RESET, ("n", n)); + // Defensive fallback: validator_vote was present but empty; the snapshot may have + // been produced from a chainbase DB with a type-enum mismatch (see export warning). + // If an old witness_vote key also exists with data, use it to recover. + if (n == 0 && state.contains("witness_vote")) { + auto n2 = detail::import_validator_votes(db, state["witness_vote"].get_array()); + if (n2 > 0) + ilog(CLOG_ORANGE "Imported ${n} validator votes (recovered from witness_vote)" CLOG_RESET, ("n", n2)); + } } else if (state.contains("witness_vote")) { // backward compat: old snapshots used "witness_vote" key auto n = detail::import_validator_votes(db, state["witness_vote"].get_array()); diff --git a/plugins/webserver/webserver_plugin.cpp b/plugins/webserver/webserver_plugin.cpp index 3c4aadd63b..a37fd1d99d 100644 --- a/plugins/webserver/webserver_plugin.cpp +++ b/plugins/webserver/webserver_plugin.cpp @@ -421,10 +421,22 @@ namespace graphene { auto con = server->get_con_from_hdl(hdl); con->defer_http_response(); + // CORS preflight + if (con->get_request().get_method() == "OPTIONS") { + con->append_header("Access-Control-Allow-Origin", "*"); + con->append_header("Access-Control-Allow-Methods", "POST, GET, OPTIONS"); + con->append_header("Access-Control-Allow-Headers", "Content-Type, Authorization"); + con->append_header("Access-Control-Max-Age", "86400"); + con->set_status(websocketpp::http::status_code::ok); + try { con->send_http_response(); } catch (...) {} + return; + } + thread_pool_ios.post([con, this]() { auto body = con->get_request_body(); if (body.empty()) { + con->append_header("Access-Control-Allow-Origin", "*"); con->set_body("empty request body"); con->set_status(websocketpp::http::status_code::bad_request); try { con->send_http_response(); } catch (...) {} @@ -439,12 +451,14 @@ namespace graphene { // Invalid JSON — skip cache, let json_rpc handle the error try { api->call(body, [con](const std::string &data){ + con->append_header("Access-Control-Allow-Origin", "*"); con->set_body(data); con->set_status(websocketpp::http::status_code::ok); con->send_http_response(); }); } catch (fc::exception &e) { edump((e)); + con->append_header("Access-Control-Allow-Origin", "*"); con->set_body("Could not call API"); con->set_status(websocketpp::http::status_code::not_found); try { con->send_http_response(); } catch (...) {} @@ -466,6 +480,7 @@ namespace graphene { if (cached_response.valid()) { // Patch the id in cached response to match request std::string patched = patch_response_id(*cached_response, request_id); + con->append_header("Access-Control-Allow-Origin", "*"); con->set_body(patched); con->set_status(websocketpp::http::status_code::ok); con->send_http_response(); @@ -477,6 +492,7 @@ namespace graphene { api->call(body, [con, this, request_hash, cacheable](const std::string &data){ // this lambda can be called from any thread in application // for example, when task was delegated ( see msg_pack(msg_pack&&) ) + con->append_header("Access-Control-Allow-Origin", "*"); con->set_body(data); con->set_status(websocketpp::http::status_code::ok); con->send_http_response(); @@ -489,6 +505,7 @@ namespace graphene { } catch (fc::exception &e) { // this case happens if exception was thrown on parsing request edump((e)); + con->append_header("Access-Control-Allow-Origin", "*"); con->set_body("Could not call API"); con->set_status(websocketpp::http::status_code::not_found); // this sending response can't be merged with sending response from try-block diff --git a/share/vizd/config/config.ini b/share/vizd/config/config.ini index c29dd224b4..32139779ce 100644 --- a/share/vizd/config/config.ini +++ b/share/vizd/config/config.ini @@ -118,9 +118,6 @@ history-count-blocks = 57600 # Defines starting block from which recording stats by the account_history and operation_history plugin. history-start-block = 70000000 -# Set the maximum size of cached feed for an account -follow-max-feed-size = 500 - # name of validator controlled by this node (e.g. initwitness ) # validator = # # validator = # DEPRECATED: use 'validator' diff --git a/share/vizd/config/config_debug.ini b/share/vizd/config/config_debug.ini index 25c31e30de..7d26c2f992 100644 --- a/share/vizd/config/config_debug.ini +++ b/share/vizd/config/config_debug.ini @@ -73,7 +73,7 @@ inc-shared-file-size = 100M # and resizes. The optimal strategy is do checking of the free space, but not very often. block-num-check-free-size = 10 # each 30 seconds -plugin = chain p2p json_rpc webserver network_broadcast_api validator test_api database_api private_message follow social_network tags account_by_key account_history operation_history block_info raw_block debug_node witness_api +plugin = chain p2p json_rpc webserver network_broadcast_api validator test_api database_api account_by_key account_history operation_history block_info raw_block debug_node # Remove votes before defined block, should increase performance clear-votes-before-block = 0 # don't clear votes @@ -93,12 +93,6 @@ skip-virtual-ops = false # Defines starting block from which recording stats by the account_history plugin. # history-start-block = -# Set the maximum size of cached feed for an account -follow-max-feed-size = 500 - -# Defines a range of accounts to private messages to/from as a json pair ["from","to"] [from,to) -# pm-account-range = - # Enable block production, even if the chain is stale. enable-stale-production = true diff --git a/share/vizd/config/config_debug_mongo.ini b/share/vizd/config/config_debug_mongo.ini deleted file mode 100644 index 7377448471..0000000000 --- a/share/vizd/config/config_debug_mongo.ini +++ /dev/null @@ -1,143 +0,0 @@ -# Endpoint for P2P node to listen on -# p2p-endpoint = - -# Maxmimum number of incoming connections on P2P endpoint -# p2p-max-connections = - -# P2P nodes to connect to on startup (may specify multiple times) -# p2p-seed-node = - -# Enable stale sync detection: when no blocks are received for the configured timeout, -# the node resets sync from the last irreversible block and reconnects all seed peers. -# p2p-stale-sync-detection = false - -# Timeout in seconds before stale sync detection triggers recovery (default: 120 = 2 minutes). -# p2p-stale-sync-timeout-seconds = 120 - -# Pairs of [BLOCK_NUM,BLOCK_ID] that should be enforced as checkpoints. -# checkpoint = - -# Number of threads for rpc-clients. Optimal value `-1` -webserver-thread-pool-size = 2 - -# IP:PORT for HTTP connections -webserver-http-endpoint = 0.0.0.0:8090 - -# IP:PORT for WebSocket connections -webserver-ws-endpoint = 0.0.0.0:8091 - -# Maximum microseconds for trying to get read lock -read-wait-micro = 500000 - -# Maximum retries to get read lock. Each retry is read-wait-micro microseconds. -# When all retries are made, the rpc-client receives error 'Unable to acquire READ lock'. -max-read-wait-retries = 2 - -# Maximum microseconds for trying to get write lock on broadcast transaction. -write-wait-micro = 500000 - -# Maximum retries to get write lock. Each retry is write-wait-micro microseconds. -# When all retries are made, the rpc-client receives error 'Unable to acquire WRITE lock'. -max-write-wait-retries = 3 - -# Do all write operations (push_block/push_transaction) in the single thread. -# Write lock of database is very heavy. When many threads tries to lock database on writing, rpc-clients -# receive many errors 'Unable to acquire READ lock' ('Unable to acquire WRITE lock'). -# Enabling of this options can increase performance. -single-write-thread = true - -# Enable plugin notifications about operations in a pushed transaction, which should be included to the next generated -# block. Plugins doesn't validate data in operations, they only update its own indexes, so notifications can be -# disabled on push_transaction() without any side-effects. The option doesn't have effect on a pushing signed blocks, -# so it is safe. -# Disabling of this option can increase performance. -enable-plugins-on-push-transaction = true - -# A start size for shared memory file when it doesn't have any data. Possible cases: -# - If shared memory has data and the value is greater then the size of shared_memory.bin, -# the file will be grown to requested size. -# - If shared memory has data and the value is less then the size of shared_memory.bin, nothing happens. -# Changing of this parameter doesn't require the replaying. -shared-file-size = 100M - -# The minimum free space in the shared memory file. When free space reaches the following value, the size of the -# shared_memory.bin increases by the value of inc-shared-file-size. -min-free-shared-file-size = 50M - -# Step of increasing size of shared_memory.bin. When the free memory size reaches min-free-shared-file-size, -# the shared memory size increases by the following value. -inc-shared-file-size = 100M - -# How often do checking the free space in shared_memory.bin. A very frequent checking can decrease performance. -# It's not critical if the free size became very small, because the daemon catches the `bad_alloc` exception -# and resizes. The optimal strategy is do checking of the free space, but not very often. -block-num-check-free-size = 10 # each 30 seconds - -plugin = chain p2p json_rpc webserver network_broadcast_api validator test_api database_api private_message follow social_network tags market_history account_by_key account_history operation_history block_info raw_block debug_node validator_api mongo_db - -# For connect to mongodb which is running outside Docker (if vizd running inside) -mongodb-uri = mongodb://172.17.0.1:27017/viz - -# Remove votes before defined block, should increase performance -clear-votes-before-block = 0 # don't clear votes - -# Virtual operations will not be passed to the plugins, enabling of the option helps to save some memory. -skip-virtual-ops = false - -# Defines a range of accounts to track by the account_history plugin as a json pair ["from","to"] [from,to] -# track-account-range = - -# Defines a list of operations which will be explicitly logged by the account_history plugin. -# history-whitelist-ops = - -# Defines a list of operations which will be explicitly ignored by the account_history plugin. -# history-blacklist-ops = - -# Defines starting block from which recording stats by the account_history plugin. -# history-start-block = - -# Set the maximum size of cached feed for an account -follow-max-feed-size = 500 - -# Track market history by grouping orders into buckets of equal size measured in seconds specified as a JSON array of numbers -bucket-size = [15,60,300,3600,86400] - -# How far back in time to track history for each bucket size, measured in the number of buckets (default: 5760) -history-per-size = 5760 - -# Defines a range of accounts to private messages to/from as a json pair ["from","to"] [from,to) -# pm-account-range = - -# Enable block production, even if the chain is stale. -enable-stale-production = true - - -# Percent of validators (0-99) that must be participating in order to produce blocks -required-participation = 0 - -# name of validator controlled by this node (e.g. initwitness ) -validator = "viz" -# validator = "viz" # DEPRECATED: use 'validator' - -# WIF PRIVATE KEY to be used by one or more validators -private-key = 5JVFFWRLwz6JoP9kguuRFfytToGU6cLgBVTL9t6NB3D3BQLbUBS - -# declare an appender named "stderr" that writes messages to the console -[log.console_appender.stderr] -stream=std_error - -# declare an appender named "p2p" that writes messages to p2p.log -[log.file_appender.p2p] -filename=logs/p2p/p2p.log -# filename can be absolute or relative to this config file - -# route any messages logged to the default logger to the "stderr" logger we -# declared above, if they are info level are higher -[logger.default] -level=info -appenders=stderr - -# route messages sent to the "p2p" logger to stderr too -[logger.p2p] -level=info -appenders=stderr diff --git a/share/vizd/config/config_mongo.ini b/share/vizd/config/config_mongo.ini deleted file mode 100644 index a8ee8be8e6..0000000000 --- a/share/vizd/config/config_mongo.ini +++ /dev/null @@ -1,143 +0,0 @@ -# Endpoint for P2P node to listen on -p2p-endpoint = 0.0.0.0:4243 - -# Maxmimum number of incoming connections on P2P endpoint -# p2p-max-connections = - -# P2P nodes to connect to on startup (may specify multiple times) -# p2p-seed-node = - -# Enable stale sync detection: when no blocks are received for the configured timeout, -# the node resets sync from the last irreversible block and reconnects all seed peers. -# p2p-stale-sync-detection = false - -# Timeout in seconds before stale sync detection triggers recovery (default: 120 = 2 minutes). -# p2p-stale-sync-timeout-seconds = 120 - -# Pairs of [BLOCK_NUM,BLOCK_ID] that should be enforced as checkpoints. -# checkpoint = - -# Number of threads for rpc-clients. The optimal value is `-1` -webserver-thread-pool-size = 2 - -# IP:PORT for HTTP connections -webserver-http-endpoint = 0.0.0.0:8090 - -# IP:PORT for WebSocket connections -webserver-ws-endpoint = 0.0.0.0:8091 - -# Maximum microseconds for trying to get read lock -read-wait-micro = 500000 - -# Maximum retries to get read lock. Each retry is read-wait-micro microseconds. -# When all retries are made, the rpc-client receives error 'Unable to acquire READ lock'. -max-read-wait-retries = 2 - -# Maximum microseconds for trying to get write lock on broadcast transaction. -write-wait-micro = 500000 - -# Maximum retries to get write lock. Each retry is write-wait-micro microseconds. -# When all retries are made, the rpc-client receives error 'Unable to acquire WRITE lock'. -max-write-wait-retries = 3 - -# Do all write operations (push_block/push_transaction) in the single thread. -# Write lock of database is very heavy. When many threads tries to lock database on writing, rpc-clients -# receive many errors 'Unable to acquire READ lock' ('Unable to acquire WRITE lock'). -# Enabling of this options can increase performance. -single-write-thread = true - -# Enable plugin notifications about operations in a pushed transaction, which should be included to the next generated -# block. Plugins doesn't validate data in operations, they only update its own indexes, so notifications can be -# disabled on push_transaction() without any side-effects. The option doesn't have effect on a pushing signed blocks, -# so it is safe. -# Disabling of this option can increase performance. -enable-plugins-on-push-transaction = false - -# A start size for shared memory file when it doesn't have any data. Possible cases: -# - If shared memory has data and the value is greater then the size of shared_memory.bin, -# the file will be grown to requested size. -# - If shared memory has data and the value is less then the size of shared_memory.bin, nothing happens. -# Changing of this parameter doesn't require the replaying. -shared-file-size = 2G - -# The minimum free space in the shared memory file. When free space reaches the following value, the size of the -# shared_memory.bin increases by the value of inc-shared-file-size. -min-free-shared-file-size = 500M - -# Step of increasing size of shared_memory.bin. When the free memory size reaches min-free-shared-file-size, -# the shared memory size increases by the following value. -inc-shared-file-size = 2G - -# How often do checking the free space in shared_memory.bin. A very frequent checking can decrease performance. -# It's not critical if the free size became very small, because the daemon catches the `bad_alloc` exception -# and resizes. The optimal strategy is do checking of the free space, but not very often. -block-num-check-free-size = 1000 # each 3000 seconds - -plugin = chain p2p json_rpc webserver network_broadcast_api validator test_api database_api private_message follow social_network tags market_history account_by_key operation_history account_history block_info raw_block validator_api mongo_db - -# For connect to mongodb which is running outside Docker (if vizd running inside) -mongodb-uri = mongodb://172.17.0.1:27017/viz - -# Remove votes before defined block, should increase performance -clear-votes-before-block = 0 # clear votes after each cashout - -# Virtual operations will not be passed to the plugins, enabling of the option helps to save some memory. -skip-virtual-ops = false - -# Defines a range of accounts to track by the account_history plugin as a json pair ["from","to"] [from,to] -# track-account-range = - -# Defines a list of operations which will be explicitly logged by the account_history plugin. -# history-whitelist-ops = account_create_operation account_update_operation content_operation delete_content_operation vote_operation author_reward_operation curation_reward_operation transfer_operation transfer_to_vesting_operation withdraw_vesting_operation witness_update_operation account_witness_vote_operation account_witness_proxy_operation fill_vesting_withdraw_operation shutdown_witness_operation custom_json_operation request_account_recovery_operation recover_account_operation change_recovery_account_operation escrow_transfer_operation escrow_approve_operation escrow_dispute_operation escrow_release_operation content_benefactor_reward_operation - -# Defines a list of operations which will be explicitly ignored by the account_history plugin. -# history-blacklist-ops = - -# Defines starting block from which recording stats by the account_history plugin. -# history-start-block = 0 - -# Set the maximum size of cached feed for an account -follow-max-feed-size = 500 - -# Track market history by grouping orders into buckets of equal size measured in seconds specified as a JSON array of numbers -bucket-size = [15,60,300,3600,86400] - -# How far back in time to track history for each bucket size, measured in the number of buckets (default: 5760) -history-per-size = 5760 - -# Defines a range of accounts to private messages to/from as a json pair ["from","to"] [from,to) -# pm-account-range = - -# Enable block production, even if the chain is stale. -enable-stale-production = false - - -# Percent of validators (0-99) that must be participating in order to produce blocks -required-participation = 0 - -# name of validator controlled by this node (e.g. initwitness ) -# validator = -# # validator = # DEPRECATED: use 'validator' - -# WIF PRIVATE KEY to be used by one or more validators -# private-key = - -# declare an appender named "stderr" that writes messages to the console -[log.console_appender.stderr] -stream=std_error - -# declare an appender named "p2p" that writes messages to p2p.log -[log.file_appender.p2p] -filename=logs/p2p/p2p.log -# filename can be absolute or relative to this config file - -# route any messages logged to the default logger to the "stderr" logger we -# declared above, if they are info level are higher -[logger.default] -level=debug -appenders=stderr - -# route messages sent to the "p2p" logger to stderr too -[logger.p2p] -level=error -appenders=stderr diff --git a/share/vizd/config/config_stock_exchange.ini b/share/vizd/config/config_stock_exchange.ini index 3a89b81b94..48a413df51 100644 --- a/share/vizd/config/config_stock_exchange.ini +++ b/share/vizd/config/config_stock_exchange.ini @@ -73,7 +73,7 @@ inc-shared-file-size = 2G # and resizes. The optimal strategy is do checking of the free space, but not very often. block-num-check-free-size = 1000 # each 3000 seconds -plugin = chain p2p json_rpc webserver network_broadcast_api validator database_api block_info raw_block operation_history account_history witness_api +plugin = chain p2p json_rpc webserver network_broadcast_api validator database_api block_info raw_block operation_history account_history # Remove votes before defined block, should increase performance clear-votes-before-block = 0 # clear votes after each cashout diff --git a/share/vizd/config/config_testnet.ini b/share/vizd/config/config_testnet.ini index 7281d042b8..83e1ebaa6d 100644 --- a/share/vizd/config/config_testnet.ini +++ b/share/vizd/config/config_testnet.ini @@ -73,7 +73,7 @@ inc-shared-file-size = 2G # and resizes. The optimal strategy is do checking of the free space, but not very often. block-num-check-free-size = 1000 # each 3000 seconds -plugin = validator witness_api +plugin = validator plugin = chain p2p json_rpc webserver network_broadcast_api database_api plugin = account_history operation_history plugin = committee_api invite_api paid_subscription_api custom_protocol_api @@ -97,12 +97,6 @@ skip-virtual-ops = false # Defines starting block from which recording stats by the account_history plugin. # history-start-block = 0 -# Set the maximum size of cached feed for an account -follow-max-feed-size = 500 - -# Defines a range of accounts to private messages to/from as a json pair ["from","to"] [from,to) -# pm-account-range = - # Enable block production, even if the chain is stale. enable-stale-production = true