Skip to content

Commit 80af423

Browse files
Spec 21 (#92)
# Torus Network v0.5 Changelog This release introduces major architectural changes to enable decentralized economic relationships, improved governance flexibility, and preparation for off-chain service integration. The changes span several months of development focused on creating a more sophisticated and scalable network. ## Major Features ### Permission System (permission0 pallet) A comprehensive permission framework that revolutionizes how agents interact economically within the network: - Agents can now share their token emissions with contributors through recursive permission trees. Supports percentage-based streams or fixed amounts, with flexible distribution controls (manual, automatic threshold, scheduled). - Permissions can be managed by arbiters (multi-sig groups) for enhanced security and decentralized control. - Governance powers are now granular with specific permissions for application review, whitelist management, and penalty control. Replaces the old curator system with a more flexible approach. - Built-in protections against double-spending and infinite recursion ensure tokenomics. ### Namespace System A hierarchical naming system that functions as decentralized DNS/capability listing for agent services: - Agents can create dot-separated paths like `agent.alice.api.v2` to organize their off-chain services. - Owning a namespace gives control over all sub-paths, enabling structured delegation of services. - Base fees go to treasury while refundable deposits incentivize efficient storage use. - Namespaces can be delegated through the permission system, enabling complex service architectures. ### Agent Management Improvements - Agent names are automatically converted to namespace-compliant format (lowercase, no spaces) during the upgrade. - Curators can now freeze/unfreeze agents, adding a new governance tool for spam control. - Agent metadata updates now have cooldowns to prevent spam and ensure stability. - Burn parameters adjusted for better economic balance during high registration activity. ### Economic Enhancements - All transaction fees now flow to the treasury instead of being burned, providing sustainable funding for network development. - Only whitelisted agents receive emissions, ensuring quality participants chosen by the DAO are rewarded. - Permission holders can dynamically adjust how they distribute received emissions. - Distribution remainders are now properly accumulated, preventing token loss. ### Developer Experience - Proof-of-work based faucet for obtaining testnet tokens, preventing abuse while maintaining accessibility. - Comprehensive docs for all pallets now auto-published to GitHub Pages. - New `torus0_namespacePathCreationCost` RPC for calculating namespace fees upfront. - Integrated coverage reporting with `cargo xtask coverage` for maintaining code quality. ## Bug Fixes & Safety Improvements - Critical fix ensuring stakes are properly refunded before clearing storage during de-registration. - Banned arithmetic side effects throughout the runtime, using saturating operations to prevent overflows. - All agents now automatically delegate weights to allocators, simplifying the onboarding process. ## Governance Changes - Instead of all-or-nothing curator status, specific permissions can be granted. - Improved with better event emissions and clearer execution flows. - Now integrated with the permission system for more flexible control. ## Infrastructure - Enhanced GitHub Actions for automated testing, documentation, and Docker builds. - Added development container configuration for consistent environments. - Migrated CI infrastructure for better performance. This release represents a fundamental evolution of the Torus Network, creating the foundation for a truly decentralized economy where agents can form complex relationships, share resources, and organize their services in meaningful ways. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary by CodeRabbit * **New Features** * Introduced a comprehensive permission system enabling emission, curator, and namespace permissions with fine-grained control, revocation, and enforcement. * Added namespace management: users can create and delete hierarchical namespaces with associated economic and permission models. * Added a testnet-only faucet feature allowing users to obtain test tokens via proof-of-work. * Expanded governance with freezing controls for agent/namespace registration and more granular role/permission management. * Added new RPC endpoints for permission and namespace queries. * Enhanced agent management with update cooldowns and namespace integration. * **Improvements** * Unified numeric types for emission calculations, improving precision and consistency. * Refined governance proposal lifecycle, voting, and reward distribution with improved type safety and fixed-point math. * Strengthened access controls and permission checks across emission, governance, and agent operations. * Improved documentation, developer guides, and user manuals for new features and workflows. * Expanded benchmarking and test coverage for new and existing modules. * **Bug Fixes** * Fixed edge cases in emission and permission logic, including overflow handling and delegation validation. * Addressed governance and agent update race conditions with improved cooldown and permission enforcement. * **Chores** * Updated dependencies, development environment, CI workflows, and added new workspace members for modularity. * Upgraded Nix flake and build tooling for improved developer experience. * **Documentation** * Added detailed docs covering permission system, namespaces, emission mechanics, governance structure, deployment, and developer tooling. * **Style/Refactor** * Refactored imports, code organization, and type usage for clarity and maintainability. * Removed deprecated benchmarking and test files, replacing them with updated implementations. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 parents 42172e0 + 7952818 commit 80af423

File tree

133 files changed

+16560
-4920
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+16560
-4920
lines changed

.devcontainer/devcontainer.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"image": "mcr.microsoft.com/devcontainers/universal:2",
3+
"features": {
4+
"ghcr.io/devcontainers/features/nix:1": {
5+
"flake": "github:nixos/nixpkgs/nixpkgs-unstable#direnv"
6+
}
7+
}
8+
}

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
* @supremesource @saiintbrisson @steinerkelvin @devwckd
1+
* @functor-flow @saiintbrisson @steinerkelvin @devwckd
22

