Nervos CKB Docs
  • Basics
  • Reference
  • Labs
  • Integrate
  • Essays

›Essays

Basics

  • Basics Introduction
  • Concepts

    • Nervos Blockchain
    • Cell Model
    • Consensus
    • Economics
    • CKB-VM

    Guides

    • Run a CKB Dev Blockchain
    • Run a CKB Mainnet Node
    • Run a CKB Testnet Node
    • Neuron Wallet Guide
    • Run a CKB Mainnet Node and Testnet Node with Docker
    • Get CKB Binary
    • Get CKB Binary on Windows (experimental)
  • Tools
  • Glossary

Reference

  • Introduction
  • Cell
  • Script
  • Transaction
  • JSON-RPC

Labs

  • Introduction
  • Write a SUDT script by Capsule
  • Introduction to Lumos via NervosDAO
  • Dynamic loading in Capsule

Integrate

  • Nervos CKB Mainnet - Integration Guide
  • Q&A | For Wallets/Exchanges/Mining Pools
  • Nervos CKB SDK

Essays

  • Introduction
  • Developer Materials Guide
  • A Tour of RFCs
  • Transaction validation lifecycle
  • Tips for debugging CKB script
  • Tips for profiling CKB script
  • The General Workflow for Constructing a Transaction
  • Script dependencies
  • Introduction to CKB Studio
  • Technical Bits on Polyjuice
  • CKB FAQs
  • Tips for CKB development
  • Integrity Check for CKB Release
  • Mint SUDT via Contract

Tips for CKB development

Nervos CKB is the layer 1 of Nervos Network, a public/permissionless blockchain, which is an open source project on github. There are some tips for ckb development below, hope it will be useful for you.

Molecule

We have developed a particular serialization format called Molecule.It is recommended to check the molecule github repo for more details.

Well-known Hashes

The command ckb list-hashes prints the well-known hashes for current effective chain spec.

The file docs/hashes.toml in ckb release package and source code repository contains the well-known hashes for all the bundled chain specs. The file is generated by:

cargo run list-hashes -b > docs/hashes.toml

Running Test

Install dependencies

rustup component add rustfmt
rustup component add clippy

Run tests

make ci

Run acceptance integration tests

make integration

Debug CKB

Note: Only support linux system.

Track Memory Usage in Logs

Add the follow configuration into ckb.toml:

[logger]
filter = "error,ckb-memory-tracker=trace"

[memory_tracker]
# Seconds between checking the process, 0 is disable, default is 0.
interval = 600

Profile Memory

  • Compile ckb with feature profiling.

    make build-for-profiling
    

    After compiling, a script named jeprof will be generated in target direcotry.

    find target/ -name "jeprof"
    
  • Enable RPC module Debug in ckb.toml.

    [rpc]
    modules = ["Debug"]
    
  • Run ckb.

  • Dump memory usage to a file via call RPC jemalloc_profiling_dump.

    curl -H 'content-type: application/json' -d '{ "id": 2, "jsonrpc": "2.0", "method": "jemalloc_profiling_dump", "params": [] }' http://localhost:8114
    

    Then, a file named ckb-jeprof.$TIMESTAMP.heap will be generated in the working directory of the running ckb.

  • Generate a PDF of the call graph.

    Required: graphviz and ghostscript

    jeprof --show_bytes --pdf target/debug/ckb ckb-jeprof.$TIMESTAMP.heap > call-graph.pdf
    

References

  • JEMALLOC: Use Case: Leak Checking
  • JEMALLOC: Use Case: Heap Profiling
  • RocksDB: Memory usage in RocksDB
← CKB FAQsIntegrity Check for CKB Release →
  • Molecule
  • Well-known Hashes
  • Running Test
  • Debug CKB
    • Track Memory Usage in Logs
    • Profile Memory
    • References
Foundation
About Us
Developer
GitHubWhitepaperRFCs
TwitterBlogTelegramRedditYouTubeForum
Copyright © 2020 Nervos Foundation. All Rights Reserved.
Note we've completely rebuilt Nervos Doc site! For the old doc site, please see docs-old.