Docs

Docs

  • 文档
  • github

›快速入门

概述

  • 简介
  • 术语
  • 版本发布

架构特性

  • 整体架构
  • 共识机制
  • 账本存储
  • 智能合约
  • 数据归档
  • 数据可视化
  • 消息订阅

快速入门

  • 部署安装
  • 使用示例
  • 配置说明

操作指南

  • EVM
  • HVM
  • 消息订阅
  • 数据可视化
  • 交互式命令

SDK

  • LITESDK
  • JAVASDK

配置说明

在安装包中的配置文件主要有global.toml和namespace.toml等,下面分别对这些配置文件进行详细说明。

global.toml

在该配置文件中记录了一些全局配置项,包括输出日志等级、输出日志文件的路径、网络模块配置、全局端口配置、namespace的启动配置等。

###########################################################
#  _   _                        ____ _           _        #
# | | | |_   _ _ __   ___ _ __ / ___| |__   __ _(_)_ __   #
# | |_| | | | | '_ \ / _ \ '__| |   | '_ \ / _\` | | '_ \ #
# |  _  | |_| | |_) |  __/ |  | |___| | | | (_| | | | | | #
# |_| |_|\__, | .__/ \___|_|   \____|_| |_|\__,_|_|_| |_| #
#        |___/|_|                                         #
###########################################################

title = "Hyperchain global configurations"
commercialVersion = "1.7"
##########################################################
#
# Logger section
# config log's level by module
# CRITICAL ERROR WARNING NOTICE INFO DEBUG
# high <------------- log level -------> low
#
##########################################################

[log]
dump_file           = true # dump the log file or not
dump_interval       = "24h"  # Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". such as "300ms", "2h45m".
log_dir             = "./logs"
log_level           = "NOTICE" # default loglevel for all modules which can be override by module level log setting
file_format         = "[%{module}][%{level:.5s}] %{time:15:04:05.000} %{shortfile} %{message}"
console_format      = "%{color}[%{module}][%{level:.5s}] %{time:15:04:05.000} %{shortfile} %{message} %{color:reset}"
max_log_size        = "200mb"  # "mb", "kb"
check_size_interval = "2m"

    [log.module] #set log level by module
    p2p         = "NOTICE"
    consensus   = "INFO"
    core        = "NOTICE"
    hyperdb     = "NOTICE"
    eventhub    = "NOTICE"
    jsonrpc     = "NOTICE"
    hypernet    = "NOTICE"
    hvm         = "NOTICE"

##########################################################
#
#  JSONRPC section
#
##########################################################
[http]
# allowedOrigins should be a comma-separated list of allowed origin URLs
# to allow connections with any origin, pass "*". An origin may contain a
# wildcard (*) to replace 0 or more characters(i.e.: http://*.domain.com).
# Usage of wildcards implies a small performance penalty. Only one wildcard
# can be used per origin.
# i.e.: "http://172.16.10.6", "http://172.16.*", "http://localhost:9000", "http://128.168.10.22:8080",
# http://www.*.com and "http://www.baidu.com" are allowed. All URLs must has string prefix "http://".
allowedOrigins=["*"]
# if true, it will enable secure http connection(https).
security    = false
# if true, use http/2, otherwise use http/1.1.
# WARN: if version_2 is true, option sercurity must be true, otherwise use default http/1.1 without https.
http_2   = false

    [http.request]
    maxContentLength = "12mb" # default 12mb
    readTimeout = "5s"         # default 5s

##########################################################
#
# P2P section
#
##########################################################
[p2p]
servername              = "hyperchainServer1"
ipc                     = "hpc_1.ipc"
tlsCA                   = "./tls/tlsca.ca"
tlsServerHostOverride   = "hyperchain.cn"
tlsCert                 = "./tls/tls_peer.cert"
tlsCertPriv             = "./tls/tls_peer.priv"

##########################################################
#
# key ports section
#
##########################################################
[port]
jsonrpc     = 8081
restful     = 9001
websocket   = 10001
ledger      = 50051
grpc        = 50011 # p2p

##########################################################
#
# namespace section
#
##########################################################
[namespace]
config_root_dir = "./namespaces"

    [namespace.start] # define start which namespaces when node starts
    global          = true
    ns_2e6160583867 = false