33
/.github/workflows/* @steinerkelvin @daviptrs @saiintbrisson
44
/docker/**/* @steinerkelvin @daviptrs @saiintbrisson
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
name: Build and push Docker image
1+
name: Build Torus node Docker image
22

33
on:
44
push:
5-
branches: [main, testnet, github-ci-test]
5+
branches:
6+
- main
7+
- dev
8+
- testnet
9+
- github-ci-test
610
tags:
711
- "*"
812

@@ -13,9 +17,9 @@ concurrency:
1317
jobs:
1418
build-n-push:
1519
permissions: write-all
16-
runs-on: ubuntu-22.04-32core-karl
20+
runs-on: ubicloud-standard-16
1721
steps:
18-
- uses: actions/checkout@v3
22+
- uses: actions/checkout@v4
1923

2024
- id: commit
2125
uses: prompt/actions-commit-hash@v3
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Build xtask cli tool Docker image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
- github-ci-test
9+
paths:
10+
- "xtask/**"
11+
- ".github/workflows/build-docker-xtask.yml"
12+
- "docker/xtask.dockerfile"
13+
14+
jobs:
15+
docker:
16+
permissions:
17+
contents: read
18+
packages: write
19+
runs-on: ubicloud-standard-2
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Docker meta
24+
id: meta
25+
uses: docker/metadata-action@v5
26+
with:
27+
images: ghcr.io/${{ github.repository_owner }}/torus-xtask
28+
tags: |
29+
type=sha,prefix=,enable=true
30+
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
31+
32+
- name: Set up Docker Buildx
33+
uses: docker/setup-buildx-action@v3
34+
35+
- name: Login to GitHub Container Registry
36+
uses: docker/login-action@v3
37+
with:
38+
registry: ghcr.io
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Build and push
43+
uses: docker/build-push-action@v5
44+
with:
45+
context: .
46+
push: true
47+
file: ./docker/xtask.dockerfile
48+
tags: ${{ steps.meta.outputs.tags }}
49+
cache-from: type=gha
50+
cache-to: type=gha,mode=max

.github/workflows/build-docs.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Build docs and publish to github pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
publish:
10+
permissions:
11+
contents: read
12+
id-token: write
13+
pages: write
14+
runs-on: ubicloud-standard-2
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Setup Rust cache
19+
uses: Swatinem/rust-cache@v2
20+
21+
- name: Install Rust toolchain
22+
run: |
23+
rustup set profile minimal
24+
rustup show
25+
26+
- name: Install Protoc
27+
uses: arduino/setup-protoc@v1
28+
with:
29+
version: 3.20.1
30+
repo-token: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Generate Docs
33+
run: |
34+
cargo doc --workspace --no-deps
35+
36+
- name: Setup Pages
37+
uses: actions/configure-pages@v5
38+
39+
- name: Upload artifact
40+
uses: actions/upload-pages-artifact@v3
41+
with:
42+
path: 'target/doc/'
43+
44+
- name: Deploy to GitHub Pages
45+
id: deployment
46+
uses: actions/deploy-pages@v4
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
name: Build Torus Runtime
1+
name: Build Torus runtime
22

