infrablockchain-docs
en
en
  • InfraBlockchain
    • Learn
      • Architecture
        • Architecture
        • Network Participants
        • Parachain
          • System Parachains
      • Protocol
        • System Token
        • Transaction Fee
        • Proof of Transaction
      • Substrate
        • Learn
          • Basic
            • Cryptography
            • Blockchain Basics
            • Consensus
            • Networks and Nodes
            • Blockchain Transaction
            • Transaction Life Cycle
            • Offchain Operations
            • Light Client
            • Rust for Substrate
            • Introduction to Library
            • Architecture and Rust Libraries
            • File Architecture
            • Accounts, Addresses, and Keys
            • Transaction Format
            • Blockchain Randomness
          • FRAME
            • FRAME Pallets
            • FRAME Macros
            • Custom Pallets
            • Pallet Coupling
            • Origin
            • Events and Erros
            • Runtime Storage
            • State Transitions and Storage
            • SCALE Encoding
            • Weight and Fee
            • Runtime API
            • Runtime Development
          • Account
          • Address Format
          • Glossary
          • CLI
            • Archive
            • Memory Profiler
            • Node Template
            • sidecar
            • srtool
            • Subkey
            • subxt
            • try-runtime
            • tx-wrapper
          • Runtime Development
            • Basics
              • Configure Genesis State
              • Configure Runtime Constants
              • Customize a Chain Spec
              • Import a Pallet
              • Use Helper Function
            • Consensus Model
              • PoW
              • Create a Hybrid Node
            • Offchain Worker
              • Request Offchain HTTP
              • Offchain Indexing
              • Offchain Local Storage
            • Pallet Design
              • Create a Storage Structure
              • Implement Lockable Currency
              • Incorporate Randomness
              • Loose Coupling
              • Tight Coupling
            • Parachain Development
              • Add HRMP Channel
              • Add Paranodes
              • Connect to a Local Relay Chain
              • Convert a Solo Chain
              • Prepare to Launch
              • Select Collator
              • Upgrade a Parachain
            • Storage Migration
              • Basics
              • Trigger Migration
            • Test
              • Basics
              • Test a Transfer Transaction
            • Tools
              • Create a TxWrapper
              • Use Sidecar
              • try-runtime
              • Verify WASM
            • Weigths
              • Benchmark
              • Calculate Fees
              • Use Conditional Weights
              • Use Custom Weights
        • Build
          • Decide What to Build
          • Build Process
          • Determinisitc Runtime
          • Chain Spec
          • Genesis Configuration
          • Application Development
          • RPC
          • Troubleshoot Your Code
        • Tutorials
          • Install
            • Developer Tools
            • Linux
            • macOS
            • Rust Toolchain
            • Issues
            • Windows
          • Quick Start
            • Explore the Code
            • Modify Runtime
            • Start a Node
            • Substrate Basics
          • Build a Blockchain
            • Add Trusted Nodes
            • Authorize Specific Nodes
            • Build a Local Blockchain
            • Simulate Network
            • Upgrade a Running Network
          • Build Application Logic
            • Add a Pallet
            • Add Offchasin Workers
            • Publish Custom Pallets
            • Specify Origin for a Call
            • Use Macros in a Custom Pallet
          • Integrate with Tools
            • Access EVM Accounts
            • EVM Integration
            • Explore Sidecar Endpoints
            • Integrate a Light Client Node
          • Smart Contracts
            • Strategy
            • Build a Token Contract
            • Develop a Smart Contract
            • Prepare Your First Contract
            • Troubleshoot Smart Contracts
            • Use Maps for Storing Values
      • XCM
        • XCM
        • XCM Format
    • Service Chains
      • InfraDID
      • InfraEVM
      • URAuth(Universal Resource Auth)
    • DevOps
      • Build
      • Deploy
      • Monitoring
      • Runtime Upgrade
    • Tutorials
      • Basic
        • How to Interact with System Token
        • How To Pay Transaction Fee
        • How To Vote with TaaV
        • Hot to Get Validator Reward
      • Build
        • Build InfraRelayChain
        • Build Parachain
        • Open Message Passing Channels
        • Transfer Assets with XCM
      • Test
        • Benchmark
        • Check Runtime
        • Debug
        • Simulate Parachains
        • Unit Testing
      • Service Chains
        • Play with InfraDID
          • Build
          • Add Keys
          • Add Service Endpoint
          • Create InfraDID
        • Play with InfraEVM
          • Build
          • Deposit and Withdraw Token
          • Deploy ERC20 Contract
          • Deploy ERC721 Contract
          • Deploy ERC1155 Contract
  • Newnal Data Market
Powered by GitBook
On this page
  • Set a unique protocol identifier
  • Memory profiling
  • Minimize your runtime size
  • Critical parachain constraints
  • Use proper weights
  • Setup call filters
  • Incremental runtime deployments
  • Launch simulation
  • Examples
  • Resources
  1. InfraBlockchain
  2. Learn
  3. Substrate
  4. Learn
  5. Runtime Development
  6. Parachain Development