##########################################################
#
# other configurations section
#
##########################################################

[flow.control.ratelimit]
 enable            = true
 txRatePeak        = 100
 txFillRate        = "0.5ms"
 contractRatePeak  = 100
 contractFillRate  = "0.5ms"

其中log模块表示日志相关的配置选项,用户可以通过修改log.dump_file来控制是否将输出日志重定向至日志文件中,我们推荐用户开启日志重定向。

用户可以根据实际申请开放的端口号进行port模块的配置,其中grpc端口是节点间通信的端口号,注意要与addr.toml中的端口号对应;jsonrpc端口是外部应用向hyperchain平台发送请求使用的端口号。

namespace模块指定了namespace的根目录路径以及节点启动时默认参与的namespace名称,我们建议每个节点都要默认启动global这个namespace。

namespace.toml

namespace.toml中记录了所有namespace级别的配置项,包括共识算法配置、加密证书的配置、数据库相关配置、日志等级配置等等。所有共识节点在接收到交易后打包成一个小的slice后进行全网转发,主节点对slice打包后发送PrePrepare,在降低了节点转发交易次数的同时,也减少了PrePrepare的带宽消耗,其中:slice_size表示最多多少笔交易打包成一个小的slice,batch_size表示最多多少个slice将组成一个batch,pool_size则表示slicePool缓存池中最多能够缓存多少个slice。默认的共识算法配置信息如下所示:

###########################################################
#  _   _                        ____ _           _        #
# | | | |_   _ _ __   ___ _ __ / ___| |__   __ _(_)_ __   #
# | |_| | | | | '_ \ / _ \ '__| |   | '_ \ / _\` | | '_ \ #
# |  _  | |_| | |_) |  __/ |  | |___| | | | (_| | | | | | #
# |_| |_|\__, | .__/ \___|_|   \____|_| |_|\__,_|_|_| |_| #
#        |___/|_|                                         #
###########################################################
title = "namespace configurations"

[genesis]
    [genesis.alloc]
     "000f1a7a08ccc48e5d30f80850cf1cf283aa3abd" = "1000000000"
     "e93b92f1da08f925bdee44e91e7768380ae83307" = "1000000000"
     "6201cb0448964ac597faf6fdf1f472edf2a22b89" = "1000000000"
     "b18c8575e3284e79b92100025a31378feb8100d6" = "1000000000"
     "856E2B9A5FA82FD1B031D1FF6863864DBAC7995D" = "1000000000"
     "fbca6a7e9e29728773b270d3f00153c75d04e1ad" = "1000000000"

############################################################################################################
# consensus algorithm configuration section
#
# 1. choose which consensus algorithm to use
# 2. define the algorithm related configurations
#
############################################################################################################
[consensus]
    [consensus.solo]             # solo configurations
        slice_size       = 25    # How many transactions should the node broadcast at once
        batch_size       = 20    # How many slices should the node pack
        pool_size        = 2000  # How many slices could the txPool stores in total

        [consensus.solo.timeout]
            batch             = "0.5s"# Node send a batch if there are pending requests, although batchsize isn't reached yet
            set               = "0.1s"# Node broadcasts transactions if there are cached transactions, although set_size isn't reached yet

############################################################################################################
# database configuration section
############################################################################################################
[database]
    [database.leveldb]
    root_dir           = "data/leveldb" #leveldb table root dir
    log_path           = "data/db.log"
    measurement_enable = false
    data_encryption    = false

    [database.leveldb.options]
    block_cache_capacity      = "8mb" # "mb", "kb"
    block_size                = "4kb" # "mb", "kb"
    write_buffer              = "4mb" # "mb", "kb"
    write_l0_pause_trigger    = 12
    write_l0_slowdown_trigger = 8
    # the level db file size (default is 2mb, v1.2 is 8mb)
    compaction_table_size     = "8mb"

    [database.filelog]
    root_dir = "data/filelog/"
    compression = "snappy" #zlib pure snappy
    max_log_file_size = "100mb" # "mb", "kb"
    max_idx_file_size = "1mb" # "mb", "kb"
    archive_path = "backup"
    journal_archive_path = "journal_backup"

    [database.filelog.cache]
    enable = true
    max_cache_size = 50 #mb
    cache_expired_time = 48 #hour
    cache_entry_num = 40

    [database.filelog.handler_cache]
    handler_cache_num = 100
    handler_cache_expired_time = 0

    [database.minifile]
    root_dir = "data/minifile/"

    [database.dbpath]
    archive    = "data/leveldb/archive"
    blockchain = "data/leveldb/blockchain"
    consensus  = "data/leveldb/consensus"
    camanager  = "data/leveldb/camanager"

