Compare commits

...

4 Commits

Author SHA1 Message Date
676984ba8e feat: 更新 .gitignore 文件
All checks were successful
Build and Release / build-and-test (arm64, alpine) (push) Successful in 6s
Build and Release / build-and-test (amd64, alpine) (push) Successful in -39s
Build and Release / build-and-test (arm64, ubuntu) (push) Successful in 17s
Build and Release / build-and-test (amd64, ubuntu) (push) Successful in -19s
Build and Release / release (push) Has been skipped
2026-01-24 09:16:38 +08:00
961b2d3702 chore: 删除过时的文档文件以清理项目结构 2026-01-24 09:15:25 +08:00
8f7cca95fe feat: 添加内存锁定资源限制以支持 RandomX 大页内存优化
All checks were successful
Build and Release / build-and-test (arm64, alpine) (push) Successful in 9s
Build and Release / build-and-test (amd64, alpine) (push) Successful in -38s
Build and Release / build-and-test (arm64, ubuntu) (push) Successful in 18s
Build and Release / build-and-test (amd64, ubuntu) (push) Successful in -24s
Build and Release / release (push) Has been skipped
2026-01-23 11:36:52 +08:00
8f0463687e fix: 修复 apt 升级后服务需要手动重新启用的问题
- 修改 prerm 脚本,升级时只停止服务不禁用
- 修改 postinst 脚本,升级后自动重启已启用的服务
- 首次安装仍保持手动启用服务的行为
2026-01-23 11:35:32 +08:00
14 changed files with 68 additions and 688 deletions

7
.gitignore vendored
View File

@@ -1,6 +1,11 @@
.DS_Store
.idea/ .idea/
.vscode/ .vscode/
.claude/ .claude/
CLAUDE.md
docs/ docs/
example/ example/
llmdoc/
CLAUDE.md

View File

@@ -15,6 +15,10 @@ StandardOutput=journal
StandardError=journal StandardError=journal
SyslogIdentifier=p2pool SyslogIdentifier=p2pool
# Resource limits
LimitMEMLOCK=infinity
AmbientCapabilities=CAP_IPC_LOCK
# Security hardening # Security hardening
NoNewPrivileges=true NoNewPrivileges=true
PrivateTmp=true PrivateTmp=true

33
debian/postinst vendored
View File

@@ -13,13 +13,13 @@ if ! getent passwd p2pool >/dev/null; then
fi fi
# Create data directory # Create data directory
mkdir -p /var/lib/p2pool mkdir -p /var/lib/p2pool/data-api
chown p2pool:p2pool /var/lib/p2pool chown -R p2pool:p2pool /var/lib/p2pool
chmod 750 /var/lib/p2pool chmod -R 750 /var/lib/p2pool
# Create example params.conf if it doesn't exist # Create example params.conf if it doesn't exist
if [ ! -f /var/lib/p2pool/params.conf ]; then if [ ! -f /var/lib/p2pool/params.conf ]; then
cat > /var/lib/p2pool/params.conf << 'EOF' cat > /var/lib/p2pool/params.conf << 'CONF'
# P2Pool Configuration File # P2Pool Configuration File
# Edit this file with your settings and restart the service # Edit this file with your settings and restart the service
@@ -28,6 +28,12 @@ host = 127.0.0.1
rpc-port = 18081 rpc-port = 18081
zmq-port = 18083 zmq-port = 18083
# Use SSL for RPC connection
# rpc-ssl = true
# RPC credentials (if applicable)
# rpc-login = username:password
# Your Monero wallet address (REQUIRED) # Your Monero wallet address (REQUIRED)
wallet = YOUR_MONERO_WALLET_ADDRESS wallet = YOUR_MONERO_WALLET_ADDRESS
@@ -46,11 +52,11 @@ loglevel = 3
# mini = true # mini = true
# Merge mining (optional - uncomment to enable Tari merge mining) # Merge mining (optional - uncomment to enable Tari merge mining)
# merge-mine = tari://TARI_NODE_IP:18102 TARI_WALLET_ADDRESS # merge-mine = tari://TARI_NODE_IP:18142 TARI_WALLET_ADDRESS
# Stratum server (for miners to connect) # Stratum server (for miners to connect)
# stratum = 0.0.0.0:3333 # stratum = 0.0.0.0:3333
EOF CONF
chown p2pool:p2pool /var/lib/p2pool/params.conf chown p2pool:p2pool /var/lib/p2pool/params.conf
chmod 640 /var/lib/p2pool/params.conf chmod 640 /var/lib/p2pool/params.conf
fi fi
@@ -64,9 +70,22 @@ chmod 750 /var/log/p2pool
chown root:root /opt/p2pool/p2pool chown root:root /opt/p2pool/p2pool
chmod 755 /opt/p2pool/p2pool chmod 755 /opt/p2pool/p2pool
# Reload systemd # Reload systemd and handle service restart on upgrade
if [ -d /run/systemd/system ]; then if [ -d /run/systemd/system ]; then
systemctl daemon-reload systemctl daemon-reload
# On upgrade: restart service if it was enabled
if [ "$1" = "configure" ] && [ -n "$2" ]; then
# $2 is the previously installed version (only set on upgrade)
if systemctl is-enabled --quiet p2pool.service 2>/dev/null; then
echo "Restarting p2pool service after upgrade..."
systemctl start p2pool.service || true
fi
fi
# Note: On fresh install, service is NOT auto-enabled or auto-started
# Users should manually enable the service:
# systemctl enable p2pool.service
# systemctl start p2pool.service
fi fi
echo "" echo ""

26
debian/prerm vendored
View File

@@ -1,17 +1,33 @@
#!/bin/sh case "$1" in
set -e upgrade)
# Stop service only during upgrade, keep enabled state
# Stop and disable service if running if [ -d /run/systemd/system ]; then
if systemctl is-active --quiet p2pool.service; then
echo "Stopping p2pool service for upgrade..."
systemctl stop p2pool.service
fi
fi
;;
remove|deconfigure)
# Stop and disable service during removal
if [ -d /run/systemd/system ]; then if [ -d /run/systemd/system ]; then
if systemctl is-active --quiet p2pool.service; then if systemctl is-active --quiet p2pool.service; then
echo "Stopping p2pool service..." echo "Stopping p2pool service..."
systemctl stop p2pool.service systemctl stop p2pool.service
fi fi
if systemctl is-enabled --quiet p2pool.service 2>/dev/null; then if systemctl is-enabled --quiet p2pool.service 2>/dev/null; then
echo "Disabling p2pool service..." echo "Disabling p2pool service..."
systemctl disable p2pool.service systemctl disable p2pool.service
fi fi
fi fi
;;
failed-upgrade)
# Do nothing on failed upgrade
;;
*)
echo "prerm called with unknown argument \`$1'" >&2
exit 1
;;
esac
exit 0 exit 0

View File

@@ -1,83 +0,0 @@
# CI/CD 架构
## 流水线概述
P2Pool 构建系统使用 Gitea Actions 实现自动化构建、测试和发布流程。
## 构建矩阵
### 架构支持
- amd64
- arm64
### 发行版本
- Ubuntu
- Alpine Linux
### 构建组合
- 总计 4 种构建变体:
1. amd64 + Ubuntu
2. amd64 + Alpine
3. arm64 + Ubuntu
4. arm64 + Alpine
## 流水线触发条件
### 自动触发
- 推送到 `main``develop` 分支
- 创建 Git 标签(发布版本)
## 流水线阶段
### 构建与测试阶段
```yaml
jobs:
build-and-test:
strategy:
matrix:
arch: [amd64, arm64]
distro: [ubuntu, alpine]
# 使用原生架构的 runner
runs-on: >-
${{
matrix.arch == 'amd64' && 'ubuntu-latest-amd64' ||
'ubuntu-latest-arm64'
}}
```
### 关键步骤
1. 设置 Docker Buildx
2. 构建二进制文件
3. 打包为 tar.gz
4. 对于 Ubuntu创建 Debian 包
5. 上传构建产物
### 发布阶段
- 下载所有构建产物
- 上传到 Gitea 通用包仓库
- 上传 Debian 包
- 创建发布版本
- 附加下载链接
## 性能特点
### 原生架构构建
- 比 QEMU 跨架构编译快 3-10 倍
- 构建稳定性高
- 需要专用的 amd64 和 arm64 runner
### 编译并行度
- amd64使用一半 CPU 核心
- arm64使用全部 CPU 核心
- 跨架构编译:限制为 2 个并行作业
## 关键配置文件
- [.gitea/workflows/ci.yaml](../../.gitea/workflows/ci.yaml):主要 CI/CD 配置
## 安全与性能平衡
- 限制并行编译作业数
- 使用原生架构 runner
- 避免使用 QEMU 虚拟化

