diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 7d954206..8b5383e8 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -53,9 +53,7 @@ If checked, describe the breaking changes and migration path: ## Documentation -- [ ] README.md updated -- [ ] DEVELOPER_GUIDE.md updated (if applicable) -- [ ] API_REFERENCE.md updated (if applicable) +- [ ] README.md updated (if applicable) - [ ] No documentation changes needed ## Screenshots (if applicable) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1a11a205..3896d9b2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,6 +4,14 @@ on: push: pull_request: +# Harden against transient crates.io download failures on the runners +# (e.g. "curl failed [55] ... SSL_ERROR_SYSCALL"). Disabling HTTP/2 multiplexing +# and raising the retry count is the standard mitigation for that error. +env: + CARGO_NET_RETRY: "10" + CARGO_HTTP_MULTIPLEXING: "false" + CARGO_TERM_COLOR: always + jobs: fmt: name: Rustfmt diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml new file mode 100644 index 00000000..a704529f --- /dev/null +++ b/.github/workflows/fuzz.yml @@ -0,0 +1,57 @@ +name: Fuzz + +on: + push: + paths: + - "src/utils/fuzzing.rs" + - "src/utils/state_migration.rs" + - "src/utils/mock_soroban.rs" + - "src/commands/fuzz.rs" + - "tests/contract_property_tests.rs" + - "fuzz/**" + - ".github/workflows/fuzz.yml" + pull_request: + schedule: + # Nightly guided-fuzzing run at 03:17 UTC. + - cron: "17 3 * * *" + +# Harden against transient crates.io download failures on the runners. +env: + CARGO_NET_RETRY: "10" + CARGO_HTTP_MULTIPLEXING: "false" + +jobs: + property: + name: Property-Based & Engine Tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - name: Install system dependencies + run: sudo apt-get update && sudo apt-get install -y libudev-dev + - name: Property-based tests + run: cargo test --test contract_property_tests --locked + - name: Fuzzing engine unit tests + run: cargo test --locked fuzzing + + cargo-fuzz: + name: Guided Fuzzing (nightly) + runs-on: ubuntu-latest + # Only run on the nightly schedule: guided fuzzing is slow and nightly + + # libFuzzer can be flaky, so it should not run (or appear) on every PR/push. + if: github.event_name == 'schedule' + # Non-blocking even when scheduled: failures should never gate the branch. + continue-on-error: true + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@nightly + - name: Install system dependencies + run: sudo apt-get update && sudo apt-get install -y libudev-dev + - name: Install cargo-fuzz + run: cargo install cargo-fuzz --locked + - name: Fuzz the WASM validator (time-boxed) + working-directory: fuzz + run: cargo +nightly fuzz run fuzz_wasm_validator -- -max_total_time=60 + - name: Fuzz state diffing (time-boxed) + working-directory: fuzz + run: cargo +nightly fuzz run fuzz_state_diff -- -max_total_time=60 diff --git a/API_REFERENCE.md b/API_REFERENCE.md deleted file mode 100644 index ef2d934b..00000000 --- a/API_REFERENCE.md +++ /dev/null @@ -1,1236 +0,0 @@ -# StarForge API Reference - -Complete reference for all StarForge commands, options, and utilities. - -> For a concise, navigable index of every CLI subcommand see [docs/COMMAND_REFERENCE.md](docs/COMMAND_REFERENCE.md). - -## Table of Contents - -1. [Command Line Interface](#command-line-interface) -2. [Wallet Commands](#wallet-commands) -3. [Template Commands](#template-commands) -4. [Contract Commands](#contract-commands) -5. [Network Commands](#network-commands) -6. [Transaction Commands](#transaction-commands) -7. [Utility Commands](#utility-commands) -8. [Configuration](#configuration) -9. [Exit Codes](#exit-codes) - ---- - -## Command Line Interface - -### Global Options - -```bash -starforge [OPTIONS] -``` - -| Option | Description | -|--------|-------------| -| `-q, --quiet` | Suppress ASCII banner and decorative output | -| `-h, --help` | Print help information | -| `-V, --version` | Print version information | - -### Environment Variables - -| Variable | Description | Default | -|----------|-------------|---------| -| `STARFORGE_CONFIG_DIR` | Configuration directory | `~/.starforge` | -| `STARFORGE_TELEMETRY` | Enable/disable telemetry | `true` | -| `RUST_LOG` | Logging level | `info` | - ---- - -## Wallet Commands - -### `starforge wallet create` - -Create a new Stellar keypair and save it locally. - -**Usage:** -```bash -starforge wallet create [OPTIONS] -``` - -**Arguments:** -- `` - Friendly name for the wallet (alphanumeric, dash, underscore) - -**Options:** -- `--fund` - Fund the wallet via Friendbot immediately (testnet only) -- `--network ` - Network to associate with wallet (`testnet`, `mainnet`) -- `--encrypt` - Encrypt the secret key with a passphrase - -**Examples:** -```bash -# Create basic wallet -starforge wallet create alice - -# Create and fund on testnet -starforge wallet create deployer --fund - -# Create with encryption -starforge wallet create secure-wallet --encrypt - -# Create on mainnet -starforge wallet create mainnet-wallet --network mainnet -``` - -**Output:** -``` -◆ Creating wallet 'alice' - -[1/2] Generating keypair… - -Public Key : GABC...XYZ -Secret Key : Stored in plaintext (not recommended for mainnet). - -[2/2] Saving to ~/.starforge/config.toml… - -✓ Wallet 'alice' created and saved! - -View it with: starforge wallet show alice -``` - ---- - -### `starforge wallet list` - -List all saved wallets. - -**Usage:** -```bash -starforge wallet list -``` - -**Output:** -``` -◆ Saved Wallets -───────────────────────────────────────────────────────────── - - 1. alice [funded] - Key : GABC...XYZ - Net : testnet - - 2. bob [unfunded] - Key : GDEF...ABC - Net : testnet - -───────────────────────────────────────────────────────────── -2 wallet(s) on testnet — ~/.starforge/config.toml -``` - ---- - -### `starforge wallet show` - -Show details of a saved wallet including live balance. - -**Usage:** -```bash -starforge wallet show [OPTIONS] -``` - -**Arguments:** -- `` - Wallet name - -**Options:** -- `--reveal` - Show the secret key in plaintext - -**Examples:** -```bash -# Show wallet details -starforge wallet show alice - -# Reveal secret key -starforge wallet show alice --reveal -``` - -**Output:** -``` -◆ Wallet: alice -───────────────────────────────────────────────────────────── - -Public Key : GABC...XYZ -Secret Key : ******************** (--reveal to show) -Network : testnet -Funded : yes -Created : 2025-01-01T00:00:00Z - -───────────────────────────────────────────────────────────── - -Fetching live balance on testnet… - -XLM : 10000.0000000 XLM -``` - ---- - -### `starforge wallet fund` - -Fund a wallet via Friendbot (testnet only). - -**Usage:** -```bash -starforge wallet fund -``` - -**Arguments:** -- `` - Wallet name to fund - -**Example:** -```bash -starforge wallet fund alice -``` - ---- - -### `starforge wallet remove` - -Remove a wallet from local storage. - -**Usage:** -```bash -starforge wallet remove -``` - -**Arguments:** -- `` - Wallet name to remove - -**Example:** -```bash -starforge wallet remove alice -``` - ---- - -### `starforge wallet rename` - -Rename a wallet. - -**Usage:** -```bash -starforge wallet rename -``` - -**Arguments:** -- `` - Current wallet name -- `` - New wallet name - -**Example:** -```bash -starforge wallet rename alice alice-testnet -``` - ---- - -### `starforge wallet export` - -Export a wallet to a JSON backup file. - -**Usage:** -```bash -starforge wallet export --output -``` - -**Arguments:** -- `` - Wallet name to export - -**Options:** -- `--output ` - Output file path for the backup JSON - -**Example:** -```bash -starforge wallet export alice --output ./wallet-backup.json -``` - -**Notes:** -- Secrets are written only to the backup file and are never printed to stdout. - ---- - -### `starforge wallet import` - -Import wallets from a JSON backup file. - -**Usage:** -```bash -starforge wallet import --file -``` - -**Options:** -- `--file ` - Path to a wallet backup JSON file - -**Example:** -```bash -starforge wallet import --file ./wallet-backup.json -``` - ---- - -### `starforge wallet sign` - -Sign an arbitrary message using a wallet. - -**Usage:** -```bash -starforge wallet sign [OPTIONS] -``` - -**Arguments:** -- `` - Wallet name to use for signing -- `` - Message to sign (UTF-8 string) - -**Options:** -- `--hardware ` - Use hardware wallet (`ledger`, `trezor`) - -**Examples:** -```bash -# Sign with local key -starforge wallet sign alice "Hello, Stellar!" - -# Sign with hardware wallet -starforge wallet sign alice "Transaction data" --hardware ledger -``` - ---- - -### `starforge wallet multisig` - -Multi-signature account management. - -#### `starforge wallet multisig create` - -Create a multi-sig configuration. - -**Usage:** -```bash -starforge wallet multisig create --threshold --signers -``` - -**Arguments:** -- `` - Multi-sig account name - -**Options:** -- `--threshold ` - Required signature weight -- `--signers ` - Comma-separated wallet names -- `--network ` - Network override - -**Example:** -```bash -starforge wallet multisig create treasury \ - --threshold 2 \ - --signers alice,bob,charlie -``` - -#### `starforge wallet multisig sign` - -Sign a multi-sig transaction. - -**Usage:** -```bash -starforge wallet multisig sign --transaction [OPTIONS] -``` - -**Arguments:** -- `` - Multi-sig account name - -**Options:** -- `--transaction ` - Path to transaction JSON -- `--output ` - Output file (defaults to in-place update) - -**Example:** -```bash -starforge wallet multisig sign treasury --transaction tx.json -``` - -#### `starforge wallet multisig list` - -List multi-sig accounts. - -**Usage:** -```bash -starforge wallet multisig list -``` - -#### `starforge wallet multisig show` - -Show multi-sig account details. - -**Usage:** -```bash -starforge wallet multisig show -``` - -#### `starforge wallet multisig submit` - -Submit a fully-signed multi-sig transaction. - -**Usage:** -```bash -starforge wallet multisig submit --transaction [OPTIONS] -``` - -**Options:** -- `--transaction ` - Path to signed transaction JSON -- `--network ` - Network to submit on - ---- - -## Template Commands - -### `starforge template init` - -Initialize template registry with example templates. - -**Usage:** -```bash -starforge template init -``` - -**Output:** -``` -◆ Initialize Template Registry - -Adding example templates to the marketplace... - -✓ Added: uniswap-v2 -✓ Added: lending-pool -✓ Added: governance -✓ Added: multisig-wallet - -✓ Template registry initialized with 4 example templates - -Browse templates: - starforge template list - starforge template search defi -``` - ---- - -### `starforge template search` - -Search for templates in the marketplace. - -**Usage:** -```bash -starforge template search [OPTIONS] -``` - -**Arguments:** -- `` - Search query (matches name, description, tags) - -**Options:** -- `--tags ` - Filter by tags (comma-separated) - -**Examples:** -```bash -# Search by keyword -starforge template search defi - -# Search with tag filter -starforge template search dex --tags amm,swap - -# Search for governance -starforge template search governance -``` - -**Output:** -``` -◆ Template Marketplace — Search -Query : defi -───────────────────────────────────────────────────────────── - -Found 2 template(s): - -1. uniswap-v2 ✓ - Uniswap V2 style automated market maker (AMM) DEX implementation - 1.0.0 • Stellar Community • 42 downloads - Tags: defi, dex, amm, swap - -2. lending-pool ✓ - Decentralized lending and borrowing protocol - 1.0.0 • Stellar Community • 28 downloads - Tags: defi, lending, borrowing - -───────────────────────────────────────────────────────────── - -Use a template: - starforge new contract my-project --template uniswap-v2 --from marketplace -``` - ---- - -### `starforge template list` - -List all available templates. - -**Usage:** -```bash -starforge template list -``` - ---- - -### `starforge template show` - -Show details of a specific template. - -**Usage:** -```bash -starforge template show -``` - -**Arguments:** -- `` - Template name - -**Example:** -```bash -starforge template show uniswap-v2 -``` - -**Output:** -``` -◆ Template: uniswap-v2 -───────────────────────────────────────────────────────────── - -uniswap-v2 ✓ - -Description : Uniswap V2 style automated market maker (AMM) DEX -Version : 1.0.0 -Author : Stellar Community -Downloads : 42 -Tags : defi, dex, amm, swap - -Created : 2025-01-01T00:00:00Z -Updated : 2025-01-15T00:00:00Z - -Source : Git Repository -URL : https://github.com/stellar/soroban-examples -Branch : main - -───────────────────────────────────────────────────────────── - -Use this template: - starforge new contract my-project --template uniswap-v2 --from marketplace -``` - ---- - -### `starforge template publish` - -Publish a template to the local marketplace. - -**Usage:** -```bash -starforge template publish [OPTIONS] -``` - -**Arguments:** -- `` - Path to template directory - -**Options:** -- `--name ` - Template name -- `--description ` - Template description -- `--author ` - Author name -- `--tags ` - Comma-separated tags -- `--version ` - Version (default: 1.0.0) - -**Examples:** -```bash -# Publish with all options -starforge template publish ./my-template \ - --name my-awesome-template \ - --description "An awesome contract" \ - --author "Your Name" \ - --tags "defi,custom" \ - --version "1.0.0" - -# Interactive publish (prompts for missing info) -starforge template publish ./my-template -``` - ---- - -### `starforge template remove` - -Remove a template from the local marketplace. - -**Usage:** -```bash -starforge template remove -``` - -**Arguments:** -- `` - Template name to remove - -**Example:** -```bash -starforge template remove my-template -``` - ---- - -## Contract Commands - -### `starforge new contract` - -Scaffold a new Soroban smart contract project. - -**Usage:** -```bash -starforge new contract [OPTIONS] -``` - -**Arguments:** -- `` - Project name - -**Options:** -- `--template