Prepare to Launch

PreviousConvert a Solo ChainNextSelect Collator

Last updated 1 year ago

The aim of this guide is to step you through how to launch a parachain outside of a local testing environment. You will learn how to make sure protocolId is set uniquely and that runtime weights are correct.

The runtime constraints on a parachain are much stricter than a solochain, as you must coordinate with the relay chain to finalize state transitions. When launching a parachain to production, it is critically important to make sure a chain's runtime is properly configured and tested.

Set a unique protocol identifier

Network collisions can cause major headaches. All chains should use a unique protocolId that no other network of any type—whether a test network, relay chain, or parachain—uses. Having a unique protocol identifier ensures your nodes connect with the correct peer nodes and not with nodes from other libp2p networks. You want to isolate them to a distinct peer group with this ID. Protocol ID collisions will cause many issues for your nodes.

In order to set a unique protocol ID, change make sure you use some nonce or salt value. This is set (for the ) as a CLI item in /client/network/src/command.rs, and passed to extend the /client/network/src/chain_spec.rs

All files include this item as a field. For example, the primary chain specs have unique protocol IDs. For Polkadot:

// raw chain spec file in polkadot repo `/node/service/chain-specs/polkadot.json`
{
  //--snip--
  "protocolId": "dot"
  //--snip--
}

Monitor for updates about a better way to safely configure this constant in the future.

Memory profiling

Collator should be done to analyze memory leaks, identify where memory consumption is happening, define temporary allocations, and investigate excessive memory fragmentation within applications.

Minimize your runtime size

When launching a parachain, it is critical to use the compressed version of the runtime to lower the amount of resource consumption as much as possible for the relay chain.

  • It is recommended to launch a parachain with limited functionality and gradually increase it with runtime upgrades. The reason behind that is that during a runtime upgrade both the previous runtime and the new runtime are included in the PoVBlock and therefore if the changes are large enough the block might be rejected by the Relay Chain due to PoVBlock size limits.

  • If the runtime is included in the state proof, ensure the PoV block (i.e. the set of extrinsics, including the new runtime, the PoV state proof, potentially the old runtime) fits within the PoVBlock size limit. If the runtime is not included in the state proof, the size limit of the new runtime will be much higher.

Critical parachain constraints

  • The runtime version of the relay chain you are targeting (these may change)

  • MAX_CODE_SIZE

  • MAX_HEAD_DATA_SIZE

  • MAX_POV_SIZE

You must have your parachain fit comfortably within these maxima. You can also use the the Polkadot-JS Apps UI connected to a relay node to see these constants: Developers -> ParachainsConfiguration -> ActiveConfiguration

Use proper weights

Custom weights

If you need to diverge from benchmarks, make sure that each pallet in your runtime employs the correct weighting system. Default and "guessed at" weights are not to be used in production, as a general rule.

Set block weight limit

It is recommended to have a block weight limit (block production time) of 0.5 seconds in the beginning due to uncertainties in block execution time. As the execution time of the network stabilizes the weight limit can be increased to 2 seconds.

Setup call filters

Especially when launching a parachain, you might need to highly constrict what is enabled for specific classes of users. This can be accomplished with call filters.

Incremental runtime deployments

If you are approaching limits outline above before launch (like a too-large large runtime) it is highly advisable to prune down functionality as much as practical and incrementally upgrade. In these cases, you can:

  1. Generate the genesis state of your chain with full runtime functionality (including all the pallets)

  2. Remove all pallets that you will not need upon parachain launch from your runtime

  3. Re-build the WASM blob (validation logic) and the runtime of the chain

  4. Register your parachain with the updated genesis and the WASM blob generated in (3)

  5. After your parachain is live you can upgrade your runtime on-chain to include the missing pallets (ensure that pallet indices and names match those used to generate the genesis state in step (1) without having to do storage migrations. For more information on on-chain runtime upgrades refer to the next section.

Launch simulation

Before you try anything on a production testnet or mainnet, you should launch your chain on a network that simulates the behavior of a real network as closely as possible. Testing in a confined network will help you prepare for potential failures in a real network with many collators and validators and constraints like bandwidth and latency. The more closely you can simulate a real network for testing, the more sure you can be that your runtime upgrades will succeeds.

Examples

Resources

You can check the maximum sizes for all relay chains (these are common constants). Make note of:

Use to ensure that your runtime weights are actually indicative of the resources used by your runtime.

Here you can see an example of how to and functionality with filters as implemented in the .

See the for how to go about actually performing these incremental runtime upgrades.

See the to for a selection of tools for automation of such testing.

parachain node template
chain specification
relay chain runtime
this issue
memory profiling
in the Polkadot repo
runtime benchmarking
limit
enable
Statemine runtime deployment
parachain runtime upgrade guide
Prepare a local relay chain
Statemine runtime deployment
Reference documentation for runtime upgrades
A how-to guide to use benchmarked weights
Reference for try-runtime documentation
try-runtime video workshop
Fork Off Substrate tool