-
Notifications
You must be signed in to change notification settings - Fork 16
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: get_children_ids_recursive #80
feature: get_children_ids_recursive #80
Conversation
@Tguntenaar You can use this method https://docs.rs/near-sdk/latest/near_sdk/test_utils/struct.VMContextBuilder.html#method.prepaid_gas to
For example:
|
@Tguntenaar 300T gas is the maximum allowed on near blockchain, so check if you hit a infinite or too expensive recursion |
@ailisp @frol , it isn't solely related to the recursive function itself. Even excluding it from the unit test, attempting to add just a few posts still results in exceeding the gas limit. I will replace the recursive function with an iterative version to be sure. The thing with the I could be wrong and missing something in which case please let me know. PS So that's why I just made two more contexts to reset the gas to the limit. I think it would be a better solution to refactor the contextbuilder a bit to be able to add gass to the context in contract calls. Another thing is we could limit the amount |
@Tguntenaar good findings! In fact, you can create another context object after gas use up (to get another 300 T gas). So this way you can create arbitrary number of posts.
This is a brilliant idea! We would want to figure out the number "99" or more here. Could you experiment it a bit, for example, get_all_children_ids with 10 child posts, 20 child posts, 100 child posts. And count the gas usage. Then further add 10 posts each with 10 children posts. We can estimate a rough gas usage to get_all_children_ids in this case. Say, if the result is quite little gas even for hundreds of post, we are not bothered to limit the number. Otherwise you can figure out a safe limit like "99" or so. |
Alright I will find out the gas price based on the depth. |
I'm closing this PR because @frol made this comment: I suggest we don't invest any more time into old style posts / notifications / nested comments / kanban boards since proposals and announcements will fix many of the issues by design or will require rethinking of the approach. |
Resolves #11
@frol @ailisp if I add more posts to the test the gas limit exceeds. How can I add a significant number of posts and prevent exceeding the gas limit in the 'test_get_children_ids_recursive' function?