You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/fees_data_structures.md
+1-122Lines changed: 1 addition & 122 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -376,125 +376,4 @@ Example:
376
376
},
377
377
}
378
378
}
379
-
```
380
-
381
-
## How to set fees for an action
382
-
For setting fees for an action we need to make the following steps:
383
-
* Send a SET_FEES txn with appropriate amount for required alias.
384
-
For example, we have an alias, like "add_new_steward" (and we want to set fees for adding new nym action). For setting fees for this alias, we need to send a SET_FEES transaction with map {"add_new_steward": 42}.
385
-
Txn will be looked as:
386
-
```
387
-
{
388
-
"reqId": <int>, //random identifier
389
-
"protocolVersion": <int>, // the version of the client/node communication protocol
390
-
"operation": {
391
-
"type": "20000",
392
-
"fees": {
393
-
"add_new_steward": 42,,
394
-
}
395
-
},
396
-
}
397
-
```
398
-
* After that, we need to add metadata into default auth constraint for action "add new nym".
399
-
For this example, txn for changing metadata for default auth_rule will be looked as:
400
-
```
401
-
{
402
-
'operation': {
403
-
'type':'120',
404
-
'constraint':{
405
-
'constraint_id': 'ROLE',
406
-
'role': '0',
407
-
'sig_count': 1,
408
-
'need_to_be_owner': False,
409
-
'metadata': {'fees': 'add_new_steward'}
410
-
},
411
-
'field' :'role',
412
-
'auth_type': '1',
413
-
'auth_action': 'ADD',
414
-
'new_value': '2'
415
-
},
416
-
417
-
'identifier': <str: some identifier>,
418
-
'reqId': <int: timestamp>,
419
-
'protocolVersion': 1,
420
-
'signature': <str: signature>
421
-
}
422
-
```
423
-
424
-
The pool performs the following validation for the given example:
425
-
* doDynamicValidation for "adding new steward" nym (_`from indy-node's side`_);
426
-
* making general role's authorization (_`from indy-node's side`_)
427
-
* making fees specific validation, using metadata field (_`from plugin's side`_)
428
-
* lookup through config state for getting amount of "add_new_steward" alias (_`from plugin's side`_)
429
-
* making can_pay_fees validation (_`from plugin's side`_)
430
-
431
-
### Notes:
432
-
* The order of previous steps is very important. First of all SET_FEES is required, then - AUTH_RULE.
433
-
* SET_FEES is "updating" transaction, so that it appends new aliases to the existing FEEs map (either adding or overriding aliases). For example, if current fees are {A: 1, B: 2} then after sending SET_FEES transaction with {A: 42, C:3}, the resulted map will look like {A: 42, B: 2, C:3}.
434
-
* Setting fees without adding or changing metadata in corresponding auth_rule doesn't have any effect.
435
-
436
-
## How to setup fees for whole pool
437
-
For setting fees for whole we need to make the following steps:
438
-
* Define all the actions which we would like to set fees for
439
-
* Repeat all the steps from [How to set fees for an action](#how-to-set-fees-for-an-action) for each action
440
-
441
-
## How to change fees amount for alias
442
-
For changing amount of fees for existing alias, you need to send a SET_FEES (as described in [How to set fees for an action](#how-to-set-fees-for-an-action)) transaction with 'fees' value, like:
443
-
```
444
-
{<str: fees alias to change>: <int: new amount>}
445
-
```
446
-
As was mentioned before, SET_FEES is "updating" transaction and this request will update whole fees map in state and new amount of fees_alias will be used for validation.
447
-
Full SET_FEES request:
448
-
```
449
-
{
450
-
"reqId": <int>, //random identifier
451
-
"protocolVersion": <int>, // the version of the client/node communication protocol
452
-
"operation": {
453
-
"type": "20000",
454
-
"fees": {
455
-
<str: fees alias to change>: <int: new amount>,
456
-
}
457
-
},
458
-
}
459
-
```
460
-
461
-
## How to set fees for complex Auth Constraints
462
-
For example, we have a constraint like:
463
-
```
464
-
(TRUSTEE, 2) or (STEWARD, 5)
465
-
```
466
-
It means, that this action requires "2 signatures from 2 different TRUSTEEs" or "5 signatures from 5 different STEWARDs" and we want to set fees for steward's part of this constraint.
467
-
For this case, we need to:
468
-
* add new alias, 'some_action_by_steward' for example, as described in [How to set fees for an action](#how-to-set-fees-for-an-action)
469
-
* set this alias for corresponding auth_rule into steward's part of constraint:
470
-
```
471
-
(TRUSTEE, 2) or (STEWARD, 5, 'fees': 'some_action_by_steward')
472
-
```
473
-
After that, the next requests will be ordered:
474
-
* with 2 and more TRUSTEE's signatures
475
-
* with 5 and more STEWARD's signature and required amount of fees.
476
-
477
-
Also, trustee's part of constraint can contains 'fees' field with different fees alias, like:
478
-
```
479
-
(TRUSTEE, 2, 'fees': 'some_action_by_trustee') or (STEWARD, 5, 'fees': 'some_action_by_steward')
480
-
```
481
-
'some_action_by_trustee' should exists before setting it in AUTH_RULE transaction.
482
-
483
-
## Recommendation for setting fees.
484
-
***If you want to set an alias for `AND` constraint, then make sure, that all of fees aliases will have the same amount.**
485
-
In the other words, fees aliases can be different, but amount should be the same.
486
-
For example, there is a constraint:
487
-
```
488
-
(TRUSTEE, 1) and (STEWARD, 3) - it means, that 1 trustee's and 3 steward's signatures are required
489
-
```
490
-
And we want to setup fees, like:
491
-
```
492
-
(TRUSTEE, 1, {'fees': 'trustees_fees'}) and (STEWARD, 3, {'fees': 'steward_fees'})
493
-
```
494
-
And after all setup actions we try to send a request with fees, related to 'trustees_fees' alias and signatures from 1 TRUSTEE and 3 STEWARD.
495
-
In this case, if amount of 'trustees_fees' doesn't equal to amount of 'steward_fees' then RequestRejectedException will be raised (`AND` constraint and the second part will be failed).
496
-
***Either do not set FEEs for NODE txn, or set equal amount of Fees for all fields (except service)**
497
-
For now, we can add only 1 fees field per request, but Node txn can contain several actions so that validation process (including fees validation) will be called for each action.
498
-
For example we can change ip address, port and alias in 1 txn, but 1 fees field would be used for each action validation.
499
-
If each of this actions cost 5 tokens, then Node request with 15 token will be rejected, because we don't summarize all action's tokens during validation process.
0 commit comments