curaOS / source

Start a solid foundation of tools for creators+builders.
https://cura.run
15 stars 13 forks source link

Gas issue while calling nft_tokens #57

Closed bestatigen closed 2 years ago

bestatigen commented 3 years ago

I noticed that if I was trying to fetch too many NFTs I would get an error about exceeding the allowed gas amount. Besides paging, which has to be implemented anyway at some point, I would rather take this occasion to figure out if I'm packing too much data in one NFT and if that should be separated from the NFT details, so that you can retrieve more objects with one request and fetch the other Metadata details only if necessary.

bestatigen commented 2 years ago

It's 100 Tgasnow; increasing to 300 should fix for now.

sekaiking commented 2 years ago

I don't think this is still a problem. I executed nft_tokens as a view method, it returns all NFTs (9 in total) and it doesn't even use any gas

Command tested:

near view 0.share-nft.testnet nft_tokens
bestatigen commented 2 years ago

Just tried the same command @achrafismyname:

near view 0.share-nft.testnet nft_tokens

and the result points out to not enough gas:

View call: 0.share-nft.testnet.nft_tokens()
An error occured
Error: Querying [object Object] failed: wasm execution failed with error: FunctionCallError(HostError(GasLimitExceeded)).
{
  "block_hash": "4qFDb5927AjHnkuBrZ7hj7CQWSf74BPAwXMKV7eoWuaE",
  "block_height": 71459760,
  "error": "wasm execution failed with error: FunctionCallError(HostError(GasLimitExceeded))",
  "logs": []
}
sekaiking commented 2 years ago

Hey @devey, I forgot to mention this I found the limit to be 8. It was working before without limit because there was less than 9 NFTs in the contract. Try this and it will work

near view 0.share-nft.testnet nft_tokens '{"from_index":"0","limit":8}'

How many NFTs per call would be good enough for our projects?

bestatigen commented 2 years ago

@achrafismyname I think we'll be able to have more once we separate storage of Metadata from storage of Tokens. Wrote it down in #135. Will close this.