Skip to content

cbdc-chain · 配置

TIP

配置 schema 由各应用 internal/conf/conf.proto 定义;运行时配置为 cbdc-biz/conf/<role>/core.yaml(容器内挂载到 /conf)。本章只列源码 / 配置可核实的字段。

顶层环境变量

来源:cbdc-biz/.env.examplecbdc-network/.env.exampleREADME.md:99-136

变量用途
KMS_USER_PINsign-kms 签发的 JWT access token(用作 PKCS#11 token 的 PIN)
KMS_TOKEN_LABELPKCS#11 token label;默认 KMS_TK
SIGN_KMS_ENDPOINTKMS gRPC(如 cbdc-dev.sign.global:9200
CA_URL含 admin 凭据的 Fabric CA URL(如 http://admin:adminpw@cbdc-dev.sign.global:7054),用于 gen_crypto.sh enroll
CA_HOST无凭据 Fabric CA 地址(如 http://cbdc-dev.sign.global:7054),bizhub 运行时读取
IMAGE_PREFIX镜像 registry 前缀;cbdc-dev.sign.global:5000
OTLP_ENDPOINTOTLP collector(如 host.docker.internal:4317
COMMITTER_NOTIFICATION_ADDR / COMMITTER_QUERY_ADDRcommitter sidecar 通知流 / query-service 地址
BIZHUB_ADDR / UPSTREAM_ISSUER_ADDR / INSTITUTION_001_ADDRbizhub 与下游节点互调地址
FSC_*_ADDR各节点 FSC P2P 解析地址(auditor/issuer/endorser1/institution-001)
TLS_ENABLEDTLS 总开关;默认 true
TLS_CLIENT_AUTH_REQUIREDmTLS 客户端证书要求;默认 true

JWT_SECRET(KMS namespace 管理认证)仅在 README 的手动初始化示例中出现(README.md:99-112,示例值 c33c66f24581fc59bcf107da7f21e51d6549be30aa016cf21fb6c2f8dd70abdb),不在 .env.example 中。

cbdc-biz/.env.example(节选)

dotenv
IMAGE_PREFIX=cbdc-dev.sign.global:5000
DOCKER_TOOLS_IMAGE=cbdc-dev.sign.global:5000/cbdc-tool:v0.0.6
SIGN_KMS_ENDPOINT=cbdc-dev.sign.global:9200
KMS_TOKEN_LABEL=KMS_TK
KMS_USER_PIN=<JWT access token from KMS>
CA_URL=http://admin:adminpw@cbdc-dev.sign.global:7054
CA_HOST=http://cbdc-dev.sign.global:7054
OTLP_ENDPOINT=host.docker.internal:4317
TLS_ENABLED=true
TLS_CLIENT_AUTH_REQUIRED=true
BIZHUB_ADDR=host.docker.internal:9000
UPSTREAM_ISSUER_ADDR=issuer:9100
INSTITUTION_001_ADDR=institution-001:9500

cbdc-network/.env.example

dotenv
SIGN_KMS_ENDPOINT=cbdc-dev.sign.global:9200
KMS_TOKEN_LABEL=KMS_TK
KMS_USER_PIN=<JWT token>
CA_URL=http://admin:adminpw@cbdc-dev.sign.global:7054
TLS_ENABLED=true
TLS_CLIENT_AUTH_REQUIRED=true

cbdc-infra/.env-example

dotenv
IMAGE_PREFIX=cbdc-dev.sign.global:5000
SIGN_KMS_IMAGE=cbdc-dev.sign.global:5000/sign-kms:v0.1.5
PLATFORM=linux/arm64,linux/amd64

关键端口

来源:cbdc-biz/conf/<role>/core.yamlcbdc-biz/docker/compose-local-run.ymlcompose-local-run-infra.yml

服务gRPC备注
BizHub9000mTLS server
Issuer9100FSC P2P 9101
Endorser9300FSC P2P 9301
Institution-0019500FSC P2P 9501,HTTP REST 9502
Auditor9750FSC P2P 9751
KMS9200 / 9201gRPC / HTTP(基础设施 compose)
Fabric CA70549443(基础设施 compose)

Network 配置

来源:cbdc-network/Makefilecbdc-network/configs/test-full-kms.yaml

  • 默认 KMS 配置文件:configs/test-full-kms.yaml
  • 输出:cbdc-network/out/docker-compose.yaml(由 fxconfig 生成)

具体 YAML 字段 [未核]。

Docker Compose 文件清单

来源:cbdc-biz/docker/

文件用途
compose-build-base.yml构建基础镜像
compose-build.yml构建应用镜像
compose-local-run.yml本地开发主 compose(postgres + 5 个业务应用)
compose-local-run-infra.yml本地 KMS + Fabric CA 服务
compose-rtgs-mock.ymlRTGS 模拟服务

cbdc-network 编排在 out/docker-compose.yaml,由 setup 阶段生成。

应用配置(core.yaml

各应用 cmd/<app>/main.go-conf 指定配置目录(默认 ../../configs),容器内挂载到 /conf

go
flag.StringVar(&flagconf, "conf", "../../configs", "config path, eg: -conf config.yaml")

internal/conf/conf.proto 定义配置 schema;真实运行配置在 cbdc-biz/conf/<role>/core.yaml,顶层键包括 bizserver.addr / observability / bizhub_addr)、fscid / identity / p2p / persistences / endpoint.resolvers)、fabricmsps / BCCSP PKCS11 / tls / notificationService / queryService / channels)、tokentms / zkatdlog / finality)。BizHub 的 core.yaml 另含 institutions 注册表与 rtgs(SWIFT / SMB / keystore)配置。

TLS / mTLS

来源:cbdc-biz/conf/<role>/core.yamlcbdc-biz/.env.example

TLS_ENABLED / TLS_CLIENT_AUTH_REQUIRED 控制开关(默认 true,两侧 .env 必须一致)。证书材料由 gen_crypto.sh 经 Fabric CA enroll 生成,放在各角色的 keys/ 下:

  • 节点 TLS 证书 / 私钥:./keys/node.crt./keys/node.key
  • BizHub mTLS:server 证书 + ca_cert: ./keys/mtls-ca.crt(Fabric CA root),require_client_cert: trueconf/bizhub/core.yaml:52-57
  • 连 committer 的 root:./keys/fabric/user/tlscacerts/tlsca.org1.example.com-cert.pemconf/endorser1/core.yaml:113-114

镜像 tag 规则

来源:README.md:242-249

子项目tag 前缀
cbdc-bizbiz/v*biz/v0.0.6
cbdc-networknetwork/v*network/v0.1.0
cbdc-infrainfra/v*infra/v0.0.3

make version 在每个子项目内可查当前 tag。

数据库

来源:cbdc-biz/go.mod;PostgreSQL 另见 cbdc-biz/docker/compose-local-run.ymlpostgres:18.1-alpine3.23,容器 cbdc_local_db)。compose 中无 redis 服务,Redis 依赖仅由 go.mod 证实。

实现
主 DBPostgreSQL(github.com/lib/pq v1.10.9
ORMEnt(entgo.io/ent v0.14.6
缓存Redis(github.com/redis/go-redis/v9 v9.18.0

测试模拟:github.com/alicebob/miniredis/v2 v2.37.0DATA-DOG/go-sqlmock v1.5.2

可观测性

来源:cbdc-biz/pkg/signet/signet.gocbdc-biz/pkg/observability/

  • 通过 signet 包统一初始化 OpenTelemetry:Metrics 与 Tracing 启用,Logging bridge 当前硬编码关闭(signet.go:73-77,因 fabric-smart-client 的 otel/log 版本冲突)
  • Tracing 上报到 OTLP_ENDPOINT(如 host.docker.internal:4317),采样率由 observability.tracing 配置
  • metric 输出兼容 Prometheus / VictoriaMetrics(pkg/observability/views.go