-
Notifications
You must be signed in to change notification settings - Fork 249
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
chore: replace expect
calls
#1220
Conversation
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.
4kb is already not too bad. I have spotted a few more potential improvements that could further drop the size. I believe that if we manage to avoid all instances of string formatting (.expect
uses formatting under the hood to include the source file name and line of code), we could see a major drop in size, but for that someone would need to check the produced Wasm file static strings and identify how we can avoid those.
As a rule of thumb, panic_any
should not be used here. We should either use near_sdk::env::panic_str
or otherwise it is an indicator that .expect
is not going to be part of Wasm file anyway.
near-sdk-macros/src/core_impl/code_generator/impl_item_method_info.rs
Outdated
Show resolved
Hide resolved
Ok(deserialized) => deserialized, | ||
Err(_) => near_sdk::env::panic_str("Failed to deserialize input from JSON.") | ||
}, | ||
None => near_sdk::env::panic_str("Expected input since method has arguments.") |
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.
Please, use fully-qualified syntax here (add ::
in the beginning) since this code is generated into the user code and we want to avoid an unexpected aliasing:
None => near_sdk::env::panic_str("Expected input since method has arguments.") | |
None => ::near_sdk::env::panic_str("Expected input since method has arguments.") |
P.S. Apply this change in other places where applicable (in near-sdk-marcos)
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.
Please, revert 8296a73, it is not helping us.
Can you provide the size changes for adder and fungible token contracts after all the changes (after you address my above comments)?
near-sdk-macros/src/core_impl/code_generator/snapshots/callback_args.snap
Outdated
Show resolved
Hide resolved
hey @frol here is the report, let me know if the pr need further fix
|
near-sdk-macros/src/core_impl/code_generator/snapshots/callback_args_vec.snap
Outdated
Show resolved
Hide resolved
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.
@TropicalDog17 Please, address the review comment and fix the issues reported by CI.
8f60c9d
to
23d7ca0
Compare
b15ba77
to
b872a33
Compare
@frol I've fixed based on your review. About the failing CI it seems it also fails on |
Yeah, I created an issue for that: #1223 |
@TropicalDog17 Sorry for jumping in, I'd like to invite you to participate in the Race of Sloths. Just mention @race-of-sloths user in your GitHub comment or PR description to join! See how the flow works here: NEAR-DevHub/neardevhub-bos#910 |
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.
@TropicalDog17 Thanks for working on it! I think this is already good enough
@race-of-sloths score 3
@TropicalDog17 Thank you for your contribution! Your pull request is now a part of the Race of Sloths! Current status: executed
The average score is 3 @TropicalDog17 check out your results on the Race of Sloths Leaderboard! and in the profile What is the Race of SlothsRace of Sloths is a friendly competition where you can participate in challenges and compete with other open-source contributors within your normal workflow For contributors:
For maintainers:
Feel free to check our website for additional details! Bot commands
|
🔄 The PR has been merged.Important This pull request is a part of the Race of Sloths and has not been scored yet. Scoring will close in 24 hours! 🕰️ |
@race-of-sloths score 3 |
🌟 Score recorded!@frol, thank you for scoring this pull request in the Race of Sloths! |
✅ PR is finalized!Your contribution is much appreciated with a final score of 3! Another weekly streak completed, well done @TropicalDog17! To keep your weekly streak and get another bonus make pull request next week! Looking forward to see you in race-of-sloths |
Resolves #746