-
Notifications
You must be signed in to change notification settings - Fork 3
Syncing dev to main #131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Syncing dev to main #131
Conversation
Substrate development is HEAVY. Our simple chain has over 2000 dependencies in total, most of which are unused and just included because of the umbrella dependency `polkadot-sdk`. This new crate allows you to select which crates and dependencies you want rust-analyzer to index: ```sh just select just select pallet-torus0,pallet-emission0 just select node 1 # will only fetch up to second-level transient dependencies ```
…119) Renames the permission terminology from Grantor/Grantee/Grant to Delegator/Recipient/Delegate. This plays better with the terminology throughout the project.
The built-in chain specfile for main and testnet have been out of date for a while. This patch updates it to ship with a new one containing the correct bootnodes. Closes CHAIN-117
Because an agent can now exist without being whitelisted, it doesn't make sense to de-register it when removed from the whitelist. Closes CHAIN-118.
This change stops the charging of deposit and fee when registering an agent regarding the root namespace created. Only the agent burn will charged when registering. Closes CHAIN-119.
Emit events on emission accumulation and distribution. This helps tracking where streams are flowing to. This change replaces `PermissionExecuted` and `AutoDistributionExecuted` for `EmissionDistribution` with a `reason` field and a new `AccumulatedEmission`.
This change limits to whom you may delegate a namespace permission. From now on, only registered agents will be eligible for receiving namespace contracts. Closes CHAIN-114.
Some entries in the accumulation storage were lost in the early permission0 days. This migration patch re-inserts them, resuming the accumulation and distribution of tokens. Closes CHAIN-115
This change prevents errors that might happen when we wrongly track stake changes. By moving to reserved balances, we avoid minting tokens when unstaking from accounts. Closes CHAIN-104.
This patch introduces the first version of namespace permission
re-delegation.
Closes CHAIN-107.
# Interface Changes: Permission Redelegation and Cascading Revocation
## Extrinsic Signature Changes
### `delegate_namespace_permission` - BREAKING CHANGE
```rust
// BEFORE
pub fn delegate_namespace_permission(
origin: OriginFor<T>,
recipient: T::AccountId,
paths: BoundedBTreeSet<NamespacePathInner, T::MaxNamespacesPerPermission>,
duration: PermissionDuration<T>,
revocation: RevocationTerms<T>,
) -> DispatchResult
// AFTER
pub fn delegate_namespace_permission(
origin: OriginFor<T>,
recipient: T::AccountId,
paths: BoundedBTreeMap<
Option<PermissionId>, // Parent permission (None for root)
BoundedBTreeSet<NamespacePathInner, T::MaxNamespacesPerPermission>,
T::MaxNamespacesPerPermission,
>, // Now supports inheritance from parent permissions
duration: PermissionDuration<T>,
revocation: RevocationTerms<T>,
instances: u32, // ADDED: Max re-delegation capacity
) -> DispatchResult
```
## Structure Changes
### `PermissionContract<T>` - BREAKING CHANGES
```rust
// BEFORE
pub struct PermissionContract<T: Config> {
...
pub parent: Option<PermissionId>, // REMOVED
}
// AFTER
pub struct PermissionContract<T: Config> {
...
pub max_instances: u32, // ADDED: Controls re-delegation capacity
pub children: BoundedBTreeSet<H256, T::MaxChildrenPerPermission>, // ADDED: Enables cascading revocation
}
```
### `NamespaceScope<T>` - BREAKING CHANGE
```rust
// BEFORE
pub struct NamespaceScope<T: Config> {
pub paths: BoundedBTreeSet<NamespacePath, T::MaxNamespacesPerPermission>,
}
// AFTER
pub struct NamespaceScope<T: Config> {
pub paths: BoundedBTreeMap<
Option<PermissionId>, // Parent permission that granted these paths.
// None if path belongs to delegator itself
BoundedBTreeSet<NamespacePath, T::MaxNamespacesPerPermission>,
T::MaxNamespacesPerPermission,
>,
}
```
## Behavioral Changes
### Instance Management
- `max_instances` controls how many child permissions can be created
- Each child consumes instances from parent, preventing unlimited
delegation
### Inheritance Validation
- Child permissions must have weaker or equal revocation terms than
parent
- Namespace paths must be accessible through parent permissions
- Supports granular delegation of more specific namespaces
### Cascading Revocation
- Revoking a permission automatically revokes ALL child permissions
recursively
- Multiple `PermissionRevoked` events emitted for each revoked
permission
## Migration Impact
- All existing permissions get `max_instances = 1` and empty `children`
set
## Client SDK Requirements
1. Update `delegate_namespace_permission` call construction
2. Handle new error variants in error handling
3. Update struct parsing for `PermissionContract` and `NamespaceScope`
4. Change event listening from `Permissiondelegated` to
`PermissionDelegated`
5. Use accessor methods instead of direct field access
6. Implement cascading revocation event handling
7. Add hierarchy validation using `RevocationTerms::is_weaker()`
This change finished CHAIN-105 by implementing the same re-delegation system for curator scopes.
This pull request adds the torus-client `client/` to the repo complete with examples and readme. --------- Co-authored-by: Kelvin Steiner <[email protected]> Co-authored-by: Luiz Carvalho <[email protected]>
|
Caution Review failedThe pull request is closed. WalkthroughThis update introduces a comprehensive overhaul of the permission and agent systems, focusing on renaming core entities from "grantor/grantee" to "delegator/recipient" and shifting from permission granting to hierarchical delegation. It implements deep changes to the permission0 and torus0 pallets, including new extrinsics, storage structures, migration logic, staking mechanics, event emission, and extensive test and documentation updates. The runtime version is incremented, and new migrations are added. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Runtime
participant Permission0
participant Torus0
participant Agent
participant Storage
User->>Runtime: Call delegate_namespace_permission (delegator, recipient, paths, ...)
Runtime->>Permission0: Validate delegator/recipient, paths, instances
Permission0->>Storage: Check parent permissions, delegation depth, instance limits
Permission0->>Storage: Create PermissionContract with parent-child links
Permission0-->>Runtime: Emit PermissionDelegated event
User->>Runtime: Call register_agent (name, url, metadata)
Runtime->>Torus0: Derive agent_key from origin
Torus0->>Agent: Check uniqueness, register agent
Torus0-->>Runtime: Emit AgentRegistered event
User->>Runtime: Call add_stake (staker, staked, amount)
Runtime->>Torus0: Reserve tokens using NamedReservableCurrency
Torus0->>Storage: Update StakingTo, StakedBy, TotalStake
Torus0-->>Runtime: Emit StakeAdded event
Estimated code review effort🎯 5 (Critical) | ⏱️ ~90+ minutes Possibly related PRs
Suggested reviewers
Poem
Note 🔌 MCP (Model Context Protocol) integration is now available in Early Access!Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Check all the changes in CHANGELOG.md, entries 22 and 23.
Summary by CodeRabbit
New Features
Improvements
Bug Fixes
Documentation
Chores
Tests
Refactor/Style
Migrations