View File

@@ -1,45 +0,0 @@
# Debian 打包架构
## 1. 身份
- **目的**:为 p2pool 构建跨架构的 Debian 软件包
- **关键功能**:多架构支持、自动化构建和发布
## 2. 核心组件
关键文件:
- `.gitea/workflows/ci.yaml`CI/CD 流程
- `debian/build-deb.sh`Debian 打包脚本
- `debian/control`:软件包元数据
- `debian/postinst`:安装后脚本
- `debian/postrm`:卸载后脚本
## 3. 构建流程
1. **架构选择**
- `amd64`: 64位 x86 架构
- `arm64`: ARM 64位架构
2. **发行版目标**
- `stable`:统一的稳定发行版仓库
3. **Package Registry**
- Generic Package Registry存储 `.tar.gz`
- Debian Package Registry存储 `.deb`
## 4. 配置管理
- 配置文件:`/var/lib/p2pool/params.conf`
- 安全原则:
- 配置与二进制包分离
- 升级时保留用户配置
- 最小权限原则
## 5. 发布策略
- 自动化版本发布
- 标签触发(`refs/tags/*`
- 多渠道发布:
1. Generic Package Registry
2. Debian Package Registry
3. GitHub/Gitea Releases

View File

@@ -1,93 +0,0 @@
# Docker 构建架构
## 多阶段构建策略
P2Pool 的 Docker 构建使用多阶段构建,确保最终镜像轻量且安全。
### 构建阶段概览
```
┌─────────────────────────────────────────────────┐
│ 阶段 1基础镜像 (Alpine 3.21 / Ubuntu 24.04) │
│ - 安装构建依赖: │
│ git, cmake, gcc, g++, make │
│ libuv-dev, libzmq-dev, libcurl-dev │
└─────────────────┬───────────────────────────────┘
┌─────────────────▼───────────────────────────────┐
│ 阶段 2构建 │
│ 1. 从 GitHub 克隆 p2pool使用 --recursive
│ 2. 检出指定的 P2POOL_VERSION 标签 │
│ 3. CMake 配置: │
│ - 发布构建 │
│ - 禁用合并挖矿捐赠 │
│ 4. 使用 make 编译: │
│ - 交叉编译:-j2 │
│ - amd64-j$(nproc / 2) │
│ - arm64-j$(nproc) │
└─────────────────┬───────────────────────────────┘
┌─────────────────▼───────────────────────────────┐
│ 阶段 3提取 (scratch 镜像) │
│ - 将二进制文件复制到 /linux_${TARGETARCH}/ │
│ - 启用 Docker buildx 本地文件提取 │
└──────────────────────────────────────────────────┘
```
## 关键构建参数
### 版本控制
- `P2POOL_VERSION`:指定上游 p2pool 版本
- 使用 `--build-arg` 传递版本
### 编译配置
- `-DWITH_MERGE_MINING_DONATION=OFF`:禁用合并挖矿捐赠
- 不同架构的编译并行度控制
## 镜像变体
### Alpine 镜像 (推荐)
- 基于 Alpine Linux
- 镜像体积小
- 安全性高
- 文件:`docker/Dockerfile.alpine`
### Ubuntu 镜像
- 基于 Ubuntu LTS
- 更广泛的系统兼容性
- 文件:`docker/Dockerfile.ubuntu`
## 构建命令示例
```bash
# Alpine 构建(推荐)
docker buildx build --pull \
--platform linux/amd64 \
--build-arg P2POOL_VERSION=v4.9.1 \
--output type=local,dest=./output \
-f docker/Dockerfile.alpine .
# 多架构构建
docker buildx build --pull \
--platform linux/amd64,linux/arm64 \
--build-arg P2POOL_VERSION=v4.9.1 \
--output type=local,dest=./output \
-f docker/Dockerfile.alpine .
```
## 性能优化策略
### 并行度控制
- amd64`$(nproc) / 2`(减少资源竞争)
- arm64`$(nproc)`(充分利用资源)
### 缓存优化
- 使用多阶段构建减少最终镜像大小
- 利用 Docker 构建缓存
## 注意事项
- 需要 Docker Buildx 支持
- 构建需要互联网连接
- 克隆上游仓库需要 `--recursive` 参数
- 编译过程禁用合并挖矿捐赠功能

View File

@@ -1,135 +0,0 @@
# Debian 包安装与配置指南
## 安装步骤
### 添加 Gitea 包仓库
```bash
# 导入 Gitea 仓库密钥
sudo curl https://GITEA_URL/api/packages/OWNER/debian/repository.key \
-o /etc/apt/keyrings/gitea-OWNER.asc
# 添加仓库源(以 Debian 12 为例)
echo "deb [signed-by=/etc/apt/keyrings/gitea-OWNER.asc] \
https://GITEA_URL/api/packages/OWNER/debian stable main" | \
sudo tee /etc/apt/sources.list.d/OWNER.list
# 更新包列表并安装
sudo apt-get update
sudo apt-get install p2pool
```
## 配置 P2Pool
### 编辑配置文件
P2Pool 使用配置文件 `/var/lib/p2pool/params.conf` 来管理所有设置。安装后会自动创建示例配置文件。
```bash
# 编辑配置文件
sudo nano /var/lib/p2pool/params.conf
```
配置文件示例:
```conf
# P2Pool Configuration File
# Monero node connection
host = 127.0.0.1
rpc-port = 18081
zmq-port = 18083
# Your Monero wallet address (REQUIRED)
wallet = YOUR_MONERO_WALLET_ADDRESS
# P2P settings
p2p = 0.0.0.0:37889
# API settings
data-api = /var/lib/p2pool/data-api
local-api = true
# Logging
log-file = /var/log/p2pool/p2pool.log
loglevel = 3
# Mining mode (uncomment to enable mini sidechain)
# mini = true
# Stratum server (for miners to connect)
# stratum = 0.0.0.0:3333
```
### 关键配置参数
- `host`Monero 节点的 IP 地址
- `rpc-port`Monero 节点的 RPC 端口
- `zmq-port`Monero 节点的 ZMQ 端口
- `wallet`**必需** - 您的 Monero 钱包地址
- `mini`:启用 mini 侧链(适合算力较小的矿工)
- `stratum`Stratum 服务器地址,供矿机连接
- `loglevel`日志级别0-63 为默认值)
### 配置文件的优势
-**版本升级安全**`params.conf``apt upgrade` 时不会被覆盖
-**易于管理**:所有配置集中在一个文件中
-**支持注释**:可以添加说明和注释
-**无需修改 systemd**:避免编辑系统服务文件
## 启动和管理服务
```bash
# 启用服务,设置开机自启
sudo systemctl enable p2pool.service
# 启动服务
sudo systemctl start p2pool.service
# 查看服务状态
sudo systemctl status p2pool.service
# 查看实时日志
sudo journalctl -u p2pool -f
```
## 目录结构
- `/opt/p2pool/p2pool`P2Pool 二进制文件
- `/var/lib/p2pool/`:数据目录
- `/var/log/p2pool/`:日志目录
## 安全建议
- 使用专用钱包地址
- 限制 Stratum 端口的网络访问
- 定期更新 p2pool 版本
## 故障排查
### 常见错误
- RPC 端口配置不正确
- 钱包地址无效
- 网络连接问题
### 检查日志
```bash
# 查看完整日志
sudo cat /var/log/p2pool/p2pool.log
# 查看最近错误
sudo journalctl -u p2pool -n 50 --no-pager
```
## 版本管理
```bash
# 查看当前版本
/opt/p2pool/p2pool --version
# 检查可用更新
sudo apt-get update
sudo apt-cache policy p2pool
```

