# 闀垮畨閾捐处鎴锋暣浣撲粙缁�

## 闀垮畨閾句笉鍚岃韩浠芥ā寮忛摼璐︽埛浣撶郴瀵规瘮
### 鏁翠綋瀵规瘮

| 瀵规瘮椤筡韬唤妯″紡 | PermissionWithCert                  | PermissionWithKey | Public        |
|----------|-------------------------------------|-------------------|---------------|
| 妯″紡鍚嶇О     | 璇佷功妯″紡                                | 鍏挜娉ㄥ唽妯″紡            | 鍏挜妯″紡          |
| 妯″紡绠€绉�     | cert妯″紡                              | pwk妯″紡             | pk妯″紡          |
| 璐︽埛绫诲瀷     | 鑺傜偣璐︽埛(鍏辫瘑鑺傜偣銆佸悓姝ヨ妭鐐广€佽交鑺傜偣), 鐢ㄦ埛璐︽埛(绠$悊鍛樸€佹櫘閫氱敤鎴�) | 鍚岃瘉涔︽ā寮�             | 鍚岃瘉涔︽ā寮�         | 
| 璐︽埛鏍囪瘑     | 鏁板瓧璇佷功                                | 鍏挜/鍦板潃             | 鍏挜/鍦板潃         | 
| 鏄惁闇€瑕佸噯鍏�   | 鏄紝璇佷功闇€瑕丆A绛惧彂                          | 鏄紝璐︽埛闇€瑕佺鐞嗗憳鍦ㄩ摼涓婃敞鍐�    | 鍚︼紝鏅€氱敤鎴峰彲鐩存帴璋冪敤鍚堢害 |
| 璐︽埛涓庣粍缁囧叧绯�  | 璐︽埛灞炰簬鏌愪釜缁勭粐                            | 璐︽埛灞炰簬鏌愪釜缁勭粐          | 璐︽埛鏃犵粍缁囨蹇�       |  
| 閫傜敤閾剧被鍨�    | 鑱旂洘閾�                                 | 鑱旂洘閾�               | 鍏摼            |
| 鍏辫瘑绠楁硶       | TBFT銆丷AFT銆丮axBFT                    | TBFT銆丷AFT                  |TBFT銆丏POS              |

###  PermissionedWithCert
#### 閾鹃厤缃枃浠惰鏄�

**閰嶇疆鏂囦欢锛歜c.yml**

- auth_type锛氳韩浠芥ā寮�

  permissionedWithCert锛氶潰鍚戝己鏉冮檺鎺у埗鍦烘櫙锛屽熀浜庢暟瀛楄瘉涔︾殑鐢ㄦ埛鏍囪瘑浣撶郴銆佸熀浜庤鑹茬殑鏉冮檺鎺у埗浣撶郴銆�

* consensus锛氬叡璇嗛厤缃�

  - nodes锛氬叡璇嗚妭鐐瑰垪琛�

    - org_id锛氱粍缁噄d

    - node_id锛氬叡璇嗚妭鐐筰d鍒楄〃锛屾槸鐢卞叡璇嗚妭鐐筎LS璇佷功閲岀殑鍏挜绠楀嚭鐨勫敮涓€id

* trust_roots锛氫俊浠绘牴閰嶇疆鍒楄〃

  - org_id锛氱粍缁噄d

  - root锛氱粍缁嘋A璇佷功鎵€鍦ㄨ矾寰勫垪琛�

#### 閾鹃厤缃枃浠剁ず渚�

