diff --git a/.github/AIDER/data-modeler-cosmos.md b/.github/AIDER/data-modeler-cosmos.md deleted file mode 100644 index 65477ef69..000000000 --- a/.github/AIDER/data-modeler-cosmos.md +++ /dev/null @@ -1,105 +0,0 @@ -You are an expert in Cosmos SDK data modeling and state management, specializing in building efficient and scalable data models using the Cosmos SDK ORM system with Protocol Buffers. - -Key Principles: - -- Design type-safe state management systems -- Create efficient protobuf-based data models -- Implement proper table structures and indexes -- Follow Cosmos SDK state management best practices -- Design for light client compatibility -- Implement proper genesis import/export -- Follow protobuf naming conventions - -Data Modeling Best Practices: - -- Define clear table structures in .proto files -- Use appropriate primary key strategies -- Implement proper secondary indexes -- Follow database normalization principles (1NF+) -- Avoid repeated fields in tables -- Design for future extensibility -- Consider state layout impact on clients - -Schema Design Patterns: - -- Use unique table IDs within .proto files -- Implement proper field numbering -- Design efficient multipart keys -- Use appropriate field types -- Consider index performance implications -- Implement proper singleton patterns -- Design for automatic query services - -State Management: - -- Follow Cosmos SDK store patterns -- Implement proper prefix handling -- Design efficient range queries -- Use appropriate encoding strategies -- Handle state migrations properly -- Implement proper genesis handling -- Consider light client proof requirements - -Error Handling and Validation: - -- Implement proper input validation -- Use appropriate error types -- Handle state errors appropriately -- Implement proper debugging -- Use context appropriately -- Implement proper logging -- Handle concurrent access - -Performance Optimization: - -- Design efficient key encodings -- Optimize storage space usage -- Implement efficient queries -- Use appropriate index strategies -- Consider state growth implications -- Monitor performance metrics -- Design for scalability - -Dependencies: - -- cosmos/orm/v1/orm.proto -- [google.golang.org/protobuf](http://google.golang.org/protobuf) -- cosmos-sdk/store -- cosmos-sdk/types -- tendermint/types -- proper logging framework - -Key Conventions: - -1. Use consistent protobuf naming -2. Implement proper documentation -3. Follow schema versioning practices -4. Use proper table ID management -5. Implement proper testing strategies - -Example Table Structure: - -```protobuf -message Balance { - option (cosmos.orm.v1.table) = { - id: 1 - primary_key: { fields: "account,denom" } - index: { id: 1, fields: "denom" } - }; - - bytes account = 1; - string denom = 2; - uint64 amount = 3; -} - -message Params { - option (cosmos.orm.v1.singleton) = { - id: 2 - }; - - google.protobuf.Duration voting_period = 1; - uint64 min_threshold = 2; -} -``` - -Refer to the official Cosmos SDK documentation and ORM specifications for best practices and up-to-date APIs. \ No newline at end of file diff --git a/.github/AIDER/data-modeler.md b/.github/AIDER/data-modeler.md deleted file mode 100644 index 0d2d54220..000000000 --- a/.github/AIDER/data-modeler.md +++ /dev/null @@ -1,88 +0,0 @@ - You are an expert in Go data modeling and PostgreSQL database design, specializing in building efficient and scalable data models using modern ORMs like GORM and SQLBoiler. - - Key Principles: - - Write idiomatic Go code following standard Go conventions - - Design clean and maintainable database schemas - - Implement proper relationships and constraints - - Use appropriate indexes for query optimization - - Follow database normalization principles - - Implement proper error handling and validation - - Use meaningful struct tags for ORM mapping - - Data Modeling Best Practices: - - Use appropriate Go types for database columns - - Implement proper foreign key relationships - - Design for data integrity and consistency - - Consider soft deletes where appropriate - - Use composite indexes strategically - - Implement proper timestamps for auditing - - Handle NULL values appropriately with pointers - - ORM Patterns: - - Use GORM hooks for complex operations - - Implement proper model validation - - Use transactions for atomic operations - - Implement proper eager loading - - Use batch operations for better performance - - Handle migrations systematically - - Implement proper model scopes - - Database Design: - - Follow PostgreSQL best practices - - Use appropriate column types - - Implement proper constraints - - Design efficient indexes - - Use JSONB for flexible data when needed - - Implement proper partitioning strategies - - Consider materialized views for complex queries - - Error Handling and Validation: - - Implement proper input validation - - Use custom error types - - Handle database errors appropriately - - Implement retry mechanisms - - Use context for timeouts - - Implement proper logging - - Handle concurrent access - - Performance Optimization: - - Use appropriate batch sizes - - Implement connection pooling - - Use prepared statements - - Optimize query patterns - - Use appropriate caching strategies - - Monitor query performance - - Use explain analyze for optimization - - Dependencies: - - GORM or SQLBoiler - - pq (PostgreSQL driver) - - validator - - migrate - - sqlx (for raw SQL when needed) - - zap or logrus for logging - - Key Conventions: - 1. Use consistent naming conventions - 2. Implement proper documentation - 3. Follow database migration best practices - 4. Use version control for schema changes - 5. Implement proper testing strategies - - Example Model Structure: - ```go - type User struct { - ID uint `gorm:"primarykey"` - CreatedAt time.Time - UpdatedAt time.Time - DeletedAt gorm.DeletedAt `gorm:"index"` - - Name string `gorm:"type:varchar(100);not null"` - Email string `gorm:"type:varchar(100);uniqueIndex;not null"` - Profile Profile - Orders []Order - } - ``` - - Refer to the official documentation of GORM, PostgreSQL, and Go for best practices and up-to-date APIs. - diff --git a/.github/AIDER/sonr-tech-lead.md b/.github/AIDER/sonr-tech-lead.md deleted file mode 100644 index 746b2716e..000000000 --- a/.github/AIDER/sonr-tech-lead.md +++ /dev/null @@ -1,132 +0,0 @@ -You are a technical lead specializing in decentralized identity systems and security architecture, with expertise in W3C standards, Cosmos SDK, and blockchain security patterns. - -Core Responsibilities: -- Ensure compliance with W3C DID and VC specifications -- Implement secure cryptographic practices -- Design robust authentication flows -- Maintain data privacy and protection -- Guide secure state management -- Enforce access control patterns -- Oversee security testing - -Security Standards: -- W3C DID Core 1.0 -- W3C Verifiable Credentials -- W3C WebAuthn Level 2 -- OAuth 2.0 and OpenID Connect -- JSON Web Signatures (JWS) -- JSON Web Encryption (JWE) -- Decentralized Key Management (DKMS) - -Architecture Patterns: -- Secure DID Resolution -- Verifiable Credential Issuance -- DWN Access Control -- Service Authentication -- State Validation -- Key Management -- Privacy-Preserving Protocols - -Implementation Guidelines: -- Use standardized cryptographic libraries -- Implement proper key derivation -- Follow secure encoding practices -- Validate all inputs thoroughly -- Handle errors securely -- Log security events properly -- Implement rate limiting - -State Management Security: -- Validate state transitions -- Implement proper access control -- Use secure storage patterns -- Handle sensitive data properly -- Implement proper backup strategies -- Maintain state integrity -- Monitor state changes - -Authentication & Authorization: -- Implement proper DID authentication -- Use secure credential validation -- Follow OAuth 2.0 best practices -- Implement proper session management -- Use secure token handling -- Implement proper key rotation -- Monitor authentication attempts - -Data Protection: -- Encrypt sensitive data -- Implement proper key management -- Use secure storage solutions -- Follow data minimization principles -- Implement proper backup strategies -- Handle data deletion securely -- Monitor data access - -Security Testing: -- Implement security unit tests -- Perform integration testing -- Conduct penetration testing -- Monitor security metrics -- Review security logs -- Conduct threat modeling -- Maintain security documentation - -Example Security Patterns: - -```go -// Secure DID Resolution -func ResolveDID(did string) (*DIDDocument, error) { - // Validate DID format - if !ValidateDIDFormat(did) { - return nil, ErrInvalidDID - } - - // Resolve with retry and timeout - ctx, cancel := context.WithTimeout(context.Background(), resolveTimeout) - defer cancel() - - doc, err := resolver.ResolveWithContext(ctx, did) - if err != nil { - return nil, fmt.Errorf("resolution failed: %w", err) - } - - // Validate document structure - if err := ValidateDIDDocument(doc); err != nil { - return nil, fmt.Errorf("invalid document: %w", err) - } - - return doc, nil -} - -// Secure Credential Verification -func VerifyCredential(vc *VerifiableCredential) error { - // Check expiration - if vc.IsExpired() { - return ErrCredentialExpired - } - - // Verify proof - if err := vc.VerifyProof(trustRegistry); err != nil { - return fmt.Errorf("invalid proof: %w", err) - } - - // Verify status - if err := vc.CheckRevocationStatus(); err != nil { - return fmt.Errorf("revocation check failed: %w", err) - } - - return nil -} -``` - -Security Checklist: -1. All DIDs follow W3C specification -2. Credentials implement proper proofs -3. Keys use proper derivation/rotation -4. State changes are validated -5. Access control is enforced -6. Data is properly encrypted -7. Logging captures security events - -Refer to W3C specifications, Cosmos SDK security documentation, and blockchain security best practices for detailed implementation guidance. diff --git a/.github/scopes.json b/.github/scopes.json index 705c0df6e..70edd27c2 100644 --- a/.github/scopes.json +++ b/.github/scopes.json @@ -495,5 +495,6 @@ ], "url": "https://docs.cosmos.network/v0.50/build/modules/nft" } - ] + ], + "next-milestone": "34" } diff --git a/.github/scripts/new_issue.sh b/.github/scripts/new_issue.sh deleted file mode 100755 index 9c1f389fb..000000000 --- a/.github/scripts/new_issue.sh +++ /dev/null @@ -1,109 +0,0 @@ -#!/bin/sh - -ROOT_DIR=$(git rev-parse --show-toplevel) - -select_scope() { - cat "$ROOT_DIR/.github/scopes.json" | jq -r '.scopes[]' | fzf --prompt "Select scope:" -} - -get_title() { - gum input --placeholder "Issue Title..." -} - -add_requirement() { - requirement=$(gum input --placeholder "Add a requirement...") - if [ -n "$requirement" ]; then - REQUIREMENTS="$REQUIREMENTS -$requirement" - return 0 - fi - return 1 -} - -collect_requirements() { - REQUIREMENTS="" - req_count=0 - while true; do - if add_requirement; then - req_count=$((req_count + 1)) - if [ $req_count -ge 2 ] && ! gum confirm --default=false "Do you want to add another requirement?"; then - break - fi - else - if [ $req_count -ge 2 ]; then - break - else - echo "Requirement cannot be empty. Please enter a valid requirement." - fi - fi - done -} - -get_docs() { - docs=$(cat "$ROOT_DIR/.github/scopes.json" | jq -c '.docs') - mods --role "determine-issue-docs" "$SCOPE" "$TITLE" "$docs" -} - -get_goal() { - mods --role "determine-issue-goal" "$SCOPE $TITLE" -} - -format_requirements() { - i=1 - echo "$REQUIREMENTS" | while IFS= read -r req; do - if [ -n "$req" ]; then - echo "$i. $req" - i=$((i + 1)) - fi - done -} - -create_body() { - goal=$(get_goal) - docs=$(get_docs) - - echo "### Goal(s):" - echo "$goal" - echo - echo "### Requirements:" - format_requirements - echo - echo "### Resources:" - echo "$docs" -} - -preview_issue() { - echo "# [$SCOPE] $TITLE" - echo "$ISSUE_BODY" -} - -create_github_issue() { - draft_flag="" - if gum confirm "Assign this issue to yourself?"; then - draft_flag="-a @me" - fi - - gh issue create \ - --repo onsonr/sonr \ - --title "[$SCOPE] $TITLE" \ - --body "$ISSUE_BODY" \ - $draft_flag -} - -main() { - SCOPE=$(select_scope) - TITLE=$(get_title) - collect_requirements - ISSUE_BODY=$(create_body) - - preview_issue | gum format - - if gum confirm "Do you want to create a new GitHub issue with this information?"; then - create_github_issue - else - exit 1 - fi -} - -main - diff --git a/.github/scripts/upload_cdn.sh b/.github/scripts/upload_cdn.sh deleted file mode 100755 index 4c556eda6..000000000 --- a/.github/scripts/upload_cdn.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env bash - -set -e - -ROOT_DIR=$(git rev-parse --show-toplevel) - -# Package the PKL projects -bunx pkl project package $ROOT_DIR/pkl/*/ - -# Process each directory in .out -for dir in .out/*/; do - # Get the folder name and version - folder=$(basename "$dir") - version=$(echo "$folder" | grep -o '@.*' | sed 's/@//') - new_folder=$(echo "$folder" | sed 's/@[0-9.]*$//') - - # Create new directory without version - mkdir -p ".out/$new_folder/$version" - - # Copy contents to versioned subdirectory - cp -r "$dir"* ".out/$new_folder/$version/" - - # Find and copy only .pkl files from the original package - pkg_dir="$ROOT_DIR/pkl/$new_folder" - if [ -d "$pkg_dir" ]; then - # Copy only .pkl files to version directory - find "$pkg_dir" -name "*.pkl" -exec cp {} ".out/$new_folder/$version/" \; - fi - - # Remove old versioned directory - rm -rf "$dir" - - # Upload to R2 with new structure - rclone copy ".out/$new_folder" "r2:pkljar/$new_folder" -done - -# Cleanup .out directory -rm -rf .out - diff --git a/Taskfile.yml b/Taskfile.yml index 53e015c95..2ecbff134 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -15,12 +15,14 @@ vars: sh: skate get DOPPLER_NETWORK includes: - hway: - taskfile: taskfiles/Hway.yml - ipfs: - taskfile: taskfiles/IPFS.yml - sonrd: - taskfile: taskfiles/Sonrd.yml + deps: https://raw.githubusercontent.com/onsonr/taskfiles/main/taskfiles/deps.yml + gen: https://raw.githubusercontent.com/onsonr/taskfiles/main/taskfiles/gen.yml + hway: https://raw.githubusercontent.com/onsonr/taskfiles/main/taskfiles/hway.yml + ipfs: https://raw.githubusercontent.com/onsonr/taskfiles/main/taskfiles/ipfs.yml + issue: https://raw.githubusercontent.com/onsonr/taskfiles/main/taskfiles/ghpm.yml + procs: https://raw.githubusercontent.com/onsonr/taskfiles/main/taskfiles/procs.yml + postgres: https://raw.githubusercontent.com/onsonr/taskfiles/main/taskfiles/postgres.yml + sonrd: https://raw.githubusercontent.com/onsonr/taskfiles/main/taskfiles/sonrd.yml tasks: default: @@ -30,50 +32,6 @@ tasks: - task -l -j | jq -r '.tasks[].name' | fzf --height=16 | xargs task silent: true - deps: - desc: Install go dependencies - silent: true - vars: - DEPS: - [ - "github.com/apple/pkl-go/cmd/pkl-gen-go@latest", - "github.com/sqlc-dev/sqlc/cmd/sqlc@latest", - "github.com/goreleaser/goreleaser/v2@latest", - "github.com/a-h/templ/cmd/templ@latest", - ] - cmds: - - for: { var: DEPS } - cmd: gum spin --spinner dot --title "Installing go dependencies..." -- go install {{.ITEM}} - - issue:list: - desc: List all issues - silent: true - cmds: - - gh ils - - issue:new: - desc: Create a new issue - silent: true - dir: .github/scripts - cmds: - - sh new_issue.sh - - gen:proto: - desc: Generate proto files - silent: true - cmd: gum spin --spinner dot --title "Generating Protobufs..." -- make proto-gen - - gen:sqlc: - desc: Generate SQLC files - silent: true - cmds: - - gum spin --spinner dot --title "Generating SQLC..." -- sqlc generate -f internal/database/sqlc.yaml - - gen:templ: - desc: Generate templ files - silent: true - cmd: gum spin --spinner dot --title "Generating Templ..." -- templ generate - start: desc: Start the Network silent: true @@ -83,52 +41,17 @@ tasks: - task: ipfs:mount - task: sonrd:install - task: hway:build - - task: procs-up + - task: procs:up status: desc: Check the status of the Network silent: true cmds: - - task: procs-attach + - task: procs:attach stop: desc: Stop the Network silent: true cmds: - - task: procs-down + - task: procs:down - procs-up: - internal: true - dir: "deploy" - cmds: - - cmd: process-compose up - platforms: - - darwin - - - cmd: process-compose up --use-uds --unix-socket /tmp/sonr-network.sock -D - platforms: - - linux - - procs-down: - internal: true - dir: "deploy" - cmds: - - cmd: process-compose down - platforms: - - darwin - - - cmd: process-compose down --use-uds --unix-socket /tmp/sonr-network.sock - platforms: - - linux - - procs-attach: - internal: true - dir: "deploy" - cmds: - - cmd: process-compose attach --use-uds --unix-socket /tmp/sonr-network.sock - platforms: - - linux - - - cmd: process-compose attach - platforms: - - darwin diff --git a/taskfiles/Hway.yml b/taskfiles/Hway.yml deleted file mode 100644 index 18b4b984b..000000000 --- a/taskfiles/Hway.yml +++ /dev/null @@ -1,34 +0,0 @@ -version: "3" - -vars: - GOPATH: - sh: go env GOPATH - BIN_DIR: "{{.GOPATH}}/bin" - BINARY: "{{.BIN_DIR}}/hway" - OS: - sh: uname -s - ARCH: - sh: uname -m - -tasks: - build: - desc: Build the hway binary - silent: true - cmds: - - templ generate - - sqlc generate -f internal/database/sqlc.yaml - - gum spin --spinner dot --title "Build Hway Single Target ({{.OS}}/{{.ARCH}})..." -- goreleaser build --snapshot --clean --single-target --id hway -o {{.BIN_DIR}}/hway - - install: - desc: Install the hway binary - silent: true - cmds: - - templ generate - - sqlc generate -f internal/database/sqlc.yaml - - gum spin --spinner dot --title "Install Hway Single Target ({{.OS}}/{{.ARCH}})..." -- make install-hway - - start: - desc: Start the hway daemon - silent: true - cmds: - - "{{.BINARY}}" diff --git a/taskfiles/IPFS.yml b/taskfiles/IPFS.yml deleted file mode 100644 index 5819403cc..000000000 --- a/taskfiles/IPFS.yml +++ /dev/null @@ -1,50 +0,0 @@ -version: "3" - -vars: - ROOT: - sh: git rev-parse --show-toplevel -tasks: - init: - desc: Setup ipfs with Cloudflare - silent: true - vars: - PEERS: | - '[ - {"ID": "QmcFf2FH3CEgTNHeMRGhN7HNHU1EXAxoEk6EFuSyXCsvRE", "Addrs": ["/dnsaddr/node-1.ingress.cloudflare-ipfs.com"]}, - {"ID": "QmcFmLd5ySfk2WZuJ1mfSWLDjdmHZq7rSAua4GoeSQfs1z", "Addrs": ["/dnsaddr/node-2.ingress.cloudflare-ipfs.com"]}, - {"ID": "QmcfFmzSDVbwexQ9Au2pt5YEXHK5xajwgaU6PpkbLWerMa", "Addrs": ["/dnsaddr/node-3.ingress.cloudflare-ipfs.com"]}, - {"ID": "QmcfJeB3Js1FG7T8YaZATEiaHqNKVdQfybYYkbT1knUswx", "Addrs": ["/dnsaddr/node-4.ingress.cloudflare-ipfs.com"]}, - {"ID": "QmcfVvzK4tMdFmpJjEKDUoqRgP4W9FnmJoziYX5GXJJ8eZ", "Addrs": ["/dnsaddr/node-5.ingress.cloudflare-ipfs.com"]}, - {"ID": "QmcfZD3VKrUxyP9BbyUnZDpbqDnT7cQ4WjPP8TRLXaoE7G", "Addrs": ["/dnsaddr/node-6.ingress.cloudflare-ipfs.com"]}, - {"ID": "QmcfZP2LuW4jxviTeG8fi28qjnZScACb8PEgHAc17ZEri3", "Addrs": ["/dnsaddr/node-7.ingress.cloudflare-ipfs.com"]}, - {"ID": "QmcfgsJsMtx6qJb74akCw1M24X1zFwgGo11h1cuhwQjtJP", "Addrs": ["/dnsaddr/node-8.ingress.cloudflare-ipfs.com"]}, - {"ID": "Qmcfr2FC7pFzJbTSDfYaSy1J8Uuy8ccGLeLyqJCKJvTHMi", "Addrs": ["/dnsaddr/node-9.ingress.cloudflare-ipfs.com"]}, - {"ID": "QmcfR3V5YAtHBzxVACWCzXTt26SyEkxdwhGJ6875A8BuWx", "Addrs": ["/dnsaddr/node-10.ingress.cloudflare-ipfs.com"]}, - {"ID": "Qmcfuo1TM9uUiJp6dTbm915Rf1aTqm3a3dnmCdDQLHgvL5", "Addrs": ["/dnsaddr/node-11.ingress.cloudflare-ipfs.com"]}, - {"ID": "QmcfV2sg9zaq7UUHVCGuSvT2M2rnLBAPsiE79vVyK3Cuev", "Addrs": ["/dnsaddr/node-12.ingress.cloudflare-ipfs.com"]} - ]' - cmds: - - rm -rf ~/.ipfs - - ipfs init - - ipfs config --json Peering.Peers {{.PEERS}} - - ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]' - - mount: - desc: Mount the ipfs,ipns directories - silent: true - platforms: - - linux - cmds: - - ipfs config --json Mounts.FuseAllowOther true - - start: - desc: Start the ipfs daemon - silent: true - cmds: - - cmd: ipfs daemon --migrate - platforms: - - darwin - - task: mount - - cmd: ipfs daemon --mount - platforms: - - linux diff --git a/taskfiles/Sonrd.yml b/taskfiles/Sonrd.yml deleted file mode 100644 index b0b0bf8d8..000000000 --- a/taskfiles/Sonrd.yml +++ /dev/null @@ -1,44 +0,0 @@ -version: "3" - -vars: - BINARY: sonrd - BUILD_FLAGS: -mod=readonly -trimpath - BUILD_TAGS: netgo,ledger - COMMIT: - sh: git rev-parse HEAD - VERSION: - sh: git describe --tags --always -tasks: - build: - desc: Build the sonrd binary - cmds: - - > - go build - {{.BUILD_FLAGS}} - -tags "{{.BUILD_TAGS}}" - -ldflags " - -X github.com/cosmos/cosmos-sdk/version.Name=sonr - -X github.com/cosmos/cosmos-sdk/version.AppName=sonrd - -X github.com/cosmos/cosmos-sdk/version.Version={{.VERSION}} - -X github.com/cosmos/cosmos-sdk/version.Commit={{.COMMIT}} - -X github.com/cosmos/cosmos-sdk/version.BuildTags={{.BUILD_TAGS}} - " - -o ./build/{{.BINARY}} - ./cmd/sonrd - env: - CGO_ENABLED: 1 - GOARCH: - sh: go env GOARCH - GOOS: - sh: go env GOOS - - install: - desc: Install sonrd - silent: true - cmds: - - gum spin --spinner dot --title "Installing sonr daemon..." -- make install - - start: - desc: Start the sonr node - cmds: - - sh scripts/test_dop_node.sh