############################################################################################################
#
# executor configuration section
#
############################################################################################################
[executor]
    [executor.syncer]
    max_block_fetch         = 50
    block_fetch_timeout     = "1m"
    state_fetch_enable      = true
    state_fetch_packet_size = 1024  # 1024KB

    [executor.archive] 
    snapshot_manifest = "data/snapshot.meta"
    archive_manifest  = "data/archive.meta"
    threshold = 0
    force_consistency = true

    [executor.nvp]
    exitflag = false

    [executor.buckettree.state]
    capacity         = 1000003
    aggreation       = 5
    merklenode_cache = 100000
    bucket_cache     = 100000

    [executor.buckettree.storage]
     capacity         = 1000003
     aggreation       = 5
     merklenode_cache = 100000
     bucket_cache     = 100000

    [executor.vm]
        [executor.vm.evm]
            gas_limit = 1000000000

############################################################################################################
#
# Hyperchain additional services section
# If a service is configured below, the service will start with hyperchain.
# Choose not start the following services by do not write them in config file.
# Currently they are not started
#
############################################################################################################
# [[service]]
#     service_name = "Radar"
[[service]]
    service_name = "MQ"

############################################################################################################
#
# radar configurations
#
############################################################################################################

[radar-params]
 viewable_db_type = "mysql"
 mysql_connURL  = "root:root@tcp(127.0.0.1:3306)/%s?charset=utf8"
############################################################################################################
#
# executor configuration section
# config log's level by module
# CRITICAL ERROR WARNING NOTICE INFO DEBUG
# high <------------- log level -------> low
#
############################################################################################################
[log]
dump_file           = true # dump the log file or not
dump_interval       = "24h"  # Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". such as "300ms", "2h45m".
log_dir             = "data/logs"
log_level           = "NOTICE" # default loglevel for all modules which can be override by module level log setting
file_format         = "[%{module}][%{level:.5s}] %{time:15:04:05.000} %{shortfile} %{message}"
console_format      = "%{color}[%{module}][%{level:.5s}] %{time:15:04:05.000} %{shortfile} %{message} %{color:reset}"
max_log_size        = "200mb"  # "mb", "kb"
check_size_interval = "2m"

    [log.module] #set log level by module
    p2p         = "NOTICE"
    consensus   = "INFO"
    hyperdb     = "NOTICE"
    eventhub    = "NOTICE"
    executor    = "NOTICE"
    buckettree  = "NOTICE"
    radar       = "NOTICE"
    private     = "INFO"
    midware     = "NOTICE"
    node        = "NOTICE"

############################################################################################################
#
# other configurations
#
############################################################################################################
[flow.control.ratelimit]
 enable            = true
 txRatePeak        = 100
 txFillRate        = "0.5ms"
 contractRatePeak  = 100
 contractFillRate  = "0.5ms"

[duplicate.remove.bloomfilter] # bloom filter used in tx duplication checking
 interval          = "24h" # [5min, 24h]
 rebuild_time      = 6
 bloombit          = 100000000
 active_time       = "24h" # >= interval

[amqp]
  url             = "amqp://guest:guest@127.0.0.1:5672/"
  autoDeleted     = false
  mqdb            = "MQDB"
  mq_persist      = true

############################################################################################################
#
# private protection configuration section
#
############################################################################################################
[private]
cache_size    = 500

    [private.timeout]
    sync_data     = "3s"
    query_data    = "3s"
    fetch_data    = "3s"
    check         = "1h"

    [private.ttl]
    name = "time"
        [private.ttl.time]
        timeout = "24h"
        [private.ttl.block]
        number = 5

我们推荐用户将batchtime设置为0.5s使得系统拥有较高的交易处理能力、较低的交易处理时延。当然用户也可以根据本身的需求修改。由于一些异常情况超时时长(timeout)与共识算法的正确性密切相关,因此我们不建议用户对这部分内容进行修改。

