-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Account Query DB : Proposal to maintain get_(key|controlled)_accounts [2.0] #8899
Conversation
…maps to being many:many
…. If not present (implicitly or explicitly) it is treated like a wild card
This is an excellent addition, and couldn't wish for a better API structure. 👍 |
When providing a non-key to the API, you get back a 500 error. I was expecting a 200 with an empty list. You get 200 with empty list when providing a non-exist account, so the API is really not consistent here.
|
@matthewdarwin I agree that is not desired behavior. An account that does not exist is still a valid "account name". The key you provided is not a valid key. As such, I wondered if you would agree to the following behavior:
|
Hi Bart, The proposal looks good to me. Much better than current. Feedback from wallet owners would be good. I see you got a +1 from scatter already. |
I should add that passing no parameters right now gets a 200. Maybe that should be a 400? |
I agree that no inputs should also be a |
I reached out to TokenPocket to see if they have any comments. |
this issue is great, really liberates all mankind |
Agreeing with all of the other commenters above, this would be a very welcome addition from the wallet developer point of view. This solution would be far better than multiple calls against the existing APIs and still maintain a great UX during the import process. |
@matthewdarwin do you mind re-testing to check me? |
I deployed the new version. It does resolve the 500 error which was my main concern. A few comments:
|
I should add that I didn't test the other nodeos APIs, so maybe the errors here are no worse than the rest of nodoes. But still, seems it could be better. Just use something "does not seem like a valid key" rather then getting code back in the error message. Also not good practice to echo back the provided input (see "garbage" above test). Could possibly be used to generate some cross-site scripting issue. |
@matthewdarwin Agreed on the un-helpfulness of the messages. I can confirm, those are the "standard" messages from the rest of the APIs but I think its worth cleaning them up in this PR as an example of what we'd like to see. I will ping you again once I have that fixed up.
I suspect you have |
For most situations, wallets depend on |
Would be better if the response format was not mixing types (to match the request format and avoid clients having to do typechecking on responses). E.g. {
"accounts" : [
{
"account_name" : "",
"permission_name" : "",
"authorizer_key": "PUB_...",
"authorizer_auth": null.
"weight" : 1,
"threshold": 1
}
]
} |
My assumption is that you are asking for the I think that is a fine change. Can others on this thread weigh in with a 👍 or 👎 ? |
Guys, this is a great feature, must have for wallet developers! Especially get_key_accounts method to get all associated accounts with a specific public key without history plugin or state_history_plugin. |
…unt` so that the type of the field can be inferred by the name of the field
Updated to include the response suggestion from @jnordberg |
…eed for the reading thread to access the chain data completely
/** | ||
* Allow moving the account query DB (including by assignment) | ||
*/ | ||
account_query_db(account_query_db&&); |
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.
Not implemented. Also I doubt the operator= is used, I think you should remove them.
…required. Consider moving this to an atomic high-watermark
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.
One or two required changes and several suggestions.
plugins/chain_plugin/include/eosio/chain_plugin/account_query_db.hpp
Outdated
Show resolved
Hide resolved
… concrete alias pattern, added extra error checking to parsing accounts that ensures no extraneous keys are allowed and that the actor must be present if it is an object, fixed other typos etc
Account Query DB : maintain get_(key|controlled)_accounts develop version ported from #8899
Account Query DB : maintain get_(key|controlled)_accounts port to develop from #8899
Account Query DB maintain get_(key|controlled)_accounts port to develop from #8899
Account Query DB : maintain get_(key|controlled)_accounts port to develop from #8899
Change Description
This is a proposed optional addition to
chain_plugin
andchain_api_plugin
that provides a superset of the deprecatedhistory_api_plugin
'sget_key_accounts
andget_controlled_accounts
RPC methods. While we have many other solutions covering the history access that thehistory_api_plugin
provided, none easily covered this use case for wallets and other end-users.This solution builds the associated indices on start-up and, as a result, does not suffer from the brittle issues that the
history_api_plugin
had. It also means it can be added to or removed from any operatingnodeos
at any time. This does impose a penalty on start-up times.Timings on a modest cloud VM* indicated that these indices can be built for a node synced with the EOS Public Network @ block 113060000 in about 15-20 seconds. Note: this penalty is only imposed if the Account Query DB is enabled (see below).
The solution will watch the chain as it processes and update the indices accordingly. This process has minimal overhead on the operating node.
*modest VM had 2x 2.0-2.2 gHz vCPUs
API Changes
POST /v1/chain/get_accounts_by_authorizers
This is the single endpoint that produces a superset of the information provided by
get_key_accounts
andget_controlled_accounts
.Request format
The basic request payload is the following JSON:
Account entries that are only account names have an implicit wildcard permission which matches any permission level from that account. This can be explicitly set to an empty string or a specific permission level. For instance:
will list all accounts authorized in part or whole by
eosio
whereas:will only list accounts authorized specifically by
[email protected]
Omitting
accounts
orkeys
indicates that those arrays would be empty if explicit.Response format
The basic response format is the following JSON:
Porting Hints
get_key_accounts
becomes:
get_controlled_accounts
becomes:
Batch fetches
In addition to single value queries, you can add as many account names or public keys to the request as needed. The result will be the union of all the individual responses saving time when determining a set of accounts from various authorization materials.
Consensus Changes
Documentation Additions
--enable-account-queries
default: false
Boolean that indicates whether the Account Query DB should be initialized at start-up and maintained for the life of this instance. if set to
true
then the RPC endpoint for/v1/chain/get_accounts_by_authorizers
will be registered otherwise it will not be present and requests to that endpoint will return404
errors.