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

Endpoint /account/:accountId/data/:keyPattern returns inconsistent data and iterator doesn't work #13

Open
arrusev opened this issue Jul 24, 2023 · 5 comments

Comments

@arrusev
Copy link

arrusev commented Jul 24, 2023

I'm trying to fetch the most recent state of priceoracle.testnet contract but the response differs from the one that RPC request returns.

How to reproduce:

  1. Make RPC call
  • Request:
curl --location --request POST 'https://rpc.testnet.near.org' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "id": "dontcare",
    "method": "query",
    "params": {
        "request_type": "view_state",
        "finality": "final",
        "account_id": "priceoracle.testnet",
        "prefix_base64": "U1RBVEU=" -> "STATE" in base64
    }
}'
  • Response:
[
    {
        "key": "U1RBVEU=",
        "value": "AgAAAABpBAAAAAAAAAACAAAAAGsEAAAAAAAAAAIAAAAAdgIAAAABaQoAAAAAAAAAAgAAAAFrCgAAAAAAAAACAAAAAXZaAAAAEwAAAHByaWNlb3JhY2xlLnRlc3RuZXQAAAAlpAAKi8oiBAAAAAAA"
    }
]
  1. Make Fast-Near HTTP call:
  • Request:
curl --location --request GET 'https://rpc.web4.testnet.page/account/priceoracle.testnet/data/STATE?encoding=base64'
  • Response:
{
    "data":
    [
     ..996 elements
    ],
    "iterator": "02643a70726963656f7261636c652e746573746e65743a535441544507e78d04"
}
  1. Compare the results:
    The value AgAAAABpBAAAAAAAAAACAAAAAGsEAAAAAAAAAAIAAAAAdgIAAAABaQoAAAAAAAAAAgAAAAFrCgAAAAAAAAACAAAAAXZaAAAAEwAAAHByaWNlb3JhY2xlLnRlc3RuZXQAAAAlpAAKi8oiBAAAAAAA returned from the RPC call is missing within Fast-Near's response.

Also i've tried to supply the iterator param in order to fetch the next page but the response is 1:1 the same as without iterator(it seems like the response is cached but not refetched).

https://rpc.web4.testnet.page/account/priceoracle.testnet/data/STATE?encoding=base64&iterator=02643a70726963656f7261636c652e746573746e65743a535441544507e78d04

@vgrichina
Copy link
Collaborator

/data endpoint still needs some work to work as expected

e.g. this change has been deployed only recently 50f9fce and I don't think testnet RPC is up to date with it

there might need to be some caching changes as well

I think only contract calls / account views have been tested extensively so far

@arrusev may you give more details on what's your use case for fetching state vs calling contract?

@vgrichina
Copy link
Collaborator

I think even with 50f9fce there are more issues with contracts which have a lot of state changes for single key – I'm gonna prepare few more improvements to get it work

but basically main reason that /data is not in readme is because it's not quire ready as is

@arrusev
Copy link
Author

arrusev commented Jul 27, 2023

we want to extend the near-api-js library to be able to execute contract functions locally, instead of calling RPC provider.

We face some issues with states bigger than 50kb and in that case, we want to use fast-near API to retrieve the whole contract state

@vgrichina
Copy link
Collaborator

@arrusev are you still working on this?

@arrusev
Copy link
Author

arrusev commented Feb 28, 2024

@arrusev are you still working on this?

I am personally not involved in this anymore but other people are working on stuff related to near-api-js. @vikinatora , @gtsonevv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants