-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Add cleos helper command to add eosio.code to permission #6116
Conversation
c605bb7
to
a435f0d
Compare
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.
Nice job. There are three issues I discovered though and I have suggested changes to fix them.
First, it should be possible to add and remove null@eosio.code
to an authority. The way you are checking for the null
string of the authority to maintain the old behavior of deleting a permission regardless of whether --add-code
or --remove-code
are specified was preventing that from being possible.
Second, the blockchain rules enforce certain validation rules on authorities provided in updateauth
. One of those rules is that the permission_level
s specified in the accounts
vector of an authority
must be in ascending order with no repeats (similar rules apply for keys
and waits
as well). So, if you just add a new code permission to the end of the accounts
vector, it will sometimes fail. My suggested code changes should insert the new code permission into the correct spot.
Third, an authority can consist entirely of waits
(meaning no entries in keys
and accounts
). This is perhaps not a wise move because it means any account can satisfy that authority if they just delay their transaction for long enough. But it is technically a valid authority, and so that must be considered by this cleos command to make sure to not incorrectly delete a permission that won't actually have an empty authority after remove the code permission.
a435f0d
to
911854d
Compare
@arhag I applied all of your suggestions. Thanks for your kind review. :) |
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.
Thanks!
For future reference, please just add a new commit of the requested changes rather than force pushing a replacement commit since it makes it easier to review the changes.
Change Description
Fixes #6072
This PR adds
--add-code
and--remove-code
options tocleos set account permission
command so as to add or removeeosio.code
permission conveniently to specified permission authority.Documentation Additions
Following examples can be added to documentation.
Add
eosio@eosio.code
toeosio@active
cleos set account permission eosio active --add-code
Remove
eosio@eosio.code
fromeosio@active
cleos set account permission eosio active --remove-code
Add
eosio.token@eosio.code
toeosio@owner
cleos set account permission eosio owner eosio.token --add-code -p eosio@owner