View File

@@ -1,88 +0,0 @@
# 本地构建指南
## 准备工作
### 系统依赖
- Docker
- Docker Buildx
- Git
### 安装 Docker Buildx
```bash
# 启用 QEMU支持多平台构建
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
# 创建 buildx builder
docker buildx create --use --name p2pool_builder --driver docker-container
docker buildx inspect --bootstrap
```
## 构建二进制包
### Alpine 构建(推荐)
```bash
# 构建单一架构
docker buildx build --pull \
--platform linux/amd64 \
--build-arg P2POOL_VERSION=v4.9.1 \
--output type=local,dest=./output \
-f docker/Dockerfile.alpine .
# 多架构构建
docker buildx build --pull \
--platform linux/amd64,linux/arm64 \
--build-arg P2POOL_VERSION=v4.9.1 \
--output type=local,dest=./output \
-f docker/Dockerfile.alpine .
```
### Ubuntu 构建
```bash
docker buildx build --pull \
--platform linux/amd64 \
--build-arg P2POOL_VERSION=v4.9.1 \
--output type=local,dest=./output \
-f docker/Dockerfile.ubuntu .
```
## 构建 Debian 包
```bash
# 打包二进制文件
TARGZ="p2pool-amd64-ubuntu-v4.12.tar.gz"
tar -czf "${TARGZ}" -C ./output/linux_amd64 .
# 生成 Debian 包
./debian/build-deb.sh amd64 v4.12 "${TARGZ}"
```
## 常见问题排查
### 调整编译并行度
修改 Dockerfile 中的 `MAKE_JOBS` 变量:
```dockerfile
# 使用全部 CPU 核心amd64
elif [ "$TARGETARCH" = "amd64" ]; then \
MAKE_JOBS="-j$(nproc)";
# 或使用固定作业数
elif [ "$TARGETARCH" = "amd64" ]; then \
MAKE_JOBS="-j4";
```
### 网络和依赖问题
- 确保 Docker 可以访问互联网
- 检查 Git 子模块是否正确初始化
- 验证 CMake 和编译器版本兼容性
## 性能提示
- 使用 SSD 提高构建速度
- 保持 Docker 镜像和依赖更新
- 对于大型项目,考虑使用构建缓存