需要说明的是,开放下载版本的Hyperchain采用的是solo共识算法,用于支持单节点共识,相应的也增加了若干的配置项,各配置项含义如上所述,另外,batch timeout表示主节点在规定时间内未收集到batch_size个slice将直接打包一个batch;set timeout表示节点在规定时间内未收集到slice_size个交易将直接打包一个小的slice。

[consensus]
algo = "SOLO"
    [consensus.solo]
    slice_size = 25
    batch_size = 20
    pool_size = 2000
    
    [consensus.solo.timeout]
        batch = "0.5s"
        set = "0.1s"

同时,在log模块中用户可以按照模块分别配置各个模块的日志等级,我们推荐用户所有模块的日志等级设置为NOTICE,除了共识模块的日志等级设置为INFO。

[log]
dump_file           = true # dump the log file or not
dump_interval       = "24h"  # Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". such as "300ms", "2h45m".
log_dir             = "data/logs"
log_level           = "NOTICE" # default loglevel for all modules which can be override by module level log setting
file_format         = "[%{module}][%{level:.5s}] %{time:15:04:05.000} %{shortfile} %{message}"
console_format      = "%{color}[%{module}][%{level:.5s}] %{time:15:04:05.000} %{shortfile} %{message} %{color:reset}"
max_log_size        = "200mb"  # "mb", "kb"
check_size_interval = "2m"

    [log.module] #set log level by module
    p2p         = "NOTICE"
    consensus   = "INFO"
    hyperdb     = "NOTICE"
    eventhub    = "NOTICE"
    executor    = "NOTICE"
    buckettree  = "NOTICE"
    radar       = "NOTICE"
    private     = "INFO"
    midware     = "NOTICE"
    node        = "NOTICE"

Hyperchain1.7版本中,增加了Filelog用于存储区块和journal相关数据,同时增加了minifile用了临时存储共识数据库中存储交易。下面是Filelog的相关配置:

 [database.filelog]
    root_dir = "data/filelog/"     #Filelog数据根路径
    compression = "snappy" #zlib pure snappy   #Filelog数据压缩算法
    max_log_file_size = "100mb" # "mb", "kb"   #每个Log文件的大小
    max_idx_file_size = "1mb" # "mb", "kb"  #每个Index文件的大小
    archive_path = "backup"  #Filelog 区块归档的备份路径
    journal_archive_path = "journal_backup" #Filelog Journal归档的路径

    [database.filelog.cache]
    enable = true
    max_cache_size = 50 #mb
    cache_expired_time = 2400 #hour
    cache_entry_num = 40

    [database.filelog.handler_cache]
    handler_cache_num = 100
    handler_cache_expired_time = 0

下面是minifile的相关配置:

 [database.minifile]
    root_dir = "data/minifile/"

camanage数据库配置选项,archive功能配置项,leveldb数据迁移目标路径配置项为:

[database.dbpath]
    archive    = "data/leveldb/archive"
    blockchain = "data/leveldb/blockchain"
    consensus  = "data/leveldb/consensus"
    camanager  = "data/leveldb/camanager"

针对数据归档,Hyperchain1.7在namespace.toml文件中提供了专门的配置项executor.archive,详细的配置项如下:

[executor.archive] 
    snapshot_manifest = "data/snapshot.meta" # 快照元数据文件路径
    archive_manifest  = "data/archive.meta"  # archive过程更改信息记录文件路径
    threshold = 0                            # 允许做归档操作的最小区块号
    force_consistency = true                 # 是否必须保证线上线下数据连续
    contract_archive = false                 # 是否启用合约归档(暂时必须配置为false)

以及上文提到的,filelog内数据的迁移目标路径配置项:

    [database.filelog]
    root_dir = "data/filelog/"
    compression = "snappy" #zlib pure snappy
    max_log_file_size = "100mb" # "mb", "kb"
    max_idx_file_size = "1mb" # "mb", "kb"
    archive_path = "backup"
    journal_archive_path = "journal_backup"
← 使用示例EVM →
  • global.toml
  • namespace.toml
QTechGitHub
Copyright © 2025 Hyperchain Co., Ltd.