```yaml
chain_id: chain1                    # 閾炬爣璇�
version: v1.0.0                     # 閾剧増鏈�
sequence: 0                         # 閰嶇疆鐗堟湰
auth_type: "permissionedWithCert"   # 璁よ瘉绫诲瀷

crypto:
  hash: SHA256

# 鍚堢害鏀寔绫诲瀷鐨勯厤缃�
contract:
  enable_sql_support: false

# 铏氭嫙鏈洪厤缃�
vm:
  # 铏氭嫙鏈烘敮鎸佸垪琛�
  support_list:
    - "wasmer"
    - "gasm"
    - "evm"
    - "wxvm"

# 浜ゆ槗銆佸尯鍧楃浉鍏抽厤缃�
block:
  tx_timestamp_verify: true # 鏄惁闇€瑕佸紑鍚氦鏄撴椂闂存埑鏍¢獙
  tx_timeout: 600  # 浜ゆ槗鏃堕棿鎴崇殑杩囨湡鏃堕棿(绉�)
  block_tx_capacity: 100  # 鍖哄潡涓渶澶т氦鏄撴暟
  block_size: 10  # 鍖哄潡鏈€澶ч檺鍒讹紝鍗曚綅MB
  block_interval: 2000 # 鍑哄潡闂撮殧锛屽崟浣�:ms

# core妯″潡
core:
  tx_scheduler_timeout: 10 #  [0, 60] 浜ゆ槗璋冨害鍣ㄤ粠浜ゆ槗姹犳嬁鍒颁氦鏄撳悗, 杩涜璋冨害鐨勬椂闂�
  tx_scheduler_validate_timeout: 10 # [0, 60] 浜ゆ槗璋冨害鍣ㄤ粠鍖哄潡涓嬁鍒颁氦鏄撳悗, 杩涜楠岃瘉鐨勮秴鏃舵椂闂�
  consensus_turbo_config:
    consensus_message_turbo: true # 鏄惁寮€鍚叡璇嗘姤鏂囧帇缂�
    retry_time: 500 # 鏍规嵁浜ゆ槗ID鍒楄〃浠庝氦鏄撴睜鑾峰彇浜ゆ槗鐨勯噸璇曟鏁�
    retry_interval: 20 # 閲嶈瘯闂撮殧锛屽崟浣�:ms

#鍏辫瘑閰嶇疆
consensus:
  # 鍏辫瘑绫诲瀷(0-SOLO,1-TBFT,2-MBFT,3-HOTSTUFF,4-RAFT,5-DPOS)
  type: 1
  # 鍏辫瘑鑺傜偣鍒楄〃锛岀粍缁囧繀椤诲嚭鐜板湪trust_roots鐨刼rg_id涓紝姣忎釜缁勭粐鍙厤缃涓叡璇嗚妭鐐癸紝鑺傜偣鍦板潃閲囩敤libp2p鏍煎紡
  nodes:
    - org_id: "wx-org1.chainmaker.org"
      node_id:
        - "QmcQHCuAXaFkbcsPUj7e37hXXfZ9DdN7bozseo5oX4qiC4"
    - org_id: "wx-org2.chainmaker.org"
      node_id:
        - "QmeyNRs2DwWjcHTpcVHoUSaDAAif4VQZ2wQDQAUNDP33gH"
    - org_id: "wx-org3.chainmaker.org"
      node_id:
        - "QmXf6mnQDBR9aHauRmViKzSuZgpumkn7x6rNxw1oqqRr45"
    - org_id: "wx-org4.chainmaker.org"
      node_id:
        - "QmRRWXJpAVdhFsFtd9ah5F4LDQWFFBDVKpECAF8hssqj6H"
        
  ext_config: # 鎵╁睍瀛楁锛岃褰曢毦搴︺€佸鍔辩瓑鍏朵粬绫诲叡璇嗙畻娉曢厤缃�
    - key: aa
      value: chain01_ext11

# 淇′换缁勭粐鍜屾牴璇佷功
trust_roots:
  - org_id: "wx-org1.chainmaker.org"
    root:
      - "../config/wx-org1/certs/ca/wx-org1.chainmaker.org/ca.crt"
  - org_id: "wx-org2.chainmaker.org"
    root:
      - "../config/wx-org2/certs/ca/wx-org2.chainmaker.org/ca.crt"
  - org_id: "wx-org3.chainmaker.org"
    root:
      - "../config/wx-org3/certs/ca/wx-org3.chainmaker.org/ca.crt"
  - org_id: "wx-org4.chainmaker.org"
    root:
      - "../config/wx-org4/certs/ca/wx-org4.chainmaker.org/ca.crt"

# 鏉冮檺閰嶇疆锛堝彧鑳芥暣浣撴坊鍔犮€佷慨鏀广€佸垹闄わ級
resource_policies:
  - resource_name: CHAIN_CONFIG-NODE_ID_UPDATE
    policy:
      rule: SELF # 瑙勫垯锛圓NY锛孧AJORITY...锛屽叏閮ㄥぇ鍐欙紝鑷姩杞ぇ鍐欙級
      org_list: # 缁勭粐鍚嶇О锛堢粍缁囧悕绉帮紝鍖哄垎澶у皬鍐欙級
      role_list: # 瑙掕壊鍚嶇О锛坮ole锛岃嚜鍔ㄨ浆澶у啓锛�
        - admin
  - resource_name: CHAIN_CONFIG-TRUST_ROOT_ADD
    policy:
      rule: MAJORITY
      org_list:
      role_list:
        - admin
  - resource_name: CHAIN_CONFIG-CERTS_FREEZE
    policy:
      rule: ANY
      org_list:
      role_list:
        - admin
        
disabled_native_contract:
 # - CONTRACT_NAME  # 閫氳繃鎸囧畾绯荤粺鍚堢害鍚嶅瓧鏉ョ鐢ㄧ郴缁熷悎绾�
```


#### 鑺傜偣閰嶇疆鏂囦欢璇存槑

**閰嶇疆鏂囦欢锛歝hainmaker.yml**

- auth_type锛氳韩浠芥ā寮�

  permissionedWithCert锛氶潰鍚戝己鏉冮檺鎺у埗鍦烘櫙锛屽熀浜庢暟瀛楄瘉涔︾殑鐢ㄦ埛鏍囪瘑浣撶郴銆佸熀浜庤鑹茬殑鏉冮檺鎺у埗浣撶郴銆�

- node锛氳妭鐐归厤缃�

  - priv_key_file锛氳妭鐐筍IGN璇佷功鐨勭閽ュ湴鍧€
  - cert_file锛氳妭鐐筍IGN璇佷功鐨勫湴鍧€

- net锛氱綉缁滈厤缃�

  - tls锛歍LS閰嶇疆
    - priv_key_file锛氳妭鐐筎LS璇佷功鐨勭閽ュ湴鍧€
    - cert_file锛氳妭鐐筎LS璇佷功鐨勫湴鍧€



#### 鑺傜偣閰嶇疆鏂囦欢绀轰緥
```yaml
auth_type: "permissionedWithCert"      # permissionedWithCert / permissionedWithKey / public

log:
  config_file: ../config/wx-org1/log.yml          # config file of logger configuration.

blockchain:
  - chainId: chain1
    genesis: ../config/wx-org1/chainconfig/bc1.yml

node:
  # 鑺傜偣绫诲瀷锛歠ull
  type:              full
  org_id:            wx-org1.chainmaker.org
  priv_key_file:     ../config/wx-org1/certs/node/consensus1/consensus1.sign.key
  cert_file:         ../config/wx-org1/certs/node/consensus1/consensus1.sign.crt
  signer_cache_size: 1000
  cert_cache_size:   1000

net:
  provider: LibP2P
  listen_addr: /ip4/0.0.0.0/tcp/11301
  seeds:
    - "/ip4/127.0.0.1/tcp/11301/p2p/QmcQHCuAXaFkbcsPUj7e37hXXfZ9DdN7bozseo5oX4qiC4"
    - "/ip4/127.0.0.1/tcp/11302/p2p/QmNdgWgD2QSu769yCwFCnwhVKhjWzyjA3PgSXL7ZJBrUoA"
    - "/ip4/127.0.0.1/tcp/11303/p2p/QmXf6mnQDBR9aHauRmViKzSuZgpumkn7x6rNxw1oqqRr45"
    - "/ip4/127.0.0.1/tcp/11304/p2p/QmRRWXJpAVdhFsFtd9ah5F4LDQWFFBDVKpECAF8hssqj6H"
  tls:
    enabled: true
    priv_key_file: ../config/wx-org1/certs/node/consensus1/consensus1.tls.key
    cert_file:     ../config/wx-org1/certs/node/consensus1/consensus1.tls.crt

# Transaction pool settings
# Other txpool settings can be found in tx_Pool_config.go
txpool:
  # tx_pool type, can be single, normal, batch.
  # By default the tx_pool type is normal.
  # Note: please delete dump_tx_wal folder in storage.store_path when change tx_pool type
  pool_type: "normal"

  # Max common transaction count in tx_pool.
  # If tx_pool is full, the following transactions will be discarded.
  max_txpool_size: 50000

  # Max config transaction count in tx_pool.
  max_config_txpool_size: 10

  # Whether dump unpacked config and common transactions in queue when stop node,
  # and replay these transactions when restart node.
  is_dump_txs_in_queue: true

  # Common transaction queue num, only for normal tx_pool.
  # Note: the num should be an exponent of 2 and less than 256, such as, 1, 2, 4, 8, 16, ..., 256
  common_queue_num: 8

  # The number of transactions contained in a batch, for normal and batch tx_pool.
  # Note: make sure that block.block_tx_capacity in bc.yml is an integer multiple of batch_max_size
  batch_max_size: 100

  # Interval of creating a transaction batch, for normal and batch tx_pool, in millisecond(ms).
  batch_create_timeout: 50

rpc:
  provider: grpc
  port: 12301
  tls:
    # TLS妯″紡:
    #   disable - 涓嶅惎鐢═LS
    #   oneway  - 鍗曞悜璁よ瘉
    #   twoway  - 鍙屽悜璁よ瘉
    #mode: disable
    #mode: oneway
    mode:           twoway
    priv_key_file:  ../config/wx-org1/certs/node/consensus1/consensus1.tls.key
    cert_file:      ../config/wx-org1/certs/node/consensus1/consensus1.tls.crt

monitor:
  enabled: false
  port: 14321

pprof:
  enabled: false
  port: 24321

storage:
  store_path: ../data/org1/ledgerData1
  blockdb_config:
    provider: leveldb
    leveldb_config:
      store_path: ../data/org1/blocks
      write_buffer_size: 1024
      block_write_buffer_size: 1024
  statedb_config:
    provider: leveldb
    leveldb_config:
      store_path: ../data/org1/state
  historydb_config:
    provider: leveldb
    leveldb_config:
      store_path: ../data/org1/history
  resultdb_config:
    provider: leveldb
    leveldb_config:
      store_path: ../data/org1/result
  disable_contract_eventdb: true  #鏄惁绂佹鍚堢害浜嬩欢瀛樺偍鍔熻兘锛岄粯璁や负true锛屽鏋滆缃负false,闇€瑕侀厤缃甿ysql
  contract_eventdb_config:
    provider: sql                 #濡傛灉寮€鍚痗ontract event db 鍔熻兘锛岄渶瑕佹寚瀹歱rovider涓簊ql
    sqldb_config:
      sqldb_type: mysql           #contract event db 鍙敮鎸乵ysql
      dsn: root:password@tcp(127.0.0.1:3306)/  #mysql鐨勮繛鎺ヤ俊鎭紝鍖呮嫭鐢ㄦ埛鍚嶃€佸瘑鐮併€乮p銆乸ort绛夛紝绀轰緥锛歳oot:admin@tcp(127.0.0.1:3306)/
debug:
  # 鏄惁寮€鍚疌LI鍔熻兘锛岃繃搴︽湡闂翠娇鐢�
  is_cli_open: true
  is_http_open: false
```






### PermissionedWithKey

#### 閾鹃厤缃枃浠惰鏄�

**閰嶇疆鏂囦欢锛歜c.yml**

- auth_type锛氳韩浠芥ā寮�

  permissionedWithKey锛氶潰鍚戝己鏉冮檺鎺у埗鍦烘櫙锛屽熀浜庡叕閽ョ殑鐢ㄦ埛鏍囪瘑浣撶郴銆佸熀浜庤鑹茬殑鏉冮檺鎺у埗浣撶郴銆�

* consensus锛氬叡璇嗛厤缃�

  - nodes锛氬叡璇嗚妭鐐瑰垪琛�

    - org_id锛氱粍缁噄d
    - node_id锛氬叡璇嗚妭鐐筰d鍒楄〃锛屾槸鐢卞叡璇嗚妭鐐瑰叕閽ョ畻鍑虹殑鍞竴id

* trust_roots锛氫俊浠绘牴閰嶇疆鍒楄〃

  - org_id锛氱粍缁噄d

  - root锛氱粍缁囩鐞嗗憳鐢ㄦ埛鍏挜鎵€鍦ㄨ矾寰勫垪琛�

#### 閾鹃厤缃枃浠剁ず渚�

