-
Notifications
You must be signed in to change notification settings - Fork 3
Syncing Dev to Main #132
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 #132
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 change introduces a major overhaul of the permission system, agent registration, staking, and related runtime logic. It implements hierarchical permission delegation, reworks curator and namespace permissions, adds migration logic, and updates extrinsics, events, storage, and tests accordingly. The Torus client library is introduced with code generation infrastructure and comprehensive examples. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant TorusClient
participant SubstrateNode
User->>TorusClient: Connect to Mainnet/Testnet
TorusClient->>SubstrateNode: Establish WebSocket connection
User->>TorusClient: Call extrinsic (e.g., delegate_permission)
TorusClient->>SubstrateNode: Submit extrinsic (signed/unsigned)
SubstrateNode-->>TorusClient: Extrinsic status updates
TorusClient-->>User: Extrinsic hash / finalization status
User->>TorusClient: Fetch storage data
TorusClient->>SubstrateNode: Query storage at latest/specific block
SubstrateNode-->>TorusClient: Return storage value
TorusClient-->>User: Return decoded value
User->>TorusClient: Subscribe to events
TorusClient->>SubstrateNode: Subscribe to finalized blocks/events
SubstrateNode-->>TorusClient: Stream events
TorusClient-->>User: Stream decoded events
User->>TorusClient: Call RPC (e.g., namespace cost)
TorusClient->>SubstrateNode: Send RPC request
SubstrateNode-->>TorusClient: Return RPC result
TorusClient-->>User: Return result
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 CHANGELOG.md, entries 22 and 23, for all the changes.
Summary by CodeRabbit
New Features
torus-client) with async extrinsic calls, storage access, event subscriptions, and RPC support.Improvements
Bug Fixes
Documentation
Tests
Chores