-
Notifications
You must be signed in to change notification settings - Fork 86
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
Custom active permission #86
Changes from 6 commits
15fbf7f
7a13f4d
aed7556
e928c44
e8fabfd
5ebcbb6
a825307
239b7a2
28f96ba
10fa5ad
815a50c
8591695
824549e
71e57c5
54d0ee6
1083311
189ceec
cb79a4f
e6cc5f1
75faa36
5b5e550
7ae9f94
55aa5b0
ef397f0
bcfa32f
5da66a4
6c64b50
8207e24
e2d9022
fccca20
2bcc40a
4349e8d
2051ff3
6df4a38
ba625b1
1d4aa42
523ed86
07b6fa0
ab5500d
0e8e9ad
e145ede
d5e6f75
15a0514
d77a526
6c7a90a
41a2403
cf72eaa
f0d16bb
63f6ddc
b7282a5
9b07069
12355d6
2222cea
b1864f8
03f24f0
8dce372
34d0086
651e00c
8893727
5d92967
b8f2691
871b93d
d036c8c
ecf22d4
7d1468e
d9466f2
5ddc6cd
40b7ae4
552b5c4
6a00164
5dcf316
3ac2159
f1f9755
0919eae
78100ed
a1ce8ab
e9c8e9b
f9c2df5
bd2af37
0c43bfd
0f2a433
982348c
64338a4
02bb9e5
1d0a341
e749319
51d46da
b560291
b0dfaa5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,7 +102,8 @@ List of possible restrictions are: | |
| ------------- |:-------------:| -----:| | ||
| `any` | [`list`, `of`, `allowed`, `values`] | stateless | | ||
| `none` | [`none`, `of`, `these`, `values`] | stateless | | ||
| `lt, le, gt, ge` | `comparative` | stateless | | ||
| `lt, le, gt, ge, eq` | `comparative` | stateless | | ||
| `contains, not_contains` | [`list`, `of`, `values`] | stateless | | ||
| `limit` | [`max_cumsum`, `interval_in_sec`] | [`current_cumsum`, `interval_began`] | | ||
| `limit_monthly` | [`max_cumsum`, `interval_in_months`] | [`current_cumsum`, `interval_began`] | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Best to have an function "can_not_change" for update-like operations. For example, we may want to use a bot to update an asset's core exchange rate via Actually this can be a bit hard to define, because some data fields in some operations are nested, for example, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have added a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I've stated, this part is hard.
A "contains_only" assert makes some sense, but it's operation-specific:
Last, not like other functions which each applies to an argument/field, this "contains_only" function applies to the whole operation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I discussed this with Stefan already. Nested objects are probably out of scope here. |
||
| `attribute_assert` | list of restrictions | stateless | | ||
|
@@ -130,12 +131,20 @@ Stateless assert, all argument types. `Argument value` must NOT be equal to any | |
Stateless assert. Allows explicit type conversion: | ||
- `int` type: use as is | ||
- `string` type: use `length` of string as `argument value` | ||
- `object` type: use `size` of object as `argument value` | ||
- `list` type: use `length` of the list as `argument value` | ||
|
||
The different asserts read as: | ||
- `lt`: `Argument value` must be less than `comparative` | ||
- `le`: `Argument value` must be less than or equal to `comparative` | ||
- `gt`: `Argument value` must be greater than `comparative` | ||
- `ge`: `Argument value` must be greater than or equal to `comparative` | ||
- `eq`: `Argument value` must equal to `comparative` | ||
|
||
#### `contains, not_contains` | ||
Stateless assert, for `list` type arguments. | ||
- `contains`: The `argument value` must contain all items specified by `data`, but can contain more | ||
- `not_contains`: The `argument value` must NOT contain any of the items specified by `data`, but can contain others | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TBH I don't like to use a list as parameter of a function named There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have changed the wording to |
||
|
||
#### `limit` | ||
Stateful assert, only `int` type arguments. When the authority is created, `interval_began` is set to `valid_from` from its custom active authority and `max_cumsum` to `0`. Incoming operations are first tried to match all stateless asserts, | ||
|
@@ -158,10 +167,10 @@ When a signed transaction arrives and before the backend evaluates if all necess | |
- iterate over `required accounts` | ||
- iterate over all `operations` (child operations of proposal are not included) within the transactions that require the active authority of this account | ||
- iterate the `custom_active_authorities` of this account, and if it matches, remember that and continue with next `operation` | ||
- if a `custom active authority` match was found for every operation in the loop, behave as if the `active authority` of this account is present for the correspoding operations | ||
- if a `custom active authority` match was found for every operation in the loop, behave as if the `active authority` of this account is present for the corresponding operations | ||
|
||
Note: | ||
- A `custom_active_authority` can only grant the `active authority` of the corresponding account for the matching operation, nothing more | ||
- A `custom_active_authority` can only grant the `active authority` of the required account of the corresponding operation, nothing more | ||
- The actual active authority of a required account can still be given as before, existing behavior is not to be changed | ||
- This for illustration, not actual implementation instructions | ||
|
||
|
@@ -171,9 +180,13 @@ Adding a custom active authority means increased effort for the backend, and wit | |
- `install_custom_active_authority`: Normal accounts can only create custom active authoritites with a duration of maximum 1 year, LTM can do any duration. Two options come to mind: | ||
- A fixed high fee independent of authorities content | ||
- Tied to the duration and complexity of the custom active authority. Transaction fee is then `fee = flat_fee + basic_fee * duration` where `basic_fee` is calculated according to complexity (e.g. size of authority, number of restrictions and etc.). Fee is capped at 1 year for LTM. | ||
- `update_custom_active_authority`: Base fee similar to `account_update` plus dynamic one for any duration changes | ||
- `update_custom_active_authority`: Base fee similar to `account_update` plus dynamic one for any duration changes, no payback if duration in decreased. | ||
- `delete_custom_active_authority`: Cheap similar to `limit_order_cancel` | ||
|
||
This logic forces the user to think about the desired duration and enforces to put it rather too short than too long. | ||
If a custom active is expired, or considered to be too short, extending it is easily doable. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about a user changing period from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I see. It was meant like In your example, the reference base duration when updating id There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, good point. The fee would then depend on execution time and not creation time. Let's simply do it that all time period increase counts, whereas decrease is ignored. In your example: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately the value before change is in chain state so can't be used as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then the fee of updating should take argument size and authority size into account, but not only duration difference. Ideally,
Since all old data is in chain state, to calculate the difference, we need to put some "supposed" data in the operation, to be simpler, we can directly put the supposed delta in the operation and calculate in background. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
You basically added a modifier field, which is used to extract the implicit type conversions into explicit ones. Which is totally fine and is covered by my note in the BSIP
What is best here for implementation I leave to you (the devs). One question I have: If the user overpays the transaction fee, will he (or can he) get the rest back? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In BitShares fees can always be overpaid, and the system never refund overpaid fees except the "refund order creation fee when order is cancelled" feature. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW I mentioned fee pooling mechanism earlier but Peter didn't like it at this early stage. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I saw that, but that takes it to a new level in terms of complexity. I think user can be expected to think before they create one. |
||
After expired, the custom active becomes disabled and can still be enabled again with a new period, paying the fee for that new period. | ||
|
||
### Modification to the backend | ||
|
||
* Add a new index or extend the account object to store custom active permission are assigned to an account and contain a list of custom active authorities. Multiple custom active authority entries are possible for one operation | ||
|
@@ -360,7 +373,7 @@ the transaction is executed. | |
|
||
We propose do split the implmentation into two milestones. Each milestone will be voted on as a separate BSIP: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You list three milestones, not two There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not done. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now done |
||
|
||
1. Implementation of basic functionaliy to allow custom active permissions and authorities, including `any`, `none` and `lt, le, gt, ge` and `attribute_assert` `asserts`. If deemed necessary by developpers, reduce to only allow one key or one account for every `custom active authority` | ||
1. Implementation of basic functionaliy to allow custom active permissions and authorities, including `any`, `none` and `lt, le, gt, ge`, `contains, not_contains` and `attribute_assert` `asserts`. If deemed necessary by developpers, reduce to only allow one key or one account for every `custom active authority` | ||
2. Implement stateful asserts `limit` and `limit_monthly` | ||
3. Implement `logical_or` | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already added
eq
, why not addne
aka "not equal"?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added neq