```yaml
chain_id: chain1                      # 閾炬爣璇�
version: v1.0.0                       # 閾剧増鏈�
sequence: 0                           # 閰嶇疆鐗堟湰
auth_type: "permissionedWithKey"      # 璁よ瘉绫诲瀷 permissionedWithCert / permissionedWithKey / public

crypto:
  hash: SHA256

# 鍚堢害鏀寔绫诲瀷鐨勯厤缃�
contract:
  enable_sql_support: false

# 浜ゆ槗銆佸尯鍧楃浉鍏抽厤缃�
block:
  tx_timestamp_verify: true # 鏄惁闇€瑕佸紑鍚氦鏄撴椂闂存埑鏍¢獙
  tx_timeout: 600  # 浜ゆ槗鏃堕棿鎴崇殑杩囨湡鏃堕棿(绉�)
  block_tx_capacity: 100  # 鍖哄潡涓渶澶т氦鏄撴暟
  block_size: 10  # 鍖哄潡鏈€澶ч檺鍒讹紝鍗曚綅MB
  block_interval: 2000 # 鍑哄潡闂撮殧锛屽崟浣�:ms

# core妯″潡
core:
  tx_scheduler_timeout: 10 #  [0, 60] 浜ゆ槗璋冨害鍣ㄤ粠浜ゆ槗姹犳嬁鍒颁氦鏄撳悗, 杩涜璋冨害鐨勬椂闂�
  tx_scheduler_validate_timeout: 10 # [0, 60] 浜ゆ槗璋冨害鍣ㄤ粠鍖哄潡涓嬁鍒颁氦鏄撳悗, 杩涜楠岃瘉鐨勮秴鏃舵椂闂�
  consensus_turbo_config:
    consensus_message_turbo: false # 鏄惁寮€鍚叡璇嗘姤鏂囧帇缂�
    retry_time: 500 # 鏍规嵁浜ゆ槗ID鍒楄〃浠庝氦鏄撴睜鑾峰彇浜ゆ槗鐨勯噸璇曟鏁�
    retry_interval: 20 # 閲嶈瘯闂撮殧锛屽崟浣�:ms


#鍏辫瘑閰嶇疆
consensus:
  # 鍏辫瘑绫诲瀷(0-SOLO,1-TBFT,2-MBFT,3-HOTSTUFF,4-RAFT,5-DPOS)
  type: 1
  # 鍏辫瘑鑺傜偣鍒楄〃锛岀粍缁囧繀椤诲嚭鐜板湪trust_roots鐨刼rg_id涓紝姣忎釜缁勭粐鍙厤缃涓叡璇嗚妭鐐癸紝鑺傜偣鍦板潃閲囩敤libp2p鏍煎紡
  nodes:
    - org_id: "wx-org1.chainmaker.org"
      node_id:
        - "QmZcFcJFYYoZ3FNNGL88QaszUZwFwuBdFqYh6yPzJURc3s"
    - org_id: "wx-org2.chainmaker.org"
      node_id:
        - "QmXwtuPemSgH5ypzoKvcLdCLbd9jZ25FbpNf7VPjHF3HMS"
    - org_id: "wx-org3.chainmaker.org"
      node_id:
        - "QmRmQLHJoqAYGkuLFaNY6HLzwtTNxr45UJsYpSjdKvBQw2"
    - org_id: "wx-org4.chainmaker.org"
      node_id:
        - "QmURUHTGsuzzjgh1Xg6s92G1Q3gK91A6JEZGPfYNWwJMiT"
  ext_config: # 鎵╁睍瀛楁锛岃褰曢毦搴︺€佸鍔辩瓑鍏朵粬绫诲叡璇嗙畻娉曢厤缃�
    - key: aa
      value: chain01_ext11

# 淇′换缁勭粐鍜岀鐞嗗憳鍏挜
trust_roots:
  - org_id: "wx-org1.chainmaker.org"
    root:
      - "../config-pk/permissioned-with-key/wx-org1/public-key/admin/wx-org1.chainmaker.org/admin.pem"
  - org_id: "wx-org2.chainmaker.org"
    root:
      - "../config-pk/permissioned-with-key/wx-org1/public-key/admin/wx-org2.chainmaker.org/admin.pem"
  - org_id: "wx-org3.chainmaker.org"
    root:
      - "../config-pk/permissioned-with-key/wx-org1/public-key/admin/wx-org3.chainmaker.org/admin.pem"
  - org_id: "wx-org4.chainmaker.org"
    root:
      - "../config-pk/permissioned-with-key/wx-org1/public-key/admin/wx-org4.chainmaker.org/admin.pem"

# 鏉冮檺閰嶇疆锛堝彧鑳芥暣浣撴坊鍔犮€佷慨鏀广€佸垹闄わ級
resource_policies:
  - resource_name: CHAIN_CONFIG-NODE_ID_UPDATE
    policy:
      rule: SELF # 瑙勫垯锛圓NY锛孧AJORITY...锛屽叏閮ㄥぇ鍐欙紝鑷姩杞ぇ鍐欙級
      org_list: # 缁勭粐鍚嶇О锛堢粍缁囧悕绉帮紝鍖哄垎澶у皬鍐欙級
      role_list: # 瑙掕壊鍚嶇О锛坮ole锛岃嚜鍔ㄨ浆澶у啓锛�
        - admin
  - resource_name: CHAIN_CONFIG-TRUST_ROOT_ADD
    policy:
      rule: MAJORITY
      org_list:
      role_list:
        - admin
  - resource_name: CHAIN_CONFIG-CERTS_FREEZE
    policy:
      rule: ANY
      org_list:
      role_list:
        - admin
```


#### 鑺傜偣閰嶇疆鏂囦欢璇存槑

**閰嶇疆鏂囦欢锛歝hainmaker.yml**


- auth_type锛氳韩浠芥ā寮�

  permissionedWithKey锛氶潰鍚戝己鏉冮檺鎺у埗鍦烘櫙锛屽熀浜庡叕閽ョ殑鐢ㄦ埛鏍囪瘑浣撶郴銆佸熀浜庤鑹茬殑鏉冮檺鎺у埗浣撶郴銆�

- node锛氳妭鐐归厤缃�

  - priv_key_file锛氳妭鐐圭閽ュ湴鍧€
  - cert_file锛氫笉闇€瑕侀厤缃�

- net锛氱綉缁滈厤缃�

  - tls锛歍LS閰嶇疆
    - priv_key_file锛氳妭鐐圭閽ュ湴鍧€
    - cert_file锛氫笉闇€瑕侀厤缃�

**娉細node鍜宯et閲岄渶瑕侀厤缃悓涓€涓閽ョ殑鍦板潃**銆�

#### 鑺傜偣閰嶇疆鏂囦欢绀轰緥


```yaml
auth_type: "permissionedWithKey"                                   # permissionedWithCert / permissionedWithKey / public

log:
  config_file: ../config-pk/permissioned-with-key/wx-org1/log.yml          # config file of logger configuration.

blockchain:
  - chainId: chain1
    genesis: ../config-pk/permissioned-with-key/wx-org1/chainconfig/bc1.yml

node:
  # 鑺傜偣绫诲瀷锛歠ull
  type:              full
  org_id:            wx-org1.chainmaker.org
  priv_key_file:     ../config-pk/permissioned-with-key/wx-org1/public-key/node/consensus1/consensus1.key
  signer_cache_size: 1000
  cert_cache_size:   1000

net:
  provider: liquid
  listen_addr: /ip4/0.0.0.0/tcp/11351
  seeds:
    - "/ip4/127.0.0.1/tcp/11351/p2p/QmZcFcJFYYoZ3FNNGL88QaszUZwFwuBdFqYh6yPzJURc3s"
    - "/ip4/127.0.0.1/tcp/11352/p2p/QmXwtuPemSgH5ypzoKvcLdCLbd9jZ25FbpNf7VPjHF3HMS"
    - "/ip4/127.0.0.1/tcp/11353/p2p/QmRmQLHJoqAYGkuLFaNY6HLzwtTNxr45UJsYpSjdKvBQw2"
    - "/ip4/127.0.0.1/tcp/11354/p2p/QmURUHTGsuzzjgh1Xg6s92G1Q3gK91A6JEZGPfYNWwJMiT"
  tls:
    enabled: true
    priv_key_file: ../config-pk/permissioned-with-key/wx-org1/public-key/node/consensus1/consensus1.key

# Transaction pool settings
# Other txpool settings can be found in tx_Pool_config.go
txpool:
  # tx_pool type, can be single, normal, batch.
  # By default the tx_pool type is normal.
  # Note: please delete dump_tx_wal folder in storage.store_path when change tx_pool type
  pool_type: "normal"

  # Max common transaction count in tx_pool.
  # If tx_pool is full, the following transactions will be discarded.
  max_txpool_size: 50000

  # Max config transaction count in tx_pool.
  max_config_txpool_size: 10

  # Whether dump unpacked config and common transactions in queue when stop node,
  # and replay these transactions when restart node.
  is_dump_txs_in_queue: true

  # Common transaction queue num, only for normal tx_pool.
  # Note: the num should be an exponent of 2 and less than 256, such as, 1, 2, 4, 8, 16, ..., 256
  common_queue_num: 8

  # The number of transactions contained in a batch, for normal and batch tx_pool.
  # Note: make sure that block.block_tx_capacity in bc.yml is an integer multiple of batch_max_size
  batch_max_size: 100

  # Interval of creating a transaction batch, for normal and batch tx_pool, in millisecond(ms).
  batch_create_timeout: 50

rpc:
  provider: grpc
  port: 12301
  tls:
    # TLS妯″紡:
    #   disable - 涓嶅惎鐢═LS
    #   oneway  - 鍗曞悜璁よ瘉
    #   twoway  - 鍙屽悜璁よ瘉
    #mode: disable
    #mode: oneway
    mode: disable

monitor:
  enabled: false
  port: 14321

pprof:
  enabled: false
  port: 24321

storage:
  store_path: ../data/org1/ledgerData1
  blockdb_config:
    provider: leveldb
    leveldb_config:
      store_path: ../data/org1/blocks
  statedb_config:
    provider: leveldb
    leveldb_config:
      store_path: ../data/org1/state
  historydb_config:
    provider: leveldb
    leveldb_config:
      store_path: ../data/org1/history
  resultdb_config:
    provider: leveldb
    leveldb_config:
      store_path: ../data/org1/result
  disable_contract_eventdb: true  #鏄惁绂佹鍚堢害浜嬩欢瀛樺偍鍔熻兘锛岄粯璁や负true锛屽鏋滆缃负false,闇€瑕侀厤缃甿ysql
  contract_eventdb_config:
    provider: sql                 #濡傛灉寮€鍚痗ontract event db 鍔熻兘锛岄渶瑕佹寚瀹歱rovider涓簊ql
    sqldb_config:
      sqldb_type: mysql           #contract event db 鍙敮鎸乵ysql
      dsn: root:password@tcp(127.0.0.1:3306)/  #mysql鐨勮繛鎺ヤ俊鎭紝鍖呮嫭鐢ㄦ埛鍚嶃€佸瘑鐮併€乮p銆乸ort绛夛紝绀轰緥锛歳oot:admin@tcp(127.0.0.1:3306)/
debug:
  # 鏄惁寮€鍚疌LI鍔熻兘锛岃繃搴︽湡闂翠娇鐢�
  is_cli_open: true
  is_http_open: false

```


### Public

#### 閾鹃厤缃枃浠惰鏄�

**閰嶇疆鏂囦欢锛歜c.yml**

- auth_type锛氳韩浠芥ā寮�

  public锛氶潰鍚戝急鏉冮檺鎺у埗鍦烘櫙锛屽熀浜庡叕閽ョ殑鐢ㄦ埛鏍囪瘑浣撶郴銆佸熀浜庤鑹茬殑鏉冮檺鎺у埗浣撶郴銆�

* consensus锛氬叡璇嗛厤缃�

  - nodes锛氬叡璇嗚妭鐐瑰垪琛�

    **TBFT鍏辫瘑妯″紡闇€瑕侀厤缃叡璇嗚妭鐐瑰垪琛紝DPOS鍏辫瘑妯″紡涓嶉渶瑕侀厤缃€�**

* trust_roots锛氫俊浠绘牴閰嶇疆鍒楄〃

  **榛樿鍙娇鐢ㄥ垪琛ㄤ笅绗竴涓厤缃�**

  - org_id锛歱ublic妯″紡閰嶇疆鏍囪瘑锛堥渶瑕佸~鍐檖ublic锛�

  ```yaml
  org_id: "public"
  ```

  - root锛氶摼绠$悊鍛樺叕閽ユ墍鍦ㄨ矾寰勫垪琛�

#### 閾鹃厤缃枃浠剁ず渚�


```yaml
chain_id: chain1                      # 閾炬爣璇�
version: v1.0.0                       # 閾剧増鏈�
sequence: 0                           # 閰嶇疆鐗堟湰
auth_type: "public"                   # 璁よ瘉绫诲瀷 permissionedWithCert / permissionedWithKey / public

crypto:
  hash: SHA256

# 鍚堢害鏀寔绫诲瀷鐨勯厤缃�
contract:
  enable_sql_support: false

# 浜ゆ槗銆佸尯鍧楃浉鍏抽厤缃�
block:
  tx_timestamp_verify: true # 鏄惁闇€瑕佸紑鍚氦鏄撴椂闂存埑鏍¢獙
  tx_timeout: 600  # 浜ゆ槗鏃堕棿鎴崇殑杩囨湡鏃堕棿(绉�)
  block_tx_capacity: 100  # 鍖哄潡涓渶澶т氦鏄撴暟
  block_size: 10  # 鍖哄潡鏈€澶ч檺鍒讹紝鍗曚綅MB
  block_interval: 2000 # 鍑哄潡闂撮殧锛屽崟浣�:ms

# core妯″潡
core:
  tx_scheduler_timeout: 10 #  [0, 60] 浜ゆ槗璋冨害鍣ㄤ粠浜ゆ槗姹犳嬁鍒颁氦鏄撳悗, 杩涜璋冨害鐨勬椂闂�
  tx_scheduler_validate_timeout: 10 # [0, 60] 浜ゆ槗璋冨害鍣ㄤ粠鍖哄潡涓嬁鍒颁氦鏄撳悗, 杩涜楠岃瘉鐨勮秴鏃舵椂闂�
  consensus_turbo_config:
    consensus_message_turbo: false # 鏄惁寮€鍚叡璇嗘姤鏂囧帇缂�
    retry_time: 500 # 鏍规嵁浜ゆ槗ID鍒楄〃浠庝氦鏄撴睜鑾峰彇浜ゆ槗鐨勯噸璇曟鏁�
    retry_interval: 20 # 閲嶈瘯闂撮殧锛屽崟浣�:ms

#鍏辫瘑閰嶇疆
consensus:
  # 鍏辫瘑绫诲瀷(0-SOLO,1-TBFT,2-MBFT,3-HOTSTUFF,4-RAFT,5-DPOS)
  type: 5
  ext_config: # 鎵╁睍瀛楁锛岃褰曢毦搴︺€佸鍔辩瓑鍏朵粬绫诲叡璇嗙畻娉曢厤缃�
    - key: aa
      value: chain01_ext11
  dpos_config: # DPoS
    #ERC20鍚堢害閰嶇疆
    - key: erc20.total
      value: "10000000"
    - key: erc20.owner
      value: "6CeSsjU5M62Ee3Gx9umUX6nXJoaBkWYufQdTZqEJM5di"
    - key: erc20.decimals
      value: "18"
    - key: erc20.account:DPOS_STAKE
      value: "10000000"
    #Stake鍚堢害閰嶇疆
    - key: stake.minSelfDelegation
      value: "2500000"
    - key: stake.epochValidatorNum
      value: "4"
    - key: stake.epochBlockNum
      value: "10"
    - key: stake.completionUnbondingEpochNum
      value: "1"
    - key: stake.candidate:6CeSsjU5M62Ee3Gx9umUX6nXJoaBkWYufQdTZqEJM5di
      value: "2500000"
    - key: stake.candidate:F5tJ4ca4vdbuyffpc1Szw3WHU3caGaTVAh52MRMS4qBt
      value: "2500000"
    - key: stake.candidate:FxfunVWGkKgYMjngxMtLkd4pUNYVNAHNAqiDqopg5zdw
      value: "2500000"
    - key: stake.candidate:DYt7DfcZnqKNpjgyJ6tU6GFixNfLMkkmnqdwB3NNiAP7
      value: "2500000"

    - key: stake.nodeID:6CeSsjU5M62Ee3Gx9umUX6nXJoaBkWYufQdTZqEJM5di
      value: "QmZcFcJFYYoZ3FNNGL88QaszUZwFwuBdFqYh6yPzJURc3s"
    - key: stake.nodeID:F5tJ4ca4vdbuyffpc1Szw3WHU3caGaTVAh52MRMS4qBt
      value: "QmXwtuPemSgH5ypzoKvcLdCLbd9jZ25FbpNf7VPjHF3HMS"
    - key: stake.nodeID:FxfunVWGkKgYMjngxMtLkd4pUNYVNAHNAqiDqopg5zdw
      value: "QmRmQLHJoqAYGkuLFaNY6HLzwtTNxr45UJsYpSjdKvBQw2"
    - key: stake.nodeID:DYt7DfcZnqKNpjgyJ6tU6GFixNfLMkkmnqdwB3NNiAP7
      value: "QmURUHTGsuzzjgh1Xg6s92G1Q3gK91A6JEZGPfYNWwJMiT"

# 瓒呯骇绠$悊鍛�
trust_roots:
  - org_id: "public"
    root:
      - "../config-pk/public/admin/admin1/admin1.pem"
      - "../config-pk/public/admin/admin2/admin2.pem"
      - "../config-pk/public/admin/admin3/admin3.pem"
      - "../config-pk/public/admin/admin4/admin4.pem"
```



#### 鑺傜偣閰嶇疆鏂囦欢璇存槑

**閰嶇疆鏂囦欢锛歝hainmaker.yml**

- auth_type锛氳韩浠芥ā寮�

  public锛氶潰鍚戝急鏉冮檺鎺у埗鍦烘櫙锛屽熀浜庡叕閽ョ殑鐢ㄦ埛鏍囪瘑浣撶郴銆佸熀浜庤鑹茬殑鏉冮檺鎺у埗浣撶郴銆�

- node锛氳妭鐐归厤缃�

  - priv_key_file锛氳妭鐐圭閽ュ湴鍧€
  - cert_file锛氫笉闇€瑕侀厤缃�

- net锛氱綉缁滈厤缃�

  - tls锛歍LS閰嶇疆
    - priv_key_file锛氳妭鐐圭閽ュ湴鍧€
    - cert_file锛氫笉闇€瑕侀厤缃�

**娉細node鍜宯et閲岄渶瑕侀厤缃悓涓€涓閽ョ殑鍦板潃**銆�

#### 鑺傜偣閰嶇疆鏂囦欢绀轰緥


