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

refactor: optimize some checks on upd_price #403

Merged
merged 2 commits into from
May 13, 2024

Conversation

ali-bahjati
Copy link
Collaborator

@ali-bahjati ali-bahjati commented May 13, 2024

  • Remove rent check because it costs 500CU (+10% of upd_price without aggregate) and it really is not needed.
  • Use abs() on checking confidence threshold because it's incredibly slow on negative prices (2000CU). We don't have negative prices but will guard us in the future.

- Remove rent check on hot code path because it costs 500CU and
  add/remove instructions take care of it.
- Use abs() on checking confidence threshold because it's incredibly
  slow on negative prices (2000CU). We don't have negative prices
  but will guard us in the future.
@ali-bahjati ali-bahjati requested review from jayantk, guibescos and Reisen and removed request for jayantk and guibescos May 13, 2024 15:25
jayantk
jayantk previously approved these changes May 13, 2024
@@ -123,7 +123,7 @@ pub fn upd_price(
}?;

check_valid_funding_account(funding_account)?;
check_valid_writable_account(program_id, price_account)?;
check_valid_writable_account_without_rent_check(program_id, price_account)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmmmm what about removing the rent check everywhere? I think the check is not useful anywhere

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is introducing more complexity

@ali-bahjati ali-bahjati force-pushed the optimize/optimize-checks branch from d8be0a7 to 2996b13 Compare May 13, 2024 18:36
@ali-bahjati ali-bahjati merged commit 9acf172 into main May 13, 2024
3 checks passed
@ali-bahjati ali-bahjati deleted the optimize/optimize-checks branch May 13, 2024 18:50
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

Successfully merging this pull request may close these issues.

3 participants