-
Notifications
You must be signed in to change notification settings - Fork 93
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
Feature: Add support for unlimited assets. #900
Conversation
* Ledger refactoring changes. * Move some of the preloading logic to accounting/. * Use setResourcesReq(). * Some renaming. * Add comments to ledger_for_evaluator.LookupResources(). * Encode state proof id.
#896) * backwards-compatible JSON encodings for account data * update encoding test for new field names * CR fixes * CR fix b
Adds new REST endpoints and "exclude" parameter for account information endpoint, similar to algorand/go-algorand#3542. Relies on #870 Update endpoint: GET /v2/accounts/{address} Supports new query parameter “exclude”, which can be a combination of all, created-apps, created-assets, apps-local-state, assets Removes empty “creator” string from AssetHolding type — was not implemented (removed associated TODO) Update endpoint: GET /v2/assets/{asset-id}/balances Remove "round" query parameter — I noticed support is not implemented, and the parameter was being ignored New endpoints: GET /v2/accounts/{address}/created-apps GET /v2/accounts/{address}/created-assets GET /v2/accounts/{address}/assets GET /v2/accounts/{address}/apps-local-state Supported query parameters: asset-id / application-id (look up a single asset), include-all (include deleted), limit, next (for pagination)
…#901) * REST API: count include-all results when checking max resources limit * update TestValidate for removed round param * move countOnly to function argument rather than polluting idb interface
Codecov Report
@@ Coverage Diff @@
## develop #900 +/- ##
===========================================
+ Coverage 57.94% 58.93% +0.98%
===========================================
Files 40 42 +2
Lines 4713 5720 +1007
===========================================
+ Hits 2731 3371 +640
- Misses 1646 1902 +256
- Partials 336 447 +111
Continue to review full report at Codecov.
|
@@ -455,9 +651,6 @@ | |||
{ | |||
"$ref": "#/parameters/next" | |||
}, | |||
{ | |||
"$ref": "#/parameters/round" |
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.
Will this impact sdk backwards compatibility? Is this removed for both algod and indexer? Please comment.
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.
Yes, anyone who was providing this argument with an SDK will have a compilation error, and anyone who was using without the SDK will receive a 400 (since the backend will not know what "round" is for). After talking with @winder and @algoanne I believe this is preferable to the current behavior — where the round parameter is being silently ignored, the latest round's data is returned, but the caller thinks they are getting a historical value from an old round.
"creator": { | ||
"description": "Address that created this asset. This is the address where the parameters for this asset can be found, and also the address where unwanted asset units can be sent in the worst case.", | ||
"type": "string" | ||
}, |
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.
Will this impact sdk backwards compatibility? Please comment.
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.
Yes, similarly, if anyone was expecting this value using the SDK it will no longer compile. However, this value was always being returned as an empty string and was never implemented. So anyone who has ever written code that retrieved this field should have already found it empty and useless, and likely was not depending on it.
I would like to suggest a change in the new implementation of Reason: Assuming most of users won't have a lot of opted-in assets/apps, any UI like wallets would be able to fill the whole information with just one call to the backend. If an error is returned, the UI must call the endpoint with exclude all and then the new apis (one for each type of information they want to retrieve) in order to get the first page of assets/apps they use. |
We were concerned that for backwards compatibility reasons, giving callers a "trimmed down" account for some cases, but a full one in others, would leave them with the false impression that the account was empty, especially if they were using an older SDK. Since most users won't have a lot of opted-in assets, like you said the error case is rare, but clear. Optimizing the number of calls for the rare error case wasn't a priority when we talked this through. One hope we had, and considered making a requirement, was that developers would adopt exclude=all everywhere, and then only pull information about assets/apps when truly necessary. This would be the most error-proof / future-proof way to look up account information and saves the indexer a lot of unnecessary work. For those that choose not to adopt exclude=all for their initial lookup (e.g. to check counts of opted-in assets/apps) and are willing to "risk" an optimistic exclude=none, do you think it is too onerous to have them implement the 400, then re-request flow? It is just one more call, for what should be a rare occurrence. |
Oh I re-read. So an extra flag that says "give me a trimmed version if it goes over the limit." I guess that is "exclude=sometimes" |
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.
Aside from the merge conflict, this still looks good!
* use ErrorResponse instead of AccountsErrorResponse * update for ErrorResponse format in tests * remove unnecessary pointers from preparing ErrorResponse
Summary
Companion updates for algorand/go-algorand#3652
Adds new REST endpoints and "exclude" parameter for account information endpoint, similar to algorand/go-algorand#3542.
Update endpoint: GET /v2/accounts/{address}
all
,created-apps
,created-assets
,apps-local-state
,assets
,none
Update endpoint: GET /v2/assets/{asset-id}/balances
New endpoints:
GET /v2/accounts/{address}/created-apps
GET /v2/accounts/{address}/created-assets
GET /v2/accounts/{address}/assets
GET /v2/accounts/{address}/apps-local-state
Test Plan
New tests added, existing tests should pass.