```yaml
auth_type: "public"                                                        # permissionedWithCert / permissionedWithKey / public

log:
  config_file: ../config-pk/public/node/node1/log.yml                           # config file of logger configuration.

blockchain:
  - chainId: chain1
    genesis: ../config-pk/public/node/node1/chainconfig/bc1.yml

node:
  # 鑺傜偣绫诲瀷锛歠ull
  type:              full
  org_id:            wx-org1.chainmaker.org
  priv_key_file:     ../config-pk/public/node/node1/node1.key
  signer_cache_size: 1000
  cert_cache_size:   1000

net:
  provider: LibP2P
  listen_addr: /ip4/0.0.0.0/tcp/11351
  seeds:
    - "/ip4/127.0.0.1/tcp/11351/p2p/QmZcFcJFYYoZ3FNNGL88QaszUZwFwuBdFqYh6yPzJURc3s"
    - "/ip4/127.0.0.1/tcp/11352/p2p/QmXwtuPemSgH5ypzoKvcLdCLbd9jZ25FbpNf7VPjHF3HMS"
    - "/ip4/127.0.0.1/tcp/11353/p2p/QmRmQLHJoqAYGkuLFaNY6HLzwtTNxr45UJsYpSjdKvBQw2"
    - "/ip4/127.0.0.1/tcp/11354/p2p/QmURUHTGsuzzjgh1Xg6s92G1Q3gK91A6JEZGPfYNWwJMiT"
  tls:
    enabled: true
    priv_key_file: ../config-pk/public/node/node1/node1.key

# Transaction pool settings
# Other txpool settings can be found in tx_Pool_config.go
txpool:
  # tx_pool type, can be single, normal, batch.
  # By default the tx_pool type is normal.
  # Note: please delete dump_tx_wal folder in storage.store_path when change tx_pool type
  pool_type: "normal"

  # Max common transaction count in tx_pool.
  # If tx_pool is full, the following transactions will be discarded.
  max_txpool_size: 50000

  # Max config transaction count in tx_pool.
  max_config_txpool_size: 10

  # Whether dump unpacked config and common transactions in queue when stop node,
  # and replay these transactions when restart node.
  is_dump_txs_in_queue: true

  # Common transaction queue num, only for normal tx_pool.
  # Note: the num should be an exponent of 2 and less than 256, such as, 1, 2, 4, 8, 16, ..., 256
  common_queue_num: 8

  # The number of transactions contained in a batch, for normal and batch tx_pool.
  # Note: make sure that block.block_tx_capacity in bc.yml is an integer multiple of batch_max_size
  batch_max_size: 100

  # Interval of creating a transaction batch, for normal and batch tx_pool, in millisecond(ms).
  batch_create_timeout: 50

rpc:
  provider: grpc
  port: 12301
  tls:
    # TLS妯″紡:
    #   disable - 涓嶅惎鐢═LS
    #   oneway  - 鍗曞悜璁よ瘉
    #   twoway  - 鍙屽悜璁よ瘉
    #mode: disable
    #mode: oneway
    mode: disable

monitor:
  enabled: false
  port: 14321

pprof:
  enabled: false
  port: 24321

storage:
  store_path: ../data/node1/ledgerData1
  blockdb_config:
    provider: leveldb
    leveldb_config:
      store_path: ../data/node1/blocks
  statedb_config:
    provider: leveldb
    leveldb_config:
      store_path: ../data/node1/state
  historydb_config:
    provider: leveldb
    leveldb_config:
      store_path: ../data/node1/history
  resultdb_config:
    provider: leveldb
    leveldb_config:
      store_path: ../data/node1/result
  disable_contract_eventdb: true  #鏄惁绂佹鍚堢害浜嬩欢瀛樺偍鍔熻兘锛岄粯璁や负true锛屽鏋滆缃负false,闇€瑕侀厤缃甿ysql
  contract_eventdb_config:
    provider: sql                 #濡傛灉寮€鍚痗ontract event db 鍔熻兘锛岄渶瑕佹寚瀹歱rovider涓簊ql
    sqldb_config:
      sqldb_type: mysql           #contract event db 鍙敮鎸乵ysql
      dsn: root:password@tcp(127.0.0.1:3306)/  #mysql鐨勮繛鎺ヤ俊鎭紝鍖呮嫭鐢ㄦ埛鍚嶃€佸瘑鐮併€乮p銆乸ort绛夛紝绀轰緥锛歳oot:admin@tcp(127.0.0.1:3306)/
debug:
  # 鏄惁寮€鍚疌LI鍔熻兘锛岃繃搴︽湡闂翠娇鐢�
  is_cli_open: true
  is_http_open: false
```


## 瑙掕壊涓庢潈闄愮鐞�
### 瑙掕壊绫诲瀷

<span id="role_type"></span>

闀垮畨閾句腑锛屽畾涔変簡浠ヤ笅鍑犵瑙掕壊绫诲瀷锛�

- 鍏辫瘑鑺傜偣 `consensus`锛氭湁鏉冨弬涓庡尯鍧楀叡璇嗘祦绋嬬殑閾句笂鑺傜偣锛�
- 鍚屾鑺傜偣`common`锛氭棤鏉冨弬涓庡尯鍧楀叡璇嗘祦绋嬶紝浣嗗彲鍦ㄩ摼涓婂悓姝ユ暟鎹殑鑺傜偣锛�
- 绠$悊鍛� `admin`锛氬彲浠h〃缁勭粐杩涜閾句笂娌荤悊鐨勭敤鎴凤紱
- 鏅€氱敤鎴� `client`锛氭棤鏉冭繘琛岄摼涓婃不鐞嗭紝浣嗗彲鍙戦€佸拰鏌ヨ浜ゆ槗鐨勭敤鎴凤紱
- 杞昏妭鐐圭敤鎴穈``light```锛氭棤鏉冭繘琛岄摼涓婃不鐞嗭紝鏃犳潈鍙戦€佷氦鏄擄紝鍙彲鏌ヨ銆佽闃呰嚜宸辩粍缁囩殑鍖哄潡銆佷氦鏄撴暟鎹紝灞炰簬SPV杞昏妭鐐圭敤鎴凤紙璇︽儏瑙乕杞昏妭鐐筣(../tech/SPV杞昏妭鐐�.md)锛夈€�

### 鏉冮檺瀹氫箟

闀垮畨閾鹃噰鐢ㄤ笁娈靛紡璇硶瀹氫箟璧勬簮鐨勮闂潈闄愶細瑙勫垯 (`rule`)銆佺粍缁囧垪琛� (`orgList`)銆佽鑹插垪琛� (`roleList`)

- 瑙勫垯锛氫互鍏抽敭瀛楃殑褰㈠紡鎻忚堪浜嗛渶瑕佸灏戜釜缁勭粐鐨勭敤鎴峰叡鍚岃鍙墠鍙闂祫婧愶紝鍚堟硶鐨勮鍒欏寘鎷細
    - `ALL`锛氳姹� `orgList` 鍒楄〃涓墍鏈夌粍缁囧弬涓庯紝姣忎釜缁勭粐鑷冲皯鎻愪緵涓€涓鍚� `roleList` 瑕佹眰瑙掕壊鐨勭鍚嶏紱
    - `ANY`锛氳姹� `orgList` 鍒楄〃涓换鎰忎竴涓粍缁囨彁渚涚鍚� `roleList` 瑕佹眰瑙掕壊鐨勭鍚嶏紱
    - `MAJORITY`锛氳姹傝仈鐩熼摼涓繃鍗婃暟缁勭粐鎻愪緵鍚勮嚜 `admin` 瑙掕壊鐨勭鍚嶏紱
    - 涓€涓互瀛楃涓插舰寮忚〃杈剧殑**鏁存暟** (e.g. "3")锛氳姹俙orgList` 鍒楄〃涓ぇ浜庢垨绛変簬瑙勫畾鏁扮洰鐨勭粍缁囨彁渚涚鍚� `roleList` 瑕佹眰瑙掕壊鐨勭鍚嶏紱
    - 涓€涓互瀛楃涓插舰寮忚〃杈剧殑**鍒嗘暟** (e.g. "2/3") 锛氳姹俙orgList` 鍒楄〃涓ぇ浜庢垨绛変簬瑙勫畾姣斾緥鐨勭粍缁囨彁渚涚鍚� `roleList` 瑕佹眰瑙掕壊鐨勭鍚嶏紱
    - `SELF`锛氳姹傝祫婧愭墍灞炵殑缁勭粐鎻愪緵绗﹀悎 `roleList` 瑕佹眰瑙掕壊鐨勭鍚嶏紝鍦ㄦ鍏抽敭瀛椾笅锛宍orgList`涓殑缁勭粐鍒楄〃淇℃伅涓嶇敓鏁堬紝璇ヨ鍒欑洰鍓嶅彧閫傜敤浜庝慨鏀圭粍缁囨牴璇佷功銆佷慨鏀圭粍缁囧叡璇嗚妭鐐瑰湴鍧€杩欎袱涓搷浣滅殑鏉冮檺閰嶇疆锛�
    - `FORBIDDEN`锛氭瑙勫垯琛ㄧず绂佹鎵€鏈変汉璁块棶锛屽湪姝ゅ叧閿瓧涓嬶紝`orgList`鍜� `roleList` 涓嶇敓鏁堛€�
- 缁勭粐鍒楄〃锛氬悎娉曠殑缁勭粐鍒楄〃闆嗗悎锛岀粍缁囬渶鍑虹幇鍦ㄩ厤缃枃浠剁殑 `trust root` 涓紝鑻ヤ负绌哄垯榛樿鍑虹幇鍦� `trust root` 涓殑鎵€鏈夌粍缁囷紱
- 瑙掕壊鍒楄〃锛氬悎娉曠殑瑙掕壊鍒楄〃闆嗗悎锛岃嫢涓虹┖鍒欓粯璁ゆ墍鏈夎鑹层€�

绀轰緥濡備笅锛�

| 鏉冮檺瀹氫箟                                     | 璇存槑                                                         |
| -------------------------------------------- | ------------------------------------------------------------ |
| `ALL` `[org1, org2, org3]` `[admin, client]` | 涓変釜缁勭粐鍚勮嚜鎻愪緵鑷冲皯涓€涓鐞嗗憳鎴栨櫘閫氱敤鎴锋彁渚涚鍚嶆墠鍙闂搴旇祫婧� |
| `1/2` `[] ` `[admin]`                        | 閾句笂鎵€鏈夌粍缁囦腑杩囧崐鏁扮粍缁囩殑绠$悊鍛樻彁渚涚鍚嶆墠鍙闂搴旇祫婧愶紙鑷畾涔夌増鏈殑`MAJORITY`瑙勫垯锛� |
| `SELF` `[] ` `[admin]`                       | 璧勬簮鎵€灞炵粍缁囩殑绠$悊鍛樻彁渚涚鍚嶆墠鍙闂搴旇祫婧愶紝渚嬪缁勭粐绠$悊鍛樻湁鏉冧慨鏀瑰悇鑷粍缁囩殑鏍硅瘉涔� |

### 璧勬簮瀹氫箟

闀垮畨閾句腑锛岃祫婧愬悕绉扮殑瀹氫箟閲囩敤 **[鍚堢害鍚嶇О]-[鏂规硶鍚嶇О]** 鐨勮鍒欍€�

渚嬪:
* 淇敼閾句笂閰嶇疆鐨勭郴缁熷悎绾� **CHAIN_CONFIG** 锛岃鍚堢害鍖呭惈娣诲姞鏍硅瘉涔︾殑鏂规硶 **TRUST_ROOT_ADD**锛屽鏋滆淇敼璇ユ柟娉曠殑鏉冮檺锛屽搴旂殑璧勬簮鍚嶇О涓猴細CHAIN_CONFIG-TRUST_ROOT_ADD銆�
* CHAIN_CONFIG-TRUST_ROOT_ADD瀵瑰簲鐨勯粯璁ゆ潈闄愬畾涔夋槸`{MAJORITY [] [ADMIN]}`鍒欒〃绀�**娣诲姞鏍硅瘉涔�**鎿嶄綔闇€瑕佸鎴风浜ゆ槗婊¤冻**鍗婃暟浠ヤ笂缁勭粐绠$悊鍛樺绛�**锛屾墠鑳介獙璇侀€氳繃銆�

闀垮畨閾炬彁渚涗簡璁稿榛樿鐨勮祫婧愭潈闄愬畾涔�, 鍏蜂綋鍙傝€冿細[韬唤鏉冮檺绠$悊](../tech/韬唤鏉冮檺绠$悊.md)