Skip to content

Commit

Permalink
Merge pull request EOSIO#1581 from cj-oci/permissionsEnablingFix-stat565
Browse files Browse the repository at this point in the history
Update permission without waiting on apply block check.
  • Loading branch information
bytemaster authored Mar 7, 2018
2 parents b9c678f + ccd4c71 commit 1f97a16
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 30 deletions.
15 changes: 6 additions & 9 deletions libraries/chain/contracts/eosio_contract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,7 @@ void apply_eosio_deleteauth(apply_context& context) {
"Cannot delete a linked authority. Unlink the authority first");
}

if (context.controller.is_applying_block())
db.remove(permission);
db.remove(permission);
}

void apply_eosio_linkauth(apply_context& context) {
Expand All @@ -280,11 +279,10 @@ void apply_eosio_linkauth(apply_context& context) {
if (link) {
EOS_ASSERT(link->required_permission != requirement.requirement, action_validate_exception,
"Attempting to update required authority, but new requirement is same as old");
if (context.controller.is_applying_block())
db.modify(*link, [requirement = requirement.requirement](permission_link_object& link) {
link.required_permission = requirement;
});
} else if (context.controller.is_applying_block()) {
db.modify(*link, [requirement = requirement.requirement](permission_link_object& link) {
link.required_permission = requirement;
});
} else {
db.create<permission_link_object>([&requirement](permission_link_object& link) {
link.account = requirement.account;
link.code = requirement.code;
Expand All @@ -303,8 +301,7 @@ void apply_eosio_unlinkauth(apply_context& context) {
auto link_key = boost::make_tuple(unlink.account, unlink.code, unlink.type);
auto link = db.find<permission_link_object, by_action_name>(link_key);
EOS_ASSERT(link != nullptr, action_validate_exception, "Attempting to unlink authority, but no link found");
if (context.controller.is_applying_block())
db.remove(*link);
db.remove(*link);
}


Expand Down
13 changes: 0 additions & 13 deletions libraries/chain/include/eosio/chain/chain_controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,6 @@ namespace eosio { namespace chain {











/**
* @brief Check whether the controller is currently applying a block or not
* @return True if the controller is now applying a block; false otherwise
*/
bool is_applying_block()const { return _currently_applying_block; }
bool is_start_of_round( block_num_type n )const;
uint32_t blocks_per_round()const;

Expand Down
14 changes: 6 additions & 8 deletions tests/eosiod_run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,14 +537,12 @@ def cmdError(name, code=0, exitNow=False):
cmdError("%s set action permission set" % (ClientName))
errorExit("Failed to set permission")

# TODO remove failed on eos-noon
if not amINoon:
Print("remove permission")
requirement="null"
trans=node.setPermission(testeraAccount.name, code, pType, requirement, waitForTransBlock=True)
if trans is None:
cmdError("%s set action permission set" % (ClientName))
errorExit("Failed to remove permission")
Print("remove permission")
requirement="null"
trans=node.setPermission(testeraAccount.name, code, pType, requirement, waitForTransBlock=True)
if trans is None:
cmdError("%s set action permission set" % (ClientName))
errorExit("Failed to remove permission")

Print("Locking all wallets.")
if not walletMgr.lockAllWallets():
Expand Down

0 comments on commit 1f97a16

Please sign in to comment.