Skip to content
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

[3.2] cleos sorts keys/permission_levels/waits for "cleos set account permission #696

Merged
merged 1 commit into from
Jul 20, 2022

Conversation

ClaytonCalabrese
Copy link
Contributor

The same change to release/2.2.x branch for #10903 .

The keys/permissions/waits to eosio::updateauth action must be ordered. The order is not simply the string order.

At current, cleos can validate the authority data structure. But when there are multiple keys or multiple permission_levels, it is hard to figure out how to order the keys/permissions/waits. There are N! number of combinations to try for N keys/permission_levels.

It will be convenient if cleos set account permission can automatically sort the keys, permission_levels and waits for users.

One example:

./bin/cleos -u https://eos.greymass.com set account permission eosio active -sdj -x 3600 '{
  "threshold": 1,
  "keys": [
    {
      "key": "EOS8YWkQM9bcwHUSjEfZVAb7cDoQNAwikYvJXrAbQya2hhdDz7KSR",
      "weight": 1
    },
    {
      "key": "EOS7QvhpiF4uWTrjCgyJz2mV13mhdCwzNLNXSGn6npK87Ymz56Mip",
      "weight": 1
    }
  ],
  "accounts": [
    {
      "permission": {
          "actor": "eosio.token",
          "permission": "owner"
        },
        "weight": 1
    },
    {
      "permission": {
          "actor": "eosio.token",
          "permission": "active"
        },
        "weight": 1
    },
    {
      "permission": {
          "actor": "eosio.saving",
          "permission": "active"
        },
        "weight": 1
    }
  ],
  "waits": [
    {
      "wait_sec": 10,
      "weight": 2
    },
    {
      "wait_sec": 5,
      "weight": 1
    }
  ]
}' -p eosio@active
{
  "expiration": "2021-11-24T10:27:24",
  "ref_block_num": 46078,
  "ref_block_prefix": 3678459831,
  "max_net_usage_words": 0,
  "max_cpu_usage_ms": 0,
  "delay_sec": 0,
  "context_free_actions": [],
  "actions": [{
      "account": "eosio",
      "name": "updateauth",
      "authorization": [{
          "actor": "eosio",
          "permission": "active"
        }
      ],
      "data": {
        "account": "eosio",
        "permission": "active",
        "parent": "owner",
        "auth": {
          "threshold": 1,
          "keys": [{
              "key": "EOS7QvhpiF4uWTrjCgyJz2mV13mhdCwzNLNXSGn6npK87Ymz56Mip",
              "weight": 1
            },{
              "key": "EOS8YWkQM9bcwHUSjEfZVAb7cDoQNAwikYvJXrAbQya2hhdDz7KSR",
              "weight": 1
            }
          ],
          "accounts": [{
              "permission": {
                "actor": "eosio.saving",
                "permission": "active"
              },
              "weight": 1
            },{
              "permission": {
                "actor": "eosio.token",
                "permission": "active"
              },
              "weight": 1
            },{
              "permission": {
                "actor": "eosio.token",
                "permission": "owner"
              },
              "weight": 1
            }
          ],
          "waits": [{
              "wait_sec": 5,
              "weight": 1
            },{
              "wait_sec": 10,
              "weight": 2
            }
          ]
        }
      },
      "hex_data": "0000000000ea305500000000a8ed32320000000080ab26a7010000000200034c80d981ee83fd82089672e361102b87f561f2f07fc51fd10bbda24471072c6d01000003e16d3374ee29cf0b794df19dd0919ee309cf4e500e1f71c4c866884a32ae9f67010003c0a6db0603ea305500000000a8ed3232010000a6823403ea305500000000a8ed3232010000a6823403ea30550000000080ab26a70100020500000001000a0000000200"
    }
  ],
  "signatures": [],
  "context_free_data": []
}

Resolves #454

@ClaytonCalabrese ClaytonCalabrese added 3.2 Candidate OCI OCI working this issue... labels Jul 19, 2022
@ClaytonCalabrese ClaytonCalabrese self-assigned this Jul 19, 2022
@ClaytonCalabrese ClaytonCalabrese changed the title [2.2] cleos sorts keys/permission_levels/waits for "cleos set account permission [3.2] cleos sorts keys/permission_levels/waits for "cleos set account permission Jul 20, 2022
@ClaytonCalabrese ClaytonCalabrese merged commit 94a9fb8 into main Jul 20, 2022
@ClaytonCalabrese ClaytonCalabrese deleted the cleos_sort_keys branch July 22, 2022 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.2 Candidate OCI OCI working this issue...
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backport: cleos sorts keys/permission_levels/waits for "cleos set account permission"
3 participants