Skip to content

Commit a9a309b

Browse files
refac: renaming agent functions to deregister and removing payer key (#119)
Renames the permission terminology from Grantor/Grantee/Grant to Delegator/Recipient/Delegate. This plays better with the terminology throughout the project.
2 parents bf81566 + 11d3312 commit a9a309b

Some content is hidden

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

41 files changed

+796
-668
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/namespace.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,15 @@ pub struct NamespaceScope<T: Config> {
112112
}
113113
```
114114

115-
The namespace permission scope contains a set of paths that the grantee can access. The permission system's existing infrastructure handles the complexity of duration, revocation terms, and enforcement authorities. This means namespace permissions can be temporary, require multi-signature revocation, or include third-party controllers. Read more in [permission0.md](permission0.md).
115+
The namespace permission scope contains a set of paths that the recipient can access. The permission system's existing infrastructure handles the complexity of duration, revocation terms, and enforcement authorities. This means namespace permissions can be temporary, require multi-signature revocation, or include third-party controllers. Read more in [permission0.md](permission0.md).
116116

117117
This integration creates composition possibilities. An agent running a data aggregation service could delegate read access to `agent.alice.data.public` while keeping `agent.alice.data.private` restricted, or delegate the entire data scope: `agent.alice.data`. The delegation could be time-limited, revocable by designated arbiters, or controlled by enforcement authorities who verify off-chain conditions.
118118

119119
## Practical Applications
120120

121121
A memory service agent registers `agent.memory` and creates specialized sub-namespaces like `agent.memory.twitter`, `agent.memory.discord`, and `agent.memory.telegram`. Each represents a different data source with potentially different access requirements. The agent can delegate read access to `agent.memory.twitter` to analytics agents while keeping other sources private.
122122

123-
A compute marketplace might use `agent.compute.gpu.nvidia.a100` to represent specific hardware resources. Delegating this namespace grants access to submit jobs to those specific GPUs. The hierarchical structure naturally represents the hardware taxonomy while permissions control access.
123+
A compute marketplace might use `agent.compute.gpu.nvidia.a100` to represent specific hardware resources. Delegating this namespace delegates access to submit jobs to those specific GPUs. The hierarchical structure naturally represents the hardware taxonomy while permissions control access.
124124

125125
API versioning is viable with paths like `agent.api.v1` and `agent.api.v2`. Services can maintain backward compatibility by keeping old namespaces active while encouraging migration to newer versions. Permissions can be time-limited to enforce deprecation schedules.
126126

docs/permission0.md

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ The concept draws inspiration from multi-level competency networks that self-org
88

99
## Permission Contracts
1010

11-
A permission contract forms the foundation of the delegation relationship. Each contract defines the relationship between a grantor (who delegates emissions) and a grantee (who receives the delegation authority). The contract specifies allocation parameters, distribution controls, duration, and revocation terms.
11+
A permission contract forms the foundation of the delegation relationship. Each contract defines the relationship between a delegator (who delegates emissions) and a recipient (who receives the delegation authority). The contract specifies allocation parameters, distribution controls, duration, and revocation terms.
1212

13-
Permission contracts are identified by a unique `PermissionId` generated deterministically from the grantor, grantee, scope, and creation block. This ensures contracts can be consistently referenced and avoids collision issues when multiple contracts exist between the same parties.
13+
Permission contracts are identified by a unique `PermissionId` generated deterministically from the delegator, recipient, scope, and creation block. This ensures contracts can be consistently referenced and avoids collision issues when multiple contracts exist between the same parties.
1414

1515
```rust
1616
pub struct PermissionContract<T: Config> {
17-
pub grantor: T::AccountId,
18-
pub grantee: T::AccountId,
17+
pub delegator: T::AccountId,
18+
pub recipient: T::AccountId,
1919
pub scope: PermissionScope<T>,
2020
pub duration: PermissionDuration<T>,
2121
pub revocation: RevocationTerms<T>,
@@ -62,11 +62,11 @@ pub enum EmissionAllocation<T: Config> {
6262
}
6363
```
6464

65-
With `Streams` allocation, portions of the grantor's incoming emissions from specific streams are diverted according to the percentages specified (0-100%). Each stream ID represents a distinct emission source, allowing for fine-grained control over different emission types. For `FixedAmount` allocation, a specific number of tokens is reserved from the grantor's account at contract creation.
65+
With `Streams` allocation, portions of the delegator's incoming emissions from specific streams are diverted according to the percentages specified (0-100%). Each stream ID represents a distinct emission source, allowing for fine-grained control over different emission types. For `FixedAmount` allocation, a specific number of tokens is reserved from the delegator's account at contract creation.
6666

6767
The `targets` field identifies recipients with associated weights, determining how tokens are distributed among multiple targets. For example, with targets A (weight 1) and B (weight 2), target B receives twice the tokens of target A.
6868

69-
The `accumulating` boolean determines whether emissions should actively accumulate for this permission. This flag can be toggled by the grantor or enforcement authorities to temporarily pause emission accumulation.
69+
The `accumulating` boolean determines whether emissions should actively accumulate for this permission. This flag can be toggled by the delegator or enforcement authorities to temporarily pause emission accumulation.
7070

7171
### Curator Scope
7272

@@ -90,7 +90,7 @@ const WHITELIST_MANAGE = 0b0000_0100;
9090
const PENALTY_CONTROL = 0b0000_1000;
9191
```
9292

93-
> `ROOT = 0b0001` exists but is reserved for future use. For now, only the SUDO key is able to grant curator permissions.
93+
> `ROOT = 0b0001` exists but is reserved for future use. For now, only the SUDO key is able to delegate curator permissions.
9494
9595
The `cooldown` option provides a rate-limiting mechanism for curator actions.
9696

@@ -109,7 +109,7 @@ pub enum DistributionControl<T: Config> {
109109

110110
The distribution control mechanism provides flexibility in how emissions flow through the network:
111111

112-
- `Manual`: The grantee must explicitly call `execute_permission` to trigger distribution
112+
- `Manual`: The recipient must explicitly call `execute_permission` to trigger distribution
113113
- `Automatic`: Distribution occurs when accumulated amount reaches the specified threshold
114114
- `AtBlock`: Distribution triggers at a specific block number
115115
- `Interval`: Distribution occurs periodically at the specified block interval
@@ -132,7 +132,7 @@ Revocation terms define how a permission can be revoked before its normal expira
132132
```rust
133133
pub enum RevocationTerms<T: Config> {
134134
Irrevocable,
135-
RevocableByGrantor,
135+
RevocableByDelegator,
136136
RevocableByArbiters {
137137
accounts: BoundedVec<T::AccountId, T::MaxRevokersPerPermission>,
138138
required_votes: u32,
@@ -141,7 +141,7 @@ pub enum RevocationTerms<T: Config> {
141141
}
142142
```
143143

144-
These terms create different security guarantees for the grantee, ranging from complete assurance (`Irrevocable`) to flexible arrangements (`RevocableByGrantor`). The `RevocableByArbiters` option allows for multi-signature revocation by designated third parties. The grantee can ALWAYS revoke a permission as it is the one being benefitted.
144+
These terms create different security guarantees for the recipient, ranging from complete assurance (`Irrevocable`) to flexible arrangements (`RevocableByDelegator`). The `RevocableByArbiters` option allows for multi-signature revocation by designated third parties. The recipient can ALWAYS revoke a permission as it is the one being benefitted.
145145

146146
## Enforcement Authority System
147147

@@ -213,8 +213,8 @@ For example, a permission might require KYC verification before distributions ca
213213

214214
Enforcement can be configured in two ways:
215215

216-
1. During permission creation via the `grant_emission_permission` extrinsic
217-
2. After creation through the `set_enforcement_authority` extrinsic (only by the grantor or root)
216+
1. During permission creation via the `delegate_emission_permission` extrinsic
217+
2. After creation through the `set_enforcement_authority` extrinsic (only by the delegator or root)
218218

219219
```rust
220220
pub fn set_enforcement_authority(
@@ -233,12 +233,12 @@ The enforcement authority system transforms the permission framework from a simp
233233

234234
The Permission0 pallet provides several extrinsics to manage the permission lifecycle:
235235

236-
### grant_emission_permission
236+
### delegate_emission_permission
237237

238238
```rust
239-
pub fn grant_emission_permission(
239+
pub fn delegate_emission_permission(
240240
origin: OriginFor<T>,
241-
grantee: T::AccountId,
241+
recipient: T::AccountId,
242242
allocation: EmissionAllocation<T>,
243243
targets: Vec<(T::AccountId, u16)>,
244244
distribution: DistributionControl<T>,
@@ -248,24 +248,24 @@ pub fn grant_emission_permission(
248248
) -> DispatchResult
249249
```
250250

251-
Creates a new emission permission from the signed origin to the specified grantee. The caller must be a registered agent, as must the grantee and all targets. Checks for valid allocation percentages, ensuring the total allocated percentage doesn't exceed 100% per stream.
251+
Creates a new emission permission from the signed origin to the specified recipient. The caller must be a registered agent, as must the recipient and all targets. Checks for valid allocation percentages, ensuring the total allocated percentage doesn't exceed 100% per stream.
252252

253-
### grant_curator_permission
253+
### delegate_curator_permission
254254

255255
```rust
256-
pub fn grant_curator_permission(
256+
pub fn delegate_curator_permission(
257257
origin: OriginFor<T>,
258-
grantee: T::AccountId,
258+
recipient: T::AccountId,
259259
flags: u32,
260260
cooldown: Option<BlockNumberFor<T>>,
261261
duration: PermissionDuration<T>,
262262
revocation: RevocationTerms<T>,
263263
) -> DispatchResult
264264
```
265265

266-
Creates a new curator permission, but can only be called with the Root origin. The `flags` parameter is a bitwise combination of curator permissions (APPLICATION_REVIEW, WHITELIST_MANAGE, PENALTY_CONTROL). The ROOT permission cannot be granted.
266+
Creates a new curator permission, but can only be called with the Root origin. The `flags` parameter is a bitwise combination of curator permissions (APPLICATION_REVIEW, WHITELIST_MANAGE, PENALTY_CONTROL). The ROOT permission cannot be delegated.
267267

268-
Only one curator permission can exist per grantee - attempting to create a second will result in a `DuplicatePermission` error. The optional `cooldown` parameter enforces a delay between successive uses of the permission.
268+
Only one curator permission can exist per recipient - attempting to create a second will result in a `DuplicatePermission` error. The optional `cooldown` parameter enforces a delay between successive uses of the permission.
269269

270270
### revoke_permission
271271

@@ -277,8 +277,9 @@ pub fn revoke_permission(
277277
```
278278

279279
Revokes the specified permission if the caller meets the permission's revocation terms. This can be:
280-
- The grantee (always allowed)
281-
- The grantor (if RevocableByGrantor)
280+
281+
- The recipient (always allowed)
282+
- The delegator (if RevocableByDelegator)
282283
- Root origin (always allowed)
283284
- Designated arbiters (with sufficient votes for RevocableByArbiters)
284285
- Anyone, after the specified block (for RevocableAfter)
@@ -294,7 +295,7 @@ pub fn execute_permission(
294295
) -> DispatchResult
295296
```
296297

297-
Manually executes a permission with distribution control set to Manual. For emission permissions, this distributes accumulated tokens to the targets according to their weights. Can only be called by the grantor or root.
298+
Manually executes a permission with distribution control set to Manual. For emission permissions, this distributes accumulated tokens to the targets according to their weights. Can only be called by the delegator or root.
298299

299300
### toggle_permission_accumulation
300301

@@ -306,7 +307,7 @@ pub fn toggle_permission_accumulation(
306307
) -> DispatchResult
307308
```
308309

309-
Enables or disables accumulation for an emission permission. Can be called by the grantor, root, or enforcement controllers (with sufficient votes).
310+
Enables or disables accumulation for an emission permission. Can be called by the delegator, root, or enforcement controllers (with sufficient votes).
310311

311312
### enforcement_execute_permission
312313

@@ -330,22 +331,22 @@ pub fn set_enforcement_authority(
330331
) -> DispatchResult
331332
```
332333

333-
Sets or updates the enforcement authority for a permission. Can only be called by the grantor or root. The controllers and required_votes must form a valid multi-signature configuration (non-empty controllers, required_votes > 0, required_votes <= controllers.len()).
334+
Sets or updates the enforcement authority for a permission. Can only be called by the delegator or root. The controllers and required_votes must form a valid multi-signature configuration (non-empty controllers, required_votes > 0, required_votes <= controllers.len()).
334335

335336
## Permission Creation
336337

337338
```mermaid
338339
flowchart TD
339-
A["Agent/Grantor"] -- grant_permission --> B["Create Permission"]
340+
A["Agent/Delegator"] -- delegate_permission --> B["Create Permission"]
340341
B -- validate --> C["Check agent registration"] --> E["Check targets"] --> P{"Check Allocation Type"}
341342
P -- Fixed Amount --> K["Reserve Tokens"]
342343
P -- Streams --> D["Check stream percentages <= 100%"]
343344
B -- Generate ID --> F["Permission Contract"]
344345
F -- store --> G["Permissions Storage"]
345346
F -- index --> J["PermissionsByParticipants"]
346-
F -- index --> I["PermissionsByGrantee"]
347-
F -- index --> H["PermissionsByGrantor"]
348-
B -- emit event --> M["PermissionGranted Event"]
347+
F -- index --> I["PermissionsByRecipient"]
348+
F -- index --> H["PermissionsByDelegator"]
349+
B -- emit event --> M["Permissiondelegated Event"]
349350
D -- accumulate --> L["AccumulatedStreamAmounts"]
350351
```
351352

@@ -407,8 +408,8 @@ The Permission0 pallet uses several storage maps to track permissions and accumu
407408
```rust
408409
pub type Permissions<T: Config> = StorageMap<_, Identity, PermissionId, PermissionContract<T>>;
409410
pub type PermissionsByParticipants<T: Config> = StorageMap<_, Identity, (T::AccountId, T::AccountId), BoundedVec<PermissionId, T::MaxTargetsPerPermission>>;
410-
pub type PermissionsByGrantor<T: Config> = StorageMap<_, Identity, T::AccountId, BoundedVec<PermissionId, T::MaxTargetsPerPermission>>;
411-
pub type PermissionsByGrantee<T: Config> = StorageMap<_, Identity, T::AccountId, BoundedVec<PermissionId, T::MaxTargetsPerPermission>>;
411+
pub type PermissionsByDelegator<T: Config> = StorageMap<_, Identity, T::AccountId, BoundedVec<PermissionId, T::MaxTargetsPerPermission>>;
412+
pub type PermissionsByRecipient<T: Config> = StorageMap<_, Identity, T::AccountId, BoundedVec<PermissionId, T::MaxTargetsPerPermission>>;
412413
pub type AccumulatedStreamAmounts<T: Config> = StorageNMap<
413414
_,
414415
(
@@ -423,7 +424,7 @@ pub type AccumulatedStreamAmounts<T: Config> = StorageNMap<
423424
This storage design allows efficient lookups for:
424425

425426
- Finding all permissions between specific parties
426-
- Retrieving all permissions granted by an account
427+
- Retrieving all permissions delegated by an account
427428
- Retrieving all permissions received by an account
428429
- Tracking accumulated tokens for each permission by stream
429430

node/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "torus-node"
33
description = "Torus Substrate Node"
4-
version = "0.1.0"
4+
version = "0.2.0"
55
license = "MIT-0"
66
authors.workspace = true
77
edition.workspace = true

pallets/emission0/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub mod pallet {
4040

4141
/// Map of consensus members indexed by their keys. A consensus member is
4242
/// any agent eligible for emissions in the next epoch. This means
43-
/// unregistered agents will also receive emissions.
43+
/// deregistered agents will also receive emissions.
4444
#[pallet::storage]
4545
pub type ConsensusMembers<T: Config> =
4646
StorageMap<_, Identity, AccountIdOf<T>, ConsensusMember<T>>;

pallets/emission0/tests/distribution.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ fn weights_are_filtered_and_normalized() {
8989
let mut member = ConsensusMember::<Test>::default();
9090
member.update_weights(BoundedVec::truncate_from(vec![
9191
(0, 0), // self-weight is discarded
92-
(1, 10), // unregistered agent still in members
92+
(1, 10), // deregistered agent still in members
9393
(2, 20), // new agent not in members
9494
(3, 40), // unknown agent
9595
]));
@@ -155,7 +155,7 @@ fn creates_list_of_all_member_inputs_for_rewards() {
155155
let validator = 0;
156156
let new = 1;
157157
let delegating_registered = 2;
158-
let delegating_unregistered = 3;
158+
let delegating_deregistered = 3;
159159
let delegating_unknown = 4;
160160
let miner = 5;
161161
let staker = 6;
@@ -166,7 +166,7 @@ fn creates_list_of_all_member_inputs_for_rewards() {
166166
register_empty_agent(id);
167167
}
168168

169-
for id in [miner, delegating_registered, delegating_unregistered] {
169+
for id in [miner, delegating_registered, delegating_deregistered] {
170170
ConsensusMembers::<Test>::set(id, Some(Default::default()));
171171
}
172172

@@ -179,7 +179,7 @@ fn creates_list_of_all_member_inputs_for_rewards() {
179179

180180
for id in [
181181
delegating_registered,
182-
delegating_unregistered,
182+
delegating_deregistered,
183183
delegating_unknown,
184184
] {
185185
WeightControlDelegation::<Test>::set(id, Some(validator));
@@ -231,9 +231,9 @@ fn creates_list_of_all_member_inputs_for_rewards() {
231231
);
232232

233233
assert_eq!(
234-
members[&delegating_unregistered],
234+
members[&delegating_deregistered],
235235
ConsensusMemberInput {
236-
agent_id: delegating_unregistered,
236+
agent_id: delegating_deregistered,
237237
validator_permit: false,
238238
weights: vec![],
239239
stakes: vec![],

pallets/governance/src/benchmarking.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn curator<T: Config>() -> T::AccountId {
3030
T::AccountId,
3131
OriginFor<T>,
3232
BlockNumberFor<T>,
33-
>>::grant_curator_permission(
33+
>>::delegate_curator_permission(
3434
RawOrigin::Root.into(),
3535
curator_id.clone(),
3636
CuratorPermissions::all(),

pallets/governance/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ pub mod pallet {
440440
ProposalExpired(ProposalId),
441441
/// A vote has been cast on a proposal.
442442
ProposalVoted(u64, T::AccountId, bool),
443-
/// A vote has been unregistered from a proposal.
443+
/// A vote has been deregistered from a proposal.
444444
ProposalVoteUnregistered(u64, T::AccountId),
445445
/// An agent account has been added to the whitelist.
446446
WhitelistAdded(T::AccountId),

pallets/governance/src/migrations.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,13 @@ pub mod v5 {
138138
}
139139

140140
for (curator, _) in old_storage::Curators::<T>::iter() {
141-
let res = <<T as Config>::Permission0>::grant_curator_permission(
141+
let res = <<T as Config>::Permission0>::delegate_curator_permission(
142142
RawOrigin::Root.into(),
143143
curator.clone(),
144144
CuratorPermissions::all(),
145145
None,
146146
PermissionDuration::Indefinite,
147-
pallet_permission0_api::RevocationTerms::RevocableByGrantor,
147+
pallet_permission0_api::RevocationTerms::RevocableByDelegator,
148148
);
149149

150150
match res {

0 commit comments

Comments
 (0)