33
on:
44
workflow_dispatch:
55
push:
6-
tags:
7-
- "runtime/*"
86
branches:
97
- "github-ci-test"
108
- "build-runtime*"
119
- "testnet"
10+
tags:
11+
- "runtime/*"
1212

1313
concurrency:
1414
group: ${{ github.workflow }}-${{ github.ref }}
1515
cancel-in-progress: true
1616

1717
jobs:
1818
build:
19-
runs-on: ubuntu-22.04-32core-karl
19+
runs-on: ubicloud-standard-16
2020

2121
steps:
2222
- uses: actions/checkout@v4
@@ -37,7 +37,8 @@ jobs:
3737

3838
- name: Build runtime
3939
run: |
40-
cargo build --release --timings --package torus-runtime
40+
echo "Building ${{ startsWith(github.ref, 'refs/tags/runtime/testnet') && 'with testnet feature flag' || 'without testnet feature flag' }}"
41+
cargo build --release --timings --package torus-runtime ${{ startsWith(github.ref, 'refs/tags/runtime/testnet') && '--features testnet' || '' }}
4142
4243
export SHA256SUM=$(sha256sum target/release/wbuild/torus-runtime/torus_runtime.compact.compressed.wasm | cut -d ' ' -f1)
4344
echo Hash of compact and compressed WASM: $SHA256SUM

.github/workflows/check.yml

Lines changed: 88 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@ concurrency:
1111

1212
jobs:
1313
check:
14-
runs-on: ubuntu-24.04-8core-bakunin
14+
permissions:
15+
pull-requests: write
16+
id-token: write
17+
pages: write
18+
checks: write
19+
contents: write
20+
21+
runs-on: ubicloud-standard-8
1522

1623
steps:
1724
- uses: actions/checkout@v4
@@ -44,8 +51,86 @@ jobs:
4451
args: --color=always --tests -- -D warnings
4552
token: ${{ secrets.GITHUB_TOKEN }}
4653

47-
- name: Run tests
54+
# - name: Run tests
55+
# env:
56+
# RUST_BACKTRACE: 1
57+
# SKIP_WASM_BUILD: 1
58+
# run: cargo test
59+
60+
- uses: jwalton/gh-find-current-pr@v1
61+
id: findPr
62+
63+
- name: Extract branch name
64+
shell: bash
65+
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
66+
id: extractBranch
67+
68+
- name: Install cargo-llvm-cov
69+
if: success() && steps.findPr.outputs.number && steps.extractBranch.outputs.branch
70+
uses: taiki-e/install-action@cargo-llvm-cov
71+
72+
- name: Install cargo-xtask
73+
if: success() && steps.findPr.outputs.number && steps.extractBranch.outputs.branch
74+
run: cargo install cargo-xtask
75+
76+
- name: Generate lcov code coverage
77+
if: success() && steps.findPr.outputs.number && steps.extractBranch.outputs.branch
78+
run: cargo xtask coverage
4879
env:
4980
RUST_BACKTRACE: 1
5081
SKIP_WASM_BUILD: 1
51-
run: cargo test
82+
83+
- name: Generate coverage summary report
84+
if: success() && steps.findPr.outputs.number && steps.extractBranch.outputs.branch
85+
uses: irongut/[email protected]
86+
with:
87+
filename: target/cov.xml
88+
badge: true
89+
format: markdown
90+
hide_branch_rate: false
91+
hide_complexity: true
92+
indicators: true
93+
output: both
94+
95+
- name: Generate html code coverage
96+
if: success() && steps.findPr.outputs.number && steps.extractBranch.outputs.branch
97+
run: cargo xtask coverage --html
98+
env:
99+
RUST_BACKTRACE: 1
100+
SKIP_WASM_BUILD: 1
101+
102+
- name: Upload html report to S3 Bucket
103+
if: success() && steps.findPr.outputs.number && steps.extractBranch.outputs.branch
104+
id: htmlUpload
105+
continue-on-error: true
106+
run: |
107+
aws --endpoint-url $ENDPOINT s3 sync ./target/llvm-cov/html s3://$BUCKET_NAME/$BRANCH --acl public-read
108+
echo "link=https://$BUCKET_NAME.$REGION.$ENDPOINT_DOMAIN/$BRANCH/index.html" >> $GITHUB_OUTPUT
109+
env:
110+
BRANCH: ${{ steps.extractBranch.outputs.branch }}
111+
ENDPOINT: ${{ vars.COV_ENDPOINT_URL }}
112+
BUCKET_NAME: ${{ vars.COV_BUCKET_NAME }}
113+
AWS_ACCESS_KEY_ID: ${{ secrets.COV_AWS_ACCESS_KEY_ID }}
114+
AWS_SECRET_ACCESS_KEY: ${{ secrets.COV_AWS_SECRET_ACCESS_KEY }}
115+
AWS_DEFAULT_REGION: ${{ vars.COV_DEFAULT_REGION }}
116+
REGION: nyc3
117+
ENDPOINT_DOMAIN: "digitaloceanspaces.com"
118+
119+
- name: Add coverage PR report comment
120+
if: success() && steps.findPr.outputs.number
121+
uses: marocchino/sticky-pull-request-comment@v2
122+
with:
123+
header: report
124+
number: ${{ steps.findPr.outputs.pr }}
125+
recreate: true
126+
path: code-coverage-results.md
127+
128+
- name: Add coverage PR html comment
129+
if: success() && steps.findPr.outputs.number
130+
uses: marocchino/sticky-pull-request-comment@v2
131+
with:
132+
header: html
133+
number: ${{ steps.findPr.outputs.pr }}
134+
recreate: true
135+
message: |
136+
[Detailed coverage report](${{ steps.htmlUpload.outputs.link }})

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Local files
2+
*.local.*
3+
14
# Temporary files
25
/tmp/
36

.vscode/extensions.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"recommendations": [
33
"streetsidesoftware.code-spell-checker",
4-
"rust-lang.rust-analyzer"
4+
"rust-lang.rust-analyzer",
5+
"ryanluker.vscode-coverage-gutters"
56
]
6-
}
7+
}

.vscode/settings.json

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,25 @@
22
// Editor
33
"editor.formatOnSave": true,
44
// Rust
5-
"rust-analyzer.cargo.extraEnv": { "SKIP_WASM_BUILD": "1" },
6-
"rust-analyzer.check.extraEnv": { "SKIP_WASM_BUILD": "1" },
7-
"rust-analyzer.cargo.features": ["runtime-benchmarks"]
5+
"rust-analyzer.cargo.extraEnv": {
6+
"SKIP_WASM_BUILD": "1"
7+
},
8+
"rust-analyzer.check.extraEnv": {
9+
"SKIP_WASM_BUILD": "1"
10+
},
11+
"rust-analyzer.cargo.features": ["runtime-benchmarks", "testnet"],
12+
"coverage-gutters.coverageFileNames": ["target/cov.xml"],
13+
// Spell checker
14+
"cSpell.words": [
15+
"alice",
16+
"buildx",
17+
"devcontainers",
18+
"extrinsics",
19+
"irongut",
20+
"jwalton",
21+
"mainnet",
22+
"presign",
23+
"Swatinem",
24+
"wbuild"
25+
]
826
}

0 commit comments

Comments
 (0)