===========================================
POP BUILD CHAIN
===========================================

Build a chain

Usage: pop build [OPTIONS] [PATH]
       pop build <COMMAND>

Commands:
  spec  Build a chain specification and its genesis artifacts

Arguments:
  [PATH]  Directory path without flag for your project [default: current directory]

Options:
      --path <PATH>          Directory path with flag for your project [default: current directory]
  -p, --package <PACKAGE>    The package to be built
  -r, --release              For production, always build in release mode to exclude debug features
      --profile <PROFILE>    Build profile [default: debug]
  -f, --features <FEATURES>  List of features that project is built with, separated by commas
  -h, --help                 Print help

Chain options:
  -b, --benchmark    For benchmarking, always build with `runtime-benchmarks` feature
  -t, --try-runtime  For testing with `try-runtime`, always build with `try-runtime` feature

Runtime options:
  -d, --deterministic  Whether to build a runtime deterministically. Implies --only-runtime
      --only-runtime   Whether to build only the runtime

===========================================
USAGE
===========================================

# Build from inside chain directory
cd my-chain
pop build

# Build release
pop build --release

# Build with specific profile
pop build --profile release

# Build from outside directory
pop build --path ./my-chain --release

# Build with benchmarking support
pop build --release --benchmark

# Build with try-runtime for testing upgrades
pop build --release --try-runtime

# Build deterministic runtime (requires Docker/Podman)
pop build --deterministic

# Build chain specification
pop build spec --release

===========================================
BUILD PROFILES
===========================================

--profile <PROFILE>:
- debug (default): Development builds with debug symbols
- release: Built in release mode
- production: Built for production

===========================================
CHAIN BUILD FLAGS
===========================================

--benchmark (-b):
- Builds runtime with `runtime-benchmarks` feature enabled
- Required for running benchmarks on your chain
- Use when you need to benchmark pallet extrinsics
- Enables frame-benchmarking functionality

When to use:
pop build --release --benchmark
pop bench pallet  # Requires runtime built with --benchmark

--try-runtime (-t):
- Builds runtime with `try-runtime` feature enabled
- Required for testing runtime upgrades before deployment
- Use when testing migrations and on-runtime-upgrade hooks
- Enables try-runtime CLI functionality

When to use:
pop build --release --try-runtime
pop test on-runtime-upgrade  # Test migrations
pop test fast-forward        # Test runtime upgrade simulation
pop test execute-block       # Execute blocks against state

--deterministic (-d):
- Builds runtime deterministically using Docker/Podman
- Produces reproducible WASM runtime blob
- Automatically implies --only-runtime
- Ensures byte-for-byte identical builds

When to use:
- Production runtime releases
- Reproducible builds for runtime upgrades

Requirements:
- Docker or Podman installed
- Builds only the runtime (not the node)

--only-runtime:
- Builds only the runtime WASM blob
- Skips building the node binary
- Faster builds when only runtime changes
- Used with --deterministic

===========================================
WHAT IT DOES
===========================================

Standard Build (pop build):
- Compiles chain runtime to WASM
- Compiles node binary
- Generates runtime blob

Release Build (pop build --release):
- Optimized compilation
- Smaller binary size
- Better performance

Build Spec (pop build spec):
- Generates chain specification file
- Creates genesis state and code
- Required for parachain registration

===========================================
EXAMPLES
===========================================

# Standard development build
pop build

# Production release build
pop build --release

# Build for benchmarking pallets
pop build --release --benchmark

# Build for testing runtime upgrades
pop build --release --try-runtime

# Build deterministic runtime for governance
pop build --deterministic

# Build chain spec
pop build spec

# Build with multiple features
pop build --release --benchmark --try-runtime

# Build only runtime
pop build --release --only-runtime

# Build specific package
pop build --package my-runtime --release

===========================================
WORKFLOW: BENCHMARKING
===========================================

1. Build with benchmark flag:
pop build --release --benchmark

2. Run benchmarks:
pop bench pallet
pop bench block
pop bench overhead
pop bench storage
pop bench machine

See: https://learn.onpop.io (benchmarking guide)

===========================================
WORKFLOW: TESTING RUNTIME UPGRADES
===========================================

1. Build with try-runtime flag:
pop build --release --try-runtime

2. Test runtime upgrade:
pop test on-runtime-upgrade

3. Test with state simulation:
pop test fast-forward

4. Execute historical blocks:
pop test execute-block

See: https://learn.onpop.io (runtime upgrades guide)

===========================================
WORKFLOW: PRODUCTION DEPLOYMENT
===========================================

1. Build deterministic runtime:
pop build --deterministic

2. Build release node:
pop build --release

3. Generate chain spec:
pop build spec --release --para-id 2000

4. Deploy to relay chain:
pop up --id 2000 --relay-chain-url wss://paseo-rpc.dwellir.com

===========================================
NEXT STEPS
===========================================

After building:

For benchmarking:
pop bench pallet

For testing upgrades:
pop test on-runtime-upgrade

For deployment:
pop up

For extrinsics:
pop call chain --pallet System --function remark --args "Hello"

See: up/chain.txt, call/chain.txt
