Skip to content

Commit 832647d

Browse files
saiintbrissondevwckdsteinerkelvin
authored
Syncing dev to main (#131)
Check all the changes in CHANGELOG.md, entries 22 and 23. --------- Co-authored-by: João Victor <[email protected]> Co-authored-by: Kelvin Steiner <[email protected]>
1 parent a130c1b commit 832647d

File tree

114 files changed

+13457
-1669
lines changed

Some content is hidden

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

114 files changed

+13457
-1669
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
/docker/volumes/
1616

1717
# Rust
18-
/target/
18+
**/target/
1919

2020
# Git Hooks
2121
.pre-commit-config.yaml
22+
23+
rust-project.json

.vscode/settings.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,27 @@
88
"rust-analyzer.check.extraEnv": {
99
"SKIP_WASM_BUILD": "1"
1010
},
11-
"rust-analyzer.cargo.features": ["runtime-benchmarks", "testnet"],
11+
// "rust-analyzer.cargo.features": ["runtime-benchmarks", "testnet"],
12+
"rust-analyzer.check.overrideCommand": [
13+
"cargo",
14+
"check",
15+
"--message-format=json"
16+
],
1217
"coverage-gutters.coverageFileNames": ["target/cov.xml"],
1318
// Spell checker
1419
"cSpell.words": [
1520
"alice",
1621
"buildx",
22+
"codegen",
1723
"devcontainers",
1824
"extrinsics",
1925
"irongut",
2026
"jwalton",
2127
"mainnet",
28+
"nocapture",
2229
"presign",
30+
"println",
31+
"subxt",
2332
"Swatinem",
2433
"wbuild"
2534
]

.zed/settings.json

Whitespace-only changes.

CHANGELOG.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,132 @@
11
# Changelog
22

3+
## Spec 23
4+
5+
This release builds upon the permission delegation system with enhanced re-delegation capabilities, enabling more sophisticated hierarchical permission structures for curators and namespace management.
6+
7+
### Major Features
8+
9+
#### Curator Re-delegation
10+
11+
Curators can now re-delegate their permissions to other agents, creating a hierarchical permission structure:
12+
13+
- The implementation tracks parent-child relationships between permissions and enforces inheritance rules where child permissions cannot exceed parent permission scopes.
14+
- Enables more flexible governance structures where curators can delegate specific subsets of their permissions to trusted agents, creating delegation chains.
15+
- Particularly useful for scaling curator operations and distributing workload while maintaining accountability through the permission hierarchy.
16+
- Existing curator permissions are automatically migrated to the new structure with their flags mapped to a single entry with no parent permission ID.
17+
18+
#### Namespace Re-delegation
19+
20+
Added support for namespace permission re-delegation with depth limiting:
21+
22+
- Agents can now delegate namespace permissions they've received to other agents, creating delegation chains up to 5 levels deep.
23+
- The system validates that child namespace paths exist and are properly owned before allowing delegation.
24+
- Allows namespace owners to create more complex delegation structures for namespace management.
25+
- Organizations can delegate namespace control to team leads who can further delegate to team members, enabling hierarchical namespace administration.
26+
- No migration needed for existing namespace permissions as they remain compatible with the new system.
27+
28+
#### Permission Instance Tracking
29+
30+
All permission types now support instance tracking through the instances parameter:
31+
32+
- Allows delegators to specify how many times a permission can be used concurrently, providing better control over permission usage.
33+
- Prevents permission abuse by limiting concurrent usage and provides better resource management for delegated operations.
34+
- Particularly important for curator and namespace permissions where parallel operations could cause conflicts.
35+
- Existing permissions are migrated with a default instance count of 1, maintaining current behavior.
36+
37+
### Infrastructure Changes
38+
39+
#### Storage Migration v5
40+
41+
Migrated the CuratorScope structure to support the new hierarchical permission model:
42+
43+
- The migration transforms the flat CuratorPermissions flags into a BoundedBTreeMap structure where existing permissions are mapped with no parent permission ID.
44+
- Ensures backward compatibility while enabling the new curator re-delegation features.
45+
- All existing curator permissions continue to work as before while gaining the ability to be re-delegated.
46+
- The migration runs automatically during runtime upgrade and is transparent to other pallets.
47+
48+
### Configuration Updates
49+
50+
- Added MaxCuratorSubpermissionsPerPermission parameter to limit the number of curator sub-permissions that can be delegated in a single permission contract (set to 16).
51+
- Added new error types to handle curator permission limits and namespace delegation depth restrictions.
52+
53+
This release enhances the permission system's flexibility while maintaining security through proper validation and depth limiting, enabling more sophisticated governance and namespace management structures.
54+
55+
## Spec 22
56+
57+
This release introduces a major redesign of the permission system from a grant-based to a delegation-based model, along with significant improvements to staking, agent registration, and emission distribution.
58+
59+
### Major Features
60+
61+
#### Permission Delegation System Redesign
62+
63+
The entire permission system has been redesigned around delegation rather than granting:
64+
65+
- All functions, events, and storage items renamed from "grant/grantor/grantee" to "delegate/delegator/recipient" terminology.
66+
- Better reflects the actual relationship between participants - one party delegates authority to another rather than simply granting permissions.
67+
- Improves the mental model for developers and users interacting with the permission system.
68+
- All client applications must update their calls to use the new extrinsic names and parameter names.
69+
70+
#### Hierarchical Namespace Permissions
71+
72+
Namespace permissions now support hierarchical delegation through a parent-child relationship system:
73+
74+
- The NamespaceScope structure changed from a simple set of paths to a map of parent permission IDs to path sets.
75+
- Permission contracts now track children and have instance limits.
76+
- Enables sophisticated permission delegation chains where a recipient of namespace permissions can re-delegate subsets of those permissions to other parties.
77+
- The instance system prevents over-delegation by limiting how many active delegations can exist from a single permission.
78+
79+
#### Staking System Overhaul
80+
81+
The staking system now uses named reserves instead of withdrawing and issuing tokens:
82+
83+
- Stakes are tracked using the Balances pallet's named reserve functionality with identifier "torstake".
84+
- Improves the economic model by ensuring staked tokens remain as part of the staker's balance but are properly reserved and cannot be spent.
85+
- Ensures the total issuance remains consistent and stakes are properly tracked by the underlying currency system.
86+
- The v6 migration automatically handles the conversion of existing stakes to the new reserve-based system.
87+
88+
#### Agent Registration Simplification
89+
90+
The register_agent extrinsic no longer takes a separate agent_key parameter:
91+
92+
- The agent key is now always the transaction signer.
93+
- The registration process also now checks for duplicate agent names in addition to duplicate keys.
94+
- Simplifies the registration process and ensures stronger consistency between the transaction signer and the registered agent.
95+
- Name uniqueness prevents confusion and impersonation attempts.
96+
97+
#### Enhanced Emission Distribution Tracking
98+
99+
The emission distribution system now emits more granular events:
100+
101+
- Individual EmissionDistribution events for each target and AccumulatedEmission events when tokens are accumulated for permissions.
102+
- Distribution functions now return DispatchResult and handle errors gracefully.
103+
- Provides better observability into the emission system, allowing external systems to track exactly how tokens flow through the network.
104+
- Error handling prevents the emission system from silently failing.
105+
106+
#### Whitelist-Based Consensus Participation
107+
108+
The emission system now considers agents to be eligible for consensus only if they are both registered and whitelisted:
109+
110+
- The registered field in ConsensusMemberInput was renamed to whitelisted to reflect this dual requirement.
111+
- Provides finer-grained control over network participation.
112+
- Allows the governance system to temporarily restrict agents from consensus without full deregistration.
113+
114+
#### Namespace Creation Event Granularity
115+
116+
Namespace creation and deletion now emit individual events for each namespace path rather than batch events:
117+
118+
- Provides more detailed tracking of namespace operations.
119+
- Better supports indexing and monitoring systems that need to track individual namespace state changes.
120+
- Applications listening to namespace events should expect multiple events per operation when multiple paths are involved.
121+
122+
### API Changes
123+
124+
- The Torus0Api stake_to method now returns DispatchResult instead of Result<(), Balance> for consistent error handling.
125+
- Added find_agent_by_name method to the Torus0Api to support name-based agent lookups.
126+
- Added agent_name method to NamespacePath to extract agent names from namespace paths.
127+
128+
This release represents a fundamental shift in how permissions are conceptualized and managed within the Torus Network, providing clearer semantics and more powerful delegation capabilities.
129+
3130
## Spec 21
4131

5132
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.

CLAUDE.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,36 @@ Torus is a stake-driven peer-to-peer network built on Substrate. The blockchain
2121
- **`governance`**: Proposals, voting, treasury, roles (allocators, curators)
2222
- **`permission0`**: Permission and access control
2323

24+
### Permission0 Pallet Structure
25+
26+
The `permission0` pallet manages delegated permissions and access control within the Torus network. Key components:
27+
28+
**Core Permission Types** (`pallets/permission0/src/permission.rs`):
29+
- `PermissionContract<T>` - Main permission structure with delegator, recipient, scope, duration, and enforcement
30+
- `PermissionId` - Unique permission identifier (H256 hash)
31+
- `PermissionScope<T>` - Defines what actions the permission covers
32+
- `NamespaceScope<T>` - Defines namespace path permissions for delegation
33+
34+
**Permission Scopes** (`pallets/permission0/src/permission/`):
35+
- `pallets/permission0/src/permission/curator.rs` - `CuratorPermissions` and `CuratorScope` types
36+
- `pallets/permission0/src/permission/emission.rs` - `EmissionAllocation`, `DistributionControl`, and `EmissionScope` types
37+
38+
**Implementation Handlers** (`pallets/permission0/src/ext/`):
39+
- `pallets/permission0/src/ext/curator_impl.rs` - Functions for curator permission enforcement
40+
- `pallets/permission0/src/ext/emission_impl.rs` - Functions for emission permission enforcement
41+
- `pallets/permission0/src/ext/namespace_impl.rs` - Functions for namespace permission enforcement
42+
2443
## Architecture Principles
2544

2645
- **API-first design**: Each pallet has separate `api` crate to prevent circular dependencies
2746
- **Domain separation**: Complex logic split into focused modules (agent.rs, stake.rs, etc.)
2847
- **Storage efficiency**: Use container types to minimize state size
2948
- **Zero-panic policy**: Runtime code must NEVER panic under any circumstances
3049

50+
## Project Structure
51+
52+
- All pallet tests are located within the /tests folder in each pallet's folder
53+
3154
## Essential Commands
3255

3356
```sh
@@ -152,4 +175,4 @@ cargo build --release # Build the node
152175
2. **MUST** run `just check` and fix all warnings
153176
3. **MUST** run `just test` and ensure all pass
154177
4. **MUST** run `cargo xtask coverage` to verify coverage
155-
5. **MUST** test runtime upgrades if storage changed
178+
5. **MUST** test runtime upgrades if storage changed

0 commit comments

Comments
 (0)