Dymension Hub Development Guide
A comprehensive guide for developing on the Dymension Hub blockchain - the settlement layer of the Dymension protocol built with Cosmos SDK in Go.
Architecture Overview
Dymension Hub is a Cosmos SDK-based blockchain with specialized modules for RollApp management:
Core Modules
**rollapp**: RollApp registration, state updates, finalization queue, fraud proofs**sequencer**: Sequencer lifecycle, bonding/unbonding, rotation, rewards**lightclient**: Canonical IBC light clients for RollApps (critical for EIBC)**delayedack**: Custom IBC middleware for delayed packet acknowledgments**eibc**: Fast finality via market makers fulfilling orders before finalizationEconomic Modules
**iro**: Initial RollApp Offering with bonding curves**incentives**: Gauge-based liquidity rewards**sponsorship**: Validator-voted reward distributionDevelopment Environment Setup
Prerequisites
Go 1.23.0+ with toolchain 1.24.2Docker (for proto generation)golangci-lint v2.1Local Setup
```bash
Clone and enter repository
git clone [repository-url]
cd dymension
Install binary
make install
Setup local node
./scripts/setup_local.sh
Start local node
dymd start
Bootstrap liquidity pools (optional)
sh scripts/pools/pools_bootstrap.sh
```
Building and Testing
Build Commands
```bash
Install to $GOPATH/bin
make install
Build to ./build/dymd
make build
Build debug version
make build-debug
```
Testing Commands
```bash
Run all tests
go test ./...
Run with race detection and coverage
go test -race -coverprofile=coverage.txt ./...
Test specific module
go test ./x/rollapp/...
Integration tests
go test ./ibctesting/...
```
Linting and Formatting
```bash
Run linter
golangci-lint run
Format code
gofumpt -w .
Format proto files
make proto-format
```
Critical Development Rules
Cosmos SDK Constraints
All code runs single-threaded - no multithreadingTransactions are atomic - any error causes complete rollbackBeginBlocker/EndBlocker must NEVER panic (causes chain halt)Code must be deterministic across all validatorsProto Buffer Management
```bash
Generate protobuf files (requires Docker)
make proto-gen
Generate swagger docs
make proto-swagger-gen
Lint proto files
make proto-lint
```
Module Development Patterns
Standard Module Structure
```
x/module/
├── keeper/ # Business logic
├── types/ # Type definitions
├── client/cli/ # CLI commands
└── hooks.go # Cross-module communication
```
Key Dependencies
`rollapp` → `sequencer`: Sequencer validation`delayedack` → `rollapp`: State finalization checks`eibc` → `delayedack`: Packet fulfillment`incentives` → `lockup`, `sponsorship`: Reward distributionCLI Usage Guide
Configuration
```bash
View client configuration
dymd config view client
Set chain ID
dymd config set client chain-id dymension_1100-1
Set RPC endpoint
dymd config set client node https://dymension-rpc.polkachu.com:443
```
Key Management
```bash
Create new key
dymd keys add wallet1
Recover from mnemonic
dymd keys add wallet2 --recover
List all keys
dymd keys list
Show address
dymd keys show wallet1 --address
```
Querying State
```bash
Check balance
dymd query bank balances dym1address...
List validators
dymd query staking validators
Query RollApp
dymd query rollapp show rollapp_1234-1
List sequencers
dymd query sequencer list-sequencer
```
Common Transactions
```bash
Send tokens
dymd tx bank send wallet1 dym1recipient... 1000000adym --from wallet1
Delegate to validator
dymd tx staking delegate dymvaloper1... 1000000adym --from wallet1
Create RollApp (example)
dymd tx rollapp create-rollapp rollapp_1234-1 --from wallet1
```
Code Quality Standards
Comments Policy
NEVER comment WHAT code does (code is self-documenting)ONLY comment WHY for unusual/unclear implementationsExample:```go
// BAD: Increment counter by 1
counter++
// GOOD: Retry 3 times due to intermittent network issues
for i := 0; i < 3; i++ {
// retry logic
}
```
CI Tools Usage
Run tools only when needed:
`golangci-lint run` - Only for Go code changes`gofumpt -w .` - Only for Go code changes`make proto-format` and `make proto-gen` - Only for .proto changes`go test ./package/...` - Only for modified packagesDefault Configuration
Network Ports
RPC: 36657P2P: 36656gRPC: 8090REST API: 1318JSON-RPC: 9545Chain Parameters
Default chain ID: `dymension_100-1` (local)Default denom: `adym` (1 dym = 1 * 10^18 adym)Home directory: `~/.dymension/`Troubleshooting
Common Issues
1. **Chain halt**: Check for panics in BeginBlocker/EndBlocker
2. **Non-deterministic behavior**: Ensure all validators get same results
3. **Transaction failures**: All operations are atomic - any error rolls back entire transaction
Verification Commands
```bash
Check node status
dymd status
Get node ID
dymd comet show-node-id
Show validator info
dymd comet show-validator
Check uncommitted changes
git status --porcelain
```
This guide provides the essential knowledge for developing on the Dymension Hub blockchain while following Cosmos SDK best practices and maintaining code quality standards.