Skip to content

Latest commit

 

History

History
204 lines (154 loc) · 5.94 KB

File metadata and controls

204 lines (154 loc) · 5.94 KB

Pull Request: Local Development Guide & Docker Integration

Description

This PR adds comprehensive documentation and tooling for local development of ILN smart contracts, including a complete local Stellar node setup via Docker for integration testing without testnet dependency.

What's Included

📖 Documentation

  • docs/local-development.md - Complete guide covering:
    • Prerequisites and environment setup
    • Rust & Stellar CLI installation
    • Local Stellar node setup via Docker
    • Contract building and deployment
    • Running unit, integration, and fuzz tests
    • Common issues and troubleshooting
    • Helper scripts for automation
    • CI/CD integration examples

🐳 Docker & Infrastructure

  • docker-compose.yml - Production-ready Stellar quickstart container with:
    • Health checks for automatic readiness detection
    • Persistent data volumes
    • Isolated network configuration
    • Comments explaining each section

🛠️ Helper Scripts

  • scripts/setup-local-env.sh - One-shot setup script that:

    • Verifies all prerequisites (Docker, Rust, Stellar CLI)
    • Starts local Stellar node
    • Waits for node health
    • Configures Stellar CLI
    • Creates and funds test account
  • scripts/deploy-local.sh - Contract deployment script that:

    • Builds all contracts to WASM
    • Uploads and deploys to local node
    • Saves contract IDs to .contracts-local.env
    • Provides detailed feedback
  • scripts/stop-local.sh - Stops and cleans up local node

  • scripts/local-test.sh - Quick test runner that:

    • Runs unit tests
    • Builds WASM
    • Checks benchmark regression

Key Features

🎯 Comprehensive Local Development

  • No Testnet Required - Full integration testing on local node
  • End-to-End - From setup to deployment in one guide
  • Well-Documented - 500+ lines covering all scenarios
  • Troubleshooting - Solutions for 10+ common issues
  • Automation - Helper scripts reduce manual work

📚 Documentation Quality

  • Prerequisite Verification - Clear tool version requirements
  • Step-by-Step - Each section builds on previous
  • Code Examples - Every instruction has exact copy-paste commands
  • Error Handling - Common failure modes and fixes
  • CI/CD Ready - GitHub Actions workflow example included

🔧 Developer Experience

  • Quick Setup - ./scripts/setup-local-env.sh does it all
  • Easy Deployment - ./scripts/deploy-local.sh handles contracts
  • Fast Testing - ./scripts/local-test.sh runs full suite
  • Clear Logs - Color-coded output, helpful error messages

Testing & Validation

✅ Verified

  • Docker Compose configuration syntax (valid)
  • Shell script syntax (bash v5.0+ compatible)
  • Markdown formatting (clean, readable)
  • All instructions are copy-paste ready
  • Links to existing documentation are valid
  • Environment variable naming is consistent
  • Script comments are comprehensive

🔄 Local Development Workflow

The documentation enables this development loop:

  1. Clone repo
  2. ./scripts/setup-local-env.sh - One command setup
  3. cargo test - Unit tests
  4. cargo build-wasm - Build contracts
  5. ./scripts/deploy-local.sh - Deploy to local node
  6. stellar contract invoke ... - Test on-chain

Changes Summary

File Type Purpose
docs/local-development.md ✨ New Complete local dev guide
docker-compose.yml ✨ New Local Stellar node config
scripts/setup-local-env.sh ✨ New Automated setup
scripts/deploy-local.sh ✨ New Contract deployment
scripts/stop-local.sh ✨ New Node shutdown
scripts/local-test.sh ✨ New Test automation

How to Review

  1. Read the guide: docs/local-development.md

    • Check coverage of all local development scenarios
    • Verify prerequisites are clear
    • Confirm troubleshooting section is helpful
  2. Review scripts: scripts/*.sh

    • Check error handling and logging
    • Verify they follow shell best practices
    • Ensure they're compatible with target platforms
  3. Validate Docker config: docker-compose.yml

    • Confirm health checks are appropriate
    • Check port mappings
    • Review environment variables
  4. Test locally (optional):

    # If you have Docker and Rust installed:
    ./scripts/setup-local-env.sh
    cargo test
    cargo build-wasm
    ./scripts/deploy-local.sh
    docker compose logs -f stellar

Breaking Changes

None. This is a documentation and configuration addition with no impact on existing code.


Related Issues

  • Closes: Contributors need clear instructions for running full smart contract stack locally
  • Addresses: No testnet dependency for local development

Checklist

  • Documentation is comprehensive and accurate
  • Code examples are tested for syntax
  • Helper scripts are production-ready
  • Docker configuration is valid
  • Troubleshooting section covers common issues
  • Links to existing docs are correct
  • Scripts have proper error handling
  • File permissions are correct (scripts executable)
  • No breaking changes to existing code
  • Ready for merge

Installation & Usage

After merge, contributors can follow these quick steps:

# Full setup in one command
./scripts/setup-local-env.sh

# Run tests
cargo test

# Build and deploy contracts locally
cargo build-wasm
./scripts/deploy-local.sh

# Stop local node when done
./scripts/stop-local.sh

See docs/local-development.md for detailed instructions.


Files Changed

✨ docs/local-development.md (NEW)
✨ docker-compose.yml (NEW)
✨ scripts/setup-local-env.sh (NEW)
✨ scripts/deploy-local.sh (NEW)
✨ scripts/stop-local.sh (NEW)
✨ scripts/local-test.sh (NEW)

Questions or Issues?

See the Troubleshooting section in the guide or open an issue.