View File

@@ -1,13 +0,0 @@
# p2pool 文档系统
## 概述 (Overview)
- [CI 工作流程](/llmdoc/overview/ci-workflow.md)
## 指南 (Guides)
- [Debian 包安装](/llmdoc/guides/debian-package.md)
## 架构 (Architecture)
- [Debian 打包架构](/llmdoc/architecture/debian-packaging.md)
## 参考 (Reference)
(暂无)

View File

@@ -1,24 +0,0 @@
# CI 工作流程概述
## 1. 身份
- **目的**:自动化构建、测试和发布 p2pool 软件包
- **关键功能**:支持多架构、多发行版的软件包构建和发布
## 2. 高层描述
CI 工作流程通过 Gitea 工作流实现自动化构建和发布:
- 支持架构:`amd64``arm64`
- 支持发行版:`ubuntu``alpine`
- 发布目标:
1. Generic Package Registry
2. Debian Package Registry (stable)
3. GitHub/Gitea Releases
## 3. 关键文件
- `.gitea/workflows/ci.yaml`:主要工作流配置
- `debian/build-deb.sh`Debian 打包脚本
- `docker/Dockerfile.ubuntu`Ubuntu 构建镜像
- `docker/Dockerfile.alpine`Alpine 构建镜像

View File

@@ -1,45 +0,0 @@
# 项目概述P2Pool Docker 构建基础设施
## 项目背景
P2Pool 是一个去中心化的 Monero 矿池,本项目旨在提供一个标准化、可靠的构建和打包基础设施。
## 主要目标
1. 自动化构建 p2pool 二进制包
2. 支持多架构amd64, arm64
3. 生成 Debian 和通用包
4. 禁用合并挖矿捐赠功能
## 构建输出
- **二进制包**
- amd64 架构
- arm64 架构
- **包格式**
- tar.gz 压缩包
- Debian 包(.deb
- **构建基础镜像**
- Alpine Linux (推荐)
- Ubuntu LTS
## 关键特性
- 使用 Docker 多阶段构建
- 通过 Gitea Actions 自动化 CI/CD
- 支持版本化构建
- 原生架构构建,性能优化
- 自动包发布到 Gitea 包仓库
## 版本管理
- 直接从 [SChernykh/p2pool](https://github.com/SChernykh/p2pool) 上游仓库构建
- 通过 `P2POOL_VERSION` 环境变量控制构建版本
- 使用 Git 标签管理版本发布
## 使用限制
- 不包含 p2pool 源代码
- 构建时需要互联网连接
- 依赖 Docker Buildx
- 需要配置钱包地址才能运行服务

View File

@@ -1,59 +0,0 @@
# 编码规范
## Shell 脚本规范
### 基本原则
- 使用 `#!/bin/sh` 作为脚本头
- 遵循 POSIX shell 标准
- 避免使用 Bash 特定语法
### 缩进与格式
- 使用 4 个空格缩进
- 每个代码块使用一致的缩进
- 长行使用 `\` 换行
### 变量使用
- 使用双引号包裹变量:`"$VARIABLE"`
- 避免未定义变量
- 使用 `${VARIABLE:-default}` 设置默认值
### 示例
```sh
#!/bin/sh
set -eu
# 变量定义
P2POOL_VERSION="${1:-v4.9.1}"
OUTPUT_DIR="${2:-./output}"
# 函数定义
build_p2pool() {
local arch="$1"
local distro="$2"
docker buildx build --pull \
--platform "linux/${arch}" \
--build-arg "P2POOL_VERSION=${P2POOL_VERSION}" \
--output "type=local,dest=${OUTPUT_DIR}" \
-f "docker/Dockerfile.${distro}" .
}
# 主逻辑
main() {
build_p2pool "amd64" "alpine"
}
main "$@"
```
## Docker 文件规范
- 遵循多阶段构建
- 尽量减少镜像层数
- 使用多架构构建
- 避免在构建过程中下载可变内容
## Git 提交规范
- 使用清晰、简洁的提交信息
- 提交信息应描述**为什么**做这个改动
- 使用动词开头:添加(Add)、修复(Fix)、优化(Improve)等

View File

@@ -1,79 +0,0 @@
# Git 协作规范
## 分支管理
### 主分支
- `main`: 稳定版本
- `develop`: 开发分支
### 开发流程
1.`develop` 创建功能分支
2. 功能分支命名规范:
- `feature/` 前缀表示新功能
- `bugfix/` 前缀表示 bug 修复
- `docs/` 前缀表示文档更新
### 示例分支创建
```bash
# 从 develop 创建功能分支
git checkout develop
git pull origin develop
git checkout -b feature/add-architecture-docs
```
## 提交规范
### 提交信息格式
```
<类型>: <简要描述>
[可选的详细说明]
[关联的 issue 或 PR]
```
### 类型定义
- `feat`: 新功能
- `fix`: 修复 bug
- `docs`: 文档更新
- `style`: 代码风格调整
- `refactor`: 重构
- `test`: 测试相关
- `build`: 构建系统或外部依赖变更
- `ci`: CI 配置变更
### 提交示例
```bash
docs: 添加 p2pool 构建文档系统
- 创建 llmdoc 目录结构
- 添加项目概述文档
- 编写编码和 Git 规范文档
关联 Issue: #123
```
## 代码审查
### 合并请求(PR)规范
- 所有 PR 必须从功能分支提交到 `develop`
- PR 标题应简洁描述变更
- PR 描述必须包含:
1. 变更的目的
2. 具体实现
3. 测试方法
- 至少需要一个审查者批准
## 版本标签
### 版本命名
- 使用语义化版本 (Semantic Versioning)
- 格式:`vMAJOR.MINOR.PATCH`
- 示例:`v4.12.0`
### 发布流程
```bash
# 创建版本标签
git tag v4.12.0
git push origin v4.12.0
```